added list timeline shortcut

This commit is contained in:
Mariotaku Lee 2017-09-02 14:29:00 +08:00
parent 2abab7c256
commit 302180b95b
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
16 changed files with 102 additions and 1 deletions

View File

@ -444,6 +444,17 @@
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".activity.shortcut.UserListTimelineShortcutCreatorActivity"
android:icon="@mipmap/ic_shortcut_list"
android:label="@string/title_user_list"
android:theme="@style/Theme.Twidere.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".activity.RequestPermissionsActivity"
android:label="@string/permissions_request"

View File

@ -0,0 +1,35 @@
/*
* 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/>.
*/
package org.mariotaku.twidere.activity.shortcut
import org.mariotaku.twidere.model.ParcelableUserList
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.util.shortcut.ShortcutCreator
/**
* Created by mariotaku on 2017/9/2.
*/
class UserListTimelineShortcutCreatorActivity : AbsUserListRelatedShortcutCreatorActivity() {
override fun onUserListSelected(accountKey: UserKey?, userList: ParcelableUserList) {
addShortcut { ShortcutCreator.userListTimeline(this, accountKey, userList) }
}
}

View File

@ -1882,6 +1882,5 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
private const val TAB_TYPE_STATUSES_WITH_REPLIES = "statuses_with_replies"
private const val TAB_TYPE_MEDIA = "media"
private const val TAB_TYPE_FAVORITES = "favorites"
private const val FRAGMENT_TAG_ADD_SHORTCUT_TO_HOME_SCREEN = "add_shortcut_to_home_screen"
}
}

View File

@ -44,6 +44,7 @@ import org.mariotaku.twidere.extension.loadProfileImage
import org.mariotaku.twidere.extension.showProgressDialog
import org.mariotaku.twidere.fragment.BaseFragment
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.model.ParcelableUserList
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.util.IntentUtils
import org.mariotaku.twidere.util.dagger.DependencyHolder
@ -130,6 +131,19 @@ object ShortcutCreator {
return Promise.of(builder.build())
}
fun userListTimeline(context: Context, accountKey: UserKey?, list: ParcelableUserList): Promise<ShortcutInfoCompat, Exception> {
val holder = DependencyHolder.get(context)
val preferences = holder.preferences
val userColorNameManager = holder.userColorNameManager
val launchIntent = IntentUtils.userListTimeline(accountKey, list.id,
list.user_key, list.user_screen_name, list.name)
val builder = ShortcutInfoCompat.Builder(context, "$accountKey:user-list-timeline:${list.id}")
builder.setIntent(launchIntent)
builder.setShortLabel(userColorNameManager.getDisplayName(list, preferences[nameFirstKey]))
builder.setIcon(IconCompat.createWithResource(context, R.mipmap.ic_shortcut_list))
return Promise.of(builder.build())
}
inline fun performCreation(fragment: BaseFragment, createPromise: () -> Promise<ShortcutInfoCompat, Exception>) {
if (!ShortcutManagerCompat.isRequestPinShortcutSupported(fragment.context)) return
val promise = fragment.showProgressDialog("create_shortcut")

View File

@ -0,0 +1,24 @@
<?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/>.
-->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/bg_ic_shortcut_adaptive"/>
<foreground android:drawable="@mipmap/ic_shortcut_list_adaptive_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="108px" height="108px" viewBox="0 0 108 108" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
<title>ic_shortcut_list_adaptive_foreground-mdpi</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="App-Icon-Adaptive" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Shortcut-/-List-Timeline">
<g id="Foreground">
<g id="Group-2" transform="translate(18.000000, 18.000000)">
<rect id="Rectangle-2" x="0" y="0" width="72" height="72"></rect>
<path d="M15.75,38.25 L20.25,38.25 L20.25,33.75 L15.75,33.75 L15.75,38.25 Z M15.75,47.25 L20.25,47.25 L20.25,42.75 L15.75,42.75 L15.75,47.25 Z M15.75,29.25 L20.25,29.25 L20.25,24.75 L15.75,24.75 L15.75,29.25 Z M24.75,38.25 L56.25,38.25 L56.25,33.75 L24.75,33.75 L24.75,38.25 Z M24.75,47.25 L56.25,47.25 L56.25,42.75 L24.75,42.75 L24.75,47.25 Z M24.75,24.75 L24.75,29.25 L56.25,29.25 L56.25,24.75 L24.75,24.75 Z" id="Shape" fill="#2196F3" fill-rule="nonzero"></path>
</g>
<rect id="Guide" x="18" y="18" width="72" height="72"></rect>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB