mirror of
https://github.com/nextcloud/android.git
synced 2024-12-21 08:24:08 +03:00
fix back button behaviour
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
84ec717a57
commit
a501c81bae
2 changed files with 18 additions and 9 deletions
|
@ -10,6 +10,7 @@ package com.nextcloud.ui.composeActivity
|
|||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
|
@ -55,6 +56,8 @@ class ComposeActivity : DrawerActivity() {
|
|||
openDrawer()
|
||||
}
|
||||
|
||||
handleOnBackPressed()
|
||||
|
||||
binding.composeView.setContent {
|
||||
MaterialTheme(
|
||||
colorScheme = viewThemeUtils.getColorScheme(this),
|
||||
|
@ -65,6 +68,19 @@ class ComposeActivity : DrawerActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleOnBackPressed() {
|
||||
onBackPressedDispatcher.addCallback(
|
||||
this,
|
||||
onBackPressedCallback
|
||||
)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
|
|
|
@ -255,14 +255,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
@SuppressFBWarnings("RV")
|
||||
private void handleBottomNavigationViewClicks() {
|
||||
bottomNavigationView.setOnItemSelectedListener(menuItem -> {
|
||||
int previousMenuItemId = menuItemId;
|
||||
int newMenuItemId = menuItem.getItemId();
|
||||
|
||||
if (previousMenuItemId == newMenuItemId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
menuItemId = newMenuItemId;
|
||||
menuItemId = menuItem.getItemId();
|
||||
|
||||
if (menuItemId == R.id.nav_all_files) {
|
||||
showFiles(false,false);
|
||||
|
@ -271,7 +264,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
}
|
||||
} else if (menuItemId == R.id.nav_favorites) {
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.FAVORITE_SEARCH), menuItemId);
|
||||
} else if (menuItemId == R.id.nav_assistant) {
|
||||
} else if (menuItemId == R.id.nav_assistant && !(this instanceof ComposeActivity)) {
|
||||
startComposeActivity(ComposeDestination.AssistantScreen, R.string.assistant_screen_top_bar_title);
|
||||
} else if (menuItemId == R.id.nav_gallery) {
|
||||
startPhotoSearch(menuItem.getItemId());
|
||||
|
|
Loading…
Reference in a new issue