From 9a2f048e1a3bff88885f50dc09aad0c462c460e5 Mon Sep 17 00:00:00 2001 From: Jonas Kalderstam Date: Tue, 28 Oct 2014 21:50:10 +0100 Subject: [PATCH] Move dropbox files to playflavor Signed-off-by: Jonas Kalderstam --- app/build.gradle | 4 +- .../filepicker/DropboxFilePickerActivity.java | 23 +++ .../sync/orgsync/DropboxSyncHelper.java | 32 ++++ .../sync/orgsync/DropboxSynchronizer.java | 164 ++++++++++++++++++ .../notepad/prefs/SyncPrefs.java | 2 +- .../notepad/sync/orgsync/OrgSyncService.java | 2 +- .../filepicker/DropboxFilePickerActivity.java | 0 .../filepicker/DropboxFilePickerFragment.java | 0 .../sync/orgsync/DropboxSyncHelper.java | 0 .../sync/orgsync/DropboxSynchronizer.java | 0 .../play}/libs/armeabi/libDropboxSync.so | Bin .../play}/libs/dropbox-sync-sdk-android.jar | Bin .../play}/libs/mips/libDropboxSync.so | Bin app/{ => src/play}/libs/x86/libDropboxSync.so | Bin 14 files changed, 224 insertions(+), 3 deletions(-) create mode 100644 app/src/free/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java create mode 100644 app/src/free/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java create mode 100644 app/src/free/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java rename app/src/{main => play}/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java (100%) rename app/src/{main => play}/java/com/nononsenseapps/filepicker/DropboxFilePickerFragment.java (100%) rename app/src/{main => play}/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java (100%) rename app/src/{main => play}/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java (100%) rename app/{ => src/play}/libs/armeabi/libDropboxSync.so (100%) rename app/{ => src/play}/libs/dropbox-sync-sdk-android.jar (100%) rename app/{ => src/play}/libs/mips/libDropboxSync.so (100%) rename app/{ => src/play}/libs/x86/libDropboxSync.so (100%) diff --git a/app/build.gradle b/app/build.gradle index 9603ba655..94f54fe7f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -148,7 +148,7 @@ task nativeLibsToJar(type: Zip) { destinationDir file("$buildDir/native-libs") baseName 'native-libs' extension 'jar' - from fileTree(dir: 'libs', include: '**/*.so') + from fileTree(dir: 'src/playBeta/libs', include: '**/*.so') into 'lib/' } @@ -171,6 +171,8 @@ dependencies { apt "org.androidannotations:androidannotations:$AAVersion" compile "org.androidannotations:androidannotations-api:$AAVersion" // Dropbox and non-free stuff + playCompile fileTree(dir: 'src/play/libs', include: '*.jar') + playBetaCompile fileTree(dir: 'src/play/libs', include: '*.jar') playCompile fileTree(dir: "$buildDir/native-libs", include: "*.jar") playCompile 'com.google.android.gms:play-services:+' playBetaCompile fileTree(dir: "$buildDir/native-libs", include: "*.jar") diff --git a/app/src/free/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java b/app/src/free/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java new file mode 100644 index 000000000..4ff8e2a99 --- /dev/null +++ b/app/src/free/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2014 Jonas Kalderstam. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.nononsenseapps.filepicker; + +/** + * Dummy class. See Play build flavor for real one. + */ +public class DropboxFilePickerActivity { +} diff --git a/app/src/free/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java b/app/src/free/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java new file mode 100644 index 000000000..2574da52f --- /dev/null +++ b/app/src/free/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 Jonas Kalderstam. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.nononsenseapps.notepad.sync.orgsync; + +import android.app.Activity; + +/** + * Dummy file, see play flavor. + */ +public class DropboxSyncHelper { + public static boolean hasSynced(Activity activity) { + return false; + } + + public static void doFirstSync(Activity activity) { + + } +} diff --git a/app/src/free/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java b/app/src/free/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java new file mode 100644 index 000000000..67a2fd378 --- /dev/null +++ b/app/src/free/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2014 Jonas Kalderstam. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.nononsenseapps.notepad.sync.orgsync; + +import android.app.Activity; + +import com.nononsenseapps.notepad.prefs.SyncPrefs; + +import org.cowboyprogrammer.org.OrgFile; + +import java.io.BufferedReader; +import java.io.IOException; +import java.text.ParseException; +import java.util.HashSet; + +/** + * Dummy class. See play flavor. + */ +public class DropboxSynchronizer implements SynchronizerInterface { + public static final String DEFAULT_DIR = "DUMMY"; + + public DropboxSynchronizer(OrgSyncService orgSyncService) { + + } + + public static void linkAccount(SyncPrefs syncPrefs, int dropboxLinkCode) { + + } + + public static void unlink(Activity activity) { + + } + + /** + * @return A unique name for this service. Should be descriptive, like + * DropboxOrg, SDOrg or SSHOrg. + */ + @Override + public String getServiceName() { + return null; + } + + /** + * @return The username of the configured service. Likely an e-mail. + */ + @Override + public String getAccountName() { + return null; + } + + /** + * Returns true if the synchronizer has been configured. This is called + * before synchronization. It will be true if the user has selected an + * account, folder etc... + */ + @Override + public boolean isConfigured() { + return false; + } + + /** + * Returns an OrgFile object with a filename set that is guaranteed to + * not already exist. Use this method to avoid having multiple objects + * pointing to the same file. + * + * @param desiredName The name you'd want. If it exists, + * it will be used as the base in desiredName1, + * desiredName2, etc. Limited to 99. + * @return an OrgFile guaranteed not to exist. + * @throws java.io.IOException + * @throws IllegalArgumentException + */ + @Override + public OrgFile getNewFile(String desiredName) throws IOException, IllegalArgumentException { + return null; + } + + /** + * Replaces the file on the remote end with the given content. + * + * @param orgFile The file to save. Uses the filename stored in the object. + */ + @Override + public void putRemoteFile(OrgFile orgFile) throws IOException { + + } + + /** + * Delete the file on the remote end. + * + * @param orgFile The file to delete. + */ + @Override + public void deleteRemoteFile(OrgFile orgFile) { + + } + + /** + * Rename the file on the remote end. + * + * @param oldName The name it is currently stored as on the remote end. + * @param orgFile + */ + @Override + public void renameRemoteFile(String oldName, OrgFile orgFile) { + + } + + /** + * Returns a BufferedReader to the remote file. Null if it doesn't exist. + * + * @param filename Name of the file, without path + */ + @Override + public BufferedReader getRemoteFile(String filename) { + return null; + } + + /** + * @return a set of all remote files. + */ + @Override + public HashSet getRemoteFilenames() { + return null; + } + + /** + * Do a full 2-way sync. + */ + @Override + public void fullSync() throws IOException, ParseException { + + } + + /** + * Use this to disconnect from any services and cleanup. + */ + @Override + public void postSynchronize() { + + } + + /** + * @return a Monitor for this source. May be null. + */ + @Override + public Monitor getMonitor() { + return null; + } +} diff --git a/app/src/main/java/com/nononsenseapps/notepad/prefs/SyncPrefs.java b/app/src/main/java/com/nononsenseapps/notepad/prefs/SyncPrefs.java index 6faa6f8cc..267f0c9db 100644 --- a/app/src/main/java/com/nononsenseapps/notepad/prefs/SyncPrefs.java +++ b/app/src/main/java/com/nononsenseapps/notepad/prefs/SyncPrefs.java @@ -192,7 +192,7 @@ public boolean onPreferenceClick(final Preference preference) { } }); - if (BuildConfig.DROPBOX_ENABLED) { + if (BuildConfig.DROPBOX_ENABLED && BuildConfig.NONFREE) { // Dropbox, disable if no key present findPreference(KEY_DROPBOX_ENABLE) .setEnabled(BuildConfig.DROPBOX_ENABLED && diff --git a/app/src/main/java/com/nononsenseapps/notepad/sync/orgsync/OrgSyncService.java b/app/src/main/java/com/nononsenseapps/notepad/sync/orgsync/OrgSyncService.java index 80524d80c..9e1aa77de 100644 --- a/app/src/main/java/com/nononsenseapps/notepad/sync/orgsync/OrgSyncService.java +++ b/app/src/main/java/com/nononsenseapps/notepad/sync/orgsync/OrgSyncService.java @@ -115,7 +115,7 @@ public ArrayList getSynchronizers() { } // Try Dropbox - if (BuildConfig.DROPBOX_ENABLED) { + if (BuildConfig.DROPBOX_ENABLED && BuildConfig.NONFREE) { SynchronizerInterface db = new DropboxSynchronizer(this); if (db.isConfigured()) { syncers.add(db); diff --git a/app/src/main/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java b/app/src/play/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java similarity index 100% rename from app/src/main/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java rename to app/src/play/java/com/nononsenseapps/filepicker/DropboxFilePickerActivity.java diff --git a/app/src/main/java/com/nononsenseapps/filepicker/DropboxFilePickerFragment.java b/app/src/play/java/com/nononsenseapps/filepicker/DropboxFilePickerFragment.java similarity index 100% rename from app/src/main/java/com/nononsenseapps/filepicker/DropboxFilePickerFragment.java rename to app/src/play/java/com/nononsenseapps/filepicker/DropboxFilePickerFragment.java diff --git a/app/src/main/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java b/app/src/play/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java similarity index 100% rename from app/src/main/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java rename to app/src/play/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSyncHelper.java diff --git a/app/src/main/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java b/app/src/play/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java similarity index 100% rename from app/src/main/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java rename to app/src/play/java/com/nononsenseapps/notepad/sync/orgsync/DropboxSynchronizer.java diff --git a/app/libs/armeabi/libDropboxSync.so b/app/src/play/libs/armeabi/libDropboxSync.so similarity index 100% rename from app/libs/armeabi/libDropboxSync.so rename to app/src/play/libs/armeabi/libDropboxSync.so diff --git a/app/libs/dropbox-sync-sdk-android.jar b/app/src/play/libs/dropbox-sync-sdk-android.jar similarity index 100% rename from app/libs/dropbox-sync-sdk-android.jar rename to app/src/play/libs/dropbox-sync-sdk-android.jar diff --git a/app/libs/mips/libDropboxSync.so b/app/src/play/libs/mips/libDropboxSync.so similarity index 100% rename from app/libs/mips/libDropboxSync.so rename to app/src/play/libs/mips/libDropboxSync.so diff --git a/app/libs/x86/libDropboxSync.so b/app/src/play/libs/x86/libDropboxSync.so similarity index 100% rename from app/libs/x86/libDropboxSync.so rename to app/src/play/libs/x86/libDropboxSync.so