1 /* 2 * Copyright (C) 2010 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.internal.app; 18 19 import android.app.Activity; 20 import android.content.ActivityNotFoundException; 21 import android.content.Intent; 22 import android.os.Bundle; 23 import android.os.Handler; 24 import android.os.Vibrator; 25 import android.view.MotionEvent; 26 import android.view.View; 27 import android.view.ViewConfiguration; 28 import android.widget.ImageView; 29 import android.widget.Toast; 30 31 public class PlatLogoActivity extends Activity { 32 Toast mToast; 33 ImageView mContent; 34 Vibrator mZzz = new Vibrator(); 35 int mCount; 36 final Handler mHandler = new Handler(); 37 38 Runnable mSuperLongPress = new Runnable() { 39 public void run() { 40 mCount++; 41 mZzz.vibrate(50 * mCount); 42 final float scale = 1f + 0.25f * mCount * mCount; 43 mContent.setScaleX(scale); 44 mContent.setScaleY(scale); 45 46 if (mCount <= 3) { 47 mHandler.postDelayed(mSuperLongPress, ViewConfiguration.getLongPressTimeout()); 48 } else { 49 try { 50 startActivity(new Intent(Intent.ACTION_MAIN) 51 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 52 | Intent.FLAG_ACTIVITY_CLEAR_TASK 53 | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) 54 .setClassName("com.android.systemui","com.android.systemui.Nyandroid")); 55 } catch (ActivityNotFoundException ex) { 56 android.util.Log.e("PlatLogoActivity", "Couldn't find platlogo screensaver."); 57 } 58 finish(); 59 } 60 } 61 }; 62 63 @Override 64 protected void onCreate(Bundle savedInstanceState) { 65 super.onCreate(savedInstanceState); 66 67 mToast = Toast.makeText(this, "Android 4.0: Ice Cream Sandwich", Toast.LENGTH_SHORT); 68 69 mContent = new ImageView(this); 70 mContent.setImageResource(com.android.internal.R.drawable.platlogo); 71 mContent.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 72 73 mContent.setOnTouchListener(new View.OnTouchListener() { 74 @Override 75 public boolean onTouch(View v, MotionEvent event) { 76 final int action = event.getAction(); 77 if (action == MotionEvent.ACTION_DOWN) { 78 mContent.setPressed(true); 79 mHandler.removeCallbacks(mSuperLongPress); 80 mCount = 0; 81 mHandler.postDelayed(mSuperLongPress, 2*ViewConfiguration.getLongPressTimeout()); 82 } else if (action == MotionEvent.ACTION_UP) { 83 if (mContent.isPressed()) { 84 mContent.setPressed(false); 85 mHandler.removeCallbacks(mSuperLongPress); 86 mToast.show(); 87 } 88 } 89 return true; 90 } 91 }); 92 93 setContentView(mContent); 94 } 95 } 96