diff --git a/src/main/java/com/owncloud/android/MainApp.java b/src/main/java/com/owncloud/android/MainApp.java index 63be9a7b7a7c..c4686237627e 100644 --- a/src/main/java/com/owncloud/android/MainApp.java +++ b/src/main/java/com/owncloud/android/MainApp.java @@ -119,7 +119,9 @@ public void onCreate() { // initialise thumbnails cache on background thread new ThumbnailsCacheManager.InitDiskCacheTask().execute(); - if (BuildConfig.DEBUG) { + + if (BuildConfig.DEBUG || getApplicationContext().getResources().getBoolean(R.bool.logger_enabled) || + appPrefs.getBoolean(Preferences.EXPERT_MODE, false)) { // use app writable dir, no permissions needed Log_OC.startLogging(getAppContext()); Log_OC.d("Debug", "start logging"); diff --git a/src/main/java/com/owncloud/android/ui/activity/Preferences.java b/src/main/java/com/owncloud/android/ui/activity/Preferences.java index 86997bf621dd..122c93830c52 100644 --- a/src/main/java/com/owncloud/android/ui/activity/Preferences.java +++ b/src/main/java/com/owncloud/android/ui/activity/Preferences.java @@ -85,6 +85,8 @@ public class Preferences extends PreferenceActivity public final static String PREFERENCE_USE_FINGERPRINT = "use_fingerprint"; + public static final String EXPERT_MODE = "expert_mode"; + private static final String SCREEN_NAME = "Settings"; private static final int ACTION_REQUEST_PASSCODE = 5; @@ -317,20 +319,30 @@ public boolean onPreferenceClick(Preference preference) { preferenceCategoryDetails.removePreference(mShowHiddenFiles); } - mExpertMode = (SwitchPreference) findPreference("expert_mode"); + mExpertMode = (SwitchPreference) findPreference(EXPERT_MODE); if (getResources().getBoolean(R.bool.syncedFolder_light)) { preferenceCategoryDetails.removePreference(mExpertMode); } else { - mExpertMode = (SwitchPreference) findPreference("expert_mode"); + mExpertMode = (SwitchPreference) findPreference(EXPERT_MODE); mExpertMode.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = appPrefs.edit(); - editor.putBoolean("expert_mode", mExpertMode.isChecked()); + editor.putBoolean(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; } }); @@ -473,7 +485,7 @@ public boolean onPreferenceClick(Preference preference) { PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); boolean loggerEnabled = getResources().getBoolean(R.bool.logger_enabled) || BuildConfig.DEBUG || - appPrefs.getBoolean("expert_mode", false); + appPrefs.getBoolean(EXPERT_MODE, false); Preference pLogger = findPreference("logger"); if (pLogger != null) { if (loggerEnabled) { diff --git a/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java b/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java index c22b48caf1de..b592458c2975 100755 --- a/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UploadListActivity.java @@ -62,6 +62,8 @@ import java.io.File; +import static com.owncloud.android.ui.activity.Preferences.EXPERT_MODE; + /** * Activity listing pending, active, and completed uploads. User can delete * completed uploads from view. Content of this list of coming from @@ -76,8 +78,6 @@ public class UploadListActivity extends FileActivity implements UploadListFragme private static final String SCREEN_NAME = "Uploads"; - private static final String EXPERT_MODE = "expert_mode"; - private UploadMessagesReceiver mUploadMessagesReceiver; private Menu mMenu;