summaryrefslogtreecommitdiffstats
path: root/src/com/android/deskclock/HandleShortcuts.java
diff options
context:
space:
mode:
authorJustin Klaassen <justinklaassen@google.com>2016-08-28 18:59:40 -0700
committerJustin Klaassen <justinklaassen@google.com>2016-08-30 10:33:50 -0700
commitab6a8e1f3e21977b0fddfa03ee0ba942830dc00a (patch)
tree4ae1a9fada600661e32da82e447526d36e747bcb /src/com/android/deskclock/HandleShortcuts.java
parent1791cebccf4e62a19a215909b92474b159456bf4 (diff)
downloadandroid_packages_apps_DeskClock-ab6a8e1f3e21977b0fddfa03ee0ba942830dc00a.tar.gz
android_packages_apps_DeskClock-ab6a8e1f3e21977b0fddfa03ee0ba942830dc00a.tar.bz2
android_packages_apps_DeskClock-ab6a8e1f3e21977b0fddfa03ee0ba942830dc00a.zip
Cleanup exported APIs
Bug: 30076796 - Removed preliminary support for deeplinks since Clock doesn't have a public content provider. - Removed unnecessarily exported intent actions since Intents specifying explicit components don't need to register specific actions. - Removed unused strings and resources. Change-Id: Ifbee006dbd752ecdcfe0125cabe19ffda40ea659
Diffstat (limited to 'src/com/android/deskclock/HandleShortcuts.java')
-rw-r--r--src/com/android/deskclock/HandleShortcuts.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/com/android/deskclock/HandleShortcuts.java b/src/com/android/deskclock/HandleShortcuts.java
new file mode 100644
index 000000000..00094d84e
--- /dev/null
+++ b/src/com/android/deskclock/HandleShortcuts.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.deskclock;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+
+import com.android.deskclock.data.DataModel;
+import com.android.deskclock.events.Events;
+import com.android.deskclock.stopwatch.StopwatchService;
+import com.android.deskclock.uidata.UiDataModel;
+
+import static com.android.deskclock.uidata.UiDataModel.Tab.STOPWATCH;
+
+public class HandleShortcuts extends Activity {
+
+ private static final LogUtils.Logger LOGGER = new LogUtils.Logger("HandleShortcuts");
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final Intent intent = getIntent();
+
+ try {
+ final String action = intent.getAction();
+ switch (action) {
+ case StopwatchService.ACTION_PAUSE_STOPWATCH:
+ Events.sendStopwatchEvent(R.string.action_pause, R.string.label_shortcut);
+ DataModel.getDataModel().pauseStopwatch();
+
+ // Open DeskClock positioned on the stopwatch tab.
+ UiDataModel.getUiDataModel().setSelectedTab(STOPWATCH);
+ startActivity(new Intent(this, DeskClock.class));
+ setResult(RESULT_OK);
+ break;
+ case StopwatchService.ACTION_START_STOPWATCH:
+ Events.sendStopwatchEvent(R.string.action_start, R.string.label_shortcut);
+ DataModel.getDataModel().startStopwatch();
+
+ // Open DeskClock positioned on the stopwatch tab.
+ UiDataModel.getUiDataModel().setSelectedTab(STOPWATCH);
+ startActivity(new Intent(this, DeskClock.class));
+ setResult(RESULT_OK);
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported action: " + action);
+ }
+ } catch (Exception e) {
+ LOGGER.e("Error handling intent: " + intent, e);
+ setResult(RESULT_CANCELED);
+ } finally {
+ finish();
+ }
+ }
+}