Move more strings into strings.xml

This commit is contained in:
MrLetsplay 2023-10-04 15:53:25 +02:00
parent 87d1c21f50
commit 4c7891b1d3
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
22 changed files with 55 additions and 51 deletions

View File

@ -45,8 +45,6 @@ public class MainActivity extends BaseActivity {
private static final long BACK_BUTTON_DELAY = 500; private static final long BACK_BUTTON_DELAY = 500;
private ActivityMainBinding binding;
private ActivityResultLauncher<Void> startQRCodeScan; private ActivityResultLauncher<Void> startQRCodeScan;
private ActivityResultLauncher<PickVisualMediaRequest> pickQRCodeImage; private ActivityResultLauncher<PickVisualMediaRequest> pickQRCodeImage;
@ -237,7 +235,7 @@ public class MainActivity extends BaseActivity {
fullyLaunched = true; fullyLaunched = true;
lockOnStop = true; lockOnStop = true;
binding = ActivityMainBinding.inflate(getLayoutInflater()); ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot()); setContentView(binding.getRoot());
ThemeUtil.loadBackground(this); ThemeUtil.loadBackground(this);
@ -281,7 +279,8 @@ public class MainActivity extends BaseActivity {
} }
if(fragment instanceof EditOTPFragment) { 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; return true;
} }

View File

