PageRenderTime 61ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/ideal/TextEnlarger/src/com/ideal/textenlarger/TextEnlargerPrefs.java

http://eyes-free.googlecode.com/
Java | 113 lines | 78 code | 17 blank | 18 comment | 2 complexity | 4ac2cda5ccc7e04e5333ab5a8f1e6ae0 MD5 | raw file
Possible License(s): GPL-3.0, Apache-2.0
  1. /*
  2. * Copyright (C) 2010 The IDEAL Group
  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. package com.ideal.textenlarger;
  17. import android.app.Dialog;
  18. import android.app.AlertDialog.Builder;
  19. import android.content.DialogInterface;
  20. import android.content.Intent;
  21. import android.net.Uri;
  22. import android.os.Bundle;
  23. import android.preference.Preference;
  24. import android.preference.PreferenceActivity;
  25. import android.preference.Preference.OnPreferenceClickListener;
  26. /**
  27. * Pref settings for the Text Enlarger.
  28. */
  29. public class TextEnlargerPrefs extends PreferenceActivity {
  30. private Preference mAppSettings = null;
  31. private Preference mHelp = null;
  32. @Override
  33. protected void onCreate(Bundle savedInstanceState) {
  34. super.onCreate(savedInstanceState);
  35. addPreferencesFromResource(R.xml.prefs);
  36. if (!TextEnlargerService.phoneCheckPassed()){
  37. Intent i = new Intent();
  38. i.setAction("android.intent.action.VIEW");
  39. i.addCategory("android.intent.category.BROWSABLE");
  40. Uri uri = Uri.parse("http://apps4android.org/textenlarger/unsupported_device.html");
  41. i.setData(uri);
  42. startActivity(i);
  43. finish();
  44. return;
  45. }
  46. if (!TextEnlargerService.isServiceInitialized()) {
  47. showEnableDialog();
  48. }
  49. final PreferenceActivity self = this;
  50. mAppSettings = findPreference("app_settings");
  51. mAppSettings.setOnPreferenceClickListener(new OnPreferenceClickListener() {
  52. public boolean onPreferenceClick(Preference preference) {
  53. Intent i = new Intent();
  54. i.setClass(self, ApplicationsListActivity.class);
  55. startActivity(i);
  56. return true;
  57. }
  58. });
  59. mHelp = findPreference("help");
  60. mHelp.setOnPreferenceClickListener(new OnPreferenceClickListener() {
  61. public boolean onPreferenceClick(Preference preference) {
  62. Intent i = new Intent();
  63. i.setAction("android.intent.action.VIEW");
  64. i.addCategory("android.intent.category.BROWSABLE");
  65. Uri uri = Uri.parse("http://apps4android.org/textenlarger");
  66. i.setData(uri);
  67. startActivity(i);
  68. return true;
  69. }
  70. });
  71. }
  72. private void showEnableDialog() {
  73. Builder enableMessage = new Builder(this);
  74. String titleText = "Please enable Text Enlarger";
  75. enableMessage.setTitle(titleText);
  76. enableMessage
  77. .setMessage("You need to enable the Text Enlarger under the Accessibility settings before you can use it.");
  78. enableMessage.setPositiveButton("Take me to the Accessibility settings",
  79. new Dialog.OnClickListener() {
  80. public void onClick(DialogInterface dialog, int which) {
  81. Intent i = new Intent();
  82. i.setClassName("com.android.settings",
  83. "com.android.settings.AccessibilitySettings");
  84. startActivity(i);
  85. finish();
  86. }
  87. });
  88. enableMessage.setNegativeButton("Quit", new Dialog.OnClickListener() {
  89. public void onClick(DialogInterface dialog, int which) {
  90. finish();
  91. }
  92. });
  93. enableMessage.setCancelable(true);
  94. enableMessage.show();
  95. }
  96. }