Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDobli <61doal1mst@hft-stuttgart.de>2018-03-14 17:07:21 +0300
committerNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2018-04-06 21:36:17 +0300
commit2dc184160324bcca68d0d7748da59cbfdf2903de (patch)
treecca6ff05cb6b444462770c353f3a99669e5b6602 /app/src/main/java/it/niedermann/owncloud/notes/android/quicksettings/NewNoteTileService.java
parentbaff5083766fffe4bd07697179599f88ec94f633 (diff)
Added support for a quick settings tile to create a new note (only on Android 7.0+)
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/android/quicksettings/NewNoteTileService.java')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/android/quicksettings/NewNoteTileService.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/android/quicksettings/NewNoteTileService.java b/app/src/main/java/it/niedermann/owncloud/notes/android/quicksettings/NewNoteTileService.java
new file mode 100644
index 00000000..9b29fe43
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/android/quicksettings/NewNoteTileService.java
@@ -0,0 +1,41 @@
+package it.niedermann.owncloud.notes.android.quicksettings;
+
+import android.annotation.TargetApi;
+import android.content.Intent;
+import android.os.Build;
+import android.service.quicksettings.Tile;
+import android.service.quicksettings.TileService;
+
+import it.niedermann.owncloud.notes.android.activity.CreateNoteActivity;
+
+/**
+ * This {@link TileService} adds a quick settings tile that leads to the new note view.
+ */
+@TargetApi(Build.VERSION_CODES.N)
+public class NewNoteTileService extends TileService {
+
+ @Override
+ public void onStartListening() {
+ Tile tile = getQsTile();
+ tile.setState(Tile.STATE_ACTIVE);
+
+ tile.updateTile();
+ }
+
+ @Override
+ public void onClick() {
+ // create new note intent
+ final Intent newNoteIntent = new Intent(getApplicationContext(), CreateNoteActivity.class);
+ // ensure it won't open twice if already running
+ newNoteIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+
+ // ask to unlock the screen if locked, then start new note intent
+ unlockAndRun(new Runnable() {
+ @Override
+ public void run() {
+ startActivityAndCollapse(newNoteIntent);
+ }
+ });
+
+ }
+}