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  */
16 package com.android.contacts.activities;
17 
18 import android.app.Fragment;
19 import android.app.FragmentManager;
20 import android.os.Bundle;
21 
22 import com.android.contacts.AppCompatContactsActivity;
23 import com.android.contacts.R;
24 import com.android.contacts.SimImportFragment;
25 import com.android.contacts.model.SimCard;
26 
27 /**
28  * Host activity for SimImportFragment
29  *
30  * Initially SimImportFragment was a DialogFragment but there were accessibility issues with
31  * that so it was changed to an activity
32  */
33 public class SimImportActivity extends AppCompatContactsActivity {
34 
35     public static final String EXTRA_SUBSCRIPTION_ID = "extraSubscriptionId";
36 
37     @Override
onCreate(Bundle savedInstanceState)38     protected void onCreate(Bundle savedInstanceState) {
39         super.onCreate(savedInstanceState);
40         setContentView(R.layout.sim_import_activity);
41         final FragmentManager fragmentManager = getFragmentManager();
42         Fragment fragment = fragmentManager.findFragmentByTag("SimImport");
43         if (fragment == null) {
44             fragment = SimImportFragment.newInstance(getIntent().getIntExtra(EXTRA_SUBSCRIPTION_ID,
45                     SimCard.NO_SUBSCRIPTION_ID));
46             fragmentManager.beginTransaction().add(R.id.root, fragment, "SimImport").commit();
47         }
48     }
49 }
50