mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 15:15:51 +03:00
Merge pull request #13513 from nextcloud/bugfix/unify-drawer-menu-item-handling
BugFix - Unify Drawer Menu Item Handling
This commit is contained in:
commit
af3b19d947
12 changed files with 157 additions and 153 deletions
|
@ -36,12 +36,10 @@ import java.lang.ref.WeakReference
|
|||
class ComposeActivity : DrawerActivity() {
|
||||
|
||||
lateinit var binding: ActivityComposeBinding
|
||||
private var menuItemId: Int = R.id.nav_all_files
|
||||
|
||||
companion object {
|
||||
const val DESTINATION = "DESTINATION"
|
||||
const val TITLE = "TITLE"
|
||||
const val MENU_ITEM = "MENU_ITEM"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -51,9 +49,8 @@ class ComposeActivity : DrawerActivity() {
|
|||
|
||||
val destination = intent.getSerializableArgument(DESTINATION, ComposeDestination::class.java)
|
||||
val titleId = intent.getIntExtra(TITLE, R.string.empty)
|
||||
menuItemId = intent.getIntExtra(MENU_ITEM, R.id.nav_all_files)
|
||||
|
||||
setupDrawer(menuItemId)
|
||||
setupDrawer()
|
||||
|
||||
setupToolbarShowOnlyMenuButtonAndTitle(getString(titleId)) {
|
||||
openDrawer()
|
||||
|
@ -69,11 +66,6 @@ class ComposeActivity : DrawerActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setDrawerMenuItemChecked(menuItemId)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.ui.activity.DrawerActivity
|
||||
|
||||
/**
|
||||
* Determines the appropriate menu item ID based on the current ActionBar title.
|
||||
*
|
||||
* This function serves as a workaround solution because not all drawer menu item
|
||||
* navigations extend from DrawerActivity and back button changes content but not the drawer menu item.
|
||||
* As a result, the content and highlighted
|
||||
* menu item may not always match. This function helps maintain consistency between
|
||||
* the displayed content and the highlighted menu item.
|
||||
*
|
||||
* @return The menu item ID corresponding to the current ActionBar title, or null if
|
||||
* the ActionBar is not available.
|
||||
*/
|
||||
fun DrawerActivity.getMenuItemIdFromTitle(): Int? {
|
||||
val actionBar = supportActionBar ?: return null
|
||||
|
||||
return when (actionBar.title.toString()) {
|
||||
getString(R.string.drawer_item_all_files) -> R.id.nav_all_files
|
||||
getString(R.string.drawer_item_personal_files) -> R.id.nav_personal_files
|
||||
getString(R.string.drawer_item_activities) -> R.id.nav_activity
|
||||
getString(R.string.drawer_item_favorites) -> R.id.nav_favorites
|
||||
getString(R.string.drawer_item_gallery) -> R.id.nav_gallery
|
||||
getString(R.string.drawer_item_shared) -> R.id.nav_shared
|
||||
getString(R.string.drawer_item_groupfolders) -> R.id.nav_groupfolders
|
||||
getString(R.string.drawer_item_on_device) -> R.id.nav_on_device
|
||||
getString(R.string.drawer_item_recently_modified) -> R.id.nav_recently_modified
|
||||
getString(R.string.drawer_item_notifications) -> R.id.nav_notifications
|
||||
getString(R.string.drawer_item_assistant) -> R.id.nav_assistant
|
||||
getString(R.string.drawer_item_uploads_list) -> R.id.nav_uploads
|
||||
getString(R.string.drawer_item_trashbin) -> R.id.nav_trashbin
|
||||
else -> {
|
||||
if (MainApp.isOnlyPersonFiles()) {
|
||||
R.id.nav_personal_files
|
||||
} else if (MainApp.isOnlyOnDevice()) {
|
||||
R.id.nav_on_device
|
||||
} else {
|
||||
DrawerActivity.menuItemId
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,7 +29,6 @@ import com.owncloud.android.ui.interfaces.ActivityListInterface;
|
|||
import com.owncloud.android.ui.preview.PreviewImageActivity;
|
||||
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -59,7 +58,6 @@ public class ActivitiesActivity extends DrawerActivity implements ActivityListIn
|
|||
@Inject ActivitiesRepository activitiesRepository;
|
||||
@Inject FilesRepository filesRepository;
|
||||
@Inject ClientFactory clientFactory;
|
||||
@Inject ViewThemeUtils viewThemeUtils;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -77,7 +75,7 @@ public class ActivitiesActivity extends DrawerActivity implements ActivityListIn
|
|||
viewThemeUtils.androidx.themeSwipeRefreshLayout(binding.swipeContainingList);
|
||||
|
||||
// setup drawer
|
||||
setupDrawer(R.id.nav_activity);
|
||||
setupDrawer();
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_activities));
|
||||
|
||||
binding.swipeContainingList.setOnRefreshListener(() -> {
|
||||
|
@ -153,11 +151,7 @@ public class ActivitiesActivity extends DrawerActivity implements ActivityListIn
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
actionListener.onResume();
|
||||
|
||||
setDrawerMenuItemChecked(R.id.nav_activity);
|
||||
|
||||
setupContent();
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ open class CommunityActivity : DrawerActivity() {
|
|||
|
||||
setupToolbar()
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_community))
|
||||
setupDrawer(R.id.nav_community)
|
||||
setupDrawer()
|
||||
binding.communityReleaseCandidateText.movementMethod = LinkMovementMethod.getInstance()
|
||||
setupContributeForumView()
|
||||
setupContributeTranslationView()
|
||||
|
@ -125,9 +125,4 @@ open class CommunityActivity : DrawerActivity() {
|
|||
}
|
||||
return retval
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setDrawerMenuItemChecked(R.id.nav_community)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,6 +124,8 @@ import androidx.drawerlayout.widget.DrawerLayout;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import hct.Hct;
|
||||
|
||||
import static com.nextcloud.utils.extensions.DrawerActivityExtensionsKt.getMenuItemIdFromTitle;
|
||||
|
||||
/**
|
||||
* Base class to handle setup of the drawer implementation including user switching and avatar fetching and fallback
|
||||
* generation.
|
||||
|
@ -133,7 +135,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
|
||||
private static final String TAG = DrawerActivity.class.getSimpleName();
|
||||
private static final String KEY_IS_ACCOUNT_CHOOSER_ACTIVE = "IS_ACCOUNT_CHOOSER_ACTIVE";
|
||||
private static final String KEY_CHECKED_MENU_ITEM = "CHECKED_MENU_ITEM";
|
||||
private static final int ACTION_MANAGE_ACCOUNTS = 101;
|
||||
private static final int MENU_ORDER_EXTERNAL_LINKS = 3;
|
||||
private static final int MENU_ITEM_EXTERNAL_LINK = 111;
|
||||
|
@ -168,7 +169,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
/**
|
||||
* Id of the checked menu item.
|
||||
*/
|
||||
private int mCheckedMenuItem = Menu.NONE;
|
||||
public static int menuItemId = Menu.NONE;
|
||||
|
||||
/**
|
||||
* container layout of the quota view.
|
||||
|
@ -200,17 +201,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
@Inject
|
||||
ClientFactory clientFactory;
|
||||
|
||||
/**
|
||||
* Initializes the drawer, its content and highlights the menu item with the given id. This method needs to be
|
||||
* called after the content view has been set.
|
||||
*
|
||||
* @param menuItemId the menu item to be checked/highlighted
|
||||
*/
|
||||
protected void setupDrawer(int menuItemId) {
|
||||
setupDrawer();
|
||||
setDrawerMenuItemChecked(menuItemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the drawer and its content. This method needs to be called after the content view has been set.
|
||||
*/
|
||||
|
@ -241,6 +231,20 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
*/
|
||||
private void setupDrawerToggle() {
|
||||
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
|
||||
private boolean isMenuItemChecked = false;
|
||||
|
||||
@Override
|
||||
public void onDrawerSlide(View drawerView, float slideOffset) {
|
||||
super.onDrawerSlide(drawerView, slideOffset);
|
||||
if (slideOffset > 0 && !isMenuItemChecked) {
|
||||
Integer menuItemIdFromTitle = getMenuItemIdFromTitle(DrawerActivity.this);
|
||||
if (menuItemIdFromTitle != null && menuItemIdFromTitle != menuItemId) {
|
||||
menuItemId = menuItemIdFromTitle;
|
||||
}
|
||||
setDrawerMenuItemChecked();
|
||||
isMenuItemChecked = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when a drawer has settled in a completely closed state. */
|
||||
public void onDrawerClosed(View view) {
|
||||
|
@ -253,6 +257,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
pendingRunnable = null;
|
||||
}
|
||||
|
||||
isMenuItemChecked = false;
|
||||
closeDrawer();
|
||||
}
|
||||
|
||||
|
@ -272,8 +277,10 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
R.drawable.ic_arrow_back,
|
||||
null);
|
||||
|
||||
if (backArrow != null) {
|
||||
viewThemeUtils.platform.tintToolbarArrowDrawable(this, mDrawerToggle, backArrow);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* setup quota elements of the drawer.
|
||||
|
@ -364,7 +371,10 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
notesView.setOnClickListener(v -> openAppOrStore("it.niedermann.owncloud.notes"));
|
||||
talkView.setOnClickListener(v -> openAppOrStore("com.nextcloud.talk2"));
|
||||
moreView.setOnClickListener(v -> openAppStore("Nextcloud", true));
|
||||
assistantView.setOnClickListener(v -> startComposeActivity(ComposeDestination.AssistantScreen, R.string.assistant_screen_top_bar_title, -1));
|
||||
assistantView.setOnClickListener(v -> {
|
||||
DrawerActivity.menuItemId = Menu.NONE;
|
||||
startComposeActivity(ComposeDestination.AssistantScreen, R.string.assistant_screen_top_bar_title);
|
||||
});
|
||||
if (getCapabilities() != null && getCapabilities().getAssistant().isTrue()) {
|
||||
assistantView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -487,9 +497,9 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
}
|
||||
|
||||
private void onNavigationItemClicked(final MenuItem menuItem) {
|
||||
setDrawerMenuItemChecked(menuItem.getItemId());
|
||||
|
||||
int itemId = menuItem.getItemId();
|
||||
menuItemId = itemId;
|
||||
setDrawerMenuItemChecked();
|
||||
|
||||
if (itemId == R.id.nav_all_files || itemId == R.id.nav_personal_files) {
|
||||
if (this instanceof FileDisplayActivity &&
|
||||
|
@ -511,7 +521,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
}
|
||||
|
||||
intent.setAction(FileDisplayActivity.ALL_FILES);
|
||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
@ -537,7 +546,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
} else if (itemId == R.id.nav_community) {
|
||||
startActivity(CommunityActivity.class);
|
||||
} else if (itemId == R.id.nav_logout) {
|
||||
mCheckedMenuItem = -1;
|
||||
menuItemId = Menu.NONE;
|
||||
MenuItem isNewMenuItemChecked = menuItem.setChecked(false);
|
||||
Log_OC.d(TAG,"onNavigationItemClicked nav_logout setChecked " + isNewMenuItemChecked);
|
||||
final Optional<User> optionalUser = getUser();
|
||||
|
@ -549,13 +558,12 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
} else if (itemId == R.id.nav_recently_modified) {
|
||||
startRecentlyModifiedSearch(menuItem);
|
||||
} else if (itemId == R.id.nav_assistant) {
|
||||
startComposeActivity(ComposeDestination.AssistantScreen, R.string.assistant_screen_top_bar_title, itemId);
|
||||
startComposeActivity(ComposeDestination.AssistantScreen, R.string.assistant_screen_top_bar_title);
|
||||
} else if (itemId == R.id.nav_groupfolders) {
|
||||
MainApp.showOnlyFilesOnDevice(false);
|
||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.setAction(FileDisplayActivity.LIST_GROUPFOLDERS);
|
||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
|
||||
startActivity(intent);
|
||||
} else {
|
||||
if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK &&
|
||||
|
@ -568,11 +576,10 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void startComposeActivity(ComposeDestination destination, int titleId, int menuItemId) {
|
||||
private void startComposeActivity(ComposeDestination destination, int titleId) {
|
||||
Intent composeActivity = new Intent(getApplicationContext(), ComposeActivity.class);
|
||||
composeActivity.putExtra(ComposeActivity.DESTINATION, destination);
|
||||
composeActivity.putExtra(ComposeActivity.TITLE, titleId);
|
||||
composeActivity.putExtra(ComposeActivity.MENU_ITEM, menuItemId);
|
||||
startActivity(composeActivity);
|
||||
}
|
||||
|
||||
|
@ -644,6 +651,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
}
|
||||
|
||||
private void launchActivityForSearch(SearchEvent searchEvent, int menuItemId) {
|
||||
DrawerActivity.menuItemId = menuItemId;
|
||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
|
@ -653,7 +661,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
|
||||
intent.setAction(Intent.ACTION_SEARCH);
|
||||
intent.putExtra(OCFileListFragment.SEARCH_EVENT, searchEvent);
|
||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
@ -681,7 +688,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, link.getName());
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, link.getUrl());
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, true);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, menuItem.getItemId());
|
||||
startActivity(externalWebViewIntent);
|
||||
}
|
||||
}
|
||||
|
@ -815,7 +821,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
}
|
||||
}
|
||||
|
||||
mCheckedMenuItem = Menu.NONE;
|
||||
menuItemId = Menu.NONE;
|
||||
}
|
||||
|
||||
private void updateQuotaLink() {
|
||||
|
@ -836,7 +842,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, firstQuota.getName());
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, firstQuota.getUrl());
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, true);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, -1);
|
||||
menuItemId = Menu.NONE;
|
||||
startActivity(externalWebViewIntent);
|
||||
});
|
||||
|
||||
|
@ -879,16 +885,27 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
/**
|
||||
* checks/highlights the provided menu item if the drawer has been initialized and the menu item exists.
|
||||
*
|
||||
* @param menuItemId the menu item to be highlighted
|
||||
*/
|
||||
protected void setDrawerMenuItemChecked(int menuItemId) {
|
||||
if (mNavigationView != null && mNavigationView.getMenu().findItem(menuItemId) != null) {
|
||||
viewThemeUtils.platform.colorNavigationView(mNavigationView);
|
||||
mCheckedMenuItem = menuItemId;
|
||||
mNavigationView.getMenu().findItem(menuItemId).setChecked(true);
|
||||
} else {
|
||||
Log_OC.w(TAG, "setDrawerMenuItemChecked has been called with invalid menu-item-ID");
|
||||
public void setDrawerMenuItemChecked() {
|
||||
if (mNavigationView == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
MenuItem menuItem = mNavigationView.getMenu().findItem(menuItemId);
|
||||
|
||||
if (menuItem == null) {
|
||||
Log_OC.w(TAG, "setDrawerMenuItemChecked has been called with invalid menu-item-ID");
|
||||
return;
|
||||
}
|
||||
|
||||
if (menuItem.isChecked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Log_OC.d(TAG, "New menu item is: " + menuItemId);
|
||||
|
||||
viewThemeUtils.platform.colorNavigationView(mNavigationView);
|
||||
menuItem.setChecked(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -988,8 +1005,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
target,
|
||||
R.drawable.ic_link);
|
||||
}
|
||||
|
||||
setDrawerMenuItemChecked(mCheckedMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1008,10 +1023,8 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
mIsAccountChooserActive = savedInstanceState.getBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, false);
|
||||
mCheckedMenuItem = savedInstanceState.getInt(KEY_CHECKED_MENU_ITEM, Menu.NONE);
|
||||
}
|
||||
|
||||
externalLinksProvider = new ExternalLinksProvider(getContentResolver());
|
||||
|
@ -1021,22 +1034,14 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
@Override
|
||||
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
||||
outState.putBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, mIsAccountChooserActive);
|
||||
outState.putInt(KEY_CHECKED_MENU_ITEM, mCheckedMenuItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
|
||||
mIsAccountChooserActive = savedInstanceState.getBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, false);
|
||||
mCheckedMenuItem = savedInstanceState.getInt(KEY_CHECKED_MENU_ITEM, Menu.NONE);
|
||||
|
||||
// check/highlight the menu item if present
|
||||
if (mCheckedMenuItem > Menu.NONE || mCheckedMenuItem < Menu.NONE) {
|
||||
setDrawerMenuItemChecked(mCheckedMenuItem);
|
||||
}
|
||||
setDrawerMenuItemChecked();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1053,10 +1058,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
updateQuotaLink();
|
||||
}
|
||||
|
||||
public int getCheckedMenuItem() {
|
||||
return mCheckedMenuItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
@ -1080,12 +1081,6 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
setDrawerMenuItemChecked(mCheckedMenuItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
|
|
@ -44,14 +44,12 @@ public class ExternalSiteWebView extends FileActivity {
|
|||
public static final String EXTRA_URL = "URL";
|
||||
public static final String EXTRA_SHOW_SIDEBAR = "SHOW_SIDEBAR";
|
||||
public static final String EXTRA_SHOW_TOOLBAR = "SHOW_TOOLBAR";
|
||||
public static final String EXTRA_MENU_ITEM_ID = "MENU_ITEM_ID";
|
||||
public static final String EXTRA_TEMPLATE = "TEMPLATE";
|
||||
|
||||
private static final String TAG = ExternalSiteWebView.class.getSimpleName();
|
||||
|
||||
protected boolean showToolbar = true;
|
||||
private ExternalsiteWebviewBinding binding;
|
||||
private int menuItemId;
|
||||
private boolean showSidebar;
|
||||
String url;
|
||||
|
||||
|
@ -67,7 +65,6 @@ public class ExternalSiteWebView extends FileActivity {
|
|||
showToolbar = extras.getBoolean(EXTRA_SHOW_TOOLBAR);
|
||||
}
|
||||
|
||||
menuItemId = extras.getInt(EXTRA_MENU_ITEM_ID);
|
||||
showSidebar = extras.getBoolean(EXTRA_SHOW_SIDEBAR);
|
||||
|
||||
// show progress
|
||||
|
@ -107,8 +104,7 @@ public class ExternalSiteWebView extends FileActivity {
|
|||
}
|
||||
}
|
||||
|
||||
// setup drawer
|
||||
setupDrawer(menuItemId);
|
||||
setupDrawer();
|
||||
|
||||
if (!showSidebar) {
|
||||
setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||
|
@ -235,12 +231,6 @@ public class ExternalSiteWebView extends FileActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
setDrawerMenuItemChecked(menuItemId);
|
||||
}
|
||||
|
||||
protected WebView getWebView() {
|
||||
return binding.webView;
|
||||
}
|
||||
|
|
|
@ -196,8 +196,6 @@ public class FileDisplayActivity extends FileActivity
|
|||
|
||||
public static final String ACTION_DETAILS = "com.owncloud.android.ui.activity.action.DETAILS";
|
||||
|
||||
public static final String DRAWER_MENU_ID = "DRAWER_MENU_ID";
|
||||
|
||||
public static final int REQUEST_CODE__SELECT_CONTENT_FROM_APPS = REQUEST_CODE__LAST_SHARED + 1;
|
||||
public static final int REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM = REQUEST_CODE__LAST_SHARED + 2;
|
||||
public static final int REQUEST_CODE__MOVE_OR_COPY_FILES = REQUEST_CODE__LAST_SHARED + 3;
|
||||
|
@ -231,7 +229,6 @@ public class FileDisplayActivity extends FileActivity
|
|||
private SearchView searchView;
|
||||
private PlayerServiceConnection mPlayerConnection;
|
||||
private Optional<User> lastDisplayedUser = Optional.empty();
|
||||
private int menuItemId = -1;
|
||||
|
||||
@Inject AppPreferences preferences;
|
||||
|
||||
|
@ -382,11 +379,7 @@ public class FileDisplayActivity extends FileActivity
|
|||
|
||||
if (IntentExtensionsKt.getParcelableArgument(getIntent(), OCFileListFragment.SEARCH_EVENT, SearchEvent.class) != null) {
|
||||
switchToSearchFragment(savedInstanceState);
|
||||
|
||||
int menuId = getIntent().getIntExtra(DRAWER_MENU_ID, -1);
|
||||
if (menuId != -1) {
|
||||
setupDrawer(menuId);
|
||||
}
|
||||
setupDrawer();
|
||||
} else {
|
||||
createMinFragments(savedInstanceState);
|
||||
syncAndUpdateFolder(true);
|
||||
|
@ -561,13 +554,13 @@ public class FileDisplayActivity extends FileActivity
|
|||
}
|
||||
} else if (ALL_FILES.equals(intent.getAction())) {
|
||||
Log_OC.d(this, "Switch to oc file fragment");
|
||||
|
||||
DrawerActivity.menuItemId = R.id.nav_all_files;
|
||||
setLeftFragment(new OCFileListFragment());
|
||||
getSupportFragmentManager().executePendingTransactions();
|
||||
browseToRoot();
|
||||
} else if (LIST_GROUPFOLDERS.equals(intent.getAction())) {
|
||||
Log_OC.d(this, "Switch to list groupfolders fragment");
|
||||
|
||||
DrawerActivity.menuItemId = R.id.nav_groupfolders;
|
||||
setLeftFragment(new GroupfolderListFragment());
|
||||
getSupportFragmentManager().executePendingTransactions();
|
||||
} else {
|
||||
|
@ -1147,10 +1140,7 @@ public class FileDisplayActivity extends FileActivity
|
|||
mDownloadFinishReceiver = new DownloadFinishReceiver();
|
||||
localBroadcastManager.registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
|
||||
|
||||
// setup drawer
|
||||
menuItemId = getIntent().getIntExtra(FileDisplayActivity.DRAWER_MENU_ID, -1);
|
||||
|
||||
if (menuItemId == -1) {
|
||||
if (menuItemId == Menu.NONE) {
|
||||
setDrawerAllFiles();
|
||||
} else {
|
||||
if (menuItemId == R.id.nav_all_files || menuItemId == R.id.nav_personal_files) {
|
||||
|
@ -1158,7 +1148,6 @@ public class FileDisplayActivity extends FileActivity
|
|||
} else {
|
||||
setupToolbar();
|
||||
}
|
||||
setDrawerMenuItemChecked(menuItemId);
|
||||
}
|
||||
|
||||
if (ocFileListFragment instanceof GalleryFragment) {
|
||||
|
@ -1169,21 +1158,20 @@ public class FileDisplayActivity extends FileActivity
|
|||
|
||||
Log_OC.v(TAG, "onResume() end");
|
||||
}
|
||||
|
||||
private void setDrawerAllFiles() {
|
||||
if (MainApp.isOnlyPersonFiles()) {
|
||||
setDrawerMenuItemChecked(R.id.nav_personal_files);
|
||||
setupHomeSearchToolbarWithSortAndListButtons();
|
||||
menuItemId = R.id.nav_personal_files;
|
||||
} else if (MainApp.isOnlyOnDevice()) {
|
||||
setDrawerMenuItemChecked(R.id.nav_on_device);
|
||||
setupToolbar();
|
||||
} else {
|
||||
int lastMenuItem = getCheckedMenuItem();
|
||||
if (lastMenuItem == Menu.NONE) {
|
||||
lastMenuItem = R.id.nav_all_files;
|
||||
menuItemId = R.id.nav_on_device;
|
||||
} else if (menuItemId == Menu.NONE) {
|
||||
menuItemId = R.id.nav_all_files;
|
||||
}
|
||||
|
||||
setDrawerMenuItemChecked(lastMenuItem);
|
||||
setDrawerMenuItemChecked();
|
||||
|
||||
if (MainApp.isOnlyOnDevice()) {
|
||||
setupToolbar();
|
||||
} else {
|
||||
setupHomeSearchToolbarWithSortAndListButtons();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View {
|
|||
|
||||
setupToolbar()
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_notifications))
|
||||
setupDrawer(R.id.nav_notifications)
|
||||
setupDrawer()
|
||||
|
||||
if (optionalUser?.isPresent == false) {
|
||||
showError()
|
||||
|
@ -303,11 +303,6 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View {
|
|||
binding.emptyList.emptyListIcon.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
setDrawerMenuItemChecked(R.id.nav_notifications)
|
||||
}
|
||||
|
||||
override fun onRemovedNotification(isSuccess: Boolean) {
|
||||
if (!isSuccess) {
|
||||
DisplayUtils.showSnackMessage(this, getString(R.string.remove_notification_failed))
|
||||
|
|
|
@ -21,6 +21,7 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
|
@ -284,7 +285,7 @@ public class SettingsActivity extends PreferenceActivity
|
|||
getResources().getString(R.string.privacy));
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_URL, privacyUrl.toString());
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, -1);
|
||||
DrawerActivity.menuItemId = Menu.NONE;
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
|
@ -314,6 +315,14 @@ public class SettingsActivity extends PreferenceActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
Intent i = new Intent(this, FileDisplayActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
i.setAction(FileDisplayActivity.ALL_FILES);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
private void setupSyncCategory() {
|
||||
final PreferenceCategory preferenceCategorySync = (PreferenceCategory) findPreference("sync");
|
||||
viewThemeUtils.files.themePreferenceCategory(preferenceCategorySync);
|
||||
|
@ -876,20 +885,22 @@ public class SettingsActivity extends PreferenceActivity
|
|||
|
||||
private void setupActionBar() {
|
||||
ActionBar actionBar = getDelegate().getSupportActionBar();
|
||||
if (actionBar == null) return;
|
||||
|
||||
if (actionBar != null) {
|
||||
viewThemeUtils.platform.themeStatusBar(this);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
if (this.getResources() != null) {
|
||||
|
||||
if (getResources() == null) return;
|
||||
Drawable menuIcon = ResourcesCompat.getDrawable(getResources(),
|
||||
R.drawable.ic_arrow_back,
|
||||
null);
|
||||
|
||||
if (menuIcon == null) return;
|
||||
viewThemeUtils.androidx.themeActionBar(this,
|
||||
actionBar,
|
||||
getString(R.string.actionbar_settings),
|
||||
ResourcesCompat.getDrawable(this.getResources(),
|
||||
R.drawable.ic_arrow_back,
|
||||
null));
|
||||
}
|
||||
}
|
||||
menuIcon);
|
||||
}
|
||||
|
||||
private void launchDavDroidLogin() {
|
||||
|
@ -1107,7 +1118,7 @@ public class SettingsActivity extends PreferenceActivity
|
|||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, link.getName());
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, link.getUrl());
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, link.getId());
|
||||
DrawerActivity.menuItemId = link.getId();
|
||||
startActivity(externalWebViewIntent);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -131,7 +131,7 @@ public class UploadListActivity extends FileActivity {
|
|||
updateActionBarTitleAndHomeButtonByString(getString(R.string.uploads_view_title));
|
||||
|
||||
// setup drawer
|
||||
setupDrawer(R.id.nav_uploads);
|
||||
setupDrawer();
|
||||
|
||||
setupContent();
|
||||
observeWorkerState();
|
||||
|
@ -232,8 +232,6 @@ public class UploadListActivity extends FileActivity {
|
|||
Log_OC.v(TAG, "onResume() start");
|
||||
super.onResume();
|
||||
|
||||
setDrawerMenuItemChecked(R.id.nav_uploads);
|
||||
|
||||
// Listen for upload messages
|
||||
uploadMessagesReceiver = new UploadMessagesReceiver();
|
||||
IntentFilter uploadIntentFilter = new IntentFilter();
|
||||
|
|
|
@ -93,8 +93,8 @@ import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
|
|||
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment;
|
||||
import com.owncloud.android.ui.events.ChangeMenuEvent;
|
||||
import com.owncloud.android.ui.events.CommentsEvent;
|
||||
import com.owncloud.android.ui.events.EncryptionEvent;
|
||||
|
@ -279,7 +279,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
super.onResume();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -109,7 +109,7 @@ class TrashbinActivity :
|
|||
View.GONE
|
||||
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.trashbin_activity_title))
|
||||
setupDrawer(R.id.nav_trashbin)
|
||||
setupDrawer()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
|
@ -119,12 +119,6 @@ class TrashbinActivity :
|
|||
setupContent()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
setDrawerMenuItemChecked(R.id.nav_trashbin)
|
||||
}
|
||||
|
||||
private fun setupContent() {
|
||||
val recyclerView = binding.list
|
||||
recyclerView.setEmptyView(binding.emptyList.emptyListView)
|
||||
|
|
Loading…
Reference in a new issue