blob: af7eb75ec92a8639a37f591ef9894287c4e32273 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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.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);
}
});
}
}
|