Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
mariagpuyol | 5874835 | 2016-03-09 15:36:28 -0800 | [diff] [blame] | 16 | package com.android.emergency.preferences; |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 17 | |
Akshay Kannan | 44ef39d | 2016-01-26 09:08:41 -0800 | [diff] [blame] | 18 | import android.app.AlertDialog; |
mariagpuyol | 27b306e | 2017-03-01 13:14:31 -0800 | [diff] [blame] | 19 | import android.content.ActivityNotFoundException; |
mariagpuyol | e0f631b | 2016-08-16 18:58:26 -0700 | [diff] [blame] | 20 | import android.content.ComponentName; |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 21 | import android.content.Context; |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 22 | import android.content.DialogInterface; |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 23 | import android.content.Intent; |
mariagpuyol | e0f631b | 2016-08-16 18:58:26 -0700 | [diff] [blame] | 24 | import android.content.pm.PackageManager; |
| 25 | import android.content.pm.ResolveInfo; |
mariagpuyol | 95dc040 | 2016-02-17 11:12:46 -0800 | [diff] [blame] | 26 | import android.graphics.drawable.Drawable; |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 27 | import android.net.Uri; |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 28 | import android.os.Bundle; |
| 29 | import android.os.Parcel; |
| 30 | import android.os.Parcelable; |
mariagpuyol | aee2378 | 2016-02-16 13:29:49 -0800 | [diff] [blame] | 31 | import android.support.annotation.NonNull; |
mariagpuyol | 16472ca | 2016-02-16 17:49:26 -0800 | [diff] [blame] | 32 | import android.support.annotation.Nullable; |
Juan Lang | 2c0518a | 2017-05-10 17:00:32 -0700 | [diff] [blame] | 33 | import android.support.v7.preference.Preference; |
| 34 | import android.support.v7.preference.PreferenceViewHolder; |
Tyler Gunn | 1c888f8 | 2018-04-15 22:49:59 -0700 | [diff] [blame] | 35 | import android.telecom.TelecomManager; |
mariagpuyol | 9bc0818 | 2016-05-13 14:54:49 -0700 | [diff] [blame] | 36 | import android.text.BidiFormatter; |
| 37 | import android.text.TextDirectionHeuristics; |
Juan Lang | 2c0518a | 2017-05-10 17:00:32 -0700 | [diff] [blame] | 38 | import android.util.AttributeSet; |
mariagpuyol | 27b306e | 2017-03-01 13:14:31 -0800 | [diff] [blame] | 39 | import android.util.Log; |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 40 | import android.view.View; |
mariagpuyol | 27b306e | 2017-03-01 13:14:31 -0800 | [diff] [blame] | 41 | import android.widget.Toast; |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 42 | |
mariagpuyol | acef32a | 2016-12-12 11:33:20 -0800 | [diff] [blame] | 43 | import com.android.emergency.CircleFramedDrawable; |
mariagpuyol | 5874835 | 2016-03-09 15:36:28 -0800 | [diff] [blame] | 44 | import com.android.emergency.EmergencyContactManager; |
mariagpuyol | 5874835 | 2016-03-09 15:36:28 -0800 | [diff] [blame] | 45 | import com.android.emergency.R; |
mariagpuyol | 9e2eea1 | 2016-04-01 18:10:12 -0700 | [diff] [blame] | 46 | import com.android.internal.annotations.VisibleForTesting; |
Akshay Kannan | 44ef39d | 2016-01-26 09:08:41 -0800 | [diff] [blame] | 47 | import com.android.internal.logging.MetricsLogger; |
Tamas Berghammer | 2fdeb9a | 2016-06-22 15:28:50 +0100 | [diff] [blame] | 48 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Akshay Kannan | 44ef39d | 2016-01-26 09:08:41 -0800 | [diff] [blame] | 49 | |
mariagpuyol | e0f631b | 2016-08-16 18:58:26 -0700 | [diff] [blame] | 50 | import java.util.List; |
| 51 | |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 52 | |
| 53 | /** |
mariagpuyol | 5cf7f73 | 2016-03-08 09:48:15 -0800 | [diff] [blame] | 54 | * A {@link Preference} to display or call a contact using the specified URI string. |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 55 | */ |
| 56 | public class ContactPreference extends Preference { |
| 57 | |
mariagpuyol | 27b306e | 2017-03-01 13:14:31 -0800 | [diff] [blame] | 58 | private static final String TAG = "ContactPreference"; |
| 59 | |
Juan Lang | 6ad3b5f | 2017-06-08 17:14:27 -0700 | [diff] [blame] | 60 | static final ContactFactory DEFAULT_CONTACT_FACTORY = new ContactFactory() { |
| 61 | @Override |
| 62 | public EmergencyContactManager.Contact getContact(Context context, Uri phoneUri) { |
| 63 | return EmergencyContactManager.getContact(context, phoneUri); |
| 64 | } |
| 65 | }; |
| 66 | |
Juan Lang | 9511388 | 2017-05-30 15:20:50 -0700 | [diff] [blame] | 67 | private final ContactFactory mContactFactory; |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 68 | private EmergencyContactManager.Contact mContact; |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 69 | @Nullable private RemoveContactPreferenceListener mRemoveContactPreferenceListener; |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 70 | @Nullable private AlertDialog mRemoveContactDialog; |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 71 | |
| 72 | /** |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 73 | * Listener for removing a contact. |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 74 | */ |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 75 | public interface RemoveContactPreferenceListener { |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 76 | /** |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 77 | * Callback to remove a contact preference. |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 78 | */ |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 79 | void onRemoveContactPreference(ContactPreference preference); |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 80 | } |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 81 | |
| 82 | /** |
Juan Lang | 9511388 | 2017-05-30 15:20:50 -0700 | [diff] [blame] | 83 | * Interface for getting a contact for a phone number Uri. |
| 84 | */ |
| 85 | public interface ContactFactory { |
| 86 | /** |
| 87 | * Gets a {@link EmergencyContactManager.Contact} for a phone {@link Uri}. |
| 88 | * |
| 89 | * @param context The context to use. |
| 90 | * @param phoneUri The phone uri. |
| 91 | * @return a contact for the given phone uri. |
| 92 | */ |
| 93 | EmergencyContactManager.Contact getContact(Context context, Uri phoneUri); |
| 94 | } |
| 95 | |
Juan Lang | 2c0518a | 2017-05-10 17:00:32 -0700 | [diff] [blame] | 96 | public ContactPreference(Context context, AttributeSet attributes) { |
| 97 | super(context, attributes); |
| 98 | mContactFactory = DEFAULT_CONTACT_FACTORY; |
| 99 | } |
| 100 | |
Juan Lang | 9511388 | 2017-05-30 15:20:50 -0700 | [diff] [blame] | 101 | /** |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 102 | * Instantiates a ContactPreference that displays an emergency contact, taking in a Context and |
mariagpuyol | 5cf7f73 | 2016-03-08 09:48:15 -0800 | [diff] [blame] | 103 | * the Uri. |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 104 | */ |
mariagpuyol | 08e2e51 | 2017-03-08 10:00:15 -0800 | [diff] [blame] | 105 | public ContactPreference(Context context, @NonNull Uri phoneUri) { |
Juan Lang | 6ad3b5f | 2017-06-08 17:14:27 -0700 | [diff] [blame] | 106 | this(context, phoneUri, DEFAULT_CONTACT_FACTORY); |
Juan Lang | 9511388 | 2017-05-30 15:20:50 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | @VisibleForTesting |
Juan Lang | 6ad3b5f | 2017-06-08 17:14:27 -0700 | [diff] [blame] | 110 | ContactPreference(Context context, @NonNull Uri phoneUri, |
Juan Lang | 9511388 | 2017-05-30 15:20:50 -0700 | [diff] [blame] | 111 | @NonNull ContactFactory contactFactory) { |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 112 | super(context); |
Juan Lang | 9511388 | 2017-05-30 15:20:50 -0700 | [diff] [blame] | 113 | mContactFactory = contactFactory; |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 114 | setOrder(DEFAULT_ORDER); |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 115 | |
mariagpuyol | 08e2e51 | 2017-03-08 10:00:15 -0800 | [diff] [blame] | 116 | setPhoneUri(phoneUri); |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 117 | |
| 118 | setWidgetLayoutResource(R.layout.preference_user_delete_widget); |
| 119 | setPersistent(false); |
| 120 | } |
| 121 | |
mariagpuyol | 08e2e51 | 2017-03-08 10:00:15 -0800 | [diff] [blame] | 122 | public void setPhoneUri(@NonNull Uri phoneUri) { |
| 123 | if (mContact != null && !phoneUri.equals(mContact.getPhoneUri()) && |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 124 | mRemoveContactDialog != null) { |
| 125 | mRemoveContactDialog.dismiss(); |
| 126 | } |
Juan Lang | 9511388 | 2017-05-30 15:20:50 -0700 | [diff] [blame] | 127 | mContact = mContactFactory.getContact(getContext(), phoneUri); |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 128 | |
mariagpuyol | 5cf7f73 | 2016-03-08 09:48:15 -0800 | [diff] [blame] | 129 | setTitle(mContact.getName()); |
mariagpuyol | 08e2e51 | 2017-03-08 10:00:15 -0800 | [diff] [blame] | 130 | setKey(mContact.getPhoneUri().toString()); |
mariagpuyol | f9ab89a | 2016-03-10 09:19:07 -0800 | [diff] [blame] | 131 | String summary = mContact.getPhoneType() == null ? |
| 132 | mContact.getPhoneNumber() : |
| 133 | String.format( |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 134 | getContext().getResources().getString(R.string.phone_type_and_phone_number), |
mariagpuyol | f9ab89a | 2016-03-10 09:19:07 -0800 | [diff] [blame] | 135 | mContact.getPhoneType(), |
mariagpuyol | 9bc0818 | 2016-05-13 14:54:49 -0700 | [diff] [blame] | 136 | BidiFormatter.getInstance().unicodeWrap(mContact.getPhoneNumber(), |
| 137 | TextDirectionHeuristics.LTR)); |
mariagpuyol | f9ab89a | 2016-03-10 09:19:07 -0800 | [diff] [blame] | 138 | setSummary(summary); |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 139 | |
| 140 | // Update the message to show the correct name. |
| 141 | if (mRemoveContactDialog != null) { |
| 142 | mRemoveContactDialog.setMessage( |
| 143 | String.format(getContext().getString(R.string.remove_contact), |
| 144 | mContact.getName())); |
| 145 | } |
mariagpuyol | 95dc040 | 2016-02-17 11:12:46 -0800 | [diff] [blame] | 146 | |
| 147 | //TODO: Consider doing the following in a non-UI thread. |
mariagpuyol | 9be3265 | 2016-03-16 12:34:53 -0700 | [diff] [blame] | 148 | Drawable icon; |
| 149 | if (mContact.getPhoto() != null) { |
| 150 | icon = new CircleFramedDrawable(mContact.getPhoto(), |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 151 | (int) getContext().getResources().getDimension(R.dimen.circle_avatar_size)); |
mariagpuyol | 9be3265 | 2016-03-16 12:34:53 -0700 | [diff] [blame] | 152 | } else { |
Fan Zhang | 0326efa | 2018-05-15 17:37:34 -0700 | [diff] [blame] | 153 | icon = getContext().getDrawable(R.drawable.ic_account_circle_filled_24dp); |
mariagpuyol | 9be3265 | 2016-03-16 12:34:53 -0700 | [diff] [blame] | 154 | } |
mariagpuyol | 95dc040 | 2016-02-17 11:12:46 -0800 | [diff] [blame] | 155 | setIcon(icon); |
| 156 | } |
| 157 | |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 158 | /** Listener to be informed when a contact preference should be deleted. */ |
| 159 | public void setRemoveContactPreferenceListener( |
| 160 | RemoveContactPreferenceListener removeContactListener) { |
| 161 | mRemoveContactPreferenceListener = removeContactListener; |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 162 | if (mRemoveContactPreferenceListener == null) { |
| 163 | mRemoveContactDialog = null; |
| 164 | return; |
| 165 | } |
| 166 | if (mRemoveContactDialog != null) { |
| 167 | return; |
| 168 | } |
| 169 | // Create the remove contact dialog |
| 170 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); |
| 171 | builder.setNegativeButton(getContext().getString(R.string.cancel), null); |
| 172 | builder.setPositiveButton(getContext().getString(R.string.remove), |
| 173 | new DialogInterface.OnClickListener() { |
| 174 | @Override |
| 175 | public void onClick(DialogInterface dialogInterface, |
| 176 | int which) { |
| 177 | if (mRemoveContactPreferenceListener != null) { |
| 178 | mRemoveContactPreferenceListener |
| 179 | .onRemoveContactPreference(ContactPreference.this); |
| 180 | } |
| 181 | } |
| 182 | }); |
| 183 | builder.setMessage(String.format(getContext().getString(R.string.remove_contact), |
| 184 | mContact.getName())); |
| 185 | mRemoveContactDialog = builder.create(); |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 186 | } |
| 187 | |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 188 | @Override |
Juan Lang | 2c0518a | 2017-05-10 17:00:32 -0700 | [diff] [blame] | 189 | public void onBindViewHolder(PreferenceViewHolder holder) { |
| 190 | super.onBindViewHolder(holder); |
| 191 | View deleteContactIcon = holder.findViewById(R.id.delete_contact); |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 192 | if (mRemoveContactPreferenceListener == null) { |
mariagpuyol | 16472ca | 2016-02-16 17:49:26 -0800 | [diff] [blame] | 193 | deleteContactIcon.setVisibility(View.GONE); |
| 194 | } else { |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 195 | deleteContactIcon.setOnClickListener(new View.OnClickListener() { |
| 196 | @Override |
| 197 | public void onClick(View view) { |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 198 | showRemoveContactDialog(null); |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 199 | } |
| 200 | }); |
| 201 | |
mariagpuyol | d19ace5 | 2016-02-12 10:37:26 -0800 | [diff] [blame] | 202 | } |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 203 | } |
| 204 | |
mariagpuyol | 08e2e51 | 2017-03-08 10:00:15 -0800 | [diff] [blame] | 205 | public Uri getPhoneUri() { |
| 206 | return mContact.getPhoneUri(); |
mariagpuyol | 609f68a | 2016-02-22 17:45:47 -0800 | [diff] [blame] | 207 | } |
| 208 | |
mariagpuyol | 9e2eea1 | 2016-04-01 18:10:12 -0700 | [diff] [blame] | 209 | @VisibleForTesting |
| 210 | EmergencyContactManager.Contact getContact() { |
| 211 | return mContact; |
| 212 | } |
| 213 | |
| 214 | @VisibleForTesting |
| 215 | AlertDialog getRemoveContactDialog() { |
| 216 | return mRemoveContactDialog; |
| 217 | } |
| 218 | |
Akshay Kannan | cdb6c14 | 2016-01-20 18:25:44 -0800 | [diff] [blame] | 219 | /** |
Akshay Kannan | 44ef39d | 2016-01-26 09:08:41 -0800 | [diff] [blame] | 220 | * Calls the contact. |
| 221 | */ |
mariagpuyol | 5cf7f73 | 2016-03-08 09:48:15 -0800 | [diff] [blame] | 222 | public void callContact() { |
Tyler Gunn | 1c888f8 | 2018-04-15 22:49:59 -0700 | [diff] [blame] | 223 | // Use TelecomManager to place the call; this APK has CALL_PRIVILEGED permission so it will |
| 224 | // be able to call emergency numbers. |
| 225 | TelecomManager tm = (TelecomManager) getContext().getSystemService(Context.TELECOM_SERVICE); |
| 226 | tm.placeCall(Uri.parse("tel:" + mContact.getPhoneNumber()), null); |
mariagpuyol | 5cf7f73 | 2016-03-08 09:48:15 -0800 | [diff] [blame] | 227 | MetricsLogger.action(getContext(), MetricsEvent.ACTION_CALL_EMERGENCY_CONTACT); |
mariagpuyol | 0504a44 | 2016-02-17 16:22:57 -0800 | [diff] [blame] | 228 | } |
mariagpuyol | 36b3f9d | 2016-03-11 16:02:31 -0800 | [diff] [blame] | 229 | |
| 230 | /** |
| 231 | * Displays a contact card for the contact. |
| 232 | */ |
| 233 | public void displayContact() { |
mariagpuyol | 27b306e | 2017-03-01 13:14:31 -0800 | [diff] [blame] | 234 | Intent displayIntent = new Intent(Intent.ACTION_VIEW); |
| 235 | displayIntent.setData(mContact.getContactLookupUri()); |
| 236 | try { |
| 237 | getContext().startActivity(displayIntent); |
| 238 | } catch (ActivityNotFoundException e) { |
| 239 | Toast.makeText(getContext(), |
| 240 | getContext().getString(R.string.fail_display_contact), |
| 241 | Toast.LENGTH_LONG).show(); |
| 242 | Log.w(TAG, "No contact app available to display the contact", e); |
| 243 | return; |
| 244 | } |
| 245 | |
mariagpuyol | 36b3f9d | 2016-03-11 16:02:31 -0800 | [diff] [blame] | 246 | } |
mariagpuyol | 53745bf | 2016-03-23 14:43:55 -0700 | [diff] [blame] | 247 | |
| 248 | /** Shows the dialog to remove the contact, restoring it from {@code state} if it's not null. */ |
| 249 | private void showRemoveContactDialog(Bundle state) { |
| 250 | if (mRemoveContactDialog == null) { |
| 251 | return; |
| 252 | } |
| 253 | if (state != null) { |
| 254 | mRemoveContactDialog.onRestoreInstanceState(state); |
| 255 | } |
| 256 | mRemoveContactDialog.show(); |
| 257 | } |
| 258 | |
| 259 | @Override |
| 260 | protected Parcelable onSaveInstanceState() { |
| 261 | final Parcelable superState = super.onSaveInstanceState(); |
| 262 | if (mRemoveContactDialog == null || !mRemoveContactDialog.isShowing()) { |
| 263 | return superState; |
| 264 | } |
| 265 | final SavedState myState = new SavedState(superState); |
| 266 | myState.isDialogShowing = true; |
| 267 | myState.dialogBundle = mRemoveContactDialog.onSaveInstanceState(); |
| 268 | return myState; |
| 269 | } |
| 270 | |
| 271 | @Override |
| 272 | protected void onRestoreInstanceState(Parcelable state) { |
| 273 | if (state == null || !state.getClass().equals(SavedState.class)) { |
| 274 | // Didn't save state for us in onSaveInstanceState |
| 275 | super.onRestoreInstanceState(state); |
| 276 | return; |
| 277 | } |
| 278 | SavedState myState = (SavedState) state; |
| 279 | super.onRestoreInstanceState(myState.getSuperState()); |
| 280 | if (myState.isDialogShowing) { |
| 281 | showRemoveContactDialog(myState.dialogBundle); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | private static class SavedState extends BaseSavedState { |
| 286 | boolean isDialogShowing; |
| 287 | Bundle dialogBundle; |
| 288 | |
| 289 | public SavedState(Parcel source) { |
| 290 | super(source); |
| 291 | isDialogShowing = source.readInt() == 1; |
| 292 | dialogBundle = source.readBundle(); |
| 293 | } |
| 294 | |
| 295 | @Override |
| 296 | public void writeToParcel(Parcel dest, int flags) { |
| 297 | super.writeToParcel(dest, flags); |
| 298 | dest.writeInt(isDialogShowing ? 1 : 0); |
| 299 | dest.writeBundle(dialogBundle); |
| 300 | } |
| 301 | |
| 302 | public SavedState(Parcelable superState) { |
| 303 | super(superState); |
| 304 | } |
| 305 | |
| 306 | public static final Parcelable.Creator<SavedState> CREATOR = |
| 307 | new Parcelable.Creator<SavedState>() { |
| 308 | public SavedState createFromParcel(Parcel in) { |
| 309 | return new SavedState(in); |
| 310 | } |
| 311 | |
| 312 | public SavedState[] newArray(int size) { |
| 313 | return new SavedState[size]; |
| 314 | } |
| 315 | }; |
| 316 | } |
mariagpuyol | e0f631b | 2016-08-16 18:58:26 -0700 | [diff] [blame] | 317 | } |