-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added session expire popup on task detail screen (#289)
- Loading branch information
1 parent
af7a00c
commit c067365
Showing
8 changed files
with
109 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
app/src/main/java/com/alfresco/content/app/activity/TaskViewerActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.alfresco.content.app.activity | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.navigation.fragment.NavHostFragment | ||
import com.airbnb.mvrx.InternalMavericksApi | ||
import com.airbnb.mvrx.MavericksView | ||
import com.airbnb.mvrx.withState | ||
import com.alfresco.auth.activity.LoginViewModel | ||
import com.alfresco.content.actions.Action | ||
import com.alfresco.content.activityViewModel | ||
import com.alfresco.content.browse.R | ||
import com.alfresco.content.browse.databinding.ActivityTaskViewerBinding | ||
import com.alfresco.content.common.BaseActivity | ||
import com.alfresco.content.session.SessionManager | ||
import com.alfresco.content.viewer.ViewerArgs | ||
import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
import java.lang.ref.WeakReference | ||
|
||
/** | ||
* Marked as TaskViewerActivity class | ||
*/ | ||
class TaskViewerActivity : BaseActivity(), MavericksView { | ||
|
||
private lateinit var binding: ActivityTaskViewerBinding | ||
|
||
@OptIn(InternalMavericksApi::class) | ||
private val viewModel: MainActivityViewModel by activityViewModel() | ||
private var signedOutDialog = WeakReference<AlertDialog>(null) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityTaskViewerBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
configureNav() | ||
setupActionToasts() | ||
} | ||
|
||
private fun configureNav() { | ||
val navHostFragment = | ||
supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment | ||
val navController = navHostFragment.navController | ||
val inflater = navController.navInflater | ||
val graph = inflater.inflate(R.navigation.nav_task_paths) | ||
navController.setGraph(graph, intent.extras) | ||
} | ||
|
||
override fun invalidate() = withState(viewModel) { state -> | ||
if (state.requiresReLogin) { | ||
if (state.isOnline) { | ||
showSignedOutPrompt() | ||
} | ||
} | ||
} | ||
|
||
private fun showSignedOutPrompt() { | ||
val oldDialog = signedOutDialog.get() | ||
if (oldDialog != null && oldDialog.isShowing) return | ||
val dialog = MaterialAlertDialogBuilder(this).setTitle(resources.getString(com.alfresco.content.app.R.string.auth_signed_out_title)) | ||
.setMessage(resources.getString(com.alfresco.content.app.R.string.auth_signed_out_subtitle)) | ||
.setNegativeButton(resources.getString(com.alfresco.content.app.R.string.sign_out_confirmation_negative), null) | ||
.setPositiveButton(resources.getString(com.alfresco.content.app.R.string.auth_basic_sign_in_button)) { _, _ -> | ||
navigateToReLogin() | ||
}.show() | ||
signedOutDialog = WeakReference(dialog) | ||
} | ||
|
||
private fun navigateToReLogin() { | ||
val i = Intent(this, LoginActivity::class.java) | ||
val acc = SessionManager.requireSession.account | ||
i.putExtra(LoginViewModel.EXTRA_IS_EXTENSION, false) | ||
i.putExtra(LoginViewModel.EXTRA_ENDPOINT, acc.serverUrl) | ||
i.putExtra(LoginViewModel.EXTRA_AUTH_TYPE, acc.authType) | ||
i.putExtra(LoginViewModel.EXTRA_AUTH_CONFIG, acc.authConfig) | ||
i.putExtra(LoginViewModel.EXTRA_AUTH_STATE, acc.authState) | ||
i.putExtra(ViewerArgs.ID_KEY, intent.extras?.getString(ViewerArgs.ID_KEY, "")) | ||
i.putExtra(ViewerArgs.MODE_KEY, intent.extras?.getString(ViewerArgs.MODE_KEY, "")) | ||
i.putExtra(ViewerArgs.KEY_FOLDER, intent.extras?.getBoolean(ViewerArgs.KEY_FOLDER, false)) | ||
startActivity(i) | ||
} | ||
|
||
private fun setupActionToasts() = Action.showActionToasts( | ||
lifecycleScope, | ||
binding.root, | ||
binding.bottomView, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
browse/src/main/kotlin/com/alfresco/content/browse/tasks/TaskViewerActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
common/src/main/kotlin/com/alfresco/content/common/BaseActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.alfresco.content.common | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
|
||
open class BaseActivity : AppCompatActivity() |