Remove HomeFragment, Double back to exit

This commit is contained in:
MrLetsplay 2023-10-03 19:16:24 +02:00
parent 1734907eb7
commit abe74d8315
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
8 changed files with 15 additions and 74 deletions

View File

@ -24,7 +24,6 @@ import com.cringe_studios.code_guard.databinding.DialogInputCodeChoiceBinding;
import com.cringe_studios.code_guard.fragment.AboutFragment;
import com.cringe_studios.code_guard.fragment.EditOTPFragment;
import com.cringe_studios.code_guard.fragment.GroupFragment;
import com.cringe_studios.code_guard.fragment.HomeFragment;
import com.cringe_studios.code_guard.fragment.NamedFragment;
import com.cringe_studios.code_guard.fragment.SettingsFragment;
import com.cringe_studios.code_guard.icon.IconPack;
@ -48,6 +47,8 @@ import java.util.UUID;
public class MainActivity extends BaseActivity {
private static final long BACK_BUTTON_DELAY = 500;
private ActivityMainBinding binding;
private ActivityResultLauncher<Void> startQRCodeScan;
@ -74,6 +75,8 @@ public class MainActivity extends BaseActivity {
private boolean lockOnStop = true;
private long backLastPressed;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -251,7 +254,9 @@ public class MainActivity extends BaseActivity {
ActionBar bar = getSupportActionBar();
if(bar != null) bar.setTitle(((NamedFragment) fragment).getName());
}else {
NavigationUtil.navigate(this, HomeFragment.class, null);
Bundle bundle = new Bundle();
bundle.putString(GroupFragment.BUNDLE_GROUP, SettingsUtil.getGroups(this).get(0));
NavigationUtil.navigate(this, GroupFragment.class, bundle);
}
if(SettingsUtil.isFirstLaunch(this) && SettingsUtil.getGroups(this).isEmpty()) {
@ -314,12 +319,11 @@ public class MainActivity extends BaseActivity {
return;
}
if(!(fragment instanceof HomeFragment)) {
NavigationUtil.navigate(this, HomeFragment.class, null);
return;
if(System.currentTimeMillis() - backLastPressed < BACK_BUTTON_DELAY) {
finishAffinity();
}else {
backLastPressed = System.currentTimeMillis();
}
finishAffinity();
}
public void openSettings(MenuItem item) {

View File

@ -1,39 +0,0 @@
package com.cringe_studios.code_guard.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.cringe_studios.code_guard.R;
import com.cringe_studios.code_guard.databinding.FragmentHomeBinding;
public class HomeFragment extends NamedFragment {
private FragmentHomeBinding binding;
@Override
public String getName() {
return requireActivity().getString(R.string.fragment_home);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentHomeBinding.inflate(inflater, container, false);
return binding.getRoot();
}
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
}

View File

@ -5,7 +5,7 @@
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?android:attr/colorBackground"
tools:context=".fragment.HomeFragment">
tools:context=".fragment.AboutFragment">
<LinearLayout
android:layout_width="match_parent"

View File

@ -4,7 +4,7 @@
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.EditOTPFragment"
android:background="?android:attr/colorBackground">
<LinearLayout

View File

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragment.HomeFragment">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleX="0.5"
android:scaleY="0.5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/cringeauth_white" />
</androidx.constraintlayout.widget.ConstraintLayout>

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=".fragment.HomeFragment"
tools:context=".fragment.SettingsFragment"
android:background="?android:attr/colorBackground">
<LinearLayout

View File

@ -79,7 +79,6 @@
<string name="settings">Einstellungen</string>
<string name="appearance">Aussehen</string>
<string name="developed_by">Developed by Cringe Studios and JG-Cody</string>
<string name="fragment_home">Startseite</string>
<string name="fragment_settings">Einstellungen</string>
<string name="fragment_about">Über</string>
<string name="fragment_edit_otp">OTP bearbeiten</string>
@ -120,7 +119,7 @@
<string name="error_icon_pack_exists">Das Symbolpaket, das du versuchst zu importieren, existiert bereits.\n\nImportiert: %s (Version %d)\nVorhanden: %s (Version %d)\n\nWas willst du tun?</string>
<string name="broken_icon_packs_title">Beschädigte Symbolpakete</string>
<string name="broken_icon_packs_message">Einige Symbolpakete konnten nicht geladen werden.\n\nWillst du die beschädigten Symbolpakete entfernen?</string>
<string name="icon_pack_imported">Symbolpaket mit %s Symbol(en) importiert</string>
<string name="icon_pack_imported">Symbolpaket mit %d Symbol(en) importiert</string>
<string name="enable_encryption_message">Es ist empfehlenswert, Verschlüsselung zu aktivieren, um die Sicherheit der App zu erhöhen.\n\nMöchtest du zu den Einstellungen wechseln, um Verschlüsselung zu aktivieren?</string>
<string name="enable_encryption_title">Verschlüsselung aktivieren</string>
</resources>

View File

@ -63,7 +63,6 @@
<string name="settings">Settings</string>
<string name="appearance">Appearance</string>
<string name="developed_by">Developed by Cringe Studios and JG-Cody</string>
<string name="fragment_home">Home</string>
<string name="fragment_settings">Settings</string>
<string name="fragment_about">About</string>
<string name="fragment_edit_otp">Edit OTP</string>