Support for full backup/restore to sdcard

This commit is contained in:
Moxie Marlinspike
2018-02-26 09:58:18 -08:00
parent 9f6b761d98
commit 24e573e537
41 changed files with 5884 additions and 269 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingLeft="23dp"
android:paddingRight="23dp">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:text="@string/backup_enable_dialog__backups_will_be_saved_to_external_storage_and_encrypted_with_the_passphrase_below_you_must_have_this_passphrase_in_order_to_restore_a_backup"/>
<TableLayout android:id="@+id/number_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_gravity="center_horizontal"
android:clickable="true"
android:focusable="true">
<TableRow android:gravity="center_horizontal"
android:clickable="false"
android:focusable="false">
<TextView android:id="@+id/code_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/BackupPassphrase"
tools:text="22934"/>
<TextView android:id="@+id/code_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
style="@style/BackupPassphrase"
tools:text="56944"
android:layout_marginStart="20dp"/>
<TextView android:id="@+id/code_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
style="@style/BackupPassphrase"
tools:text="42738"
android:layout_marginStart="20dp"/>
</TableRow>
<TableRow android:gravity="center_horizontal">
<TextView android:id="@+id/code_fourth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/BackupPassphrase"
tools:text="34431"/>
<TextView android:id="@+id/code_fifth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
style="@style/BackupPassphrase"
tools:text="24922"
android:layout_marginStart="20dp"/>
<TextView android:id="@+id/code_sixth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
style="@style/BackupPassphrase"
tools:text="58594"
android:layout_marginStart="20dp"/>
</TableRow>
</TableLayout>
<LinearLayout android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<CheckBox android:id="@+id/confirmation_check"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"/>
<TextView android:id="@+id/confirmation_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:text="@string/backup_enable_dialog__i_have_written_down_this_passphrase"/>
</LinearLayout>
</LinearLayout>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="@+id/restore_passphrase_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/enter_backup_passphrase_dialog__backup_passphrase"
android:imeOptions="actionDone"
android:inputType="textVisiblePassword" />
</android.support.design.widget.TextInputLayout>
</FrameLayout>

View File

@@ -109,68 +109,5 @@
</LinearLayout>
</LinearLayout>
<include layout="@layout/preference_divider"/>
<TextView
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
android:text="@string/ImportExportActivity_export"
android:textSize="14sp"
android:fontFamily="sans-serif-medium"
android:textColor="@color/signal_primary_dark"/>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout android:id="@+id/export_plaintext_backup"
android:clickable="true"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="12dp"
android:paddingBottom="12dp"
android:gravity="center_vertical"
android:background="?selectableItemBackground">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginRight="32dp"
android:layout_marginEnd="32dp"
android:src="@drawable/ic_content_copy_white_24dp"
android:tint="?attr/pref_icon_tint"/>
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
style="@style/Registration.Description"
android:text="@string/export_fragment__export_plaintext_backup"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/export_fragment__export_a_plaintext_backup_compatible_with"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:gravity="bottom">
<ProgressBar android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"/>
<TextView android:id="@+id/progress_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
tools:text="1345 messages so far"/>
</LinearLayout>

View File

@@ -55,6 +55,64 @@
android:layout_centerHorizontal="true"
android:layout_marginBottom="-32dp"/>
<LinearLayout android:id="@+id/restore_container"
android:padding="16dp"
android:paddingBottom="0dp"
android:layout_marginTop="30dp"
android:layout_below="@id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:visibility="visible">
<TextView android:id="@+id/backup_created_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Backup created: 1 min ago"/>
<TextView android:id="@+id/backup_size_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
tools:text="Backup size: 899 KB"/>
<TextView android:id="@+id/backup_progress_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_gravity="center_horizontal"
tools:text="100 messages so far..."/>
<com.dd.CircularProgressButton
android:id="@+id/restore_button"
app:cpb_textIdle="@string/registration_activity__restore_backup"
app:cpb_selectorIdle="@drawable/progress_button_state"
app:cpb_colorIndicator="@color/white"
app:cpb_colorProgress="@color/textsecure_primary"
app:cpb_cornerRadius="50dp"
android:background="@color/signal_primary"
android:textColor="@color/white"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="20dp"
android:layout_gravity="center_horizontal"/>
<TextView android:id="@+id/skip_restore_button"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:textColor="@color/gray50"
android:paddingLeft="30dp"
android:paddingRight="30dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:text="@string/registration_activity__skip"/>
</LinearLayout>
<LinearLayout android:id="@+id/registration_container"
android:padding="16dp"
android:paddingBottom="0dp"
@@ -104,7 +162,7 @@
<com.dd.CircularProgressButton
android:id="@+id/registerButton"
app:cpb_textIdle="Register"
app:cpb_textIdle="@string/registration_activity__register"
app:cpb_selectorIdle="@drawable/progress_button_state"
app:cpb_colorIndicator="@color/white"
app:cpb_colorProgress="@color/textsecure_primary"
@@ -168,7 +226,7 @@
android:layout_below="@id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:visibility="visible">
tools:visibility="invisible">
<org.thoughtcrime.securesms.components.registration.VerificationCodeView
android:id="@+id/code"

