|
29 | 29 | import android.widget.Toast; |
30 | 30 |
|
31 | 31 | public class PlatLogoActivity extends Activity { |
32 | | - Vibrator mZzz; |
33 | 32 | Toast mToast; |
34 | 33 | ImageView mContent; |
35 | 34 | int mCount; |
36 | 35 | final Handler mHandler = new Handler(); |
37 | 36 |
|
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 | 37 | @Override |
64 | 38 | protected void onCreate(Bundle savedInstanceState) { |
65 | 39 | super.onCreate(savedInstanceState); |
66 | 40 |
|
67 | | - mZzz = (Vibrator)getSystemService(VIBRATOR_SERVICE); |
68 | | - mToast = Toast.makeText(this, "Android 4.0: Ice Cream Sandwich", Toast.LENGTH_SHORT); |
| 41 | + mToast = Toast.makeText(this, "Android X.X: Jelly Bean", Toast.LENGTH_SHORT); |
69 | 42 |
|
70 | 43 | mContent = new ImageView(this); |
71 | 44 | mContent.setImageResource(com.android.internal.R.drawable.platlogo); |
72 | 45 | mContent.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
73 | 46 |
|
74 | | - mContent.setOnTouchListener(new View.OnTouchListener() { |
| 47 | + mContent.setOnClickListener(new View.OnClickListener() { |
75 | 48 | @Override |
76 | | - public boolean onTouch(View v, MotionEvent event) { |
77 | | - final int action = event.getAction(); |
78 | | - if (action == MotionEvent.ACTION_DOWN) { |
79 | | - mContent.setPressed(true); |
80 | | - mHandler.removeCallbacks(mSuperLongPress); |
81 | | - mCount = 0; |
82 | | - mHandler.postDelayed(mSuperLongPress, 2*ViewConfiguration.getLongPressTimeout()); |
83 | | - } else if (action == MotionEvent.ACTION_UP) { |
84 | | - if (mContent.isPressed()) { |
85 | | - mContent.setPressed(false); |
86 | | - mHandler.removeCallbacks(mSuperLongPress); |
87 | | - mToast.show(); |
88 | | - } |
| 49 | + public void onClick(View v) { |
| 50 | + mToast.show(); |
| 51 | + mContent.setImageResource(com.android.internal.R.drawable.platlogo_alt); |
| 52 | + } |
| 53 | + }); |
| 54 | + |
| 55 | + mContent.setOnLongClickListener(new View.OnLongClickListener() { |
| 56 | + @Override |
| 57 | + public boolean onLongClick(View v) { |
| 58 | + try { |
| 59 | + startActivity(new Intent(Intent.ACTION_MAIN) |
| 60 | + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 61 | + | Intent.FLAG_ACTIVITY_CLEAR_TASK |
| 62 | + | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) |
| 63 | + .addCategory("com.android.internal.category.PLATLOGO")); |
| 64 | + //.setClassName("com.android.systemui","com.android.systemui.BeanBag")); |
| 65 | + } catch (ActivityNotFoundException ex) { |
| 66 | + android.util.Log.e("PlatLogoActivity", "Couldn't find a bag of beans."); |
89 | 67 | } |
| 68 | + finish(); |
90 | 69 | return true; |
91 | 70 | } |
92 | 71 | }); |
|
0 commit comments