Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Started refactoring towards 2.0

  • Loading branch information...
commit 57c11b4f9125d7500b874c41b3695f6305dae1cc 1 parent 82099ec
Jake Wharton authored April 01, 2010
5  .gitignore
... ...
@@ -0,0 +1,5 @@
  1
+.classpath
  2
+.project
  3
+.settings
  4
+bin
  5
+gen
28  AndroidManifest.xml
... ...
@@ -1,33 +1,27 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 3
       package="com.jakewharton.smsmorse"
4  
-      android:versionCode="112"
5  
-      android:versionName="1.1.2">
  4
+      android:versionCode="200"
  5
+      android:versionName="2.0.0">
  6
+    
  7
+    <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
6 8
 	
7  
-	<uses-permission android:name="android.permission.VIBRATE" />
8  
-	<uses-permission android:name="android.permission.RECEIVE_SMS" />
9  
-	<uses-permission android:name="android.permission.WRITE_SETTINGS" />
  9
+	<uses-permission android:name="android.permission.VIBRATE"/>
  10
+	<uses-permission android:name="android.permission.RECEIVE_SMS"/>
  11
+	<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
10 12
     
11  
-    <application
12  
-    	android:icon="@drawable/icon"
13  
-    	android:label="@string/app_name">
14  
-        
  13
+    <application android:icon="@drawable/icon" android:label="@string/app_name">
15 14
         <activity android:name=".ui.Preferences" android:label="@string/app_name">
16 15
             <intent-filter>
17  
-                <action android:name="android.intent.action.MAIN" />
18  
-                <category android:name="android.intent.category.LAUNCHER" />
  16
+                <action android:name="android.intent.action.MAIN"/>
  17
+                <category android:name="android.intent.category.LAUNCHER"/>
19 18
 			</intent-filter>
20 19
         </activity>
21 20
         
22  
-        <activity android:name=".ui.About" android:label="@string/app_about_name"/>
23  
-        
24 21
         <receiver android:name=".transaction.EventReceiver" android:label="@string/app_receiver">
25 22
 			<intent-filter>
26  
-				<action android:name="android.provider.Telephony.SMS_RECEIVED" />
27  
-				<action android:name="com.jakewharton.smsmorse.VIBRATE_MORSE" />
  23
+				<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
28 24
 			</intent-filter>
29 25
         </receiver>
30  
-        
31 26
     </application>
32  
-
33 27
 </manifest>
13  default.properties
... ...
@@ -0,0 +1,13 @@
  1
+# This file is automatically generated by Android Tools.
  2
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
  3
+# 
  4
+# This file must be checked in Version Control Systems.
  5
+# 
  6
+# To customize properties used by the Ant build system use,
  7
+# "build.properties", and override values to adapt the script to your
  8
+# project structure.
  9
+
  10
+# Indicates whether an apk should be generated for each density.
  11
+split.density=false
  12
+# Project target.
  13
+target=android-4
45  res/layout/about.xml
... ...
@@ -1,41 +1,16 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2  
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2
+<ScrollView
  3
+	xmlns:android="http://schemas.android.com/apk/res/android"
3 4
 	android:layout_width="fill_parent"
4 5
 	android:layout_height="fill_parent"
5  
-	android:orientation="vertical"
6  
-	android:gravity="center">
7  
-	<ImageView
8  
-		android:id="@+id/icon"
9  
-		android:layout_width="wrap_content"
10  
-		android:layout_height="wrap_content"
11  
-		android:src="@drawable/icon"/>
  6
+	android:id="@+id/AboutScrollView">
12 7
 	<TextView
13  
-		android:id="@+id/app_name"
14  
-		android:layout_width="fill_parent"
15  
-		android:layout_height="wrap_content"
16  
-		android:gravity="center"
17  
-		android:textStyle="bold"
18  
-		android:text="@string/app_name"/>
19  
-	<TextView
20  
-		android:id="@+id/app_version"
21  
-		android:layout_width="fill_parent"
22  
-		android:layout_height="wrap_content"
23  
-		android:gravity="center"
24  
-		android:text="@string/app_version"/>
25  
-	<TextView
26  
-		android:id="@+id/app_by"
27  
-		android:layout_width="fill_parent"
  8
