Skip to content

Commit

Permalink
Responvie UI/Checkbox modification
Browse files Browse the repository at this point in the history
  • Loading branch information
Emre Tatlı authored and markpash committed Mar 7, 2024
1 parent 1f1fa9a commit 91fbe72
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 50 deletions.
22 changes: 20 additions & 2 deletions app/src/main/java/org/bepass/oblivion/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +28,8 @@ public class MainActivity extends ConnectionAwareBaseActivity {
Boolean canShowNotification = false;
private ActivityResultLauncher<String> pushNotificationPermissionLauncher;
private ActivityResultLauncher<Intent> vpnPermissionLauncher;

private long backPressedTime;
private Toast backToast;

private SwitchButton.OnCheckedChangeListener createSwitchCheckedChangeListener() {
return (view, isChecked) -> {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/color/checkbox_tint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Checked and enabled -->
<item android:color="#FFA200" android:state_checked="true" android:state_enabled="true"/>
<!-- Default (disabled) -->
<item android:color="?android:attr/colorControlNormal"/> <!-- This uses the default color -->
</selector>
66 changes: 36 additions & 30 deletions app/src/main/res/layout/activity_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@
</RelativeLayout>

<TextView
android:id="@+id/about"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="@font/shabnammedium"
android:textColor="@color/black"
android:paddingHorizontal="12dp"
android:text="این برنامه با هدف دسترسی به اینترنت آزاد تهیه شده و هرگونه استفاده تجاری از آن مجاز نیست.\n\n\n'اینترنت برای همه، یا هیچ‌کس!'" />
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" />

<RelativeLayout
android:id="@+id/github_layout"
Expand All @@ -69,34 +72,37 @@
app:tint="@color/black" />

<TextView
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: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" />

<TextView
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: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" />

</RelativeLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/shabnam"
android:textColor="@color/black"
android:gravity="center"
android:text="App Version: 1" />
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" />


</LinearLayout>
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
</LinearLayout>

Expand Down Expand Up @@ -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" />
</LinearLayout>

Expand Down Expand Up @@ -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" />
</LinearLayout>

Expand Down
30 changes: 15 additions & 15 deletions app/src/main/res/layout/edit_sheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

<View
android:id="@+id/dividingCloser"
android:layout_width="64dp"
android:layout_height="5dp"
android:layout_marginTop="8dp"
android:layout_width="64sp"
android:layout_height="5sp"
android:layout_marginTop="8sp"
android:background="@drawable/bottom_sheet_closer" />

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginTop="16sp"
android:fontFamily="@font/shabnam"
android:text="تغییر مقدار Endpoint"
android:textColor="@color/black"
Expand All @@ -27,13 +27,13 @@
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="12dp"
android:layout_height="48sp"
android:layout_marginHorizontal="16sp"
android:layout_marginTop="12sp"
android:background="@drawable/edittext_back"
android:fontFamily="@font/shabnam"
android:lineSpacingExtra="4dp"
android:padding="12dp"
android:lineSpacingExtra="4sp"
android:padding="12sp"
android:singleLine="true"
android:textAlignment="center"
android:textColor="@color/black"
Expand All @@ -42,15 +42,15 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="12dp"
android:layout_marginHorizontal="16sp"
android:layout_marginVertical="12sp"
android:orientation="horizontal">

<Button
android:id="@+id/cancelButton"
android:layout_width="0dp"
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginEnd="8sp"
android:layout_weight="1"
android:background="@drawable/bottom_sheet_cancel"
android:fontFamily="@font/shabnam"
Expand All @@ -60,9 +60,9 @@

<Button
android:id="@+id/applyButton"
android:layout_width="0dp"
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginEnd="8sp"
android:layout_weight="1"
android:background="@drawable/bottom_sheet_closer"
android:fontFamily="@font/shabnam"
Expand Down

0 comments on commit 91fbe72

Please sign in to comment.