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