1 /* 2 * Copyright (C) 2008 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.settings; 18 19 import com.android.internal.widget.LockPatternUtils; 20 21 import android.app.Activity; 22 import android.content.Intent; 23 import android.os.Bundle; 24 import android.view.View; 25 26 public class ChooseLockPatternTutorial extends Activity implements View.OnClickListener { 27 private static final int REQUESTCODE_EXAMPLE = 1; 28 29 private View mNextButton; 30 private View mSkipButton; 31 32 @Override onCreate(Bundle savedInstanceState)33 protected void onCreate(Bundle savedInstanceState) { 34 super.onCreate(savedInstanceState); 35 // Don't show the tutorial if the user has seen it before. 36 LockPatternUtils lockPatternUtils = new LockPatternUtils(getContentResolver()); 37 if (savedInstanceState == null && lockPatternUtils.isPatternEverChosen()) { 38 Intent intent = new Intent(); 39 intent.setClassName("com.android.settings", "com.android.settings.ChooseLockPattern"); 40 startActivity(intent); 41 finish(); 42 } else { 43 initViews(); 44 } 45 } 46 initViews()47 private void initViews() { 48 setContentView(R.layout.choose_lock_pattern_tutorial); 49 mNextButton = findViewById(R.id.next_button); 50 mNextButton.setOnClickListener(this); 51 mSkipButton = findViewById(R.id.skip_button); 52 mSkipButton.setOnClickListener(this); 53 } 54 onClick(View v)55 public void onClick(View v) { 56 if (v == mSkipButton) { 57 // Canceling, so finish all 58 setResult(ChooseLockPattern.RESULT_FINISHED); 59 finish(); 60 } else if (v == mNextButton) { 61 startActivityForResult(new Intent(this, ChooseLockPatternExample.class), 62 REQUESTCODE_EXAMPLE); 63 } 64 } 65 66 @Override onActivityResult(int requestCode, int resultCode, Intent data)67 protected void onActivityResult(int requestCode, int resultCode, Intent data) { 68 if (requestCode == REQUESTCODE_EXAMPLE && resultCode == ChooseLockPattern.RESULT_FINISHED) { 69 setResult(resultCode); 70 finish(); 71 } 72 } 73 74 } 75 76