@ -37,7 +37,7 @@ public class Crypto {
private static final String KEY_STORE = "AndroidKeyStore"; 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() Argon2Parameters params = new Argon2Parameters.Builder()
.withVersion(parameters.getArgon2Version()) .withVersion(parameters.getArgon2Version())
.withIterations(parameters.getArgon2Iterations()) .withIterations(parameters.getArgon2Iterations())

View File

@ -15,8 +15,6 @@ import com.cringe_studios.code_guard.databinding.FragmentAboutBinding;
public class AboutFragment extends NamedFragment { public class AboutFragment extends NamedFragment {
private FragmentAboutBinding binding;
@Override @Override
public String getName() { public String getName() {
return requireActivity().getString(R.string.fragment_about); return requireActivity().getString(R.string.fragment_about);
@ -25,7 +23,7 @@ public class AboutFragment extends NamedFragment {
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = FragmentAboutBinding.inflate(inflater); FragmentAboutBinding binding = FragmentAboutBinding.inflate(inflater);
try { try {
PackageManager manager = requireContext().getPackageManager(); PackageManager manager = requireContext().getPackageManager();
PackageInfo info = manager.getPackageInfo(requireContext().getPackageName(), 0); PackageInfo info = manager.getPackageInfo(requireContext().getPackageName(), 0);

View File

@ -19,8 +19,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
public class PickIconDrawerFragment extends BottomSheetDialogFragment { public class PickIconDrawerFragment extends BottomSheetDialogFragment {
private FragmentPickIconBinding binding;
private final Consumer<Icon> selected; private final Consumer<Icon> selected;
public PickIconDrawerFragment(Consumer<Icon> selected) { public PickIconDrawerFragment(Consumer<Icon> selected) {
@ -30,7 +28,7 @@ public class PickIconDrawerFragment extends BottomSheetDialogFragment {
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 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 -> { IconListAdapter adapter = new IconListAdapter(requireContext(), IconUtil.loadAllIcons(requireContext()), icon -> {
selected.accept(icon); selected.accept(icon);

View File

@ -1,8 +1,6 @@
package com.cringe_studios.code_guard.grouplist; package com.cringe_studios.code_guard.grouplist;
import android.content.Context; import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -28,8 +26,6 @@ public class GroupListAdapter extends RecyclerView.Adapter<GroupListItem> {
private final List<String> items; private final List<String> items;
private final Handler handler;
private final Consumer<String> navigateToGroup; private final Consumer<String> navigateToGroup;
private final Runnable saveGroups; private final Runnable saveGroups;
@ -46,7 +42,6 @@ public class GroupListAdapter extends RecyclerView.Adapter<GroupListItem> {
this.updateToolbarOptions = updateToolbarOptions; this.updateToolbarOptions = updateToolbarOptions;
this.inflater = LayoutInflater.from(context); this.inflater = LayoutInflater.from(context);
this.items = new ArrayList<>(); this.items = new ArrayList<>();
this.handler = new Handler(Looper.getMainLooper());
attachTouchHelper(recyclerView); attachTouchHelper(recyclerView);
} }

View File

@ -7,7 +7,7 @@ import com.cringe_studios.code_guard.databinding.DialogManageIconPacksItemBindin
public class IconPackItem extends RecyclerView.ViewHolder { public class IconPackItem extends RecyclerView.ViewHolder {
private DialogManageIconPacksItemBinding binding; private final DialogManageIconPacksItemBinding binding;
private IconPack pack; private IconPack pack;

View File

@ -15,11 +15,11 @@ import java.util.List;
public class IconPackListAdapter extends RecyclerView.Adapter<IconPackItem> { public class IconPackListAdapter extends RecyclerView.Adapter<IconPackItem> {
private Context context; private final Context context;
private LayoutInflater inflater; private final LayoutInflater inflater;
private List<IconPack> packs; private final List<IconPack> packs;
public IconPackListAdapter(Context context, List<IconPack> packs) { public IconPackListAdapter(Context context, List<IconPack> packs) {
this.context = context; this.context = context;

View File

@ -79,7 +79,7 @@ public class OTPDatabase {
((BaseActivity) ctx).promptUnlock(success, failure); ((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); File file = new File(context.getFilesDir(), DB_FILE_NAME);
if(!file.exists()) { if(!file.exists()) {
try { try {
@ -94,7 +94,6 @@ public class OTPDatabase {
loadedDatabase = loadFromEncryptedBytes(bytes, key, SettingsUtil.getCryptoParameters(context)); loadedDatabase = loadFromEncryptedBytes(bytes, key, SettingsUtil.getCryptoParameters(context));
loadedKey = key; loadedKey = key;
return loadedDatabase;
}catch(IOException e) { }catch(IOException e) {
throw new OTPDatabaseException(e); throw new OTPDatabaseException(e);
} }

View File

@ -15,7 +15,7 @@ import java.util.Locale;
public class SettingsUtil { public class SettingsUtil {
public static String public static final String
GROUPS_PREFS_NAME = "groups", GROUPS_PREFS_NAME = "groups",
GENERAL_PREFS_NAME = "general"; GENERAL_PREFS_NAME = "general";

View File

@ -25,7 +25,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:text="Details" android:text="@string/details"
android:textStyle="bold" /> android:textStyle="bold" />
<HorizontalScrollView <HorizontalScrollView

View File

@ -11,7 +11,7 @@
android:layout_weight="1" android:layout_weight="1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="left|center" android:gravity="start|center"
tools:text="My Icon Pack"/> tools:text="My Icon Pack"/>
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton

View File

@ -210,7 +210,7 @@
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:text="Developed by Cringe Studios and JG-Cody" android:text="@string/developed_by"
android:textAlignment="center" /> android:textAlignment="center" />
<LinearLayout <LinearLayout

View File

@ -12,7 +12,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:autofillHints="" android:autofillHints=""
android:hint="Search" /> android:hint="@string/search" />
<ExpandableListView <ExpandableListView
android:id="@+id/pick_icon_list" android:id="@+id/pick_icon_list"

View File

@ -77,7 +77,7 @@
android:id="@+id/settings_enable_themed_background" android:id="@+id/settings_enable_themed_background"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Use themed background" /> android:text="@string/settings_enable_themed_background" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -95,7 +95,7 @@
android:id="@+id/settings_enable_minimalist_theme" android:id="@+id/settings_enable_minimalist_theme"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Use minimalist theme" /> android:text="@string/settings_enable_minimalist_theme" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -147,7 +147,7 @@
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Icon Packs" /> android:text="@string/settings_icon_packs" />
<androidx.appcompat.widget.AppCompatButton <androidx.appcompat.widget.AppCompatButton
android:id="@+id/settings_load_icon_pack" android:id="@+id/settings_load_icon_pack"
@ -155,7 +155,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:background="?attr/buttonBackground" android:background="?attr/buttonBackground"
android:text="Import icon pack" android:text="@string/settings_icon_packs_import"
android:textAllCaps="false" /> android:textAllCaps="false" />
<androidx.appcompat.widget.AppCompatButton <androidx.appcompat.widget.AppCompatButton
@ -164,7 +164,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:background="?attr/buttonBackground" android:background="?attr/buttonBackground"
android:text="Manage icon packs" android:text="@string/settings_icon_packs_manage"
android:textAllCaps="false" /> android:textAllCaps="false" />
<Space <Space

View File

@ -5,7 +5,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingVertical="5dp" android:paddingVertical="5dp"
android:paddingStart="?android:attr/expandableListPreferredChildPaddingLeft"> android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft">
<com.caverock.androidsvg.SVGImageView <com.caverock.androidsvg.SVGImageView
android:id="@+id/icon_list_icon_image" android:id="@+id/icon_list_icon_image"
android:layout_width="50dp" android:layout_width="50dp"

View File

@ -22,7 +22,7 @@
android:id="@+id/otp_code_icon" android:id="@+id/otp_code_icon"
android:layout_width="60dp" android:layout_width="60dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingLeft="10dp" android:paddingStart="10dp"
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:scaleType="centerInside" android:scaleType="centerInside"
android:src="@drawable/cringeauth_white" /> android:src="@drawable/cringeauth_white" />
@ -36,9 +36,8 @@
android:id="@+id/label" android:id="@+id/label"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="bottom" android:gravity="bottom|center"
android:minHeight="25dp" android:minHeight="25dp"
android:textAlignment="center"
android:textSize="16sp" android:textSize="16sp"
tools:text="My OTP" /> tools:text="My OTP" />
@ -59,8 +58,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:fontFamily="monospace" android:fontFamily="monospace"
android:gravity="top" android:gravity="top|center"
android:textAlignment="center"
android:textSize="24sp" android:textSize="24sp"
tools:text="000000" /> tools:text="000000" />

View File

@ -4,13 +4,13 @@
<item <item
android:id="@+id/action_cancel" android:id="@+id/action_cancel"
android:orderInCategory="100" android:orderInCategory="100"
android:title="Cancel" android:title="@string/cancel"
android:onClick="cancelEditingOTP" android:onClick="cancelEditingOTP"
app:showAsAction="always" /> app:showAsAction="always" />
<item <item
android:id="@+id/action_save" android:id="@+id/action_save"
android:orderInCategory="100" android:orderInCategory="100"
android:title="Save" android:title="@string/save"
android:onClick="saveOTP" android:onClick="saveOTP"
app:showAsAction="always" /> app:showAsAction="always" />
</menu> </menu>

View File

@ -5,7 +5,7 @@
<item <item
android:id="@+id/action_lock" android:id="@+id/action_lock"
android:orderInCategory="100" android:orderInCategory="100"
android:title="Lock" android:title="@string/lock"
app:showAsAction="never" app:showAsAction="never"
android:onClick="lockApp" /> android:onClick="lockApp" />
<item <item

View File

@ -12,21 +12,21 @@
android:id="@+id/action_otp_input" android:id="@+id/action_otp_input"
android:orderInCategory="100" android:orderInCategory="100"
android:icon="@drawable/baseline_edit_24" android:icon="@drawable/baseline_edit_24"
android:title="Input manually" android:title="@string/otp_input"
android:onClick="inputCode" android:onClick="inputCode"
app:showAsAction="never"/> app:showAsAction="never"/>
<item <item
android:id="@+id/action_otp_scan" android:id="@+id/action_otp_scan"
android:orderInCategory="100" android:orderInCategory="100"
android:icon="@drawable/baseline_qr_code_scanner_24" android:icon="@drawable/baseline_qr_code_scanner_24"
android:title="Scan QR code" android:title="@string/otp_scan"
android:onClick="scanCode" android:onClick="scanCode"
app:showAsAction="never"/> app:showAsAction="never"/>
<item <item
android:id="@+id/action_otp_scan_image" android:id="@+id/action_otp_scan_image"
android:orderInCategory="100" android:orderInCategory="100"
android:icon="@drawable/baseline_compare_24" android:icon="@drawable/baseline_compare_24"
android:title="Scan image" android:title="@string/otp_scan_image"
android:onClick="scanCodeFromImage" android:onClick="scanCodeFromImage"
app:showAsAction="never"/> app:showAsAction="never"/>
</menu> </menu>
@ -34,7 +34,7 @@
<item <item
android:id="@+id/action_lock" android:id="@+id/action_lock"
android:orderInCategory="100" android:orderInCategory="100"
android:title="Lock" android:title="@string/lock"
app:showAsAction="never" app:showAsAction="never"
android:onClick="lockApp" /> android:onClick="lockApp" />
<item <item

View File

@ -5,34 +5,34 @@
android:id="@+id/action_view_otp" android:id="@+id/action_view_otp"
android:orderInCategory="100" android:orderInCategory="100"
android:icon="@drawable/baseline_visibility_24" android:icon="@drawable/baseline_visibility_24"
android:title="View OTP" android:title="@string/otp_view"
android:onClick="viewOTP" android:onClick="viewOTP"
app:showAsAction="always" /> app:showAsAction="always" />
<item <item
android:id="@+id/action_edit_otp" android:id="@+id/action_edit_otp"
android:orderInCategory="100" android:orderInCategory="100"
android:icon="@drawable/baseline_edit_24" android:icon="@drawable/baseline_edit_24"
android:title="Edit OTP" android:title="@string/otp_edit"
android:onClick="editOTP" android:onClick="editOTP"
app:showAsAction="always" /> app:showAsAction="always" />
<item <item
android:id="@+id/action_move_otp" android:id="@+id/action_move_otp"
android:orderInCategory="100" android:orderInCategory="100"
android:icon="@drawable/baseline_drive_file_move_24" android:icon="@drawable/baseline_drive_file_move_24"
android:title="Move OTP" android:title="@string/otp_move"
android:onClick="moveOTP" android:onClick="moveOTP"
app:showAsAction="always" /> app:showAsAction="always" />
<item <item
android:id="@+id/action_delete_otp" android:id="@+id/action_delete_otp"
android:orderInCategory="100" android:orderInCategory="100"
android:icon="@drawable/baseline_delete_24" android:icon="@drawable/baseline_delete_24"
android:title="Delete OTP" android:title="@string/otp_delete"
android:onClick="deleteOTP" android:onClick="deleteOTP"
app:showAsAction="always" /> app:showAsAction="always" />
<item <item
android:id="@+id/action_lock" android:id="@+id/action_lock"
android:orderInCategory="100" android:orderInCategory="100"
android:title="Lock" android:title="@string/lock"
app:showAsAction="never" app:showAsAction="never"
android:onClick="lockApp" /> android:onClick="lockApp" />
<item <item

View File

@ -4,7 +4,7 @@
<item <item
android:id="@+id/action_cancel" android:id="@+id/action_cancel"
android:orderInCategory="100" android:orderInCategory="100"
android:title="Close" android:title="@string/close"
android:onClick="cancelEditingOTP" android:onClick="cancelEditingOTP"
app:showAsAction="always" /> app:showAsAction="always" />
</menu> </menu>

View File

@ -150,6 +150,23 @@
<string name="icon_pack_exists_title">Icon pack already exists</string> <string name="icon_pack_exists_title">Icon pack already exists</string>
<string name="error_import_icon_pack">Failed to import icon pack</string> <string name="error_import_icon_pack">Failed to import icon pack</string>
<string name="error_no_camera_permission">No camera permission</string> <string name="error_no_camera_permission">No camera permission</string>
<string name="details">Details</string>
<string name="search">Search</string>
<string name="settings_enable_themed_background">Use themed background</string>
<string name="settings_enable_minimalist_theme">Use minimalist theme</string>
<string name="settings_icon_packs">Icon Packs</string>
<string name="settings_icon_packs_import">Import icon pack</string>
<string name="settings_icon_packs_manage">Manage icon packs</string>
<string name="save">Save</string>
<string name="lock">Lock</string>
<string name="otp_input">Input manually</string>
<string name="otp_scan">Scan QR code</string>
<string name="otp_scan_image">Scan image</string>
<string name="otp_view">View OTP</string>
<string name="otp_edit">Edit OTP</string>
<string name="otp_move">Move OTP</string>
<string name="otp_delete">Delete OTP</string>
<string name="close">Close</string>
<string-array name="edit_otp_choose_image_options"> <string-array name="edit_otp_choose_image_options">
<item>Image from icon pack</item> <item>Image from icon pack</item>
<item>Image from gallery</item> <item>Image from gallery</item>