Do not launch clock when touching the clock on the lockscreen

Bug: 7640566

On the lock screen:
Do not launch clock at all, launch CitiesActivity when clicking on the world clock.
On the home screen:
Launch the clock app when touching the clock, launch CitiesActivity when
clicking on the world clock.

Change-Id: I09302f35c7c585bfd1db010eb3f14feea84e34af
diff --git a/src/com/android/alarmclock/DigitalAppWidgetProvider.java b/src/com/android/alarmclock/DigitalAppWidgetProvider.java
index dbcb68e..e8ceb20 100644
--- a/src/com/android/alarmclock/DigitalAppWidgetProvider.java
+++ b/src/com/android/alarmclock/DigitalAppWidgetProvider.java
@@ -19,6 +19,7 @@
 import android.app.PendingIntent;
 import android.appwidget.AppWidgetManager;
 import android.appwidget.AppWidgetProvider;
+import android.appwidget.AppWidgetProviderInfo;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -37,6 +38,7 @@
 import com.android.deskclock.DeskClock;
 import com.android.deskclock.R;
 import com.android.deskclock.Utils;
+import com.android.deskclock.worldclock.CitiesActivity;
 
 import java.util.Calendar;
 
@@ -72,8 +74,14 @@
     private void updateClock(
             Context c, AppWidgetManager appWidgetManager, int appWidgetId, float ratio) {
         RemoteViews widget = new RemoteViews(c.getPackageName(), R.layout.digital_appwidget);
-        widget.setOnClickPendingIntent(R.id.digital_appwidget,
-                PendingIntent.getActivity(c, 0, new Intent(c, DeskClock.class), 0));
+        // launch clock when clicking on the time in the widget only if not a lock screen widget
+        Bundle newOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
+        if (newOptions != null &&
+                newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, -1)
+                != AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) {
+            widget.setOnClickPendingIntent(R.id.digital_appwidget,
+                    PendingIntent.getActivity(c, 0, new Intent(c, DeskClock.class), 0));
+        }
         refreshAlarm(c, widget);
         WidgetUtils.setClockSize(c, widget, ratio);
         final Intent intent = new Intent(c, DigitalAppWidgetService.class);
@@ -81,7 +89,7 @@
         intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
         widget.setRemoteAdapter(appWidgetId, R.id.digital_appwidget_listview, intent);
         widget.setPendingIntentTemplate(R.id.digital_appwidget_listview,
-                PendingIntent.getActivity(c, 0, new Intent(c, DeskClock.class), 0));
+                PendingIntent.getActivity(c, 0, new Intent(c, CitiesActivity.class), 0));
         appWidgetManager.notifyAppWidgetViewDataChanged(
                 appWidgetId, R.id.digital_appwidget_listview);
         appWidgetManager.updateAppWidget(appWidgetId, widget);
diff --git a/src/com/android/deskclock/timer/CountingTimerView.java b/src/com/android/deskclock/timer/CountingTimerView.java
index 417e9b1..5124b13 100644
--- a/src/com/android/deskclock/timer/CountingTimerView.java
+++ b/src/com/android/deskclock/timer/CountingTimerView.java
@@ -53,9 +53,9 @@
     private final Paint mPaintMed = new Paint();
     private final Paint mPaintLabel = new Paint();
     private final float mBigFontSize, mSmallFontSize;
-    private SignedTime mBigHours, mBigMinutes;
-    private UnsignedTime mBigThinSeconds;
-    private Hundredths mMedHundredths;
+    private final SignedTime mBigHours, mBigMinutes;
+    private final UnsignedTime mBigThinSeconds;
+    private final Hundredths mMedHundredths;
     private float mTextHeight = 0;
     private float mTotalTextWidth;
     private static final String HUNDREDTH_SEPERATOR = ".";
@@ -87,7 +87,7 @@
         protected Paint mPaint;
         protected float mEm;
         protected float mWidth = 0;
-        private String mWidest;
+        private final String mWidest;
         protected String mLabel;
         private float mLabelWidth = 0;