Commit 4e5afbad authored by Mygod's avatar Mygod

Update dependencies

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