From ed3b7f09be7bfc5cc5ea88e2c4374f8693781db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emre=20Tatl=C4=B1?= Date: Mon, 4 Mar 2024 19:32:47 +0330 Subject: [PATCH] Responvie UI/Checkbox modification --- .../org/bepass/oblivion/MainActivity.java | 22 ++++++- app/src/main/res/color/checkbox_tint.xml | 7 ++ app/src/main/res/layout/activity_info.xml | 66 ++++++++++--------- app/src/main/res/layout/activity_settings.xml | 6 +- app/src/main/res/layout/edit_sheet.xml | 30 ++++----- 5 files changed, 81 insertions(+), 50 deletions(-) create mode 100644 app/src/main/res/color/checkbox_tint.xml diff --git a/app/src/main/java/org/bepass/oblivion/MainActivity.java b/app/src/main/java/org/bepass/oblivion/MainActivity.java index 59cde9a0..4830bfde 100644 --- a/app/src/main/java/org/bepass/oblivion/MainActivity.java +++ b/app/src/main/java/org/bepass/oblivion/MainActivity.java @@ -9,7 +9,9 @@ import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; +import android.window.OnBackInvokedDispatcher; +import androidx.activity.OnBackPressedCallback; import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; @@ -26,7 +28,8 @@ public class MainActivity extends ConnectionAwareBaseActivity { Boolean canShowNotification = false; private ActivityResultLauncher pushNotificationPermissionLauncher; private ActivityResultLauncher vpnPermissionLauncher; - + private long backPressedTime; + private Toast backToast; private SwitchButton.OnCheckedChangeListener createSwitchCheckedChangeListener() { return (view, isChecked) -> { @@ -57,11 +60,26 @@ private SwitchButton.OnCheckedChangeListener createSwitchCheckedChangeListener() protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { + @Override + public void handleOnBackPressed() { + // Custom back pressed logic here + if (backPressedTime + 2000 > System.currentTimeMillis()) { + if (backToast != null) backToast.cancel(); + finish(); // or super.handleOnBackPressed() if you want to keep default behavior alongside + } else { + if (backToast != null) backToast.cancel(); // Cancel the existing toast to avoid stacking + backToast = Toast.makeText(MainActivity.this, "برای خروج، دوباره بازگشت را فشار دهید.", Toast.LENGTH_SHORT); + backToast.show(); + } + backPressedTime = System.currentTimeMillis(); + } + }); init(); firstValueInit(); switchButton.setOnCheckedChangeListener(createSwitchCheckedChangeListener()); - } + } @NonNull @Override diff --git a/app/src/main/res/color/checkbox_tint.xml b/app/src/main/res/color/checkbox_tint.xml new file mode 100644 index 00000000..c16dcc3a --- /dev/null +++ b/app/src/main/res/color/checkbox_tint.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/src/main/res/layout/activity_info.xml b/app/src/main/res/layout/activity_info.xml index bc45952a..6f97ac97 100644 --- a/app/src/main/res/layout/activity_info.xml +++ b/app/src/main/res/layout/activity_info.xml @@ -38,14 +38,17 @@ + android:id="@+id/about" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="end" + android:layout_marginTop="16dp" + android:fontFamily="@font/shabnammedium" + android:paddingHorizontal="12dp" + android:text='این برنامه با هدف دسترسی به اینترنت آزاد تهیه شده و هرگونه استفاده تجاری از آن مجاز نیست.\n\n\n" اینترنت برای همه، یا هیچ‌کس! "' + android:textAlignment="textEnd" + android:textColor="@color/black" + android:textSize="16sp" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:layout_toEndOf="@id/github_image" + android:fontFamily="@font/shabnam" + android:text="Github" + android:textColor="@color/black" + android:textSize="14sp" /> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentEnd="true" + android:layout_centerVertical="true" + android:layout_marginEnd="16dp" + android:fontFamily="@font/shabnambold" + android:text="BePass/Oblivion" + android:textColor="@color/black" + android:textSize="14sp" /> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:fontFamily="@font/shabnam" + android:gravity="center" + android:text="App Version: 1" + android:textColor="@color/black" + android:textSize="14sp" /> diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 1152bd9d..d49ff31c 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -241,7 +241,7 @@ android:layout_height="38dp" android:scaleX="1.5" android:scaleY="1.5" - android:buttonTint="#9F9D9E" + android:buttonTint="@color/checkbox_tint" android:translationX="5dp" /> @@ -302,7 +302,7 @@ android:layout_height="38dp" android:scaleX="1.5" android:scaleY="1.5" - android:buttonTint="#9F9D9E" + android:buttonTint="@color/checkbox_tint" android:translationX="5dp" /> @@ -473,7 +473,7 @@ android:layout_height="38dp" android:scaleX="1.5" android:scaleY="1.5" - android:buttonTint="#9F9D9E" + android:buttonTint="@color/checkbox_tint" android:translationX="5dp" /> diff --git a/app/src/main/res/layout/edit_sheet.xml b/app/src/main/res/layout/edit_sheet.xml index 7a22b59c..4897119b 100644 --- a/app/src/main/res/layout/edit_sheet.xml +++ b/app/src/main/res/layout/edit_sheet.xml @@ -9,16 +9,16 @@