<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -27,4 +27,12 @@
         &lt;item&gt;1&lt;/item&gt;
         &lt;item&gt;0&lt;/item&gt;
     &lt;/string-array&gt;
+    &lt;string-array name=&quot;vibration_notifications&quot;&gt;
+        &lt;item&gt;On&lt;/item&gt;
+        &lt;item&gt;Off&lt;/item&gt;
+    &lt;/string-array&gt;
+    &lt;string-array name=&quot;vibration_notifications_values&quot;&gt;
+        &lt;item&gt;1&lt;/item&gt;
+        &lt;item&gt;0&lt;/item&gt;
+    &lt;/string-array&gt;
 &lt;/resources&gt;
\ No newline at end of file</diff>
      <filename>presently-android/res/values/arrays.xml</filename>
    </modified>
    <modified>
      <diff>@@ -19,5 +19,9 @@
 	&lt;string name=&quot;preferences_visual_notifications_title&quot;&gt;Visual Notifications&lt;/string&gt;
 	&lt;string name=&quot;preferences_visual_notifications_summary&quot;&gt;Turn on or off visual notifications&lt;/string&gt;
 	&lt;string name=&quot;preferences_visual_notifications_default_value&quot;&gt;1&lt;/string&gt;
+
+	&lt;string name=&quot;preferences_vibration_notifications_title&quot;&gt;Vibrating Notifications&lt;/string&gt;
+	&lt;string name=&quot;preferences_vibration_notifications_summary&quot;&gt;Vibrate when there is a new notification&lt;/string&gt;
+	&lt;string name=&quot;preferences_vibration_notifications_default_value&quot;&gt;1&lt;/string&gt;
   
 &lt;/resources&gt;</diff>
      <filename>presently-android/res/values/strings.xml</filename>
    </modified>
    <modified>
      <diff>@@ -21,6 +21,15 @@
                 android:defaultValue=&quot;@string/preferences_visual_notifications_default_value&quot;
                 android:dialogTitle=&quot;@string/choose_one&quot;/&gt;
 
+        &lt;ListPreference
+                android:key=&quot;vibration_notifications_on&quot;
+                android:title=&quot;@string/preferences_vibration_notifications_title&quot;
+                android:summary=&quot;@string/preferences_vibration_notifications_summary&quot;
+                android:entries=&quot;@array/vibration_notifications&quot;
+                android:entryValues=&quot;@array/vibration_notifications_values&quot;
+                android:defaultValue=&quot;@string/preferences_vibration_notifications_default_value&quot;
+                android:dialogTitle=&quot;@string/choose_one&quot;/&gt;
+
     &lt;/PreferenceCategory&gt;
 
 &lt;/PreferenceScreen&gt;
\ No newline at end of file</diff>
      <filename>presently-android/res/xml/preferences.xml</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,8 @@ public final class R {
         public static final int update_item_actions_without_link=0x7f050000;
         public static final int update_service_polling_interval_values=0x7f050003;
         public static final int update_service_polling_intervals=0x7f050002;
+        public static final int vibration_notifications=0x7f050006;
+        public static final int vibration_notifications_values=0x7f050007;
         public static final int visual_notifications=0x7f050004;
         public static final int visual_notifications_values=0x7f050005;
     }
