Skip to content

Commit

Permalink
Release version with Dropbox hidden
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Kalderstam <[email protected]>
  • Loading branch information
spacecowboy committed Jun 17, 2014
1 parent 49bfed0 commit ed3e15a
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 93 deletions.
30 changes: 15 additions & 15 deletions core/res/xml/app_pref_sync.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,21 @@

</PreferenceCategory>

<PreferenceCategory
android:key="pref_dropbox_section_key"
android:persistent="false"
android:title="@string/dropbox">
<com.nononsenseapps.notepad.prefs.FixedSwitchPreference
android:defaultValue="false"
android:key="pref_sync_dropbox_enabled"
android:summary="@string/dropbox_sync_summary"
android:title="@string/dropbox_sync" />
<Preference
android:dependency="pref_sync_dropbox_enabled"
android:key="pref_sync_dropbox_dir"
android:summary="@string/directory_summary"
android:title="@string/directory" />
<!--<PreferenceCategory-->
<!--android:key="pref_dropbox_section_key"-->
<!--android:persistent="false"-->
<!--android:title="@string/dropbox">-->
<!--<com.nononsenseapps.notepad.prefs.FixedSwitchPreference-->
<!--android:defaultValue="false"-->
<!--android:key="pref_sync_dropbox_enabled"-->
<!--android:summary="@string/dropbox_sync_summary"-->
<!--android:title="@string/dropbox_sync" />-->
<!--<Preference-->
<!--android:dependency="pref_sync_dropbox_enabled"-->
<!--android:key="pref_sync_dropbox_dir"-->
<!--android:summary="@string/directory_summary"-->
<!--android:title="@string/directory" />-->

</PreferenceCategory>
<!--</PreferenceCategory>-->

</PreferenceScreen>
143 changes: 72 additions & 71 deletions core/src/com/nononsenseapps/notepad/prefs/SyncPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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());
Expand Down Expand Up @@ -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<Bundle> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -113,10 +113,10 @@ public ArrayList<SynchronizerInterface> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion full/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ android {

defaultConfig {
applicationId "com.nononsenseapps.notepad"
versionCode 115
versionCode 116
versionName getVersionName()

testPackageName "com.nononsenseapps.notepad.test"
Expand Down

0 comments on commit ed3e15a

Please sign in to comment.