|
@@ -21,10 +21,11 @@
|
|
* You should have received a copy of the GNU General Public License
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
*/
|
|
-package com.nextcloud.talk.controllers
|
|
|
|
|
|
+package com.nextcloud.talk.settings
|
|
|
|
|
|
import android.animation.Animator
|
|
import android.animation.Animator
|
|
import android.animation.AnimatorListenerAdapter
|
|
import android.animation.AnimatorListenerAdapter
|
|
|
|
+import android.app.Activity
|
|
import android.app.KeyguardManager
|
|
import android.app.KeyguardManager
|
|
import android.content.Context
|
|
import android.content.Context
|
|
import android.content.DialogInterface
|
|
import android.content.DialogInterface
|
|
@@ -33,6 +34,7 @@ import android.content.Intent
|
|
import android.content.pm.PackageManager
|
|
import android.content.pm.PackageManager
|
|
import android.content.res.ColorStateList
|
|
import android.content.res.ColorStateList
|
|
import android.graphics.PorterDuff
|
|
import android.graphics.PorterDuff
|
|
|
|
+import android.graphics.drawable.ColorDrawable
|
|
import android.media.RingtoneManager
|
|
import android.media.RingtoneManager
|
|
import android.net.Uri
|
|
import android.net.Uri
|
|
import android.os.Build
|
|
import android.os.Build
|
|
@@ -52,26 +54,21 @@ import android.widget.LinearLayout
|
|
import android.widget.Toast
|
|
import android.widget.Toast
|
|
import androidx.appcompat.app.AlertDialog
|
|
import androidx.appcompat.app.AlertDialog
|
|
import androidx.core.content.ContextCompat
|
|
import androidx.core.content.ContextCompat
|
|
|
|
+import androidx.core.content.res.ResourcesCompat
|
|
import androidx.core.view.ViewCompat
|
|
import androidx.core.view.ViewCompat
|
|
import androidx.work.OneTimeWorkRequest
|
|
import androidx.work.OneTimeWorkRequest
|
|
import androidx.work.WorkManager
|
|
import androidx.work.WorkManager
|
|
import autodagger.AutoInjector
|
|
import autodagger.AutoInjector
|
|
-import com.bluelinelabs.conductor.Controller
|
|
|
|
-import com.bluelinelabs.conductor.RouterTransaction
|
|
|
|
-import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
|
|
|
|
-import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
|
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
import com.google.android.material.textfield.TextInputLayout
|
|
import com.google.android.material.textfield.TextInputLayout
|
|
import com.nextcloud.talk.BuildConfig
|
|
import com.nextcloud.talk.BuildConfig
|
|
import com.nextcloud.talk.R
|
|
import com.nextcloud.talk.R
|
|
|
|
+import com.nextcloud.talk.activities.BaseActivity
|
|
import com.nextcloud.talk.api.NcApi
|
|
import com.nextcloud.talk.api.NcApi
|
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
|
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.setAppTheme
|
|
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.setAppTheme
|
|
-import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
|
|
|
-import com.nextcloud.talk.controllers.base.BaseController
|
|
|
|
-import com.nextcloud.talk.controllers.util.viewBinding
|
|
|
|
import com.nextcloud.talk.data.user.model.User
|
|
import com.nextcloud.talk.data.user.model.User
|
|
-import com.nextcloud.talk.databinding.ControllerSettingsBinding
|
|
|
|
|
|
+import com.nextcloud.talk.databinding.ActivitySettingsBinding
|
|
import com.nextcloud.talk.jobs.AccountRemovalWorker
|
|
import com.nextcloud.talk.jobs.AccountRemovalWorker
|
|
import com.nextcloud.talk.jobs.ContactAddressBookWorker
|
|
import com.nextcloud.talk.jobs.ContactAddressBookWorker
|
|
import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.checkPermission
|
|
import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.checkPermission
|
|
@@ -87,7 +84,6 @@ import com.nextcloud.talk.utils.NotificationUtils
|
|
import com.nextcloud.talk.utils.NotificationUtils.getCallRingtoneUri
|
|
import com.nextcloud.talk.utils.NotificationUtils.getCallRingtoneUri
|
|
import com.nextcloud.talk.utils.NotificationUtils.getMessageRingtoneUri
|
|
import com.nextcloud.talk.utils.NotificationUtils.getMessageRingtoneUri
|
|
import com.nextcloud.talk.utils.SecurityUtils
|
|
import com.nextcloud.talk.utils.SecurityUtils
|
|
-import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ARE_CALL_SOUNDS
|
|
|
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
|
|
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
|
|
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
|
import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
|
|
import com.nextcloud.talk.utils.preferences.MagicUserInputModule
|
|
import com.nextcloud.talk.utils.preferences.MagicUserInputModule
|
|
@@ -106,8 +102,8 @@ import java.util.Locale
|
|
import javax.inject.Inject
|
|
import javax.inject.Inject
|
|
|
|
|
|
@AutoInjector(NextcloudTalkApplication::class)
|
|
@AutoInjector(NextcloudTalkApplication::class)
|
|
-class SettingsController : BaseController(R.layout.controller_settings) {
|
|
|
|
- private val binding: ControllerSettingsBinding? by viewBinding(ControllerSettingsBinding::bind)
|
|
|
|
|
|
+class SettingsActivity : BaseActivity() {
|
|
|
|
+ private lateinit var binding: ActivitySettingsBinding
|
|
|
|
|
|
@Inject
|
|
@Inject
|
|
lateinit var ncApi: NcApi
|
|
lateinit var ncApi: NcApi
|
|
@@ -131,21 +127,16 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
private var profileQueryDisposable: Disposable? = null
|
|
private var profileQueryDisposable: Disposable? = null
|
|
private var dbQueryDisposable: Disposable? = null
|
|
private var dbQueryDisposable: Disposable? = null
|
|
|
|
|
|
- override val title: String
|
|
|
|
- get() =
|
|
|
|
- resources!!.getString(R.string.nc_settings)
|
|
|
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
|
+ NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
|
|
|
|
|
- private fun getCurrentUser() {
|
|
|
|
- currentUser = currentUserProvider.currentUser.blockingGet()
|
|
|
|
- credentials = ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token)
|
|
|
|
- }
|
|
|
|
|
|
+ binding = ActivitySettingsBinding.inflate(layoutInflater)
|
|
|
|
+ setupActionBar()
|
|
|
|
+ setupSystemColors()
|
|
|
|
+ setContentView(binding.root)
|
|
|
|
|
|
- override fun onViewBound(view: View) {
|
|
|
|
- super.onViewBound(view)
|
|
|
|
- setHasOptionsMenu(true)
|
|
|
|
- sharedApplication!!.componentApplication.inject(this)
|
|
|
|
-
|
|
|
|
- binding?.avatarImage?.let { ViewCompat.setTransitionName(it, "userAvatar.transitionTag") }
|
|
|
|
|
|
+ binding.avatarImage.let { ViewCompat.setTransitionName(it, "userAvatar.transitionTag") }
|
|
|
|
|
|
getCurrentUser()
|
|
getCurrentUser()
|
|
|
|
|
|
@@ -155,10 +146,10 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
setupLicenceSetting()
|
|
setupLicenceSetting()
|
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
- binding?.settingsIncognitoKeyboard?.visibility = View.GONE
|
|
|
|
|
|
+ binding.settingsIncognitoKeyboard.visibility = View.GONE
|
|
}
|
|
}
|
|
|
|
|
|
- binding?.settingsScreenLock?.setSummary(
|
|
|
|
|
|
+ binding.settingsScreenLock.setSummary(
|
|
String.format(
|
|
String.format(
|
|
Locale.getDefault(),
|
|
Locale.getDefault(),
|
|
resources!!.getString(R.string.nc_settings_screen_lock_desc),
|
|
resources!!.getString(R.string.nc_settings_screen_lock_desc),
|
|
@@ -168,7 +159,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
|
|
|
|
setupPrivacyUrl()
|
|
setupPrivacyUrl()
|
|
setupSourceCodeUrl()
|
|
setupSourceCodeUrl()
|
|
- binding?.settingsVersion?.setSummary("v" + BuildConfig.VERSION_NAME)
|
|
|
|
|
|
+ binding.settingsVersion.setSummary("v" + BuildConfig.VERSION_NAME)
|
|
|
|
|
|
setupSoundSettings()
|
|
setupSoundSettings()
|
|
|
|
|
|
@@ -177,17 +168,105 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
setupClientCertView()
|
|
setupClientCertView()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ override fun onResume() {
|
|
|
|
+ super.onResume()
|
|
|
|
+ supportActionBar?.show()
|
|
|
|
+ dispose(null)
|
|
|
|
+
|
|
|
|
+ binding.settingsVersion.setOnClickListener {
|
|
|
|
+ sendLogs()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!TextUtils.isEmpty(currentUser!!.clientCertificate)) {
|
|
|
|
+ binding.settingsClientCert.setTitle(R.string.nc_client_cert_change)
|
|
|
|
+ } else {
|
|
|
|
+ binding.settingsClientCert.setTitle(R.string.nc_client_cert_setup)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setupCheckables()
|
|
|
|
+ setupScreenLockSetting()
|
|
|
|
+
|
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
+ binding.settingsNotificationsCategory.setTitle(
|
|
|
|
+ resources!!.getString(R.string.nc_settings_notification_sounds_post_oreo)
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val callRingtoneUri = getCallRingtoneUri(context, (appPreferences))
|
|
|
|
+ binding.settingsCallSound.setSummary(getRingtoneName(context, callRingtoneUri))
|
|
|
|
+ val messageRingtoneUri = getMessageRingtoneUri(context, (appPreferences))
|
|
|
|
+ binding.settingsMessageSound.setSummary(getRingtoneName(context, messageRingtoneUri))
|
|
|
|
+
|
|
|
|
+ setupProxyTypeSettings()
|
|
|
|
+ setupProxyCredentialSettings()
|
|
|
|
+
|
|
|
|
+ if (currentUser != null) {
|
|
|
|
+ binding.baseUrlText.text = Uri.parse(currentUser!!.baseUrl).host
|
|
|
|
+ setupServerAgeWarning()
|
|
|
|
+ if (currentUser!!.displayName != null) {
|
|
|
|
+ binding.displayNameText.text = currentUser!!.displayName
|
|
|
|
+ }
|
|
|
|
+ DisplayUtils.loadAvatarImage(currentUser, binding.avatarImage, false)
|
|
|
|
+
|
|
|
|
+ setupProfileQueryDisposable()
|
|
|
|
+
|
|
|
|
+ binding.settingsRemoveAccount.addPreferenceClickListener {
|
|
|
|
+ showRemoveAccountWarning()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ setupMessageView()
|
|
|
|
+
|
|
|
|
+ binding.avatarContainer.setOnClickListener {
|
|
|
|
+ val intent = Intent(this, ProfileActivity::class.java)
|
|
|
|
+ startActivity(intent)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ themeCategories()
|
|
|
|
+ themeSwitchPreferences()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun setupActionBar() {
|
|
|
|
+ setSupportActionBar(binding.settingsToolbar)
|
|
|
|
+ binding.settingsToolbar.setNavigationOnClickListener {
|
|
|
|
+ onBackPressed()
|
|
|
|
+ }
|
|
|
|
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
|
|
+ supportActionBar?.setDisplayShowHomeEnabled(true)
|
|
|
|
+ supportActionBar?.setIcon(ColorDrawable(resources!!.getColor(android.R.color.transparent)))
|
|
|
|
+ supportActionBar?.title = context.getString(R.string.nc_settings)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun setupSystemColors() {
|
|
|
|
+ DisplayUtils.applyColorToStatusBar(
|
|
|
|
+ this,
|
|
|
|
+ ResourcesCompat.getColor(
|
|
|
|
+ resources,
|
|
|
|
+ R.color.appbar,
|
|
|
|
+ null
|
|
|
|
+ )
|
|
|
|
+ )
|
|
|
|
+ DisplayUtils.applyColorToNavigationBar(
|
|
|
|
+ this.window,
|
|
|
|
+ ResourcesCompat.getColor(resources, R.color.bg_default, null)
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private fun getCurrentUser() {
|
|
|
|
+ currentUser = currentUserProvider.currentUser.blockingGet()
|
|
|
|
+ credentials = ApiUtils.getCredentials(currentUser!!.username, currentUser!!.token)
|
|
|
|
+ }
|
|
|
|
+
|
|
private fun setupPhoneBookIntegration() {
|
|
private fun setupPhoneBookIntegration() {
|
|
if (CapabilitiesUtilNew.isPhoneBookIntegrationAvailable(currentUser!!)) {
|
|
if (CapabilitiesUtilNew.isPhoneBookIntegrationAvailable(currentUser!!)) {
|
|
- binding?.settingsPhoneBookIntegration?.visibility = View.VISIBLE
|
|
|
|
|
|
+ binding.settingsPhoneBookIntegration.visibility = View.VISIBLE
|
|
} else {
|
|
} else {
|
|
- binding?.settingsPhoneBookIntegration?.visibility = View.GONE
|
|
|
|
|
|
+ binding.settingsPhoneBookIntegration.visibility = View.GONE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupSoundSettings() {
|
|
private fun setupSoundSettings() {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
- binding?.settingsCallSound?.setOnClickListener {
|
|
|
|
|
|
+ binding.settingsCallSound.setOnClickListener {
|
|
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
|
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
|
intent.putExtra(
|
|
intent.putExtra(
|
|
@@ -197,7 +276,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
|
|
|
|
startActivity(intent)
|
|
startActivity(intent)
|
|
}
|
|
}
|
|
- binding?.settingsMessageSound?.setOnClickListener {
|
|
|
|
|
|
+ binding.settingsMessageSound.setOnClickListener {
|
|
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
|
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildConfig.APPLICATION_ID)
|
|
intent.putExtra(
|
|
intent.putExtra(
|
|
@@ -207,32 +286,13 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
startActivity(intent)
|
|
startActivity(intent)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- binding?.settingsCallSound?.setOnClickListener {
|
|
|
|
- val bundle = Bundle()
|
|
|
|
- bundle.putBoolean(KEY_ARE_CALL_SOUNDS, true)
|
|
|
|
-
|
|
|
|
- router.pushController(
|
|
|
|
- RouterTransaction.with(RingtoneSelectionController(bundle))
|
|
|
|
- .pushChangeHandler(HorizontalChangeHandler())
|
|
|
|
- .popChangeHandler(HorizontalChangeHandler())
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- binding?.settingsMessageSound?.setOnClickListener {
|
|
|
|
- val bundle = Bundle()
|
|
|
|
- bundle.putBoolean(KEY_ARE_CALL_SOUNDS, false)
|
|
|
|
-
|
|
|
|
- router.pushController(
|
|
|
|
- RouterTransaction.with(RingtoneSelectionController(bundle))
|
|
|
|
- .pushChangeHandler(HorizontalChangeHandler())
|
|
|
|
- .popChangeHandler(HorizontalChangeHandler())
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
|
|
+ Log.e(TAG, "setupSoundSettings currently not supported for versions < Build.VERSION_CODES.O")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupSourceCodeUrl() {
|
|
private fun setupSourceCodeUrl() {
|
|
if (!TextUtils.isEmpty(resources!!.getString(R.string.nc_source_code_url))) {
|
|
if (!TextUtils.isEmpty(resources!!.getString(R.string.nc_source_code_url))) {
|
|
- binding?.settingsSourceCode?.addPreferenceClickListener {
|
|
|
|
|
|
+ binding.settingsSourceCode.addPreferenceClickListener {
|
|
startActivity(
|
|
startActivity(
|
|
Intent(
|
|
Intent(
|
|
Intent.ACTION_VIEW,
|
|
Intent.ACTION_VIEW,
|
|
@@ -241,13 +301,13 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
)
|
|
)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- binding?.settingsSourceCode?.visibility = View.GONE
|
|
|
|
|
|
+ binding.settingsSourceCode.visibility = View.GONE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupPrivacyUrl() {
|
|
private fun setupPrivacyUrl() {
|
|
if (!TextUtils.isEmpty(resources!!.getString(R.string.nc_privacy_url))) {
|
|
if (!TextUtils.isEmpty(resources!!.getString(R.string.nc_privacy_url))) {
|
|
- binding?.settingsPrivacy?.addPreferenceClickListener {
|
|
|
|
|
|
+ binding.settingsPrivacy.addPreferenceClickListener {
|
|
startActivity(
|
|
startActivity(
|
|
Intent(
|
|
Intent(
|
|
Intent.ACTION_VIEW,
|
|
Intent.ACTION_VIEW,
|
|
@@ -256,13 +316,13 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
)
|
|
)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- binding?.settingsPrivacy?.visibility = View.GONE
|
|
|
|
|
|
+ binding.settingsPrivacy.visibility = View.GONE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupLicenceSetting() {
|
|
private fun setupLicenceSetting() {
|
|
if (!TextUtils.isEmpty(resources!!.getString(R.string.nc_gpl3_url))) {
|
|
if (!TextUtils.isEmpty(resources!!.getString(R.string.nc_gpl3_url))) {
|
|
- binding?.settingsLicence?.addPreferenceClickListener {
|
|
|
|
|
|
+ binding.settingsLicence.addPreferenceClickListener {
|
|
startActivity(
|
|
startActivity(
|
|
Intent(
|
|
Intent(
|
|
Intent.ACTION_VIEW,
|
|
Intent.ACTION_VIEW,
|
|
@@ -271,15 +331,15 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
)
|
|
)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- binding?.settingsLicence?.visibility = View.GONE
|
|
|
|
|
|
+ binding.settingsLicence.visibility = View.GONE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupSettingsScreen() {
|
|
private fun setupSettingsScreen() {
|
|
val listWithIntFields: MutableList<String> = ArrayList()
|
|
val listWithIntFields: MutableList<String> = ArrayList()
|
|
listWithIntFields.add("proxy_port")
|
|
listWithIntFields.add("proxy_port")
|
|
- binding?.settingsScreen?.setUserInputModule(MagicUserInputModule(activity, listWithIntFields))
|
|
|
|
- binding?.settingsScreen?.setVisibilityController(
|
|
|
|
|
|
+ binding.settingsScreen.setUserInputModule(MagicUserInputModule(this, listWithIntFields))
|
|
|
|
+ binding.settingsScreen.setVisibilityController(
|
|
R.id.settings_proxy_use_credentials,
|
|
R.id.settings_proxy_use_credentials,
|
|
Arrays.asList(R.id.settings_proxy_username_edit, R.id.settings_proxy_password_edit),
|
|
Arrays.asList(R.id.settings_proxy_username_edit, R.id.settings_proxy_password_edit),
|
|
true
|
|
true
|
|
@@ -298,17 +358,17 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
Log.e(TAG, "Failed to create uri")
|
|
Log.e(TAG, "Failed to create uri")
|
|
}
|
|
}
|
|
|
|
|
|
- binding?.settingsClientCert?.addPreferenceClickListener {
|
|
|
|
|
|
+ binding.settingsClientCert.addPreferenceClickListener {
|
|
KeyChain.choosePrivateKeyAlias(
|
|
KeyChain.choosePrivateKeyAlias(
|
|
- activity!!,
|
|
|
|
|
|
+ this,
|
|
{ alias: String? ->
|
|
{ alias: String? ->
|
|
var finalAlias: String? = alias
|
|
var finalAlias: String? = alias
|
|
|
|
|
|
- activity!!.runOnUiThread {
|
|
|
|
|
|
+ runOnUiThread {
|
|
if (finalAlias != null) {
|
|
if (finalAlias != null) {
|
|
- binding?.settingsClientCert?.setTitle(R.string.nc_client_cert_change)
|
|
|
|
|
|
+ binding.settingsClientCert.setTitle(R.string.nc_client_cert_change)
|
|
} else {
|
|
} else {
|
|
- binding?.settingsClientCert?.setTitle(R.string.nc_client_cert_setup)
|
|
|
|
|
|
+ binding.settingsClientCert.setTitle(R.string.nc_client_cert_setup)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -361,39 +421,33 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
|
|
|
|
fun sendLogs() {
|
|
fun sendLogs() {
|
|
if (resources!!.getBoolean(R.bool.nc_is_debug)) {
|
|
if (resources!!.getBoolean(R.bool.nc_is_debug)) {
|
|
- sendMailWithAttachment((context)!!)
|
|
|
|
|
|
+ sendMailWithAttachment((context))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- override fun onRestoreViewState(view: View, savedViewState: Bundle) {
|
|
|
|
- super.onRestoreViewState(view, savedViewState)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private fun showRemoveAccountWarning() {
|
|
private fun showRemoveAccountWarning() {
|
|
- if (activity != null) {
|
|
|
|
- binding?.messageText?.context?.let {
|
|
|
|
- val materialAlertDialogBuilder = MaterialAlertDialogBuilder(it)
|
|
|
|
- .setTitle(R.string.nc_settings_remove_account)
|
|
|
|
- .setMessage(R.string.nc_settings_remove_confirmation)
|
|
|
|
- .setPositiveButton(R.string.nc_settings_remove) { _, _ ->
|
|
|
|
- removeCurrentAccount()
|
|
|
|
- }
|
|
|
|
- .setNegativeButton(R.string.nc_cancel) { _, _ ->
|
|
|
|
- // unused atm
|
|
|
|
- }
|
|
|
|
|
|
+ binding.messageText.context?.let {
|
|
|
|
+ val materialAlertDialogBuilder = MaterialAlertDialogBuilder(it)
|
|
|
|
+ .setTitle(R.string.nc_settings_remove_account)
|
|
|
|
+ .setMessage(R.string.nc_settings_remove_confirmation)
|
|
|
|
+ .setPositiveButton(R.string.nc_settings_remove) { _, _ ->
|
|
|
|
+ removeCurrentAccount()
|
|
|
|
+ }
|
|
|
|
+ .setNegativeButton(R.string.nc_cancel) { _, _ ->
|
|
|
|
+ // unused atm
|
|
|
|
+ }
|
|
|
|
|
|
- viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
|
|
|
|
- it,
|
|
|
|
- materialAlertDialogBuilder
|
|
|
|
- )
|
|
|
|
|
|
+ viewThemeUtils.dialog.colorMaterialAlertDialogBackground(
|
|
|
|
+ it,
|
|
|
|
+ materialAlertDialogBuilder
|
|
|
|
+ )
|
|
|
|
|
|
- val dialog = materialAlertDialogBuilder.show()
|
|
|
|
|
|
+ val dialog = materialAlertDialogBuilder.show()
|
|
|
|
|
|
- viewThemeUtils.platform.colorTextButtons(
|
|
|
|
- dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
|
|
|
- dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
|
|
+ viewThemeUtils.platform.colorTextButtons(
|
|
|
|
+ dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
|
|
|
+ dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
|
|
|
|
+ )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -401,15 +455,12 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
val otherUserExists = userManager.scheduleUserForDeletionWithId(currentUser!!.id!!).blockingGet()
|
|
val otherUserExists = userManager.scheduleUserForDeletionWithId(currentUser!!.id!!).blockingGet()
|
|
val accountRemovalWork = OneTimeWorkRequest.Builder(AccountRemovalWorker::class.java).build()
|
|
val accountRemovalWork = OneTimeWorkRequest.Builder(AccountRemovalWorker::class.java).build()
|
|
WorkManager.getInstance().enqueue(accountRemovalWork)
|
|
WorkManager.getInstance().enqueue(accountRemovalWork)
|
|
- if (otherUserExists && view != null) {
|
|
|
|
- onViewBound((view)!!)
|
|
|
|
- onAttach((view)!!)
|
|
|
|
|
|
+ if (otherUserExists) {
|
|
|
|
+ // TODO: find better solution once Conductor is removed
|
|
|
|
+ finish()
|
|
|
|
+ startActivity(intent)
|
|
} else if (!otherUserExists) {
|
|
} else if (!otherUserExists) {
|
|
- router.setRoot(
|
|
|
|
- RouterTransaction.with(ServerSelectionController())
|
|
|
|
- .pushChangeHandler(VerticalChangeHandler())
|
|
|
|
- .popChangeHandler(VerticalChangeHandler())
|
|
|
|
- )
|
|
|
|
|
|
+ Log.d(TAG, "No other users found. AccountRemovalWorker will restart the app.")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -426,74 +477,8 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- override fun onAttach(view: View) {
|
|
|
|
- super.onAttach(view)
|
|
|
|
- actionBar?.show()
|
|
|
|
- dispose(null)
|
|
|
|
-
|
|
|
|
- binding?.settingsVersion?.setOnClickListener {
|
|
|
|
- sendLogs()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!TextUtils.isEmpty(currentUser!!.clientCertificate)) {
|
|
|
|
- binding?.settingsClientCert?.setTitle(R.string.nc_client_cert_change)
|
|
|
|
- } else {
|
|
|
|
- binding?.settingsClientCert?.setTitle(R.string.nc_client_cert_setup)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setupCheckables()
|
|
|
|
- setupScreenLockSetting()
|
|
|
|
-
|
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
- binding?.settingsNotificationsCategory?.setTitle(
|
|
|
|
- resources!!.getString(R.string.nc_settings_notification_sounds_post_oreo)
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- val callRingtoneUri = getCallRingtoneUri(view.context, (appPreferences)!!)
|
|
|
|
- binding?.settingsCallSound?.setSummary(getRingtoneName(view.context, callRingtoneUri))
|
|
|
|
- val messageRingtoneUri = getMessageRingtoneUri(view.context, (appPreferences)!!)
|
|
|
|
- binding?.settingsMessageSound?.setSummary(getRingtoneName(view.context, messageRingtoneUri))
|
|
|
|
-
|
|
|
|
- setupProxyTypeSettings()
|
|
|
|
- setupProxyCredentialSettings()
|
|
|
|
-
|
|
|
|
- if (currentUser != null) {
|
|
|
|
- binding?.baseUrlText?.text = Uri.parse(currentUser!!.baseUrl).host
|
|
|
|
- setupServerAgeWarning()
|
|
|
|
-
|
|
|
|
- binding?.settingsReauthorize?.addPreferenceClickListener {
|
|
|
|
- router.pushController(
|
|
|
|
- RouterTransaction.with(WebViewLoginController(currentUser!!.baseUrl, true))
|
|
|
|
- .pushChangeHandler(VerticalChangeHandler())
|
|
|
|
- .popChangeHandler(VerticalChangeHandler())
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (currentUser!!.displayName != null) {
|
|
|
|
- binding?.displayNameText?.text = currentUser!!.displayName
|
|
|
|
- }
|
|
|
|
- DisplayUtils.loadAvatarImage(currentUser, binding?.avatarImage, false)
|
|
|
|
-
|
|
|
|
- setupProfileQueryDisposable()
|
|
|
|
-
|
|
|
|
- binding?.settingsRemoveAccount?.addPreferenceClickListener {
|
|
|
|
- showRemoveAccountWarning()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- setupMessageView()
|
|
|
|
-
|
|
|
|
- binding?.avatarContainer?.setOnClickListener {
|
|
|
|
- val intent = Intent(activity, ProfileActivity::class.java)
|
|
|
|
- activity!!.startActivity(intent)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- themeCategories()
|
|
|
|
- themeSwitchPreferences()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private fun themeSwitchPreferences() {
|
|
private fun themeSwitchPreferences() {
|
|
- binding?.run {
|
|
|
|
|
|
+ binding.run {
|
|
listOf(
|
|
listOf(
|
|
settingsScreenLock,
|
|
settingsScreenLock,
|
|
settingsScreenSecurity,
|
|
settingsScreenSecurity,
|
|
@@ -506,7 +491,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
}
|
|
}
|
|
|
|
|
|
private fun themeCategories() {
|
|
private fun themeCategories() {
|
|
- binding?.run {
|
|
|
|
|
|
+ binding.run {
|
|
listOf(
|
|
listOf(
|
|
settingsNotificationsCategory,
|
|
settingsNotificationsCategory,
|
|
settingsAboutCategory,
|
|
settingsAboutCategory,
|
|
@@ -537,50 +522,50 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
if (ApplicationWideMessageHolder.getInstance().messageType != null) {
|
|
if (ApplicationWideMessageHolder.getInstance().messageType != null) {
|
|
when (ApplicationWideMessageHolder.getInstance().messageType) {
|
|
when (ApplicationWideMessageHolder.getInstance().messageType) {
|
|
ApplicationWideMessageHolder.MessageType.ACCOUNT_UPDATED_NOT_ADDED -> {
|
|
ApplicationWideMessageHolder.MessageType.ACCOUNT_UPDATED_NOT_ADDED -> {
|
|
- binding?.messageText?.let {
|
|
|
|
|
|
+ binding.messageText.let {
|
|
it.setTextColor(
|
|
it.setTextColor(
|
|
viewThemeUtils.getScheme(it.context).primary
|
|
viewThemeUtils.getScheme(it.context).primary
|
|
)
|
|
)
|
|
it.text = resources!!.getString(R.string.nc_settings_account_updated)
|
|
it.text = resources!!.getString(R.string.nc_settings_account_updated)
|
|
- binding?.messageView?.visibility = View.VISIBLE
|
|
|
|
|
|
+ binding.messageView.visibility = View.VISIBLE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
ApplicationWideMessageHolder.MessageType.SERVER_WITHOUT_TALK -> {
|
|
ApplicationWideMessageHolder.MessageType.SERVER_WITHOUT_TALK -> {
|
|
- binding?.messageText?.let {
|
|
|
|
|
|
+ binding.messageText.let {
|
|
it.setTextColor(resources!!.getColor(R.color.nc_darkRed))
|
|
it.setTextColor(resources!!.getColor(R.color.nc_darkRed))
|
|
it.text = resources!!.getString(R.string.nc_settings_wrong_account)
|
|
it.text = resources!!.getString(R.string.nc_settings_wrong_account)
|
|
- binding?.messageView?.visibility = View.VISIBLE
|
|
|
|
|
|
+ binding.messageView.visibility = View.VISIBLE
|
|
it.setTextColor(
|
|
it.setTextColor(
|
|
viewThemeUtils.getScheme(it.context).primary
|
|
viewThemeUtils.getScheme(it.context).primary
|
|
)
|
|
)
|
|
it.text = resources!!.getString(R.string.nc_Server_account_imported)
|
|
it.text = resources!!.getString(R.string.nc_Server_account_imported)
|
|
- binding?.messageView?.visibility = View.VISIBLE
|
|
|
|
|
|
+ binding.messageView.visibility = View.VISIBLE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED -> {
|
|
ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED -> {
|
|
- binding?.messageText?.let {
|
|
|
|
|
|
+ binding.messageText.let {
|
|
it.setTextColor(
|
|
it.setTextColor(
|
|
viewThemeUtils.getScheme(it.context).primary
|
|
viewThemeUtils.getScheme(it.context).primary
|
|
)
|
|
)
|
|
it.text = resources!!.getString(R.string.nc_Server_account_imported)
|
|
it.text = resources!!.getString(R.string.nc_Server_account_imported)
|
|
- binding?.messageView?.visibility = View.VISIBLE
|
|
|
|
|
|
+ binding.messageView.visibility = View.VISIBLE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
ApplicationWideMessageHolder.MessageType.FAILED_TO_IMPORT_ACCOUNT -> {
|
|
ApplicationWideMessageHolder.MessageType.FAILED_TO_IMPORT_ACCOUNT -> {
|
|
- binding?.messageText?.let {
|
|
|
|
|
|
+ binding.messageText.let {
|
|
it.setTextColor(resources!!.getColor(R.color.nc_darkRed))
|
|
it.setTextColor(resources!!.getColor(R.color.nc_darkRed))
|
|
it.text = resources!!.getString(R.string.nc_server_failed_to_import_account)
|
|
it.text = resources!!.getString(R.string.nc_server_failed_to_import_account)
|
|
- binding?.messageView?.visibility = View.VISIBLE
|
|
|
|
|
|
+ binding.messageView.visibility = View.VISIBLE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- else -> binding?.messageView?.visibility = View.GONE
|
|
|
|
|
|
+ else -> binding.messageView.visibility = View.GONE
|
|
}
|
|
}
|
|
ApplicationWideMessageHolder.getInstance().messageType = null
|
|
ApplicationWideMessageHolder.getInstance().messageType = null
|
|
- binding?.messageView?.animate()
|
|
|
|
|
|
+ binding.messageView.animate()
|
|
?.translationY(0f)
|
|
?.translationY(0f)
|
|
?.alpha(0.0f)
|
|
?.alpha(0.0f)
|
|
?.setDuration(DURATION)
|
|
?.setDuration(DURATION)
|
|
@@ -588,11 +573,11 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
?.setListener(object : AnimatorListenerAdapter() {
|
|
?.setListener(object : AnimatorListenerAdapter() {
|
|
override fun onAnimationEnd(animation: Animator) {
|
|
override fun onAnimationEnd(animation: Animator) {
|
|
super.onAnimationEnd(animation)
|
|
super.onAnimationEnd(animation)
|
|
- binding?.messageView?.visibility = View.GONE
|
|
|
|
|
|
+ binding.messageView.visibility = View.GONE
|
|
}
|
|
}
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
- binding?.messageView?.visibility = View.GONE
|
|
|
|
|
|
+ binding.messageView.visibility = View.GONE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -620,7 +605,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
if ((!TextUtils.isEmpty(displayName) && !(displayName == currentUser!!.displayName))) {
|
|
if ((!TextUtils.isEmpty(displayName) && !(displayName == currentUser!!.displayName))) {
|
|
currentUser!!.displayName = displayName
|
|
currentUser!!.displayName = displayName
|
|
userManager.updateOrCreateUser(currentUser!!)
|
|
userManager.updateOrCreateUser(currentUser!!)
|
|
- binding?.displayNameText?.text = currentUser!!.displayName
|
|
|
|
|
|
+ binding.displayNameText.text = currentUser!!.displayName
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{ dispose(profileQueryDisposable) },
|
|
{ dispose(profileQueryDisposable) },
|
|
@@ -631,86 +616,86 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
private fun setupServerAgeWarning() {
|
|
private fun setupServerAgeWarning() {
|
|
when {
|
|
when {
|
|
CapabilitiesUtilNew.isServerEOL(currentUser!!) -> {
|
|
CapabilitiesUtilNew.isServerEOL(currentUser!!) -> {
|
|
- binding?.serverAgeWarningText?.setTextColor(ContextCompat.getColor((context)!!, R.color.nc_darkRed))
|
|
|
|
- binding?.serverAgeWarningText?.setText(R.string.nc_settings_server_eol)
|
|
|
|
- binding?.serverAgeWarningIcon?.setColorFilter(
|
|
|
|
|
|
+ binding.serverAgeWarningText.setTextColor(ContextCompat.getColor((context), R.color.nc_darkRed))
|
|
|
|
+ binding.serverAgeWarningText.setText(R.string.nc_settings_server_eol)
|
|
|
|
+ binding.serverAgeWarningIcon.setColorFilter(
|
|
ContextCompat.getColor((context), R.color.nc_darkRed),
|
|
ContextCompat.getColor((context), R.color.nc_darkRed),
|
|
PorterDuff.Mode.SRC_IN
|
|
PorterDuff.Mode.SRC_IN
|
|
)
|
|
)
|
|
}
|
|
}
|
|
CapabilitiesUtilNew.isServerAlmostEOL(currentUser!!) -> {
|
|
CapabilitiesUtilNew.isServerAlmostEOL(currentUser!!) -> {
|
|
- binding?.serverAgeWarningText?.setTextColor(
|
|
|
|
|
|
+ binding.serverAgeWarningText.setTextColor(
|
|
ContextCompat.getColor((context), R.color.nc_darkYellow)
|
|
ContextCompat.getColor((context), R.color.nc_darkYellow)
|
|
)
|
|
)
|
|
- binding?.serverAgeWarningText?.setText(R.string.nc_settings_server_almost_eol)
|
|
|
|
- binding?.serverAgeWarningIcon?.setColorFilter(
|
|
|
|
|
|
+ binding.serverAgeWarningText.setText(R.string.nc_settings_server_almost_eol)
|
|
|
|
+ binding.serverAgeWarningIcon.setColorFilter(
|
|
ContextCompat.getColor((context), R.color.nc_darkYellow),
|
|
ContextCompat.getColor((context), R.color.nc_darkYellow),
|
|
PorterDuff.Mode.SRC_IN
|
|
PorterDuff.Mode.SRC_IN
|
|
)
|
|
)
|
|
}
|
|
}
|
|
else -> {
|
|
else -> {
|
|
- binding?.serverAgeWarningTextCard?.visibility = View.GONE
|
|
|
|
|
|
+ binding.serverAgeWarningTextCard.visibility = View.GONE
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupCheckables() {
|
|
private fun setupCheckables() {
|
|
- (binding?.settingsScreenSecurity?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
|
|
|
|
+ (binding.settingsScreenSecurity.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
appPreferences.isScreenSecured
|
|
appPreferences.isScreenSecured
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
- (binding?.settingsIncognitoKeyboard?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
|
|
|
|
+ (binding.settingsIncognitoKeyboard.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
appPreferences.isKeyboardIncognito
|
|
appPreferences.isKeyboardIncognito
|
|
}
|
|
}
|
|
|
|
|
|
- (binding?.settingsIncognitoKeyboard?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
|
|
|
|
+ (binding.settingsIncognitoKeyboard.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
appPreferences.isKeyboardIncognito
|
|
appPreferences.isKeyboardIncognito
|
|
|
|
|
|
if (CapabilitiesUtilNew.isReadStatusAvailable(userManager.currentUser.blockingGet())) {
|
|
if (CapabilitiesUtilNew.isReadStatusAvailable(userManager.currentUser.blockingGet())) {
|
|
- (binding?.settingsReadPrivacy?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
|
|
|
|
+ (binding.settingsReadPrivacy.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
!CapabilitiesUtilNew.isReadStatusPrivate(currentUser!!)
|
|
!CapabilitiesUtilNew.isReadStatusPrivate(currentUser!!)
|
|
} else {
|
|
} else {
|
|
- binding?.settingsReadPrivacy?.visibility = View.GONE
|
|
|
|
|
|
+ binding.settingsReadPrivacy.visibility = View.GONE
|
|
}
|
|
}
|
|
|
|
|
|
- (binding?.settingsPhoneBookIntegration?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
|
|
|
|
+ (binding.settingsPhoneBookIntegration.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
appPreferences.isPhoneBookIntegrationEnabled
|
|
appPreferences.isPhoneBookIntegrationEnabled
|
|
}
|
|
}
|
|
|
|
|
|
private fun setupScreenLockSetting() {
|
|
private fun setupScreenLockSetting() {
|
|
val keyguardManager = context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
|
val keyguardManager = context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
|
if (keyguardManager.isKeyguardSecure) {
|
|
if (keyguardManager.isKeyguardSecure) {
|
|
- binding?.settingsScreenLock?.isEnabled = true
|
|
|
|
- binding?.settingsScreenLockTimeout?.isEnabled = true
|
|
|
|
- (binding?.settingsScreenLock?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
|
|
|
|
+ binding.settingsScreenLock.isEnabled = true
|
|
|
|
+ binding.settingsScreenLockTimeout.isEnabled = true
|
|
|
|
+ (binding.settingsScreenLock.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
appPreferences.isScreenLocked
|
|
appPreferences.isScreenLocked
|
|
- binding?.settingsScreenLockTimeout?.isEnabled = appPreferences.isScreenLocked
|
|
|
|
|
|
+ binding.settingsScreenLockTimeout.isEnabled = appPreferences.isScreenLocked
|
|
if (appPreferences.isScreenLocked) {
|
|
if (appPreferences.isScreenLocked) {
|
|
- binding?.settingsScreenLockTimeout?.alpha = ENABLED_ALPHA
|
|
|
|
|
|
+ binding.settingsScreenLockTimeout.alpha = ENABLED_ALPHA
|
|
} else {
|
|
} else {
|
|
- binding?.settingsScreenLockTimeout?.alpha = DISABLED_ALPHA
|
|
|
|
|
|
+ binding.settingsScreenLockTimeout.alpha = DISABLED_ALPHA
|
|
}
|
|
}
|
|
- binding?.settingsScreenLock?.alpha = ENABLED_ALPHA
|
|
|
|
|
|
+ binding.settingsScreenLock.alpha = ENABLED_ALPHA
|
|
} else {
|
|
} else {
|
|
- binding?.settingsScreenLock?.isEnabled = false
|
|
|
|
- binding?.settingsScreenLockTimeout?.isEnabled = false
|
|
|
|
|
|
+ binding.settingsScreenLock.isEnabled = false
|
|
|
|
+ binding.settingsScreenLockTimeout.isEnabled = false
|
|
appPreferences.removeScreenLock()
|
|
appPreferences.removeScreenLock()
|
|
appPreferences.removeScreenLockTimeout()
|
|
appPreferences.removeScreenLockTimeout()
|
|
- (binding?.settingsScreenLock?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked = false
|
|
|
|
- binding?.settingsScreenLock?.alpha = DISABLED_ALPHA
|
|
|
|
- binding?.settingsScreenLockTimeout?.alpha = DISABLED_ALPHA
|
|
|
|
|
|
+ (binding.settingsScreenLock.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked = false
|
|
|
|
+ binding.settingsScreenLock.alpha = DISABLED_ALPHA
|
|
|
|
+ binding.settingsScreenLockTimeout.alpha = DISABLED_ALPHA
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public override fun onDestroy() {
|
|
public override fun onDestroy() {
|
|
- appPreferences?.unregisterProxyTypeListener(proxyTypeChangeListener)
|
|
|
|
- appPreferences?.unregisterProxyCredentialsListener(proxyCredentialsChangeListener)
|
|
|
|
- appPreferences?.unregisterScreenSecurityListener(screenSecurityChangeListener)
|
|
|
|
- appPreferences?.unregisterScreenLockListener(screenLockChangeListener)
|
|
|
|
- appPreferences?.unregisterScreenLockTimeoutListener(screenLockTimeoutChangeListener)
|
|
|
|
- appPreferences?.unregisterThemeChangeListener(themeChangeListener)
|
|
|
|
- appPreferences?.unregisterReadPrivacyChangeListener(readPrivacyChangeListener)
|
|
|
|
- appPreferences?.unregisterPhoneBookIntegrationChangeListener(phoneBookIntegrationChangeListener)
|
|
|
|
|
|
+ appPreferences.unregisterProxyTypeListener(proxyTypeChangeListener)
|
|
|
|
+ appPreferences.unregisterProxyCredentialsListener(proxyCredentialsChangeListener)
|
|
|
|
+ appPreferences.unregisterScreenSecurityListener(screenSecurityChangeListener)
|
|
|
|
+ appPreferences.unregisterScreenLockListener(screenLockChangeListener)
|
|
|
|
+ appPreferences.unregisterScreenLockTimeoutListener(screenLockTimeoutChangeListener)
|
|
|
|
+ appPreferences.unregisterThemeChangeListener(themeChangeListener)
|
|
|
|
+ appPreferences.unregisterReadPrivacyChangeListener(readPrivacyChangeListener)
|
|
|
|
+ appPreferences.unregisterPhoneBookIntegrationChangeListener(phoneBookIntegrationChangeListener)
|
|
|
|
|
|
super.onDestroy()
|
|
super.onDestroy()
|
|
}
|
|
}
|
|
@@ -721,35 +706,35 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
appPreferences.removeProxyCredentials()
|
|
appPreferences.removeProxyCredentials()
|
|
appPreferences.removeProxyUsername()
|
|
appPreferences.removeProxyUsername()
|
|
appPreferences.removeProxyPassword()
|
|
appPreferences.removeProxyPassword()
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_host_edit)?.visibility = View.GONE
|
|
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_port_edit)?.visibility = View.GONE
|
|
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_use_credentials)?.visibility =
|
|
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_host_edit)?.visibility = View.GONE
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_port_edit)?.visibility = View.GONE
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_use_credentials)?.visibility =
|
|
View.GONE
|
|
View.GONE
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_username_edit)?.visibility = View.GONE
|
|
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_password_edit)?.visibility = View.GONE
|
|
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_username_edit)?.visibility = View.GONE
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_password_edit)?.visibility = View.GONE
|
|
}
|
|
}
|
|
|
|
|
|
private fun showProxySettings() {
|
|
private fun showProxySettings() {
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_host_edit)?.visibility =
|
|
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_host_edit)?.visibility =
|
|
View.VISIBLE
|
|
View.VISIBLE
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_port_edit)?.visibility =
|
|
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_port_edit)?.visibility =
|
|
View.VISIBLE
|
|
View.VISIBLE
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_use_credentials)?.visibility =
|
|
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_use_credentials)?.visibility =
|
|
View.VISIBLE
|
|
View.VISIBLE
|
|
}
|
|
}
|
|
|
|
|
|
private fun showProxyCredentials() {
|
|
private fun showProxyCredentials() {
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_username_edit)?.visibility =
|
|
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_username_edit)?.visibility =
|
|
View.VISIBLE
|
|
View.VISIBLE
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_password_edit)?.visibility =
|
|
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_password_edit)?.visibility =
|
|
View.VISIBLE
|
|
View.VISIBLE
|
|
}
|
|
}
|
|
|
|
|
|
private fun hideProxyCredentials() {
|
|
private fun hideProxyCredentials() {
|
|
appPreferences.removeProxyUsername()
|
|
appPreferences.removeProxyUsername()
|
|
appPreferences.removeProxyPassword()
|
|
appPreferences.removeProxyPassword()
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_username_edit)?.visibility = View.GONE
|
|
|
|
- binding?.settingsScreen?.findViewById<View>(R.id.settings_proxy_password_edit)?.visibility = View.GONE
|
|
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_username_edit)?.visibility = View.GONE
|
|
|
|
+ binding.settingsScreen.findViewById<View>(R.id.settings_proxy_password_edit)?.visibility = View.GONE
|
|
}
|
|
}
|
|
|
|
|
|
private fun dispose(disposable: Disposable?) {
|
|
private fun dispose(disposable: Disposable?) {
|
|
@@ -780,6 +765,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
}
|
|
}
|
|
|
|
|
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
|
|
|
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
|
if (requestCode == ContactAddressBookWorker.REQUEST_PERMISSION &&
|
|
if (requestCode == ContactAddressBookWorker.REQUEST_PERMISSION &&
|
|
grantResults.isNotEmpty() &&
|
|
grantResults.isNotEmpty() &&
|
|
grantResults[0] == PackageManager.PERMISSION_GRANTED
|
|
grantResults[0] == PackageManager.PERMISSION_GRANTED
|
|
@@ -790,7 +776,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
checkForPhoneNumber()
|
|
checkForPhoneNumber()
|
|
} else {
|
|
} else {
|
|
appPreferences.setPhoneBookIntegration(false)
|
|
appPreferences.setPhoneBookIntegration(false)
|
|
- (binding?.settingsPhoneBookIntegration?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
|
|
|
|
+ (binding.settingsPhoneBookIntegration.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
appPreferences.isPhoneBookIntegrationEnabled
|
|
appPreferences.isPhoneBookIntegrationEnabled
|
|
Toast.makeText(
|
|
Toast.makeText(
|
|
context,
|
|
context,
|
|
@@ -808,11 +794,11 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
|
|
|
|
private inner class ScreenLockListener : OnPreferenceValueChangedListener<Boolean> {
|
|
private inner class ScreenLockListener : OnPreferenceValueChangedListener<Boolean> {
|
|
override fun onChanged(newValue: Boolean) {
|
|
override fun onChanged(newValue: Boolean) {
|
|
- binding?.settingsScreenLockTimeout?.isEnabled = newValue
|
|
|
|
|
|
+ binding.settingsScreenLockTimeout.isEnabled = newValue
|
|
if (newValue) {
|
|
if (newValue) {
|
|
- binding?.settingsScreenLockTimeout?.alpha = ENABLED_ALPHA
|
|
|
|
|
|
+ binding.settingsScreenLockTimeout.alpha = ENABLED_ALPHA
|
|
} else {
|
|
} else {
|
|
- binding?.settingsScreenLockTimeout?.alpha = DISABLED_ALPHA
|
|
|
|
|
|
+ binding.settingsScreenLockTimeout.alpha = DISABLED_ALPHA
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -820,13 +806,9 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
private inner class ScreenSecurityChangeListener : OnPreferenceValueChangedListener<Boolean> {
|
|
private inner class ScreenSecurityChangeListener : OnPreferenceValueChangedListener<Boolean> {
|
|
override fun onChanged(newValue: Boolean) {
|
|
override fun onChanged(newValue: Boolean) {
|
|
if (newValue) {
|
|
if (newValue) {
|
|
- if (activity != null) {
|
|
|
|
- activity!!.window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
|
|
|
- }
|
|
|
|
|
|
+ window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
|
} else {
|
|
} else {
|
|
- if (activity != null) {
|
|
|
|
- activity!!.window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
|
|
|
- }
|
|
|
|
|
|
+ window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -849,11 +831,11 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
} else {
|
|
} else {
|
|
when (newValue) {
|
|
when (newValue) {
|
|
"HTTP" ->
|
|
"HTTP" ->
|
|
- binding?.settingsProxyPortEdit?.value = "3128"
|
|
|
|
|
|
+ binding.settingsProxyPortEdit.value = "3128"
|
|
"DIRECT" ->
|
|
"DIRECT" ->
|
|
- binding?.settingsProxyPortEdit?.value = "8080"
|
|
|
|
|
|
+ binding.settingsProxyPortEdit.value = "8080"
|
|
"SOCKS" ->
|
|
"SOCKS" ->
|
|
- binding?.settingsProxyPortEdit?.value = "1080"
|
|
|
|
|
|
+ binding.settingsProxyPortEdit.value = "1080"
|
|
else -> {
|
|
else -> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -868,11 +850,11 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private inner class PhoneBookIntegrationChangeListener(private val controller: Controller) :
|
|
|
|
|
|
+ private inner class PhoneBookIntegrationChangeListener(private val activity: Activity) :
|
|
OnPreferenceValueChangedListener<Boolean> {
|
|
OnPreferenceValueChangedListener<Boolean> {
|
|
override fun onChanged(isEnabled: Boolean) {
|
|
override fun onChanged(isEnabled: Boolean) {
|
|
if (isEnabled) {
|
|
if (isEnabled) {
|
|
- if (checkPermission(controller, (context)!!)) {
|
|
|
|
|
|
+ if (checkPermission(activity, (context))) {
|
|
checkForPhoneNumber()
|
|
checkForPhoneNumber()
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -911,11 +893,11 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
}
|
|
}
|
|
|
|
|
|
private fun askForPhoneNumber() {
|
|
private fun askForPhoneNumber() {
|
|
- val phoneNumberLayoutWrapper = LinearLayout(activity)
|
|
|
|
|
|
+ val phoneNumberLayoutWrapper = LinearLayout(context)
|
|
phoneNumberLayoutWrapper.orientation = LinearLayout.VERTICAL
|
|
phoneNumberLayoutWrapper.orientation = LinearLayout.VERTICAL
|
|
phoneNumberLayoutWrapper.setPadding(PHONE_NUMBER_SIDE_PADDING, 0, PHONE_NUMBER_SIDE_PADDING, 0)
|
|
phoneNumberLayoutWrapper.setPadding(PHONE_NUMBER_SIDE_PADDING, 0, PHONE_NUMBER_SIDE_PADDING, 0)
|
|
- val phoneNumberInputLayout = TextInputLayout((activity)!!)
|
|
|
|
- val phoneNumberField = EditText(activity)
|
|
|
|
|
|
+ val phoneNumberInputLayout = TextInputLayout(context)
|
|
|
|
+ val phoneNumberField = EditText(context)
|
|
phoneNumberInputLayout.setHelperTextColor(ColorStateList.valueOf(resources!!.getColor(R.color.nc_darkRed)))
|
|
phoneNumberInputLayout.setHelperTextColor(ColorStateList.valueOf(resources!!.getColor(R.color.nc_darkRed)))
|
|
phoneNumberField.inputType = InputType.TYPE_CLASS_PHONE
|
|
phoneNumberField.inputType = InputType.TYPE_CLASS_PHONE
|
|
phoneNumberField.setText("+")
|
|
phoneNumberField.setText("+")
|
|
@@ -1031,7 +1013,7 @@ class SettingsController : BaseController(R.layout.controller_settings) {
|
|
|
|
|
|
override fun onError(e: Throwable) {
|
|
override fun onError(e: Throwable) {
|
|
appPreferences.setReadPrivacy(!newValue)
|
|
appPreferences.setReadPrivacy(!newValue)
|
|
- (binding?.settingsReadPrivacy?.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
|
|
|
|
+ (binding.settingsReadPrivacy.findViewById<View>(R.id.mp_checkable) as Checkable).isChecked =
|
|
!newValue
|
|
!newValue
|
|
}
|
|
}
|
|
|
|
|