diff --git a/app/build.gradle b/app/build.gradle
index bfefab5f72c..d175cdf3634 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -210,8 +210,6 @@ dependencies {
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation "io.reactivex.rxjava2:rxjava:2.2.21"
- implementation 'com.bluelinelabs:conductor:3.2.0'
-
implementation "com.squareup.okhttp3:okhttp:${okhttpVersion}"
implementation "com.squareup.okhttp3:okhttp-urlconnection:${okhttpVersion}"
implementation "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 89f0d25efa7..52e4346b821 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -131,6 +131,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.kt b/app/src/main/java/com/nextcloud/talk/account/AccountVerificationActivity.kt
similarity index 69%
rename from app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.kt
rename to app/src/main/java/com/nextcloud/talk/account/AccountVerificationActivity.kt
index d6ecd5a812a..6ce3d603e15 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/AccountVerificationController.kt
+++ b/app/src/main/java/com/nextcloud/talk/account/AccountVerificationActivity.kt
@@ -19,7 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package com.nextcloud.talk.controllers
+package com.nextcloud.talk.account
import android.annotation.SuppressLint
import android.content.Intent
@@ -28,24 +28,19 @@ import android.os.Bundle
import android.os.Handler
import android.text.TextUtils
import android.util.Log
-import android.view.View
import androidx.work.Data
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import autodagger.AutoInjector
-import com.bluelinelabs.conductor.RouterTransaction
-import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
import com.bluelinelabs.logansquare.LoganSquare
import com.google.android.material.snackbar.Snackbar
import com.nextcloud.talk.R
+import com.nextcloud.talk.activities.BaseActivity
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
-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.conversationlist.ConversationsListActivity
import com.nextcloud.talk.data.user.model.User
-import com.nextcloud.talk.databinding.ControllerAccountVerificationBinding
+import com.nextcloud.talk.databinding.ActivityAccountVerificationBinding
import com.nextcloud.talk.events.EventStatus
import com.nextcloud.talk.jobs.CapabilitiesWorker
import com.nextcloud.talk.jobs.PushRegistrationWorker
@@ -71,20 +66,15 @@ import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
-import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import java.net.CookieManager
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
-class AccountVerificationController(args: Bundle? = null) : BaseController(
- R.layout.controller_account_verification,
- args
-) {
- private val binding: ControllerAccountVerificationBinding? by viewBinding(
- ControllerAccountVerificationBinding::bind
- )
+class AccountVerificationActivity : BaseActivity() {
+
+ private lateinit var binding: ActivityAccountVerificationBinding
@Inject
lateinit var ncApi: NcApi
@@ -95,9 +85,6 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
@Inject
lateinit var cookieManager: CookieManager
- @Inject
- lateinit var eventBus: EventBus
-
private var internalAccountId: Long = -1
private val disposables: MutableList = ArrayList()
private var baseUrl: String? = null
@@ -106,21 +93,34 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
private var isAccountImport = false
private var originalProtocol: String? = null
- override fun onAttach(view: View) {
- super.onAttach(view)
- eventBus.register(this)
- }
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
- override fun onDetach(view: View) {
- super.onDetach(view)
- eventBus.unregister(this)
+ binding = ActivityAccountVerificationBinding.inflate(layoutInflater)
+ actionBar?.hide()
+ requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ setContentView(binding.root)
+ setupSystemColors()
+ // viewThemeUtils.material.themeCardView(binding.searchToolbar)
+ // viewThemeUtils.material.themeSearchBarText(binding.searchText)
+
+ // onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
+
+ val extras = intent.extras!!
+ baseUrl = extras.getString(KEY_BASE_URL)
+ username = extras.getString(KEY_USERNAME)
+ token = extras.getString(KEY_TOKEN)
+ if (extras.containsKey(KEY_IS_ACCOUNT_IMPORT)) {
+ isAccountImport = true
+ }
+ if (extras.containsKey(KEY_ORIGINAL_PROTOCOL)) {
+ originalProtocol = extras.getString(KEY_ORIGINAL_PROTOCOL)
+ }
}
- override fun onViewBound(view: View) {
- super.onViewBound(view)
- activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
-
- actionBar?.hide()
+ override fun onResume() {
+ super.onResume()
if (
isAccountImport &&
@@ -166,18 +166,19 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
"http://$baseUrl"
}
if (isAccountImport) {
- router.replaceTopController(
- RouterTransaction.with(
- WebViewLoginController(
- baseUrl,
- false,
- username,
- ""
- )
- )
- .pushChangeHandler(HorizontalChangeHandler())
- .popChangeHandler(HorizontalChangeHandler())
- )
+ // TODO: start WebViewLoginActivity?
+ // router.replaceTopController(
+ // RouterTransaction.with(
+ // WebViewLoginController(
+ // baseUrl,
+ // false,
+ // username,
+ // ""
+ // )
+ // )
+ // .pushChangeHandler(HorizontalChangeHandler())
+ // .popChangeHandler(HorizontalChangeHandler())
+ // )
} else {
checkEverything()
}
@@ -214,13 +215,11 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
if (hasTalk) {
fetchProfile(credentials, capabilitiesOverall)
} else {
- if (activity != null && resources != null) {
- activity!!.runOnUiThread {
- binding?.progressText?.setText(
- String.format(
- resources!!.getString(R.string.nc_nextcloud_talk_app_not_installed),
- resources!!.getString(R.string.nc_app_product_name)
- )
+ if (resources != null) {
+ runOnUiThread {
+ binding.progressText.text = String.format(
+ resources!!.getString(R.string.nc_nextcloud_talk_app_not_installed),
+ resources!!.getString(R.string.nc_app_product_name)
)
}
}
@@ -232,9 +231,9 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
}
override fun onError(e: Throwable) {
- if (activity != null && resources != null) {
- activity!!.runOnUiThread {
- binding?.progressText?.text = String.format(
+ if (resources != null) {
+ runOnUiThread {
+ binding.progressText.text = String.format(
resources!!.getString(R.string.nc_nextcloud_talk_app_not_installed),
resources!!.getString(R.string.nc_app_product_name)
)
@@ -263,7 +262,7 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
displayName = displayName,
pushConfigurationState = null,
capabilities = LoganSquare.serialize(capabilities),
- certificateAlias = appPreferences!!.temporaryClientCertAlias,
+ certificateAlias = appPreferences.temporaryClientCertAlias,
externalSignalingServer = null
)
)
@@ -279,9 +278,9 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
if (ClosedInterfaceImpl().isGooglePlayServicesAvailable) {
registerForPush()
} else {
- activity!!.runOnUiThread {
- binding?.progressText?.text =
- """ ${binding?.progressText?.text}
+ runOnUiThread {
+ binding.progressText.text =
+ """ ${binding.progressText.text}
${resources!!.getString(R.string.nc_push_disabled)}
""".trimIndent()
}
@@ -291,7 +290,7 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
@SuppressLint("SetTextI18n")
override fun onError(e: Throwable) {
- binding?.progressText?.text = """ ${binding?.progressText?.text}""".trimIndent() +
+ binding.progressText.text = """ ${binding.progressText.text}""".trimIndent() +
resources!!.getString(R.string.nc_display_name_not_stored)
abortVerification()
}
@@ -328,14 +327,12 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
capabilities.ocs!!.data!!.capabilities!!
)
} else {
- if (activity != null) {
- activity!!.runOnUiThread {
- binding?.progressText?.text =
- """
- ${binding?.progressText?.text}
- ${resources!!.getString(R.string.nc_display_name_not_fetched)}
- """.trimIndent()
- }
+ runOnUiThread {
+ binding.progressText.text =
+ """
+ ${binding.progressText.text}
+ ${resources!!.getString(R.string.nc_display_name_not_fetched)}
+ """.trimIndent()
}
abortVerification()
}
@@ -343,14 +340,12 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
@SuppressLint("SetTextI18n")
override fun onError(e: Throwable) {
- if (activity != null) {
- activity!!.runOnUiThread {
- binding?.progressText?.text =
- """
- ${binding?.progressText?.text}
- ${resources!!.getString(R.string.nc_display_name_not_fetched)}
- """.trimIndent()
- }
+ runOnUiThread {
+ binding.progressText.text =
+ """
+ ${binding.progressText.text}
+ ${resources!!.getString(R.string.nc_display_name_not_fetched)}
+ """.trimIndent()
}
abortVerification()
}
@@ -377,11 +372,11 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
@Subscribe(threadMode = ThreadMode.BACKGROUND)
fun onMessageEvent(eventStatus: EventStatus) {
if (eventStatus.eventType == EventStatus.EventType.PUSH_REGISTRATION) {
- if (internalAccountId == eventStatus.userId && !eventStatus.isAllGood && activity != null) {
- activity!!.runOnUiThread {
- binding?.progressText?.text =
+ if (internalAccountId == eventStatus.userId && !eventStatus.isAllGood) {
+ runOnUiThread {
+ binding.progressText.text =
"""
- ${binding?.progressText?.text}
+ ${binding.progressText.text}
${resources!!.getString(R.string.nc_push_disabled)}
""".trimIndent()
}
@@ -389,14 +384,12 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
fetchAndStoreCapabilities()
} else if (eventStatus.eventType == EventStatus.EventType.CAPABILITIES_FETCH) {
if (internalAccountId == eventStatus.userId && !eventStatus.isAllGood) {
- if (activity != null) {
- activity!!.runOnUiThread {
- binding?.progressText?.text =
- """
- ${binding?.progressText?.text}
- ${resources!!.getString(R.string.nc_capabilities_failed)}
- """.trimIndent()
- }
+ runOnUiThread {
+ binding.progressText.text =
+ """
+ ${binding.progressText.text}
+ ${resources!!.getString(R.string.nc_capabilities_failed)}
+ """.trimIndent()
}
abortVerification()
} else if (internalAccountId == eventStatus.userId && eventStatus.isAllGood) {
@@ -404,14 +397,12 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
}
} else if (eventStatus.eventType == EventStatus.EventType.SIGNALING_SETTINGS) {
if (internalAccountId == eventStatus.userId && !eventStatus.isAllGood) {
- if (activity != null) {
- activity!!.runOnUiThread {
- binding?.progressText?.text =
- """
- ${binding?.progressText?.text}
- ${resources!!.getString(R.string.nc_external_server_failed)}
- """.trimIndent()
- }
+ runOnUiThread {
+ binding.progressText.text =
+ """
+ ${binding.progressText.text}
+ ${resources!!.getString(R.string.nc_external_server_failed)}
+ """.trimIndent()
}
}
proceedWithLogin()
@@ -457,24 +448,22 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
Log.d(TAG, "userToSetAsActive: " + userToSetAsActive.username)
if (userManager.setUserAsActive(userToSetAsActive).blockingGet()) {
- if (activity != null) {
- activity!!.runOnUiThread {
- if (userManager.users.blockingGet().size == 1) {
- val intent = Intent(context, ConversationsListActivity::class.java)
- startActivity(intent)
- } else {
- if (isAccountImport) {
- ApplicationWideMessageHolder.getInstance().messageType =
- ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED
- }
- val intent = Intent(context, ConversationsListActivity::class.java)
- startActivity(intent)
+ runOnUiThread {
+ if (userManager.users.blockingGet().size == 1) {
+ val intent = Intent(context, ConversationsListActivity::class.java)
+ startActivity(intent)
+ } else {
+ if (isAccountImport) {
+ ApplicationWideMessageHolder.getInstance().messageType =
+ ApplicationWideMessageHolder.MessageType.ACCOUNT_WAS_IMPORTED
}
+ val intent = Intent(context, ConversationsListActivity::class.java)
+ startActivity(intent)
}
}
} else {
Log.e(TAG, "failed to set active user")
- Snackbar.make(binding!!.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
+ Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
}
}
}
@@ -487,11 +476,6 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
}
}
- override fun onDestroyView(view: View) {
- super.onDestroyView(view)
- activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
- }
-
public override fun onDestroy() {
dispose()
super.onDestroy()
@@ -502,32 +486,36 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
if (internalAccountId != -1L) {
val count = userManager.deleteUser(internalAccountId)
if (count > 0) {
- activity?.runOnUiThread { Handler().postDelayed({ router.popToRoot() }, DELAY_IN_MILLIS) }
+ runOnUiThread {
+ Handler().postDelayed({
+ // TODO: start ServerSelectionActivity?
+ // router.popToRoot()
+ }, DELAY_IN_MILLIS)
+ }
}
} else {
- activity?.runOnUiThread { Handler().postDelayed({ router.popToRoot() }, DELAY_IN_MILLIS) }
+ runOnUiThread {
+ Handler().postDelayed({
+ // TODO: start ServerSelectionActivity?
+ // router.popToRoot()
+ }, DELAY_IN_MILLIS)
+ }
}
} else {
- ApplicationWideMessageHolder.getInstance().setMessageType(
- ApplicationWideMessageHolder.MessageType.FAILED_TO_IMPORT_ACCOUNT
- )
- activity?.runOnUiThread {
+ ApplicationWideMessageHolder.getInstance().messageType = ApplicationWideMessageHolder.MessageType
+ .FAILED_TO_IMPORT_ACCOUNT
+ runOnUiThread {
Handler().postDelayed({
- if (router.hasRootController()) {
- if (activity != null) {
- router.popToRoot()
- }
+ if (userManager.users.blockingGet().isNotEmpty()) {
+ val intent = Intent(context, ConversationsListActivity::class.java)
+ startActivity(intent)
} else {
- if (userManager.users.blockingGet().isNotEmpty()) {
- val intent = Intent(context, ConversationsListActivity::class.java)
- startActivity(intent)
- } else {
- router.setRoot(
- RouterTransaction.with(ServerSelectionController())
- .pushChangeHandler(HorizontalChangeHandler())
- .popChangeHandler(HorizontalChangeHandler())
- )
- }
+ // TODO: start ServerSelectionActivity?
+ // router.setRoot(
+ // RouterTransaction.with(ServerSelectionController())
+ // .pushChangeHandler(HorizontalChangeHandler())
+ // .popChangeHandler(HorizontalChangeHandler())
+ // )
}
}, DELAY_IN_MILLIS)
}
@@ -538,19 +526,4 @@ class AccountVerificationController(args: Bundle? = null) : BaseController(
const val TAG = "AccountVerification"
const val DELAY_IN_MILLIS: Long = 7500
}
-
- init {
- sharedApplication!!.componentApplication.inject(this)
- if (args != null) {
- baseUrl = args.getString(KEY_BASE_URL)
- username = args.getString(KEY_USERNAME)
- token = args.getString(KEY_TOKEN)
- if (args.containsKey(KEY_IS_ACCOUNT_IMPORT)) {
- isAccountImport = true
- }
- if (args.containsKey(KEY_ORIGINAL_PROTOCOL)) {
- originalProtocol = args.getString(KEY_ORIGINAL_PROTOCOL)
- }
- }
- }
}
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt b/app/src/main/java/com/nextcloud/talk/account/ServerSelectionActivity.kt
similarity index 65%
rename from app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt
rename to app/src/main/java/com/nextcloud/talk/account/ServerSelectionActivity.kt
index a05899b52a7..d7b7bf6a440 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/ServerSelectionController.kt
+++ b/app/src/main/java/com/nextcloud/talk/account/ServerSelectionActivity.kt
@@ -19,7 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package com.nextcloud.talk.controllers
+package com.nextcloud.talk.account
import android.accounts.Account
import android.annotation.SuppressLint
@@ -34,17 +34,14 @@ import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.TextView
+import androidx.activity.OnBackPressedCallback
import androidx.core.content.res.ResourcesCompat
import autodagger.AutoInjector
-import com.bluelinelabs.conductor.RouterTransaction
-import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
import com.nextcloud.talk.R
+import com.nextcloud.talk.activities.BaseActivity
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
-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.databinding.ControllerServerSelectionBinding
+import com.nextcloud.talk.databinding.ActivityServerSelectionBinding
import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall
import com.nextcloud.talk.models.json.generic.Status
import com.nextcloud.talk.users.UserManager
@@ -52,6 +49,8 @@ import com.nextcloud.talk.utils.AccountUtils
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.UriUtils
+import com.nextcloud.talk.utils.bundle.BundleKeys
+import com.nextcloud.talk.utils.bundle.BundleKeys.ADD_ADDITIONAL_ACCOUNT
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_ACCOUNT_IMPORT
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder
@@ -63,10 +62,9 @@ import java.security.cert.CertificateException
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
-class ServerSelectionController :
- BaseController(R.layout.controller_server_selection) {
+class ServerSelectionActivity : BaseActivity() {
- private val binding: ControllerServerSelectionBinding? by viewBinding(ControllerServerSelectionBinding::bind)
+ private lateinit var binding: ActivityServerSelectionBinding
@Inject
lateinit var ncApi: NcApi
@@ -76,44 +74,57 @@ class ServerSelectionController :
private var statusQueryDisposable: Disposable? = null
- fun onCertClick() {
- if (activity != null) {
- KeyChain.choosePrivateKeyAlias(
- activity!!,
- { alias: String? ->
- if (alias != null) {
- appPreferences!!.temporaryClientCertAlias = alias
- } else {
- appPreferences!!.removeTemporaryClientCertAlias()
- }
- setCertTextView()
- },
- arrayOf("RSA", "EC"),
- null,
- null,
- -1,
- null
- )
+ private val onBackPressedCallback = object : OnBackPressedCallback(true) {
+ override fun handleOnBackPressed() {
+ if (intent.hasExtra(ADD_ADDITIONAL_ACCOUNT) && intent.getBooleanExtra(ADD_ADDITIONAL_ACCOUNT, false)) {
+ finish()
+ } else {
+ finishAffinity()
+ }
}
}
- override fun onViewBound(view: View) {
- super.onViewBound(view)
- sharedApplication!!.componentApplication.inject(this)
- if (activity != null) {
- activity!!.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
- }
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
+ binding = ActivityServerSelectionBinding.inflate(layoutInflater)
actionBar?.hide()
+ requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ setContentView(binding.root)
+ setupSystemColors()
+ // // viewThemeUtils.material.themeCardView(binding.searchToolbar)
+ // // viewThemeUtils.material.themeSearchBarText(binding.searchText)
+ //
+ onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
+ //
+ //
+ //
+ // val extras = intent.extras!!
+ // baseUrl = extras.getString(BundleKeys.KEY_BASE_URL)
+ // username = extras.getString(BundleKeys.KEY_USERNAME)
+ //
+ //
+ // if (extras.containsKey(BundleKeys.KEY_IS_PASSWORD_UPDATE)) {
+ // isPasswordUpdate = extras.getBoolean(BundleKeys.KEY_IS_PASSWORD_UPDATE)
+ // }
+ //
+ // if (extras.containsKey(BundleKeys.KEY_PASSWORD)) {
+ // password = extras.getString(BundleKeys.KEY_PASSWORD)
+ // }
+ }
- binding?.hostUrlInputHelperText?.text = String.format(
+ override fun onResume() {
+ super.onResume()
+
+ binding.hostUrlInputHelperText.text = String.format(
resources!!.getString(R.string.nc_server_helper_text),
resources!!.getString(R.string.nc_server_product_name)
)
- binding?.serverEntryTextInputLayout?.setEndIconOnClickListener { checkServerAndProceed() }
+ binding.serverEntryTextInputLayout.setEndIconOnClickListener { checkServerAndProceed() }
if (resources!!.getBoolean(R.bool.hide_auth_cert)) {
- binding?.certTextView?.visibility = View.GONE
+ binding.certTextView.visibility = View.GONE
}
val loggedInUsers = userManager.users.blockingGet()
@@ -124,21 +135,69 @@ class ServerSelectionController :
} else if (isAbleToShowProviderLink() && loggedInUsers.isEmpty()) {
showVisitProvidersInfo()
} else {
- binding?.importOrChooseProviderText?.visibility = View.INVISIBLE
+ binding.importOrChooseProviderText.visibility = View.INVISIBLE
}
- binding?.serverEntryTextInputEditText?.requestFocus()
+ binding.serverEntryTextInputEditText.requestFocus()
if (!TextUtils.isEmpty(resources!!.getString(R.string.weblogin_url))) {
- binding?.serverEntryTextInputEditText?.setText(resources!!.getString(R.string.weblogin_url))
+ binding.serverEntryTextInputEditText.setText(resources!!.getString(R.string.weblogin_url))
checkServerAndProceed()
}
- binding?.serverEntryTextInputEditText?.setOnEditorActionListener { _: TextView?, i: Int, _: KeyEvent? ->
+ binding.serverEntryTextInputEditText.setOnEditorActionListener { _: TextView?, i: Int, _: KeyEvent? ->
if (i == EditorInfo.IME_ACTION_DONE) {
checkServerAndProceed()
}
false
}
- binding?.certTextView?.setOnClickListener { onCertClick() }
+ binding.certTextView.setOnClickListener { onCertClick() }
+
+ if (ApplicationWideMessageHolder.getInstance().messageType != null) {
+ if (ApplicationWideMessageHolder.getInstance().messageType
+ == ApplicationWideMessageHolder.MessageType.ACCOUNT_SCHEDULED_FOR_DELETION
+ ) {
+ setErrorText(resources!!.getString(R.string.nc_account_scheduled_for_deletion))
+ ApplicationWideMessageHolder.getInstance().messageType = null
+ } else if (ApplicationWideMessageHolder.getInstance().messageType
+ == ApplicationWideMessageHolder.MessageType.SERVER_WITHOUT_TALK
+ ) {
+ setErrorText(resources!!.getString(R.string.nc_settings_no_talk_installed))
+ } else if (ApplicationWideMessageHolder.getInstance().messageType
+ == ApplicationWideMessageHolder.MessageType.FAILED_TO_IMPORT_ACCOUNT
+ ) {
+ setErrorText(resources!!.getString(R.string.nc_server_failed_to_import_account))
+ }
+ ApplicationWideMessageHolder.getInstance().messageType = null
+ }
+ if (resources != null) {
+ DisplayUtils.applyColorToStatusBar(
+ this,
+ ResourcesCompat.getColor(resources!!, R.color.colorPrimary, null)
+ )
+ DisplayUtils.applyColorToNavigationBar(
+ window,
+ ResourcesCompat.getColor(resources!!, R.color.colorPrimary, null)
+ )
+ }
+ setCertTextView()
+ }
+
+ fun onCertClick() {
+ KeyChain.choosePrivateKeyAlias(
+ this,
+ { alias: String? ->
+ if (alias != null) {
+ appPreferences!!.temporaryClientCertAlias = alias
+ } else {
+ appPreferences!!.removeTemporaryClientCertAlias()
+ }
+ setCertTextView()
+ },
+ arrayOf("RSA", "EC"),
+ null,
+ null,
+ -1,
+ null
+ )
}
private fun isAbleToShowProviderLink(): Boolean {
@@ -152,41 +211,42 @@ class ServerSelectionController :
)
) {
if (availableAccounts.size > 1) {
- binding?.importOrChooseProviderText?.text = String.format(
+ binding.importOrChooseProviderText.text = String.format(
resources!!.getString(R.string.nc_server_import_accounts),
AccountUtils.getAppNameBasedOnPackage(resources!!.getString(R.string.nc_import_accounts_from))
)
} else {
- binding?.importOrChooseProviderText?.text = String.format(
+ binding.importOrChooseProviderText.text = String.format(
resources!!.getString(R.string.nc_server_import_account),
AccountUtils.getAppNameBasedOnPackage(resources!!.getString(R.string.nc_import_accounts_from))
)
}
} else {
if (availableAccounts.size > 1) {
- binding?.importOrChooseProviderText?.text =
+ binding.importOrChooseProviderText.text =
resources!!.getString(R.string.nc_server_import_accounts_plain)
} else {
- binding?.importOrChooseProviderText?.text =
+ binding.importOrChooseProviderText.text =
resources!!.getString(R.string.nc_server_import_account_plain)
}
}
- binding?.importOrChooseProviderText?.setOnClickListener {
+ binding.importOrChooseProviderText.setOnClickListener {
val bundle = Bundle()
bundle.putBoolean(KEY_IS_ACCOUNT_IMPORT, true)
- router.pushController(
- RouterTransaction.with(
- SwitchAccountController(bundle)
- )
- .pushChangeHandler(HorizontalChangeHandler())
- .popChangeHandler(HorizontalChangeHandler())
- )
+ // TODO start SwitchAccountActivity?
+ // router.pushController(
+ // RouterTransaction.with(
+ // SwitchAccountController(bundle)
+ // )
+ // .pushChangeHandler(HorizontalChangeHandler())
+ // .popChangeHandler(HorizontalChangeHandler())
+ // )
}
}
private fun showVisitProvidersInfo() {
- binding?.importOrChooseProviderText?.setText(R.string.nc_get_from_provider)
- binding?.importOrChooseProviderText?.setOnClickListener {
+ binding.importOrChooseProviderText.setText(R.string.nc_get_from_provider)
+ binding.importOrChooseProviderText.setOnClickListener {
val browserIntent = Intent(
Intent.ACTION_VIEW,
Uri.parse(
@@ -206,11 +266,11 @@ class ServerSelectionController :
@Suppress("Detekt.TooGenericExceptionCaught")
private fun checkServerAndProceed() {
dispose()
- var url: String = binding?.serverEntryTextInputEditText?.text.toString().trim { it <= ' ' }
+ var url: String = binding.serverEntryTextInputEditText.text.toString().trim { it <= ' ' }
showserverEntryProgressBar()
- if (binding?.importOrChooseProviderText?.visibility != View.INVISIBLE) {
- binding?.importOrChooseProviderText?.visibility = View.INVISIBLE
- binding?.certTextView?.visibility = View.INVISIBLE
+ if (binding.importOrChooseProviderText.visibility != View.INVISIBLE) {
+ binding.importOrChooseProviderText.visibility = View.INVISIBLE
+ binding.certTextView.visibility = View.INVISIBLE
}
if (url.endsWith("/")) {
url = url.substring(0, url.length - 1)
@@ -278,17 +338,17 @@ class ServerSelectionController :
hideserverEntryProgressBar()
}
- if (binding?.importOrChooseProviderText?.visibility != View.INVISIBLE) {
- binding?.importOrChooseProviderText?.visibility = View.VISIBLE
- binding?.certTextView?.visibility = View.VISIBLE
+ if (binding.importOrChooseProviderText.visibility != View.INVISIBLE) {
+ binding.importOrChooseProviderText.visibility = View.VISIBLE
+ binding.certTextView.visibility = View.VISIBLE
}
dispose()
}
}) {
hideserverEntryProgressBar()
- if (binding?.importOrChooseProviderText?.visibility != View.INVISIBLE) {
- binding?.importOrChooseProviderText?.visibility = View.VISIBLE
- binding?.certTextView?.visibility = View.VISIBLE
+ if (binding.importOrChooseProviderText.visibility != View.INVISIBLE) {
+ binding.importOrChooseProviderText.visibility = View.VISIBLE
+ binding.certTextView.visibility = View.VISIBLE
}
dispose()
}
@@ -311,29 +371,37 @@ class ServerSelectionController :
capabilities.spreedCapability?.features?.isNotEmpty() == true
if (hasTalk) {
- activity?.runOnUiThread {
+ runOnUiThread {
if (CapabilitiesUtilNew.isServerEOL(capabilities)) {
if (resources != null) {
- activity!!.runOnUiThread {
+ runOnUiThread {
setErrorText(resources!!.getString(R.string.nc_settings_server_eol))
}
}
} else {
- router.pushController(
- RouterTransaction.with(
- WebViewLoginController(
- queryUrl.replace("/status.php", ""),
- false
- )
- )
- .pushChangeHandler(HorizontalChangeHandler())
- .popChangeHandler(HorizontalChangeHandler())
- )
+ val bundle = Bundle()
+ bundle.putString(BundleKeys.KEY_BASE_URL, queryUrl.replace("/status.php", ""))
+ bundle.putBoolean(BundleKeys.KEY_IS_PASSWORD_UPDATE, false)
+
+ val intent = Intent(context, WebViewLoginActivity::class.java)
+ intent.putExtras(bundle)
+ startActivity(intent)
+
+ // router.pushController(
+ // RouterTransaction.with(
+ // WebViewLoginActivity(
+ // queryUrl.replace("/status.php", ""),
+ // false
+ // )
+ // )
+ // .pushChangeHandler(HorizontalChangeHandler())
+ // .popChangeHandler(HorizontalChangeHandler())
+ // )
}
}
} else {
- if (activity != null && resources != null) {
- activity!!.runOnUiThread {
+ if (resources != null) {
+ runOnUiThread {
setErrorText(resources!!.getString(R.string.nc_server_unsupported))
}
}
@@ -342,8 +410,8 @@ class ServerSelectionController :
override fun onError(e: Throwable) {
Log.e(TAG, "Error while checking capabilities", e)
- if (activity != null && resources != null) {
- activity!!.runOnUiThread {
+ if (resources != null) {
+ runOnUiThread {
setErrorText(resources!!.getString(R.string.nc_common_error_sorry))
}
}
@@ -360,70 +428,29 @@ class ServerSelectionController :
}
private fun setErrorText(text: String) {
- binding?.errorWrapper?.visibility = View.VISIBLE
- binding?.errorText?.text = text
+ binding.errorWrapper.visibility = View.VISIBLE
+ binding.errorText.text = text
hideserverEntryProgressBar()
}
private fun showserverEntryProgressBar() {
- binding?.errorWrapper?.visibility = View.INVISIBLE
- binding?.serverEntryProgressBar?.visibility = View.VISIBLE
+ binding.errorWrapper.visibility = View.INVISIBLE
+ binding.serverEntryProgressBar.visibility = View.VISIBLE
}
private fun hideserverEntryProgressBar() {
- binding?.serverEntryProgressBar?.visibility = View.INVISIBLE
- }
-
- override fun onAttach(view: View) {
- super.onAttach(view)
- if (ApplicationWideMessageHolder.getInstance().messageType != null) {
- if (ApplicationWideMessageHolder.getInstance().messageType
- == ApplicationWideMessageHolder.MessageType.ACCOUNT_SCHEDULED_FOR_DELETION
- ) {
- setErrorText(resources!!.getString(R.string.nc_account_scheduled_for_deletion))
- ApplicationWideMessageHolder.getInstance().messageType = null
- } else if (ApplicationWideMessageHolder.getInstance().messageType
- == ApplicationWideMessageHolder.MessageType.SERVER_WITHOUT_TALK
- ) {
- setErrorText(resources!!.getString(R.string.nc_settings_no_talk_installed))
- } else if (ApplicationWideMessageHolder.getInstance().messageType
- == ApplicationWideMessageHolder.MessageType.FAILED_TO_IMPORT_ACCOUNT
- ) {
- setErrorText(resources!!.getString(R.string.nc_server_failed_to_import_account))
- }
- ApplicationWideMessageHolder.getInstance().messageType = null
- }
- if (activity != null && resources != null) {
- DisplayUtils.applyColorToStatusBar(
- activity,
- ResourcesCompat.getColor(resources!!, R.color.colorPrimary, null)
- )
- DisplayUtils.applyColorToNavigationBar(
- activity!!.window,
- ResourcesCompat.getColor(resources!!, R.color.colorPrimary, null)
- )
- }
- setCertTextView()
+ binding.serverEntryProgressBar.visibility = View.INVISIBLE
}
@SuppressLint("LongLogTag")
private fun setCertTextView() {
- if (activity != null) {
- activity!!.runOnUiThread {
- if (!TextUtils.isEmpty(appPreferences!!.temporaryClientCertAlias)) {
- binding?.certTextView?.setText(R.string.nc_change_cert_auth)
- } else {
- binding?.certTextView?.setText(R.string.nc_configure_cert_auth)
- }
- hideserverEntryProgressBar()
+ runOnUiThread {
+ if (!TextUtils.isEmpty(appPreferences.temporaryClientCertAlias)) {
+ binding.certTextView.setText(R.string.nc_change_cert_auth)
+ } else {
+ binding.certTextView.setText(R.string.nc_configure_cert_auth)
}
- }
- }
-
- override fun onDestroyView(view: View) {
- super.onDestroyView(view)
- if (activity != null) {
- activity!!.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
+ hideserverEntryProgressBar()
}
}
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/SwitchAccountController.kt b/app/src/main/java/com/nextcloud/talk/account/SwitchAccountActivity.kt
similarity index 76%
rename from app/src/main/java/com/nextcloud/talk/controllers/SwitchAccountController.kt
rename to app/src/main/java/com/nextcloud/talk/account/SwitchAccountActivity.kt
index 36bf20a0673..2044087af80 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/SwitchAccountController.kt
+++ b/app/src/main/java/com/nextcloud/talk/account/SwitchAccountActivity.kt
@@ -22,23 +22,19 @@
* Parts related to account import were either copied from or inspired by the great work done by David Luhmer at:
* https://github.com/nextcloud/ownCloud-Account-Importer
*/
-package com.nextcloud.talk.controllers
+package com.nextcloud.talk.account
import android.accounts.Account
+import android.content.Intent
+import android.content.pm.ActivityInfo
import android.os.Bundle
import android.view.MenuItem
-import android.view.View
import androidx.preference.PreferenceManager
import androidx.recyclerview.widget.LinearLayoutManager
import autodagger.AutoInjector
-import com.bluelinelabs.conductor.RouterTransaction
-import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
-import com.nextcloud.talk.R
+import com.nextcloud.talk.activities.BaseActivity
import com.nextcloud.talk.adapters.items.AdvancedUserItem
import com.nextcloud.talk.application.NextcloudTalkApplication
-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.databinding.ControllerGenericRvBinding
import com.nextcloud.talk.models.ImportAccount
@@ -58,12 +54,8 @@ import java.net.CookieManager
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
-class SwitchAccountController(args: Bundle? = null) :
- BaseController(
- R.layout.controller_generic_rv,
- args
- ) {
- private val binding: ControllerGenericRvBinding? by viewBinding(ControllerGenericRvBinding::bind)
+class SwitchAccountActivity : BaseActivity() {
+ private lateinit var binding: ControllerGenericRvBinding
@Inject
lateinit var userManager: UserManager
@@ -89,41 +81,42 @@ class SwitchAccountController(args: Bundle? = null) :
if (userManager.setUserAsActive(user).blockingGet()) {
cookieManager.cookieStore.removeAll()
- if (activity != null) {
- activity!!.runOnUiThread { router.popCurrentController() }
- }
+ // TODO ???
+ // runOnUiThread { router.popCurrentController() }
}
}
true
}
- init {
- setHasOptionsMenu(true)
- sharedApplication!!.componentApplication.inject(this)
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
+
+ binding = ControllerGenericRvBinding.inflate(layoutInflater)
+ actionBar?.hide()
+ requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ setContentView(binding.root)
+ setupSystemColors()
+
Configuration.getInstance().load(context, PreferenceManager.getDefaultSharedPreferences(context))
- if (args?.containsKey(KEY_IS_ACCOUNT_IMPORT) == true) {
+
+ // setHasOptionsMenu(true)
+
+ val extras = intent.extras!!
+ if (extras.containsKey(KEY_IS_ACCOUNT_IMPORT)) {
isAccountImport = true
}
}
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
- return when (item.itemId) {
- android.R.id.home -> {
- router.popCurrentController()
- true
- }
- else -> super.onOptionsItemSelected(item)
- }
- }
+ override fun onResume() {
+ super.onResume()
- override fun onViewBound(view: View) {
- super.onViewBound(view)
- binding?.swipeRefreshLayout?.isEnabled = false
+ binding.swipeRefreshLayout.isEnabled = false
actionBar?.show()
if (adapter == null) {
- adapter = FlexibleAdapter(userItems, activity, false)
+ adapter = FlexibleAdapter(userItems, this, false)
var participant: Participant
if (!isAccountImport) {
@@ -165,12 +158,23 @@ class SwitchAccountController(args: Bundle? = null) :
prepareViews()
}
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ return when (item.itemId) {
+ android.R.id.home -> {
+ // router.popCurrentController()
+ finish()
+ true
+ }
+ else -> super.onOptionsItemSelected(item)
+ }
+ }
+
private fun prepareViews() {
- val layoutManager: LinearLayoutManager = SmoothScrollLinearLayoutManager(activity)
- binding?.recyclerView?.layoutManager = layoutManager
- binding?.recyclerView?.setHasFixedSize(true)
- binding?.recyclerView?.adapter = adapter
- binding?.swipeRefreshLayout?.isEnabled = false
+ val layoutManager: LinearLayoutManager = SmoothScrollLinearLayoutManager(this)
+ binding.recyclerView.layoutManager = layoutManager
+ binding.recyclerView.setHasFixedSize(true)
+ binding.recyclerView.adapter = adapter
+ binding.swipeRefreshLayout.isEnabled = false
}
private fun reauthorizeFromImport(account: Account?) {
@@ -180,14 +184,19 @@ class SwitchAccountController(args: Bundle? = null) :
bundle.putString(KEY_USERNAME, importAccount.getUsername())
bundle.putString(KEY_TOKEN, importAccount.getToken())
bundle.putBoolean(KEY_IS_ACCOUNT_IMPORT, true)
- router.pushController(
- RouterTransaction.with(AccountVerificationController(bundle))
- .pushChangeHandler(HorizontalChangeHandler())
- .popChangeHandler(HorizontalChangeHandler())
- )
+
+ // router.pushController(
+ // RouterTransaction.with(AccountVerificationController(bundle))
+ // .pushChangeHandler(HorizontalChangeHandler())
+ // .popChangeHandler(HorizontalChangeHandler())
+ // )
+
+ val intent = Intent(context, AccountVerificationActivity::class.java)
+ intent.putExtras(bundle)
+ startActivity(intent)
}
- override val title: String
- get() =
- resources!!.getString(R.string.nc_select_an_account)
+ // override val title: String
+ // get() =
+ // resources!!.getString(R.string.nc_select_an_account)
}
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/WebViewLoginController.kt b/app/src/main/java/com/nextcloud/talk/account/WebViewLoginActivity.kt
similarity index 78%
rename from app/src/main/java/com/nextcloud/talk/controllers/WebViewLoginController.kt
rename to app/src/main/java/com/nextcloud/talk/account/WebViewLoginActivity.kt
index 7bddc38c351..eeaf3e2f0c0 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/WebViewLoginController.kt
+++ b/app/src/main/java/com/nextcloud/talk/account/WebViewLoginActivity.kt
@@ -19,9 +19,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package com.nextcloud.talk.controllers
+package com.nextcloud.talk.account
import android.annotation.SuppressLint
+import android.content.Intent
import android.content.pm.ActivityInfo
import android.graphics.Bitmap
import android.net.http.SslError
@@ -40,25 +41,20 @@ import android.webkit.WebResourceResponse
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
-import androidx.appcompat.app.AppCompatActivity
-import androidx.core.content.res.ResourcesCompat
import androidx.work.Data
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import autodagger.AutoInjector
-import com.bluelinelabs.conductor.RouterTransaction
-import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
import com.nextcloud.talk.R
+import com.nextcloud.talk.activities.BaseActivity
import com.nextcloud.talk.application.NextcloudTalkApplication
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.databinding.ControllerWebViewLoginBinding
+import com.nextcloud.talk.databinding.ActivityWebViewLoginBinding
import com.nextcloud.talk.events.CertificateEvent
import com.nextcloud.talk.jobs.PushRegistrationWorker
import com.nextcloud.talk.models.LoginData
import com.nextcloud.talk.users.UserManager
-import com.nextcloud.talk.utils.DisplayUtils
+import com.nextcloud.talk.utils.bundle.BundleKeys
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_BASE_URL
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ORIGINAL_PROTOCOL
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_TOKEN
@@ -67,7 +63,6 @@ import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder
import com.nextcloud.talk.utils.ssl.TrustManager
import de.cotech.hw.fido.WebViewFidoBridge
import io.reactivex.disposables.Disposable
-import org.greenrobot.eventbus.EventBus
import java.lang.reflect.Field
import java.net.CookieManager
import java.net.URLDecoder
@@ -78,11 +73,9 @@ import java.util.Locale
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
-class WebViewLoginController(args: Bundle? = null) : BaseController(
- R.layout.controller_web_view_login,
- args
-) {
- private val binding: ControllerWebViewLoginBinding? by viewBinding(ControllerWebViewLoginBinding::bind)
+class WebViewLoginActivity : BaseActivity() {
+
+ private lateinit var binding: ActivityWebViewLoginBinding
@Inject
lateinit var userManager: UserManager
@@ -90,9 +83,6 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
@Inject
lateinit var trustManager: TrustManager
- @Inject
- lateinit var eventBus: EventBus
-
@Inject
lateinit var cookieManager: CookieManager
@@ -106,17 +96,17 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
private var automatedLoginAttempted = false
private var webViewFidoBridge: WebViewFidoBridge? = null
- constructor(baseUrl: String?, isPasswordUpdate: Boolean) : this() {
- this.baseUrl = baseUrl
- this.isPasswordUpdate = isPasswordUpdate
- }
-
- constructor(baseUrl: String?, isPasswordUpdate: Boolean, username: String?, password: String?) : this() {
- this.baseUrl = baseUrl
- this.isPasswordUpdate = isPasswordUpdate
- this.username = username
- this.password = password
- }
+ // constructor(baseUrl: String?, isPasswordUpdate: Boolean) : this() {
+ // this.baseUrl = baseUrl
+ // this.isPasswordUpdate = isPasswordUpdate
+ // }
+ //
+ // constructor(baseUrl: String?, isPasswordUpdate: Boolean, username: String?, password: String?) : this() {
+ // this.baseUrl = baseUrl
+ // this.isPasswordUpdate = isPasswordUpdate
+ // this.username = username
+ // this.password = password
+ // }
private val webLoginUserAgent: String
get() = (
@@ -129,33 +119,61 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
")"
)
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
+
+ binding = ActivityWebViewLoginBinding.inflate(layoutInflater)
+ actionBar?.hide()
+ requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ setContentView(binding.root)
+ setupSystemColors()
+ // viewThemeUtils.material.themeCardView(binding.searchToolbar)
+ // viewThemeUtils.material.themeSearchBarText(binding.searchText)
+
+ // onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
+
+ val extras = intent.extras!!
+ baseUrl = extras.getString(KEY_BASE_URL)
+ username = extras.getString(KEY_USERNAME)
+
+ if (extras.containsKey(BundleKeys.KEY_IS_PASSWORD_UPDATE)) {
+ isPasswordUpdate = extras.getBoolean(BundleKeys.KEY_IS_PASSWORD_UPDATE)
+ }
+
+ if (extras.containsKey(BundleKeys.KEY_PASSWORD)) {
+ password = extras.getString(BundleKeys.KEY_PASSWORD)
+ }
+ }
+
@SuppressLint("SetJavaScriptEnabled")
- override fun onViewBound(view: View) {
- super.onViewBound(view)
- activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ override fun onResume() {
+ super.onResume()
+
+ requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
actionBar?.hide()
assembledPrefix = resources!!.getString(R.string.nc_talk_login_scheme) + PROTOCOL_SUFFIX + "login/"
- binding?.webview?.settings?.allowFileAccess = false
- binding?.webview?.settings?.allowFileAccessFromFileURLs = false
- binding?.webview?.settings?.javaScriptEnabled = true
- binding?.webview?.settings?.javaScriptCanOpenWindowsAutomatically = false
- binding?.webview?.settings?.domStorageEnabled = true
- binding?.webview?.settings?.setUserAgentString(webLoginUserAgent)
- binding?.webview?.settings?.saveFormData = false
- binding?.webview?.settings?.savePassword = false
- binding?.webview?.settings?.setRenderPriority(WebSettings.RenderPriority.HIGH)
- binding?.webview?.clearCache(true)
- binding?.webview?.clearFormData()
- binding?.webview?.clearHistory()
+ binding.webview.settings.allowFileAccess = false
+ binding.webview.settings.allowFileAccessFromFileURLs = false
+ binding.webview.settings.javaScriptEnabled = true
+ binding.webview.settings.javaScriptCanOpenWindowsAutomatically = false
+ binding.webview.settings.domStorageEnabled = true
+ binding.webview.settings.setUserAgentString(webLoginUserAgent)
+ binding.webview.settings.saveFormData = false
+ binding.webview.settings.savePassword = false
+ binding.webview.settings.setRenderPriority(WebSettings.RenderPriority.HIGH)
+ binding.webview.clearCache(true)
+ binding.webview.clearFormData()
+ binding.webview.clearHistory()
WebView.clearClientCertPreferences(null)
- webViewFidoBridge = WebViewFidoBridge.createInstanceForWebView(activity as AppCompatActivity?, binding?.webview)
- CookieSyncManager.createInstance(activity)
+ webViewFidoBridge = WebViewFidoBridge.createInstanceForWebView(this, binding.webview)
+ CookieSyncManager.createInstance(this)
android.webkit.CookieManager.getInstance().removeAllCookies(null)
val headers: MutableMap = HashMap()
- headers.put("OCS-APIRequest", "true")
- binding?.webview?.webViewClient = object : WebViewClient() {
+ headers["OCS-APIRequest"] = "true"
+ binding.webview.webViewClient = object : WebViewClient() {
private var basePageLoaded = false
override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? {
webViewFidoBridge?.delegateShouldInterceptRequest(view, request)
@@ -180,24 +198,24 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
override fun onPageFinished(view: WebView, url: String) {
loginStep++
if (!basePageLoaded) {
- binding?.progressBar?.visibility = View.GONE
- binding?.webview?.visibility = View.VISIBLE
+ binding.progressBar.visibility = View.GONE
+ binding.webview.visibility = View.VISIBLE
basePageLoaded = true
}
if (!TextUtils.isEmpty(username)) {
if (loginStep == 1) {
- binding?.webview?.loadUrl(
+ binding.webview.loadUrl(
"javascript: {document.getElementsByClassName('login')[0].click(); };"
)
} else if (!automatedLoginAttempted) {
automatedLoginAttempted = true
if (TextUtils.isEmpty(password)) {
- binding?.webview?.loadUrl(
+ binding.webview.loadUrl(
"javascript:var justStore = document.getElementById('user').value = '$username';"
)
} else {
- binding?.webview?.loadUrl(
+ binding.webview.loadUrl(
"javascript: {" +
"document.getElementById('user').value = '" + username + "';" +
"document.getElementById('password').value = '" + password + "';" +
@@ -214,7 +232,7 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
val user = userManager.currentUser.blockingGet()
var alias: String? = null
if (!isPasswordUpdate) {
- alias = appPreferences!!.temporaryClientCertAlias
+ alias = appPreferences.temporaryClientCertAlias
}
if (TextUtils.isEmpty(alias) && user != null) {
alias = user.clientCertificate
@@ -223,9 +241,9 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
val finalAlias = alias
Thread {
try {
- val privateKey = KeyChain.getPrivateKey(activity!!, finalAlias!!)
+ val privateKey = KeyChain.getPrivateKey(applicationContext, finalAlias!!)
val certificates = KeyChain.getCertificateChain(
- activity!!,
+ applicationContext,
finalAlias
)
if (privateKey != null && certificates != null) {
@@ -241,16 +259,16 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
}.start()
} else {
KeyChain.choosePrivateKeyAlias(
- activity!!,
+ this@WebViewLoginActivity,
{ chosenAlias: String? ->
if (chosenAlias != null) {
appPreferences!!.temporaryClientCertAlias = chosenAlias
Thread {
var privateKey: PrivateKey? = null
try {
- privateKey = KeyChain.getPrivateKey(activity!!, chosenAlias)
+ privateKey = KeyChain.getPrivateKey(applicationContext, chosenAlias)
val certificates = KeyChain.getCertificateChain(
- activity!!,
+ applicationContext,
chosenAlias
)
if (privateKey != null && certificates != null) {
@@ -304,7 +322,7 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
super.onReceivedError(view, errorCode, description, failingUrl)
}
}
- binding?.webview?.loadUrl("$baseUrl/index.php/login/flow", headers)
+ binding.webview.loadUrl("$baseUrl/index.php/login/flow", headers)
}
private fun dispose() {
@@ -328,11 +346,13 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
if (userManager.checkIfUserIsScheduledForDeletion(loginData.username!!, baseUrl!!).blockingGet()) {
ApplicationWideMessageHolder.getInstance().messageType =
ApplicationWideMessageHolder.MessageType.ACCOUNT_SCHEDULED_FOR_DELETION
- if (!isPasswordUpdate) {
- router.popToRoot()
- } else {
- router.popCurrentController()
- }
+
+ // TODO ....
+ // if (!isPasswordUpdate) {
+ // router.popToRoot()
+ // } else {
+ // router.popCurrentController()
+ // }
}
val finalMessageType = messageType
cookieManager.cookieStore.removeAll()
@@ -350,11 +370,14 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
if (!TextUtils.isEmpty(protocol)) {
bundle.putString(KEY_ORIGINAL_PROTOCOL, protocol)
}
- router.pushController(
- RouterTransaction.with(AccountVerificationController(bundle))
- .pushChangeHandler(HorizontalChangeHandler())
- .popChangeHandler(HorizontalChangeHandler())
- )
+ // router.pushController(
+ // RouterTransaction.with(AccountVerificationActivity(bundle))
+ // .pushChangeHandler(HorizontalChangeHandler())
+ // .popChangeHandler(HorizontalChangeHandler())
+ // )
+ val intent = Intent(context, AccountVerificationActivity::class.java)
+ intent.putExtras(bundle)
+ startActivity(intent)
} else {
if (isPasswordUpdate) {
if (currentUser != null) {
@@ -379,7 +402,8 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
.build()
WorkManager.getInstance().enqueue(pushRegistrationWork)
- router.popCurrentController()
+ // TODO: start ServerSelectionActivity?
+ // router.popCurrentController()
}
} else {
if (finalMessageType != null) {
@@ -388,7 +412,8 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
// The token is not updated in the database and therefore the account not visible/usable
ApplicationWideMessageHolder.getInstance().messageType = finalMessageType
}
- router.popToRoot()
+ // TODO: start ServerSelectionActivity?
+ // router.popToRoot()
}
}
}
@@ -432,30 +457,11 @@ class WebViewLoginController(args: Bundle? = null) : BaseController(
}
}
- override fun onAttach(view: View) {
- super.onAttach(view)
- if (activity != null && resources != null) {
- DisplayUtils.applyColorToStatusBar(
- activity,
- ResourcesCompat.getColor(resources!!, R.color.colorPrimary, null)
- )
- DisplayUtils.applyColorToNavigationBar(
- activity!!.window,
- ResourcesCompat.getColor(resources!!, R.color.colorPrimary, null)
- )
- }
- }
-
public override fun onDestroy() {
super.onDestroy()
dispose()
}
- override fun onDestroyView(view: View) {
- super.onDestroyView(view)
- activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR
- }
-
init {
sharedApplication!!.componentApplication.inject(this)
}
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/base/providers/ActionBarProvider.java b/app/src/main/java/com/nextcloud/talk/activities/ActionBarProvider.java
similarity index 93%
rename from app/src/main/java/com/nextcloud/talk/controllers/base/providers/ActionBarProvider.java
rename to app/src/main/java/com/nextcloud/talk/activities/ActionBarProvider.java
index ceb393e673a..76d7ce1fde7 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/base/providers/ActionBarProvider.java
+++ b/app/src/main/java/com/nextcloud/talk/activities/ActionBarProvider.java
@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.nextcloud.talk.controllers.base.providers;
+package com.nextcloud.talk.activities;
import androidx.appcompat.app.ActionBar;
diff --git a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt
index 4d7462e54db..7d2d00d0480 100644
--- a/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt
+++ b/app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt
@@ -37,21 +37,14 @@ import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.ProcessLifecycleOwner
import autodagger.AutoInjector
-import com.bluelinelabs.conductor.Conductor
-import com.bluelinelabs.conductor.Router
-import com.bluelinelabs.conductor.RouterTransaction
-import com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler
-import com.bluelinelabs.conductor.changehandler.VerticalChangeHandler
import com.google.android.material.snackbar.Snackbar
-import com.nextcloud.talk.BuildConfig
import com.nextcloud.talk.R
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.callnotification.CallNotificationActivity
import com.nextcloud.talk.chat.ChatActivity
-import com.nextcloud.talk.controllers.ServerSelectionController
-import com.nextcloud.talk.controllers.WebViewLoginController
-import com.nextcloud.talk.controllers.base.providers.ActionBarProvider
+import com.nextcloud.talk.account.ServerSelectionActivity
+import com.nextcloud.talk.account.WebViewLoginActivity
import com.nextcloud.talk.conversationlist.ConversationsListActivity
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ActivityMainBinding
@@ -61,7 +54,6 @@ import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.SecurityUtils
import com.nextcloud.talk.utils.bundle.BundleKeys
-import com.nextcloud.talk.utils.bundle.BundleKeys.ADD_ACCOUNT
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import io.reactivex.Observer
import io.reactivex.SingleObserver
@@ -80,13 +72,9 @@ class MainActivity : BaseActivity(), ActionBarProvider {
@Inject
lateinit var userManager: UserManager
- private var router: Router? = null
-
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
- if (!router!!.handleBack()) {
- finish()
- }
+ finish()
}
}
@@ -111,8 +99,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
setSupportActionBar(binding.toolbar)
- router = Conductor.attachRouter(this, binding.controllerContainer, savedInstanceState)
-
handleIntent(intent)
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
@@ -128,28 +114,25 @@ class MainActivity : BaseActivity(), ActionBarProvider {
}
}
- private fun launchLoginScreen() {
- if (!TextUtils.isEmpty(resources.getString(R.string.weblogin_url))) {
- router!!.pushController(
- RouterTransaction.with(
- WebViewLoginController(resources.getString(R.string.weblogin_url), false)
- )
- .pushChangeHandler(HorizontalChangeHandler())
- .popChangeHandler(HorizontalChangeHandler())
- )
+ private fun launchServerSelection() {
+ if (isBrandingUrlSet()) {
+ val intent = Intent(context, WebViewLoginActivity::class.java)
+ val bundle = Bundle()
+ bundle.putString(BundleKeys.KEY_BASE_URL, resources.getString(R.string.weblogin_url))
+ bundle.putBoolean(BundleKeys.KEY_IS_PASSWORD_UPDATE, false)
+ intent.putExtras(bundle)
+ startActivity(intent)
} else {
- router!!.setRoot(
- RouterTransaction.with(ServerSelectionController())
- .pushChangeHandler(HorizontalChangeHandler())
- .popChangeHandler(HorizontalChangeHandler())
- )
+ val intent = Intent(context, ServerSelectionActivity::class.java)
+ startActivity(intent)
}
}
+ private fun isBrandingUrlSet() = !TextUtils.isEmpty(resources.getString(R.string.weblogin_url))
+
override fun onStart() {
Log.d(TAG, "onStart: Activity: " + System.identityHashCode(this).toString())
super.onStart()
- logRouterBackStack(router!!)
}
override fun onResume() {
@@ -178,14 +161,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
startActivity(intent)
}
- fun addAccount() {
- router!!.pushController(
- RouterTransaction.with(ServerSelectionController())
- .pushChangeHandler(VerticalChangeHandler())
- .popChangeHandler(VerticalChangeHandler())
- )
- }
-
private fun handleActionFromContact(intent: Intent) {
if (intent.action == Intent.ACTION_VIEW && intent.data != null) {
val cursor = contentResolver.query(intent.data!!, null, null, null, null)
@@ -209,7 +184,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
startConversation(user)
} else {
Snackbar.make(
- binding.controllerContainer,
+ binding.root,
R.string.nc_phone_book_integration_account_not_found,
Snackbar.LENGTH_LONG
).show()
@@ -283,28 +258,18 @@ class MainActivity : BaseActivity(), ActionBarProvider {
}
if (user != null && userManager.setUserAsActive(user).blockingGet()) {
- // this should be avoided (it's still from conductor architecture). activities should be opened directly.
if (intent.hasExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)) {
if (intent.getBooleanExtra(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL, false)) {
- if (!router!!.hasRootController()) {
- openConversationList()
- }
val callNotificationIntent = Intent(this, CallNotificationActivity::class.java)
intent.extras?.let { callNotificationIntent.putExtras(it) }
startActivity(callNotificationIntent)
} else {
- logRouterBackStack(router!!)
-
val chatIntent = Intent(context, ChatActivity::class.java)
chatIntent.putExtras(intent.extras!!)
startActivity(chatIntent)
-
- logRouterBackStack(router!!)
}
}
- } else if (intent.hasExtra(ADD_ACCOUNT) && intent.getBooleanExtra(ADD_ACCOUNT, false)) {
- addAccount()
- } else if (!router!!.hasRootController()) {
+ } else {
if (!appPreferences.isDbRoomMigrated) {
appPreferences.isDbRoomMigrated = true
}
@@ -321,7 +286,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
}
} else {
runOnUiThread {
- launchLoginScreen()
+ launchServerSelection()
}
}
}
@@ -333,18 +298,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
}
}
- private fun logRouterBackStack(router: Router) {
- if (BuildConfig.DEBUG) {
- val backstack = router.backstack
- var routerTransaction: RouterTransaction?
- Log.d(TAG, " backstack size: " + router.backstackSize)
- for (i in 0 until router.backstackSize) {
- routerTransaction = backstack[i]
- Log.d(TAG, " controller: " + routerTransaction.controller)
- }
- }
- }
-
companion object {
private const val TAG = "MainActivity"
}
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/BasicListItemWithImage.kt b/app/src/main/java/com/nextcloud/talk/bottomsheet/items/BasicListItemWithImage.kt
similarity index 95%
rename from app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/BasicListItemWithImage.kt
rename to app/src/main/java/com/nextcloud/talk/bottomsheet/items/BasicListItemWithImage.kt
index 80399135b52..247494f0ba6 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/BasicListItemWithImage.kt
+++ b/app/src/main/java/com/nextcloud/talk/bottomsheet/items/BasicListItemWithImage.kt
@@ -18,7 +18,7 @@
* along with this program. If not, see .
*/
-package com.nextcloud.talk.controllers.bottomsheet.items
+package com.nextcloud.talk.bottomsheet.items
import android.widget.ImageView
import androidx.annotation.DrawableRes
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/MagicBottomSheets.kt b/app/src/main/java/com/nextcloud/talk/bottomsheet/items/BottomSheets.kt
similarity index 97%
rename from app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/MagicBottomSheets.kt
rename to app/src/main/java/com/nextcloud/talk/bottomsheet/items/BottomSheets.kt
index ede849cddb2..fa11981de08 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/MagicBottomSheets.kt
+++ b/app/src/main/java/com/nextcloud/talk/bottomsheet/items/BottomSheets.kt
@@ -18,7 +18,7 @@
* along with this program. If not, see .
*/
-package com.nextcloud.talk.controllers.bottomsheet.items
+package com.nextcloud.talk.bottomsheet.items
import androidx.annotation.CheckResult
import androidx.recyclerview.widget.LinearLayoutManager
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/ListIconDialogAdapter.kt b/app/src/main/java/com/nextcloud/talk/bottomsheet/items/ListIconDialogAdapter.kt
similarity index 98%
rename from app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/ListIconDialogAdapter.kt
rename to app/src/main/java/com/nextcloud/talk/bottomsheet/items/ListIconDialogAdapter.kt
index 075cae600f5..ccae4ac4f17 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/items/ListIconDialogAdapter.kt
+++ b/app/src/main/java/com/nextcloud/talk/bottomsheet/items/ListIconDialogAdapter.kt
@@ -18,7 +18,7 @@
* along with this program. If not, see .
*/
-package com.nextcloud.talk.controllers.bottomsheet.items
+package com.nextcloud.talk.bottomsheet.items
import android.view.View
import android.view.ViewGroup
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.kt b/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.kt
deleted file mode 100644
index 2c5e81193a6..00000000000
--- a/app/src/main/java/com/nextcloud/talk/controllers/RingtoneSelectionController.kt
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Nextcloud Talk application
- *
- * @author Mario Danic
- * @author Andy Scherzinger
- * Copyright (C) 2022 Andy Scherzinger
- * Copyright (C) 2017-2018 Mario Danic
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.nextcloud.talk.controllers
-
-import android.annotation.SuppressLint
-import android.media.MediaPlayer
-import android.media.RingtoneManager
-import android.net.Uri
-import android.os.Bundle
-import android.os.Handler
-import android.text.TextUtils
-import android.util.Log
-import android.view.MenuItem
-import android.view.View
-import androidx.recyclerview.widget.RecyclerView
-import autodagger.AutoInjector
-import com.bluelinelabs.logansquare.LoganSquare
-import com.nextcloud.talk.R
-import com.nextcloud.talk.adapters.items.NotificationSoundItem
-import com.nextcloud.talk.application.NextcloudTalkApplication
-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.databinding.ControllerGenericRvBinding
-import com.nextcloud.talk.models.RingtoneSettings
-import com.nextcloud.talk.utils.NotificationUtils
-import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ARE_CALL_SOUNDS
-import eu.davidea.flexibleadapter.FlexibleAdapter
-import eu.davidea.flexibleadapter.SelectableAdapter
-import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
-import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
-import java.io.IOException
-
-@AutoInjector(NextcloudTalkApplication::class)
-class RingtoneSelectionController(args: Bundle) :
- BaseController(
- R.layout.controller_generic_rv,
- args
- ),
- FlexibleAdapter.OnItemClickListener {
- private val binding: ControllerGenericRvBinding? by viewBinding(ControllerGenericRvBinding::bind)
-
- private var adapter: FlexibleAdapter<*>? = null
- private var adapterDataObserver: RecyclerView.AdapterDataObserver? = null
- private val abstractFlexibleItemList: MutableList> = ArrayList()
- private val callNotificationSounds: Boolean
- private var mediaPlayer: MediaPlayer? = null
- private var cancelMediaPlayerHandler: Handler? = null
-
- override fun onViewBound(view: View) {
- super.onViewBound(view)
- if (adapter == null) {
- adapter = FlexibleAdapter(abstractFlexibleItemList, activity, false)
- adapter!!.setNotifyChangeOfUnfilteredItems(true).mode = SelectableAdapter.Mode.SINGLE
- adapter!!.addListener(this)
- cancelMediaPlayerHandler = Handler()
- }
- adapter!!.addListener(this)
- prepareViews()
- fetchNotificationSounds()
- }
-
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
- return if (item.itemId == android.R.id.home) {
- router.popCurrentController()
- } else {
- super.onOptionsItemSelected(item)
- }
- }
-
- private fun prepareViews() {
- val layoutManager: RecyclerView.LayoutManager = SmoothScrollLinearLayoutManager(activity)
- binding?.recyclerView?.layoutManager = layoutManager
- binding?.recyclerView?.setHasFixedSize(true)
- binding?.recyclerView?.adapter = adapter
- adapterDataObserver = object : RecyclerView.AdapterDataObserver() {
- override fun onChanged() {
- super.onChanged()
- findSelectedSound()
- }
- }
- adapter!!.registerAdapterDataObserver(adapterDataObserver!!)
- binding?.swipeRefreshLayout?.isEnabled = false
- }
-
- @SuppressLint("LongLogTag")
- private fun findSelectedSound() {
- var foundDefault = false
- var preferencesString: String? = null
- val callsEnabledButNoRingtone = callNotificationSounds &&
- TextUtils.isEmpty(appPreferences.callRingtoneUri.also { preferencesString = it })
- val noCallsAndNoMessageTone = !callNotificationSounds &&
- TextUtils.isEmpty(appPreferences.messageRingtoneUri.also { preferencesString = it })
- if (callsEnabledButNoRingtone || noCallsAndNoMessageTone) {
- adapter!!.toggleSelection(1)
- foundDefault = true
- }
- if (!TextUtils.isEmpty(preferencesString) && !foundDefault) {
- try {
- val ringtoneSettings: RingtoneSettings =
- LoganSquare.parse(preferencesString, RingtoneSettings::class.java)
- if (ringtoneSettings.ringtoneUri == null) {
- adapter!!.toggleSelection(0)
- } else if (ringtoneSettings.ringtoneUri!!.toString() == ringtoneString) {
- adapter!!.toggleSelection(1)
- } else {
- var notificationSoundItem: NotificationSoundItem?
- for (i in 2 until adapter!!.itemCount) {
- notificationSoundItem = adapter!!.getItem(i) as NotificationSoundItem?
- if (
- notificationSoundItem!!.notificationSoundUri == ringtoneSettings.ringtoneUri!!.toString()
- ) {
- adapter!!.toggleSelection(i)
- break
- }
- }
- }
- } catch (e: IOException) {
- Log.e(TAG, "Failed to parse ringtone settings")
- }
- }
- adapter!!.unregisterAdapterDataObserver(adapterDataObserver!!)
- adapterDataObserver = null
- }
-
- private val ringtoneString: String
- get() = if (callNotificationSounds) {
- NotificationUtils.DEFAULT_CALL_RINGTONE_URI
- } else {
- NotificationUtils.DEFAULT_MESSAGE_RINGTONE_URI
- }
-
- private fun fetchNotificationSounds() {
- abstractFlexibleItemList.add(
- NotificationSoundItem(
- resources!!.getString(R.string.nc_settings_no_ringtone),
- null
- )
- )
- abstractFlexibleItemList.add(
- NotificationSoundItem(
- resources!!.getString(R.string.nc_settings_default_ringtone),
- ringtoneString
- )
- )
- if (activity != null) {
- val manager = RingtoneManager(activity)
- if (callNotificationSounds) {
- manager.setType(RingtoneManager.TYPE_RINGTONE)
- } else {
- manager.setType(RingtoneManager.TYPE_NOTIFICATION)
- }
- val cursor = manager.cursor
- var notificationSoundItem: NotificationSoundItem
- while (cursor.moveToNext()) {
- val notificationTitle = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX)
- val notificationUri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX)
- val completeNotificationUri = notificationUri + "/" + cursor.getString(RingtoneManager.ID_COLUMN_INDEX)
- notificationSoundItem = NotificationSoundItem(notificationTitle, completeNotificationUri)
- abstractFlexibleItemList.add(notificationSoundItem)
- }
- }
- adapter!!.updateDataSet(abstractFlexibleItemList as List?, false)
- }
-
- override fun onItemClick(view: View, position: Int): Boolean {
- val notificationSoundItem = adapter!!.getItem(position) as NotificationSoundItem?
- var ringtoneUri: Uri? = null
- if (!TextUtils.isEmpty(notificationSoundItem!!.notificationSoundUri)) {
- ringtoneUri = Uri.parse(notificationSoundItem.notificationSoundUri)
- endMediaPlayer()
- mediaPlayer = MediaPlayer.create(activity, ringtoneUri)
- cancelMediaPlayerHandler = Handler()
- cancelMediaPlayerHandler!!.postDelayed(
- { endMediaPlayer() },
- (mediaPlayer!!.duration + DURATION_EXTENSION).toLong()
- )
- mediaPlayer!!.start()
- }
- if (adapter!!.selectedPositions.size == 0 || adapter!!.selectedPositions[0] != position) {
- val ringtoneSettings = RingtoneSettings()
- ringtoneSettings.ringtoneName = notificationSoundItem.notificationSoundName
- ringtoneSettings.ringtoneUri = ringtoneUri
- if (callNotificationSounds) {
- try {
- appPreferences!!.callRingtoneUri = LoganSquare.serialize(ringtoneSettings)
- adapter!!.toggleSelection(position)
- adapter!!.notifyDataSetChanged()
- } catch (e: IOException) {
- Log.e(TAG, "Failed to store selected ringtone for calls")
- }
- } else {
- try {
- appPreferences!!.messageRingtoneUri = LoganSquare.serialize(ringtoneSettings)
- adapter!!.toggleSelection(position)
- adapter!!.notifyDataSetChanged()
- } catch (e: IOException) {
- Log.e(TAG, "Failed to store selected ringtone for calls")
- }
- }
- }
- return true
- }
-
- private fun endMediaPlayer() {
- if (cancelMediaPlayerHandler != null) {
- cancelMediaPlayerHandler!!.removeCallbacksAndMessages(null)
- }
- if (mediaPlayer != null) {
- if (mediaPlayer!!.isPlaying) {
- mediaPlayer!!.stop()
- }
- mediaPlayer!!.release()
- mediaPlayer = null
- }
- }
-
- public override fun onDestroy() {
- endMediaPlayer()
- super.onDestroy()
- }
-
- companion object {
- private const val TAG = "RingtoneSelection"
- private const val DURATION_EXTENSION = 25
- }
-
- init {
- setHasOptionsMenu(true)
- sharedApplication!!.componentApplication.inject(this)
- callNotificationSounds = args.getBoolean(KEY_ARE_CALL_SOUNDS, false)
- }
-
- override val title: String
- get() =
- resources!!.getString(R.string.nc_settings_notification_sounds)
-}
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.kt b/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.kt
index 18737bc5ab8..a0158a79176 100644
--- a/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.kt
+++ b/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.kt
@@ -22,288 +22,288 @@
*/
package com.nextcloud.talk.controllers.base
-import android.content.Context
-import android.os.Build
-import android.os.Bundle
-import android.util.Log
-import android.view.LayoutInflater
-import android.view.MenuItem
-import android.view.View
-import android.view.ViewGroup
-import android.view.inputmethod.EditorInfo
-import android.view.inputmethod.InputMethodManager
-import android.widget.EditText
-import androidx.annotation.LayoutRes
-import androidx.annotation.RequiresApi
-import androidx.appcompat.app.ActionBar
-import autodagger.AutoInjector
-import com.bluelinelabs.conductor.Controller
-import com.bluelinelabs.conductor.ControllerChangeHandler
-import com.bluelinelabs.conductor.ControllerChangeType
-import com.nextcloud.talk.R
-import com.nextcloud.talk.activities.MainActivity
-import com.nextcloud.talk.application.NextcloudTalkApplication
-import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
-import com.nextcloud.talk.controllers.AccountVerificationController
-import com.nextcloud.talk.controllers.ServerSelectionController
-import com.nextcloud.talk.controllers.SwitchAccountController
-import com.nextcloud.talk.controllers.WebViewLoginController
-import com.nextcloud.talk.controllers.base.providers.ActionBarProvider
-import com.nextcloud.talk.ui.theme.ViewThemeUtils
-import com.nextcloud.talk.utils.preferences.AppPreferences
-import javax.inject.Inject
-import kotlin.jvm.internal.Intrinsics
+// import android.content.Context
+// import android.os.Build
+// import android.os.Bundle
+// import android.util.Log
+// import android.view.LayoutInflater
+// import android.view.MenuItem
+// import android.view.View
+// import android.view.ViewGroup
+// import android.view.inputmethod.EditorInfo
+// import android.view.inputmethod.InputMethodManager
+// import android.widget.EditText
+// import androidx.annotation.LayoutRes
+// import androidx.annotation.RequiresApi
+// import androidx.appcompat.app.ActionBar
+// import autodagger.AutoInjector
+// import com.bluelinelabs.conductor.Controller
+// import com.bluelinelabs.conductor.ControllerChangeHandler
+// import com.bluelinelabs.conductor.ControllerChangeType
+// import com.nextcloud.talk.R
+// import com.nextcloud.talk.activities.MainActivity
+// import com.nextcloud.talk.application.NextcloudTalkApplication
+// import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
+// import com.nextcloud.talk.account.AccountVerificationActivity
+// import com.nextcloud.talk.account.ServerSelectionActivity
+// import com.nextcloud.talk.account.SwitchAccountActivity
+// import com.nextcloud.talk.account.WebViewLoginActivity
+// import com.nextcloud.talk.activities.ActionBarProvider
+// import com.nextcloud.talk.ui.theme.ViewThemeUtils
+// import com.nextcloud.talk.utils.preferences.AppPreferences
+// import javax.inject.Inject
+// import kotlin.jvm.internal.Intrinsics
// TODO: check what needs to be migrated from this class to BaseActivity etc when conductor is removed
-@AutoInjector(NextcloudTalkApplication::class)
-abstract class BaseController(@LayoutRes var layoutRes: Int, args: Bundle? = null) : Controller(args) {
- enum class AppBarLayoutType {
- TOOLBAR, SEARCH_BAR, EMPTY
- }
-
- @Inject
- lateinit var appPreferences: AppPreferences
-
- @Inject
- lateinit var context: Context
-
- @Inject
- lateinit var viewThemeUtils: ViewThemeUtils
-
- protected open val title: String?
- get() = null
-
- @Suppress("Detekt.TooGenericExceptionCaught")
- protected val actionBar: ActionBar?
- get() {
- var actionBarProvider: ActionBarProvider? = null
- if (this.activity is ActionBarProvider) {
- try {
- actionBarProvider = this.activity as ActionBarProvider?
- } catch (e: Exception) {
- Log.d(TAG, "Failed to fetch the action bar provider", e)
- }
- }
- return actionBarProvider?.supportActionBar
- }
-
- init {
- @Suppress("LeakingThis")
- sharedApplication!!.componentApplication.inject(this)
- addLifecycleListener(object : LifecycleListener() {
- override fun postCreateView(controller: Controller, view: View) {
- onViewBound(view)
- actionBar?.let { setTitle() }
- }
- })
- cleanTempCertPreference()
- }
-
- fun isAlive(): Boolean {
- return !isDestroyed && !isBeingDestroyed
- }
-
- override fun onCreateView(
- inflater: LayoutInflater,
- container: ViewGroup,
- savedViewState: Bundle?
- ): View {
- return inflater.inflate(layoutRes, container, false)
- }
-
- protected open fun onViewBound(view: View) {
- var activity: MainActivity? = null
-
- // if (getActivity() != null && getActivity() is MainActivity) {
- // activity = getActivity() as MainActivity?
- // viewThemeUtils.material.themeCardView(activity!!.binding.searchToolbar)
- // viewThemeUtils.material.themeToolbar(activity.binding.toolbar)
- // viewThemeUtils.material.themeSearchBarText(activity.binding.searchText)
- // }
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.isKeyboardIncognito) {
- disableKeyboardPersonalisedLearning((view as ViewGroup))
- if (activity != null) {
- disableKeyboardPersonalisedLearning(activity.binding.appBar)
- }
- }
- }
-
- override fun onAttach(view: View) {
- // showSearchOrToolbar()
- setTitle()
- if (actionBar != null) {
- actionBar!!.setDisplayHomeAsUpEnabled(parentController != null || router.backstackSize >= 1)
- }
- super.onAttach(view)
- }
-
- // open fun showSearchOrToolbar() {
- // if (isValidActivity(activity)) {
- // val showSearchBar = appBarLayoutType == AppBarLayoutType.SEARCH_BAR
- // val activity = activity as MainActivity
- //
- // if (appBarLayoutType == AppBarLayoutType.EMPTY) {
- // hideBars(activity.binding)
- // } else {
- // if (showSearchBar) {
- // showSearchBar(activity.binding)
- // } else {
- // showToolbar(activity.binding)
- // }
- // colorizeStatusBar(showSearchBar, activity, resources)
- // }
- //
- // colorizeNavigationBar(activity, resources)
- // }
- // }
- //
- // private fun isValidActivity(activity: Activity?): Boolean {
- // return activity != null && activity is MainActivity
- // }
- //
- // private fun showSearchBar(binding: ActivityMainBinding) {
- // val layoutParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
- // binding.searchToolbar.visibility = View.VISIBLE
- // binding.searchText.hint = searchHint
- // binding.toolbar.visibility = View.GONE
- // // layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout
- // // .LayoutParams.SCROLL_FLAG_SNAP | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
- // layoutParams.scrollFlags = 0
- // binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
- // binding.appBar.context,
- // R.animator.appbar_elevation_off
- // )
- // binding.searchToolbar.layoutParams = layoutParams
- // }
- //
- // private fun showToolbar(binding: ActivityMainBinding) {
- // val layoutParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
- // binding.searchToolbar.visibility = View.GONE
- // binding.toolbar.visibility = View.VISIBLE
- // viewThemeUtils.material.colorToolbarOverflowIcon(binding.toolbar)
- // layoutParams.scrollFlags = 0
- // binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
- // binding.appBar.context,
- // R.animator.appbar_elevation_on
- // )
- // binding.searchToolbar.layoutParams = layoutParams
- // }
- //
- // private fun hideBars(binding: ActivityMainBinding) {
- // binding.toolbar.visibility = View.GONE
- // binding.searchToolbar.visibility = View.GONE
- // }
- //
- // fun hideSearchBar() {
- // val activity = activity as MainActivity?
- // val layoutParams = activity!!.binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
- // activity.binding.searchToolbar.visibility = View.GONE
- // activity.binding.toolbar.visibility = View.VISIBLE
- // layoutParams.scrollFlags = 0
- // activity.binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
- // activity.binding.appBar.context,
- // R.animator.appbar_elevation_on
- // )
- // }
- //
- // private fun colorizeStatusBar(showSearchBar: Boolean, activity: Activity?, resources: Resources?) {
- // if (activity != null && resources != null) {
- // if (showSearchBar) {
- // view?.let { viewThemeUtils.platform.resetStatusBar(activity) }
- // } else {
- // view?.let { viewThemeUtils.platform.themeStatusBar(activity, it) }
- // }
- // }
- // }
- //
- // private fun colorizeNavigationBar(activity: Activity?, resources: Resources?) {
- // if (activity != null && resources != null) {
- // DisplayUtils.applyColorToNavigationBar(
- // activity.window,
- // ResourcesCompat.getColor(resources, R.color.bg_default, null)
- // )
- // }
- // }
-
- override fun onDetach(view: View) {
- super.onDetach(view)
- val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
- imm.hideSoftInputFromWindow(view.windowToken, 0)
- }
-
- protected fun setTitle() {
- if (isTitleSetable()) {
- run {
- calculateValidParentController()
- }
- actionBar!!.title = title
- }
- }
-
- private fun calculateValidParentController() {
- var parentController = parentController
- while (parentController != null) {
- parentController = parentController.parentController
- }
- }
-
- private fun isTitleSetable(): Boolean {
- return title != null && actionBar != null
- }
-
- override fun onOptionsItemSelected(item: MenuItem): Boolean {
- if (item.itemId == android.R.id.home) {
- router.popCurrentController()
- return true
- }
- return super.onOptionsItemSelected(item)
- }
-
- override fun onChangeStarted(changeHandler: ControllerChangeHandler, changeType: ControllerChangeType) {
- super.onChangeStarted(changeHandler, changeType)
- if (changeType.isEnter && actionBar != null) {
- configureMenu(actionBar!!)
- }
- }
-
- fun configureMenu(toolbar: ActionBar) {
- Intrinsics.checkNotNullParameter(toolbar, "toolbar")
- }
-
- // TODO: check if this must be migrated when using activities instead of conductor
- private fun cleanTempCertPreference() {
- val temporaryClassNames: MutableList = ArrayList()
- temporaryClassNames.add(ServerSelectionController::class.java.name)
- temporaryClassNames.add(AccountVerificationController::class.java.name)
- temporaryClassNames.add(WebViewLoginController::class.java.name)
- temporaryClassNames.add(SwitchAccountController::class.java.name)
- if (!temporaryClassNames.contains(javaClass.name)) {
- appPreferences.removeTemporaryClientCertAlias()
- }
- }
-
- @RequiresApi(api = Build.VERSION_CODES.O)
- private fun disableKeyboardPersonalisedLearning(viewGroup: ViewGroup) {
- var view: View?
- var editText: EditText
- for (i in 0 until viewGroup.childCount) {
- view = viewGroup.getChildAt(i)
- if (view is EditText) {
- editText = view
- editText.imeOptions = editText.imeOptions or EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING
- } else if (view is ViewGroup) {
- disableKeyboardPersonalisedLearning(view)
- }
- }
- }
-
- open val appBarLayoutType: AppBarLayoutType
- get() = AppBarLayoutType.TOOLBAR
- val searchHint: String
- get() = context.getString(R.string.appbar_search_in, context.getString(R.string.nc_app_product_name))
-
- companion object {
- private val TAG = BaseController::class.java.simpleName
- }
-}
+// @AutoInjector(NextcloudTalkApplication::class)
+// abstract class BaseController(@LayoutRes var layoutRes: Int, args: Bundle? = null) : Controller(args) {
+// enum class AppBarLayoutType {
+// TOOLBAR, SEARCH_BAR, EMPTY
+// }
+//
+// @Inject
+// lateinit var appPreferences: AppPreferences
+//
+// @Inject
+// lateinit var context: Context
+//
+// @Inject
+// lateinit var viewThemeUtils: ViewThemeUtils
+//
+// protected open val title: String?
+// get() = null
+//
+// @Suppress("Detekt.TooGenericExceptionCaught")
+// protected val actionBar: ActionBar?
+// get() {
+// var actionBarProvider: ActionBarProvider? = null
+// if (this.activity is ActionBarProvider) {
+// try {
+// actionBarProvider = this.activity as ActionBarProvider?
+// } catch (e: Exception) {
+// Log.d(TAG, "Failed to fetch the action bar provider", e)
+// }
+// }
+// return actionBarProvider?.supportActionBar
+// }
+//
+// init {
+// @Suppress("LeakingThis")
+// sharedApplication!!.componentApplication.inject(this)
+// addLifecycleListener(object : LifecycleListener() {
+// override fun postCreateView(controller: Controller, view: View) {
+// onViewBound(view)
+// actionBar?.let { setTitle() }
+// }
+// })
+// cleanTempCertPreference()
+// }
+//
+// fun isAlive(): Boolean {
+// return !isDestroyed && !isBeingDestroyed
+// }
+//
+// override fun onCreateView(
+// inflater: LayoutInflater,
+// container: ViewGroup,
+// savedViewState: Bundle?
+// ): View {
+// return inflater.inflate(layoutRes, container, false)
+// }
+//
+// protected open fun onViewBound(view: View) {
+// var activity: MainActivity? = null
+//
+// // if (getActivity() != null && getActivity() is MainActivity) {
+// // activity = getActivity() as MainActivity?
+// // viewThemeUtils.material.themeCardView(activity!!.binding.searchToolbar)
+// // viewThemeUtils.material.themeToolbar(activity.binding.toolbar)
+// // viewThemeUtils.material.themeSearchBarText(activity.binding.searchText)
+// // }
+//
+// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.isKeyboardIncognito) {
+// disableKeyboardPersonalisedLearning((view as ViewGroup))
+// if (activity != null) {
+// disableKeyboardPersonalisedLearning(activity.binding.appBar)
+// }
+// }
+// }
+//
+// override fun onAttach(view: View) {
+// // showSearchOrToolbar()
+// setTitle()
+// if (actionBar != null) {
+// actionBar!!.setDisplayHomeAsUpEnabled(parentController != null || router.backstackSize >= 1)
+// }
+// super.onAttach(view)
+// }
+//
+// // open fun showSearchOrToolbar() {
+// // if (isValidActivity(activity)) {
+// // val showSearchBar = appBarLayoutType == AppBarLayoutType.SEARCH_BAR
+// // val activity = activity as MainActivity
+// //
+// // if (appBarLayoutType == AppBarLayoutType.EMPTY) {
+// // hideBars(activity.binding)
+// // } else {
+// // if (showSearchBar) {
+// // showSearchBar(activity.binding)
+// // } else {
+// // showToolbar(activity.binding)
+// // }
+// // colorizeStatusBar(showSearchBar, activity, resources)
+// // }
+// //
+// // colorizeNavigationBar(activity, resources)
+// // }
+// // }
+// //
+// // private fun isValidActivity(activity: Activity?): Boolean {
+// // return activity != null && activity is MainActivity
+// // }
+// //
+// // private fun showSearchBar(binding: ActivityMainBinding) {
+// // val layoutParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
+// // binding.searchToolbar.visibility = View.VISIBLE
+// // binding.searchText.hint = searchHint
+// // binding.toolbar.visibility = View.GONE
+// // // layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout
+// // // .LayoutParams.SCROLL_FLAG_SNAP | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
+// // layoutParams.scrollFlags = 0
+// // binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
+// // binding.appBar.context,
+// // R.animator.appbar_elevation_off
+// // )
+// // binding.searchToolbar.layoutParams = layoutParams
+// // }
+// //
+// // private fun showToolbar(binding: ActivityMainBinding) {
+// // val layoutParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
+// // binding.searchToolbar.visibility = View.GONE
+// // binding.toolbar.visibility = View.VISIBLE
+// // viewThemeUtils.material.colorToolbarOverflowIcon(binding.toolbar)
+// // layoutParams.scrollFlags = 0
+// // binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
+// // binding.appBar.context,
+// // R.animator.appbar_elevation_on
+// // )
+// // binding.searchToolbar.layoutParams = layoutParams
+// // }
+// //
+// // private fun hideBars(binding: ActivityMainBinding) {
+// // binding.toolbar.visibility = View.GONE
+// // binding.searchToolbar.visibility = View.GONE
+// // }
+// //
+// // fun hideSearchBar() {
+// // val activity = activity as MainActivity?
+// // val layoutParams = activity!!.binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
+// // activity.binding.searchToolbar.visibility = View.GONE
+// // activity.binding.toolbar.visibility = View.VISIBLE
+// // layoutParams.scrollFlags = 0
+// // activity.binding.appBar.stateListAnimator = AnimatorInflater.loadStateListAnimator(
+// // activity.binding.appBar.context,
+// // R.animator.appbar_elevation_on
+// // )
+// // }
+// //
+// // private fun colorizeStatusBar(showSearchBar: Boolean, activity: Activity?, resources: Resources?) {
+// // if (activity != null && resources != null) {
+// // if (showSearchBar) {
+// // view?.let { viewThemeUtils.platform.resetStatusBar(activity) }
+// // } else {
+// // view?.let { viewThemeUtils.platform.themeStatusBar(activity, it) }
+// // }
+// // }
+// // }
+// //
+// // private fun colorizeNavigationBar(activity: Activity?, resources: Resources?) {
+// // if (activity != null && resources != null) {
+// // DisplayUtils.applyColorToNavigationBar(
+// // activity.window,
+// // ResourcesCompat.getColor(resources, R.color.bg_default, null)
+// // )
+// // }
+// // }
+//
+// override fun onDetach(view: View) {
+// super.onDetach(view)
+// val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
+// imm.hideSoftInputFromWindow(view.windowToken, 0)
+// }
+//
+// protected fun setTitle() {
+// if (isTitleSetable()) {
+// run {
+// calculateValidParentController()
+// }
+// actionBar!!.title = title
+// }
+// }
+//
+// private fun calculateValidParentController() {
+// var parentController = parentController
+// while (parentController != null) {
+// parentController = parentController.parentController
+// }
+// }
+//
+// private fun isTitleSetable(): Boolean {
+// return title != null && actionBar != null
+// }
+//
+// override fun onOptionsItemSelected(item: MenuItem): Boolean {
+// if (item.itemId == android.R.id.home) {
+// router.popCurrentController()
+// return true
+// }
+// return super.onOptionsItemSelected(item)
+// }
+//
+// override fun onChangeStarted(changeHandler: ControllerChangeHandler, changeType: ControllerChangeType) {
+// super.onChangeStarted(changeHandler, changeType)
+// if (changeType.isEnter && actionBar != null) {
+// configureMenu(actionBar!!)
+// }
+// }
+//
+// fun configureMenu(toolbar: ActionBar) {
+// Intrinsics.checkNotNullParameter(toolbar, "toolbar")
+// }
+//
+// // TODO: check if this must be migrated when using activities instead of conductor
+// private fun cleanTempCertPreference() {
+// val temporaryClassNames: MutableList = ArrayList()
+// temporaryClassNames.add(ServerSelectionActivity::class.java.name)
+// temporaryClassNames.add(AccountVerificationActivity::class.java.name)
+// temporaryClassNames.add(WebViewLoginActivity::class.java.name)
+// temporaryClassNames.add(SwitchAccountActivity::class.java.name)
+// if (!temporaryClassNames.contains(javaClass.name)) {
+// appPreferences.removeTemporaryClientCertAlias()
+// }
+// }
+//
+// @RequiresApi(api = Build.VERSION_CODES.O)
+// private fun disableKeyboardPersonalisedLearning(viewGroup: ViewGroup) {
+// var view: View?
+// var editText: EditText
+// for (i in 0 until viewGroup.childCount) {
+// view = viewGroup.getChildAt(i)
+// if (view is EditText) {
+// editText = view
+// editText.imeOptions = editText.imeOptions or EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING
+// } else if (view is ViewGroup) {
+// disableKeyboardPersonalisedLearning(view)
+// }
+// }
+// }
+//
+// open val appBarLayoutType: AppBarLayoutType
+// get() = AppBarLayoutType.TOOLBAR
+// val searchHint: String
+// get() = context.getString(R.string.appbar_search_in, context.getString(R.string.nc_app_product_name))
+//
+// companion object {
+// private val TAG = BaseController::class.java.simpleName
+// }
+// }
diff --git a/app/src/main/java/com/nextcloud/talk/controllers/util/ControllerViewBindingDelegate.kt b/app/src/main/java/com/nextcloud/talk/controllers/util/ControllerViewBindingDelegate.kt
deleted file mode 100644
index 70d6247f1a3..00000000000
--- a/app/src/main/java/com/nextcloud/talk/controllers/util/ControllerViewBindingDelegate.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Nextcloud Talk application
- *
- * @author BlueLine Labs, Inc.
- * Copyright (C) 2016 BlueLine Labs, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.nextcloud.talk.controllers.util
-
-import android.view.View
-import androidx.lifecycle.LifecycleObserver
-import androidx.viewbinding.ViewBinding
-import com.bluelinelabs.conductor.Controller
-import kotlin.properties.ReadOnlyProperty
-import kotlin.reflect.KProperty
-
-fun Controller.viewBinding(bindingFactory: (View) -> T) =
- ControllerViewBindingDelegate(this, bindingFactory)
-
-class ControllerViewBindingDelegate(
- controller: Controller,
- private val viewBinder: (View) -> T
-) : ReadOnlyProperty, LifecycleObserver {
-
- private var binding: T? = null
-
- init {
- controller.addLifecycleListener(object : Controller.LifecycleListener() {
- override fun postDestroyView(controller: Controller) {
- binding = null
- }
- })
- }
-
- override fun getValue(thisRef: Controller, property: KProperty<*>): T? {
- if (binding == null) {
- binding = thisRef.view?.let { viewBinder(it) }
- }
- return binding
- }
-}
diff --git a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt
index 42c5ef67e00..8bf1be73a66 100644
--- a/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt
+++ b/app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt
@@ -58,8 +58,8 @@ import com.nextcloud.talk.adapters.items.ParticipantItem
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.contacts.ContactsActivity
-import com.nextcloud.talk.controllers.bottomsheet.items.BasicListItemWithImage
-import com.nextcloud.talk.controllers.bottomsheet.items.listItemsWithImage
+import com.nextcloud.talk.bottomsheet.items.BasicListItemWithImage
+import com.nextcloud.talk.bottomsheet.items.listItemsWithImage
import com.nextcloud.talk.conversationinfoedit.ConversationInfoEditActivity
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ActivityConversationInfoBinding
diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
index 0aa943d055a..bba83966aac 100644
--- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
+++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt
@@ -71,6 +71,8 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.talk.R
+import com.nextcloud.talk.account.ServerSelectionActivity
+import com.nextcloud.talk.account.WebViewLoginActivity
import com.nextcloud.talk.activities.BaseActivity
import com.nextcloud.talk.activities.CallActivity
import com.nextcloud.talk.adapters.items.ConversationItem
@@ -1368,20 +1370,20 @@ class ConversationsListActivity :
finish()
startActivity(intent)
} else if (!otherUserExists) {
- Log.d(TAG, "No other users found. AccountRemovalWorker will restart the app.")
+ Log.d(TAG, "No other users found. Opening ServerSelectionActivity")
+ val intent = Intent(context, ServerSelectionActivity::class.java)
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ startActivity(intent)
}
}
-
- // TODO: show negative button again when conductor is removed
- // .setNegativeButton(R.string.nc_settings_reauthorize) { _, _ ->
- // // router.pushController(
- // // RouterTransaction.with(
- // // WebViewLoginController(currentUser!!.baseUrl, true)
- // // )
- // // .pushChangeHandler(VerticalChangeHandler())
- // // .popChangeHandler(VerticalChangeHandler())
- // // )
- // }
+ .setNegativeButton(R.string.nc_settings_reauthorize) { _, _ ->
+ val intent = Intent(context, WebViewLoginActivity::class.java)
+ val bundle = Bundle()
+ bundle.putString(BundleKeys.KEY_BASE_URL, currentUser!!.baseUrl)
+ bundle.putBoolean(BundleKeys.KEY_IS_PASSWORD_UPDATE, true)
+ intent.putExtras(bundle)
+ startActivity(intent)
+ }
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(it.context, dialogBuilder)
val dialog = dialogBuilder.show()
diff --git a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java
index 940d6780d00..a7be6360af9 100644
--- a/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java
+++ b/app/src/main/java/com/nextcloud/talk/jobs/AccountRemovalWorker.java
@@ -211,17 +211,17 @@ private void deleteUser(User user) {
Log.e(TAG, "error while trying to delete user", e);
}
}
- if (userManager.getUsers().blockingGet().isEmpty()) {
- restartApp(getApplicationContext());
- }
+// if (userManager.getUsers().blockingGet().isEmpty()) {
+// restartApp(getApplicationContext());
+// }
}
- public static void restartApp(Context context) {
- PackageManager packageManager = context.getPackageManager();
- Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
- ComponentName componentName = intent.getComponent();
- Intent mainIntent = Intent.makeRestartActivityTask(componentName);
- context.startActivity(mainIntent);
- Runtime.getRuntime().exit(0);
- }
+// public static void restartApp(Context context) {
+// PackageManager packageManager = context.getPackageManager();
+// Intent intent = packageManager.getLaunchIntentForPackage(context.getPackageName());
+// ComponentName componentName = intent.getComponent();
+// Intent mainIntent = Intent.makeRestartActivityTask(componentName);
+// context.startActivity(mainIntent);
+// Runtime.getRuntime().exit(0);
+// }
}
diff --git a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt
index 13417319840..c01e95f24cb 100644
--- a/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt
+++ b/app/src/main/java/com/nextcloud/talk/settings/SettingsActivity.kt
@@ -65,6 +65,7 @@ import com.google.android.material.textfield.TextInputLayout
import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.talk.BuildConfig
import com.nextcloud.talk.R
+import com.nextcloud.talk.account.ServerSelectionActivity
import com.nextcloud.talk.activities.BaseActivity
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.application.NextcloudTalkApplication
@@ -470,11 +471,13 @@ class SettingsActivity : BaseActivity() {
val accountRemovalWork = OneTimeWorkRequest.Builder(AccountRemovalWorker::class.java).build()
WorkManager.getInstance(applicationContext).enqueue(accountRemovalWork)
if (otherUserExists) {
- // TODO: find better solution once Conductor is removed
finish()
startActivity(intent)
} else if (!otherUserExists) {
- Log.d(TAG, "No other users found. AccountRemovalWorker will restart the app.")
+ Log.d(TAG, "No other users found after removing account. Opening ServerSelectionActivity")
+ val intent = Intent(context, ServerSelectionActivity::class.java)
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ startActivity(intent)
}
}
diff --git a/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt b/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt
index 82be2318cea..305c6b1683d 100644
--- a/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt
+++ b/app/src/main/java/com/nextcloud/talk/ui/bottom/sheet/ProfileBottomSheet.kt
@@ -31,8 +31,8 @@ import com.afollestad.materialdialogs.bottomsheets.BottomSheet
import com.nextcloud.talk.R
import com.nextcloud.talk.api.NcApi
import com.nextcloud.talk.chat.ChatActivity
-import com.nextcloud.talk.controllers.bottomsheet.items.BasicListItemWithImage
-import com.nextcloud.talk.controllers.bottomsheet.items.listItemsWithImage
+import com.nextcloud.talk.bottomsheet.items.BasicListItemWithImage
+import com.nextcloud.talk.bottomsheet.items.listItemsWithImage
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.models.json.conversations.RoomOverall
import com.nextcloud.talk.models.json.hovercard.HoverCardAction
diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java b/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java
index 1e2c37cf61e..4dfb482bba6 100644
--- a/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java
+++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/ChooseAccountDialogFragment.java
@@ -35,7 +35,7 @@
import android.view.ViewGroup;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import com.nextcloud.talk.activities.MainActivity;
+import com.nextcloud.talk.account.ServerSelectionActivity;
import com.nextcloud.talk.adapters.items.AdvancedUserItem;
import com.nextcloud.talk.api.NcApi;
import com.nextcloud.talk.application.NextcloudTalkApplication;
@@ -71,7 +71,7 @@
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
-import static com.nextcloud.talk.utils.bundle.BundleKeys.ADD_ACCOUNT;
+import static com.nextcloud.talk.utils.bundle.BundleKeys.ADD_ADDITIONAL_ACCOUNT;
@AutoInjector(NextcloudTalkApplication.class)
public class ChooseAccountDialogFragment extends DialogFragment {
@@ -185,11 +185,9 @@ private void setupListeners(User user) {
// Creating listeners for quick-actions
binding.currentAccount.getRoot().setOnClickListener(v -> dismiss());
-
binding.addAccount.setOnClickListener(v -> {
- // TODO: change this when conductor is removed
- Intent intent = new Intent(getContext(), MainActivity.class);
- intent.putExtra(ADD_ACCOUNT, true);
+ Intent intent = new Intent(getContext(), ServerSelectionActivity.class);
+ intent.putExtra(ADD_ADDITIONAL_ACCOUNT, true);
startActivity(intent);
dismiss();
});
diff --git a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt
index d5b9cae6e5a..63f0afba3f1 100644
--- a/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt
+++ b/app/src/main/java/com/nextcloud/talk/utils/bundle/BundleKeys.kt
@@ -84,6 +84,8 @@ object BundleKeys {
const val KEY_DISMISS_RECORDING_URL = "KEY_DISMISS_RECORDING_URL"
const val KEY_SHARE_RECORDING_TO_CHAT_URL = "KEY_SHARE_RECORDING_TO_CHAT_URL"
const val KEY_GEOCODING_RESULT = "KEY_GEOCODING_RESULT"
- const val ADD_ACCOUNT = "ADD_ACCOUNT" // temp workaround until conductor is removed
+ const val ADD_ADDITIONAL_ACCOUNT = "ADD_ADDITIONAL_ACCOUNT"
const val SAVED_TRANSLATED_MESSAGE = "SAVED_TRANSLATED_MESSAGE"
+ const val KEY_IS_PASSWORD_UPDATE = "KEY_IS_PASSWORD_UPDATE"
+ const val KEY_PASSWORD = "KEY_PASSWORD"
}
diff --git a/app/src/main/res/layout/controller_account_verification.xml b/app/src/main/res/layout/activity_account_verification.xml
similarity index 100%
rename from app/src/main/res/layout/controller_account_verification.xml
rename to app/src/main/res/layout/activity_account_verification.xml
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 97c8575c02b..44c2ed4ba90 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -40,8 +40,6 @@
android:windowContentOverlay="@null"
app:elevation="0dp">
-
-
-
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/controller_server_selection.xml b/app/src/main/res/layout/activity_server_selection.xml
similarity index 100%
rename from app/src/main/res/layout/controller_server_selection.xml
rename to app/src/main/res/layout/activity_server_selection.xml
diff --git a/app/src/main/res/layout/controller_web_view_login.xml b/app/src/main/res/layout/activity_web_view_login.xml
similarity index 100%
rename from app/src/main/res/layout/controller_web_view_login.xml
rename to app/src/main/res/layout/activity_web_view_login.xml
diff --git a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt
index 72b42a9f164..8bf9adda9d5 100644
--- a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt
+++ b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt
@@ -97,7 +97,7 @@ class BundleKeysTest {
assertEquals("KEY_DISMISS_RECORDING_URL", BundleKeys.KEY_DISMISS_RECORDING_URL)
assertEquals("KEY_SHARE_RECORDING_TO_CHAT_URL", BundleKeys.KEY_SHARE_RECORDING_TO_CHAT_URL)
assertEquals("KEY_GEOCODING_RESULT", BundleKeys.KEY_GEOCODING_RESULT)
- assertEquals("ADD_ACCOUNT", BundleKeys.ADD_ACCOUNT)
+ assertEquals("ADD_ADDITIONAL_ACCOUNT", BundleKeys.ADD_ADDITIONAL_ACCOUNT)
assertEquals("SAVED_TRANSLATED_MESSAGE", BundleKeys.SAVED_TRANSLATED_MESSAGE)
}
}