Commit 4e5afbad authored by Mygod's avatar Mygod

Update dependencies

parent e2166f2d
...@@ -9,7 +9,7 @@ buildscript { ...@@ -9,7 +9,7 @@ buildscript {
minSdkVersion = 21 minSdkVersion = 21
sdkVersion = 29 sdkVersion = 29
compileSdkVersion = 29 compileSdkVersion = 29
lifecycleVersion = '2.2.0-rc03' lifecycleVersion = '2.2.0'
desugarLibsVersion = '1.0.4' desugarLibsVersion = '1.0.4'
junitVersion = '4.13' junitVersion = '4.13'
androidTestVersion = '1.2.0' androidTestVersion = '1.2.0'
......
...@@ -52,12 +52,11 @@ androidExtensions { ...@@ -52,12 +52,11 @@ androidExtensions {
def coroutinesVersion = '1.3.3' def coroutinesVersion = '1.3.3'
def roomVersion = '2.2.3' def roomVersion = '2.2.3'
def workVersion = '2.2.0' def workVersion = '2.3.0'
dependencies { dependencies {
api project(':plugin') api project(':plugin')
api 'androidx.activity:activity-ktx:1.1.0-rc03' api 'androidx.fragment:fragment-ktx:1.2.0'
api "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion" api "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
api "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
api "androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion" api "androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion"
api 'androidx.preference:preference:1.1.0' api 'androidx.preference:preference:1.1.0'
api "androidx.room:room-runtime:$roomVersion" api "androidx.room:room-runtime:$roomVersion"
......
...@@ -34,10 +34,5 @@ class GlobalSettingsFragment : ToolbarFragment() { ...@@ -34,10 +34,5 @@ class GlobalSettingsFragment : ToolbarFragment() {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
view.setOnApplyWindowInsetsListener(ListHolderListener) view.setOnApplyWindowInsetsListener(ListHolderListener)
toolbar.setTitle(R.string.settings) toolbar.setTitle(R.string.settings)
if (savedInstanceState != null) return
val fm = childFragmentManager
fm.beginTransaction().replace(R.id.content, GlobalSettingsPreferenceFragment()).commit()
fm.executePendingTransactions()
} }
} }
...@@ -39,6 +39,7 @@ import androidx.core.net.toUri ...@@ -39,6 +39,7 @@ import androidx.core.net.toUri
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.core.view.updateLayoutParams import androidx.core.view.updateLayoutParams
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
import androidx.fragment.app.replace
import androidx.preference.PreferenceDataStore import androidx.preference.PreferenceDataStore
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.github.shadowsocks.acl.CustomRulesFragment import com.github.shadowsocks.acl.CustomRulesFragment
...@@ -167,7 +168,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref ...@@ -167,7 +168,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
navigation.setNavigationItemSelectedListener(this) navigation.setNavigationItemSelectedListener(this)
if (savedInstanceState == null) { if (savedInstanceState == null) {
navigation.menu.findItem(R.id.profiles).isChecked = true navigation.menu.findItem(R.id.profiles).isChecked = true
displayFragment(ProfilesFragment()) displayFragment<ProfilesFragment>()
} }
fab = findViewById(R.id.fab) fab = findViewById(R.id.fab)
...@@ -194,8 +195,8 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref ...@@ -194,8 +195,8 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
} }
} }
private fun displayFragment(fragment: ToolbarFragment) { private inline fun <reified F : ToolbarFragment> displayFragment() {
supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, fragment).commitAllowingStateLoss() supportFragmentManager.beginTransaction().replace<F>(R.id.fragment_holder).commitAllowingStateLoss()
drawer.closeDrawers() drawer.closeDrawers()
} }
...@@ -203,20 +204,20 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref ...@@ -203,20 +204,20 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
if (item.isChecked) drawer.closeDrawers() else { if (item.isChecked) drawer.closeDrawers() else {
when (item.itemId) { when (item.itemId) {
R.id.profiles -> { R.id.profiles -> {
displayFragment(ProfilesFragment()) displayFragment<ProfilesFragment>()
connection.bandwidthTimeout = connection.bandwidthTimeout // request stats update connection.bandwidthTimeout = connection.bandwidthTimeout // request stats update
} }
R.id.globalSettings -> displayFragment(GlobalSettingsFragment()) R.id.globalSettings -> displayFragment<GlobalSettingsFragment>()
R.id.about -> { R.id.about -> {
Core.analytics.logEvent("about", Bundle()) Core.analytics.logEvent("about", Bundle())
displayFragment(AboutFragment()) displayFragment<AboutFragment>()
} }
R.id.faq -> { R.id.faq -> {
launchUrl(getString(R.string.faq_url)) launchUrl(getString(R.string.faq_url))
return true return true
} }
R.id.customRules -> displayFragment(CustomRulesFragment()) R.id.customRules -> displayFragment<CustomRulesFragment>()
R.id.subscriptions -> displayFragment(SubscriptionFragment()) R.id.subscriptions -> displayFragment<SubscriptionFragment>()
else -> return false else -> return false
} }
item.isChecked = true item.isChecked = true
...@@ -235,7 +236,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref ...@@ -235,7 +236,7 @@ class MainActivity : AppCompatActivity(), ShadowsocksConnection.Callback, OnPref
if (!currentFragment.onBackPressed()) { if (!currentFragment.onBackPressed()) {
if (currentFragment is ProfilesFragment) super.onBackPressed() else { if (currentFragment is ProfilesFragment) super.onBackPressed() else {
navigation.menu.findItem(R.id.profiles).isChecked = true navigation.menu.findItem(R.id.profiles).isChecked = true
displayFragment(ProfilesFragment()) displayFragment<ProfilesFragment>()
} }
} }
} }
......
...@@ -331,8 +331,9 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener { ...@@ -331,8 +331,9 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
override fun onMenuItemClick(item: MenuItem): Boolean = when (item.itemId) { override fun onMenuItemClick(item: MenuItem): Boolean = when (item.itemId) {
R.id.action_qr_code -> { R.id.action_qr_code -> {
parentFragmentManager.beginTransaction().add(QRCodeDialog(this.item.toString()), "") if (!parentFragmentManager.isStateSaved) {
.commitAllowingStateLoss() QRCodeDialog(this.item.toString()).show(parentFragmentManager, "")
}
true true
} }
R.id.action_export_clipboard -> { R.id.action_export_clipboard -> {
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true">
<include layout="@layout/toolbar_light_dark" /> <include layout="@layout/toolbar_light_dark" />
<FrameLayout android:id="@+id/content" <fragment
android:id="@+id/content"
class="com.github.shadowsocks.GlobalSettingsPreferenceFragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1"/> android:layout_weight="1"/>
......
...@@ -57,7 +57,6 @@ dependencies { ...@@ -57,7 +57,6 @@ dependencies {
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugarLibsVersion" coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:$desugarLibsVersion"
implementation project(':core') implementation project(':core')
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.fragment:fragment-ktx:1.2.0-rc05'
implementation 'androidx.leanback:leanback-preference:1.1.0-alpha03' implementation 'androidx.leanback:leanback-preference:1.1.0-alpha03'
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment