/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. */
  16. package com.google.marvin.config;
  17. import com.google.tts.ConfigurationManager;
  18. import com.google.tts.TextToSpeechBeta;
  19. import android.app.Activity;
  20. import android.os.Bundle;
  21. import android.preference.PreferenceManager;
  22. import android.util.Log;
  23. import android.content.Intent;
  24. import android.content.SharedPreferences;
  25. import android.content.pm.ActivityInfo;
  26. import android.content.pm.PackageManager;
  27. import android.content.pm.ResolveInfo;
  28. /**
  29. * Alternate home screen that dispatches to the actual shell home screen
  30. * replacement.
  31. *
  32. * @author sdoyon@google.com (Stephane Doyon)
  33. * @author clchen@google.com (Charles L. Chen)
  34. */
  35. public class MarvinHomeScreen extends Activity {
  36. @Override
  37. public void onCreate(Bundle savedInstanceState) {
  38. super.onCreate(savedInstanceState);
  39. SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
  40. String packageName = "com.android.launcher";
  41. String className = "com.android.launcher.Launcher";
  42. Intent intent = new Intent("android.intent.action.MAIN");
  43. intent.addCategory("android.intent.category.HOME");
  44. ResolveInfo[] homeAppsArray = new ResolveInfo[0];
  45. PackageManager pm = getPackageManager();
  46. homeAppsArray = pm.queryIntentActivities(intent, 0).toArray(homeAppsArray);
  47. for (int i = 0; i < homeAppsArray.length; i++) {
  48. ActivityInfo aInfo = homeAppsArray[i].activityInfo;
  49. if (!aInfo.packageName.equals("com.google.marvin.config")){
  50. packageName = aInfo.packageName;
  51. className = aInfo.name;
  52. break;
  53. }
  54. }
  55. if (prefs.getBoolean("use_shell", false)
  56. && Utils.applicationInstalled(this, "com.google.marvin.shell")
  57. && ttsChecksAllPassed() ) {
  58. packageName = "com.google.marvin.shell";
  59. className = "com.google.marvin.shell.MarvinShell";
  60. }
  61. Intent homeIntent = Utils.getAppStartIntent(this, packageName, className);
  62. startActivity(homeIntent);
  63. finish();
  64. }
  65. private boolean ttsChecksAllPassed(){
  66. //return TTS.isInstalled(this) && ConfigurationManager.allFilesExist();
  67. return ConfigurationManager.allFilesExist();
  68. }
  69. }