Enhanced import/export support.

1) Allow imports from the stock SMS database at any time.

2) Provide plaintext export support, in a format compatible with
   the "SMS Backup And Restore" app.

3) Fix the DB weirdness on encrypted restore that previously
   required killing the app.
This commit is contained in:
Moxie Marlinspike
2013-06-24 21:02:30 -07:00
parent 903ab92f5f
commit aa25f94291
37 changed files with 1343 additions and 199 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:drawable/list_selector_background"
android:state_pressed="true" />
<item android:drawable="@drawable/card" />
</selector>

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffeaeaea"
android:layout_gravity="center_vertical"
android:gravity="center_vertical">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:padding="8dip"
android:background="#ffeaeaea">
<LinearLayout android:id="@+id/export_encrypted_backup"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/clickable_card"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:src="@drawable/encrypted_backup"/>
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Registration.Description"
android:text="@string/export_fragment__export_encrypted_backup"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/export_fragment__export_an_encrypted_backup_to_the_sd_card"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/export_plaintext_backup"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/clickable_card"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:src="@drawable/plaintext_backup"/>
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Registration.Description"
android:text="@string/export_fragment__export_plaintext_backup"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/export_fragment__export_a_plaintext_backup_compatible_with"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/import_export_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffeaeaea"
android:layout_gravity="center_vertical"
android:gravity="center_vertical">
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:padding="8dip"
android:background="#ffeaeaea">
<LinearLayout android:id="@+id/import_sms"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/clickable_card"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:src="@drawable/stock_sms"/>
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Registration.Description"
android:text="@string/import_fragment__import_system_sms_database"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/import_fragment__import_the_database_from_the_default_system"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/import_encrypted_backup"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/clickable_card"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:src="@drawable/encrypted_backup"/>
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Registration.Description"
android:text="@string/import_fragment__import_encrypted_backup"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/import_fragment__restore_a_previously_exported_encrypted_textsecure_backup"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/import_plaintext_backup"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:background="@drawable/clickable_card"
android:orientation="vertical">
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:layout_marginLeft="16dip"
android:layout_marginRight="16dip">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:src="@drawable/plaintext_backup"/>
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Registration.Description"
android:text="@string/import_fragment__import_plaintext_backup"/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/import_fragment__import_a_plaintext_backup_file"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -13,19 +13,6 @@
android:id="@+id/menu_mark_all_read"
android:icon="@android:drawable/ic_menu_set_as" />
<item android:title="@string/text_secure_normal__menu_import_export"
android:icon="@android:drawable/ic_menu_save">
<menu>
<item android:title="@string/text_secure_normal__menu_import"
android:id="@+id/menu_import"
android:icon="@android:drawable/ic_menu_revert" />
<item android:title="@string/text_secure_normal__menu_export"
android:id="@+id/menu_export"
android:icon="@android:drawable/ic_menu_save" />
</menu>
</item>
<item android:title="@string/text_secure_normal__menu_settings"
android:id="@+id/menu_settings"
android:icon="@android:drawable/ic_menu_preferences" />

View File