+		android:layout_width="wrap_content"
28 9
 		android:layout_height="wrap_content"
29  
-		android:gravity="center"
30  
-		android:layout_marginTop="10dip"
31  
-		android:text="@string/app_by"/>
32  
-	<TextView
33 10
 		android:id="@+id/app_about"
34  
-		android:layout_width="fill_parent"
35  
-		android:layout_height="wrap_content"
36  
-		android:gravity="center"
37  
-		android:layout_marginTop="20dip"
38  
-		android:linksClickable="true"
39  
-		android:autoLink="web"
40  
-		android:text="@string/app_about"/>
41  
-</LinearLayout>
  11
+		android:textColor="?android:attr/textColorPrimaryDisableOnly"
  12
+		android:textAppearance="?android:attr/textAppearanceSmall"
  13
+		android:autoLink="all"
  14
+		android:padding="11dp"
  15
+		android:text="@string/app_about" />
  16
+</ScrollView>
18  res/values/strings.xml
... ...
@@ -1,20 +1,18 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <resources>
3 3
 	<string name="app_name">SMSMorse</string>
4  
-	<string name="app_about_name">About SMSMorse</string>
5  
-	<string name="app_version">v1.1.0</string>
6  
-	<string name="app_by">by Jake Wharton</string>
7  
-	<string name="app_about"><a href="http://jakewharton.com">View Website</a>\n\n<a href="http://twitter.com/JakeWharton">Follow on Twitter</a>\n\n<a href="http://cyrket.com/search?q=com.jakewharton">View Other Android Applications</a></string>
8 4
 	<string name="app_receiver">EventReceiver</string>
  5
+	<string name="app_about">Developed by Jake Wharton &lt;jakewharton@gmail.com&gt;\n\nWebsite:\nhttp://jakewharton.com\n\nGitHub Project:\nhttp://github.com/JakeWharton/smsmorse\n\nFollow on Twitter:\nhttp://twitter.com/JakeWharton</string>
9 6
 	
10 7
 	<!-- Menu Items -->
11 8
 	<string name="menu_restore_defaults">Restore Defaults</string>
12 9
 	<string name="menu_about">About</string>
13 10
 	
14 11
 	<!-- Preference Headers -->
15  
-	<string name="preference_header_general">SMSMorse General Settings</string>
16  
-	<string name="preference_header_rules">SMSMorse Rule Settings</string>
17  
-	<string name="preference_header_input">SMSMorse Input Settings</string>
  12
+	<string name="preference_header_general">General Settings</string>
  13
+	<string name="preference_header_rules">Rule Settings</string>
  14
+	<string name="preference_header_input">Input Settings</string>
  15
+	<string name="preference_header_other">Other</string>
18 16
 	
19 17
 	<!-- General Preferences -->
20 18
 	<string name="preference_enabled">enabled</string>
@@ -58,6 +56,12 @@
58 56
 	<string name="preference_error_char">error_char</string>
59 57
 	<string name="preference_error_allowed">error_allowed</string>
60 58
 	
  59
+	<!-- Other Preferences -->
  60
+	<string name="preference_about">about</string>
  61
+	<string name="preference_about_title">About SMSMorse</string>
  62
+	<string name="preference_other">other</string>
  63
+	<string name="preference_other_title">View Other Apps</string>
  64
+	
61 65
 	<!--
62 66
 	 * Morse code binary lookup tree. Left for every dot, right for every dash
63 67
 	 * 
8  res/xml/preferences.xml
@@ -66,4 +66,12 @@
66 66
 			android:summary="@string/preference_input_enabled_summary"
67 67
 			android:defaultValue="true"/>
68 68
 	</PreferenceCategory>-->
  69
+	<PreferenceCategory android:title="@string/preference_header_other">
  70
+		<com.jakewharton.smsmorse.ui.DialogPreference
  71
+			android:key="@string/preference_about"
  72
+			android:dialogIcon="@drawable/icon"
  73
+			android:title="@string/preference_about_title"
  74
