diff options
author | Raj Yengisetty <rajesh@cyngn.com> | 2014-12-08 12:35:46 -0800 |
---|---|---|
committer | Raj Yengisetty <rajesh@cyngn.com> | 2014-12-10 15:05:15 -0800 |
commit | 5022a2e5a6bac602462c8b24c1ee450c992c4086 (patch) | |
tree | 26e705a5f5f11393b42e7b02d94cb5d63a875754 | |
parent | 9351dc8e51826e3a1b72876da9b8da783c5758b1 (diff) | |
download | android_packages_apps_ContactsCommon-5022a2e5a6bac602462c8b24c1ee450c992c4086.tar.gz android_packages_apps_ContactsCommon-5022a2e5a6bac602462c8b24c1ee450c992c4086.tar.bz2 android_packages_apps_ContactsCommon-5022a2e5a6bac602462c8b24c1ee450c992c4086.zip |
Import feature - auto prompt for importing SIM contacts
Change-Id: I1c24094c3d588edf2d1182d8369882523e6f6512
3 files changed, 68 insertions, 0 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index e049c1d1..eefb8905 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -834,4 +834,8 @@ a ren't members of any other group. [CHAR LIMIT=25] --> <string name="Import_All">Import Contacts From All SIMs</string> <string name="select_path">Select Path</string> <string name="select_sim">Select SIM</string> + + <string name="import_contacts_sim">Import contacts from SIM?</string> + <string name="import_contacts_sim_confirm">Import</string> + <string name="import_contacts_sim_cancel">Cancel</string> </resources> diff --git a/src/com/android/contacts/common/interactions/ImportSIMContactsDialogFragment.java b/src/com/android/contacts/common/interactions/ImportSIMContactsDialogFragment.java new file mode 100755 index 00000000..5cf1d08a --- /dev/null +++ b/src/com/android/contacts/common/interactions/ImportSIMContactsDialogFragment.java @@ -0,0 +1,36 @@ +package com.android.contacts.common.interactions; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.app.DialogFragment; +import android.content.DialogInterface; +import android.os.Bundle; +import com.android.contacts.common.R; + +/** + * An dialog invoked to import/export contacts. + */ +public class ImportSIMContactsDialogFragment extends DialogFragment { + public static final String TAG = "ImportSIMContactsDialogFragment"; + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + // Use the Builder class for convenient dialog construction + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + builder.setMessage(R.string.import_contacts_sim) + .setPositiveButton(R.string.import_contacts_sim_confirm, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + ImportExportDialogFragment.show(getFragmentManager(), + false, ImportSIMContactsDialogFragment.class); + }}) + .setNegativeButton(R.string.import_contacts_sim_cancel, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + // Nothing to do + dismiss(); + }}); + // Create the AlertDialog object and return it + return builder.create(); + } +} diff --git a/src/com/android/contacts/common/preference/ContactsPreferences.java b/src/com/android/contacts/common/preference/ContactsPreferences.java index 311d0075..5c07f83f 100644 --- a/src/com/android/contacts/common/preference/ContactsPreferences.java +++ b/src/com/android/contacts/common/preference/ContactsPreferences.java @@ -27,6 +27,7 @@ import android.provider.ContactsContract; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; +import android.text.TextUtils; import com.android.contacts.common.R; /** @@ -54,6 +55,11 @@ public final class ContactsPreferences implements OnSharedPreferenceChangeListen public static final String SORT_ORDER_KEY = "android.contacts.SORT_ORDER"; /** + * The values of SIMs serial numbers that have been imported + */ + public static final String IMPORTED_SIMS_SNS = "android.contacts.IMPORTED_SIMS"; + + /** * The value for the SORT_ORDER key corresponding to sort by family name first. */ public static final int SORT_ORDER_ALTERNATIVE = 2; @@ -105,6 +111,28 @@ public final class ContactsPreferences implements OnSharedPreferenceChangeListen editor.commit(); } + public String[] getImportedSims() { + String imported = mPreferences.getString(IMPORTED_SIMS_SNS, ""); + if (!TextUtils.isEmpty(imported)) { + return imported.split("\\|"); + } else { + return new String[0]; + } + } + + public void addImportedSims(String simSN) { + String imported = mPreferences.getString(IMPORTED_SIMS_SNS, ""); + if (!TextUtils.isEmpty(imported)) { + imported += "|" + simSN; + } else { + imported = simSN; + } + + final Editor editor = mPreferences.edit(); + editor.putString(IMPORTED_SIMS_SNS, imported); + editor.commit(); + } + public boolean isDisplayOrderUserChangeable() { return mContext.getResources().getBoolean(R.bool.config_display_order_user_changeable); } |