From 90590936dffa0aaed563208faf82d493c0dc93bf Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Sun, 24 Sep 2023 14:38:28 +0200 Subject: [PATCH] Less strict HOTP parsing, Remove fabs --- .../cringe_authenticator/MainActivity.java | 4 -- .../fragment/GroupFragment.java | 9 ---- .../fragment/HomeFragment.java | 2 - .../fragment/MenuDrawerFragment.java | 2 - .../fragment/SettingsFragment.java | 10 ---- .../cringe_authenticator/util/FabUtil.java | 54 ------------------- .../cringe_authenticator/util/OTPParser.java | 4 -- app/src/main/res/layout/activity_main.xml | 33 ------------ 8 files changed, 118 deletions(-) delete mode 100644 app/src/main/java/com/cringe_studios/cringe_authenticator/util/FabUtil.java diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java index 73b09e8..dc7847d 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/MainActivity.java @@ -142,11 +142,7 @@ public class MainActivity extends BaseActivity { setSupportActionBar(binding.toolbar); - //binding.fabMenu.setOnClickListener(view -> NavigationUtil.navigate(this, MenuFragment.class, null)); TODO: remove old menu binding.fabMenu.setOnClickListener(view -> NavigationUtil.openMenu(this, null)); - binding.fabScan.setOnClickListener(view -> scanCode(null)); - binding.fabScanImage.setOnClickListener(view -> scanCodeFromImage(null)); - binding.fabInput.setOnClickListener(view -> inputCode(null)); Fragment fragment = NavigationUtil.getCurrentFragment(this); if(fragment instanceof NamedFragment) { diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java index 6fc33cc..f0f68a2 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java @@ -1,33 +1,26 @@ package com.cringe_studios.cringe_authenticator.fragment; -import android.content.ClipData; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.recyclerview.widget.ItemTouchHelper; -import androidx.recyclerview.widget.RecyclerView; import com.cringe_studios.cringe_authenticator.R; import com.cringe_studios.cringe_authenticator.crypto.CryptoException; import com.cringe_studios.cringe_authenticator.databinding.FragmentGroupBinding; -import com.cringe_studios.cringe_authenticator.grouplist.GroupListItem; import com.cringe_studios.cringe_authenticator.model.OTPData; import com.cringe_studios.cringe_authenticator.otplist.OTPListAdapter; import com.cringe_studios.cringe_authenticator.otplist.OTPListItem; import com.cringe_studios.cringe_authenticator.util.DialogUtil; -import com.cringe_studios.cringe_authenticator.util.FabUtil; import com.cringe_studios.cringe_authenticator.util.OTPDatabase; import com.cringe_studios.cringe_authenticator.util.OTPDatabaseException; import com.cringe_studios.cringe_authenticator.util.SettingsUtil; import com.cringe_studios.cringe_authenticator.util.StyledDialogBuilder; -import com.cringe_studios.cringe_authenticator_library.OTPException; import com.cringe_studios.cringe_authenticator_library.OTPType; import java.util.List; @@ -63,8 +56,6 @@ public class GroupFragment extends NamedFragment { groupID = requireArguments().getString(GroupFragment.BUNDLE_GROUP); - //FabUtil.showFabs(requireActivity()); - otpListAdapter = new OTPListAdapter(requireContext(), binding.itemList); binding.itemList.setAdapter(otpListAdapter); diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/HomeFragment.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/HomeFragment.java index 7bcfb68..6e1eeaf 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/HomeFragment.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/HomeFragment.java @@ -9,7 +9,6 @@ import androidx.annotation.NonNull; import com.cringe_studios.cringe_authenticator.R; import com.cringe_studios.cringe_authenticator.databinding.FragmentHomeBinding; -import com.cringe_studios.cringe_authenticator.util.FabUtil; public class HomeFragment extends NamedFragment { @@ -23,7 +22,6 @@ public class HomeFragment extends NamedFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { binding = FragmentHomeBinding.inflate(inflater, container, false); - FabUtil.hideFabs(requireActivity()); return binding.getRoot(); } diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/MenuDrawerFragment.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/MenuDrawerFragment.java index 0ab78d9..a6897ce 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/MenuDrawerFragment.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/MenuDrawerFragment.java @@ -13,9 +13,7 @@ import com.cringe_studios.cringe_authenticator.crypto.CryptoException; import com.cringe_studios.cringe_authenticator.databinding.FragmentMenuDrawerBinding; import com.cringe_studios.cringe_authenticator.grouplist.GroupListAdapter; import com.cringe_studios.cringe_authenticator.grouplist.GroupListItem; -import com.cringe_studios.cringe_authenticator.model.OTPData; import com.cringe_studios.cringe_authenticator.util.DialogUtil; -import com.cringe_studios.cringe_authenticator.util.FabUtil; import com.cringe_studios.cringe_authenticator.util.NavigationUtil; import com.cringe_studios.cringe_authenticator.util.OTPDatabase; import com.cringe_studios.cringe_authenticator.util.OTPDatabaseException; 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 4d1f50a..40d78b6 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 @@ -1,10 +1,5 @@ package com.cringe_studios.cringe_authenticator.fragment; -import static androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG; -import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL; - -import android.location.SettingInjectorService; -import android.os.Build; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; @@ -15,7 +10,6 @@ import android.widget.ArrayAdapter; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.biometric.BiometricManager; import com.cringe_studios.cringe_authenticator.MainActivity; import com.cringe_studios.cringe_authenticator.R; @@ -27,7 +21,6 @@ import com.cringe_studios.cringe_authenticator.databinding.FragmentSettingsBindi import com.cringe_studios.cringe_authenticator.util.Appearance; import com.cringe_studios.cringe_authenticator.util.BiometricUtil; import com.cringe_studios.cringe_authenticator.util.DialogUtil; -import com.cringe_studios.cringe_authenticator.util.FabUtil; import com.cringe_studios.cringe_authenticator.util.OTPDatabase; import com.cringe_studios.cringe_authenticator.util.OTPDatabaseException; import com.cringe_studios.cringe_authenticator.util.SettingsUtil; @@ -35,7 +28,6 @@ import com.cringe_studios.cringe_authenticator.util.Theme; import java.util.Arrays; import java.util.Locale; -import java.util.Objects; import javax.crypto.SecretKey; @@ -199,8 +191,6 @@ public class SettingsFragment extends NamedFragment { public void onNothingSelected(AdapterView parent) {} }); - FabUtil.hideFabs(requireActivity()); - return binding.getRoot(); } diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/FabUtil.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/FabUtil.java deleted file mode 100644 index e3c5342..0000000 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/FabUtil.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.cringe_studios.cringe_authenticator.util; - -import android.app.Activity; -import android.view.View; - -import com.cringe_studios.cringe_authenticator.R; -import com.google.android.material.floatingactionbutton.FloatingActionButton; - -public class FabUtil { - - public static void showFabs(Activity activity) { - FloatingActionButton fabScanImage = activity.findViewById(R.id.fab_scan_image); - if(fabScanImage != null) { - fabScanImage.setVisibility(View.VISIBLE); - fabScanImage.setClickable(true); - fabScanImage.animate().translationX(-activity.getResources().getDimension(R.dimen.fab1_offset)); - } - - FloatingActionButton fabScan = activity.findViewById(R.id.fab_scan); - if(fabScan != null) { - fabScan.setVisibility(View.VISIBLE); - fabScan.setClickable(true); - fabScan.animate().translationX(-activity.getResources().getDimension(R.dimen.fab2_offset)); - } - - FloatingActionButton fabInput = activity.findViewById(R.id.fab_input); - if(fabInput != null) { - fabInput.setVisibility(View.VISIBLE); - fabInput.setClickable(true); - fabInput.animate().translationX(-activity.getResources().getDimension(R.dimen.fab3_offset)); - } - } - - public static void hideFabs(Activity activity) { - FloatingActionButton fabScan = activity.findViewById(R.id.fab_scan); - if(fabScan != null) { - fabScan.setClickable(false); - fabScan.animate().translationX(0).withEndAction(() -> fabScan.setVisibility(View.GONE)); - } - - FloatingActionButton fabScanImage = activity.findViewById(R.id.fab_scan_image); - if(fabScan != null) { - fabScanImage.setClickable(false); - fabScanImage.animate().translationX(0).withEndAction(() -> fabScanImage.setVisibility(View.GONE)); - } - - FloatingActionButton fabInput = activity.findViewById(R.id.fab_input); - if(fabInput != null) { - fabInput.setClickable(false); - fabInput.animate().translationX(0).withEndAction(() -> fabInput.setVisibility(View.GONE)); - } - } - -} diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/OTPParser.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/OTPParser.java index f4e0376..5346dab 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/util/OTPParser.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/util/OTPParser.java @@ -163,10 +163,6 @@ public class OTPParser { throw new IllegalArgumentException("Failed to parse OTP parameters"); } - if(fType == OTPType.HOTP && counter == null) { - throw new IllegalArgumentException("Missing required parameters"); - } - if(accountName.length() == 0 || (issuer != null && issuer.length() == 0)) { throw new IllegalArgumentException("Missing required parameters"); } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 069d3a9..63848d6 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -22,39 +22,6 @@ - - - - - -