Organize code, Add some placeholder content

This commit is contained in:
MrLetsplay 2023-06-19 20:30:18 +02:00
parent d1c774b496
commit ecc3b2e6b8
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
20 changed files with 159 additions and 110 deletions

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="9eb4b614" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2023-06-18T17:04:59.896380543Z" />
</component>
</project>

View File

@ -43,5 +43,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "androidx.biometric:biometric:1.1.0" implementation "androidx.biometric:biometric:1.1.0"
implementation 'com.cringe_studios:CringeAuthenticatorLibrary:1.0'
implementation 'com.google.mlkit:barcode-scanning:17.1.0'
} }

View File

@ -1,29 +1,22 @@
package com.cringe_studios.cringe_authenticator; package com.cringe_studios.cringe_authenticator;
import static androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG;
import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu;
import com.google.android.material.snackbar.Snackbar; import android.view.MenuItem;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import androidx.biometric.BiometricPrompt; import androidx.biometric.BiometricPrompt;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.view.WindowCompat;
import androidx.navigation.NavController; import androidx.navigation.NavController;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI; import androidx.navigation.ui.NavigationUI;
import com.cringe_studios.cringe_authenticator.databinding.ActivityMainBinding; import com.cringe_studios.cringe_authenticator.databinding.ActivityMainBinding;
import com.cringe_studios.cringe_authenticator.fragment.MenuFragment;
import android.view.Menu; import com.cringe_studios.cringe_authenticator.fragment.SettingsFragment;
import android.view.MenuItem; import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@ -70,9 +63,7 @@ public class MainActivity extends AppCompatActivity {
appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build(); appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration); NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
binding.fab.setOnClickListener(view -> Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) binding.fab.setOnClickListener(view -> NavigationUtil.navigate(this, MenuFragment.class, null));
.setAnchorView(R.id.fab)
.setAction("Action", null).show());
} }
@Override @Override

View File

@ -1,25 +0,0 @@
package com.cringe_studios.cringe_authenticator;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.cringe_studios.cringe_authenticator.databinding.FragmentMenuBinding;
public class MenuFragment extends Fragment {
private FragmentMenuBinding binding;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = FragmentMenuBinding.inflate(inflater);
return binding.getRoot();
}
}

View File

@ -1,7 +1,6 @@
package com.cringe_studios.cringe_authenticator; package com.cringe_studios.cringe_authenticator.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -9,12 +8,11 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.NavOptions;
import androidx.navigation.Navigation;
import com.cringe_studios.cringe_authenticator.R;
import com.cringe_studios.cringe_authenticator.databinding.AuthenticateTotpBinding;
import com.cringe_studios.cringe_authenticator.databinding.FragmentDynamicBinding; import com.cringe_studios.cringe_authenticator.databinding.FragmentDynamicBinding;
import com.cringe_studios.cringe_authenticator.databinding.FragmentFirstBinding; import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
public class DynamicFragment extends Fragment { public class DynamicFragment extends Fragment {
@ -23,17 +21,26 @@ public class DynamicFragment extends Fragment {
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Log.d("AMOGUS", requireArguments().getString("sus"));
} }
@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 = FragmentDynamicBinding.inflate(inflater, container, false); binding = FragmentDynamicBinding.inflate(inflater, container, false);
binding.buttonSecond.setText(requireArguments().getString("sus")); /*binding.buttonSecond.setText(requireArguments().getString("tab"));
binding.buttonSecond.setOnClickListener(view -> { binding.buttonSecond.setOnClickListener(view -> {
NavigationUtil.navigate(this, SecondFragment.class, null); NavigationUtil.navigate(this, SecondFragment.class, null);
}); });*/
String tab = requireArguments().getString("tab");
String[] totps = new String[]{"Code 1", "Code 2", tab};
for(String totp : totps) {
AuthenticateTotpBinding itemBinding = AuthenticateTotpBinding.inflate(inflater);
itemBinding.displayName.setText(totp);
binding.itemList.addView(itemBinding.getRoot());
}
return binding.getRoot(); return binding.getRoot();
} }

View File

