Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@
android:configChanges="keyboardHidden|orientation|uiMode"
android:launchMode="singleTop" />

<activity android:name=".activities.PoliteiaWelcomeActivity"
android:configChanges="keyboardHidden|orientation|uiMode"
android:launchMode="singleTop" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
Expand Down
25 changes: 10 additions & 15 deletions app/src/main/java/com/dcrandroid/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,15 @@ class HomeActivity : BaseActivity(), SyncProgressListener, TxAndBlockNotificatio
override fun onProposalsSynced() {
}

private val isEnablePoliteiaNotification: Boolean
get() = multiWallet!!.readBoolConfigValueForKey(
Dcrlibwallet.PoliteiaNotificationConfigKey, false
) && multiWallet!!.readBoolConfigValueForKey(
Constants.GOVERNANCE_SETTING, false
)

override fun onNewProposal(proposal: Proposal) {
if (multiWallet!!.readBoolConfigValueForKey(
Dcrlibwallet.PoliteiaNotificationConfigKey,
false
)
) {
if (isEnablePoliteiaNotification) {
Utils.sendProposalNotification(
this,
notificationManager,
Expand All @@ -500,11 +503,7 @@ class HomeActivity : BaseActivity(), SyncProgressListener, TxAndBlockNotificatio
}

override fun onProposalVoteStarted(proposal: Proposal) {
if (multiWallet!!.readBoolConfigValueForKey(
Dcrlibwallet.PoliteiaNotificationConfigKey,
false
)
) {
if (isEnablePoliteiaNotification) {
Utils.sendProposalNotification(
this,
notificationManager,
Expand All @@ -515,11 +514,7 @@ class HomeActivity : BaseActivity(), SyncProgressListener, TxAndBlockNotificatio
}

override fun onProposalVoteFinished(proposal: Proposal) {
if (multiWallet!!.readBoolConfigValueForKey(
Dcrlibwallet.PoliteiaNotificationConfigKey,
false
)
) {
if (isEnablePoliteiaNotification) {
Utils.sendProposalNotification(
this,
notificationManager,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2018-2021 The Decred developers
* Use of this source code is governed by an ISC
* license that can be found in the LICENSE file.
*/

package com.dcrandroid.activities

import android.content.Intent
import android.os.Bundle
import com.dcrandroid.R
import com.dcrandroid.activities.more.PoliteiaActivity
import com.dcrandroid.data.Constants
import com.dcrandroid.dialog.InfoDialog
import kotlinx.android.synthetic.main.activity_politeia_welcome.*

class PoliteiaWelcomeActivity: BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_politeia_welcome)
iv_info.setOnClickListener {
InfoDialog(this)
.setDialogTitle(getString(R.string.governance))
.setMessage(getString(R.string.politeia_welcome_info))
.setPositiveButton(getString(R.string.got_it), null)
.show()
}
btn_fetch_proposals.setOnClickListener {
multiWallet?.setBoolConfigValueForKey(Constants.HAS_SHOW_POLITEIA_WELCOME, true)
startActivity(Intent(this, PoliteiaActivity::class.java))
finish()
}
go_back.setOnClickListener {
finish()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
package com.dcrandroid.activities.more

import android.os.Bundle
import android.view.View
import android.view.ViewTreeObserver
import com.dcrandroid.R
import com.dcrandroid.activities.BaseActivity
import com.dcrandroid.data.Constants
import com.dcrandroid.extensions.hide
import com.dcrandroid.extensions.show
import com.dcrandroid.extensions.toggleVisibility
import com.dcrandroid.fragments.PasswordPinDialogFragment
import com.dcrandroid.preference.EditTextPreference
import com.dcrandroid.preference.ListPreference
Expand Down Expand Up @@ -47,6 +49,17 @@ class SettingsActivity : BaseActivity(), ViewTreeObserver.OnScrollChangedListene
Dcrlibwallet.PoliteiaNotificationConfigKey,
enable_politeia_notification
)
SwitchPreference(
this,
Constants.GOVERNANCE_SETTING,
enable_governance
) { isOn ->
enable_politeia_notification.visibility = if (isOn) View.VISIBLE else View.GONE
return@SwitchPreference isOn
}

enable_politeia_notification.visibility =
if (multiWallet?.readBoolConfigValueForKey(Constants.GOVERNANCE_SETTING, false) == true) View.VISIBLE else View.GONE

enableStartupSecurity = SwitchPreference(
this,
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/dcrandroid/data/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public class Constants {
VOTE_SUMMARY = "votesummary",
COLOR_THEME = "color_theme",
MIXED = "mixed",
UNMIXED = "unmixed";
UNMIXED = "unmixed",
HAS_SHOW_POLITEIA_WELCOME = "has_show_politeia_welcome",
GOVERNANCE_SETTING = "governance_setting";

public static final int TRANSACTION_SUMMARY_ID = 5552478,
PROPOSAL_SUMMARY_ID = 5552479,
Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/com/dcrandroid/fragments/more/MoreFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.dcrandroid.R
import com.dcrandroid.activities.PoliteiaWelcomeActivity
import com.dcrandroid.activities.more.*
import com.dcrandroid.data.Constants
import com.dcrandroid.fragments.BaseFragment
import kotlinx.android.synthetic.main.fragment_more.*

Expand All @@ -31,7 +33,9 @@ class MoreFragment : BaseFragment() {
super.onActivityCreated(savedInstanceState)

setToolbarTitle(R.string.more, false)

val hasShowPoliteiaWelcome =
multiWallet?.readBoolConfigValueForKey(Constants.HAS_SHOW_POLITEIA_WELCOME, false)
?: false
val items = arrayOf(
ListItem(
R.string.settings,
Expand All @@ -46,7 +50,10 @@ class MoreFragment : BaseFragment() {
ListItem(
R.string.politeia,
R.drawable.ic_politeia,
Intent(context, PoliteiaActivity::class.java)
Intent(
context,
if (hasShowPoliteiaWelcome) PoliteiaActivity::class.java else PoliteiaWelcomeActivity::class.java
)
),
ListItem(
R.string.help,
Expand Down
49 changes: 49 additions & 0 deletions app/src/main/res/drawable/ic_governance.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="92dp"
android:height="92dp"
android:viewportWidth="92"
android:viewportHeight="92">
<group>
<clip-path
android:pathData="M0.6665,0.6667h90.6667v90.6667h-90.6667z"/>
<path
android:pathData="M91.3332,85.6667H0.6665V91.3334H91.3332V85.6667Z"
android:fillColor="#091440"/>
<path
android:pathData="M80.2267,74.3335H12V80.0002H80.2267V74.3335Z"
android:fillColor="#091440"/>
<path
android:pathData="M0.6665,23.3334V29.0001H91.3332V23.3334L45.9998,0.6667L0.6665,23.3334Z"
android:fillColor="#091440"/>
<path
android:pathData="M20.3867,34.6667H12V46.0001H20.3867V34.6667Z"
android:fillColor="#091440"/>
<path
android:pathData="M80.0001,34.6667H71.3867V46.0001H80.0001V34.6667Z"
android:fillColor="#091440"/>
<path
android:pathData="M65.04,34.6667H56.6533V46.0001H65.04V34.6667Z"
android:fillColor="#091440"/>
<path
android:pathData="M50.08,34.6667H41.6934V46.0001H50.08V34.6667Z"
android:fillColor="#091440"/>
<path
android:pathData="M35.3467,34.6667H26.7334V46.0001H35.3467V34.6667Z"
android:fillColor="#091440"/>
<path
android:pathData="M20.3867,46H12V68.6667H20.3867V46Z"
android:fillColor="#C4CBD2"/>
<path
android:pathData="M80.0001,46H71.3867V68.6667H80.0001V46Z"
android:fillColor="#C4CBD2"/>
<path
android:pathData="M65.04,46H56.6533V68.6667H65.04V46Z"
android:fillColor="#C4CBD2"/>
<path
android:pathData="M50.08,46H41.6934V68.6667H50.08V46Z"
android:fillColor="#C4CBD2"/>
<path
android:pathData="M35.3467,46H26.7334V68.6667H35.3467V46Z"
android:fillColor="#C4CBD2"/>
</group>
</vector>
152 changes: 152 additions & 0 deletions app/src/main/res/layout/activity_politeia_welcome.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2018-2021 The Decred developers
~ Use of this source code is governed by an ISC
~ license that can be found in the LICENSE file.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical"
android:gravity="center_horizontal"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:id="@+id/app_bar"
app:elevation="0dp"
android:background="@color/background"
android:theme="@style/AppTheme.AppBarOverlay">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="0dp"
android:paddingLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetLeft="0dp"
android:paddingEnd="0dp"
android:paddingRight="0dp"
app:contentInsetEnd="0dp"
app:contentInsetRight="0dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="@dimen/margin_padding_size_8"
android:paddingEnd="0dp"
android:orientation="horizontal"
android:gravity="center_vertical">

<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="@dimen/margin_padding_size_8"
android:background="@drawable/circular_surface_ripple"
android:focusable="true"
android:clickable="true"
android:id="@+id/go_back"
app:srcCompat="@drawable/ic_back" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/governance"
android:textSize="@dimen/edit_text_size_20"
android:layout_marginStart="@dimen/margin_padding_size_8"
android:textColor="@color/text1"
android:includeFontPadding="false"
app:fontFamily="@font/source_sans_pro" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end">

<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="@+id/iv_info"
android:padding="@dimen/margin_padding_size_8"
app:srcCompat="@drawable/ic_info"
android:focusable="true"
android:clickable="true"
android:background="@drawable/circular_surface_ripple" />

</LinearLayout>

</LinearLayout>

</androidx.appcompat.widget.Toolbar>

</com.google.android.material.appbar.AppBarLayout>

<ImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginTop="@dimen/margin_padding_size_24"
android:src="@drawable/ic_governance" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingStart="@dimen/margin_padding_size_24"
android:paddingEnd="@dimen/margin_padding_size_24"
android:layout_marginTop="@dimen/margin_padding_size_24"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/how_does_governance_work"
android:textSize="@dimen/edit_text_size_20"
android:textColor="@color/text1"
android:fontFamily="@font/source_sans_pro_semibold"
android:gravity="center" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/politeia_community_info"
android:textSize="@dimen/edit_text_size_16"
android:textColor="@color/text1"
android:fontFamily="@font/source_sans_pro"
android:layout_marginTop="@dimen/margin_padding_size_16"
android:gravity="start" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/politeia_stakeholders_info"
android:textSize="@dimen/edit_text_size_16"
android:textColor="@color/text1"
android:fontFamily="@font/source_sans_pro"
android:layout_marginTop="@dimen/margin_padding_size_16"
android:gravity="start" />

</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/surface"
android:padding="@dimen/margin_padding_size_16"
android:gravity="center_horizontal">

<TextView
android:id="@+id/btn_fetch_proposals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/margin_padding_size_16"
android:paddingBottom="@dimen/margin_padding_size_16"
style="@style/textViewButton"
android:text="@string/fetch_proposals"
android:textSize="@dimen/edit_text_size_18" />

</RelativeLayout>
</LinearLayout>
Loading