Add actions to toggle showing touches and stop recording.

Change-Id: I5104253a64853b74c64a6ec5d68f66e17de3a3fc
diff --git a/res/drawable-hdpi/ic_show_touch_disabled.png b/res/drawable-hdpi/ic_show_touch_disabled.png
new file mode 100644
index 0000000..d698cb5
--- /dev/null
+++ b/res/drawable-hdpi/ic_show_touch_disabled.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_show_touch_enabled.png b/res/drawable-hdpi/ic_show_touch_enabled.png
new file mode 100644
index 0000000..a77b1d9
--- /dev/null
+++ b/res/drawable-hdpi/ic_show_touch_enabled.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_stop_recording.png b/res/drawable-hdpi/ic_stop_recording.png
new file mode 100644
index 0000000..f70881a
--- /dev/null
+++ b/res/drawable-hdpi/ic_stop_recording.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_show_touch_disabled.png b/res/drawable-mdpi/ic_show_touch_disabled.png
new file mode 100644
index 0000000..0ba0242
--- /dev/null
+++ b/res/drawable-mdpi/ic_show_touch_disabled.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_show_touch_enabled.png b/res/drawable-mdpi/ic_show_touch_enabled.png
new file mode 100644
index 0000000..0d820f6
--- /dev/null
+++ b/res/drawable-mdpi/ic_show_touch_enabled.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_stop_recording.png b/res/drawable-mdpi/ic_stop_recording.png
new file mode 100644
index 0000000..696b186
--- /dev/null
+++ b/res/drawable-mdpi/ic_stop_recording.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_show_touch_disabled.png b/res/drawable-xhdpi/ic_show_touch_disabled.png
new file mode 100644
index 0000000..329f78c
--- /dev/null
+++ b/res/drawable-xhdpi/ic_show_touch_disabled.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_show_touch_enabled.png b/res/drawable-xhdpi/ic_show_touch_enabled.png
new file mode 100644
index 0000000..31456c4
--- /dev/null
+++ b/res/drawable-xhdpi/ic_show_touch_enabled.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_stop_recording.png b/res/drawable-xhdpi/ic_stop_recording.png
new file mode 100644
index 0000000..dbf357d
--- /dev/null
+++ b/res/drawable-xhdpi/ic_stop_recording.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_show_touch_disabled.png b/res/drawable-xxhdpi/ic_show_touch_disabled.png
new file mode 100644
index 0000000..ed1658b
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_show_touch_disabled.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_show_touch_enabled.png b/res/drawable-xxhdpi/ic_show_touch_enabled.png
new file mode 100644
index 0000000..b8e4771
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_show_touch_enabled.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_stop_recording.png b/res/drawable-xxhdpi/ic_stop_recording.png
new file mode 100644
index 0000000..90fd592
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_stop_recording.png
Binary files differ
diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml
index 226fa30..c87b741 100644
--- a/res/values-el/strings.xml
+++ b/res/values-el/strings.xml
@@ -4,7 +4,6 @@
     <string name="app_name">ScreenRecorder</string>
 
     <string name="notification_recording_title">Η καταγραφή οθόνης βρίσκεται σε εξέλιξη</string>
-    <string name="notification_recording_text">Πατήστε αυτή την ειδοποίηση για να σταματήσετε την καταγραφή</string>
 
     <string name="notification_recording_finished_title">Η καταγραφή αποθηκεύτηκε</string>
     <string name="notification_recording_finished_text">Πατήστε για να δείτε %s</string>
diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml
index 98a848f..3150aee 100644
--- a/res/values-sk/strings.xml
+++ b/res/values-sk/strings.xml
@@ -4,7 +4,6 @@
     <string name="app_name">ScreenRecorder</string>
 
     <string name="notification_recording_title">Prebieha nahrávanie obrazovky</string>
-    <string name="notification_recording_text">Kliknite pre zastavenie nahrávania</string>
 
     <string name="notification_recording_finished_title">Nahrávka uložená</string>
     <string name="notification_recording_finished_text">Kliknite pre zobrazenie %s</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d08bd6e..4f228ce 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4,7 +4,6 @@
     <string name="app_name">ScreenRecorder</string>
 
     <string name="notification_recording_title">Screen recording in progress</string>
-    <string name="notification_recording_text">Press this notification to stop recording</string>
 
     <string name="notification_recording_finished_title">Screen recording saved</string>
     <string name="notification_recording_finished_text">Touch to view %s</string>
@@ -12,6 +11,11 @@
     <string name="notification_recording_error_title">Screen recorder error</string>
     <string name="notification_recording_error_text">%s</string>
 
