From ed3e15af62716bebf1f0c34ea5b55834af6a752f Mon Sep 17 00:00:00 2001 From: Jonas Kalderstam Date: Tue, 17 Jun 2014 10:48:57 +0200 Subject: [PATCH] Release version with Dropbox hidden Signed-off-by: Jonas Kalderstam --- core/res/xml/app_pref_sync.xml | 30 ++-- .../notepad/prefs/SyncPrefs.java | 143 +++++++++--------- .../notepad/sync/orgsync/OrgSyncService.java | 12 +- full/build.gradle | 2 +- 4 files changed, 94 insertions(+), 93 deletions(-) diff --git a/core/res/xml/app_pref_sync.xml b/core/res/xml/app_pref_sync.xml index 694118e37..99b925f0c 100644 --- a/core/res/xml/app_pref_sync.xml +++ b/core/res/xml/app_pref_sync.xml @@ -76,21 +76,21 @@ - - - + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/core/src/com/nononsenseapps/notepad/prefs/SyncPrefs.java b/core/src/com/nononsenseapps/notepad/prefs/SyncPrefs.java index ae9b9440f..4e0ddc911 100644 --- a/core/src/com/nononsenseapps/notepad/prefs/SyncPrefs.java +++ b/core/src/com/nononsenseapps/notepad/prefs/SyncPrefs.java @@ -42,14 +42,14 @@ import android.widget.Toast; import com.nononsenseapps.build.Config; -import com.nononsenseapps.filepicker.DropboxFilePickerActivity; +//import com.nononsenseapps.filepicker.DropboxFilePickerActivity; import com.nononsenseapps.filepicker.FilePickerActivity; import com.nononsenseapps.helpers.Log; import com.nononsenseapps.notepad.core.R; import com.nononsenseapps.notepad.database.MyContentProvider; import com.nononsenseapps.notepad.sync.googleapi.GoogleTaskSync; -import com.nononsenseapps.notepad.sync.orgsync.DropboxSyncHelper; -import com.nononsenseapps.notepad.sync.orgsync.DropboxSynchronizer; +//import com.nononsenseapps.notepad.sync.orgsync.DropboxSyncHelper; +//import com.nononsenseapps.notepad.sync.orgsync.DropboxSynchronizer; import com.nononsenseapps.notepad.sync.orgsync.OrgSyncService; import com.nononsenseapps.notepad.sync.orgsync.SDSynchronizer; @@ -78,8 +78,8 @@ public class SyncPrefs extends PreferenceFragment implements public static final String KEY_DROPBOX_ENABLE = "pref_sync_dropbox_enabled"; public static final String KEY_DROPBOX_DIR = "pref_sync_dropbox_dir"; private static final int PICK_SD_DIR_CODE = 1; - private static final int DROPBOX_LINK_CODE = 3895; - private static final int PICK_DROPBOX_DIR_CODE = 2; +// private static final int DROPBOX_LINK_CODE = 3895; +// private static final int PICK_DROPBOX_DIR_CODE = 2; private Activity activity; @@ -192,40 +192,40 @@ public boolean onPreferenceClick(final Preference preference) { }); // Dropbox, disable if no key present - findPreference(KEY_DROPBOX_ENABLE).setEnabled(Config - .getKeyDropboxSyncSecret(getActivity()) != null && - !Config.getKeyDropboxSyncSecret(getActivity()).contains(" ")); - prefDropboxDir = findPreference(KEY_DROPBOX_DIR); - setDropboxDirSummary(sharedPrefs); - prefDropboxDir.setOnPreferenceClickListener(new OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(final Preference preference) { - // See if initial sync is complete - if (DropboxSyncHelper.hasSynced(getActivity())) { - // Start the filepicker - Intent i = new Intent(getActivity(), DropboxFilePickerActivity.class); - i.putExtra(FilePickerActivity.EXTRA_START_PATH, - sharedPrefs.getString(KEY_DROPBOX_DIR, - DropboxSynchronizer.DEFAULT_DIR) - ); - i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false) - .putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true) - .putExtra(FilePickerActivity.EXTRA_MODE, - FilePickerActivity.MODE_DIR); - i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - startActivityForResult(i, PICK_DROPBOX_DIR_CODE); - - } else { - // Start first sync - DropboxSyncHelper.doFirstSync(getActivity()); - // Notify the user to wait - Toast.makeText(getActivity(), R.string.wait_for_dropbox, - Toast.LENGTH_SHORT).show(); - } - - return true; - } - }); +// findPreference(KEY_DROPBOX_ENABLE).setEnabled(Config +// .getKeyDropboxSyncSecret(getActivity()) != null && +// !Config.getKeyDropboxSyncSecret(getActivity()).contains(" ")); +// prefDropboxDir = findPreference(KEY_DROPBOX_DIR); +// setDropboxDirSummary(sharedPrefs); +// prefDropboxDir.setOnPreferenceClickListener(new OnPreferenceClickListener() { +// @Override +// public boolean onPreferenceClick(final Preference preference) { +// // See if initial sync is complete +// if (DropboxSyncHelper.hasSynced(getActivity())) { +// // Start the filepicker +// Intent i = new Intent(getActivity(), DropboxFilePickerActivity.class); +// i.putExtra(FilePickerActivity.EXTRA_START_PATH, +// sharedPrefs.getString(KEY_DROPBOX_DIR, +// DropboxSynchronizer.DEFAULT_DIR) +// ); +// i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false) +// .putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, true) +// .putExtra(FilePickerActivity.EXTRA_MODE, +// FilePickerActivity.MODE_DIR); +// i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); +// startActivityForResult(i, PICK_DROPBOX_DIR_CODE); +// +// } else { +// // Start first sync +// DropboxSyncHelper.doFirstSync(getActivity()); +// // Notify the user to wait +// Toast.makeText(getActivity(), R.string.wait_for_dropbox, +// Toast.LENGTH_SHORT).show(); +// } +// +// return true; +// } +// }); } @Override @@ -272,17 +272,17 @@ public void onSharedPreferenceChanged(SharedPreferences prefs, OrgSyncService.stop(getActivity()); } else if (KEY_SD_DIR.equals(key)) { setSdDirSummary(prefs); - } else if (KEY_DROPBOX_ENABLE.equals(key)) { - if (prefs.getBoolean(key, false)) { - DropboxSynchronizer.linkAccount(this, - DROPBOX_LINK_CODE); - } else { - DropboxSynchronizer.unlink(getActivity()); - } - // Restart sync service - OrgSyncService.stop(getActivity()); - } else if (KEY_DROPBOX_DIR.equals(key)) { - setDropboxDirSummary(prefs); +// } else if (KEY_DROPBOX_ENABLE.equals(key)) { +// if (prefs.getBoolean(key, false)) { +// DropboxSynchronizer.linkAccount(this, +// DROPBOX_LINK_CODE); +// } else { +// DropboxSynchronizer.unlink(getActivity()); +// } +// // Restart sync service +// OrgSyncService.stop(getActivity()); +// } else if (KEY_DROPBOX_DIR.equals(key)) { +// setDropboxDirSummary(prefs); } } } catch (IllegalStateException e) { @@ -297,22 +297,23 @@ public void onSharedPreferenceChanged(SharedPreferences prefs, @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == DROPBOX_LINK_CODE) { - if (resultCode == Activity.RESULT_OK) { - // Start first sync - DropboxSyncHelper.doFirstSync(getActivity()); - } else { - // ... Link failed or was cancelled by the user. - PreferenceManager.getDefaultSharedPreferences(getActivity()).edit() - .putBoolean(KEY_DROPBOX_ENABLE, false).commit(); - } - } else if (requestCode == PICK_DROPBOX_DIR_CODE) { - if (resultCode == Activity.RESULT_OK) { - PreferenceManager.getDefaultSharedPreferences(getActivity - ()).edit().putString(KEY_DROPBOX_DIR, - data.getData().getPath()).commit(); - } // else was cancelled - } else if (requestCode == PICK_SD_DIR_CODE) { +// if (requestCode == DROPBOX_LINK_CODE) { +// if (resultCode == Activity.RESULT_OK) { +// // Start first sync +// DropboxSyncHelper.doFirstSync(getActivity()); +// } else { +// // ... Link failed or was cancelled by the user. +// PreferenceManager.getDefaultSharedPreferences(getActivity()).edit() +// .putBoolean(KEY_DROPBOX_ENABLE, false).commit(); +// } +// } else if (requestCode == PICK_DROPBOX_DIR_CODE) { +// if (resultCode == Activity.RESULT_OK) { +// PreferenceManager.getDefaultSharedPreferences(getActivity +// ()).edit().putString(KEY_DROPBOX_DIR, +// data.getData().getPath()).commit(); +// } // else was cancelled +// } else + if (requestCode == PICK_SD_DIR_CODE) { if (resultCode == Activity.RESULT_OK) { // Set it File path = new File(data.getData().getPath()); @@ -366,11 +367,11 @@ private void setSdDirSummary(final SharedPreferences sharedPreferences) { SDSynchronizer.DEFAULT_ORG_DIR)); } - private void setDropboxDirSummary(final SharedPreferences - sharedPreferences) { - prefDropboxDir.setSummary(sharedPreferences.getString(KEY_DROPBOX_DIR, - DropboxSynchronizer.DEFAULT_DIR)); - } +// private void setDropboxDirSummary(final SharedPreferences +// sharedPreferences) { +// prefDropboxDir.setSummary(sharedPreferences.getString(KEY_DROPBOX_DIR, +// DropboxSynchronizer.DEFAULT_DIR)); +// } public static class AccountDialog extends DialogFragment implements AccountManagerCallback { diff --git a/core/src/com/nononsenseapps/notepad/sync/orgsync/OrgSyncService.java b/core/src/com/nononsenseapps/notepad/sync/orgsync/OrgSyncService.java index 1229d2e14..13160e695 100644 --- a/core/src/com/nononsenseapps/notepad/sync/orgsync/OrgSyncService.java +++ b/core/src/com/nononsenseapps/notepad/sync/orgsync/OrgSyncService.java @@ -89,8 +89,8 @@ public static boolean areAnyEnabled(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - return prefs.getBoolean(SyncPrefs.KEY_SD_ENABLE, false) || - prefs.getBoolean(SyncPrefs.KEY_DROPBOX_ENABLE, false); + return prefs.getBoolean(SyncPrefs.KEY_SD_ENABLE, false);// || +// prefs.getBoolean(SyncPrefs.KEY_DROPBOX_ENABLE, false); } public OrgSyncService() { @@ -113,10 +113,10 @@ public ArrayList getSynchronizers() { } // Try Dropbox - SynchronizerInterface db = new DropboxSynchronizer(this); - if (db.isConfigured()) { - syncers.add(db); - } +// SynchronizerInterface db = new DropboxSynchronizer(this); +// if (db.isConfigured()) { +// syncers.add(db); +// } return syncers; } diff --git a/full/build.gradle b/full/build.gradle index e36c8099f..1e55aa0ff 100644 --- a/full/build.gradle +++ b/full/build.gradle @@ -88,7 +88,7 @@ android { defaultConfig { applicationId "com.nononsenseapps.notepad" - versionCode 115 + versionCode 116 versionName getVersionName() testPackageName "com.nononsenseapps.notepad.test"