PlatLogoActivity.java revision 06c0e408c4f06fdb9a5785baebeb293391711e65
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.setShadowLayer(12*metrics.density, 0, 0, 0xC085F985);
74        letter.setText(String.valueOf(Build.VERSION.RELEASE).substring(0, 1));
75
76        final int p = (int)(4 * metrics.density);
77
78        final TextView tv = new TextView(this);
79        if (light != null) tv.setTypeface(light);
80        tv.setTextSize(30);
81        tv.setPadding(p, p, p, p);
82        tv.setTextColor(0xFFFFFFFF);
83        tv.setGravity(Gravity.CENTER);
84        tv.setShadowLayer(4 * metrics.density, 0, 2 * metrics.density, 0x66000000);
85        tv.setTransformationMethod(new AllCapsTransformationMethod(this));
86        tv.setText("Android " + Build.VERSION.RELEASE);
87        tv.setVisibility(View.INVISIBLE);
88
89        mContent.addView(letter, lp);
90        mContent.addView(logo, lp);
91
92        final FrameLayout.LayoutParams lp2 = new FrameLayout.LayoutParams(lp);
93        lp2.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
94        lp2.bottomMargin = 10*p;
95
96        mContent.addView(tv, lp2);
97
98        mContent.setOnClickListener(new View.OnClickListener() {
99            @Override
100            public void onClick(View v) {
101                if (logo.getVisibility() != View.VISIBLE) {
102                    letter.animate().alpha(0.25f).scaleY(0.75f).scaleX(0.75f).setDuration(2000)
103                            .start();
104                    logo.setAlpha(0f);
105                    logo.setVisibility(View.VISIBLE);
106                    logo.animate().alpha(1f).setDuration(1000).setStartDelay(500).start();
107                    tv.setAlpha(0f);
108                    tv.setVisibility(View.VISIBLE);
109                    tv.animate().alpha(1f).setDuration(1000).setStartDelay(1000).start();
110                }
111            }
112        });
113
114        mContent.setOnLongClickListener(new View.OnLongClickListener() {
115            @Override
116            public boolean onLongClick(View v) {
117                try {
118                    startActivity(new Intent(Intent.ACTION_MAIN)
119                        .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
120                            | Intent.FLAG_ACTIVITY_CLEAR_TASK
121                            | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
122                        .addCategory("com.android.internal.category.PLATLOGO"));
123                } catch (ActivityNotFoundException ex) {
124                    android.util.Log.e("PlatLogoActivity", "Couldn't find a piece of pie.");
125                }
126                finish();
127                return true;
128            }
129        });
130
131        setContentView(mContent);
132    }
133}
134