Merge pull request #1265 from Xefir/1027

Backport #1027 No option visit list's creator profile
This commit is contained in:
Tlaster 2020-04-22 17:02:10 +08:00 committed by GitHub
commit 27ffaa7af6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -31,18 +31,24 @@ fun <T : Dialog> T.applyOnShow(action: T.() -> Unit) {
}
}
fun AlertDialog.Builder.positive(@StringRes textId: Int, action: (dialog: AlertDialog) -> Unit) {
inline fun AlertDialog.Builder.positive(@StringRes textId: Int, crossinline action: (dialog: AlertDialog) -> Unit) {
setPositiveButton(textId) { dialog, _ ->
action(dialog as AlertDialog)
}
}
fun AlertDialog.Builder.negative(@StringRes textId: Int, action: (dialog: AlertDialog) -> Unit) {
inline fun AlertDialog.Builder.negative(@StringRes textId: Int, crossinline action: (dialog: AlertDialog) -> Unit) {
setNegativeButton(textId) { dialog, _ ->
action(dialog as AlertDialog)
}
}
inline fun AlertDialog.Builder.neutral(@StringRes textId: Int, crossinline action: (dialog: AlertDialog) -> Unit) {
setNeutralButton(textId) { dialog, _ ->
action(dialog as AlertDialog)
}
}
fun <T : Dialog> T.onShow(action: (dialog: T) -> Unit) {
setOnShowListener { dialog ->
@Suppress("UNCHECKED_CAST")

View File

@ -54,6 +54,7 @@ import org.mariotaku.twidere.app.TwidereApplication
import org.mariotaku.twidere.constant.newDocumentApiKey
import org.mariotaku.twidere.extension.applyTheme
import org.mariotaku.twidere.extension.model.api.microblog.toParcelable
import org.mariotaku.twidere.extension.neutral
import org.mariotaku.twidere.extension.onShow
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowInsetsCallback
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback
@ -405,6 +406,10 @@ class UserListFragment : AbsToolbarTabPagesFragment(), OnClickListener,
builder.setTitle(userList.name)
builder.setMessage(userList.description)
builder.setPositiveButton(android.R.string.ok, null)
builder.neutral(R.string.action_list_creator) {
startActivity(IntentUtils.userProfile(userList.account_key, userList.user_key,
userList.user_screen_name))
}
val dialog = builder.create()
dialog.onShow { it.applyTheme() }
return dialog

View File

@ -78,6 +78,7 @@
<string name="action_leave_conversation">Leave conversation</string>
<!-- [verb] e.g. An action label on a tweet to like this tweet. Formerly Twitter favorite. -->
<string name="action_like">Like</string>
<string name="action_list_creator">List creator</string>
<string name="action_location">Location</string>
<string name="action_manage_in_buffer">Manage in Buffer</string>
<string name="action_mark_as_read">Mark as read</string>