| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The CyanogenMod Project |
| 3 | * Copyright (C) 2017 The LineageOS Project |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 18 | package org.lineageos.setupwizard; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 19 | |
| 20 | import android.os.Bundle; |
| 21 | import android.widget.ImageView; |
| 22 | |
| 23 | import com.android.setupwizardlib.util.ResultCodes; |
| 24 | |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 25 | import org.lineageos.setupwizard.util.PhoneMonitor; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 26 | |
| 27 | public class SimMissingActivity extends BaseSetupWizardActivity { |
| 28 | |
| 29 | public static final String TAG = SimMissingActivity.class.getSimpleName(); |
| 30 | |
| 31 | private static final int SIM_DEFAULT = 0; |
| 32 | private static final int SIM_SIDE = 1; |
| 33 | private static final int SIM_BACK = 2; |
| 34 | |
| 35 | private PhoneMonitor mPhoneMonitor; |
| 36 | |
| 37 | @Override |
| 38 | protected void onCreate(Bundle savedInstanceState) { |
| 39 | super.onCreate(savedInstanceState); |
| 40 | mPhoneMonitor = PhoneMonitor.getInstance(); |
| 41 | if (!mPhoneMonitor.simMissing()) { |
| 42 | finishAction(RESULT_OK); |
| 43 | } |
| 44 | setNextText(R.string.skip); |
| 45 | final int simLocation = getResources().getInteger( |
| 46 | R.integer.sim_image_type); |
| 47 | ImageView simLogo = ((ImageView)findViewById(R.id.sim_slot_image)); |
| 48 | switch (simLocation) { |
| 49 | case SIM_SIDE: |
| 50 | simLogo.setImageResource(R.drawable.sim_side); |
| 51 | break; |
| 52 | case SIM_BACK: |
| 53 | simLogo.setImageResource(R.drawable.sim_back); |
| 54 | break; |
| 55 | default: |
| 56 | simLogo.setImageResource(R.drawable.sim); |
| 57 | simLogo.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public void onNavigateNext() { |
| 63 | if (mPhoneMonitor.simMissing()) { |
| 64 | nextAction(ResultCodes.RESULT_SKIP); |
| 65 | } else { |
| 66 | super.onNavigateNext(); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | protected int getTransition() { |
| 72 | return TRANSITION_ID_SLIDE; |
| 73 | } |
| 74 | |
| 75 | @Override |
| 76 | protected int getLayoutResId() { |
| 77 | return R.layout.sim_missing_page; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | protected int getTitleResId() { |
| 82 | return R.string.setup_sim_missing; |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | protected int getIconResId() { |
| 87 | return R.drawable.ic_sim; |
| 88 | } |
| 89 | |
| 90 | } |