diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/EditOTPFragment.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/EditOTPFragment.java index f9fefc1..57e9e80 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/EditOTPFragment.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/EditOTPFragment.java @@ -13,7 +13,6 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; -import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.core.util.Consumer; @@ -27,8 +26,8 @@ import com.cringe_studios.cringe_authenticator.model.OTPData; import com.cringe_studios.cringe_authenticator.util.DialogUtil; import com.cringe_studios.cringe_authenticator.util.IOUtil; import com.cringe_studios.cringe_authenticator.util.NavigationUtil; +import com.cringe_studios.cringe_authenticator.util.SettingsUtil; import com.cringe_studios.cringe_authenticator.util.StyledDialogBuilder; -import com.cringe_studios.cringe_authenticator.util.ThemeUtil; import com.cringe_studios.cringe_authenticator_library.OTPAlgorithm; import com.cringe_studios.cringe_authenticator_library.OTPType; @@ -73,11 +72,7 @@ public class EditOTPFragment extends NamedFragment { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { binding = FragmentEditOtpBinding.inflate(inflater); - @DrawableRes int bg = ThemeUtil.getBackground(requireContext()); - if(bg != 0) { - binding.getRoot().setBackgroundResource(bg); - } - + binding.inputImage.setVisibility(SettingsUtil.isShowImages(requireContext()) ? View.VISIBLE : View.GONE); binding.inputImage.setOnClickListener(v -> { new StyledDialogBuilder(requireContext()) .setTitle("Choose Image") diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/SettingsFragment.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/SettingsFragment.java index aaf69ef..d88fd66 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/SettingsFragment.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/SettingsFragment.java @@ -157,6 +157,9 @@ public class SettingsFragment extends NamedFragment { binding.settingsHideCodes.setChecked(SettingsUtil.isHideCodes(requireContext())); binding.settingsHideCodes.setOnCheckedChangeListener((view, checked) -> SettingsUtil.setHideCodes(requireContext(), checked)); + binding.settingsShowImages.setChecked(SettingsUtil.isShowImages(requireContext())); + binding.settingsShowImages.setOnCheckedChangeListener((view, checked) -> SettingsUtil.setShowImages(requireContext(), checked)); + String[] themeNames = new String[Theme.values().length]; for(int i = 0; i < Theme.values().length; i++) { themeNames[i] = getResources().getString(Theme.values()[i].getName()); diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListAdapter.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListAdapter.java index 294d791..a2e018b 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListAdapter.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListAdapter.java @@ -18,6 +18,7 @@ import com.cringe_studios.cringe_authenticator.databinding.OtpCodeBinding; import com.cringe_studios.cringe_authenticator.icon.IconUtil; import com.cringe_studios.cringe_authenticator.model.OTPData; import com.cringe_studios.cringe_authenticator.util.DialogUtil; +import com.cringe_studios.cringe_authenticator.util.SettingsUtil; import com.cringe_studios.cringe_authenticator_library.OTPException; import com.cringe_studios.cringe_authenticator_library.OTPType; @@ -72,6 +73,8 @@ public class OTPListAdapter extends RecyclerView.Adapter { DialogUtil.showErrorDialog(context, context.getString(R.string.otp_add_error, e.getMessage() != null ? e.getMessage() : e.toString())); } + holder.getBinding().otpCodeIcon.setVisibility(SettingsUtil.isShowImages(context) ? View.VISIBLE : View.GONE); + holder.getBinding().label.setText(String.format("%s%s", data.getIssuer() == null || data.getIssuer().isEmpty() ? "" : data.getIssuer() + ": ", data.getName())); holder.getBinding().progress.setVisibility(data.getType() == OTPType.TOTP ? View.VISIBLE : View.GONE); holder.getBinding().refresh.setVisibility(data.getType() == OTPType.HOTP ? View.VISIBLE : View.GONE); diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java index 01c42d5..b401716 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/SettingsUtil.java @@ -185,6 +185,15 @@ public class SettingsUtil { return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getBoolean("firstLaunch", true); } + public static void setShowImages(Context ctx, boolean showImages) { + SharedPreferences prefs = ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE); + prefs.edit().putBoolean("showImages", showImages).apply(); + } + + public static boolean isShowImages(Context ctx) { + return ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE).getBoolean("showImages", true); + } + public static void setTheme(Context ctx, Theme theme) { SharedPreferences prefs = ctx.getSharedPreferences(GENERAL_PREFS_NAME, Context.MODE_PRIVATE); prefs.edit().putString("theme", theme.name()).apply(); diff --git a/app/src/main/res/layout/fragment_edit_otp.xml b/app/src/main/res/layout/fragment_edit_otp.xml index 91fb384..5ea44c7 100644 --- a/app/src/main/res/layout/fragment_edit_otp.xml +++ b/app/src/main/res/layout/fragment_edit_otp.xml @@ -4,14 +4,14 @@ android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" - tools:context=".fragment.HomeFragment"> + tools:context=".fragment.HomeFragment" + android:background="?android:attr/colorBackground"> + android:padding="16dp"> + tools:context=".fragment.HomeFragment" + android:background="?android:attr/colorBackground"> + + Type Algorithm Digits + Show Images \ No newline at end of file