@ -1,7 +1,4 @@
package com.cringe_studios.cringe_authenticator; 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.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -9,18 +6,10 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.biometric.BiometricPrompt;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.NavOptions;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;
import com.cringe_studios.cringe_authenticator.databinding.FragmentFirstBinding; import com.cringe_studios.cringe_authenticator.databinding.FragmentFirstBinding;
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
import java.util.concurrent.Executor;
public class FirstFragment extends Fragment { public class FirstFragment extends Fragment {

View File

@ -0,0 +1,52 @@
package com.cringe_studios.cringe_authenticator.fragment;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.cringe_studios.cringe_authenticator.R;
import com.cringe_studios.cringe_authenticator.databinding.FragmentMenuBinding;
import com.cringe_studios.cringe_authenticator.databinding.MenuItemBinding;
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
public class MenuFragment extends Fragment {
private FragmentMenuBinding binding;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = FragmentMenuBinding.inflate(inflater);
String[] items = {"a", "b"};
SharedPreferences pr = getContext().getSharedPreferences("menu", Context.MODE_PRIVATE);
for(String item : items) {
MenuItemBinding itemBinding = MenuItemBinding.inflate(inflater);
itemBinding.button.setText(item);
itemBinding.button.setOnClickListener(view -> {
Bundle bundle = new Bundle();
bundle.putString("tab", item);
NavigationUtil.navigate(this, DynamicFragment.class, bundle);
});
binding.menuItems.addView(itemBinding.getRoot(), 0);
}
binding.editSwitch.setOnCheckedChangeListener((view, checked) -> {
// TODO: edit mode
});
return binding.getRoot();
}
}

View File

@ -1,16 +1,15 @@
package com.cringe_studios.cringe_authenticator; package com.cringe_studios.cringe_authenticator.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;
import com.cringe_studios.cringe_authenticator.databinding.FragmentSecondBinding; import com.cringe_studios.cringe_authenticator.databinding.FragmentSecondBinding;
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
public class SecondFragment extends Fragment { public class SecondFragment extends Fragment {

View File

@ -1,4 +1,4 @@
package com.cringe_studios.cringe_authenticator; package com.cringe_studios.cringe_authenticator.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment;
import androidx.navigation.NavController; import androidx.navigation.NavController;
import androidx.navigation.Navigation; import androidx.navigation.Navigation;
import com.cringe_studios.cringe_authenticator.R;
import com.cringe_studios.cringe_authenticator.databinding.FragmentSettingsBinding; import com.cringe_studios.cringe_authenticator.databinding.FragmentSettingsBinding;
public class SettingsFragment extends Fragment { public class SettingsFragment extends Fragment {

View File

@ -1,19 +1,22 @@
package com.cringe_studios.cringe_authenticator; package com.cringe_studios.cringe_authenticator.util;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import com.cringe_studios.cringe_authenticator.R;
public class NavigationUtil { public class NavigationUtil {
public static void navigate(AppCompatActivity activity, Class<? extends Fragment> fragmentClass, Bundle args) { public static void navigate(AppCompatActivity activity, Class<? extends Fragment> fragmentClass, Bundle args) {
activity.getSupportActionBar().setTitle(fragmentClass.getSimpleName());
navigate(activity.getSupportFragmentManager().getPrimaryNavigationFragment().getChildFragmentManager(), fragmentClass, args); navigate(activity.getSupportFragmentManager().getPrimaryNavigationFragment().getChildFragmentManager(), fragmentClass, args);
} }
public static void navigate(Fragment currentFragment, Class<? extends Fragment> fragmentClass, Bundle args) { public static void navigate(Fragment currentFragment, Class<? extends Fragment> fragmentClass, Bundle args) {
((AppCompatActivity) currentFragment.getActivity()).getSupportActionBar().setTitle(fragmentClass.getSimpleName());
navigate(currentFragment.getParentFragment().getChildFragmentManager(), fragmentClass, args); navigate(currentFragment.getParentFragment().getChildFragmentManager(), fragmentClass, args);
} }

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#333333" />
<corners android:bottomLeftRadius="10dp" android:bottomRightRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp" />
</shape>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rectangle"
android:orientation="vertical">
<TextView
android:id="@+id/displayName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My TOTP"
android:textAlignment="center" />
<TextView
android:id="@+id/totpCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="000000"
android:textAlignment="center" />
</LinearLayout>

View File

@ -4,20 +4,20 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".SecondFragment"> tools:context=".fragment.SecondFragment">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="16dp"> android:padding="16dp">
<Button <LinearLayout
android:id="@+id/button_second" android:id="@+id/itemList"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:text="AMONG US" android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent" tools:layout_editor_absoluteX="16dp"
app:layout_constraintStart_toStartOf="parent" tools:layout_editor_absoluteY="16dp"></LinearLayout>
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".FirstFragment"> tools:context=".fragment.FirstFragment">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -4,21 +4,28 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".FirstFragment"> tools:context=".fragment.FirstFragment">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="16dp"> android:padding="16dp">
<Button <LinearLayout
android:id="@+id/button" android:id="@+id/menuItems"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:background="@drawable/round_rectangle" android:orientation="vertical"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> tools:layout_editor_absoluteY="16dp">
<Switch
android:id="@+id/editSwitch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Edit" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".SecondFragment"> tools:context=".fragment.SecondFragment">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".FirstFragment"> tools:context=".fragment.FirstFragment">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>

View File

@ -7,25 +7,25 @@
<fragment <fragment
android:id="@+id/FirstFragment" android:id="@+id/FirstFragment"
android:name="com.cringe_studios.cringe_authenticator.FirstFragment" android:name="com.cringe_studios.cringe_authenticator.fragment.FirstFragment"
android:label="@string/first_fragment_label" android:label="@string/first_fragment_label"
tools:layout="@layout/fragment_first"> tools:layout="@layout/fragment_first">
</fragment> </fragment>
<fragment <fragment
android:id="@+id/SecondFragment" android:id="@+id/SecondFragment"
android:name="com.cringe_studios.cringe_authenticator.SecondFragment" android:name="com.cringe_studios.cringe_authenticator.fragment.SecondFragment"
android:label="@string/second_fragment_label" android:label="@string/second_fragment_label"
tools:layout="@layout/fragment_second"> tools:layout="@layout/fragment_second">
</fragment> </fragment>
<fragment <fragment
android:id="@+id/SettingsFragment" android:id="@+id/SettingsFragment"
android:name="com.cringe_studios.cringe_authenticator.SettingsFragment" android:name="com.cringe_studios.cringe_authenticator.fragment.SettingsFragment"
android:label="Settings" android:label="Settings"
tools:layout="@layout/fragment_settings"> tools:layout="@layout/fragment_settings">
</fragment> </fragment>
<fragment <fragment
android:id="@+id/DynamicFragment" android:id="@+id/DynamicFragment"
android:name="com.cringe_studios.cringe_authenticator.DynamicFragment" android:name="com.cringe_studios.cringe_authenticator.fragment.DynamicFragment"
android:label="Dynamic" android:label="Dynamic"
tools:layout="@layout/fragment_dynamic"> tools:layout="@layout/fragment_dynamic">
</fragment> </fragment>

View File

@ -10,6 +10,9 @@ dependencyResolutionManagement {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
maven {
url "https://maven.graphite-official.com/releases"
}
} }
} }
rootProject.name = "Cringe Authenticator" rootProject.name = "Cringe Authenticator"