mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-01 17:26:46 +01:00
close #690
This commit is contained in:
parent
ea2b634b15
commit
978af2abb4
@ -54,6 +54,7 @@ import org.mariotaku.twidere.fragment.filter.FiltersImportMutesFragment
|
||||
import org.mariotaku.twidere.fragment.filter.FiltersSubscriptionsFragment
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment
|
||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCallback
|
||||
import org.mariotaku.twidere.fragment.iface.IFloatingActionButtonFragment
|
||||
import org.mariotaku.twidere.fragment.iface.IToolBarSupportFragment
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback
|
||||
import org.mariotaku.twidere.fragment.message.MessageConversationInfoFragment
|
||||
@ -201,10 +202,6 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSystemWindowsInsets(insets: Rect): Boolean {
|
||||
return super.getSystemWindowsInsets(insets)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
@ -219,6 +216,11 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
override fun onAttachFragment(fragment: Fragment?) {
|
||||
super.onAttachFragment(fragment)
|
||||
updateActionsButton()
|
||||
}
|
||||
|
||||
override fun handleKeyboardShortcutSingle(handler: KeyboardShortcutsHandler, keyCode: Int, event: KeyEvent, metaState: Int): Boolean {
|
||||
if (shouldFragmentTakeAllKeyboardShortcuts()) {
|
||||
return handleFragmentKeyboardShortcutSingle(handler, keyCode, event, metaState)
|
||||
@ -272,6 +274,15 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
||||
|
||||
override fun setControlBarVisibleAnimate(visible: Boolean, listener: ControlBarShowHideHelper.ControlBarAnimationListener?) {
|
||||
// Currently only search page needs this pattern, so we only enable this feature for it.
|
||||
actionsButton?.let { fab ->
|
||||
if (fab.isEnabled) {
|
||||
if (visible) {
|
||||
fab.show()
|
||||
} else {
|
||||
fab.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentVisibleFragment !is HideUiOnScroll) return
|
||||
controlBarShowHideHelper.setControlBarVisibleAnimate(visible, listener)
|
||||
}
|
||||
@ -491,11 +502,22 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
||||
}
|
||||
}
|
||||
|
||||
interface HideUiOnScroll
|
||||
|
||||
private fun updateActionsButton() {
|
||||
val fab = this.actionsButton ?: return
|
||||
val fragment = currentVisibleFragment as? IFloatingActionButtonFragment
|
||||
val info = fragment?.getActionInfo("link_handler") ?: run {
|
||||
fab.visibility = View.GONE
|
||||
fab.isEnabled = false
|
||||
return
|
||||
}
|
||||
fab.visibility = View.VISIBLE
|
||||
fab.isEnabled = true
|
||||
fab.setImageResource(info.icon)
|
||||
fab.contentDescription = info.title
|
||||
}
|
||||
|
||||
@Throws(Utils.NoAccountException::class)
|
||||
fun createFragmentForIntent(context: Context, linkId: Int, intent: Intent): Fragment? {
|
||||
private fun createFragmentForIntent(context: Context, linkId: Int, intent: Intent): Fragment? {
|
||||
intent.setExtrasClassLoader(context.classLoader)
|
||||
val extras = intent.extras
|
||||
val uri = intent.data
|
||||
@ -842,4 +864,6 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
}
|
||||
|
||||
interface HideUiOnScroll
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.mariotaku.twidere.extension.model
|
||||
|
||||
import org.mariotaku.twidere.model.ParcelableStatus
|
||||
import org.mariotaku.twidere.model.ParcelableUser
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/1/7.
|
||||
@ -8,3 +9,23 @@ import org.mariotaku.twidere.model.ParcelableStatus
|
||||
val ParcelableStatus.media_type: Int
|
||||
get() = media?.firstOrNull()?.type ?: 0
|
||||
|
||||
val ParcelableStatus.user: ParcelableUser
|
||||
get() = ParcelableUser(account_key, user_key, user_name, user_screen_name, user_profile_image_url)
|
||||
|
||||
val ParcelableStatus.referenced_users: Array<ParcelableUser>
|
||||
get() {
|
||||
val resultList = mutableSetOf(user)
|
||||
if (quoted_user_key != null) {
|
||||
resultList.add(ParcelableUser(account_key, quoted_user_key, quoted_user_name,
|
||||
quoted_user_screen_name, quoted_user_profile_image))
|
||||
}
|
||||
if (retweeted_by_user_key != null) {
|
||||
resultList.add(ParcelableUser(account_key, retweeted_by_user_key, retweeted_by_user_name,
|
||||
retweeted_by_user_screen_name, retweeted_by_user_profile_image))
|
||||
}
|
||||
mentions?.forEach { mention ->
|
||||
resultList.add(ParcelableUser(account_key, mention.key, mention.name,
|
||||
mention.screen_name, null))
|
||||
}
|
||||
return resultList.toTypedArray()
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.fragment.status
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AlertDialog
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_STATUS
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.extension.model.referenced_users
|
||||
import org.mariotaku.twidere.fragment.BaseDialogFragment
|
||||
import org.mariotaku.twidere.fragment.CreateUserBlockDialogFragment
|
||||
import org.mariotaku.twidere.model.ParcelableStatus
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/2/28.
|
||||
*/
|
||||
|
||||
class BlockStatusUsersDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private val status: ParcelableStatus get() = arguments.getParcelable(EXTRA_STATUS)
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
val referencedUsers = status.referenced_users
|
||||
val nameFirst = preferences[nameFirstKey]
|
||||
val displayNames = referencedUsers.map {
|
||||
userColorNameManager.getDisplayName(it, nameFirst)
|
||||
}.toTypedArray()
|
||||
builder.setTitle(R.string.action_status_block_users)
|
||||
builder.setItems(displayNames) { dialog, which ->
|
||||
CreateUserBlockDialogFragment.show(fragmentManager, referencedUsers[which])
|
||||
}
|
||||
val dialog = builder.create()
|
||||
dialog.setOnShowListener {
|
||||
it as AlertDialog
|
||||
it.applyTheme()
|
||||
}
|
||||
return dialog
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.fragment.status
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AlertDialog
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.twidere.R
|
||||
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_STATUS
|
||||
import org.mariotaku.twidere.constant.nameFirstKey
|
||||
import org.mariotaku.twidere.extension.applyTheme
|
||||
import org.mariotaku.twidere.extension.model.referenced_users
|
||||
import org.mariotaku.twidere.fragment.BaseDialogFragment
|
||||
import org.mariotaku.twidere.fragment.CreateUserMuteDialogFragment
|
||||
import org.mariotaku.twidere.model.ParcelableStatus
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 2017/2/28.
|
||||
*/
|
||||
|
||||
class MuteStatusUsersDialogFragment : BaseDialogFragment() {
|
||||
|
||||
private val status: ParcelableStatus get() = arguments.getParcelable(EXTRA_STATUS)
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val builder = AlertDialog.Builder(context)
|
||||
val referencedUsers = status.referenced_users
|
||||
val nameFirst = preferences[nameFirstKey]
|
||||
val displayNames = referencedUsers.map {
|
||||
userColorNameManager.getDisplayName(it, nameFirst)
|
||||
}.toTypedArray()
|
||||
builder.setTitle(R.string.action_status_mute_users)
|
||||
builder.setItems(displayNames) { dialog, which ->
|
||||
CreateUserMuteDialogFragment.show(fragmentManager, referencedUsers[which])
|
||||
}
|
||||
val dialog = builder.create()
|
||||
dialog.setOnShowListener {
|
||||
it as AlertDialog
|
||||
it.applyTheme()
|
||||
}
|
||||
return dialog
|
||||
}
|
||||
}
|
@ -38,6 +38,8 @@ import android.view.ContextMenu
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import org.mariotaku.kpreferences.get
|
||||
import org.mariotaku.ktextension.Bundle
|
||||
import org.mariotaku.ktextension.set
|
||||
import org.mariotaku.ktextension.setItemChecked
|
||||
import org.mariotaku.ktextension.setMenuItemIcon
|
||||
import org.mariotaku.sqliteqb.library.Expression
|
||||
@ -52,6 +54,8 @@ import org.mariotaku.twidere.fragment.AbsStatusesFragment
|
||||
import org.mariotaku.twidere.fragment.AddStatusFilterDialogFragment
|
||||
import org.mariotaku.twidere.fragment.DestroyStatusDialogFragment
|
||||
import org.mariotaku.twidere.fragment.SetUserNicknameDialogFragment
|
||||
import org.mariotaku.twidere.fragment.status.BlockStatusUsersDialogFragment
|
||||
import org.mariotaku.twidere.fragment.status.MuteStatusUsersDialogFragment
|
||||
import org.mariotaku.twidere.graphic.ActionIconDrawable
|
||||
import org.mariotaku.twidere.graphic.PaddingDrawable
|
||||
import org.mariotaku.twidere.menu.FavoriteItemProvider
|
||||
@ -92,7 +96,7 @@ object MenuUtils {
|
||||
}
|
||||
|
||||
@JvmOverloads fun addIntentToMenu(context: Context?, menu: Menu?, queryIntent: Intent?,
|
||||
groupId: Int = Menu.NONE) {
|
||||
groupId: Int = Menu.NONE) {
|
||||
if (context == null || menu == null || queryIntent == null) return
|
||||
val pm = context.packageManager
|
||||
val res = context.resources
|
||||
@ -118,11 +122,11 @@ object MenuUtils {
|
||||
}
|
||||
|
||||
fun setupForStatus(context: Context,
|
||||
preferences: SharedPreferencesWrapper,
|
||||
menu: Menu,
|
||||
status: ParcelableStatus,
|
||||
twitter: AsyncTwitterWrapper,
|
||||
manager: UserColorNameManager) {
|
||||
preferences: SharedPreferencesWrapper,
|
||||
menu: Menu,
|
||||
status: ParcelableStatus,
|
||||
twitter: AsyncTwitterWrapper,
|
||||
manager: UserColorNameManager) {
|
||||
val account = AccountUtils.getAccountDetails(AccountManager.get(context),
|
||||
status.account_key, true) ?: return
|
||||
setupForStatus(context, preferences, menu, status, account, twitter, manager)
|
||||
@ -130,12 +134,12 @@ object MenuUtils {
|
||||
|
||||
@UiThread
|
||||
fun setupForStatus(context: Context,
|
||||
preferences: SharedPreferencesWrapper,
|
||||
menu: Menu,
|
||||
status: ParcelableStatus,
|
||||
details: AccountDetails,
|
||||
twitter: AsyncTwitterWrapper,
|
||||
manager: UserColorNameManager) {
|
||||
preferences: SharedPreferencesWrapper,
|
||||
menu: Menu,
|
||||
status: ParcelableStatus,
|
||||
details: AccountDetails,
|
||||
twitter: AsyncTwitterWrapper,
|
||||
manager: UserColorNameManager) {
|
||||
if (menu is ContextMenu) {
|
||||
menu.setHeaderTitle(context.getString(R.string.status_menu_title_format,
|
||||
manager.getDisplayName(status.user_key, status.user_name, status.user_screen_name,
|
||||
@ -225,12 +229,12 @@ object MenuUtils {
|
||||
}
|
||||
|
||||
fun handleStatusClick(context: Context,
|
||||
fragment: Fragment?,
|
||||
fm: FragmentManager,
|
||||
colorNameManager: UserColorNameManager,
|
||||
twitter: AsyncTwitterWrapper,
|
||||
status: ParcelableStatus,
|
||||
item: MenuItem): Boolean {
|
||||
fragment: Fragment?,
|
||||
fm: FragmentManager,
|
||||
colorNameManager: UserColorNameManager,
|
||||
twitter: AsyncTwitterWrapper,
|
||||
status: ParcelableStatus,
|
||||
item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.copy -> {
|
||||
if (ClipboardUtils.setText(context, status.text_plain)) {
|
||||
@ -334,6 +338,20 @@ object MenuUtils {
|
||||
val whereArgs = arrayOf(status._id.toString())
|
||||
resolver.update(Statuses.CONTENT_URI, values, where, whereArgs)
|
||||
}
|
||||
R.id.mute_users -> {
|
||||
val df = MuteStatusUsersDialogFragment()
|
||||
df.arguments = Bundle {
|
||||
this[EXTRA_STATUS] = status
|
||||
}
|
||||
df.show(fm, "mute_users_selector")
|
||||
}
|
||||
R.id.block_users -> {
|
||||
val df = BlockStatusUsersDialogFragment()
|
||||
df.arguments = Bundle {
|
||||
this[EXTRA_STATUS] = status
|
||||
}
|
||||
df.show(fm, "block_users_selector")
|
||||
}
|
||||
else -> {
|
||||
if (item.intent != null) {
|
||||
try {
|
||||
|
@ -7,6 +7,12 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/contentFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/toolbar"/>
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
@ -17,11 +23,19 @@
|
||||
app:popupTheme="?actionBarPopupTheme"
|
||||
tools:elevation="0dp"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/contentFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/toolbar"/>
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/actionsButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="@dimen/element_spacing_large"
|
||||
android:clickable="true"
|
||||
android:src="@drawable/ic_action_status_compose"
|
||||
app:backgroundTint="?colorToolbar"
|
||||
app:elevation="6dp"
|
||||
app:pressedTranslationZ="12dp"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/windowOverlay"
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
@ -10,5 +11,17 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/actionsButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="@dimen/element_spacing_large"
|
||||
android:clickable="true"
|
||||
android:src="@drawable/ic_action_status_compose"
|
||||
app:backgroundTint="?colorToolbar"
|
||||
app:elevation="6dp"
|
||||
app:pressedTranslationZ="12dp"/>
|
||||
</RelativeLayout>
|
Loading…
x
Reference in New Issue
Block a user