Skip to content

Commit

Permalink
Add androidTv support
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezaafkar authored and markpash committed Apr 3, 2024
1 parent 91fbe72 commit eae2063
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 27 deletions.
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:banner="@mipmap/tv_banner"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
tools:replace="android:supportsRtl"
Expand Down Expand Up @@ -67,6 +68,7 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
<activity
Expand Down Expand Up @@ -98,4 +100,4 @@
android:exported="false" />
</application>

</manifest>
</manifest>
6 changes: 5 additions & 1 deletion app/src/main/java/org/bepass/oblivion/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import android.window.OnBackInvokedDispatcher;
import android.widget.FrameLayout;

import androidx.activity.OnBackPressedCallback;
import androidx.activity.result.ActivityResultLauncher;
Expand Down Expand Up @@ -179,6 +179,7 @@ private void init() {
bugIcon = findViewById(R.id.bug_icon);
settingsIcon = findViewById(R.id.setting_icon);

FrameLayout switchButtonFrame = findViewById(R.id.switch_button_frame);
switchButton = findViewById(R.id.switch_button);
stateText = findViewById(R.id.state_text);
publicIP = findViewById(R.id.publicIP);
Expand All @@ -187,5 +188,8 @@ private void init() {
infoIcon.setOnClickListener(v -> startActivity(new Intent(MainActivity.this, InfoActivity.class)));
bugIcon.setOnClickListener(v -> startActivity(new Intent(MainActivity.this, BugActivity.class)));
settingsIcon.setOnClickListener(v -> startActivity(new Intent(MainActivity.this, SettingsActivity.class)));
switchButtonFrame.setOnClickListener(v -> {
switchButton.toggle();
});
}
}
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/switch_ripple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#000000" />
<corners android:radius="40dp" />
</shape>
</item>
</ripple>
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_bug.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
android:id="@+id/back"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?selectableItemBackgroundBorderless"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
android:id="@+id/back"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?selectableItemBackgroundBorderless"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
Expand Down
43 changes: 26 additions & 17 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
android:id="@+id/info_icon"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?selectableItemBackgroundBorderless"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
Expand All @@ -31,6 +32,7 @@
android:id="@+id/bug_icon"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?selectableItemBackgroundBorderless"
android:layout_alignParentTop="true"
android:layout_marginTop="7dp"
android:layout_marginEnd="14dp"
Expand All @@ -42,6 +44,7 @@
android:id="@+id/setting_icon"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?selectableItemBackgroundBorderless"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
Expand All @@ -64,22 +67,28 @@

</LinearLayout>


<org.bepass.oblivion.TouchAwareSwitch
android:id="@+id/switch_button"
android:layout_width="160dp"
android:layout_height="75dp"
android:layout_centerInParent="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.565"
app:sb_background="#D7D7D7"
app:sb_border_width="3dp"
app:sb_checked_color="#FFA200"
app:sb_show_indicator="false" />
<FrameLayout
android:id="@+id/switch_button_frame"
android:layout_width="160dp"
android:layout_height="75dp"
android:layout_centerInParent="true"
android:background="@drawable/switch_ripple"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.565">

<org.bepass.oblivion.TouchAwareSwitch
android:id="@+id/switch_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:sb_background="#D7D7D7"
app:sb_border_width="3dp"
app:sb_checked_color="#FFA200"
app:sb_show_indicator="false" />
</FrameLayout>

<TextView
android:id="@+id/state_text"
Expand All @@ -92,7 +101,7 @@
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/switch_button" />
app:layout_constraintTop_toBottomOf="@id/switch_button_frame" />

<TextView
android:id="@+id/publicIP"
Expand Down
24 changes: 16 additions & 8 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
android:id="@+id/back"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?selectableItemBackgroundBorderless"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
Expand Down Expand Up @@ -58,7 +59,8 @@
<LinearLayout
android:id="@+id/endpoint_layout"
android:layout_width="match_parent"
android:layout_marginHorizontal="16dp"
android:paddingHorizontal="16dp"
android:background="?selectableItemBackground"
android:layout_height="80dp"
android:gravity="center"
android:orientation="vertical">
Expand Down Expand Up @@ -117,7 +119,8 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginHorizontal="16dp"
android:paddingHorizontal="16dp"
android:background="?selectableItemBackground"
android:orientation="vertical">

<LinearLayout
Expand Down Expand Up @@ -176,7 +179,7 @@
android:layout_height="80dp"
android:background="?android:selectableItemBackground"
android:gravity="center"
android:layout_marginHorizontal="16dp"
android:paddingHorizontal="16dp"
android:orientation="vertical">

<LinearLayout
Expand Down Expand Up @@ -221,7 +224,8 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginHorizontal="16dp"
android:paddingHorizontal="16dp"
android:background="?selectableItemBackground"
android:orientation="vertical">

<LinearLayout
Expand Down Expand Up @@ -282,7 +286,8 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginHorizontal="16dp"
android:paddingHorizontal="16dp"
android:background="?selectableItemBackground"
android:orientation="vertical"
>

Expand Down Expand Up @@ -344,7 +349,8 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginHorizontal="16dp"
android:paddingHorizontal="16dp"
android:background="?selectableItemBackground"
android:orientation="vertical">

<LinearLayout
Expand Down Expand Up @@ -397,7 +403,8 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginHorizontal="16dp"
android:paddingHorizontal="16dp"
android:background="?selectableItemBackground"
android:orientation="vertical">

<LinearLayout
Expand Down Expand Up @@ -455,7 +462,8 @@
android:layout_width="match_parent"
android:layout_height="80dp"
android:gravity="center"
android:layout_marginHorizontal="16dp"
android:paddingHorizontal="16dp"
android:background="?selectableItemBackground"
android:orientation="vertical">

<LinearLayout
Expand Down
Binary file added app/src/main/res/mipmap-xhdpi/tv_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eae2063

Please sign in to comment.