PlatLogoActivity.java revision a30b7035cec9d6d2bfc6a48889dc803695b26f36
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 17package com.android.internal.app; 18 19import android.app.Activity; 20import android.content.ActivityNotFoundException; 21import android.content.Context; 22import android.content.Intent; 23import android.graphics.Typeface; 24import android.os.Build; 25import android.os.Bundle; 26import android.os.Handler; 27import android.text.method.AllCapsTransformationMethod; 28import android.text.method.TransformationMethod; 29import android.util.DisplayMetrics; 30import android.view.Gravity; 31import android.view.View; 32import android.view.ViewGroup; 33import android.view.animation.DecelerateInterpolator; 34import android.widget.FrameLayout; 35import android.widget.ImageView; 36import android.widget.LinearLayout; 37import android.widget.TextView; 38import android.widget.Toast; 39 40public class PlatLogoActivity extends Activity { 41 FrameLayout mContent; 42 int mCount; 43 final Handler mHandler = new Handler(); 44 45 @Override 46 protected void onCreate(Bundle savedInstanceState) { 47 super.onCreate(savedInstanceState); 48 49 DisplayMetrics metrics = new DisplayMetrics(); 50 getWindowManager().getDefaultDisplay().getMetrics(metrics); 51 52 Typeface bold = Typeface.create("sans-serif", Typeface.BOLD); 53 Typeface light = Typeface.create("sans-serif-light", Typeface.NORMAL); 54 55 mContent = new FrameLayout(this); 56 57 final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams( 58 FrameLayout.LayoutParams.WRAP_CONTENT, 59 FrameLayout.LayoutParams.WRAP_CONTENT); 60 lp.gravity = Gravity.CENTER; 61 62 final ImageView logo = new ImageView(this); 63 logo.setImageResource(com.android.internal.R.drawable.platlogo); 64 logo.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 65 logo.setVisibility(View.INVISIBLE); 66 67 final TextView letter = new TextView(this); 68 69 letter.setTypeface(bold); 70 letter.setTextSize(300); 71 letter.setTextColor(0xFFFFFFFF); 72 letter.setGravity(Gravity.CENTER); 73 letter.setText(String.valueOf(Build.VERSION.RELEASE).substring(0, 1)); 74 75 final int p = (int)(4 * metrics.density); 76 77 final TextView tv = new TextView(this); 78 if (light != null) tv.setTypeface(light); 79 tv.setTextSize(30); 80 tv.setPadding(p, p, p, p); 81 tv.setTextColor(0xFFFFFFFF); 82 tv.setGravity(Gravity.CENTER); 83 tv.setTransformationMethod(new AllCapsTransformationMethod(this)); 84 tv.setText("Android " + Build.VERSION.RELEASE); 85 tv.setVisibility(View.INVISIBLE); 86 87 mContent.addView(letter, lp); 88 mContent.addView(logo, lp); 89 90 final FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(lp); 91 lp2.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; 92 lp2.bottomMargin = 10*p; 93 94 mContent.addView(tv, lp2); 95 96 mContent.setOnClickListener(new View.OnClickListener() { 97 @Override 98 public void onClick(View v) { 99 if (logo.getVisibility() != View.VISIBLE) { 100 letter.animate().alpha(0.25f).scaleY(0.75f).scaleX(0.75f).setDuration(2000) 101 .start(); 102 logo.setAlpha(0f); 103 logo.setVisibility(View.VISIBLE); 104 logo.animate().alpha(1f).setDuration(1000).setStartDelay(500).start(); 105 tv.setAlpha(0f); 106 tv.setVisibility(View.VISIBLE); 107 tv.animate().alpha(1f).setDuration(1000).setStartDelay(1000).start(); 108 } 109 } 110 }); 111 112 mContent.setOnLongClickListener(new View.OnLongClickListener() { 113 @Override 114 public boolean onLongClick(View v) { 115 try { 116 startActivity(new Intent(Intent.ACTION_MAIN) 117 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 118 | Intent.FLAG_ACTIVITY_CLEAR_TASK 119 | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) 120 .addCategory("com.android.internal.category.PLATLOGO")); 121 } catch (ActivityNotFoundException ex) { 122 android.util.Log.e("PlatLogoActivity", "Couldn't find a piece of pie."); 123 } 124 finish(); 125 return true; 126 } 127 }); 128 129 setContentView(mContent); 130 } 131} 132