+			android:dialogTitle="@string/app_name"
  75
+			android:negativeButtonText="@null"/>
  76
+	</PreferenceCategory>
69 77
 </PreferenceScreen>
135  src/com/jakewharton/smsmorse/transaction/EventReceiver.java
... ...
@@ -1,7 +1,6 @@
1 1
 package com.jakewharton.smsmorse.transaction;
2 2
 
3 3
 import java.util.ArrayList;
4  
-
5 4
 import com.jakewharton.smsmorse.R;
6 5
 import android.app.KeyguardManager;
7 6
 import android.content.BroadcastReceiver;
@@ -44,21 +43,21 @@
44 43
 	private static final boolean DEFAULT_VIBRATE_VIBRATE = true;
45 44
 	private static final boolean DEFAULT_VIBRATE_SILENT  = false;
46 45
 	private static final long    DEFAULT_INITIAL_PAUSE   = 500L;
47  
-	private static final String  DEFAULT_ERROR_CHAR      = "_";
48  
-	private static final float   DEFAULT_PERCENT_ERROR   = 0.2F;
  46
+	//private static final String  DEFAULT_ERROR_CHAR      = "_";
  47
+	//private static final float   DEFAULT_PERCENT_ERROR   = 0.2F;
49 48
 	
50 49
 	//Morse code
51  
-	private final static int DOTS_IN_DASH       = 3;
52  
-	private final static int DOTS_IN_GAP        = 1;
53  
-	private final static int DOTS_IN_LETTER_GAP = 3;
54  
-	private final static int DOTS_IN_WORD_GAP   = 7;
  50
+	private static final int DOTS_IN_DASH       = 3;
  51
+	private static final int DOTS_IN_GAP        = 1;
  52
+	private static final int DOTS_IN_LETTER_GAP = 3;
  53
+	private static final int DOTS_IN_WORD_GAP   = 7;
55 54
 	
56 55
 	//Character sets
