mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-13 07:44:11 +01:00
Fix #816 and other issues
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
4f71384e3a
commit
b597ea1ff6
@ -25,27 +25,30 @@ import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import androidx.core.view.isVisible
|
||||
import com.bluelinelabs.conductor.archlifecycle.ControllerLifecycleOwner
|
||||
import com.bluelinelabs.conductor.autodispose.ControllerScopeProvider
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.newarch.mvvm.BaseView
|
||||
import com.nextcloud.talk.utils.SecurityUtils
|
||||
import com.nextcloud.talk.utils.preferences.MagicUserInputModule
|
||||
import com.uber.autodispose.lifecycle.LifecycleScopeProvider
|
||||
import kotlinx.android.synthetic.main.settings_privacy_view.view.*
|
||||
import net.orange_box.storebox.listeners.OnPreferenceValueChangedListener
|
||||
import java.util.*
|
||||
|
||||
|
||||
class SettingsPrivacyView(private val bundle: Bundle? = null) : BaseView() {
|
||||
override val scopeProvider: LifecycleScopeProvider<*> = ControllerScopeProvider.from(this)
|
||||
override val lifecycleOwner = ControllerLifecycleOwner(this)
|
||||
|
||||
private var proxyTypeChangeListener: OnPreferenceValueChangedListener<String> = ProxyTypeChangeListener()
|
||||
private var proxyCredentialsChangeListener: OnPreferenceValueChangedListener<Boolean> = ProxyCredentialsChangeListener()
|
||||
private var screenSecurityChangeListener: OnPreferenceValueChangedListener<Boolean> = ScreenSecurityChangeListener()
|
||||
|
||||
private var screenLockListener: OnPreferenceValueChangedListener<Boolean> = ScreenLockListener()
|
||||
private var screenLockTimeoutListener: OnPreferenceValueChangedListener<String?> = ScreenLockTimeoutListener()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
setHasOptionsMenu(true)
|
||||
@ -89,6 +92,9 @@ class SettingsPrivacyView(private val bundle: Bundle? = null) : BaseView() {
|
||||
|
||||
appPreferences.registerProxyTypeListener(proxyTypeChangeListener)
|
||||
appPreferences.registerProxyCredentialsListener(proxyCredentialsChangeListener)
|
||||
appPreferences.registerScreenSecurityListener(screenSecurityChangeListener)
|
||||
appPreferences.registerScreenLockListener(screenLockListener)
|
||||
appPreferences.registerScreenLockTimeoutListener(screenLockTimeoutListener)
|
||||
|
||||
setupProxySection(view)
|
||||
return view
|
||||
@ -97,6 +103,7 @@ class SettingsPrivacyView(private val bundle: Bundle? = null) : BaseView() {
|
||||
override fun onDestroy() {
|
||||
appPreferences.unregisterProxyCredentialsListener(proxyCredentialsChangeListener)
|
||||
appPreferences.unregisterProxyTypeListener(proxyTypeChangeListener)
|
||||
appPreferences.unregisterScreenSecurityListener(screenSecurityChangeListener)
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@ -176,4 +183,34 @@ class SettingsPrivacyView(private val bundle: Bundle? = null) : BaseView() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private inner class ScreenSecurityChangeListener : OnPreferenceValueChangedListener<Boolean> {
|
||||
override fun onChanged(newValue: Boolean) {
|
||||
if (newValue) {
|
||||
activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
||||
} else {
|
||||
activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private inner class ScreenLockTimeoutListener : OnPreferenceValueChangedListener<String?> {
|
||||
override fun onChanged(newValue: String?) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
SecurityUtils.createKey(appPreferences.screenLockTimeout)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inner class ScreenLockListener : OnPreferenceValueChangedListener<Boolean> {
|
||||
override fun onChanged(newValue: Boolean) {
|
||||
if (newValue) {
|
||||
view?.settings_screen_lock_timeout?.alpha = 1.0f
|
||||
} else {
|
||||
view?.settings_screen_lock_timeout?.alpha = 0.38f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,14 @@
|
||||
apc:mpc_title="@string/nc_privacy"
|
||||
apc:mpc_title_color="@color/colorPrimary">
|
||||
|
||||
<com.yarolegovich.mp.MaterialSwitchPreference
|
||||
android:id="@+id/settings_screen_lock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
apc:mp_default_value="@bool/value_false"
|
||||
apc:mp_key="@string/nc_settings_screen_lock_key"
|
||||
apc:mp_title="@string/nc_settings_screen_lock_title" />
|
||||
|
||||
<com.yarolegovich.mp.MaterialChoicePreference
|
||||
android:id="@+id/settings_screen_lock_timeout"
|
||||
android:layout_width="match_parent"
|
||||
@ -42,14 +50,6 @@
|
||||
apc:mp_show_value="onBottom"
|
||||
apc:mp_title="@string/nc_settings_screen_lock_timeout_title" />
|
||||
|
||||
<com.yarolegovich.mp.MaterialSwitchPreference
|
||||
android:id="@+id/settings_screen_lock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
apc:mp_default_value="@bool/value_false"
|
||||
apc:mp_key="@string/nc_settings_screen_lock_key"
|
||||
apc:mp_title="@string/nc_settings_screen_lock_title" />
|
||||
|
||||
<com.yarolegovich.mp.MaterialSwitchPreference
|
||||
android:id="@+id/settings_screen_security"
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user