@@ -104,7 +104,62 @@
<!-- ConversationListItem -->
<string name="ConversationListItem_key_exchange_message">Key exchange message...</string>
<!-- ExportFragment -->
<string name="ExportFragment_export_to_sd_card">Export To SD Card?</string>
<string name="ExportFragment_this_will_export_your_encrypted_keys_settings_and_messages">This
will export your encrypted keys, settings, and messages to the SD card.
</string>
<string name="ExportFragment_export">Export</string>
<string name="ExportFragment_export_plaintext_to_sd_card">Export Plaintext To SD Card?</string>
<string name="ExportFragment_warning_this_will_export_the_plaintext_contents">Warning, this will
export the plaintext contents of your TextSecure messages to the SD card.
</string>
<string name="ExportFragment_cancel">Cancel</string>
<string name="ExportFragment_exporting">Exporting</string>
<string name="ExportFragment_exporting_plaintext_to_sd_card">Exporting plaintext to SD card...
</string>
<string name="ExportFragment_error_unable_to_write_to_sd_card">Error, unable to write to SD
card!
</string>
<string name="ExportFragment_error_while_writing_to_sd_card">Error while writing to SD card.
</string>
<string name="ExportFragment_success">Success!</string>
<string name="ExportFragment_exporting_keys_settings_and_messages">Exporting encrypted keys,
settings, and messages...
</string>
<!-- ImportFragment -->
<string name="ImportFragment_import_system_sms_database">Import System SMS Database?</string>
<string name="ImportFragment_this_will_import_messages_from_the_system">This will import
messages from the system\'s default SMS database to TextSecure. If you\'ve previously
imported the system\'s SMS database, importing again will result in duplicated messages.
</string>
<string name="ImportFragment_import">Import</string>
<string name="ImportFragment_cancel">Cancel</string>
<string name="ImportFragment_restore_encrypted_backup">Restore Encrypted Backup?</string>
<string name="ImportFragment_restoring_an_encrypted_backup_will_completely_replace_your_existing_keys">
Restoring an encrypted backup will completely replace your existing keys, preferences, and
messages. You will lose any information that\'s in your current TextSecure install but not
in the backup.
</string>
<string name="ImportFragment_restore">Restore</string>
<string name="ImportFragment_import_plaintext_backup">Import Plaintext Backup?</string>
<string name="ImportFragment_this_will_import_messages_from_a_plaintext_backup">This will import
messages from a plaintext backup. If you\'ve previously imported the system\'s SMS database,
importing again will result in duplicated messages.
</string>
<string name="ImportFragment_importing">Importing</string>
<string name="ImportFragment_import_plaintext_backup_elipse">Import plaintext backup...</string>
<string name="ImportFragment_no_plaintext_backup_found">No plaintext backup found!</string>
<string name="ImportFragment_error_importing_backup">Error importing backup!</string>
<string name="ImportFragment_import_complete">Import complete!</string>
<string name="ImportFragment_restoring">Restoring</string>
<string name="ImportFragment_restoring_encrypted_backup">Restoring encrypted backup...</string>
<string name="ImportFragment_no_encrypted_backup_found">No encrypted backup found!</string>
<string name="ImportFragment_restore_complete">Restore complete!</string>
<!-- KeyScanningActivity -->
<string name="KeyScanningActivity_no_scanned_key_found_exclamation">No scanned key found!</string>
@@ -322,6 +377,26 @@
<!-- database_upgrade_activity -->
<string name="database_upgrade_activity__updating_database">Updating Database...</string>
<string name="export_fragment__export_encrypted_backup">Export Encrypted Backup</string>
<string name="export_fragment__export_an_encrypted_backup_to_the_sd_card">Export an encrypted
backup to the SD card.
</string>
<string name="export_fragment__export_plaintext_backup">Export Plaintext Backup</string>
<string name="export_fragment__export_a_plaintext_backup_compatible_with">
Export a plaintext backup compatible with \'SMSBackup And Restore\' to the SD card.</string>
<string name="import_fragment__import_system_sms_database">Import System SMS Database</string>
<string name="import_fragment__import_the_database_from_the_default_system">Import the database
from the default system messenger app.
</string>
<string name="import_fragment__import_encrypted_backup">Import Encrypted Backup</string>
<string name="import_fragment__restore_a_previously_exported_encrypted_textsecure_backup">
Restore a previously exported encrypted TextSecure backup.
</string>
<string name="import_fragment__import_plaintext_backup">Import Plaintext Backup</string>
<string name="import_fragment__import_a_plaintext_backup_file">
Import a plaintext backup file. Compatible with \'SMSBackup And Restore.\'</string>
<!-- prompt_passphrase_activity -->
<string name="prompt_passphrase_activity__textsecure_passphrase">TEXTSECURE PASSPHRASE</string>
<string name="prompt_passphrase_activity__unlock">Unlock</string>

View File

@@ -20,8 +20,8 @@
</style>
<style name="TextSecure.LightTheme.NavigationDrawer" parent="@style/TextSecure.LightTheme">
<item name="android:homeAsUpIndicator">@drawable/ic_drawer</item>
<item name="homeAsUpIndicator">@drawable/ic_drawer</item>
<item name="navigation_drawer_background">@color/abs__background_holo_light</item>
<item name="navigation_drawer_text_color">#ff333333</item>
<item name="navigation_drawer_icons">@array/navigation_drawer_icons_light</item>
@@ -49,6 +49,7 @@
</style>
<style name="TextSecure.DarkTheme.NavigationDrawer" parent="@style/TextSecure.DarkTheme">
<item name="android:homeAsUpIndicator">@drawable/ic_drawer</item>
<item name="homeAsUpIndicator">@drawable/ic_drawer</item>
<item name="navigation_drawer_background">#ff333333</item>
<item name="navigation_drawer_text_color">#ffdddddd</item>