57  
-	private final static String      CHARSET_MORSE  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@";
58  
-	private final static String      CHARSET_COUNTS = "0123456789";
59  
-	private final static boolean     DOT  = true;
60  
-	private final static boolean     DASH = false;
61  
-	private final static boolean[][] MORSE  = {
  56
+	private static final String      CHARSET_MORSE  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,?'!/()&:;=+-_\"$@";
  57
+	private static final String      CHARSET_COUNTS = "0123456789";
  58
+	private static final boolean     DOT  = true;
  59
+	private static final boolean     DASH = false;
  60
+	private static final boolean[][] MORSE  = {
62 61
         {DOT, DASH}, //A
63 62
         {DASH, DOT, DOT, DOT}, //B
64 63
         {DASH, DOT, DASH, DOT}, //C
@@ -114,7 +113,7 @@
114 113
         {DOT, DOT, DOT, DASH, DOT, DOT, DASH}, //$
115 114
         {DOT, DASH, DASH, DOT, DASH, DOT} //@
116 115
 	};
117  
-	private final static boolean[][] COUNTS = {
  116
+	private static final boolean[][] COUNTS = {
118 117
 		{DASH}, //0
119 118
 		{DOT}, //1
120 119
 		{DOT, DOT}, //2
@@ -127,37 +126,40 @@
127 126
 		{DOT, DOT, DOT, DOT, DOT, DOT, DOT, DOT, DOT} //9
128 127
 	};
129 128
 
130  
-	//Instance variables
131  
-	private SharedPreferences settings;
132  
-	private Resources         resources;
133  
-	private Vibrator          vibrator;
  129
+	//Static variables
  130
+	private SharedPreferences settings  = null;
  131
+	private Resources         resources = null;
  132
+	private Vibrator          vibrator  = null;
134 133
 	
  134
+	/**
  135
+	 * Called when an intent is received.
  136
+	 */
135 137
 	public void onReceive(Context context, Intent intent) {
136 138
 		//Save context-specific objects needed in other methods
137  
-		settings  = PreferenceManager.getDefaultSharedPreferences(context);
  139
+		settings = PreferenceManager.getDefaultSharedPreferences(context);
138 140
 		resources = context.getResources();
139  
-		vibrator  = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
  141
+		vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
140 142
 		
141 143
 		final String action = intent.getAction();
142 144
 		final Bundle extras = intent.getExtras();
143 145
 		
144  
-		if (action.equals(VIBRATE_IN_MORSE)) {
145  
-			vibrateMorse(convertToVibrations(extras.getString(VIBRATE_IN_MORSE_KEY)));
  146
+		if (action.equals(EventReceiver.VIBRATE_IN_MORSE)) {
  147
+			this.vibrateMorse(this.convertToVibrations(extras.getString(EventReceiver.VIBRATE_IN_MORSE_KEY)));
146 148
 		}
147 149
 		/*else if (action.equals(PARSE_MORSE)) {
148  
-			Log.i(TAG, "Parsed to: " + parseMorse(extras.getLongArray(PARSE_MORSE_KEY)));
  150
+			Log.i(EventReceiver.TAG, "Parsed to: " + EventReceiver.parseMorse(extras.getLongArray(PARSE_MORSE_KEY)));
149 151
 		}*/
150  
-		else if (action.equals(SMS_RECEIVED)) {
  152
+		else if (action.equals(EventReceiver.SMS_RECEIVED)) {
151 153
 			final boolean smsValid      = extras != null;
152  
-			final boolean enabled       = settings.getBoolean(resources.getString(R.string.preference_enabled), DEFAULT_ENABLED);
  154
+			final boolean enabled       = this.settings.getBoolean(this.resources.getString(R.string.preference_enabled), EventReceiver.DEFAULT_ENABLED);
153 155
 			final boolean keygaurdOn    = ((KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE)).inKeyguardRestrictedInputMode();
154  
-			final boolean screenOffOnly = settings.getBoolean(resources.getString(R.string.preference_screen_off_only), DEFAULT_SCREEN_OFF_ONLY);
  156
+			final boolean screenOffOnly = this.settings.getBoolean(this.resources.getString(R.string.preference_screen_off_only), EventReceiver.DEFAULT_SCREEN_OFF_ONLY);
155 157
 			
156 158
 			final int audioMode = ((AudioManager)context.getSystemService(Context.AUDIO_SERVICE)).getRingerMode();
157 159
 			final boolean activeAudioMode = (
158  
-				((audioMode == AudioManager.RINGER_MODE_NORMAL) && settings.getBoolean(resources.getString(R.string.preference_vibrate_normal), DEFAULT_VIBRATE_NORMAL)) ||
159  
-				((audioMode == AudioManager.RINGER_MODE_VIBRATE) && settings.getBoolean(resources.getString(R.string.preference_vibrate_vibrate), DEFAULT_VIBRATE_VIBRATE)) ||
160  
-				((audioMode == AudioManager.RINGER_MODE_SILENT) && settings.getBoolean(resources.getString(R.string.preference_vibrate_silent), DEFAULT_VIBRATE_SILENT))
  160
+				((audioMode == AudioManager.RINGER_MODE_NORMAL) && this.settings.getBoolean(this.resources.getString(R.string.preference_vibrate_normal), EventReceiver.DEFAULT_VIBRATE_NORMAL)) ||
  161
+				((audioMode == AudioManager.RINGER_MODE_VIBRATE) && this.settings.getBoolean(this.resources.getString(R.string.preference_vibrate_vibrate), EventReceiver.DEFAULT_VIBRATE_VIBRATE)) ||
  162
+				((audioMode == AudioManager.RINGER_MODE_SILENT) && this.settings.getBoolean(this.resources.getString(R.string.preference_vibrate_silent), EventReceiver.DEFAULT_VIBRATE_SILENT))
161 163
 			);
162 164
 			
163 165
 			if (smsValid && enabled && activeAudioMode && (keygaurdOn || !screenOffOnly)) {
@@ -169,32 +171,47 @@ else if (action.equals(SMS_RECEIVED)) {
169 171
 				
170 172
 				//Assemble 
171 173
 				final ArrayList<Long> vibrations = new ArrayList<Long>();
172  
-				final int vibrateParts = Integer.parseInt(settings.getString(resources.getString(R.string.preference_vibrate_parts), DEFAULT_VIBRATE_PARTS));
  174
+				final int vibrateParts = Integer.parseInt(settings.getString(resources.getString(R.string.preference_vibrate_parts), EventReceiver.DEFAULT_VIBRATE_PARTS));
173 175
 				for (SmsMessage message : messages) {
174  
-					if ((vibrateParts == VIBRATE_CONTENT_SENDER) || (vibrateParts == VIBRATE_CONTENT_SENDER_MESSAGE))
175  
-						vibrations.addAll(convertSenderToVibrations(context, message.getOriginatingAddress()));
176  
-					if (vibrateParts != VIBRATE_CONTENT_SENDER)
177  
-						vibrations.addAll(convertToVibrations(message.getMessageBody()));
178  
-					if (vibrateParts == VIBRATE_CONTENT_MESSAGE_SENDER)
179  
-						vibrations.addAll(convertSenderToVibrations(context, message.getOriginatingAddress()));
  176
+					if ((vibrateParts == EventReceiver.VIBRATE_CONTENT_SENDER) || (vibrateParts == EventReceiver.VIBRATE_CONTENT_SENDER_MESSAGE))
  177
+						vibrations.addAll(this.convertSenderToVibrations(context, message.getOriginatingAddress()));
  178
+					if (vibrateParts != EventReceiver.VIBRATE_CONTENT_SENDER)
  179
+						vibrations.addAll(this.convertToVibrations(message.getMessageBody()));
  180
+					if (vibrateParts == EventReceiver.VIBRATE_CONTENT_MESSAGE_SENDER)
  181
+						vibrations.addAll(this.convertSenderToVibrations(context, message.getOriginatingAddress()));
180 182
 				}
181 183
 				
182  
-				vibrateMorse(vibrations);
  184
+				this.vibrateMorse(vibrations);
183 185
 			}
184 186
 		}
185 187
 	}
  188
+	
  189
+	/**
  190
+	 * Turns a converts the sender, either phone number of optionally the
  191
+	 * contact name, into associated Morse code timings.
  192
+	 * 
  193
+	 * (Uses deprecated APIs to support pre-2.0 devices.)
  194
+	 * @param context
  195
+	 * @param sender
  196
+	 * @return <pre>ArrayList</pre> of <pre>Long</pre>s of off/on vibration intervals
  197
+	 */
186 198
 	private ArrayList<Long> convertSenderToVibrations(Context context, String sender) {
187  
-		if (settings.getBoolean(context.getString(R.string.preference_lookup_contact_name), true)) {
  199
+		if (this.settings.getBoolean(context.getString(R.string.preference_lookup_contact_name), true)) {
188 200
 			final String[] projection = new String[] { Contacts.PeopleColumns.DISPLAY_NAME };
189 201
 			final String selection = Contacts.Phones.NUMBER + " = " + sender;
190 202
 			final Cursor results = context.getContentResolver().query(Contacts.Phones.CONTENT_URI, projection, selection, null, Contacts.ContactMethods.PERSON_ID);
191 203
 			
192 204
 			if (results.moveToFirst()) {
193  
-				return convertToVibrations(results.getString(results.getColumnIndex(Contacts.PeopleColumns.DISPLAY_NAME)));
  205
+				return this.convertToVibrations(results.getString(results.getColumnIndex(Contacts.PeopleColumns.DISPLAY_NAME)));
194 206
 			}
195 207
 		}
196  
-		return convertToVibrations(sender, true);
  208
+		return this.convertToVibrations(sender, true);
197 209
 	}
  210
+	
  211
+	/**
  212
+	 * Issues the vibrations contained within the <pre>vibrationLongs</pre> parameter.
  213
+	 * @param vibrationLongs
  214
+	 */
198 215
 	private void vibrateMorse(final ArrayList<Long> vibrationLongs) {
199 216
 		final long[] vibrations = new long[vibrationLongs.size()];
200 217
 		final StringBuffer morseVibrations = new StringBuffer("Vibrating Morse: ");
@@ -206,9 +223,10 @@ private void vibrateMorse(final ArrayList<Long> vibrationLongs) {
206 223
 			morseVibrations.append(vibrationLongs.get(i));
207 224
 		}
208 225
 		
209  
-		vibrator.vibrate(vibrations, -1);
210  
-		Log.i(TAG, morseVibrations.toString());
  226
+		this.vibrator.vibrate(vibrations, -1);
  227
+		Log.i(EventReceiver.TAG, morseVibrations.toString());
211 228
 	}
  229
+	
212 230
 	/*private String parseMorse(final long[] buttonPresses) {
213 231
 		final char  errorChar    = settings.getString(resources.getString(R.string.preference_error_char), DEFAULT_ERROR_CHAR).charAt(0);
214 232
 		final float errorAllowed = settings.getFloat(resources.getString(R.string.preference_error_allowed), DEFAULT_ERROR_ALLOWED);
@@ -276,26 +294,39 @@ private int average(final ArrayList<Long> numberList) {
276 294
 			sum += (Long)number;
277 295
 		return (int)(sum / numberList.size());
278 296
 	}*/
279  
-    private ArrayList<Long> convertToVibrations(final String message) {
280  
-    	return convertToVibrations(message, false);
  297
+    
  298
+	/**
  299
+     * Converts a string to associated Morse code timings.
  300
+     * @param message Message to convert
  301
+     * @return <pre>ArrayList</pre> of <pre>Long</pre>s of off/on vibration intervals
  302
+     */
  303
+	private ArrayList<Long> convertToVibrations(final String message) {
  304
+    	return this.convertToVibrations(message, false);
281 305
     }
  306
+	
  307
+	/**
  308
+	 * Converts a string to associated Morse code timings.
  309
+	 * @param message Message to convert.
  310
+	 * @param isNumber Boolean indicating whether or not the message is a phone number.
  311
+	 * @return <pre>ArrayList</pre> of <pre>Long</pre>s of off/on vibration intervals
  312
+	 */
282 313
 	private ArrayList<Long> convertToVibrations(final String message, final boolean isNumber) {
283  
-    	final boolean vibrateCounts = settings.getBoolean(resources.getString(R.string.preference_vibrate_counts), DEFAULT_VIBRATE_COUNTS);
  314
+    	final boolean vibrateCounts = this.settings.getBoolean(this.resources.getString(R.string.preference_vibrate_counts), EventReceiver.DEFAULT_VIBRATE_COUNTS);
284 315
     	
285 316
     	//Establish all lengths
286  
-		final long dot       = settings.getInt(resources.getString(R.string.preference_dot_length), DEFAULT_DOT_LENGTH);
287  
-		final long dash      = dot * DOTS_IN_DASH;
288  
-		final long gap       = dot * DOTS_IN_GAP;
289  
-		final long letterGap = dot * DOTS_IN_LETTER_GAP;
290  
-		final long wordGap   = dot * DOTS_IN_WORD_GAP;
  317
+		final long dot       = this.settings.getInt(this.resources.getString(R.string.preference_dot_length), EventReceiver.DEFAULT_DOT_LENGTH);
  318
+		final long dash      = dot * EventReceiver.DOTS_IN_DASH;
  319
+		final long gap       = dot * EventReceiver.DOTS_IN_GAP;
  320
+		final long letterGap = dot * EventReceiver.DOTS_IN_LETTER_GAP;
  321
+		final long wordGap   = dot * EventReceiver.DOTS_IN_WORD_GAP;
291 322
     	
292 323
     	final String[] words = message.toUpperCase().trim().split(" ");
293 324
     	final ArrayList<Long> vibrationObjects = new ArrayList<Long>();
294  
-    	final String charset = isNumber && vibrateCounts ? CHARSET_COUNTS : CHARSET_MORSE;
295  
-    	final boolean[][] lookups = isNumber && vibrateCounts ? COUNTS : MORSE;
  325
+    	final String charset = isNumber && vibrateCounts ? EventReceiver.CHARSET_COUNTS : EventReceiver.CHARSET_MORSE;
  326
+    	final boolean[][] lookups = isNumber && vibrateCounts ? EventReceiver.COUNTS : EventReceiver.MORSE;
296 327
     	
297 328
     	//Add initial pause
298  
-    	vibrationObjects.add(DEFAULT_INITIAL_PAUSE);
  329
+    	vibrationObjects.add(EventReceiver.DEFAULT_INITIAL_PAUSE);
299 330
     	
300 331
     	String word;
301 332
     	boolean[] letterBooleans;
1  src/com/jakewharton/smsmorse/ui/BetterSeekBarPreference.java
@@ -26,7 +26,6 @@
26 26
     private TextView mTextView;
27 27
 
28 28
 	private OnSeekBarChangeListener changeListener = new OnSeekBarChangeListener() {
29  
-
30 29
 		public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
31 30
 			setTextValue(arg1);
32 31
 		}
13  src/com/jakewharton/smsmorse/ui/DialogPreference.java
... ...
@@ -0,0 +1,13 @@
  1
+package com.jakewharton.smsmorse.ui;
  2
+
  3
+import android.content.Context;
  4
+import android.util.AttributeSet;
  5
+
  6
+public class DialogPreference extends android.preference.DialogPreference {
  7
+	public DialogPreference(Context context, AttributeSet attrs) {
  8
+		super(context, attrs);
  9
+	}
  10
+	public DialogPreference(Context context, AttributeSet attrs, int defStyle) {
  11
+		super(context, attrs, defStyle);
  12
+	}
  13
+}
14  src/com/jakewharton/smsmorse/ui/Preferences.java
@@ -4,6 +4,7 @@
4 4
 import com.jakewharton.smsmorse.transaction.EventReceiver;
5 5
 
6 6
 import android.content.Intent;
  7
+import android.content.pm.PackageManager;
7 8
 import android.os.Bundle;
8 9
 import android.preference.CheckBoxPreference;
9 10
 import android.preference.EditTextPreference;
@@ -18,7 +19,6 @@
18 19
 
19 20
 public class Preferences extends PreferenceActivity {
20 21
 	private static final int MENU_RESTORE_DEFAULTS = 0;
21  
-	private static final int MENU_ABOUT            = 1;
22 22
 	
23 23
 	private CheckBoxPreference      mCheckBoxEnabled;
24 24
 	private ListPreference          mVibratePart;
@@ -103,13 +103,19 @@ private void loadPreferences() {
103 103
 		
104 104
 		//mCheckBoxInputEnabled = (CheckBoxPreference)screen.findPreference(getString(R.string.preference_input_enabled));
105 105
 		//mCheckBoxInputEnabled.setOnPreferenceChangeListener(mInputEnabledListener);
  106
+		
  107
+		final DialogPreference about = (DialogPreference)screen.findPreference(getString(R.string.preference_about));
  108
+		about.setDialogLayoutResource(R.layout.about);
  109
+		try {
  110
+			final String version = getPackageManager().getPackageInfo("com.jakewharton.smsmorse", PackageManager.GET_META_DATA).versionName;
  111
+			about.setDialogTitle(getString(R.string.app_name) + " v" + version);
  112
+		} catch (Exception e) {}
106 113
 	}
107 114
 	@Override
108 115
 	public boolean onCreateOptionsMenu(Menu menu) {
109 116
 		super.onCreateOptionsMenu(menu);
110 117
 		menu.clear();
111 118
 		menu.add(0, MENU_RESTORE_DEFAULTS, 0, R.string.menu_restore_defaults);
112  
-		menu.add(0, MENU_ABOUT, 0, R.string.menu_about);
113 119
 		return true;
114 120
 	}
115 121
 	@Override
@@ -120,10 +126,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
120 126
 				setPreferenceScreen(null);
121 127
 				loadPreferences();
122 128
 				return true;
123  
-				
124  
-			case MENU_ABOUT:
125  
-				startActivity(new Intent(this, About.class));
126  
-				return true;
127 129
 		}
128 130
 		return false;
129 131
 	}

0 notes on commit 57c11b4

Please sign in to comment.
Something went wrong with that request. Please try again.