PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/config/src/com/google/marvin/config/MarvinHomeScreen.java

http://eyes-free.googlecode.com/
Java | 83 lines | 46 code | 14 blank | 23 comment | 5 complexity | 03ba23fe5a3db43c8bacc51334d88dc3 MD5 | raw file
 1/*
 2 * Copyright (C) 2008 Google Inc.
 3 * 
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * 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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.marvin.config;
17
18import com.google.tts.ConfigurationManager;
19import com.google.tts.TextToSpeechBeta;
20
21import android.app.Activity;
22import android.os.Bundle;
23import android.preference.PreferenceManager;
24import android.util.Log;
25import android.content.Intent;
26import android.content.SharedPreferences;
27import android.content.pm.ActivityInfo;
28import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
30
31/**
32 * Alternate home screen that dispatches to the actual shell home screen
33 * replacement.
34 * 
35 * @author sdoyon@google.com (Stephane Doyon)
36 * @author clchen@google.com (Charles L. Chen)
37 */
38
39public class MarvinHomeScreen extends Activity {
40  @Override
41  public void onCreate(Bundle savedInstanceState) {
42    super.onCreate(savedInstanceState);
43    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
44    
45    String packageName = "com.android.launcher";
46    String className = "com.android.launcher.Launcher";
47    
48    Intent intent = new Intent("android.intent.action.MAIN");
49    intent.addCategory("android.intent.category.HOME");
50
51    ResolveInfo[] homeAppsArray = new ResolveInfo[0];
52    PackageManager pm = getPackageManager();
53    homeAppsArray = pm.queryIntentActivities(intent, 0).toArray(homeAppsArray);
54
55    for (int i = 0; i < homeAppsArray.length; i++) {
56        ActivityInfo aInfo = homeAppsArray[i].activityInfo;
57        if (!aInfo.packageName.equals("com.google.marvin.config")){
58            packageName = aInfo.packageName;
59            className = aInfo.name;
60            break;
61        }
62    }
63    
64    
65    
66    if (prefs.getBoolean("use_shell", false)
67        && Utils.applicationInstalled(this, "com.google.marvin.shell")
68        && ttsChecksAllPassed() ) {
69      packageName = "com.google.marvin.shell";
70      className = "com.google.marvin.shell.MarvinShell";
71    }
72    Intent homeIntent = Utils.getAppStartIntent(this, packageName, className);
73        
74    startActivity(homeIntent);
75    finish();
76  }
77  
78  
79  private boolean ttsChecksAllPassed(){
80    //return TTS.isInstalled(this) && ConfigurationManager.allFilesExist();
81    return ConfigurationManager.allFilesExist();
82  }
83}