• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 
17 package com.android.phone;
18 
19 import android.app.Activity;
20 import android.app.Fragment;
21 import android.app.FragmentManager;
22 import android.content.Context;
23 import android.content.Intent;
24 import android.os.Bundle;
25 import android.util.Log;
26 import android.view.MenuItem;
27 
28 
29 /**
30  * Activity associated with NetworkSelectSetting fragment
31  */
32 public class NetworkSelectSettingActivity extends Activity {
33     private static final String TAG = "NetworkSelectSettingActivity";
34     public static final String KEY_PHONE_ID = "phone_id";
35 
36     /**
37      * Returns the Android Intent that led to this Activity being created.
38      */
getIntent(Context context, int phoneId)39     public static Intent getIntent(Context context, int phoneId) {
40         Intent intent = new Intent(context, NetworkSelectSettingActivity.class);
41         intent.putExtra(KEY_PHONE_ID, phoneId);
42         return intent;
43     }
44 
45     @Override
onCreate(Bundle savedState)46     public void onCreate(Bundle savedState) {
47         Log.d(TAG, "onCreate()");
48         super.onCreate(savedState);
49         int phoneId = getIntent().getExtras().getInt(KEY_PHONE_ID);
50         setContentView(R.layout.choose_network);
51 
52         FragmentManager fragmentManager = getFragmentManager();
53         Fragment fragment = fragmentManager.findFragmentById(R.id.choose_network_content);
54         if (fragment == null) {
55             fragmentManager.beginTransaction()
56                     .add(R.id.choose_network_content,
57                             NetworkSelectSetting.newInstance(phoneId), TAG)
58                     .commit();
59         }
60     }
61 
62     @Override
onOptionsItemSelected(MenuItem item)63     public boolean onOptionsItemSelected(MenuItem item) {
64         final int itemId = item.getItemId();
65         if (itemId == android.R.id.home) {
66             onBackPressed();
67             return true;
68         }
69         return super.onOptionsItemSelected(item);
70     }
71 }
72