Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c16a929 authored by Niedermann IT-Dienstleistungen's avatar Niedermann IT-Dienstleistungen
Browse files
parents 19fc0d61 cf3037e4
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -141,5 +141,17 @@
            android:name=".android.appwidget.NoteListWidgetService"
            android:permission="android.permission.BIND_REMOTEVIEWS" />

        <service
            android:name="it.niedermann.owncloud.notes.android.quicksettings.NewNoteTileService"
            android:icon="@drawable/ic_quicksettings_new"
            android:label="@string/action_create"
            android:description="@string/action_create"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
            <intent-filter>
                <action
                    android:name="android.service.quicksettings.action.QS_TILE"/>
            </intent-filter>
        </service>

    </application>
</manifest>
+41 −0
Original line number Diff line number Diff line
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.EditNoteActivity;

/**
 * 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(), EditNoteActivity.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);
            }
        });

    }
}
+1.28 KiB
Loading image diff...
+900 B
Loading image diff...
+1.68 KiB
Loading image diff...
Loading