diff --git a/app/src/main/java/com/m2049r/xmrwallet/LockFragment.java b/app/src/main/java/com/m2049r/xmrwallet/LockFragment.java new file mode 100644 index 00000000..03ddb2f4 --- /dev/null +++ b/app/src/main/java/com/m2049r/xmrwallet/LockFragment.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 m2049r + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.m2049r.xmrwallet; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; + +import androidx.fragment.app.Fragment; + +import timber.log.Timber; + +public class LockFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + Timber.d("onCreateView"); + final FrameLayout frame = new FrameLayout(requireContext()); + frame.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + return frame; + } +} diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java index c3b2f443..b6a9f5fa 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java @@ -76,6 +76,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import lombok.Getter; import timber.log.Timber; public class LoginActivity extends BaseActivity diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java index 64757f5c..afa05f6e 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java @@ -45,6 +45,7 @@ import androidx.core.view.GravityCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; +import androidx.preference.PreferenceManager; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.navigation.NavigationView; @@ -70,6 +71,7 @@ import com.m2049r.xmrwallet.widget.Toolbar; import java.util.ArrayList; import java.util.List; +import lombok.Getter; import timber.log.Timber; public class WalletActivity extends BaseActivity implements WalletFragment.Listener, @@ -200,12 +202,6 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste return getWallet().getSubaddress(major, minor); } - @Override - protected void onStart() { - super.onStart(); - Timber.d("onStart()"); - } - private void startWalletService() { Bundle extras = getIntent().getExtras(); if (extras != null) { @@ -239,12 +235,6 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste } } - @Override - protected void onStop() { - Timber.d("onStop()"); - super.onStop(); - } - @Override protected void onDestroy() { Timber.d("onDestroy()"); @@ -498,12 +488,16 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste @Override protected void onPause() { Timber.d("onPause()"); + lock(); super.onPause(); } @Override protected void onResume() { super.onResume(); + if (locked) { + unlock(); + } Timber.d("onResume()"); } @@ -1216,4 +1210,31 @@ public class WalletActivity extends BaseActivity implements WalletFragment.Liste getWallet().setPocketChangeSetting(Wallet.PocketChangeSetting.from(settings)); } + @Getter + private boolean locked = false; + + private void unlock() { + Helper.promptPassword(WalletActivity.this, getWalletName(), false, new Helper.PasswordAction() { + @Override + public void act(String walletName, String password, boolean fingerprintUsed) { + popFragmentStack(null); + locked = false; + Timber.d("locked: %b", isLocked()); + } + + @Override + public void fail(String walletName) { + finish(); + } + }); + } + + private void lock() { + if (PreferenceManager.getDefaultSharedPreferences(this) + .getBoolean(getString(R.string.preferred_lock), false)) { + replaceFragment(new LockFragment(), null, null); + locked = true; + } + Timber.d("locked %b", isLocked()); + } } diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java b/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java index 4f336119..6b06e9a4 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java @@ -478,7 +478,6 @@ public class Helper { .setPositiveButton(context.getString(R.string.label_ok), null) .setNegativeButton(context.getString(R.string.label_cancel), (dialog, id) -> { - action.fail(wallet); Helper.hideKeyboardAlways((Activity) context); cancelSignal.cancel(); if (passwordTask != null) { @@ -487,6 +486,7 @@ public class Helper { } dialog.cancel(); openDialog = null; + action.fail(wallet); }); openDialog = alertDialogBuilder.create(); diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/LegacyStorageHelper.java b/app/src/main/java/com/m2049r/xmrwallet/util/LegacyStorageHelper.java index 20ea61cc..e31f1a65 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/LegacyStorageHelper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/LegacyStorageHelper.java @@ -4,7 +4,8 @@ import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.os.Environment; -import android.preference.PreferenceManager; + +import androidx.preference.PreferenceManager; import com.m2049r.xmrwallet.BuildConfig; import com.m2049r.xmrwallet.model.WalletManager; diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/LocaleHelper.java b/app/src/main/java/com/m2049r/xmrwallet/util/LocaleHelper.java index 5066e3b2..c78c1770 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/LocaleHelper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/LocaleHelper.java @@ -19,7 +19,8 @@ package com.m2049r.xmrwallet.util; import android.annotation.SuppressLint; import android.content.Context; import android.content.res.Configuration; -import android.preference.PreferenceManager; + +import androidx.preference.PreferenceManager; import com.m2049r.xmrwallet.R; diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/NightmodeHelper.java b/app/src/main/java/com/m2049r/xmrwallet/util/NightmodeHelper.java index 3cd622df..2bf71804 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/NightmodeHelper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/NightmodeHelper.java @@ -18,8 +18,8 @@ package com.m2049r.xmrwallet.util; import android.annotation.SuppressLint; import android.content.Context; -import android.preference.PreferenceManager; +import androidx.preference.PreferenceManager; import androidx.appcompat.app.AppCompatDelegate; import com.m2049r.xmrwallet.R; diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/ServiceHelper.java b/app/src/main/java/com/m2049r/xmrwallet/util/ServiceHelper.java index 271a0e63..b04b20a7 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/ServiceHelper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/ServiceHelper.java @@ -1,16 +1,9 @@ package com.m2049r.xmrwallet.util; -import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.model.NetworkType; import com.m2049r.xmrwallet.model.WalletManager; import com.m2049r.xmrwallet.service.exchange.api.ExchangeApi; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import lombok.Getter; -import lombok.NonNull; import okhttp3.HttpUrl; public class ServiceHelper { diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/ThemeHelper.java b/app/src/main/java/com/m2049r/xmrwallet/util/ThemeHelper.java index 21ff7330..b245e022 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/ThemeHelper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/ThemeHelper.java @@ -19,7 +19,9 @@ package com.m2049r.xmrwallet.util; import android.app.Activity; import android.content.Context; import android.graphics.Color; -import android.preference.PreferenceManager; + +import androidx.preference.PreferenceManager; + import android.util.TypedValue; import androidx.annotation.ColorInt; diff --git a/app/src/main/res/values-cat/strings.xml b/app/src/main/res/values-cat/strings.xml index 2a9ddd4a..88c33154 100644 --- a/app/src/main/res/values-cat/strings.xml +++ b/app/src/main/res/values-cat/strings.xml @@ -445,4 +445,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index de497b50..3868613c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -446,4 +446,6 @@ Erstelle schnellen Wechsel ANWENDEN + + Lock Wallet in Background diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index a0f6919f..522ba7c7 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -447,4 +447,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-eo/strings.xml b/app/src/main/res/values-eo/strings.xml index 1e53f8f8..f6d669f3 100644 --- a/app/src/main/res/values-eo/strings.xml +++ b/app/src/main/res/values-eo/strings.xml @@ -445,4 +445,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 5d15adbd..bf6bbe01 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -438,9 +438,10 @@ Monto trabado hasta el bloque %1$d (faltan %2$d bloques ≈ %3$,.2f días) Modo calle activado\nSólo se ºmostrarán transacciones nuevas - Para reducir el tiempo entre pagos, Monerujo puede crear cambio de más al enviar a costo de comisiones más altas. Va a crear e intentar mantener 10 monedas del monto seleccionado. -Crear cambio + Para reducir el tiempo entre pagos, Monerujo puede crear cambio de más al enviar a costo de comisiones más altas. Va a crear e intentar mantener 10 monedas del monto seleccionado. + Crear cambio -APLICAR - + APLICAR + + Lock Wallet in Background diff --git a/app/src/main/res/values-et/strings.xml b/app/src/main/res/values-et/strings.xml index 85abc1ff..f0468de1 100644 --- a/app/src/main/res/values-et/strings.xml +++ b/app/src/main/res/values-et/strings.xml @@ -445,4 +445,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index 409611a1..2b34fa2f 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -685,4 +685,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b4a073e0..860edf1f 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -458,4 +458,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-he/strings.xml b/app/src/main/res/values-he/strings.xml index 81d68871..c05e5020 100644 --- a/app/src/main/res/values-he/strings.xml +++ b/app/src/main/res/values-he/strings.xml @@ -436,4 +436,15 @@ לא הצליח ליצור QR לשיתוף! + + Transaction amount locked until block %1$d (in %2$d blocks ≈ %3$,.2f days) + + Street Mode enabled\nOnly new transactions will be shown + + To reduce waiting time on repeated spending, Monerujo can create spare change at the expense of higher fees. It\'ll try to create and maintain at least 6 coins of the selected amount. + Create Change + + APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index e51585bd..29d01b2d 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -449,4 +449,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 9f2f188a..9d915f3c 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -450,4 +450,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 9cfa4ecc..196a1caf 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -450,4 +450,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index e34cc76c..431d1d24 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -447,4 +447,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 68b2cf46..222f4557 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -447,4 +447,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index a9ea842f..8218cb91 100755 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -440,4 +440,6 @@ aqui. Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index e17d7856..e6ccbc0a 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -451,4 +451,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 22743f89..9aa4201e 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -447,4 +447,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 70246c54..3b3967c0 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -451,4 +451,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index 7e057375..9b388474 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -448,4 +448,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 554a5981..36daf710 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -446,4 +446,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index d73c0da5..a0ab29dc 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -439,4 +439,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-ta/strings.xml b/app/src/main/res/values-ta/strings.xml index 2ec785fb..e75e0ae6 100644 --- a/app/src/main/res/values-ta/strings.xml +++ b/app/src/main/res/values-ta/strings.xml @@ -445,4 +445,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 5fdc53e0..38c0e34b 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -451,4 +451,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 5ea9e3ab..ac4e9127 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -372,4 +372,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index c1d5ac7d..df112e3a 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -446,4 +446,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 999ed773..49b006cb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -469,6 +469,7 @@ preferred_theme preferred_nightmode preferred_locale + preferred_lock about_info privacy_info credits_info @@ -498,4 +499,6 @@ Create Change APPLY + + Lock Wallet in Background diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 6e4e150b..f5949b50 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -20,6 +20,10 @@ app:key="@string/preferred_theme" app:title="@string/setting_theme" app:useSimpleSummaryProvider="true" /> +