Skip to content

Commit

Permalink
WIP replace controllers with activities
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Nov 17, 2023
1 parent 7109490 commit 35ca680
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 397 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/com/nextcloud/talk/activities/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ 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.ServerSelectionActivity
import com.nextcloud.talk.controllers.WebViewLoginActivity
import com.nextcloud.talk.controllers.base.providers.ActionBarProvider
import com.nextcloud.talk.conversationlist.ConversationsListActivity
import com.nextcloud.talk.data.user.model.User
Expand Down Expand Up @@ -132,14 +132,14 @@ class MainActivity : BaseActivity(), ActionBarProvider {
if (!TextUtils.isEmpty(resources.getString(R.string.weblogin_url))) {
router!!.pushController(
RouterTransaction.with(
WebViewLoginController(resources.getString(R.string.weblogin_url), false)
WebViewLoginActivity(resources.getString(R.string.weblogin_url), false)
)
.pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())
)
} else {
router!!.setRoot(
RouterTransaction.with(ServerSelectionController())
RouterTransaction.with(ServerSelectionActivity())
.pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())
)
Expand Down Expand Up @@ -180,7 +180,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {

fun addAccount() {
router!!.pushController(
RouterTransaction.with(ServerSelectionController())
RouterTransaction.with(ServerSelectionActivity())
.pushChangeHandler(VerticalChangeHandler())
.popChangeHandler(VerticalChangeHandler())
)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,31 @@
package com.nextcloud.talk.controllers

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.conversationlist.ConversationsListActivity
import com.nextcloud.talk.data.user.model.User
import com.nextcloud.talk.databinding.ActivityWebViewLoginBinding
import com.nextcloud.talk.databinding.ControllerGenericRvBinding
import com.nextcloud.talk.models.ImportAccount
import com.nextcloud.talk.models.json.participants.Participant
import com.nextcloud.talk.users.UserManager
import com.nextcloud.talk.utils.AccountUtils.findAvailableAccountsOnDevice
import com.nextcloud.talk.utils.AccountUtils.getInformationFromAccount
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_IS_ACCOUNT_IMPORT
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_TOKEN
Expand All @@ -58,12 +62,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 SwitchAccountController : BaseActivity() {
private lateinit var binding: ControllerGenericRvBinding

@Inject
lateinit var userManager: UserManager
Expand All @@ -89,19 +89,32 @@ 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
}
}
Expand Down Expand Up @@ -166,11 +179,11 @@ class SwitchAccountController(args: Bundle? = null) :
}

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?) {
Expand All @@ -180,11 +193,15 @@ 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
Expand Down
Loading

0 comments on commit 35ca680

Please sign in to comment.