From 4c7891b1d3eb2b6b8e1dd044953c5d76b04c36f0 Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Wed, 4 Oct 2023 15:53:25 +0200 Subject: [PATCH] Move more strings into strings.xml --- .../cringe_studios/code_guard/MainActivity.java | 7 +++---- .../code_guard/crypto/Crypto.java | 2 +- .../code_guard/fragment/AboutFragment.java | 4 +--- .../fragment/PickIconDrawerFragment.java | 4 +--- .../code_guard/grouplist/GroupListAdapter.java | 5 ----- .../code_guard/icon/IconPackItem.java | 2 +- .../code_guard/icon/IconPackListAdapter.java | 6 +++--- .../code_guard/util/OTPDatabase.java | 3 +-- .../code_guard/util/SettingsUtil.java | 2 +- app/src/main/res/layout/dialog_error.xml | 2 +- .../layout/dialog_manage_icon_packs_item.xml | 2 +- app/src/main/res/layout/fragment_about.xml | 2 +- app/src/main/res/layout/fragment_pick_icon.xml | 2 +- app/src/main/res/layout/fragment_settings.xml | 10 +++++----- app/src/main/res/layout/icon_list_icon.xml | 2 +- app/src/main/res/layout/otp_code.xml | 8 +++----- app/src/main/res/menu/menu_edit_otp.xml | 4 ++-- app/src/main/res/menu/menu_main.xml | 2 +- app/src/main/res/menu/menu_otps.xml | 8 ++++---- app/src/main/res/menu/menu_otps_edit.xml | 10 +++++----- app/src/main/res/menu/menu_view_otp.xml | 2 +- app/src/main/res/values/strings.xml | 17 +++++++++++++++++ 22 files changed, 55 insertions(+), 51 deletions(-) diff --git a/app/src/main/java/com/cringe_studios/code_guard/MainActivity.java b/app/src/main/java/com/cringe_studios/code_guard/MainActivity.java index 15d0387..2402e3c 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/MainActivity.java +++ b/app/src/main/java/com/cringe_studios/code_guard/MainActivity.java @@ -45,8 +45,6 @@ public class MainActivity extends BaseActivity { private static final long BACK_BUTTON_DELAY = 500; - private ActivityMainBinding binding; - private ActivityResultLauncher startQRCodeScan; private ActivityResultLauncher pickQRCodeImage; @@ -237,7 +235,7 @@ public class MainActivity extends BaseActivity { fullyLaunched = true; lockOnStop = true; - binding = ActivityMainBinding.inflate(getLayoutInflater()); + ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); ThemeUtil.loadBackground(this); @@ -281,7 +279,8 @@ public class MainActivity extends BaseActivity { } if(fragment instanceof EditOTPFragment) { - getMenuInflater().inflate(R.menu.menu_edit_otp, menu); + EditOTPFragment frag = (EditOTPFragment) fragment; + getMenuInflater().inflate(frag.isView() ? R.menu.menu_view_otp : R.menu.menu_edit_otp, menu); return true; } diff --git a/app/src/main/java/com/cringe_studios/code_guard/crypto/Crypto.java b/app/src/main/java/com/cringe_studios/code_guard/crypto/Crypto.java index 35f5701..420eff4 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/crypto/Crypto.java +++ b/app/src/main/java/com/cringe_studios/code_guard/crypto/Crypto.java @@ -37,7 +37,7 @@ public class Crypto { private static final String KEY_STORE = "AndroidKeyStore"; - public static byte[] generateHash(CryptoParameters parameters, String password) throws CryptoException { + public static byte[] generateHash(CryptoParameters parameters, String password) { Argon2Parameters params = new Argon2Parameters.Builder() .withVersion(parameters.getArgon2Version()) .withIterations(parameters.getArgon2Iterations()) diff --git a/app/src/main/java/com/cringe_studios/code_guard/fragment/AboutFragment.java b/app/src/main/java/com/cringe_studios/code_guard/fragment/AboutFragment.java index 03ce933..9386507 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/fragment/AboutFragment.java +++ b/app/src/main/java/com/cringe_studios/code_guard/fragment/AboutFragment.java @@ -15,8 +15,6 @@ import com.cringe_studios.code_guard.databinding.FragmentAboutBinding; public class AboutFragment extends NamedFragment { - private FragmentAboutBinding binding; - @Override public String getName() { return requireActivity().getString(R.string.fragment_about); @@ -25,7 +23,7 @@ public class AboutFragment extends NamedFragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - binding = FragmentAboutBinding.inflate(inflater); + FragmentAboutBinding binding = FragmentAboutBinding.inflate(inflater); try { PackageManager manager = requireContext().getPackageManager(); PackageInfo info = manager.getPackageInfo(requireContext().getPackageName(), 0); diff --git a/app/src/main/java/com/cringe_studios/code_guard/fragment/PickIconDrawerFragment.java b/app/src/main/java/com/cringe_studios/code_guard/fragment/PickIconDrawerFragment.java index 8e9755a..d539ce5 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/fragment/PickIconDrawerFragment.java +++ b/app/src/main/java/com/cringe_studios/code_guard/fragment/PickIconDrawerFragment.java @@ -19,8 +19,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment; public class PickIconDrawerFragment extends BottomSheetDialogFragment { - private FragmentPickIconBinding binding; - private final Consumer selected; public PickIconDrawerFragment(Consumer selected) { @@ -30,7 +28,7 @@ public class PickIconDrawerFragment extends BottomSheetDialogFragment { @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - binding = FragmentPickIconBinding.inflate(inflater); + FragmentPickIconBinding binding = FragmentPickIconBinding.inflate(inflater); IconListAdapter adapter = new IconListAdapter(requireContext(), IconUtil.loadAllIcons(requireContext()), icon -> { selected.accept(icon); diff --git a/app/src/main/java/com/cringe_studios/code_guard/grouplist/GroupListAdapter.java b/app/src/main/java/com/cringe_studios/code_guard/grouplist/GroupListAdapter.java index 52aad3c..86d7feb 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/grouplist/GroupListAdapter.java +++ b/app/src/main/java/com/cringe_studios/code_guard/grouplist/GroupListAdapter.java @@ -1,8 +1,6 @@ package com.cringe_studios.code_guard.grouplist; import android.content.Context; -import android.os.Handler; -import android.os.Looper; import android.view.LayoutInflater; import android.view.ViewGroup; @@ -28,8 +26,6 @@ public class GroupListAdapter extends RecyclerView.Adapter { private final List items; - private final Handler handler; - private final Consumer navigateToGroup; private final Runnable saveGroups; @@ -46,7 +42,6 @@ public class GroupListAdapter extends RecyclerView.Adapter { this.updateToolbarOptions = updateToolbarOptions; this.inflater = LayoutInflater.from(context); this.items = new ArrayList<>(); - this.handler = new Handler(Looper.getMainLooper()); attachTouchHelper(recyclerView); } diff --git a/app/src/main/java/com/cringe_studios/code_guard/icon/IconPackItem.java b/app/src/main/java/com/cringe_studios/code_guard/icon/IconPackItem.java index d4771ec..6517041 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/icon/IconPackItem.java +++ b/app/src/main/java/com/cringe_studios/code_guard/icon/IconPackItem.java @@ -7,7 +7,7 @@ import com.cringe_studios.code_guard.databinding.DialogManageIconPacksItemBindin public class IconPackItem extends RecyclerView.ViewHolder { - private DialogManageIconPacksItemBinding binding; + private final DialogManageIconPacksItemBinding binding; private IconPack pack; diff --git a/app/src/main/java/com/cringe_studios/code_guard/icon/IconPackListAdapter.java b/app/src/main/java/com/cringe_studios/code_guard/icon/IconPackListAdapter.java index b0a8aa5..16b1c35 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/icon/IconPackListAdapter.java +++ b/app/src/main/java/com/cringe_studios/code_guard/icon/IconPackListAdapter.java @@ -15,11 +15,11 @@ import java.util.List; public class IconPackListAdapter extends RecyclerView.Adapter { - private Context context; + private final Context context; - private LayoutInflater inflater; + private final LayoutInflater inflater; - private List packs; + private final List packs; public IconPackListAdapter(Context context, List packs) { this.context = context; diff --git a/app/src/main/java/com/cringe_studios/code_guard/util/OTPDatabase.java b/app/src/main/java/com/cringe_studios/code_guard/util/OTPDatabase.java index 22663a4..216e6ff 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/util/OTPDatabase.java +++ b/app/src/main/java/com/cringe_studios/code_guard/util/OTPDatabase.java @@ -79,7 +79,7 @@ public class OTPDatabase { ((BaseActivity) ctx).promptUnlock(success, failure); } - public static OTPDatabase loadDatabase(Context context, SecretKey key) throws OTPDatabaseException, CryptoException { + public static void loadDatabase(Context context, SecretKey key) throws OTPDatabaseException, CryptoException { File file = new File(context.getFilesDir(), DB_FILE_NAME); if(!file.exists()) { try { @@ -94,7 +94,6 @@ public class OTPDatabase { loadedDatabase = loadFromEncryptedBytes(bytes, key, SettingsUtil.getCryptoParameters(context)); loadedKey = key; - return loadedDatabase; }catch(IOException e) { throw new OTPDatabaseException(e); } diff --git a/app/src/main/java/com/cringe_studios/code_guard/util/SettingsUtil.java b/app/src/main/java/com/cringe_studios/code_guard/util/SettingsUtil.java index fdfb0ca..f1d753c 100644 --- a/app/src/main/java/com/cringe_studios/code_guard/util/SettingsUtil.java +++ b/app/src/main/java/com/cringe_studios/code_guard/util/SettingsUtil.java @@ -15,7 +15,7 @@ import java.util.Locale; public class SettingsUtil { - public static String + public static final String GROUPS_PREFS_NAME = "groups", GENERAL_PREFS_NAME = "general"; diff --git a/app/src/main/res/layout/dialog_error.xml b/app/src/main/res/layout/dialog_error.xml index 36b2dd9..0fd5531 100644 --- a/app/src/main/res/layout/dialog_error.xml +++ b/app/src/main/res/layout/dialog_error.xml @@ -25,7 +25,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" - android:text="Details" + android:text="@string/details" android:textStyle="bold" /> + android:hint="@string/search" /> + android:text="@string/settings_enable_themed_background" /> + android:text="@string/settings_enable_minimalist_theme" /> + android:text="@string/settings_icon_packs" /> + android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft"> @@ -36,9 +36,8 @@ android:id="@+id/label" android:layout_width="match_parent" android:layout_height="wrap_content" - android:gravity="bottom" + android:gravity="bottom|center" android:minHeight="25dp" - android:textAlignment="center" android:textSize="16sp" tools:text="My OTP" /> @@ -59,8 +58,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:fontFamily="monospace" - android:gravity="top" - android:textAlignment="center" + android:gravity="top|center" android:textSize="24sp" tools:text="000000" /> diff --git a/app/src/main/res/menu/menu_edit_otp.xml b/app/src/main/res/menu/menu_edit_otp.xml index 7656171..3e2dac6 100644 --- a/app/src/main/res/menu/menu_edit_otp.xml +++ b/app/src/main/res/menu/menu_edit_otp.xml @@ -4,13 +4,13 @@ \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 2b46a10..56b4708 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -5,7 +5,7 @@ @@ -34,7 +34,7 @@ \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 929c380..cc6a3ef 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -150,6 +150,23 @@ Icon pack already exists Failed to import icon pack No camera permission + Details + Search + Use themed background + Use minimalist theme + Icon Packs + Import icon pack + Manage icon packs + Save + Lock + Input manually + Scan QR code + Scan image + View OTP + Edit OTP + Move OTP + Delete OTP + Close Image from icon pack Image from gallery