Home | History | Annotate | Download | only in development
      1 /* //device/apps/Settings/src/com/android/settings/Keyguard.java
      2 **
      3 ** Copyright 2006, The Android Open Source Project
      4 **
      5 ** Licensed under the Apache License, Version 2.0 (the "License");
      6 ** you may not use this file except in compliance with the License.
      7 ** You may obtain a copy of the License at
      8 **
      9 **     http://www.apache.org/licenses/LICENSE-2.0
     10 **
     11 ** Unless required by applicable law or agreed to in writing, software
     12 ** distributed under the License is distributed on an "AS IS" BASIS,
     13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 ** See the License for the specific language governing permissions and
     15 ** limitations under the License.
     16 */
     17 
     18 package com.android.development;
     19 
     20 import android.app.Activity;
     21 import android.content.ComponentName;
     22 import android.content.Intent;
     23 import android.content.pm.ActivityInfo;
     24 import android.content.pm.PackageManager;
     25 import android.content.res.Resources;
     26 import android.provider.Settings;
     27 import android.os.Bundle;
     28 import android.view.View;
     29 import android.view.View.OnClickListener;
     30 import android.widget.Button;
     31 import android.widget.ImageView;
     32 import android.widget.TextView;
     33 
     34 
     35 public class ShowActivity extends Activity {
     36 
     37     private ActivityInfo mActivityInfo;
     38 
     39     private TextView mPackage;
     40     private ImageView mIconImage;
     41     private TextView mClass;
     42     private TextView mLabel;
     43     private TextView mLaunch;
     44     private TextView mProcess;
     45     private TextView mTaskAffinity;
     46     private TextView mPermission;
     47     private TextView mMultiprocess;
     48     private TextView mClearOnBackground;
     49     private TextView mStateNotNeeded;
     50 
     51     public void onCreate(Bundle icicle) {
     52         super.onCreate(icicle);
     53 
     54         setContentView(R.layout.show_activity);
     55 
     56         mPackage = (TextView)findViewById(R.id.packageView);
     57         mIconImage = (ImageView)findViewById(R.id.icon);
     58         mClass = (TextView)findViewById(R.id.classView);
     59         mLabel = (TextView)findViewById(R.id.label);
     60         mLaunch = (TextView)findViewById(R.id.launch);
     61         mProcess = (TextView)findViewById(R.id.process);
     62         mTaskAffinity = (TextView)findViewById(R.id.taskAffinity);
     63         mPermission = (TextView)findViewById(R.id.permission);
     64         mMultiprocess = (TextView)findViewById(R.id.multiprocess);
     65         mClearOnBackground = (TextView)findViewById(R.id.clearOnBackground);
     66         mStateNotNeeded = (TextView)findViewById(R.id.stateNotNeeded);
     67 
     68         final PackageManager pm = getPackageManager();
     69         try {
     70             mActivityInfo = pm.getActivityInfo(ComponentName.unflattenFromString(
     71                 getIntent().getData().getSchemeSpecificPart()), 0);
     72         } catch (PackageManager.NameNotFoundException e) {
     73         }
     74         if (mActivityInfo != null) {
     75             mPackage.setText(mActivityInfo.applicationInfo.packageName);
     76             mIconImage.setImageDrawable(mActivityInfo.loadIcon(pm));
     77             if (mActivityInfo.name.startsWith(
     78                     mActivityInfo.applicationInfo.packageName + ".")) {
     79                 mClass.setText(mActivityInfo.name.substring(
     80                         mActivityInfo.applicationInfo.packageName.length()));
     81             } else {
     82                 mClass.setText(mActivityInfo.name);
     83             }
     84             CharSequence label = mActivityInfo.loadLabel(pm);
     85             mLabel.setText("\"" + (label != null ? label : "") + "\"");
     86             switch (mActivityInfo.launchMode) {
     87             case ActivityInfo.LAUNCH_MULTIPLE:
     88                 mLaunch.setText(getText(R.string.launch_multiple));
     89                 break;
     90             case ActivityInfo.LAUNCH_SINGLE_TOP:
     91                 mLaunch.setText(getText(R.string.launch_singleTop));
     92                 break;
     93             case ActivityInfo.LAUNCH_SINGLE_TASK:
     94                 mLaunch.setText(getText(R.string.launch_singleTask));
     95                 break;
     96             case ActivityInfo.LAUNCH_SINGLE_INSTANCE:
     97                 mLaunch.setText(getText(R.string.launch_singleInstance));
     98                 break;
     99             default:
    100                 mLaunch.setText(getText(R.string.launch_unknown));
    101             }
    102             mProcess.setText(mActivityInfo.processName);
    103             mTaskAffinity.setText(mActivityInfo.taskAffinity != null
    104                     ? mActivityInfo.taskAffinity : getText(R.string.none));
    105             mPermission.setText(mActivityInfo.permission != null
    106                     ? mActivityInfo.permission : getText(R.string.none));
    107             mMultiprocess.setText(
    108                     (mActivityInfo.flags&ActivityInfo.FLAG_MULTIPROCESS) != 0
    109                     ? getText(R.string.yes) : getText(R.string.no));
    110             mClearOnBackground.setText(
    111                     (mActivityInfo.flags&ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH) != 0
    112                     ? getText(R.string.yes) : getText(R.string.no));
    113             mStateNotNeeded.setText(
    114                     (mActivityInfo.flags&ActivityInfo.FLAG_STATE_NOT_NEEDED) != 0
    115                     ? getText(R.string.yes) : getText(R.string.no));
    116         }
    117     }
    118 
    119     public void onResume() {
    120         super.onResume();
    121     }
    122 }
    123