From c5dda08c19cbb54ed7ecf1d3df11e8e5bcd7d4e7 Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 23 Aug 2019 22:54:44 +0800 Subject: [PATCH] Implement immersive theme --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 3 ++- .../github/shadowsocks/plugin/v2ray/ConfigActivity.kt | 11 +++++++++++ .../github/shadowsocks/plugin/v2ray/ConfigFragment.kt | 9 +++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1e502c0..47df812 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -64,7 +64,7 @@ tasks.whenTaskAdded { task -> dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "androidx.preference:preference:1.1.0-rc01" - implementation 'com.github.shadowsocks:plugin:1.3.0' + implementation 'com.github.shadowsocks:plugin:1.3.1' implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" testImplementation 'junit:junit:4.12' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 838bf1a..d4a1ff4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,7 +27,8 @@ - + diff --git a/app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigActivity.kt b/app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigActivity.kt index cab4bbb..74007b9 100644 --- a/app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigActivity.kt +++ b/app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigActivity.kt @@ -22,8 +22,10 @@ package com.github.shadowsocks.plugin.v2ray import android.os.Bundle import android.view.MenuItem +import android.view.View import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.Toolbar +import androidx.core.view.updatePadding import com.github.shadowsocks.plugin.ConfigurationActivity import com.github.shadowsocks.plugin.PluginOptions @@ -34,6 +36,15 @@ class ConfigActivity : ConfigurationActivity(), Toolbar.OnMenuItemClickListener override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + findViewById(android.R.id.content).apply { + setOnApplyWindowInsetsListener { view, insets -> + view.updatePadding(insets.systemWindowInsetLeft, insets.systemWindowInsetTop, + insets.systemWindowInsetRight) + @Suppress("DEPRECATION") + insets.replaceSystemWindowInsets(0, 0, 0, insets.systemWindowInsetBottom) + } + systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + } findViewById(R.id.toolbar).apply { title = this@ConfigActivity.title setNavigationIcon(R.drawable.ic_navigation_close) diff --git a/app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigFragment.kt b/app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigFragment.kt index 3bf711d..57afe9c 100644 --- a/app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigFragment.kt +++ b/app/src/main/java/com/github/shadowsocks/plugin/v2ray/ConfigFragment.kt @@ -25,6 +25,8 @@ import android.content.Intent import android.os.Bundle import android.text.InputFilter import android.text.InputType +import android.view.View +import androidx.core.view.updatePadding import androidx.preference.EditTextPreference import androidx.preference.ListPreference import androidx.preference.Preference @@ -89,6 +91,13 @@ class ConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChange } } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + listView.setOnApplyWindowInsetsListener { v, insets -> + insets.apply { v.updatePadding(bottom = systemWindowInsetBottom) } + } + } + override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean { val (mode, tls) = readMode(newValue as String) path.isEnabled = mode == null