diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index f95db44aea4d..4a54f266ef04 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -183,6 +183,11 @@ public abstract class DrawerActivity extends ToolbarActivity private TextView mQuotaTextPercentage; private TextView mQuotaTextLink; + private LinearLayout sidebarQuotaView; + private LinearProgressIndicator sidebarQuotaProgressBar; + private TextView sidebarQuotaTextPercentage; + private TextView sidebarQuotaTextLink; + /** * runnable that will be executed after the drawer has been closed. */ @@ -194,6 +199,9 @@ public abstract class DrawerActivity extends ToolbarActivity private BottomNavigationView bottomNavigationView; private NavigationView drawerNavigationView; + private View sidebarMenu; + private NavigationView sidebarNavigationView; + /** * Returns the navigation drawer menu item ID that represents * the current activity. @@ -242,10 +250,18 @@ protected void setupDrawer(int id) { mDrawerLayout = findViewById(R.id.drawer_layout); } + if (sidebarMenu == null) { + sidebarMenu = findViewById(R.id.sidebar_menu); + } + if (drawerNavigationView == null) { drawerNavigationView = findViewById(R.id.nav_view); } + if (sidebarMenu != null && sidebarNavigationView == null) { + sidebarNavigationView = sidebarMenu.findViewById(R.id.sidebar_view); + } + if (drawerNavigationView != null) { viewThemeUtils.files.colorNavigationView(drawerNavigationView); @@ -254,16 +270,23 @@ protected void setupDrawer(int id) { updateHeader(); setupDrawerMenu(drawerNavigationView); - getAndDisplayUserQuota(); setupQuotaElement(); - highlightNavigationViewItem(id); } - setupDrawerToggle(); + if (sidebarNavigationView != null) { + viewThemeUtils.files.colorNavigationView(sidebarNavigationView); + + // Setting up drawer header + mNavigationViewHeader = sidebarNavigationView.getHeaderView(0); + updateHeader(); - if (getSupportActionBar() != null) { - getSupportActionBar().setDisplayHomeAsUpEnabled(true); + setupSidebarMenu(sidebarNavigationView); + setupSidebarQuotaElement(); } + getAndDisplayUserQuota(); + highlightNavigationViewItem(id); + + setupDrawerToggle(); if (bottomNavigationView == null) { bottomNavigationView = findViewById(R.id.bottom_navigation); @@ -275,6 +298,12 @@ protected void setupDrawer(int id) { handleBottomNavigationViewClicks(); highlightNavigationViewItem(id); } + + if (!isDrawerLayout() && mMenuButton != null) { + mMenuButton.setVisibility(View.GONE); + } + + hideOrShowSidebar(); } /** @@ -306,6 +335,15 @@ public void highlightNavigationViewItem(int menuItemId) { } } + if (sidebarNavigationView != null) { + NavigationViewExtensionsKt.unsetAllNavigationItems(sidebarNavigationView); + MenuItem menuItem = sidebarNavigationView.getMenu().findItem(menuItemId); + + if (menuItem != null && !menuItem.isChecked()) { + menuItem.setChecked(true); + } + } + if (bottomNavigationView != null) { NavigationViewExtensionsKt.unsetAllNavigationItems(bottomNavigationView); MenuItem menuItem = bottomNavigationView.getMenu().findItem(menuItemId); @@ -408,6 +446,16 @@ private void setupQuotaElement() { viewThemeUtils.platform.colorViewBackground(mQuotaView); } + private void setupSidebarQuotaElement() { + sidebarQuotaView = (LinearLayout) findSidebarQuotaViewById(R.id.sidebar_quota); + sidebarQuotaProgressBar = (LinearProgressIndicator) findSidebarQuotaViewById(R.id.sidebar_quota_ProgressBar); + sidebarQuotaTextPercentage = (TextView) findSidebarQuotaViewById(R.id.sidebar_quota_percentage); + sidebarQuotaTextLink = (TextView) findSidebarQuotaViewById(R.id.sidebar_quota_link); + viewThemeUtils.material.colorProgressBar(sidebarQuotaProgressBar, ColorRole.PRIMARY); + sidebarQuotaProgressBar.setTrackStopIndicatorSize(0); + viewThemeUtils.platform.colorViewBackground(sidebarQuotaView); + } + public void updateHeader() { final var account = getAccount(); boolean isClientBranded = getResources().getBoolean(R.bool.is_branded_client); @@ -582,6 +630,17 @@ private void setupDrawerMenu(NavigationView navigationView) { filterDrawerMenu(navigationView.getMenu(), account); } + private void setupSidebarMenu(NavigationView navigationView) { + navigationView.setNavigationItemSelectedListener( + menuItem -> { + onNavigationItemClicked(menuItem); + return true; + }); + + User account = accountManager.getUser(); + filterDrawerMenu(navigationView.getMenu(), account); + } + private void filterDrawerMenu(final Menu menu, @NonNull final User user) { final var optionalCapability = getCapabilities(); if (optionalCapability.isPresent()) { @@ -603,6 +662,10 @@ private void filterDrawerMenu(final Menu menu, @NonNull final User user) { private void onNavigationItemClicked(final MenuItem menuItem) { int itemId = menuItem.getItemId(); + if (itemId == getMenuItemId()) { + return; + } + if (itemId == R.id.nav_all_files || itemId == R.id.nav_personal_files) { closeDrawer(); DrawerActivityExtensionsKt.navigateToAllFiles(this,itemId == R.id.nav_personal_files); @@ -889,6 +952,10 @@ protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) { if (mDrawerToggle != null) { mDrawerToggle.setDrawerIndicatorEnabled(chosenFile != null && isRoot(chosenFile)); } + + if (!isDrawerLayout() && getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(!isRoot(chosenFile)); + } } /** @@ -898,9 +965,19 @@ protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) { */ private void showQuota(boolean showQuota) { if (showQuota) { - mQuotaView.setVisibility(View.VISIBLE); + if (mQuotaView != null) { + mQuotaView.setVisibility(View.VISIBLE); + } + if (sidebarQuotaView != null) { + sidebarQuotaView.setVisibility(View.VISIBLE); + } } else { - mQuotaView.setVisibility(View.GONE); + if (mQuotaView != null) { + mQuotaView.setVisibility(View.GONE); + } + if (sidebarQuotaView != null) { + sidebarQuotaView.setVisibility(View.GONE); + } } } @@ -914,25 +991,62 @@ private void showQuota(boolean showQuota) { */ private void setQuotaInformation(long usedSpace, long totalSpace, int relative, long quotaValue) { if (GetUserInfoRemoteOperation.SPACE_UNLIMITED == quotaValue) { - mQuotaTextPercentage.setText(String.format( - getString(R.string.drawer_quota_unlimited), - DisplayUtils.bytesToHumanReadable(usedSpace))); + if (mQuotaTextPercentage != null) { + mQuotaTextPercentage.setText(String.format( + getString(R.string.drawer_quota_unlimited), + DisplayUtils.bytesToHumanReadable(usedSpace))); + } + + if (sidebarQuotaTextPercentage != null) { + sidebarQuotaTextPercentage.setText(String.format( + getString(R.string.drawer_quota_unlimited), + DisplayUtils.bytesToHumanReadable(usedSpace))); + } } else { - mQuotaTextPercentage.setText(String.format( - getString(R.string.drawer_quota), - DisplayUtils.bytesToHumanReadable(usedSpace), - DisplayUtils.bytesToHumanReadable(totalSpace))); + if (mQuotaTextPercentage != null) { + mQuotaTextPercentage.setText(String.format( + getString(R.string.drawer_quota), + DisplayUtils.bytesToHumanReadable(usedSpace), + DisplayUtils.bytesToHumanReadable(totalSpace))); + } + + if (sidebarQuotaTextPercentage != null) { + sidebarQuotaTextPercentage.setText(String.format( + getString(R.string.drawer_quota), + DisplayUtils.bytesToHumanReadable(usedSpace), + DisplayUtils.bytesToHumanReadable(totalSpace))); + } + } + + if (mQuotaProgressBar != null) { + mQuotaProgressBar.setProgress(relative); } - mQuotaProgressBar.setProgress(relative); + if (sidebarQuotaProgressBar != null) { + sidebarQuotaProgressBar.setProgress(relative); + } if (relative < RELATIVE_THRESHOLD_WARNING) { - viewThemeUtils.material.colorProgressBar(mQuotaProgressBar, ColorRole.PRIMARY); + if (mQuotaProgressBar != null) { + viewThemeUtils.material.colorProgressBar(mQuotaProgressBar, ColorRole.PRIMARY); + } + if (sidebarQuotaProgressBar != null) { + viewThemeUtils.material.colorProgressBar(sidebarQuotaProgressBar, ColorRole.PRIMARY); + } } else { - viewThemeUtils.material.colorProgressBar( - mQuotaProgressBar, - getResources().getColor(R.color.infolevel_warning, null) - ); + if (mQuotaProgressBar != null) { + viewThemeUtils.material.colorProgressBar( + mQuotaProgressBar, + getResources().getColor(R.color.infolevel_warning, null) + ); + } + + if (sidebarQuotaProgressBar != null) { + viewThemeUtils.material.colorProgressBar( + sidebarQuotaProgressBar, + getResources().getColor(R.color.infolevel_warning, null) + ); + } } updateQuotaLink(); @@ -940,15 +1054,15 @@ private void setQuotaInformation(long usedSpace, long totalSpace, int relative, } private void updateQuotaLink() { - if (mQuotaTextLink != null) { - if (MDMConfig.INSTANCE.externalSiteSupport(this)) { - List quotas = externalLinksProvider.getExternalLink(ExternalLinkType.QUOTA); + if (MDMConfig.INSTANCE.externalSiteSupport(this)) { + List quotas = externalLinksProvider.getExternalLink(ExternalLinkType.QUOTA); - float density = getResources().getDisplayMetrics().density; - final int size = Math.round(24 * density); + float density = getResources().getDisplayMetrics().density; + final int size = Math.round(24 * density); - if (!quotas.isEmpty()) { - final ExternalLink firstQuota = quotas.get(0); + if (!quotas.isEmpty()) { + final ExternalLink firstQuota = quotas.get(0); + if (mQuotaTextLink != null) { mQuotaTextLink.setText(firstQuota.getName()); mQuotaTextLink.setClickable(true); mQuotaTextLink.setVisibility(View.VISIBLE); @@ -960,18 +1074,51 @@ private void updateQuotaLink() { startActivity(externalWebViewIntent); }); + Target quotaTarget = createQuotaDrawableTarget(size, mQuotaTextLink); + GlideHelper.INSTANCE.loadIntoTarget(this, + accountManager.getCurrentOwnCloudAccount(), + firstQuota.getIconUrl(), + quotaTarget, + R.drawable.ic_link); + } + if (sidebarQuotaTextLink != null) { + sidebarQuotaTextLink.setText(firstQuota.getName()); + sidebarQuotaTextLink.setClickable(true); + sidebarQuotaTextLink.setVisibility(View.VISIBLE); + sidebarQuotaTextLink.setOnClickListener(v -> { + Intent externalWebViewIntent = new Intent(getApplicationContext(), ExternalSiteWebView.class); + externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, firstQuota.getName()); + externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, firstQuota.getUrl()); + externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, true); + startActivity(externalWebViewIntent); + }); + + Target quotaTarget = createQuotaDrawableTarget(size, mQuotaTextLink); GlideHelper.INSTANCE.loadIntoTarget(this, accountManager.getCurrentOwnCloudAccount(), firstQuota.getIconUrl(), quotaTarget, R.drawable.ic_link); - } else { - mQuotaTextLink.setVisibility(View.GONE); } } else { + if (mQuotaTextLink != null) { + mQuotaTextLink.setVisibility(View.GONE); + } + + if (sidebarQuotaTextLink != null) { + sidebarQuotaTextLink.setVisibility(View.GONE); + } + + } + } else { + if (mQuotaTextLink != null) { mQuotaTextLink.setVisibility(View.GONE); } + + if (sidebarQuotaTextLink != null) { + sidebarQuotaTextLink.setVisibility(View.GONE); + } } } @@ -1178,6 +1325,29 @@ public void onConfigurationChanged(@NonNull Configuration newConfig) { if (mDrawerToggle != null) { mDrawerToggle.onConfigurationChanged(newConfig); } + + hideOrShowSidebar(); + } + + private void hideOrShowSidebar() { + if (isDrawerLayout()) { + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + + if (sidebarMenu != null) { + sidebarMenu.setVisibility(View.GONE); + } + } else { + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(false); + } + + if (sidebarMenu != null) { + sidebarMenu.setVisibility(View.VISIBLE); + } + closeDrawer(); + } } public void addOnBackPressedCallback() { @@ -1245,6 +1415,16 @@ private View findQuotaViewById(int id) { } } + private View findSidebarQuotaViewById(int id) { + View v = ((NavigationView) findViewById(R.id.sidebar_view)).getHeaderView(0).findViewById(id); + + if (v != null) { + return v; + } else { + return findViewById(id); + } + } + /** * restart helper method which is called after a changing the current account. */ @@ -1486,4 +1666,8 @@ public boolean isToolbarStyleSearch() { menuItemId == R.id.nav_all_files || menuItemId == R.id.nav_personal_files; } + + protected boolean isDrawerLayout() { + return getResources().getBoolean(R.bool.is_support_drawer); + } } diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt index 05178e85acaa..4ab425dbcfaf 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt @@ -394,6 +394,16 @@ class FileDisplayActivity : } } } + + if (isDrawerLayout) { + mMenuButton.visibility = View.VISIBLE + } else { + if (isRoot(currentDir)) { + mMenuButton.visibility = View.GONE + } else { + mMenuButton.visibility = View.VISIBLE + } + } } override fun onPostCreate(savedInstanceState: Bundle?) { @@ -1059,6 +1069,9 @@ class FileDisplayActivity : private fun exitSelectionMode() { val ocFileListFragment = this.listOfFilesFragment ocFileListFragment?.exitSelectionMode() + + // Update toolbar with current directory + updateActionBarTitleAndHomeButton(currentDir) } private fun requestUploadOfFilesFromFileSystem(data: Intent, resultCode: Int) { @@ -1981,6 +1994,16 @@ class FileDisplayActivity : chosenFile = file // if no file is passed, current file decides } super.updateActionBarTitleAndHomeButton(chosenFile) + + if (isDrawerLayout) { + mMenuButton.visibility = View.VISIBLE + } else { + if (isRoot(currentDir)) { + mMenuButton.visibility = View.GONE + } else { + mMenuButton.visibility = View.VISIBLE + } + } } override fun isDrawerIndicatorAvailable(): Boolean = isRoot(getCurrentDir()) diff --git a/app/src/main/res/layout/activity_compose.xml b/app/src/main/res/layout/activity_compose.xml index f5cda35ea67e..c06524adb1c9 100644 --- a/app/src/main/res/layout/activity_compose.xml +++ b/app/src/main/res/layout/activity_compose.xml @@ -8,35 +8,61 @@ --> + android:focusable="true"> - + android:layout_height="match_parent"> + + + + - + - - - - - + android:orientation="vertical" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@id/sidebar_menu" + app:layout_constraintTop_toTopOf="parent"> + + + + + + + + + - - + - + - + + + + + + + + + + + - - - - + android:layout_height="match_parent"> + android:id="@+id/sidebar_menu" + android:layout_width="@dimen/drawer_width" + android:layout_height="0dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + - + + + + + + + + + + + + - - + + + + + - - + - + + + + android:background="@color/bg_default" + android:baselineAligned="false" + android:contentDescription="@string/list_layout" + android:orientation="horizontal" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + - + - + + + - + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/synced_folders_layout.xml b/app/src/main/res/layout/synced_folders_layout.xml index 7101594d388e..92889a1eea7c 100644 --- a/app/src/main/res/layout/synced_folders_layout.xml +++ b/app/src/main/res/layout/synced_folders_layout.xml @@ -15,71 +15,97 @@ android:layout_height="match_parent" tools:openDrawer="start"> - - - - - - + + android:layout_height="match_parent" + android:layout_gravity="start" /> + + + + + - + + + + android:layout_height="match_parent" + android:orientation="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - - - + + + android:layout_height="0dp" + android:layout_weight="1"> - - + - + - + + + + + + - + - + - + + - - - + - + - + + + + + + + + android:layout_below="@id/toolbar_standard_include"> - - + android:layout_height="match_parent" + android:footerDividersEnabled="false" + android:visibility="visible" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> - + + - - - + - + + + - + + + - + - + + - - - - + android:layout_height="match_parent"> + android:id="@+id/sidebar_menu" + android:layout_width="@dimen/drawer_width" + android:layout_height="0dp" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + + + + + + - + + + android:layout_below="@id/appbar"> - + android:layout_height="match_parent" + android:footerDividersEnabled="false" + android:visibility="visible"> - + - + - + + + + + - + + + + false + diff --git a/app/src/main/res/values-sw600dp/dims.xml b/app/src/main/res/values-sw600dp/dims.xml index 7436d593a3c5..1abd0e1019f7 100644 --- a/app/src/main/res/values-sw600dp/dims.xml +++ b/app/src/main/res/values-sw600dp/dims.xml @@ -8,5 +8,6 @@ --> 6 - 512dp + 512dp + 300dp diff --git a/app/src/main/res/values-w600dp/bool.xml b/app/src/main/res/values-w600dp/bool.xml new file mode 100644 index 000000000000..2e4fa466b2a2 --- /dev/null +++ b/app/src/main/res/values-w600dp/bool.xml @@ -0,0 +1,11 @@ + + + + false + diff --git a/app/src/main/res/values-w600dp/dims.xml b/app/src/main/res/values-w600dp/dims.xml new file mode 100644 index 000000000000..8883840772a3 --- /dev/null +++ b/app/src/main/res/values-w600dp/dims.xml @@ -0,0 +1,11 @@ + + + + 300dp + diff --git a/app/src/main/res/values/bools.xml b/app/src/main/res/values/bools.xml index ef48d5a0e566..31cb2b2c1978 100644 --- a/app/src/main/res/values/bools.xml +++ b/app/src/main/res/values/bools.xml @@ -8,4 +8,5 @@ --> true + true