Skip to content

Commit

Permalink
Removed legacy SpringPad importing process
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Aug 21, 2024
1 parent 69530cd commit d2c6527
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 373 deletions.
1 change: 0 additions & 1 deletion omniNotes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ dependencies {
implementation('com.github.federicoiosue:simplegallery:3.0.1') {
exclude group: 'com.android.support'
}
implementation 'com.github.federicoiosue:Springpad-Importer:1.0.1'
implementation('com.github.federicoiosue:Omni-Notes-Commons:1.4.0') {
exclude group: 'org.projectlombok'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static java.util.Collections.emptyList;
import static java.util.Collections.reverse;

import android.Manifest;
import android.Manifest.permission;
import android.annotation.TargetApi;
import android.app.Activity;
Expand Down Expand Up @@ -68,12 +67,10 @@
import it.feio.android.omninotes.helpers.LanguageHelper;
import it.feio.android.omninotes.helpers.LogDelegate;
import it.feio.android.omninotes.helpers.PermissionsHelper;
import it.feio.android.omninotes.helpers.SpringImportHelper;
import it.feio.android.omninotes.helpers.notifications.NotificationsHelper;
import it.feio.android.omninotes.intro.IntroActivity;
import it.feio.android.omninotes.models.ONStyle;
import it.feio.android.omninotes.models.PasswordValidator.Result;
import it.feio.android.omninotes.utils.FileHelper;
import it.feio.android.omninotes.utils.IntentChecker;
import it.feio.android.omninotes.utils.PasswordHelper;
import it.feio.android.omninotes.utils.ResourcesUtils;
Expand All @@ -90,7 +87,6 @@

public class SettingsFragment extends PreferenceFragmentCompat {

private static final int SPRINGPAD_IMPORT = 0;
private static final int RINGTONE_REQUEST_CODE = 100;
private static final int ACCESS_DATA_FOR_EXPORT = 200;
private static final int ACCESS_DATA_FOR_IMPORT = 210;
Expand Down Expand Up @@ -246,23 +242,6 @@ public void onResume() {
// });
// }

Preference importFromSpringpad = findPreference("settings_import_from_springpad");
if (importFromSpringpad != null) {
importFromSpringpad.setOnPreferenceClickListener(arg0 -> {
Intent intent;
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/zip");
if (!IntentChecker.isAvailable(getActivity(), intent, null)) {
Toast.makeText(getActivity(), R.string.feature_not_available_on_this_device,
Toast.LENGTH_SHORT).show();
return false;
}
startActivityForResult(intent, SPRINGPAD_IMPORT);
return false;
});
}

// Preference syncWithDrive = findPreference("settings_backup_drive");
// importFromSpringpad.setOnPreferenceClickListener(new OnPreferenceClickListener() {
// @Override
Expand Down Expand Up @@ -694,16 +673,6 @@ public void afterTextChanged(Editable arg0) {
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (resultCode == Activity.RESULT_OK) {
switch (requestCode) {
case SPRINGPAD_IMPORT:
Uri filesUri = intent.getData();
String path = FileHelper.getPath(getActivity(), filesUri);
// An IntentService will be launched to accomplish the import task
Intent service = new Intent(getActivity(), DataBackupIntentService.class);
service.setAction(SpringImportHelper.ACTION_DATA_IMPORT_SPRINGPAD);
service.putExtra(SpringImportHelper.EXTRA_SPRINGPAD_BACKUP, path);
getActivity().startService(service);
break;

case RINGTONE_REQUEST_CODE:
Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
String notificationSound = uri == null ? null : uri.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@
import it.feio.android.omninotes.helpers.BackupHelper;
import it.feio.android.omninotes.helpers.DocumentFileHelper;
import it.feio.android.omninotes.helpers.LogDelegate;
import it.feio.android.omninotes.helpers.SpringImportHelper;
import it.feio.android.omninotes.helpers.notifications.NotificationChannels.NotificationChannelNames;
import it.feio.android.omninotes.helpers.notifications.NotificationsHelper;
import it.feio.android.omninotes.models.Attachment;
import it.feio.android.omninotes.models.Note;
import it.feio.android.omninotes.models.listeners.OnAttachingFileListener;
import it.feio.android.omninotes.utils.ReminderHelper;
import it.feio.android.omninotes.utils.StorageHelper;
import java.io.File;

import java.io.IOException;
import rx.Observable;

Expand Down Expand Up @@ -80,21 +78,11 @@ protected void onHandleIntent(Intent intent) {
exportData(intent);
} else if (ACTION_DATA_IMPORT.equals(intent.getAction())) {
importData(intent);
} else if (SpringImportHelper.ACTION_DATA_IMPORT_SPRINGPAD.equals(intent.getAction())) {
importDataFromSpringpad(intent, mNotificationsHelper);
} else if (ACTION_DATA_DELETE.equals(intent.getAction())) {
deleteData(intent);
}
}

private void importDataFromSpringpad(Intent intent, NotificationsHelper mNotificationsHelper) {
new SpringImportHelper(OmniNotes.getAppContext())
.importDataFromSpringpad(intent, mNotificationsHelper);
String title = getString(R.string.data_import_completed);
String text = getString(R.string.click_to_refresh_application);
createNotification(intent, this, title, text);
}

private void exportData(Intent intent) {
String backupName = intent.getStringExtra(INTENT_BACKUP_NAME);
var backupDir = DocumentFileCompat.Companion.fromTreeUri(getBaseContext(),
Expand Down Expand Up @@ -153,8 +141,7 @@ private synchronized void deleteData(Intent intent) {

private void createNotification(Intent intent, Context context, String title, String message) {
Intent intentLaunch;
if (DataBackupIntentService.ACTION_DATA_IMPORT.equals(intent.getAction())
|| SpringImportHelper.ACTION_DATA_IMPORT_SPRINGPAD.equals(intent.getAction())) {
if (DataBackupIntentService.ACTION_DATA_IMPORT.equals(intent.getAction())) {
intentLaunch = new Intent(context, MainActivity.class);
intentLaunch.setAction(ACTION_RESTART_APP);
} else {
Expand Down
Loading

0 comments on commit d2c6527

Please sign in to comment.