mirror of
https://github.com/dovecoteescapee/ByeDPIAndroid.git
synced 2024-12-22 14:26:22 +00:00
Fix AppSelectionFragment
This commit is contained in:
parent
c6762d58be
commit
d7435c0d2f
@ -66,6 +66,7 @@ class AppSelectionFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
progressBar.visibility = View.GONE
|
progressBar.visibility = View.GONE
|
||||||
|
searchView.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
val accessibilityStatusPref = findPreferenceNotNull<Preference>("accessibility_service_status")
|
val accessibilityStatus = findPreferenceNotNull<Preference>("accessibility_service_status")
|
||||||
val switchCommandLineSettings = findPreferenceNotNull<SwitchPreference>("byedpi_enable_cmd_settings")
|
val switchCommandLineSettings = findPreferenceNotNull<SwitchPreference>("byedpi_enable_cmd_settings")
|
||||||
|
|
||||||
val uiSettings = findPreferenceNotNull<Preference>("byedpi_ui_settings")
|
val uiSettings = findPreferenceNotNull<Preference>("byedpi_ui_settings")
|
||||||
@ -67,10 +67,11 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
|
|||||||
|
|
||||||
switchCommandLineSettings.setOnPreferenceChangeListener { _, newValue ->
|
switchCommandLineSettings.setOnPreferenceChangeListener { _, newValue ->
|
||||||
setByeDpiSettingsMode(newValue as Boolean)
|
setByeDpiSettingsMode(newValue as Boolean)
|
||||||
|
updatePreferences()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
accessibilityStatusPref.setOnPreferenceClickListener {
|
accessibilityStatus.setOnPreferenceClickListener {
|
||||||
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
val intent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
true
|
true
|
||||||
@ -78,13 +79,14 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
|
|||||||
|
|
||||||
findPreferenceNotNull<Preference>("version").summary = BuildConfig.VERSION_NAME
|
findPreferenceNotNull<Preference>("version").summary = BuildConfig.VERSION_NAME
|
||||||
|
|
||||||
updateAccessibilityStatus(accessibilityStatusPref)
|
updateAccessibilityStatus()
|
||||||
updatePreferences()
|
updatePreferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
sharedPreferences?.registerOnSharedPreferenceChangeListener(preferenceListener)
|
sharedPreferences?.registerOnSharedPreferenceChangeListener(preferenceListener)
|
||||||
|
updateAccessibilityStatus()
|
||||||
updatePreferences()
|
updatePreferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,34 +96,30 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updatePreferences() {
|
private fun updatePreferences() {
|
||||||
val mode = findPreferenceNotNull<ListPreference>("byedpi_mode")
|
val mode = findPreferenceNotNull<ListPreference>("byedpi_mode").value.let { Mode.fromString(it) }
|
||||||
.value.let { Mode.fromString(it) }
|
|
||||||
val dns = findPreferenceNotNull<EditTextPreference>("dns_ip")
|
val dns = findPreferenceNotNull<EditTextPreference>("dns_ip")
|
||||||
val ipv6 = findPreferenceNotNull<SwitchPreference>("ipv6_enable")
|
val ipv6 = findPreferenceNotNull<SwitchPreference>("ipv6_enable")
|
||||||
|
val applistType = findPreferenceNotNull<ListPreference>("applist_type")
|
||||||
val applist_type = findPreferenceNotNull<ListPreference>("applist_type")
|
val selectedApps = findPreferenceNotNull<Preference>("selected_apps")
|
||||||
val selected_apps = findPreferenceNotNull<Preference>("selected_apps")
|
|
||||||
val accessibilityStatusPref = findPreferenceNotNull<Preference>("accessibility_service_status")
|
|
||||||
|
|
||||||
updateAccessibilityStatus(accessibilityStatusPref)
|
|
||||||
|
|
||||||
when (mode) {
|
when (mode) {
|
||||||
Mode.VPN -> {
|
Mode.VPN -> {
|
||||||
dns.isVisible = true
|
dns.isVisible = true
|
||||||
ipv6.isVisible = true
|
ipv6.isVisible = true
|
||||||
when (applist_type.value) {
|
|
||||||
|
when (applistType.value) {
|
||||||
"disable" -> {
|
"disable" -> {
|
||||||
applist_type.isVisible = true
|
applistType.isVisible = true
|
||||||
selected_apps.isVisible = false
|
selectedApps.isVisible = false
|
||||||
}
|
}
|
||||||
"blacklist", "whitelist" -> {
|
"blacklist", "whitelist" -> {
|
||||||
applist_type.isVisible = true
|
applistType.isVisible = true
|
||||||
selected_apps.isVisible = true
|
selectedApps.isVisible = true
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
applist_type.isVisible = true
|
applistType.isVisible = true
|
||||||
selected_apps.isVisible = false
|
selectedApps.isVisible = false
|
||||||
Log.w(TAG, "Unexpected applist_type value: ${applist_type.value}")
|
Log.w(TAG, "Unexpected applistType value: ${applistType.value}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,23 +127,22 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
|
|||||||
Mode.Proxy -> {
|
Mode.Proxy -> {
|
||||||
dns.isVisible = false
|
dns.isVisible = false
|
||||||
ipv6.isVisible = false
|
ipv6.isVisible = false
|
||||||
applist_type.isVisible = false
|
applistType.isVisible = false
|
||||||
selected_apps.isVisible = false
|
selectedApps.isVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAccessibilityStatus(preference: Preference?) {
|
private fun updateAccessibilityStatus() {
|
||||||
preference?.let {
|
val accessibilityStatus = findPreferenceNotNull<Preference>("accessibility_service_status")
|
||||||
val isEnabled = AccessibilityUtils.isAccessibilityServiceEnabled(
|
val isEnabled = AccessibilityUtils.isAccessibilityServiceEnabled(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
AutoStartAccessibilityService::class.java
|
AutoStartAccessibilityService::class.java
|
||||||
)
|
)
|
||||||
it.summary = if (isEnabled) {
|
accessibilityStatus.summary = if (isEnabled) {
|
||||||
getString(R.string.accessibility_service_enabled)
|
getString(R.string.accessibility_service_enabled)
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.accessibility_service_disabled)
|
getString(R.string.accessibility_service_disabled)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
android:id="@+id/searchView"
|
android:id="@+id/searchView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
android:queryHint="@string/search_apps" />
|
android:queryHint="@string/search_apps" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -44,7 +44,8 @@
|
|||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="selected_apps"
|
android:key="selected_apps"
|
||||||
android:title="@string/apps_select" />
|
android:title="@string/apps_select"
|
||||||
|
app:fragment="io.github.dovecoteescapee.byedpi.fragments.AppSelectionFragment" />
|
||||||
|
|
||||||
</androidx.preference.PreferenceCategory>
|
</androidx.preference.PreferenceCategory>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user