Skip to content

Commit c5dda08

Browse files
committed
Implement immersive theme
1 parent 54f9587 commit c5dda08

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ tasks.whenTaskAdded { task ->
6464
dependencies {
6565
implementation fileTree(dir: 'libs', include: ['*.jar'])
6666
implementation "androidx.preference:preference:1.1.0-rc01"
67-
implementation 'com.github.shadowsocks:plugin:1.3.0'
67+
implementation 'com.github.shadowsocks:plugin:1.3.1'
6868
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0'
6969
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
7070
testImplementation 'junit:junit:4.12'

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
<meta-data android:name="com.github.shadowsocks.plugin.executable_path"
2828
android:value="libv2ray.so"/>
2929
</provider>
30-
<activity android:name=".ConfigActivity">
30+
<activity android:name=".ConfigActivity"
31+
android:theme="@style/Theme.Shadowsocks.Immersive">
3132
<intent-filter>
3233
<action android:name="com.github.shadowsocks.plugin.ACTION_CONFIGURE"/>
3334
<category android:name="android.intent.category.DEFAULT"/>

app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigActivity.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ package com.github.shadowsocks.plugin.v2ray
2222

2323
import android.os.Bundle
2424
import android.view.MenuItem
25+
import android.view.View
2526
import androidx.appcompat.app.AlertDialog
2627
import androidx.appcompat.widget.Toolbar
28+
import androidx.core.view.updatePadding
2729
import com.github.shadowsocks.plugin.ConfigurationActivity
2830
import com.github.shadowsocks.plugin.PluginOptions
2931

@@ -34,6 +36,15 @@ class ConfigActivity : ConfigurationActivity(), Toolbar.OnMenuItemClickListener
3436
override fun onCreate(savedInstanceState: Bundle?) {
3537
super.onCreate(savedInstanceState)
3638
setContentView(R.layout.activity_main)
39+
findViewById<View>(android.R.id.content).apply {
40+
setOnApplyWindowInsetsListener { view, insets ->
41+
view.updatePadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop,
42+
insets.systemWindowInsetRight)
43+
@Suppress("DEPRECATION")
44+
insets.replaceSystemWindowInsets(0, 0, 0, insets.systemWindowInsetBottom)
45+
}
46+
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
47+
}
3748
findViewById<Toolbar>(R.id.toolbar).apply {
3849
title = this@ConfigActivity.title
3950
setNavigationIcon(R.drawable.ic_navigation_close)

app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigFragment.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import android.content.Intent
2525
import android.os.Bundle
2626
import android.text.InputFilter
2727
import android.text.InputType
28+
import android.view.View
29+
import androidx.core.view.updatePadding
2830
import androidx.preference.EditTextPreference
2931
import androidx.preference.ListPreference
3032
import androidx.preference.Preference
@@ -89,6 +91,13 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange
8991
}
9092
}
9193

94+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
95+
super.onViewCreated(view, savedInstanceState)
96+
listView.setOnApplyWindowInsetsListener { v, insets ->
97+
insets.apply { v.updatePadding(bottom = systemWindowInsetBottom) }
98+
}
99+
}
100+
92101
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
93102
val (mode, tls) = readMode(newValue as String)
94103
path.isEnabled = mode == null

0 commit comments

Comments
 (0)