aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/services/ImportBackupService.java7
-rw-r--r--src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java16
2 files changed, 19 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/services/ImportBackupService.java b/src/main/java/de/pixart/messenger/services/ImportBackupService.java
index e73b1972f..63d6c7b41 100644
--- a/src/main/java/de/pixart/messenger/services/ImportBackupService.java
+++ b/src/main/java/de/pixart/messenger/services/ImportBackupService.java
@@ -102,6 +102,10 @@ public class ImportBackupService extends Service {
return START_NOT_STICKY;
}
+ public boolean getLoadingState() {
+ return running.get();
+ }
+
public void loadBackupFiles(OnBackupFilesLoaded onBackupFilesLoaded) {
executor.execute(() -> {
List<Jid> accounts = mDatabaseBackend.getAccountJids(false);
@@ -128,13 +132,14 @@ public class ImportBackupService extends Service {
}
}
}
+ Collections.sort(backupFiles, (a, b) -> a.header.getJid().toString().compareTo(b.header.getJid().toString()));
onBackupFilesLoaded.onBackupFilesLoaded(backupFiles);
});
}
private void startForegroundService() {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext(), "backup");
- mBuilder.setContentTitle(getString(R.string.notification_restore_backup_title))
+ mBuilder.setContentTitle(getString(R.string.restoring_backup))
.setSmallIcon(R.drawable.ic_unarchive_white_24dp)
.setProgress(1, 0, true);
startForeground(NOTIFICATION_ID, mBuilder.build());
diff --git a/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java b/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java
index f1c9eea25..4aa4dbfed 100644
--- a/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ImportBackupActivity.java
@@ -14,6 +14,7 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
+import android.view.View;
import android.widget.Toast;
import java.util.List;
@@ -63,6 +64,7 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
ImportBackupService.ImportBackupServiceBinder binder = (ImportBackupService.ImportBackupServiceBinder) service;
this.service = binder.getService();
this.service.addOnBackupProcessedListener(this);
+ setLoadingState(this.service.getLoadingState());
this.service.loadBackupFiles(this);
}
@@ -73,9 +75,7 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
@Override
public void onBackupFilesLoaded(final List<ImportBackupService.BackupFile> files) {
- runOnUiThread(() -> {
- backupFileAdapter.setFiles(files);
- });
+ runOnUiThread(() -> backupFileAdapter.setFiles(files));
}
@Override
@@ -92,12 +92,20 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
Intent intent = new Intent(this, ImportBackupService.class);
intent.putExtra("password", password);
intent.putExtra("file", backupFile.getFile().getAbsolutePath());
+ setLoadingState(true);
ContextCompat.startForegroundService(this, intent);
});
builder.setCancelable(false);
builder.create().show();
}
+ private void setLoadingState(final boolean loadingState) {
+ binding.coordinator.setVisibility(loadingState ? View.GONE : View.VISIBLE);
+ binding.inProgress.setVisibility(loadingState ? View.VISIBLE : View.GONE);
+ setTitle(loadingState ? R.string.restoring_backup : R.string.restore_backup);
+ configureActionBar(getSupportActionBar(), !loadingState);
+ }
+
@Override
public void onBackupRestored() {
runOnUiThread(() -> {
@@ -111,6 +119,7 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
@Override
public void onBackupDecryptionFailed() {
runOnUiThread(() -> {
+ setLoadingState(false);
Snackbar.make(binding.coordinator, R.string.unable_to_decrypt_backup, Snackbar.LENGTH_LONG).show();
});
}
@@ -118,6 +127,7 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo
@Override
public void onBackupRestoreFailed() {
runOnUiThread(() -> {
+ setLoadingState(false);
Snackbar.make(binding.coordinator, R.string.unable_to_restore_backup, Snackbar.LENGTH_LONG).show();
});
}