@@ -69,6 +71,9 @@ public final class R {
         public static final int preferences_update_service_polling_interval_list_default_value=0x7f07000d;
         public static final int preferences_update_service_polling_interval_list_summary=0x7f07000c;
         public static final int preferences_update_service_polling_interval_list_title=0x7f07000b;
+        public static final int preferences_vibration_notifications_default_value=0x7f070013;
+        public static final int preferences_vibration_notifications_summary=0x7f070012;
+        public static final int preferences_vibration_notifications_title=0x7f070011;
         public static final int preferences_visual_notifications_default_value=0x7f070010;
         public static final int preferences_visual_notifications_summary=0x7f07000f;
         public static final int preferences_visual_notifications_title=0x7f07000e;</diff>
      <filename>presently-android/src/com/intridea/presently/android/R.java</filename>
    </modified>
    <modified>
      <diff>@@ -45,7 +45,6 @@ public class StatusActivity extends Activity {
 	private static final int MENU_REFRESH_ID = 2;
 	private static final int MENU_PREFS_ID = 3;
 	protected static final String UPDATE_SERVICE_POLLING_INTERVAL = &quot;update_service_polling_interval&quot;;
-	protected static final String VISUAL_NOTIFICATIONS_PREFS = &quot;visual_notifications_on&quot;;
 	protected static final String POLLING_INTERVAL = &quot;60000&quot;;
 	private static final long APP_IDENTIFIER = 1826316283757l;
 
@@ -92,34 +91,25 @@ public class StatusActivity extends Activity {
 		}
 	}
 
+	protected void onRestart() {
+		super.onRestart();
+		startProcedure();
+	}
+	
 	protected void onResume() {
 		super.onResume();
-		lastId = 0;
-		mNotificationManager.cancel((int) (APP_IDENTIFIER));
-		stopUpdateService();
-		suspended = false;
-		if (this.backgroundUpdateThread != null &amp;&amp; !this.backgroundUpdateThread.isAlive()) {
-			this.backgroundUpdateThread.start();
-		}
+		startProcedure();
 	}
 
 	protected void onPause() {
 		super.onPause();
-		startUpdateService();
-		suspended = true;
-		if (this.backgroundUpdateThread != null &amp;&amp; this.backgroundUpdateThread.isAlive()) {
-			this.backgroundUpdateThread.stop();
-		}
+		stopProcedure();
 	}
 
 	@Override
 	protected void onDestroy() {
 		super.onDestroy();
-		lastId = null;
-		stopUpdateService();
-		if (this.backgroundUpdateThread != null) {
-			this.backgroundUpdateThread.stop();
-		}
+		stopProcedure();
 	}
 
 	// Handles menu
@@ -152,6 +142,13 @@ public class StatusActivity extends Activity {
 		return super.onOptionsItemSelected(item);
 	}
 
+
+	public static long getPollingInterval() {
+		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(activity);
+		String interval = pref.getString(UPDATE_SERVICE_POLLING_INTERVAL, POLLING_INTERVAL);
+		return Long.parseLong(interval);
+	}
+	
 	// Handles configuration changes
 
 	@Override
@@ -180,7 +177,8 @@ public class StatusActivity extends Activity {
 				}
 			} else {
 				Log.e(&quot;TwitterService&quot;, ((Exception) msg.obj).getMessage(), (Exception) msg.obj);
-				String message = ((Exception) msg.obj).getMessage().replace(&quot;java.lang.Exception: &quot;, &quot;&quot;);
+				String message = &quot;There was a problem trying to retrieve the latest updates&quot;;
+				message = msg.arg2 == TwitterService.REQUEST_FRIENDS_TIMELINE ? message : &quot;There was a problem trying to send your status update&quot;;
 				new AlertDialog.Builder(StatusActivity.this).setTitle(&quot;Present.ly Error&quot;)
 						.setIcon(android.R.drawable.ic_menu_help).setMessage(message).setNegativeButton(&quot;Discard&quot;, null)
 						.setCancelable(false).show();
@@ -204,7 +202,6 @@ public class StatusActivity extends Activity {
 		// refreshed.
 		findViewById(R.id.status_message).requestFocus();
 		findViewById(R.id.status_message).setOnKeyListener(returnListener);
-
 		findViewById(R.id.send).setOnClickListener(messageListener);
 
 		ListView list = (ListView) findViewById(R.id.status_list);
@@ -224,7 +221,6 @@ public class StatusActivity extends Activity {
 
 			if (lastId == null) {
 				lastId = lastResponse.getId();
-
 			} else if (lastId != null &amp;&amp; lastId &lt; lastResponse.getId()) {
 				lastId = lastResponse.getId();
 			}
@@ -234,7 +230,6 @@ public class StatusActivity extends Activity {
 		list.setLongClickable(true);
 		list.setOnItemClickListener(new OnItemClickListener() {
 			public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, final int position, long arg3) {
-
 				final Matcher matcher = Pattern.compile(&quot;https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?&quot;).matcher(
 						retrievedStatuses.getItemAt(position).getText());
 
@@ -419,29 +414,34 @@ public class StatusActivity extends Activity {
 		}
 	}
 
-	public static long getPollingInterval() {
-		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(activity);
-		String interval = pref.getString(UPDATE_SERVICE_POLLING_INTERVAL, POLLING_INTERVAL);
-		return Long.parseLong(interval);
-	}
-
-	protected boolean isNotificationsEnabled() {
-		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(activity);
-		Integer interval = Integer.valueOf(pref.getString(VISUAL_NOTIFICATIONS_PREFS, &quot;0&quot;));
-		return interval == 1;
-	}
-
 	protected void stopUpdateService() {
 		Intent updateServiceIntent = new Intent(this, UpdateService.class);
 		stopService(updateServiceIntent);
 	}
 
 	protected void startUpdateService() {
-		UpdateService.setLastId(lastId);
+		UpdateService.setLastIdAndActivity(lastId, activity);
 		Intent updateServiceIntent = new Intent(this, UpdateService.class);
 		updateServiceIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
 		startService(updateServiceIntent);
 	}
+	
+	protected void stopProcedure() {
+		stopUpdateService();
+		if (this.backgroundUpdateThread != null) {
+			this.backgroundUpdateThread.stop();
+		}
+	}
+	
+	protected void startProcedure() {
+		lastId = 0;
+		mNotificationManager.cancel((int) (APP_IDENTIFIER));
+		stopUpdateService();
+		suspended = false;
+		if (this.backgroundUpdateThread != null &amp;&amp; !this.backgroundUpdateThread.isAlive()) {
+			this.backgroundUpdateThread.start();
+		}
+	}
 
 	@Override
 	public void onConfigurationChanged(Configuration newConfig) {</diff>
      <filename>presently-android/src/com/intridea/presently/android/StatusActivity.java</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,17 @@
 package com.intridea.presently.android;
 
-import java.text.SimpleDateFormat;
 import java.util.HashMap;
 import java.util.Map;
 
+import jtwitter.TwitterEntry;
+import jtwitter.TwitterResponse;
+import android.app.Activity;
 import android.content.Context;
 import android.database.DataSetObserver;
 import android.graphics.Bitmap;
 import android.graphics.Color;
 import android.text.Html;
 import android.text.Spannable;
-import android.text.util.Linkify;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageView;
@@ -20,9 +21,6 @@ import android.widget.TextView;
 import android.widget.ImageView.ScaleType;
 import android.widget.LinearLayout.LayoutParams;
 
-import jtwitter.TwitterEntry;
-import jtwitter.TwitterResponse;
-
 public class StatusAdapter implements ListAdapter {
 
 	private final TwitterResponse statuses;
@@ -97,13 +95,14 @@ public class StatusAdapter implements ListAdapter {
     	iv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
 	
     	Spannable content = (Spannable) Html.fromHtml(entry.toHtml());
-//    	Linkify.addLinks(content, Linkify.ALL);
+    	//Linkify.addLinks(content, Linkify.ALL);
     	
     	TextView tv = new TextView(context);
     	tv.setTextSize(14);
     	tv.setText(content);
-    	tv.setLayoutParams(new LayoutParams(215, LayoutParams.WRAP_CONTENT));
-	
+    	tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+    	tv.setPadding(0, 0, 5, 0);
+    	
     	LinearLayout layout = new LinearLayout(context);
     	layout.setOrientation(LinearLayout.HORIZONTAL);
 		layout.setBackgroundColor(Color.argb(255, 24, 24, 24));</diff>
      <filename>presently-android/src/com/intridea/presently/android/StatusAdapter.java</filename>
    </modified>
    <modified>
      <diff>@@ -2,54 +2,63 @@ package com.intridea.presently.android;
 
 import jtwitter.TwitterEntry;
 import jtwitter.TwitterResponse;
+import android.app.Activity;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
 import android.app.Service;
+import android.content.Context;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
+import android.os.Vibrator;
+import android.preference.PreferenceManager;
 import android.util.Log;
 
 public class UpdateService extends Service {
 	private NotificationManager mNotificationManager;
-    protected static final String POLLING_INTERVAL = &quot;60000&quot;;
-	private static final long APP_IDENTIFIER = 1826316283757l;
+	protected static final String POLLING_INTERVAL = &quot;60000&quot;;
+	protected static final long APP_IDENTIFIER = 1826316283757l;
+	protected static final String VISUAL_NOTIFICATIONS_PREFS = &quot;visual_notifications_on&quot;;
+	protected static final String VIBRATION_NOTIFICATIONS_PREFS = &quot;vibration_notifications_on&quot;;
 
 	private Thread backgroundUpdateThread;
+	private	static Activity activity;
 	private static Integer lastId = null;
 	private static boolean serviceStarted = false;
-	
-	public static void setLastId(Integer id) {
+
+	public static void setLastIdAndActivity(Integer id, Activity a) {
 		lastId = id;
+		activity = a;
 	}
 
 	public void onStart(Intent intent, int startId) {
 		super.onStart(intent, startId);
-        serviceStarted = true;
+		serviceStarted = true;
 		mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
-    	Log.v(&quot;UpdateService&quot;, &quot;*** Starting Background Update Service ***&quot;);
+		Log.v(&quot;UpdateService&quot;, &quot;*** Starting Background Update Service ***&quot;);
 		pollServiceForUpdates();
 	}
 
-    @Override
-    public void onDestroy() {
-    	super.onDestroy();
-    	serviceStarted = false;
-        if (this.backgroundUpdateThread != null) {
-            this.backgroundUpdateThread.stop();
-        }
-    	Log.v(&quot;UpdateService&quot;, &quot;*** Destroying Background Update Service ***&quot;);
-        this.stopSelf();
-    }
-    
+	@Override
+	public void onDestroy() {
+		super.onDestroy();
+		serviceStarted = false;
+		if (this.backgroundUpdateThread != null) {
+			this.backgroundUpdateThread.stop();
+		}
+		Log.v(&quot;UpdateService&quot;, &quot;*** Destroying Background Update Service ***&quot;);
+		this.stopSelf();
+	}
+
 	@Override
 	public IBinder onBind(Intent intent) {
 		// TODO Auto-generated method stub
 		return null;
 	}
-	
+
 	private Handler handler = new Handler() {
 		@Override
 		public void handleMessage(Message msg) {
@@ -76,7 +85,7 @@ public class UpdateService extends Service {
 					try {
 						Log.d(&quot;UpdateService&quot;, &quot;Sleeping for &quot; + StatusActivity.getPollingInterval() / 60 / 1000 + &quot; minutes&quot;);
 						Thread.sleep(StatusActivity.getPollingInterval());
-						if(serviceStarted) {
+						if (serviceStarted) {
 							Log.d(&quot;UpdateService&quot;, &quot;About to grab the latest updates&quot;);
 							getLatestUpdatesThread();
 						}
@@ -89,7 +98,7 @@ public class UpdateService extends Service {
 		};
 		this.backgroundUpdateThread.start();
 	}
-	
+
 	public void getLatestUpdatesThread() {
 		Config config = Config.getConfig(this);
 		if (config.getSubdomain() != null &amp;&amp; config.getPassword() != null &amp;&amp; config.getUsername() != null) {
@@ -97,9 +106,9 @@ public class UpdateService extends Service {
 			twitter.requestFriendsTimeline(handler, lastId);
 		}
 	}
-	
+
 	public void checkForNewUpdates(TwitterResponse statuses) {
-		if(statuses.getNumberOfItems() &gt; 0) {
+		if (statuses.getNumberOfItems() &gt; 0) {
 			TwitterEntry lastResponse = statuses.getItemAt(0);
 			if (lastId == null) {
 				lastId = lastResponse.getId();
@@ -112,22 +121,42 @@ public class UpdateService extends Service {
 		}
 	}
 	
+	protected boolean isNotificationsEnabled() {
+		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(activity);
+		Integer interval = Integer.valueOf(pref.getString(VISUAL_NOTIFICATIONS_PREFS, &quot;0&quot;));
+		return interval == 1;
+	}
+
+	protected boolean isVibrationEnabled() {
+		SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(activity);
+		Integer interval = Integer.valueOf(pref.getString(VIBRATION_NOTIFICATIONS_PREFS, &quot;0&quot;));
+		return interval == 1;
+	}
+
+
 	private void showNotification(String notficationText) {
-		try {
-			Intent launchableIntent = new Intent(this, StatusActivity.class);
-			launchableIntent.putExtra(&quot;LastID&quot;, 0);
-			launchableIntent.setFlags(Notification.FLAG_AUTO_CANCEL | PendingIntent.FLAG_CANCEL_CURRENT
-					| Intent.FLAG_ACTIVITY_SINGLE_TOP);
-
-			PendingIntent contentIntent = PendingIntent.getActivity(this, 0, launchableIntent, 0);
-			Notification notification = new Notification(R.drawable.stat_notify_presently, notficationText, System
-					.currentTimeMillis());
-			notification.setLatestEventInfo(this, &quot;Present.ly&quot;, notficationText, contentIntent);
-
-			mNotificationManager.notify((int) (APP_IDENTIFIER), notification);
-		} catch (Exception e) {
-			e.printStackTrace();
+		if(isNotificationsEnabled()) {
+			try {
+				Intent launchableIntent = new Intent(this, StatusActivity.class);
+				launchableIntent.putExtra(&quot;LastID&quot;, 0);
+				launchableIntent.setFlags(Notification.FLAG_AUTO_CANCEL | PendingIntent.FLAG_CANCEL_CURRENT
+						| Intent.FLAG_ACTIVITY_SINGLE_TOP);
+
+				PendingIntent contentIntent = PendingIntent.getActivity(this, 0, launchableIntent, 0);
+				Notification notification = new Notification(R.drawable.stat_notify_presently, notficationText, System
+						.currentTimeMillis());
+				notification.setLatestEventInfo(this, &quot;Present.ly&quot;, notficationText, contentIntent);
+
+				mNotificationManager.notify((int) (APP_IDENTIFIER), notification);
+
+				if(isVibrationEnabled()) {
+					Vibrator vb = (Vibrator)getApplication().getSystemService( Service.VIBRATOR_SERVICE );
+					vb.vibrate(100);
+				}
+
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
 		}
 	}
-
 }
\ No newline at end of file</diff>
      <filename>presently-android/src/com/intridea/presently/android/UpdateService.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0a0931da490b99895fd44dcfa72d68395a6c1b1f</id>
    </parent>
  </parents>
  <author>
    <name>Brendan G. Lim</name>
    <email>brendan@intridea.com</email>
  </author>
  <url>http://github.com/presently/presently-android/commit/a73ce42edaac14a581372fadb47a15ef4383aca9</url>
  <id>a73ce42edaac14a581372fadb47a15ef4383aca9</id>
  <committed-date>2008-12-11T19:08:16-08:00</committed-date>
  <authored-date>2008-12-11T19:08:16-08:00</authored-date>
  <message>Fixing layout issues when device turned in landscape mode.  Also adding in vibration to notifications and an option in preferences to turn it on or off</message>
  <tree>39288901d43804344d6f49134fdb231df152f4e4</tree>
  <committer>
    <name>Brendan G. Lim</name>
    <email>brendan@intridea.com</email>
  </committer>
</commit>
