From fca4e92749d41ff09ff6cca9528b60e9c78a45cc Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Fri, 27 Nov 2020 19:13:27 +0100 Subject: [PATCH] Move auto upload to settings Resolves #6793 Signed-off-by: Andy Scherzinger --- .../android/ui/activity/DrawerActivity.java | 5 ----- .../android/ui/activity/SettingsActivity.java | 18 +++++++++++++++--- .../ui/activity/SyncedFoldersActivity.java | 19 ++++++++++++++----- src/main/res/menu/partial_drawer_entries.xml | 5 ----- src/main/res/values/strings.xml | 1 + src/main/res/xml/preferences.xml | 4 ++++ 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index bc3dd59a7b..26288d6e17 100644 --- a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -314,8 +314,6 @@ public abstract class DrawerActivity extends ToolbarActivity DrawerMenuUtil.removeMenuItem(menu, R.id.nav_contacts, !getResources().getBoolean(R.bool.contacts_backup) || !getResources().getBoolean(R.bool.show_drawer_contacts_backup)); - DrawerMenuUtil.removeMenuItem(menu, R.id.nav_synced_folders, - getResources().getBoolean(R.bool.syncedFolder_light)); DrawerMenuUtil.removeMenuItem(menu, R.id.nav_logout, !getResources().getBoolean(R.bool.show_drawer_logout)); } @@ -367,9 +365,6 @@ public abstract class DrawerActivity extends ToolbarActivity case R.id.nav_notifications: startActivity(NotificationsActivity.class); break; - case R.id.nav_synced_folders: - startActivity(SyncedFoldersActivity.class); - break; case R.id.nav_contacts: ContactsPreferenceActivity.startActivity(this); break; diff --git a/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java b/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java index c52986453e..37ba1b7902 100644 --- a/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/SettingsActivity.java @@ -317,6 +317,8 @@ public class SettingsActivity extends ThemedPreferenceActivity preferenceCategoryMore.setTitle(ThemeUtils.getColoredTitle(getString(R.string.prefs_category_more), accentColor)); + setupAutoUploadPreference(preferenceCategoryMore); + setupCalendarPreference(preferenceCategoryMore); setupContactsBackupPreference(preferenceCategoryMore); @@ -455,6 +457,18 @@ public class SettingsActivity extends ThemedPreferenceActivity } } + private void setupAutoUploadPreference(PreferenceCategory preferenceCategoryMore) { + Preference autoUpload = findPreference("syncedFolders"); + if (getResources().getBoolean(R.bool.syncedFolder_light)) { + preferenceCategoryMore.removePreference(autoUpload); + } else { + autoUpload.setOnPreferenceClickListener(preference -> { + SyncedFoldersActivity.startActivityWithoutSidebar(this); + return true; + }); + } + } + private void setupContactsBackupPreference(PreferenceCategory preferenceCategoryMore) { boolean contactsBackupEnabled = !getResources().getBoolean(R.bool.show_drawer_contacts_backup) && getResources().getBoolean(R.bool.contacts_backup); @@ -618,9 +632,7 @@ public class SettingsActivity extends ThemedPreferenceActivity if (getResources().getBoolean(R.bool.syncedFolder_light) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { pSyncedFolder.setOnPreferenceClickListener(preference -> { - Intent syncedFoldersIntent = new Intent(getApplicationContext(), SyncedFoldersActivity.class); - syncedFoldersIntent.putExtra(SyncedFoldersActivity.EXTRA_SHOW_SIDEBAR, false); - startActivity(syncedFoldersIntent); + SyncedFoldersActivity.startActivityWithoutSidebar(this); return true; }); } else { diff --git a/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java b/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java index 24eda68fc8..9ac5a8e1ef 100644 --- a/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java @@ -115,6 +115,12 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA @Inject Clock clock; @Inject BackgroundJobManager backgroundJobManager; + public static void startActivityWithoutSidebar(Context context) { + Intent intent = new Intent(context, SyncedFoldersActivity.class); + intent.putExtra(EXTRA_SHOW_SIDEBAR, false); + context.startActivity(intent); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -151,12 +157,16 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA setupToolbar(); updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_synced_folders)); - // setup drawer - setupDrawer(R.id.nav_synced_folders); - if (!showSidebar) { setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); - mDrawerToggle.setDrawerIndicatorEnabled(false); + + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + } + + if (mDrawerToggle != null) { + mDrawerToggle.setDrawerIndicatorEnabled(false); + } } // TODO: The content loading should be done asynchronously @@ -800,7 +810,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA @Override protected void onResume() { super.onResume(); - setDrawerMenuItemChecked(R.id.nav_synced_folders); } private void showBatteryOptimizationInfo() { diff --git a/src/main/res/menu/partial_drawer_entries.xml b/src/main/res/menu/partial_drawer_entries.xml index 4ac1d8ff6f..2a3c2a0f4d 100644 --- a/src/main/res/menu/partial_drawer_entries.xml +++ b/src/main/res/menu/partial_drawer_entries.xml @@ -76,11 +76,6 @@ android:id="@+id/nav_notifications" android:icon="@drawable/nav_notifications" android:title="@string/drawer_item_notifications"/> - Neither F-Droid nor Google Play is installed Calendar & contacts sync set up Daily backup of your contacts + Manage folders for auto upload Help Recommend to friend Imprint diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 902b6cd238..7c7d73ad41 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -60,6 +60,10 @@ +