Эх сурвалжийг харах

Merge pull request #3447 from nextcloud/removeExpertMode

Removing expert mode checks
Tobias Kaminsky 6 жил өмнө
parent
commit
6f3595e780

+ 1 - 2
src/main/java/com/owncloud/android/MainApp.java

@@ -148,8 +148,7 @@ public class MainApp extends MultiDexApplication {
         new ThumbnailsCacheManager.InitDiskCacheTask().execute();
 
 
-        if (BuildConfig.DEBUG || getApplicationContext().getResources().getBoolean(R.bool.logger_enabled) ||
-                appPrefs.getBoolean(Preferences.PREFERENCE_EXPERT_MODE, false)) {
+        if (BuildConfig.DEBUG || getApplicationContext().getResources().getBoolean(R.bool.logger_enabled)) {
             // use app writable dir, no permissions needed
             Log_OC.startLogging(getAppContext());
             Log_OC.d("Debug", "start logging");

+ 1 - 39
src/main/java/com/owncloud/android/ui/activity/Preferences.java

@@ -96,7 +96,6 @@ public class Preferences extends PreferenceActivity
     public static final String LOCK_DEVICE_CREDENTIALS = "device_credentials";
 
     public final static String PREFERENCE_USE_FINGERPRINT = "use_fingerprint";
-    public static final String PREFERENCE_EXPERT_MODE = "expert_mode";
 
     private static final int ACTION_REQUEST_PASSCODE = 5;
     private static final int ACTION_CONFIRM_PASSCODE = 6;
@@ -115,7 +114,6 @@ public class Preferences extends PreferenceActivity
 
     private ListPreference mLock;
     private SwitchPreference mShowHiddenFiles;
-    private SwitchPreference mExpertMode;
     private AppCompatDelegate mDelegate;
 
     private ListPreference mPrefStoragePath;
@@ -127,8 +125,6 @@ public class Preferences extends PreferenceActivity
 
     public static class PreferenceKeys {
         public static final String STORAGE_PATH = "storage_path";
-        public static final String INSTANT_UPLOAD_PATH = "instant_upload_path";
-        public static final String INSTANT_VIDEO_UPLOAD_PATH = "instant_video_upload_path";
     }
 
     @SuppressWarnings("deprecation")
@@ -336,11 +332,8 @@ public class Preferences extends PreferenceActivity
     }
 
     private void setupLoggingPreference(PreferenceCategory preferenceCategoryMore) {
-        SharedPreferences appPrefs =
-                PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
 
-        boolean loggerEnabled = getResources().getBoolean(R.bool.logger_enabled) || BuildConfig.DEBUG ||
-                appPrefs.getBoolean(PREFERENCE_EXPERT_MODE, false);
+        boolean loggerEnabled = getResources().getBoolean(R.bool.logger_enabled) || BuildConfig.DEBUG;
         Preference pLogger = findPreference("logger");
         if (pLogger != null) {
             if (loggerEnabled) {
@@ -518,42 +511,11 @@ public class Preferences extends PreferenceActivity
 
         setupHiddenFilesPreference(preferenceCategoryDetails, fShowHiddenFilesEnabled);
 
-        setupExpertModePreference(preferenceCategoryDetails, fSyncedFolderLightEnabled);
-
         if (!fPassCodeEnabled && !fDeviceCredentialsEnabled && !fShowHiddenFilesEnabled && fSyncedFolderLightEnabled) {
             preferenceScreen.removePreference(preferenceCategoryDetails);
         }
     }
 
-    private void setupExpertModePreference(PreferenceCategory preferenceCategoryDetails,
-                                           boolean fSyncedFolderLightEnabled) {
-        mExpertMode = (SwitchPreference) findPreference(PREFERENCE_EXPERT_MODE);
-
-        if (fSyncedFolderLightEnabled) {
-            preferenceCategoryDetails.removePreference(mExpertMode);
-        } else {
-            mExpertMode = (SwitchPreference) findPreference(PREFERENCE_EXPERT_MODE);
-            mExpertMode.setOnPreferenceClickListener(preference -> {
-                SharedPreferences appPrefs =
-                        PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-                SharedPreferences.Editor editor = appPrefs.edit();
-                editor.putBoolean(PREFERENCE_EXPERT_MODE, mExpertMode.isChecked());
-                editor.apply();
-
-                if (mExpertMode.isChecked()) {
-                    Log_OC.startLogging(getApplicationContext());
-                } else {
-                    if (!BuildConfig.DEBUG &&
-                            !getApplicationContext().getResources().getBoolean(R.bool.logger_enabled)) {
-                        Log_OC.stopLogging();
-                    }
-                }
-
-                return true;
-            });
-        }
-    }
-
     private void setupHiddenFilesPreference(PreferenceCategory preferenceCategoryDetails,
                                             boolean fShowHiddenFilesEnabled) {
         mShowHiddenFiles = (SwitchPreference) findPreference("show_hidden_files");

+ 21 - 38
src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java

@@ -25,23 +25,20 @@ import android.accounts.Account;
 import android.annotation.SuppressLint;
 import android.content.Context;
 import android.content.Intent;
-import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.PowerManager;
-import android.preference.PreferenceManager;
 import android.text.TextUtils;
 import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
 import android.widget.TextView;
 
-import com.google.android.material.appbar.AppBarLayout;
-import com.google.android.material.appbar.CollapsingToolbarLayout;
 import com.google.android.material.bottomnavigation.BottomNavigationView;
 import com.owncloud.android.BuildConfig;
 import com.owncloud.android.MainApp;
@@ -86,7 +83,6 @@ import androidx.recyclerview.widget.GridLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 
 import static android.provider.Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS;
-import static com.google.android.material.appbar.AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS;
 import static com.owncloud.android.datamodel.SyncedFolderDisplayItem.UNPERSISTED_ID;
 
 /**
@@ -108,7 +104,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
     private SyncedFolderProvider mSyncedFolderProvider;
     private SyncedFolderPreferencesDialogFragment mSyncedFolderPreferencesDialogFragment;
     private boolean showSidebar = true;
-    private RelativeLayout mCustomFolderRelativeLayout;
 
     private String path;
     private int type;
@@ -140,28 +135,9 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
 
         // setup toolbar
         setupToolbar();
-        CollapsingToolbarLayout mCollapsingToolbarLayout = findViewById(R.id.collapsing_toolbar);
-        mCollapsingToolbarLayout.setTitle(this.getString(R.string.drawer_synced_folders));
-
-        mCustomFolderRelativeLayout = findViewById(R.id.custom_folder_toolbar);
-
-        SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-
-
-        findViewById(R.id.toolbar).post(() -> {
-            if (!appPrefs.getBoolean(Preferences.PREFERENCE_EXPERT_MODE, false)) {
-                findViewById(R.id.app_bar).getLayoutParams().height = findViewById(R.id.toolbar).getHeight();
-
-                AppBarLayout.LayoutParams p = (AppBarLayout.LayoutParams) mCollapsingToolbarLayout.getLayoutParams();
-                p.setScrollFlags(SCROLL_FLAG_ENTER_ALWAYS);
-                mCollapsingToolbarLayout.setLayoutParams(p);
-                mCustomFolderRelativeLayout.setVisibility(View.GONE);
-            } else {
-                mCustomFolderRelativeLayout.setVisibility(View.VISIBLE);
-                findViewById(R.id.app_bar).setBackgroundColor(getResources().getColor(R.color.filelist_icon_backgorund));
-            }
-        });
-
+        if (getSupportActionBar() != null){
+            getSupportActionBar().setTitle(R.string.drawer_synced_folders);
+        }
 
         // setup drawer
         setupDrawer(R.id.nav_synced_folders);
@@ -184,6 +160,13 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         }
     }
 
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        MenuInflater inflater = getMenuInflater();
+        inflater.inflate(R.menu.synced_folders_menu, menu);
+        return true;
+    }
+
     /**
      * sets up the UI elements and loads all media/synced folders.
      */
@@ -480,6 +463,15 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                 break;
             }
 
+            case R.id.action_create_custom_folder: {
+                Log.d(TAG, "Show custom folder dialog");
+                SyncedFolderDisplayItem emptyCustomFolder = new SyncedFolderDisplayItem(
+                    SyncedFolder.UNPERSISTED_ID, null, null, true, false,
+                    false, getAccount().name,
+                    FileUploader.LOCAL_BEHAVIOUR_FORGET, false, null, MediaFolderType.CUSTOM);
+                onSyncFolderSettingsClick(0, emptyCustomFolder);
+            }
+
             default:
                 result = super.onOptionsItemSelected(item);
                 break;
@@ -681,15 +673,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         }
     }
 
-    public void onAddCustomFolderClick(View view) {
-        Log.d(TAG, "Show custom folder dialog");
-        SyncedFolderDisplayItem emptyCustomFolder = new SyncedFolderDisplayItem(
-                SyncedFolder.UNPERSISTED_ID, null, null, true, false,
-            false, getAccount().name,
-                FileUploader.LOCAL_BEHAVIOUR_FORGET, false, null, MediaFolderType.CUSTOM);
-        onSyncFolderSettingsClick(0, emptyCustomFolder);
-    }
-
     @Override
     protected void onResume() {
         super.onResume();

+ 3 - 10
src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java

@@ -28,10 +28,8 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
-import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.os.IBinder;
-import android.preference.PreferenceManager;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
@@ -65,8 +63,6 @@ import butterknife.BindView;
 import butterknife.ButterKnife;
 import butterknife.Unbinder;
 
-import static com.owncloud.android.ui.activity.Preferences.PREFERENCE_EXPERT_MODE;
-
 /**
  * Activity listing pending, active, and completed uploads. User can delete
  * completed uploads from view. Content of this list of coming from
@@ -278,12 +274,9 @@ public class UploadListActivity extends FileActivity {
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
-        SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
-        if (appPrefs.getBoolean(PREFERENCE_EXPERT_MODE, false)) {
-            MenuInflater inflater = getMenuInflater();
-            inflater.inflate(R.menu.upload_list_menu, menu);
-            this.menu = menu;
-        }
+        MenuInflater inflater = getMenuInflater();
+        inflater.inflate(R.menu.upload_list_menu, menu);
+        this.menu = menu;
 
         return true;
     }

BIN
src/main/res/drawable-hdpi/ic_folder_star_18dp.png


BIN
src/main/res/drawable-mdpi/ic_folder_star_18dp.png


BIN
src/main/res/drawable-xhdpi/ic_folder_star_18dp.png


BIN
src/main/res/drawable-xxhdpi/ic_folder_star_18dp.png


BIN
src/main/res/drawable-xxxhdpi/ic_folder_star_18dp.png


+ 4 - 44
src/main/res/layout/synced_folders_layout.xml

@@ -38,51 +38,11 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content">
 
-            <com.google.android.material.appbar.CollapsingToolbarLayout
-                android:id="@+id/collapsing_toolbar"
+            <androidx.appcompat.widget.Toolbar
+                android:id="@+id/toolbar"
                 android:layout_width="match_parent"
-                android:layout_height="@dimen/collapsing_toolbar_layout_height"
-                app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
-                app:titleEnabled="false">
-
-                <RelativeLayout
-                    android:id="@+id/custom_folder_toolbar"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_gravity="center_horizontal|bottom"
-                    android:gravity="center"
-                    android:onClick="onAddCustomFolderClick"
-                    android:padding="@dimen/standard_padding"
-                    app:layout_collapseMode="pin">
-
-                    <ImageView
-                        android:id="@+id/custom_folder_image"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:src="@drawable/ic_folder_star_18dp"
-                        android:contentDescription="@string/synced_folder_custom_folder_image"/>
-
-                    <TextView
-                        android:id="@+id/add_custom_folder"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_toRightOf="@id/custom_folder_image"
-                        android:layout_toEndOf="@id/custom_folder_image"
-                        android:paddingLeft="@dimen/alternate_half_padding"
-                        android:paddingStart="@dimen/alternate_half_padding"
-                        android:paddingRight="@dimen/zero"
-                        android:paddingEnd="@dimen/zero"
-                        android:text="@string/autoupload_custom_folder"/>
-
-                </RelativeLayout>
-
-                <androidx.appcompat.widget.Toolbar
-                    android:id="@+id/toolbar"
-                    android:layout_width="match_parent"
-                    android:layout_height="?attr/actionBarSize"
-                    android:background="?attr/colorPrimary"
-                    app:layout_collapseMode="pin"/>
-            </com.google.android.material.appbar.CollapsingToolbarLayout>
+                android:layout_height="?attr/actionBarSize"
+                android:background="?attr/colorPrimary"/>
         </com.google.android.material.appbar.AppBarLayout>
 
         <FrameLayout

+ 29 - 0
src/main/res/menu/synced_folders_menu.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Nextcloud Android client application
+
+  Copyright (C) 2019 Andy Scherzinger
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program. If not, see <https://www.gnu.org/licenses/>.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <group
+        android:id="@+id/synced_folders_actions"
+        android:checkableBehavior="none">
+
+        <item
+            android:id="@+id/action_create_custom_folder"
+            android:title="@string/autoupload_custom_folder"/>
+    </group>
+</menu>

+ 0 - 1
src/main/res/values/dims.xml

@@ -132,7 +132,6 @@
     <dimen name="synced_folders_item_type_layout_width">32dp</dimen>
     <dimen name="synced_folders_item_type_layout_height">32dp</dimen>
     <dimen name="synced_folders_item_type_layout_right_end_margin">24dp</dimen>
-    <dimen name="collapsing_toolbar_layout_height">110dp</dimen>
     <dimen name="synced_folders_progress_bar_layout_width">72dp</dimen>
     <dimen name="synced_folders_progress_bar_layout_height">72dp</dimen>
     <dimen name="synced_folders_recycler_view_layout_margin">-3dp</dimen>

+ 0 - 2
src/main/res/values/strings.xml

@@ -44,7 +44,6 @@
     <string name="prefs_lock_using_device_credentials">Device credentials</string>
     <string name="prefs_lock_device_credentials_enabled">Device credentials enabled</string>
     <string name="prefs_lock_device_credentials_not_setup">No device credentials have been set up.</string>
-    <string name="prefs_expert_mode">Expert mode</string>
     <string name="prefs_show_hidden_files">Show hidden files</string>
     <string name="prefs_log_delete_history_button">Delete history</string>
     <string name="prefs_calendar_contacts">Sync calendar &amp; contacts</string>
@@ -689,7 +688,6 @@
     <string name="synced_folders_type">Type</string>
     <string name="sync_status_button">Sync status button</string>
     <string name="synced_folder_settings_button">Settings button</string>
-    <string name="synced_folder_custom_folder_image">Custom folder image</string>
     <string name="upload_item_action_button">Upload item action button</string>
     <string name="forward">Forward</string>
     <string name="what_s_new_image">What\'s new image</string>

+ 0 - 3
src/main/res/xml/preferences.xml

@@ -47,9 +47,6 @@
 		<com.owncloud.android.ui.ThemeableSwitchPreference
 			android:title="@string/prefs_show_hidden_files"
 			android:key="show_hidden_files"/>
-		<com.owncloud.android.ui.ThemeableSwitchPreference
-			android:title="@string/prefs_expert_mode"
-			android:key="expert_mode"/>
 	</PreferenceCategory>
 
 	<PreferenceCategory android:title="@string/prefs_category_more" android:key="more">