Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platforms;android-36"

- name: Compile Release APK using Gradle
run: gradle assembleRelease -PversionCode=${{ github.run_number }}
run: gradle assembleRelease -PversionCode=${{ github.run_number }} -PversionName=1.0.${{ github.run_number }}

- name: Decode Permanent Keystore
run: |
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk = 24
targetSdk = 36
versionCode = (project.findProperty("versionCode") as String?)?.toIntOrNull() ?: 2
versionName = "1.0"
versionName = (project.findProperty("versionName") as String?) ?: "1.0.0"
}
// Suggested by IzzyOnDroid
dependenciesInfo {
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/java/com/dhangofa/networktoggle/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
package com.dhangofa.networktoggle;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
Expand All @@ -33,6 +37,9 @@ public class MainActivity extends Activity {
private RadioButton radioRoot;
private RadioButton radioShizuku;
private TextView statusText;
private TextView appVersionText;
private ImageView githubLink;
private ImageView telegramLink;
private SharedPreferences prefs;

private volatile boolean activityDestroyed = false;
Expand Down Expand Up @@ -86,6 +93,15 @@ protected void onCreate(Bundle savedInstanceState) {
radioRoot = findViewById(R.id.radioRoot);
radioShizuku = findViewById(R.id.radioShizuku);
statusText = findViewById(R.id.shizukuStatusText);

appVersionText = findViewById(R.id.appVersionText);
githubLink = findViewById(R.id.githubLink);
telegramLink = findViewById(R.id.telegramLink);

appVersionText.setText("v" + getAppVersionName());

githubLink.setOnClickListener(v -> openUrl("https://github.com/Dhangofa/NetToggle"));
telegramLink.setOnClickListener(v -> openUrl("https://t.me/dhangofa"));

// Register the lifecycle listeners
Shizuku.addBinderReceivedListener(binderReceivedListener);
Expand Down Expand Up @@ -221,4 +237,21 @@ private void checkShizukuPermission(boolean requestIfNeeded) {
statusText.setTextColor(0xFFFF5555);
}
}

private String getAppVersionName() {
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
return packageInfo.versionName;
} catch (Exception e) {
return "unknown";
}
}

private void openUrl(String url) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
} catch (Exception ignored) {
}
}
}
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_github.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,0c-6.626,0 -12,5.373 -12,12c0,5.302 3.438,9.8 8.207,11.387c0.599,0.111 0.793,-0.261 0.793,-0.577v-2.234c-3.338,0.726 -4.033,-1.416 -4.033,-1.416c-0.546,-1.387 -1.333,-1.756 -1.333,-1.756c-1.089,-0.745 0.083,-0.729 0.083,-0.729c1.205,0.084 1.839,1.237 1.839,1.237c1.07,1.834 2.807,1.304 3.492,0.997c0.107,-0.775 0.418,-1.305 0.762,-1.604c-2.665,-0.305 -5.467,-1.334 -5.467,-5.931c0,-1.311 0.469,-2.381 1.236,-3.221c-0.124,-0.303 -0.535,-1.524 0.117,-3.176c0,0 1.008,-0.322 3.301,1.23c0.957,-0.266 1.983,-0.399 3.003,-0.404c1.02,0.005 2.047,0.138 3.006,0.404c2.291,-1.552 3.297,-1.23 3.297,-1.23c0.653,1.653 0.242,2.874 0.118,3.176c0.77,0.84 1.235,1.911 1.235,3.221c0,4.609 -2.807,5.624 -5.479,5.921c0.43,0.372 0.823,1.102 0.823,2.222v3.293c0,0.319 0.192,0.694 0.801,0.576c4.765,-1.589 8.199,-6.086 8.199,-11.386c0,-6.627 -5.373,-12 -12,-12z" />

</vector>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_person.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="512"
android:viewportHeight="512">

<path
android:fillColor="#FFFFFFFF"
android:pathData="M364.038,355.035c-19.948,-7.458 -49.037,-29.238 -49.037,-42.797c0,-8.983 0,-20.205 0,-35.587c11.528,-12.826 20.294,-38.864 25.504,-68.38c12.152,-4.338 19.096,-11.281 27.771,-41.658c9.221,-32.358 -13.886,-31.258 -13.886,-31.258c18.69,-61.873 -5.913,-120.022 -47.125,-115.753c-28.426,-49.73 -123.636,11.36 -153.468,7.102c0,17.055 7.102,29.842 7.102,29.842c-10.37,19.69 -6.37,58.951 -3.458,78.809c-1.684,-0.03 -22.581,0.188 -13.717,31.258c8.676,30.376 15.619,37.32 27.772,41.658c5.2,29.516 13.965,55.554 25.504,68.38c0,15.382 0,26.604 0,35.587c0,13.559 -30.901,36.399 -49.036,42.797c-37.469,13.193 -129.54,51.136 -123.597,122.21C25.792,494.301 119.577,512 256,512c136.414,0 230.209,-17.699 231.635,-34.755C493.577,406.102 401.269,368.961 364.038,355.035z" />

</vector>
33 changes: 33 additions & 0 deletions app/src/main/res/drawable/ic_telegram.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="32"
android:viewportHeight="32">

