From 5796470981db83423a56d29bf70fd5ab4beb343e Mon Sep 17 00:00:00 2001 From: Chris Pacia Date: Fri, 5 Apr 2019 20:55:18 -0400 Subject: [PATCH] Add rescan settings preference --- .../android_neutrino/DialogPreference.java | 10 +++++++ .../android_neutrino/SettingsFragment.java | 26 ++++++++++++++++++ .../bchd/android_neutrino/wallet/Wallet.java | 6 ++++ app/src/main/res/drawable/rescan.png | Bin 0 -> 1306 bytes .../main/res/drawable/rescan_icon_small.xml | 10 +++++++ app/src/main/res/xml/preferences.xml | 6 ++++ 6 files changed, 58 insertions(+) create mode 100644 app/src/main/java/cash/bchd/android_neutrino/DialogPreference.java create mode 100644 app/src/main/res/drawable/rescan.png create mode 100644 app/src/main/res/drawable/rescan_icon_small.xml diff --git a/app/src/main/java/cash/bchd/android_neutrino/DialogPreference.java b/app/src/main/java/cash/bchd/android_neutrino/DialogPreference.java new file mode 100644 index 0000000..c33dd40 --- /dev/null +++ b/app/src/main/java/cash/bchd/android_neutrino/DialogPreference.java @@ -0,0 +1,10 @@ +package cash.bchd.android_neutrino; + +import android.content.Context; +import android.util.AttributeSet; + +public class DialogPreference extends android.support.v7.preference.DialogPreference { + public DialogPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } +} \ No newline at end of file diff --git a/app/src/main/java/cash/bchd/android_neutrino/SettingsFragment.java b/app/src/main/java/cash/bchd/android_neutrino/SettingsFragment.java index 90016e1..acd4538 100644 --- a/app/src/main/java/cash/bchd/android_neutrino/SettingsFragment.java +++ b/app/src/main/java/cash/bchd/android_neutrino/SettingsFragment.java @@ -1,9 +1,11 @@ package cash.bchd.android_neutrino; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import com.takisoft.fix.support.v7.preference.EditTextPreference; +import android.support.v7.app.AlertDialog; import android.support.v7.preference.Preference; import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompat; import android.support.v7.preference.PreferenceScreen; @@ -278,4 +280,28 @@ public boolean onPreferenceChange(Preference preference, Object o) { activeScreen = "encryption"; } } + + @Override + public void onDisplayPreferenceDialog(Preference preference) { + if (preference.getKey().equals("rescan")) { + AlertDialog.Builder alert = new AlertDialog.Builder(getContext()); + alert.setTitle("Rescan"); + + alert.setMessage("Rescan from wallet birthday?"); + alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + // Canceled. + } + }); + alert.setPositiveButton("OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + wallet.rescan(); + } + }); + alert.setCancelable(true); + alert.show(); + } else { + super.onDisplayPreferenceDialog(preference); + } + } } \ No newline at end of file diff --git a/app/src/main/java/cash/bchd/android_neutrino/wallet/Wallet.java b/app/src/main/java/cash/bchd/android_neutrino/wallet/Wallet.java index 12d250d..9176ebc 100644 --- a/app/src/main/java/cash/bchd/android_neutrino/wallet/Wallet.java +++ b/app/src/main/java/cash/bchd/android_neutrino/wallet/Wallet.java @@ -375,6 +375,12 @@ public long balance() throws Exception { return reply.getSpendable(); } + public void rescan() { + WalletServiceGrpc.WalletServiceBlockingStub stub = WalletServiceGrpc.newBlockingStub(this.channel).withCallCredentials(this.creds); + Api.RescanRequest request = Api.RescanRequest.newBuilder().build(); + stub.rescan(request); + } + public boolean validateAddress(String addr) throws Exception { WalletServiceGrpc.WalletServiceBlockingStub stub = WalletServiceGrpc.newBlockingStub(this.channel).withCallCredentials(this.creds); Api.ValidateAddressRequest request = Api.ValidateAddressRequest.newBuilder().setAddress(addr).build(); diff --git a/app/src/main/res/drawable/rescan.png b/app/src/main/res/drawable/rescan.png new file mode 100644 index 0000000000000000000000000000000000000000..9aa983d10f0bd7a2bfb38a7f27e8f60ba668faa1 GIT binary patch literal 1306 zcmZ8heN<9s7{3wV>Uq!eJiqgMpWpMmf4uLD z=cuxyBe{_f1Vv*g$Rl$wecw!a~Dl+Dg1ww?dC;-B;cWMPNDH9-U z0;P%%aVEW7dTjgeI~3=^-A?_nI^VO86V+_OH$B)A;d?Ju95>pl?bejk&K=^bbBR>! zM=jy4MY*n3{eBH-ii9Vo{?w8Vd(Eg(EoONSfWD|Q*J1s$S*!l6soVcY+HsdBCrMyU zn0oN!?x2i7fzahh$&RixJ&~su=wYw?x1#LEd{@IWTBVWmaMQ+0(^#Y-nl*gC1G zcXXd71#4OcW0@V7RieqvKo4KcAIz83*BCw#wfB6vJaG#^2n`bKZ6weY6Je=9;?{_- zC9nb;M~Iy!B>w{@BhPTB$1PtP!%4gVs|&;{XCCWB|4F}ey}Z48ZoYUJYCW)!l7cv#xB`$!-P z2_ump{uoXj$qA_GW^xpj8E_hBs<(&3jOl4e7@*w7TT3oan=3_5{zC_+772U(Q}|W~ z(*+(iR~?ASlJIl_N#VkNk8%pkIKmHJaAb+>Q~{h^y7%o#)`Yy4pDj1V?{+S3J*a-% z^6--Kaf>!tEJI{mR=|>tjEn2*h|yo?6UoADZe3ubWK@pG>jXji!$a$IYY5a6i3z9K zP;O?+<_$-a>en=W4Z5$~=xa0UeP4l<{^EEze}@*=@7;gEG#(q_Egx#Op|?wwk`=QM z-Im(#Oa;ba#y!?c)BHyie5 z3F@1%xhCaK@<}WRbe)!4t|RMfe8Gu}$V;qLKV9!?7#e(#laz*CNy~8Tw3N0P^2!RT z6@X&5P{j*uI2xbW9pfZ1i&5d@vk9p?oP>HU?|*RAYi#p>1>GfB*Da}T3{DNSN + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 0822e8e..6fff655 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -62,6 +62,12 @@ android:icon="@drawable/key_icon_small" app:summary="Decrypt wallet and return to unencrypted state."/> + +