View File

@@ -1029,7 +1029,7 @@
<string name="AndroidManifest_remove_photo">Remove photo</string>
<!-- arrays.xml -->
<string name="arrays__import_export">Import / export</string>
<string name="arrays__import_export">Import</string>
<string name="arrays__use_default">Use default</string>
<string name="arrays__use_custom">Use custom</string>
@@ -1326,6 +1326,40 @@
<string name="PushDecryptJob_unlock_to_view_pending_messages">Unlock to view pending messages</string>
<string name="ExperienceUpgradeActivity_unlock_to_complete_update">Unlock to complete update</string>
<string name="ExperienceUpgradeActivity_please_unlock_signal_to_complete_update">Please unlock Signal to complete update</string>
<string name="enter_backup_passphrase_dialog__backup_passphrase">Backup passphrase</string>
<string name="backup_enable_dialog__backups_will_be_saved_to_external_storage_and_encrypted_with_the_passphrase_below_you_must_have_this_passphrase_in_order_to_restore_a_backup">Backups will be saved to external storage and encrypted with the passphrase below. You must have this passphrase in order to restore a backup.</string>
<string name="backup_enable_dialog__i_have_written_down_this_passphrase">I have written down this passphrase. Without it, I will be unable to restore a backup.</string>
<string name="registration_activity__restore_backup">Restore backup</string>
<string name="registration_activity__skip">Skip</string>
<string name="registration_activity__register">Register</string>
<string name="preferences_chats__chat_backups">Chat backups</string>
<string name="preferences_chats__backup_chats_to_external_storage">Backup chats to external storage</string>
<string name="preferences_chats__create_backup">Create backup</string>
<string name="RegistrationActivity_enter_backup_passphrase">Enter backup passphrase</string>
<string name="RegistrationActivity_restore">Restore</string>
<string name="RegistrationActivity_incorrect_backup_passphrase">Incorrect backup password</string>
<string name="RegistrationActivity_checking">Checking...</string>
<string name="RegistrationActivity_d_messages_so_far">%d messages so far...</string>
<string name="RegistrationActivity_restore_from_backup">Restore from backup?</string>
<string name="RegistrationActivity_restore_your_messages_and_media_from_a_local_backup">Restore your messages and media from a local backup. If you don\'t restore now, you won\'t be able to restore later.</string>
<string name="RegistrationActivity_backup_size_s">Backup size: %s</string>
<string name="RegistrationActivity_backup_timestamp_s">Backup timestamp: %s</string>
<string name="BackupDialog_enable_local_backups">Enable local backups?</string>
<string name="BackupDialog_enable_backups">Enable backups</string>
<string name="BackupDialog_please_acknowledge_your_understanding_by_marking_the_confirmation_check_box">Please acknowledge your understanding by marking the confirmation check box.</string>
<string name="BackupDialog_delete_backups">Delete backups?</string>
<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="ChatsPreferenceFragment_signal_requires_external_storage_permission_in_order_to_create_backups">Signal requires external storage permission in order to create backups, but it has been permanently denied. Please continue to app settings, select \"Permissions\" and enable \"External Storage\".</string>
<string name="ChatsPreferenceFragment_last_backup_s">Last backup: %s</string>
<string name="ChatsPreferenceFragment_in_progress">In progress</string>
<string name="ProgressPreference_d_messages_so_far">%d messages so far</string>
<string name="RegistrationActivity_verify_s">Verify %s</string>
<string name="RegistrationActivity_please_enter_the_verification_code_sent_to_s">Please enter the verification code sent to %s.</string>
<string name="RegistrationActivity_wrong_number">Wrong number?</string>
<string name="BackupUtil_never">Never</string>
<string name="BackupUtil_unknown">Unknown</string>
<!-- EOF -->

View File

@@ -207,6 +207,15 @@
<item name="android:focusable">false</item>
</style>
<style name="BackupPassphrase">
<item name="android:fontFamily">monospace</item>
<item name="android:typeface">monospace</item>
<item name="android:textSize">15sp</item>
<item name="android:clickable">false</item>
<item name="android:focusable">false</item>
</style>
<style name="PreferenceThemeOverlay.Fix" parent="PreferenceThemeOverlay.v14.Material">
</style>

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<PreferenceCategory android:key="media_download" android:title="@string/preferences_chats__media_auto_download">
<MultiSelectListPreference
android:title="@string/preferences_chats__when_using_mobile_data"
@@ -77,4 +78,23 @@
android:summary="@string/preferences__scan_through_all_conversations_and_enforce_conversation_length_limits"
android:dependency="pref_trim_threads" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_divider"/>
<PreferenceCategory android:key="backup_category" android:title="Backups">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_backup_enabled"
android:title="@string/preferences_chats__chat_backups"
android:summary="@string/preferences_chats__backup_chats_to_external_storage" />
<org.thoughtcrime.securesms.preferences.widgets.ProgressPreference
android:key="pref_backup_create"
android:title="@string/preferences_chats__create_backup"
android:persistent="false"
android:dependency="pref_backup_enabled"
tools:summary="Last backup: 3 days ago"/>
</PreferenceCategory>
</PreferenceScreen>