Move files & strings

This commit is contained in:
nielsandriesse 2020-09-17 13:26:03 +10:00
parent bf666f0296
commit d2f79f902f
12 changed files with 23 additions and 33 deletions

View File

@ -1499,7 +1499,6 @@
<string name="BackupDialog_disable_and_delete_all_local_backups">Disable and delete all local backups?</string>
<string name="BackupDialog_delete_backups_statement">Delete backups</string>
<string name="BackupDialog_copied_to_clipboard">Copied to clipboard</string>
<string name="BackupDialog_activation_error">Failed to activate backups. Please try again or contact support.</string>
<string name="ChatsPreferenceFragment_signal_requires_external_storage_permission_in_order_to_create_backups">Session requires external storage permission in order to create backups, but it has been permanently denied. Please continue to app settings, select \"Permissions\" and enable \"Storage\".</string>
<string name="ChatsPreferenceFragment_last_backup_s">Last backup: %s</string>
<string name="ChatsPreferenceFragment_in_progress">In progress</string>
@ -1867,4 +1866,6 @@
<string name="attachment_type_voice_message">Voice Message</string>
<string name="details">Details</string>
<string name="dialog_backup_activation_failed">Failed to activate backups. Please try again or contact support.</string>
</resources>

View File

@ -1,6 +1,5 @@
package org.thoughtcrime.securesms.backup;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
@ -51,7 +50,7 @@ public class BackupDialog {
} catch (IOException e) {
Log.e(TAG, "Failed to activate backups.", e);
Toast.makeText(context,
context.getString(R.string.BackupDialog_activation_error),
context.getString(R.string.dialog_backup_activation_failed),
Toast.LENGTH_LONG)
.show();
return;

View File

@ -1,14 +1,13 @@
package org.thoughtcrime.securesms.backup;
import android.content.Context;
import android.database.Cursor;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.net.Uri;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.annimon.stream.function.Consumer;
import com.annimon.stream.function.Predicate;
import com.google.protobuf.ByteString;

View File

@ -32,6 +32,7 @@ import org.thoughtcrime.securesms.database.helpers.ClassicOpenHelper;
import org.thoughtcrime.securesms.database.helpers.SQLCipherMigrationHelper;
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
import org.thoughtcrime.securesms.loki.database.LokiAPIDatabase;
import org.thoughtcrime.securesms.loki.database.LokiBackupFilesDatabase;
import org.thoughtcrime.securesms.loki.database.LokiMessageDatabase;
import org.thoughtcrime.securesms.loki.database.LokiPreKeyBundleDatabase;
import org.thoughtcrime.securesms.loki.database.LokiPreKeyRecordDatabase;

View File

@ -24,7 +24,7 @@ import org.thoughtcrime.securesms.database.GroupDatabase;
import org.thoughtcrime.securesms.database.GroupReceiptDatabase;
import org.thoughtcrime.securesms.database.IdentityDatabase;
import org.thoughtcrime.securesms.database.JobDatabase;
import org.thoughtcrime.securesms.database.LokiBackupFilesDatabase;
import org.thoughtcrime.securesms.loki.database.LokiBackupFilesDatabase;
import org.thoughtcrime.securesms.database.MmsDatabase;
import org.thoughtcrime.securesms.database.OneTimePreKeyDatabase;
import org.thoughtcrime.securesms.database.PushDatabase;
@ -92,7 +92,7 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
private static final int lokiV13 = 34;
private static final int lokiV14_BACKUP_FILES = 35;
private static final int DATABASE_VERSION = lokiV14_BACKUP_FILES; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Session makes any database changes
private static final int DATABASE_VERSION = lokiV14_BACKUP_FILES; // Loki - onUpgrade(...) must be updated to use Loki version numbers if Signal makes any database changes
private static final String DATABASE_NAME = "signal.db";
private final Context context;

View File

@ -4,7 +4,7 @@ package org.thoughtcrime.securesms.jobs;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.database.NoExternalStorageException;
import org.thoughtcrime.securesms.database.model.BackupFileRecord;
import org.thoughtcrime.securesms.loki.database.BackupFileRecord;
import org.thoughtcrime.securesms.jobmanager.Data;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.logging.Log;

View File

@ -1,4 +1,4 @@
package org.thoughtcrime.securesms.database.model
package org.thoughtcrime.securesms.loki.database
import android.net.Uri
import java.util.*
@ -8,5 +8,5 @@ import java.util.*
*/
data class BackupFileRecord(val id: Long, val uri: Uri, val fileSize: Long, val timestamp: Date) {
constructor(uri: Uri, fileSize: Long, timestamp: Date): this(-1, uri, fileSize, timestamp)
constructor(uri: Uri, fileSize: Long, timestamp: Date) : this(-1, uri, fileSize, timestamp)
}

View File

@ -1,12 +1,11 @@
package org.thoughtcrime.securesms.database
package org.thoughtcrime.securesms.loki.database
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.net.Uri
import androidx.annotation.NonNull
import org.thoughtcrime.securesms.database.Database
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
import org.thoughtcrime.securesms.database.model.BackupFileRecord
import java.lang.IllegalArgumentException
import java.util.*
import kotlin.collections.ArrayList
@ -15,7 +14,7 @@ import kotlin.collections.ArrayList
* Keeps track of the backup files saved by the app.
* Uses [BackupFileRecord] as an entry data projection.
*/
class LokiBackupFilesDatabase(context: Context?, databaseHelper: SQLCipherOpenHelper?)
class LokiBackupFilesDatabase(context: Context, databaseHelper: SQLCipherOpenHelper)
: Database(context, databaseHelper) {
companion object {

View File

@ -1,6 +1,5 @@
package org.thoughtcrime.securesms.preferences;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
@ -27,7 +26,6 @@ import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.preferences.widgets.ProgressPreference;
import org.thoughtcrime.securesms.util.BackupDirSelector;
import org.thoughtcrime.securesms.util.BackupUtil;
import org.thoughtcrime.securesms.util.FragmentContextProvider;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Trimmer;
@ -120,9 +118,8 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
}
private void setBackupSummary() {
findPreference(TextSecurePreferences.BACKUP_NOW).setSummary(
String.format(getString(R.string.ChatsPreferenceFragment_last_backup_s),
BackupUtil.getLastBackupTimeString(getContext(), Locale.getDefault())));
findPreference(TextSecurePreferences.BACKUP_NOW)
.setSummary(String.format(getString(R.string.ChatsPreferenceFragment_last_backup_s), BackupUtil.getLastBackupTimeString(getContext(), Locale.getDefault())));
}
private void setMediaDownloadSummaries() {
@ -152,7 +149,7 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
private class BackupClickListener implements Preference.OnPreferenceClickListener {
@Override
public boolean onPreferenceClick(Preference preference) {
if (!((SwitchPreferenceCompat)preference).isChecked()) {
if (!((SwitchPreferenceCompat) preference).isChecked()) {
BackupDialog.showEnableBackupDialog(getActivity(), (SwitchPreferenceCompat)preference, backupDirSelector);
} else {
BackupDialog.showDisableBackupDialog(getActivity(), (SwitchPreferenceCompat)preference);

View File

@ -17,11 +17,10 @@ import org.thoughtcrime.securesms.backup.BackupPassphrase
import org.thoughtcrime.securesms.backup.FullBackupExporter
import org.thoughtcrime.securesms.crypto.AttachmentSecretProvider
import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.database.model.BackupFileRecord
import org.thoughtcrime.securesms.loki.database.BackupFileRecord
import org.thoughtcrime.securesms.service.LocalBackupListener
import org.whispersystems.libsignal.util.ByteUtil
import java.io.IOException
import java.lang.IllegalStateException
import java.security.SecureRandom
import java.text.SimpleDateFormat
import java.util.*

View File

@ -2,21 +2,14 @@ package org.thoughtcrime.securesms.util;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.thoughtcrime.securesms.database.model.BackupFileRecord;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.loki.database.BackupFileRecord;
import network.loki.messenger.R;
import org.thoughtcrime.securesms.database.NoExternalStorageException;
import org.whispersystems.libsignal.util.ByteUtil;
import java.io.File;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Locale;
//TODO AC: Delete this class when its functionality is
// fully replaced by the BackupUtil.kt and related classes.

View File

@ -15,6 +15,7 @@ interface ContextProvider {
}
class ActivityContextProvider(private val activity: Activity): ContextProvider {
override fun getContext(): Context {
return activity
}
@ -25,6 +26,7 @@ class ActivityContextProvider(private val activity: Activity): ContextProvider {
}
class FragmentContextProvider(private val fragment: Fragment): ContextProvider {
override fun getContext(): Context {
return fragment.requireContext()
}