Skip to content

Commit bf1829f

Browse files
authored
PocketChange (#901)
1 parent bc4aa0f commit bf1829f

File tree

64 files changed

+1179
-320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1179
-320
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.m2049r.xmrwallet"
99
minSdkVersion 21
1010
targetSdkVersion 31
11-
versionCode 3200
12-
versionName "3.2.0 'Decoy Selection'"
11+
versionCode 3307
12+
versionName "3.3.7 'Pocket Change'"
1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
externalNativeBuild {
1515
cmake {

app/src/main/cpp/monerujo.cpp

Lines changed: 177 additions & 18 deletions
Large diffs are not rendered by default.

app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,11 @@ private void showNet(NetworkType net) {
658658
break;
659659
case NetworkType_Testnet:
660660
toolbar.setSubtitle(getString(R.string.connect_testnet));
661-
toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark));
661+
toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, androidx.appcompat.R.attr.colorPrimaryDark));
662662
break;
663663
case NetworkType_Stagenet:
664664
toolbar.setSubtitle(getString(R.string.connect_stagenet));
665-
toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark));
665+
toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, androidx.appcompat.R.attr.colorPrimaryDark));
666666
break;
667667
default:
668668
throw new IllegalStateException("NetworkType unknown: " + net);

app/src/main/java/com/m2049r/xmrwallet/TxFragment.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public TxFragment() {
7979
private TextView tvTxPaymentId;
8080
private TextView tvTxBlockheight;
8181
private TextView tvTxAmount;
82+
private TextView tvTxPocketChangeAmount;
8283
private TextView tvTxFee;
8384
private TextView tvTxTransfers;
8485
private TextView etTxNotes;
@@ -116,6 +117,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
116117
tvTxPaymentId = view.findViewById(R.id.tvTxPaymentId);
117118
tvTxBlockheight = view.findViewById(R.id.tvTxBlockheight);
118119
tvTxAmount = view.findViewById(R.id.tvTxAmount);
120+
tvTxPocketChangeAmount = view.findViewById(R.id.tvTxPocketChangeAmount);
119121
tvTxFee = view.findViewById(R.id.tvTxFee);
120122
tvTxTransfers = view.findViewById(R.id.tvTxTransfers);
121123
etTxNotes = view.findViewById(R.id.etTxNotes);
@@ -249,8 +251,10 @@ private void show() {
249251
}
250252
String sign = (info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-");
251253

252-
long realAmount = info.amount;
253-
tvTxAmount.setText(sign + Wallet.getDisplayAmount(realAmount));
254+
tvTxAmount.setText(sign + Wallet.getDisplayAmount(info.amount));
255+
final long pcAmount = info.getPocketChangeAmount();
256+
tvTxPocketChangeAmount.setVisibility(pcAmount > 0 ? View.VISIBLE : View.GONE);
257+
tvTxPocketChangeAmount.setText(getString(R.string.pocketchange_tx_detail, Wallet.getDisplayAmount(pcAmount)));
254258

255259
if ((info.fee > 0)) {
256260
String fee = Wallet.getDisplayAmount(info.fee);

app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
import com.m2049r.xmrwallet.data.Subaddress;
5353
import com.m2049r.xmrwallet.data.TxData;
5454
import com.m2049r.xmrwallet.data.UserNotes;
55-
import com.m2049r.xmrwallet.dialog.CreditsFragment;
5655
import com.m2049r.xmrwallet.dialog.HelpFragment;
56+
import com.m2049r.xmrwallet.dialog.PocketChangeFragment;
5757
import com.m2049r.xmrwallet.fragment.send.SendAddressWizardFragment;
5858
import com.m2049r.xmrwallet.fragment.send.SendFragment;
5959
import com.m2049r.xmrwallet.ledger.LedgerProgressDialog;
@@ -82,7 +82,8 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste
8282
WalletFragment.DrawerLocker,
8383
NavigationView.OnNavigationItemSelectedListener,
8484
SubaddressFragment.Listener,
85-
SubaddressInfoFragment.Listener {
85+
SubaddressInfoFragment.Listener,
86+
PocketChangeFragment.Listener {
8687

8788
public static final String REQUEST_ID = "id";
8889
public static final String REQUEST_PW = "pw";
@@ -285,8 +286,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
285286
onWalletRescan();
286287
} else if (itemId == R.id.action_info) {
287288
onWalletDetails();
288-
} else if (itemId == R.id.action_credits) {
289-
CreditsFragment.display(getSupportFragmentManager());
290289
} else if (itemId == R.id.action_share) {
291290
onShareTxInfo();
292291
} else if (itemId == R.id.action_help_tx_info) {
@@ -301,6 +300,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
301300
HelpFragment.display(getSupportFragmentManager(), R.string.help_send);
302301
} else if (itemId == R.id.action_rename) {
303302
onAccountRename();
303+
} else if (itemId == R.id.action_pocketchange) {
304+
PocketChangeFragment.display(getSupportFragmentManager(), getWallet().getPocketChangeSetting());
304305
} else if (itemId == R.id.action_subaddresses) {
305306
showSubaddresses(true);
306307
} else if (itemId == R.id.action_streetmode) {
@@ -422,7 +423,7 @@ public void showNet() {
422423
break;
423424
case NetworkType_Stagenet:
424425
case NetworkType_Testnet:
425-
toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, R.attr.colorPrimaryDark));
426+
toolbar.setBackgroundResource(ThemeHelper.getThemedResourceId(this, androidx.appcompat.R.attr.colorPrimaryDark));
426427
break;
427428
default:
428429
throw new IllegalStateException("Unsupported Network: " + WalletManager.getInstance().getNetworkType());
@@ -628,6 +629,7 @@ public void onWalletOpen(final Wallet.Device device) {
628629

629630
@Override
630631
public void onWalletStarted(final Wallet.Status walletStatus) {
632+
loadPocketChangeSettings();
631633
runOnUiThread(() -> {
632634
dismissProgressDialog();
633635
if (walletStatus == null) {
@@ -1104,6 +1106,7 @@ public void onAccountRename() {
11041106

11051107
public void setAccountIndex(int accountIndex) {
11061108
getWallet().setAccountIndex(accountIndex);
1109+
loadPocketChangeSettings();
11071110
selectedSubaddressIndex = 0;
11081111
}
11091112

@@ -1214,4 +1217,19 @@ public void showSubaddress(View view, final int subaddressIndex) {
12141217
b.putInt("subaddressIndex", subaddressIndex);
12151218
replaceFragmentWithTransition(view, new SubaddressInfoFragment(), null, b);
12161219
}
1220+
1221+
@Override
1222+
public void setPocketChange(Wallet.PocketChangeSetting setting) {
1223+
SharedPreferences.Editor editor = getPrefs().edit();
1224+
editor.putString(getWallet().getAddress() + "_PC", setting.toPrefString());
1225+
editor.apply();
1226+
getWallet().setPocketChangeSetting(setting);
1227+
}
1228+
1229+
1230+
public void loadPocketChangeSettings() {
1231+
final String settings = getPrefs().getString(getWallet().getAddress() + "_PC", "0");
1232+
getWallet().setPocketChangeSetting(Wallet.PocketChangeSetting.from(settings));
1233+
}
1234+
12171235
}

app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
112112
flExchange = view.findViewById(R.id.flExchange);
113113
((ProgressBar) view.findViewById(R.id.pbExchange)).getIndeterminateDrawable().
114114
setColorFilter(
115-
ThemeHelper.getThemedColor(getContext(), R.attr.colorPrimaryVariant),
115+
ThemeHelper.getThemedColor(getContext(), com.google.android.material.R.attr.colorPrimaryVariant),
116116
android.graphics.PorterDuff.Mode.MULTIPLY);
117117

118118
tvProgress = view.findViewById(R.id.tvProgress);

app/src/main/java/com/m2049r/xmrwallet/data/NodeInfo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public void showInfo(TextView view, String info, boolean isError) {
270270
(hostAddress.isOnion() ? " .onion  " : ""), " " + info));
271271
view.setText(text);
272272
if (isError)
273-
view.setTextColor(ThemeHelper.getThemedColor(ctx, R.attr.colorError));
273+
view.setTextColor(ThemeHelper.getThemedColor(ctx, androidx.appcompat.R.attr.colorError));
274274
else
275275
view.setTextColor(ThemeHelper.getThemedColor(ctx, android.R.attr.textColorSecondary));
276276
}

0 commit comments

Comments
 (0)