Reload service after remote profile updated

This commit is contained in:
世界 2024-12-03 12:26:07 +08:00
parent cff12c57dd
commit 95401743e9
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
11 changed files with 6 additions and 134 deletions

View file

@ -18,14 +18,11 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import io.nekohasekai.libbox.Libbox
import io.nekohasekai.libbox.ProfileContent
@ -46,7 +43,6 @@ import io.nekohasekai.sfa.ktx.errorDialogBuilder
import io.nekohasekai.sfa.ktx.hasPermission
import io.nekohasekai.sfa.ktx.launchCustomTab
import io.nekohasekai.sfa.ui.profile.NewProfileActivity
import io.nekohasekai.sfa.ui.settings.CoreFragment
import io.nekohasekai.sfa.ui.shared.AbstractActivity
import io.nekohasekai.sfa.utils.MIUIUtils
import io.nekohasekai.sfa.vendor.Vendor
@ -57,7 +53,6 @@ import java.io.File
import java.util.Date
class MainActivity : AbstractActivity<ActivityMainBinding>(),
PreferenceFragmentCompat.OnPreferenceStartFragmentCallback,
ServiceConnection.Callback {
companion object {
@ -111,21 +106,6 @@ class MainActivity : AbstractActivity<ActivityMainBinding>(),
binding.dashboardTabContainer.isVisible = destinationId == R.id.navigation_dashboard
}
override fun onPreferenceStartFragment(
caller: PreferenceFragmentCompat,
pref: Preference
): Boolean {
val navController = findNavController(R.id.nav_host_fragment_activity_my)
when (pref.fragment) {
CoreFragment::class.java.name -> {
navController.navigate(R.id.navigation_settings_core)
return true
}
else -> return false
}
}
override public fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
val uri = intent.data ?: return

View file

@ -1,9 +0,0 @@
package io.nekohasekai.sfa.ui.main
import io.nekohasekai.sfa.R
import io.nekohasekai.sfa.ui.settings.AbstractSettingsFragment
class SettingsFragment0 : AbstractSettingsFragment(R.xml.preferences_settings) {
}

View file

@ -1,27 +0,0 @@
package io.nekohasekai.sfa.ui.settings
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.XmlRes
import androidx.preference.PreferenceFragmentCompat
import androidx.recyclerview.widget.RecyclerView
import io.nekohasekai.sfa.R
open class AbstractSettingsFragment(@XmlRes val resId: Int) : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(resId, rootKey)
}
override fun onCreateRecyclerView(
inflater: LayoutInflater,
parent: ViewGroup,
savedInstanceState: Bundle?
): RecyclerView {
val recyclerView = inflater
.inflate(R.layout.view_prefenence_screen, parent, false) as RecyclerView
recyclerView.layoutManager = onCreateLayoutManager()
return recyclerView
}
}

View file

@ -1,6 +0,0 @@
package io.nekohasekai.sfa.ui.settings
import androidx.fragment.app.Fragment
class CoreFragment : Fragment() {
}

View file

@ -1,45 +0,0 @@
package io.nekohasekai.sfa.ui.settings
import android.content.Context
import android.util.AttributeSet
import android.util.TypedValue
import androidx.preference.Preference
import io.nekohasekai.sfa.ktx.getAttrColor
class Preference : Preference {
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes) {
icon?.setTint(context.getAttrColor(com.google.android.material.R.attr.colorOnSurface))
}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : this(
context,
attrs,
defStyleAttr,
0
)
constructor(context: Context, attrs: AttributeSet?) : this(
context, attrs, getAttr(
context, androidx.preference.R.attr.preferenceStyle,
android.R.attr.preferenceStyle
)
)
companion object {
private fun getAttr(context: Context, attr: Int, fallbackAttr: Int): Int {
val value = TypedValue()
context.theme.resolveAttribute(attr, value, true)
if (value.resourceId != 0) {
return attr
}
return fallbackAttr
}
}
}

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -29,10 +29,5 @@
android:label="@string/title_settings"
tools:layout="@layout/fragment_settings" />
<fragment
android:id="@+id/navigation_settings_core"
android:name="io.nekohasekai.sfa.ui.settings.CoreFragment"
android:label="@string/settings_title_core"
tools:layout="@layout/fragment_settings_core" />
</navigation>

View file

@ -194,6 +194,5 @@
<string name="location_permission_background_description"><![CDATA[On Android 10 and up, <strong>background location</strong> permission is required. Select <strong>Allow all the time</strong> to grant the permission.]]></string>
<string name="open_settings">Open Settings</string>
<string name="settings_title_core">Core</string>
</resources>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<io.nekohasekai.sfa.ui.settings.Preference
app:fragment="io.nekohasekai.sfa.ui.settings.CoreFragment"
app:icon="@drawable/ic_qr_code_2_24"
app:title="@string/settings_title_core" />
</androidx.preference.PreferenceScreen>

View file

@ -5,10 +5,10 @@ buildscript {
}
plugins {
id 'com.android.application' version '8.7.2' apply false
id 'com.android.library' version '8.7.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
id 'com.google.devtools.ksp' version '1.9.23-1.0.20' apply false
id 'com.android.application' version '8.7.3' apply false
id 'com.android.library' version '8.7.3' apply false
id 'org.jetbrains.kotlin.android' version '2.1.0' apply false
id 'com.google.devtools.ksp' version '2.1.0-1.0.29' apply false
id 'com.github.triplet.play' version '3.8.4' apply false
}

View file

@ -1,7 +1,7 @@
#Sun Oct 06 20:10:49 CST 2024
#Fri Nov 29 14:47:37 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME