Skip to content

Commit

Permalink
Merge pull request #1660 from nextcloud/fix-logging
Browse files Browse the repository at this point in the history
Fixes #1656
  • Loading branch information
AndyScherzinger authored Oct 19, 2017
2 parents a4844f0 + 884a0a1 commit d4cf475
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
20 changes: 16 additions & 4 deletions src/main/java/com/owncloud/android/ui/activity/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
});
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit d4cf475

Please sign in to comment.