mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-07 23:38:40 +01:00
fixed compose shortcut
This commit is contained in:
parent
c21e6ebcb5
commit
16e1d2b977
@ -391,7 +391,8 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.shortcut.CreateComposeShortcutActivity"
|
||||
android:icon="@drawable/ic_app_shortcut_compose"
|
||||
android:enabled="@bool/use_legacy_widget_shortcuts"
|
||||
android:icon="@mipmap/ic_shortcut_compose"
|
||||
android:label="@string/title_compose"
|
||||
android:theme="@style/Theme.Twidere.NoDisplay">
|
||||
<intent-filter>
|
||||
|
@ -21,9 +21,10 @@ package org.mariotaku.twidere.activity.shortcut
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Canvas
|
||||
import android.os.Bundle
|
||||
import android.support.v4.content.pm.ShortcutInfoCompat
|
||||
import android.support.v4.content.pm.ShortcutManagerCompat
|
||||
import android.support.v4.graphics.drawable.IconCompat
|
||||
import org.mariotaku.twidere.BuildConfig
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.IntentConstants.INTENT_ACTION_COMPOSE
|
||||
@ -32,27 +33,12 @@ class CreateComposeShortcutActivity : Activity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setVisible(true)
|
||||
val intent = Intent()
|
||||
val launchIntent = Intent(INTENT_ACTION_COMPOSE).apply {
|
||||
`package` = BuildConfig.APPLICATION_ID
|
||||
}
|
||||
val icon = BitmapFactory.decodeResource(resources, R.drawable.ic_app_shortcut_compose,
|
||||
BitmapFactory.Options().apply { inMutable = true }).apply {
|
||||
val appIcon = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher, BitmapFactory.Options().apply {
|
||||
inSampleSize = 3
|
||||
})
|
||||
val canvas = Canvas(this)
|
||||
val appIconLeft = (width - appIcon.width).toFloat()
|
||||
val appIconTop = (height - appIcon.height).toFloat()
|
||||
canvas.drawBitmap(appIcon, appIconLeft, appIconTop, null)
|
||||
appIcon.recycle()
|
||||
}
|
||||
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent)
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon)
|
||||
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.action_compose))
|
||||
setResult(RESULT_OK, intent)
|
||||
val shortcut = ShortcutInfoCompat.Builder(this, "compose")
|
||||
.setIcon(IconCompat.createWithResource(this, R.mipmap.ic_shortcut_compose))
|
||||
.setShortLabel(getString(R.string.action_compose))
|
||||
.setIntent(Intent(INTENT_ACTION_COMPOSE).setPackage(BuildConfig.APPLICATION_ID))
|
||||
.build()
|
||||
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(this, shortcut))
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
23
twidere/src/main/res/values-v25/configs.xml
Normal file
23
twidere/src/main/res/values-v25/configs.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Twidere - Twitter client for Android
|
||||
~
|
||||
~ Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<bool name="use_legacy_widget_shortcuts">false</bool>
|
||||
</resources>
|
@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<bool name="support_new_document_intent">false</bool>
|
||||
|
||||
<bool name="use_job_refresh_service">false</bool>
|
||||
<bool name="use_legacy_refresh_service">true</bool>
|
||||
<bool name="support_new_document_intent">false</bool>
|
||||
</resources>
|
||||
<bool name="use_legacy_widget_shortcuts">true</bool>
|
||||
</resources>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<bool name="default_multi_column_tabs_land">false</bool>
|
||||
<bool name="default_multi_column_tabs_port">false</bool>
|
||||
|
Loading…
x
Reference in New Issue
Block a user