+    <string name="notification_video_processing_title">Processing recorded video</string>
+
+    <string name="notification_action_stop_recording">Stop recording</string>
+    <string name="notification_action_show_touch">Show touch</string>
+
     <string name="error_unable_to_create_directory">Unable to create output directory.</string>
     <string name="error_external_storage_unavailable">No external storage available.</string>
     <string name="error_unable_to_start">Unable to start recording.</string>
diff --git a/src/org/chameleonos/screenrecorder/ScreenRecorderService.java b/src/org/chameleonos/screenrecorder/ScreenRecorderService.java
index 1e1fb93..57a8cf7 100644
--- a/src/org/chameleonos/screenrecorder/ScreenRecorderService.java
+++ b/src/org/chameleonos/screenrecorder/ScreenRecorderService.java
@@ -49,6 +49,8 @@
             = "org.chameleonos.action.NOTIFY_RECORD_SERVICE";
     public static final String ACTION_NOTIFY_DELETE_SCREENRECORD
             = "org.chameleonos.action.NOTIFY_DELETE_SCREENRECORD";
+    public static final String ACTION_NOTIFY_TOGGLE_SHOW_TOUCHES
+            = "org.chameleonos.action.NOTIFY_TOGGLE_SHOW_TOUCHES";
     public static final String SCREENRECORD_PATH
             = "org.chameleonos.screenrecorder.SCREENRECORD_PATH";
 
@@ -84,6 +86,7 @@
         } else {
             sActionSound.play(MediaActionSound.STOP_VIDEO_RECORDING);
             sScreenRecorder.stop();
+            postProcessingNotification();
         }
     }
 
@@ -161,18 +164,44 @@
     }
 
     private void postRecordingNotification() {
+        // set an action for stopping recording
         Intent intent = new Intent(ACTION_NOTIFY_RECORD_SERVICE);
-        PendingIntent contentIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
+        PendingIntent stopIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
+        intent = new Intent(this, ScreenRecorderService.class);
+
+        // set an action for toggling show touches
+        intent.setAction(ACTION_NOTIFY_TOGGLE_SHOW_TOUCHES);
+        PendingIntent showTouchesIntent = PendingIntent.getService(this, 0,
+                intent, 0);
+        final boolean showTouches = Settings.System.getInt(getContentResolver(),
+                Settings.System.SHOW_TOUCHES, 0) == 1;
         NotificationManager nm =
                 (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
         Notification notice = new Notification.Builder(this)
                 .setAutoCancel(false)
                 .setOngoing(true)
                 .setContentTitle(getString(R.string.notification_recording_title))
-                .setContentText(getString(R.string.notification_recording_text))
                 .setSmallIcon(R.drawable.ic_notify_screen_recorder)
                 .setWhen(System.currentTimeMillis())
-                .setContentIntent(contentIntent)
+                .setPriority(Integer.MAX_VALUE)
+                .addAction(R.drawable.ic_stop_recording,
+                        getString(R.string.notification_action_stop_recording), stopIntent)
+                .addAction(showTouches ? R.drawable.ic_show_touch_enabled
+                        : R.drawable.ic_show_touch_disabled,
+                        getString(R.string.notification_action_show_touch), showTouchesIntent)
+                .build();
+        nm.notify(NOTIFICATION_ID, notice);
+    }
+
+    private void postProcessingNotification() {
+        NotificationManager nm =
+                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+        Notification notice = new Notification.Builder(this)
+                .setAutoCancel(true)
+                .setOngoing(false)
+                .setContentTitle(getString(R.string.notification_video_processing_title))
+                .setSmallIcon(R.drawable.ic_notify_screen_recorder)
+                .setWhen(System.currentTimeMillis())
                 .build();
         nm.notify(NOTIFICATION_ID, notice);
     }
@@ -288,8 +317,16 @@
 
     @Override
     protected void onHandleIntent(Intent intent) {
-        if (ACTION_NOTIFY_RECORD_SERVICE.equals(intent.getAction())) {
+        final String action = intent.getAction();
+        if (ACTION_NOTIFY_RECORD_SERVICE.equals(action)) {
             startOrStopRecording();
+        } else if (ACTION_NOTIFY_TOGGLE_SHOW_TOUCHES.equals(action)) {
+            final boolean showTouches = Settings.System.getInt(getContentResolver(),
+                    Settings.System.SHOW_TOUCHES, 0) == 1;
+            Settings.System.putInt(getContentResolver(),
+                    Settings.System.SHOW_TOUCHES, showTouches ? 0 : 1);
+            // call postRecordingNotification so the icon gets updated based on this change
+            postRecordingNotification();
         }
     }
 }