<path
android:fillColor="#FFFFFFFF"
android:fillType="evenOdd"
android:pathData="
M16,0
C7.164,0 0,7.164 0,16
C0,24.836 7.164,32 16,32
C24.836,32 32,24.836 32,16
C32,7.164 24.836,0 16,0
Z

M22.9866,10.2088
C23.1112,9.40332 22.3454,8.76755 21.6292,9.082
L7.36482,15.3448
C6.85123,15.5703 6.8888,16.3483 7.42147,16.5179
L10.3631,17.4547
C10.9246,17.6335 11.5325,17.541 12.0228,17.2023
L18.655,12.6203
C18.855,12.4821 19.073,12.7665 18.9021,12.9426
L14.1281,17.8646
C13.665,18.3421 13.7569,19.1512 14.314,19.5005
L19.659,22.8523
C20.2585,23.2282 21.0297,22.8506 21.1418,22.1261
L22.9866,10.2088
Z" />

</vector>
7 changes: 7 additions & 0 deletions app/src/main/res/drawable/social_icon_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid android:color="?android:attr/colorControlHighlight" />

</shape>
205 changes: 154 additions & 51 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,65 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="32dp"
android:gravity="center_horizontal"
android:background="?android:attr/colorBackground">
android:background="?android:attr/colorBackground"
android:fillViewport="true">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NetToggle Configuration"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginTop="32dp"
android:layout_marginBottom="8dp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Select the background execution method for the Quick Settings tile."
android:textSize="14sp"
android:gravity="center"
android:textColor="?android:attr/textColorSecondary"
android:layout_marginBottom="48dp" />

<RadioGroup
android:id="@+id/modeRadioGroup"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:padding="32dp"
android:gravity="center_horizontal">

<TextView
android:id="@+id/appTitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NetToggle"
android:textSize="26sp"
android:textStyle="bold"
android:layout_marginTop="24dp"
android:layout_marginBottom="2dp" />

<TextView
android:id="@+id/appVersionText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="v0.0.0"
android:textSize="13sp"
android:textColor="?android:attr/textColorSecondary"
android:layout_marginBottom="10dp" />

<RadioButton
android:id="@+id/radioRoot"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Root (su)"
android:textSize="18sp"
android:padding="16dp"
android:layout_marginBottom="12dp"
android:background="?android:attr/selectableItemBackground" />

<RadioButton
android:id="@+id/radioShizuku"
android:text="Switch Network between 5G, 4G, Preferred 5G and Preferred 4G from Quick Settings."
android:textSize="14sp"
android:gravity="center"
android:textColor="?android:attr/textColorSecondary"
android:layout_marginBottom="36dp" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Shizuku (ADB)"
android:textSize="18sp"
android:padding="16dp"
android:background="?android:attr/selectableItemBackground" />
android:text="Execution Mode"
android:textSize="16sp"
android:textStyle="bold"
android:layout_marginBottom="8dp" />

</RadioGroup>
<RadioGroup
android:id="@+id/modeRadioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/shizukuStatusText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="14sp"
android:gravity="center"
android:textColor="#FF5555"
android:layout_marginTop="24dp" />
<RadioButton
android:id="@+id/radioRoot"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Root (su)"
android:textSize="18sp"
android:padding="16dp"
android:layout_marginBottom="12dp"
android:background="?android:attr/selectableItemBackground" />

<RadioButton
android:id="@+id/radioShizuku"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Shizuku (ADB)"
android:textSize="18sp"
android:padding="16dp"
android:background="?android:attr/selectableItemBackground" />

</RadioGroup>

<TextView
android:id="@+id/shizukuStatusText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="14sp"
android:gravity="center"
android:textColor="#FF5555"
android:layout_marginTop="24dp"
android:layout_marginBottom="28dp" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#333333"
android:layout_marginTop="4dp"
android:layout_marginBottom="18dp" />

<TextView
android:id="@+id/developerTitleText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Developer"
android:textSize="16sp"
android:textStyle="bold"
android:gravity="center"
android:layout_marginBottom="12dp" />

<ImageView
android:id="@+id/developerPersonIcon"
android:layout_width="72dp"
android:layout_height="72dp"
android:padding="14dp"
android:src="@drawable/ic_person"
android:tint="?android:attr/textColorPrimary"
android:background="@drawable/social_icon_bg"
android:contentDescription="Developer"
android:layout_marginBottom="8dp" />

<TextView
android:id="@+id/developerNameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dhangofa"
android:textSize="16sp"
android:textStyle="bold"
android:gravity="center"
android:layout_marginBottom="18dp" />

<LinearLayout
android:id="@+id/socialLinksRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginTop="4dp"
android:layout_marginBottom="8dp">

<ImageView
android:id="@+id/githubLink"
android:layout_width="72dp"
android:layout_height="72dp"
android:padding="16dp"
android:src="@drawable/ic_github"
android:tint="?android:attr/textColorPrimary"
android:contentDescription="GitHub"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackgroundBorderless" />

<Space
android:layout_width="28dp"
android:layout_height="1dp" />

<ImageView
android:id="@+id/telegramLink"
android:layout_width="72dp"
android:layout_height="72dp"
android:padding="16dp"
android:src="@drawable/ic_telegram"
android:tint="?android:attr/textColorPrimary"
android:contentDescription="Telegram"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackgroundBorderless" />

</LinearLayout>

</LinearLayout>

</LinearLayout>
</ScrollView>
Loading