Home | History | Annotate | Download | only in app
      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.graphics.Typeface;
     23 import android.os.Build;
     24 import android.os.Bundle;
     25 import android.os.Handler;
     26 import android.util.DisplayMetrics;
     27 import android.view.Gravity;
     28 import android.view.View;
     29 import android.view.ViewGroup;
     30 import android.widget.ImageView;
     31 import android.widget.LinearLayout;
     32 import android.widget.TextView;
     33 import android.widget.Toast;
     34 
     35 public class PlatLogoActivity extends Activity {
     36     Toast mToast;
     37     ImageView mContent;
     38     int mCount;
     39     final Handler mHandler = new Handler();
     40 
     41     private View makeView() {
     42         DisplayMetrics metrics = new DisplayMetrics();
     43         getWindowManager().getDefaultDisplay().getMetrics(metrics);
     44 
     45         LinearLayout view = new LinearLayout(this);
     46         view.setOrientation(LinearLayout.VERTICAL);
     47         view.setLayoutParams(
     48                 new ViewGroup.LayoutParams(
     49                     ViewGroup.LayoutParams.WRAP_CONTENT,
     50                     ViewGroup.LayoutParams.WRAP_CONTENT
     51                 ));
     52         final int p = (int)(8 * metrics.density);
     53         view.setPadding(p, p, p, p);
     54 
     55         Typeface light = Typeface.create("sans-serif-light", Typeface.NORMAL);
     56         Typeface normal = Typeface.create("sans-serif", Typeface.BOLD);
     57 
     58         final float size = 14 * metrics.density;
     59         final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
     60                 LinearLayout.LayoutParams.WRAP_CONTENT,
     61                 LinearLayout.LayoutParams.WRAP_CONTENT);
     62         lp.gravity = Gravity.CENTER_HORIZONTAL;
     63         lp.bottomMargin = (int) (-4*metrics.density);
     64 
     65         TextView tv = new TextView(this);
     66         if (light != null) tv.setTypeface(light);
     67         tv.setTextSize(1.25f*size);
     68         tv.setTextColor(0xFFFFFFFF);
     69         tv.setShadowLayer(4*metrics.density, 0, 2*metrics.density, 0x66000000);
     70         tv.setText("Android " + Build.VERSION.RELEASE);
     71         view.addView(tv, lp);
     72 
     73         tv = new TextView(this);
     74         if (normal != null) tv.setTypeface(normal);
     75         tv.setTextSize(size);
     76         tv.setTextColor(0xFFFFFFFF);
     77         tv.setShadowLayer(4*metrics.density, 0, 2*metrics.density, 0x66000000);
     78         tv.setText("JELLY BEAN");
     79         view.addView(tv, lp);
     80 
     81         return view;
     82     }
     83 
     84     @Override
     85     protected void onCreate(Bundle savedInstanceState) {
     86         super.onCreate(savedInstanceState);
     87 
     88         mToast = Toast.makeText(this, "", Toast.LENGTH_LONG);
     89         mToast.setView(makeView());
     90 
     91         DisplayMetrics metrics = new DisplayMetrics();
     92         getWindowManager().getDefaultDisplay().getMetrics(metrics);
     93 
     94         mContent = new ImageView(this);
     95         mContent.setImageResource(com.android.internal.R.drawable.platlogo_alt);
     96         mContent.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
     97 
     98         final int p = (int)(32 * metrics.density);
     99         mContent.setPadding(p, p, p, p);
    100 
    101         mContent.setOnClickListener(new View.OnClickListener() {
    102             @Override
    103             public void onClick(View v) {
    104                 mToast.show();
    105                 mContent.setImageResource(com.android.internal.R.drawable.platlogo);
    106             }
    107         });
    108 
    109         mContent.setOnLongClickListener(new View.OnLongClickListener() {
    110             @Override
    111             public boolean onLongClick(View v) {
    112                 try {
    113                     startActivity(new Intent(Intent.ACTION_MAIN)
    114                         .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
    115                             | Intent.FLAG_ACTIVITY_CLEAR_TASK
    116                             | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
    117                         .addCategory("com.android.internal.category.PLATLOGO"));
    118                         //.setClassName("com.android.systemui","com.android.systemui.BeanBag"));
    119                 } catch (ActivityNotFoundException ex) {
    120                     android.util.Log.e("PlatLogoActivity", "Couldn't find a bag of beans.");
    121                 }
    122                 finish();
    123                 return true;
    124             }
    125         });
    126 
    127         setContentView(mContent);
    128     }
    129 }
    130