mirror of
https://github.com/SagerNet/sing-box-for-android.git
synced 2025-03-31 10:27:38 +03:00
Reload service after remote profile updated
This commit is contained in:
parent
cff12c57dd
commit
95401743e9
11 changed files with 6 additions and 134 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
package io.nekohasekai.sfa.ui.settings
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
class CoreFragment : Fragment() {
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue