adding a launcher shortcut for creating new events quicker
This commit is contained in:
parent
0c590e477d
commit
69fd4ed5cc
6 changed files with 60 additions and 0 deletions
|
@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
|
|||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'de.timfreiheit.resourceplaceholders'
|
||||
|
||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
def keystoreProperties = new Properties()
|
||||
|
@ -49,6 +50,10 @@ android {
|
|||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
resourcePlaceholders {
|
||||
files = ['xml/shortcuts.xml']
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -391,6 +391,10 @@
|
|||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.app.shortcuts"
|
||||
android:resource="@xml/shortcuts"/>
|
||||
</activity-alias>
|
||||
|
||||
<activity-alias
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.simplemobiletools.calendar.pro.activities
|
||||
|
||||
import android.content.Intent
|
||||
import com.simplemobiletools.calendar.pro.extensions.getNewEventTimestampFromCode
|
||||
import com.simplemobiletools.calendar.pro.helpers.*
|
||||
import com.simplemobiletools.commons.activities.BaseSplashActivity
|
||||
import org.joda.time.DateTime
|
||||
|
||||
class SplashActivity : BaseSplashActivity() {
|
||||
override fun getAppPackageName() = packageName
|
||||
|
@ -19,6 +21,13 @@ class SplashActivity : BaseSplashActivity() {
|
|||
putExtra(EVENT_OCCURRENCE_TS, intent.getLongExtra(EVENT_OCCURRENCE_TS, 0L))
|
||||
startActivity(this)
|
||||
}
|
||||
intent.action == "shortcut_new_event" -> {
|
||||
val dayCode = Formatter.getDayCodeFromDateTime(DateTime())
|
||||
Intent(this, EventActivity::class.java).apply {
|
||||
putExtra(NEW_EVENT_START_TS, getNewEventTimestampFromCode(dayCode))
|
||||
startActivity(this)
|
||||
}
|
||||
}
|
||||
else -> startActivity(Intent(this, MainActivity::class.java))
|
||||
}
|
||||
finish()
|
||||
|
|
16
app/src/main/res/drawable/shortcut_plus_orange.xml
Normal file
16
app/src/main/res/drawable/shortcut_plus_orange.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/color_primary"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:bottom="@dimen/medium_margin"
|
||||
android:drawable="@drawable/ic_plus"
|
||||
android:left="@dimen/medium_margin"
|
||||
android:right="@dimen/medium_margin"
|
||||
android:top="@dimen/medium_margin"/>
|
||||
|
||||
</layer-list>
|
24
app/src/main/res/xml/shortcuts.xml
Normal file
24
app/src/main/res/xml/shortcuts.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shortcuts
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<shortcut
|
||||
android:enabled="true"
|
||||
android:icon="@drawable/shortcut_plus_orange"
|
||||
android:shortcutDisabledMessage="@string/new_event"
|
||||
android:shortcutId="new_event"
|
||||
android:shortcutLongLabel="@string/new_event"
|
||||
android:shortcutShortLabel="@string/new_event "
|
||||
tools:targetApi="n_mr1">
|
||||
|
||||
<intent
|
||||
android:action="shortcut_new_event"
|
||||
android:targetClass="com.simplemobiletools.calendar.pro.activities.SplashActivity"
|
||||
android:targetPackage="${applicationId}"/>
|
||||
|
||||
<categories
|
||||
android:name="android.shortcut.conversation"/>
|
||||
|
||||
</shortcut>
|
||||
</shortcuts>
|
|
@ -6,11 +6,13 @@ buildscript {
|
|||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://plugins.gradle.org/m2" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.3.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "de.timfreiheit.resourceplaceholders:placeholders:0.3"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
Loading…
Reference in a new issue