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.espresso:espresso-core:3.5.1'
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;
import static androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG;
import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL;
import android.os.Bundle;
import com.google.android.material.snackbar.Snackbar;
import android.view.Menu;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import androidx.biometric.BiometricPrompt;
import androidx.core.content.ContextCompat;
import androidx.core.view.WindowCompat;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.cringe_studios.cringe_authenticator.databinding.ActivityMainBinding;
import android.view.Menu;
import android.view.MenuItem;
import com.cringe_studios.cringe_authenticator.fragment.MenuFragment;
import com.cringe_studios.cringe_authenticator.fragment.SettingsFragment;
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
import java.util.concurrent.Executor;
@ -70,9 +63,7 @@ public class MainActivity extends AppCompatActivity {
appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
binding.fab.setOnClickListener(view -> Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAnchorView(R.id.fab)
.setAction("Action", null).show());
binding.fab.setOnClickListener(view -> NavigationUtil.navigate(this, MenuFragment.class, null));
}
@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.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -9,12 +8,11 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
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.FragmentFirstBinding;
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
public class DynamicFragment extends Fragment {
@ -23,17 +21,26 @@ public class DynamicFragment extends Fragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("AMOGUS", requireArguments().getString("sus"));
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = FragmentDynamicBinding.inflate(inflater, container, false);
binding.buttonSecond.setText(requireArguments().getString("sus"));
/*binding.buttonSecond.setText(requireArguments().getString("tab"));
binding.buttonSecond.setOnClickListener(view -> {
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();
}

View File

@ -1,7 +1,4 @@
package com.cringe_studios.cringe_authenticator;
import static androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG;
import static androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL;
package com.cringe_studios.cringe_authenticator.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
@ -9,18 +6,10 @@ import android.view.View;
import android.view.ViewGroup;
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.navigation.NavController;
import androidx.navigation.NavOptions;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;
import com.cringe_studios.cringe_authenticator.databinding.FragmentFirstBinding;
import java.util.concurrent.Executor;
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
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.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;
import com.cringe_studios.cringe_authenticator.databinding.FragmentSecondBinding;
import com.cringe_studios.cringe_authenticator.util.NavigationUtil;
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.view.LayoutInflater;
@ -12,6 +12,7 @@ import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import com.cringe_studios.cringe_authenticator.R;
import com.cringe_studios.cringe_authenticator.databinding.FragmentSettingsBinding;
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 androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.cringe_studios.cringe_authenticator.R;
public class NavigationUtil {
public static void navigate(AppCompatActivity activity, Class<? extends Fragment> fragmentClass, Bundle args) {
activity.getSupportActionBar().setTitle(fragmentClass.getSimpleName());
navigate(activity.getSupportFragmentManager().getPrimaryNavigationFragment().getChildFragmentManager(), fragmentClass, 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);
}

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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SecondFragment">
tools:context=".fragment.SecondFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<Button
android:id="@+id/button_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AMONG US"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/itemList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="16dp"></LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FirstFragment">
tools:context=".fragment.FirstFragment">
<androidx.constraintlayout.widget.ConstraintLayout
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
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"
tools:layout="@layout/fragment_first">
</fragment>
<fragment
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"
tools:layout="@layout/fragment_second">
</fragment>
<fragment
android:id="@+id/SettingsFragment"
android:name="com.cringe_studios.cringe_authenticator.SettingsFragment"
android:name="com.cringe_studios.cringe_authenticator.fragment.SettingsFragment"
android:label="Settings"
tools:layout="@layout/fragment_settings">
</fragment>
<fragment
android:id="@+id/DynamicFragment"
android:name="com.cringe_studios.cringe_authenticator.DynamicFragment"
android:name="com.cringe_studios.cringe_authenticator.fragment.DynamicFragment"
android:label="Dynamic"
tools:layout="@layout/fragment_dynamic">
</fragment>

View File

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