fixed kotlin fucked up my imports when refactoring
updated library version
This commit is contained in:
parent
2afe74d5fe
commit
c4269a1885
|
@ -9,7 +9,7 @@ android:
|
||||||
- tools
|
- tools
|
||||||
- tools # To fix https://github.com/travis-ci/travis-ci/issues/6040
|
- tools # To fix https://github.com/travis-ci/travis-ci/issues/6040
|
||||||
- platform-tools
|
- platform-tools
|
||||||
- build-tools-25.0.2
|
- build-tools-25.0.3
|
||||||
- android-25
|
- android-25
|
||||||
|
|
||||||
# Additional components
|
# Additional components
|
||||||
|
|
|
@ -33,7 +33,7 @@ subprojects {
|
||||||
MariotakuCommons : '0.9.15',
|
MariotakuCommons : '0.9.15',
|
||||||
RestFu : '0.9.54',
|
RestFu : '0.9.54',
|
||||||
ObjectCursor : '0.9.20',
|
ObjectCursor : '0.9.20',
|
||||||
PlayServices : '10.2.1',
|
PlayServices : '10.2.4',
|
||||||
MapsUtils : '0.4.4',
|
MapsUtils : '0.4.4',
|
||||||
Crashlyrics : '2.6.7',
|
Crashlyrics : '2.6.7',
|
||||||
FabricPlugin : '1.22.1',
|
FabricPlugin : '1.22.1',
|
||||||
|
@ -73,7 +73,7 @@ subprojects {
|
||||||
if (project.hasProperty('android')) {
|
if (project.hasProperty('android')) {
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 25
|
compileSdkVersion 25
|
||||||
buildToolsVersion '25.0.2'
|
buildToolsVersion '25.0.3'
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
abortOnError false
|
abortOnError false
|
||||||
|
|
|
@ -374,7 +374,7 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
|
||||||
val offsetFactor = 1 - (Math.abs(offset).toFloat() / swipeContainer.height)
|
val offsetFactor = 1 - (Math.abs(offset).toFloat() / swipeContainer.height)
|
||||||
swipeContainer.backgroundAlpha = offsetFactor
|
swipeContainer.backgroundAlpha = offsetFactor
|
||||||
val colorToolbar = overrideTheme.colorToolbar
|
val colorToolbar = overrideTheme.colorToolbar
|
||||||
val alpha = Math.round(Color.alpha(colorToolbar) * offsetFactor)
|
val alpha = Math.round(Color.alpha(colorToolbar) * offsetFactor).coerceIn(0..255)
|
||||||
activityLayout.setStatusBarColor(ColorUtils.setAlphaComponent(colorToolbar, alpha))
|
activityLayout.setStatusBarColor(ColorUtils.setAlphaComponent(colorToolbar, alpha))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.mariotaku.twidere.extension.model.setColor
|
||||||
import org.mariotaku.twidere.extension.model.setPosition
|
import org.mariotaku.twidere.extension.model.setPosition
|
||||||
import org.mariotaku.twidere.loader.AccountDetailsLoader
|
import org.mariotaku.twidere.loader.AccountDetailsLoader
|
||||||
import org.mariotaku.twidere.model.AccountDetails
|
import org.mariotaku.twidere.model.AccountDetails
|
||||||
|
import org.mariotaku.twidere.model.AccountPreferences
|
||||||
import org.mariotaku.twidere.model.UserKey
|
import org.mariotaku.twidere.model.UserKey
|
||||||
import org.mariotaku.twidere.provider.TwidereDataStore.Activities
|
import org.mariotaku.twidere.provider.TwidereDataStore.Activities
|
||||||
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses
|
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses
|
||||||
|
@ -222,6 +223,8 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
|
||||||
DialogInterface.BUTTON_POSITIVE -> {
|
DialogInterface.BUTTON_POSITIVE -> {
|
||||||
val accountKey = account.getAccountKey(am)
|
val accountKey = account.getAccountKey(am)
|
||||||
resolver.deleteAccountData(accountKey)
|
resolver.deleteAccountData(accountKey)
|
||||||
|
AccountPreferences.getSharedPreferencesForAccount(context, accountKey).edit()
|
||||||
|
.clear().apply()
|
||||||
am.removeAccountSupport(account)
|
am.removeAccountSupport(account)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,8 @@ abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
|
||||||
this@CursorActivitiesFragment.accountKeys
|
this@CursorActivitiesFragment.accountKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
override val pagination by lazy {
|
override val pagination: Array<SinceMaxPagination?>? by lazy {
|
||||||
|
val context = context ?: return@lazy null
|
||||||
val keys = accountKeys.toNulls()
|
val keys = accountKeys.toNulls()
|
||||||
val sinceIds = DataStoreUtils.getRefreshNewestActivityMaxPositions(context,
|
val sinceIds = DataStoreUtils.getRefreshNewestActivityMaxPositions(context,
|
||||||
contentUri, keys)
|
contentUri, keys)
|
||||||
|
|
|
@ -114,6 +114,6 @@ class SavedSearchesListFragment : AbsContentListViewFragment<SavedSearchesAdapte
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val POSITION_COMPARATOR = Comparator<org.mariotaku.microblog.library.twitter.model.SavedSearch> { object1, object2 -> object1.position - object2.position }
|
private val POSITION_COMPARATOR = Comparator<SavedSearch> { object1, object2 -> object1.position - object2.position }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,107 +19,139 @@
|
||||||
|
|
||||||
package org.mariotaku.twidere.fragment.status
|
package org.mariotaku.twidere.fragment.status
|
||||||
|
|
||||||
|
import android.accounts.AccountManager
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface.BUTTON_NEUTRAL
|
||||||
|
import android.content.DialogInterface.BUTTON_POSITIVE
|
||||||
|
import android.os.Bundle
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
|
import android.support.v7.app.AlertDialog.Builder
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.widget.Toast
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import nl.komponents.kovenant.Promise
|
||||||
import nl.komponents.kovenant.combine.and
|
import nl.komponents.kovenant.combine.and
|
||||||
|
import nl.komponents.kovenant.task
|
||||||
import nl.komponents.kovenant.ui.failUi
|
import nl.komponents.kovenant.ui.failUi
|
||||||
|
import nl.komponents.kovenant.ui.promiseOnUi
|
||||||
import nl.komponents.kovenant.ui.successUi
|
import nl.komponents.kovenant.ui.successUi
|
||||||
|
import org.mariotaku.microblog.library.MicroBlog
|
||||||
|
import org.mariotaku.twidere.R
|
||||||
|
import org.mariotaku.twidere.adapter.DummyItemAdapter
|
||||||
import org.mariotaku.twidere.constant.IntentConstants.*
|
import org.mariotaku.twidere.constant.IntentConstants.*
|
||||||
import org.mariotaku.twidere.extension.applyTheme
|
import org.mariotaku.twidere.extension.applyTheme
|
||||||
import org.mariotaku.twidere.extension.model.api.toParcelable
|
import org.mariotaku.twidere.extension.model.api.toParcelable
|
||||||
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
|
import org.mariotaku.twidere.extension.model.newMicroBlogInstance
|
||||||
|
import org.mariotaku.twidere.fragment.BaseDialogFragment
|
||||||
|
import org.mariotaku.twidere.model.AccountDetails
|
||||||
import org.mariotaku.twidere.model.ParcelableStatus
|
import org.mariotaku.twidere.model.ParcelableStatus
|
||||||
|
import org.mariotaku.twidere.model.UserKey
|
||||||
|
import org.mariotaku.twidere.model.util.AccountUtils
|
||||||
|
import org.mariotaku.twidere.view.holder.StatusViewHolder
|
||||||
|
import java.lang.ref.WeakReference
|
||||||
|
|
||||||
abstract class AbsStatusDialogFragment : org.mariotaku.twidere.fragment.BaseDialogFragment() {
|
abstract class AbsStatusDialogFragment : BaseDialogFragment() {
|
||||||
|
|
||||||
protected abstract val android.app.Dialog.loadProgress: android.view.View
|
protected abstract val Dialog.loadProgress: View
|
||||||
protected abstract val android.app.Dialog.itemContent: android.view.View
|
protected abstract val Dialog.itemContent: View
|
||||||
|
|
||||||
protected val status: org.mariotaku.twidere.model.ParcelableStatus?
|
protected val status: ParcelableStatus?
|
||||||
get() = arguments.getParcelable<org.mariotaku.twidere.model.ParcelableStatus>(EXTRA_STATUS)
|
get() = arguments.getParcelable<ParcelableStatus>(EXTRA_STATUS)
|
||||||
|
|
||||||
protected val statusId: String
|
protected val statusId: String
|
||||||
get() = arguments.getString(EXTRA_STATUS_ID)
|
get() = arguments.getString(EXTRA_STATUS_ID)
|
||||||
|
|
||||||
protected val accountKey: org.mariotaku.twidere.model.UserKey
|
protected val accountKey: UserKey
|
||||||
get() = arguments.getParcelable(EXTRA_ACCOUNT_KEY)
|
get() = arguments.getParcelable(EXTRA_ACCOUNT_KEY)
|
||||||
|
|
||||||
private lateinit var adapter: org.mariotaku.twidere.adapter.DummyItemAdapter
|
private lateinit var adapter: DummyItemAdapter
|
||||||
|
|
||||||
override final fun onCreateDialog(savedInstanceState: android.os.Bundle?): android.app.Dialog {
|
override final fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val builder = android.support.v7.app.AlertDialog.Builder(context)
|
val builder = Builder(context)
|
||||||
val accountKey = this.accountKey
|
val accountKey = this.accountKey
|
||||||
|
|
||||||
builder.setupAlertDialog()
|
builder.setupAlertDialog()
|
||||||
|
|
||||||
adapter = org.mariotaku.twidere.adapter.DummyItemAdapter(context, requestManager = Glide.with(this))
|
adapter = DummyItemAdapter(context, requestManager = Glide.with(this))
|
||||||
adapter.showCardActions = false
|
adapter.showCardActions = false
|
||||||
adapter.showAccountsColor = true
|
adapter.showAccountsColor = true
|
||||||
|
|
||||||
val dialog = builder.create()
|
val dialog = builder.create()
|
||||||
dialog.setOnShowListener { dialog ->
|
dialog.setOnShowListener { dialog ->
|
||||||
dialog as android.support.v7.app.AlertDialog
|
dialog as AlertDialog
|
||||||
dialog.applyTheme()
|
dialog.applyTheme()
|
||||||
|
|
||||||
val am = android.accounts.AccountManager.get(context)
|
val am = AccountManager.get(context)
|
||||||
val details = org.mariotaku.twidere.model.util.AccountUtils.getAccountDetails(am, accountKey, true) ?: run {
|
val details = AccountUtils.getAccountDetails(am, accountKey, true) ?: run {
|
||||||
dismiss()
|
dismiss()
|
||||||
return@setOnShowListener
|
return@setOnShowListener
|
||||||
}
|
}
|
||||||
val weakThis = java.lang.ref.WeakReference(this)
|
val weakThis = WeakReference(this)
|
||||||
val weakHolder = java.lang.ref.WeakReference(org.mariotaku.twidere.view.holder.StatusViewHolder(adapter, dialog.itemContent).apply {
|
val weakHolder = WeakReference(StatusViewHolder(adapter = adapter, itemView = dialog.itemContent).apply {
|
||||||
setupViewOptions()
|
setupViewOptions()
|
||||||
})
|
})
|
||||||
nl.komponents.kovenant.ui.promiseOnUi {
|
val extraStatus = status
|
||||||
val currentDialog = weakThis.get()?.dialog as? AlertDialog ?: return@promiseOnUi
|
if (extraStatus != null) {
|
||||||
currentDialog.loadProgress.visibility = View.VISIBLE
|
showStatus(weakHolder.get()!!, extraStatus, details, savedInstanceState)
|
||||||
currentDialog.itemContent.visibility = View.GONE
|
} else promiseOnUi {
|
||||||
currentDialog.getButton(android.content.DialogInterface.BUTTON_POSITIVE)?.isEnabled = false
|
weakThis.get()?.showProgress()
|
||||||
currentDialog.getButton(android.content.DialogInterface.BUTTON_NEUTRAL)?.isEnabled = false
|
} and AbsStatusDialogFragment.showStatus(context, details, statusId, extraStatus).successUi { status ->
|
||||||
} and org.mariotaku.twidere.fragment.status.AbsStatusDialogFragment.Companion.showStatus(context, details, statusId, status).successUi { status ->
|
|
||||||
val fragment = weakThis.get() ?: return@successUi
|
|
||||||
val currentDialog = fragment.dialog as? android.support.v7.app.AlertDialog ?: return@successUi
|
|
||||||
val holder = weakHolder.get() ?: return@successUi
|
val holder = weakHolder.get() ?: return@successUi
|
||||||
currentDialog.getButton(android.content.DialogInterface.BUTTON_POSITIVE)?.isEnabled = true
|
weakThis.get()?.showStatus(holder, status, details, savedInstanceState)
|
||||||
currentDialog.getButton(android.content.DialogInterface.BUTTON_NEUTRAL)?.isEnabled = true
|
|
||||||
currentDialog.itemContent.visibility = android.view.View.VISIBLE
|
|
||||||
currentDialog.loadProgress.visibility = android.view.View.GONE
|
|
||||||
currentDialog.itemContent.isFocusable = false
|
|
||||||
holder.display(status = status, displayInReplyTo = false)
|
|
||||||
currentDialog.onStatusLoaded(details, status, savedInstanceState)
|
|
||||||
}.failUi {
|
}.failUi {
|
||||||
val fragment = weakThis.get()?.takeIf { it.dialog != null } ?: return@failUi
|
val fragment = weakThis.get()?.takeIf { it.dialog != null } ?: return@failUi
|
||||||
android.widget.Toast.makeText(fragment.context, org.mariotaku.twidere.R.string.message_toast_error_occurred, android.widget.Toast.LENGTH_SHORT).show()
|
Toast.makeText(fragment.context, R.string.message_toast_error_occurred,
|
||||||
|
Toast.LENGTH_SHORT).show()
|
||||||
fragment.dismiss()
|
fragment.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dialog
|
return dialog
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun android.support.v7.app.AlertDialog.Builder.setupAlertDialog()
|
private fun showProgress() {
|
||||||
|
val currentDialog = this.dialog as? AlertDialog ?: return
|
||||||
|
currentDialog.loadProgress.visibility = View.VISIBLE
|
||||||
|
currentDialog.itemContent.visibility = View.GONE
|
||||||
|
currentDialog.getButton(BUTTON_POSITIVE)?.isEnabled = false
|
||||||
|
currentDialog.getButton(BUTTON_NEUTRAL)?.isEnabled = false
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract fun android.support.v7.app.AlertDialog.onStatusLoaded(details: org.mariotaku.twidere.model.AccountDetails, status: org.mariotaku.twidere.model.ParcelableStatus,
|
private fun showStatus(holder: StatusViewHolder, status: ParcelableStatus,
|
||||||
savedInstanceState: android.os.Bundle?)
|
details: AccountDetails, savedInstanceState: Bundle?) {
|
||||||
|
status.apply {
|
||||||
|
if (account_key != details.key) {
|
||||||
|
my_retweet_id = null
|
||||||
|
is_favorite = false
|
||||||
|
}
|
||||||
|
account_key = details.key
|
||||||
|
account_color = details.color
|
||||||
|
}
|
||||||
|
val currentDialog = this.dialog as? AlertDialog ?: return
|
||||||
|
currentDialog.getButton(BUTTON_POSITIVE)?.isEnabled = true
|
||||||
|
currentDialog.getButton(BUTTON_NEUTRAL)?.isEnabled = true
|
||||||
|
currentDialog.itemContent.visibility = View.VISIBLE
|
||||||
|
currentDialog.loadProgress.visibility = View.GONE
|
||||||
|
currentDialog.itemContent.isFocusable = false
|
||||||
|
holder.display(status = status, displayInReplyTo = false)
|
||||||
|
currentDialog.onStatusLoaded(details, status, savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract fun Builder.setupAlertDialog()
|
||||||
|
|
||||||
|
protected abstract fun AlertDialog.onStatusLoaded(details: AccountDetails, status: ParcelableStatus,
|
||||||
|
savedInstanceState: Bundle?)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun showStatus(context: android.content.Context, details: org.mariotaku.twidere.model.AccountDetails, statusId: String,
|
fun showStatus(context: Context, details: AccountDetails, statusId: String,
|
||||||
status: org.mariotaku.twidere.model.ParcelableStatus?): nl.komponents.kovenant.Promise<ParcelableStatus, Exception> {
|
status: ParcelableStatus?): Promise<ParcelableStatus, Exception> {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
status.apply {
|
return Promise.ofSuccess(status)
|
||||||
if (account_key != details.key) {
|
|
||||||
my_retweet_id = null
|
|
||||||
is_favorite = false
|
|
||||||
}
|
|
||||||
account_key = details.key
|
|
||||||
account_color = details.color
|
|
||||||
}
|
|
||||||
return nl.komponents.kovenant.Promise.Companion.ofSuccess(status)
|
|
||||||
}
|
}
|
||||||
val microBlog = details.newMicroBlogInstance(context, org.mariotaku.microblog.library.MicroBlog::class.java)
|
val microBlog = details.newMicroBlogInstance(context, MicroBlog::class.java)
|
||||||
val profileImageSize = context.getString(org.mariotaku.twidere.R.string.profile_image_size)
|
val profileImageSize = context.getString(R.string.profile_image_size)
|
||||||
return nl.komponents.kovenant.task { microBlog.showStatus(statusId).toParcelable(details, profileImageSize) }
|
return task { microBlog.showStatus(statusId).toParcelable(details, profileImageSize) }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,21 @@
|
||||||
|
|
||||||
package org.mariotaku.twidere.fragment.status
|
package org.mariotaku.twidere.fragment.status
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import android.content.DialogInterface.BUTTON_POSITIVE
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.support.v7.app.AlertDialog
|
||||||
import org.mariotaku.kpreferences.get
|
import org.mariotaku.kpreferences.get
|
||||||
|
import org.mariotaku.ktextension.Bundle
|
||||||
import org.mariotaku.ktextension.set
|
import org.mariotaku.ktextension.set
|
||||||
|
import org.mariotaku.twidere.R
|
||||||
|
import org.mariotaku.twidere.activity.content.FavoriteConfirmDialogActivity
|
||||||
import org.mariotaku.twidere.constant.IntentConstants.*
|
import org.mariotaku.twidere.constant.IntentConstants.*
|
||||||
|
import org.mariotaku.twidere.constant.iWantMyStarsBackKey
|
||||||
|
import org.mariotaku.twidere.model.AccountDetails
|
||||||
|
import org.mariotaku.twidere.model.ParcelableStatus
|
||||||
|
import org.mariotaku.twidere.model.UserKey
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks user to favorite a status.
|
* Asks user to favorite a status.
|
||||||
|
@ -30,35 +42,35 @@ import org.mariotaku.twidere.constant.IntentConstants.*
|
||||||
*/
|
*/
|
||||||
class FavoriteConfirmDialogFragment : AbsStatusDialogFragment() {
|
class FavoriteConfirmDialogFragment : AbsStatusDialogFragment() {
|
||||||
|
|
||||||
override val android.app.Dialog.loadProgress: android.view.View get() = findViewById(org.mariotaku.twidere.R.id.loadProgress)
|
override val Dialog.loadProgress: android.view.View get() = findViewById(R.id.loadProgress)
|
||||||
|
|
||||||
override val android.app.Dialog.itemContent: android.view.View get() = findViewById(org.mariotaku.twidere.R.id.itemContent)
|
override val Dialog.itemContent: android.view.View get() = findViewById(R.id.itemContent)
|
||||||
|
|
||||||
override fun android.support.v7.app.AlertDialog.Builder.setupAlertDialog() {
|
override fun AlertDialog.Builder.setupAlertDialog() {
|
||||||
if (preferences[org.mariotaku.twidere.constant.iWantMyStarsBackKey]) {
|
if (preferences[iWantMyStarsBackKey]) {
|
||||||
setTitle(org.mariotaku.twidere.R.string.title_favorite_confirm)
|
setTitle(R.string.title_favorite_confirm)
|
||||||
} else {
|
} else {
|
||||||
setTitle(org.mariotaku.twidere.R.string.title_like_confirm)
|
setTitle(R.string.title_like_confirm)
|
||||||
}
|
}
|
||||||
setView(org.mariotaku.twidere.R.layout.dialog_status_favorite_confirm)
|
setView(R.layout.dialog_status_favorite_confirm)
|
||||||
setPositiveButton(org.mariotaku.twidere.R.string.action_favorite, null)
|
setPositiveButton(R.string.action_favorite, null)
|
||||||
setNegativeButton(android.R.string.cancel, null)
|
setNegativeButton(android.R.string.cancel, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun android.support.v7.app.AlertDialog.onStatusLoaded(details: org.mariotaku.twidere.model.AccountDetails, status: org.mariotaku.twidere.model.ParcelableStatus,
|
override fun AlertDialog.onStatusLoaded(details: AccountDetails, status: ParcelableStatus,
|
||||||
savedInstanceState: android.os.Bundle?) {
|
savedInstanceState: Bundle?) {
|
||||||
val positiveButton = getButton(android.content.DialogInterface.BUTTON_POSITIVE)
|
val positiveButton = getButton(BUTTON_POSITIVE)
|
||||||
if (preferences[org.mariotaku.twidere.constant.iWantMyStarsBackKey]) {
|
if (preferences[iWantMyStarsBackKey]) {
|
||||||
if (status.is_favorite) {
|
if (status.is_favorite) {
|
||||||
positiveButton.setText(org.mariotaku.twidere.R.string.action_unfavorite)
|
positiveButton.setText(R.string.action_unfavorite)
|
||||||
} else {
|
} else {
|
||||||
positiveButton.setText(org.mariotaku.twidere.R.string.action_favorite)
|
positiveButton.setText(R.string.action_favorite)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (status.is_favorite) {
|
if (status.is_favorite) {
|
||||||
positiveButton.setText(org.mariotaku.twidere.R.string.action_undo_like)
|
positiveButton.setText(R.string.action_undo_like)
|
||||||
} else {
|
} else {
|
||||||
positiveButton.setText(org.mariotaku.twidere.R.string.action_like)
|
positiveButton.setText(R.string.action_like)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
positiveButton.setOnClickListener {
|
positiveButton.setOnClickListener {
|
||||||
|
@ -72,18 +84,18 @@ class FavoriteConfirmDialogFragment : AbsStatusDialogFragment() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCancel(dialog: android.content.DialogInterface) {
|
override fun onCancel(dialog: DialogInterface) {
|
||||||
finishFavoriteConfirmActivity()
|
finishFavoriteConfirmActivity()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDismiss(dialog: android.content.DialogInterface) {
|
override fun onDismiss(dialog: DialogInterface) {
|
||||||
super.onDismiss(dialog)
|
super.onDismiss(dialog)
|
||||||
finishFavoriteConfirmActivity()
|
finishFavoriteConfirmActivity()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun finishFavoriteConfirmActivity() {
|
private fun finishFavoriteConfirmActivity() {
|
||||||
val activity = this.activity
|
val activity = this.activity
|
||||||
if (activity is org.mariotaku.twidere.activity.content.FavoriteConfirmDialogActivity && !activity.isFinishing) {
|
if (activity is FavoriteConfirmDialogActivity && !activity.isFinishing) {
|
||||||
activity.finish()
|
activity.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,15 +104,15 @@ class FavoriteConfirmDialogFragment : AbsStatusDialogFragment() {
|
||||||
|
|
||||||
val FRAGMENT_TAG = "favorite_confirm"
|
val FRAGMENT_TAG = "favorite_confirm"
|
||||||
|
|
||||||
fun show(fm: android.support.v4.app.FragmentManager, accountKey: org.mariotaku.twidere.model.UserKey, statusId: String,
|
fun show(fm: android.support.v4.app.FragmentManager, accountKey: UserKey, statusId: String,
|
||||||
status: org.mariotaku.twidere.model.ParcelableStatus? = null): org.mariotaku.twidere.fragment.status.FavoriteConfirmDialogFragment {
|
status: ParcelableStatus? = null): FavoriteConfirmDialogFragment {
|
||||||
val f = org.mariotaku.twidere.fragment.status.FavoriteConfirmDialogFragment()
|
val f = FavoriteConfirmDialogFragment()
|
||||||
f.arguments = org.mariotaku.ktextension.Bundle {
|
f.arguments = Bundle {
|
||||||
this[EXTRA_ACCOUNT_KEY] = accountKey
|
this[EXTRA_ACCOUNT_KEY] = accountKey
|
||||||
this[EXTRA_STATUS_ID] = statusId
|
this[EXTRA_STATUS_ID] = statusId
|
||||||
this[EXTRA_STATUS] = status
|
this[EXTRA_STATUS] = status
|
||||||
}
|
}
|
||||||
f.show(fm, org.mariotaku.twidere.fragment.status.FavoriteConfirmDialogFragment.Companion.FRAGMENT_TAG)
|
f.show(fm, FavoriteConfirmDialogFragment.FRAGMENT_TAG)
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,8 @@ import android.provider.BaseColumns
|
||||||
import android.support.annotation.CheckResult
|
import android.support.annotation.CheckResult
|
||||||
import android.support.v4.app.FragmentManager
|
import android.support.v4.app.FragmentManager
|
||||||
import android.support.v7.app.AlertDialog
|
import android.support.v7.app.AlertDialog
|
||||||
import android.support.v7.widget.PopupMenu
|
|
||||||
import android.view.Gravity
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageButton
|
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.twitter.Validator
|
import com.twitter.Validator
|
||||||
|
@ -68,15 +65,11 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
|
||||||
override val Dialog.loadProgress: View get() = findViewById(R.id.loadProgress)
|
override val Dialog.loadProgress: View get() = findViewById(R.id.loadProgress)
|
||||||
override val Dialog.itemContent: View get() = findViewById(R.id.itemContent)
|
override val Dialog.itemContent: View get() = findViewById(R.id.itemContent)
|
||||||
|
|
||||||
private lateinit var popupMenu: PopupMenu
|
|
||||||
|
|
||||||
private val Dialog.textCountView get() = findViewById(R.id.commentTextCount) as StatusTextCountView
|
private val Dialog.textCountView get() = findViewById(R.id.commentTextCount) as StatusTextCountView
|
||||||
|
|
||||||
private val Dialog.commentContainer get() = findViewById(R.id.commentContainer) as RelativeLayout
|
private val Dialog.commentContainer get() = findViewById(R.id.commentContainer) as RelativeLayout
|
||||||
private val Dialog.editComment get() = findViewById(R.id.editComment) as ComposeEditText
|
private val Dialog.editComment get() = findViewById(R.id.editComment) as ComposeEditText
|
||||||
private val Dialog.commentMenu get() = findViewById(R.id.commentMenu) as ImageButton
|
private val Dialog.quoteOriginal get() = findViewById(R.id.quoteOriginal) as android.widget.CheckBox
|
||||||
|
|
||||||
private val PopupMenu.quoteOriginalStatus get() = menu.isItemChecked(R.id.quote_original_status)
|
|
||||||
|
|
||||||
private val text: String?
|
private val text: String?
|
||||||
get() = arguments.getString(EXTRA_TEXT)
|
get() = arguments.getString(EXTRA_TEXT)
|
||||||
|
@ -104,7 +97,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onHitEnter(): Boolean {
|
override fun onHitEnter(): Boolean {
|
||||||
if (retweetOrQuote(details, status, SHOW_PROTECTED_CONFIRM)) {
|
if (retweetOrQuote(details, status, showProtectedConfirm)) {
|
||||||
dismiss()
|
dismiss()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -114,35 +107,25 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
|
||||||
enterHandler.addTextChangedListener(object : SimpleTextWatcher {
|
enterHandler.addTextChangedListener(object : SimpleTextWatcher {
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||||
updateTextCount(getDialog(), s, status, details)
|
updateTextCount(dialog, s, status, details)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
popupMenu = PopupMenu(context, commentMenu, Gravity.NO_GRAVITY,
|
quoteOriginal.visibility = if (status.retweet_id != null || status.quoted_id != null) {
|
||||||
R.attr.actionOverflowMenuStyle, 0).apply {
|
View.VISIBLE
|
||||||
inflate(R.menu.menu_dialog_comment)
|
} else {
|
||||||
menu.setItemAvailability(R.id.quote_original_status, status.retweet_id != null || status.quoted_id != null)
|
View.GONE
|
||||||
setOnMenuItemClickListener(PopupMenu.OnMenuItemClickListener { item ->
|
|
||||||
if (item.isCheckable) {
|
|
||||||
item.isChecked = !item.isChecked
|
|
||||||
return@OnMenuItemClickListener true
|
|
||||||
}
|
|
||||||
false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
commentMenu.setOnClickListener { popupMenu.show() }
|
|
||||||
commentMenu.setOnTouchListener(popupMenu.dragToOpenListener)
|
|
||||||
commentMenu.visibility = if (popupMenu.menu.hasVisibleItems()) View.VISIBLE else View.GONE
|
|
||||||
|
|
||||||
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
|
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
|
||||||
var dismissDialog = false
|
var dismissDialog = false
|
||||||
if (editComment.length() > 0) {
|
if (editComment.length() > 0) {
|
||||||
dismissDialog = retweetOrQuote(details, status, SHOW_PROTECTED_CONFIRM)
|
dismissDialog = retweetOrQuote(details, status, showProtectedConfirm)
|
||||||
} else if (isMyRetweet(status)) {
|
} else if (isMyRetweet(status)) {
|
||||||
twitterWrapper.cancelRetweetAsync(details.key, status.id, status.my_retweet_id)
|
twitterWrapper.cancelRetweetAsync(details.key, status.id, status.my_retweet_id)
|
||||||
dismissDialog = true
|
dismissDialog = true
|
||||||
} else if (useQuote(!status.user_is_protected, details)) {
|
} else if (useQuote(!status.user_is_protected, details)) {
|
||||||
dismissDialog = retweetOrQuote(details, status, SHOW_PROTECTED_CONFIRM)
|
dismissDialog = retweetOrQuote(details, status, showProtectedConfirm)
|
||||||
} else {
|
} else {
|
||||||
Analyzer.logException(IllegalStateException(status.toString()))
|
Analyzer.logException(IllegalStateException(status.toString()))
|
||||||
}
|
}
|
||||||
|
@ -152,10 +135,8 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
|
||||||
}
|
}
|
||||||
getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener {
|
getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener {
|
||||||
val intent = Intent(INTENT_ACTION_QUOTE)
|
val intent = Intent(INTENT_ACTION_QUOTE)
|
||||||
val menu = popupMenu.menu
|
|
||||||
val quoteOriginalStatus = menu.findItem(R.id.quote_original_status)
|
|
||||||
intent.putExtra(EXTRA_STATUS, status)
|
intent.putExtra(EXTRA_STATUS, status)
|
||||||
intent.putExtra(EXTRA_QUOTE_ORIGINAL_STATUS, quoteOriginalStatus.isChecked)
|
intent.putExtra(EXTRA_QUOTE_ORIGINAL_STATUS, quoteOriginal.isChecked)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
@ -216,7 +197,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
|
||||||
val dialog = dialog ?: return false
|
val dialog = dialog ?: return false
|
||||||
val editComment = dialog.findViewById(R.id.editComment) as EditText
|
val editComment = dialog.findViewById(R.id.editComment) as EditText
|
||||||
if (useQuote(editComment.length() > 0, account)) {
|
if (useQuote(editComment.length() > 0, account)) {
|
||||||
val quoteOriginalStatus = popupMenu.quoteOriginalStatus
|
val quoteOriginalStatus = dialog.quoteOriginal.isChecked
|
||||||
|
|
||||||
var commentText: String
|
var commentText: String
|
||||||
val update = ParcelableStatusUpdate()
|
val update = ParcelableStatusUpdate()
|
||||||
|
@ -283,7 +264,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
|
||||||
draft.timestamp = System.currentTimeMillis()
|
draft.timestamp = System.currentTimeMillis()
|
||||||
draft.action_extras = QuoteStatusActionExtras().apply {
|
draft.action_extras = QuoteStatusActionExtras().apply {
|
||||||
this.status = this@RetweetQuoteDialogFragment.status
|
this.status = this@RetweetQuoteDialogFragment.status
|
||||||
this.isQuoteOriginalStatus = popupMenu.quoteOriginalStatus
|
this.isQuoteOriginalStatus = quoteOriginal.isChecked
|
||||||
}
|
}
|
||||||
val values = ObjectCursor.valuesCreatorFrom(Draft::class.java).create(draft)
|
val values = ObjectCursor.valuesCreatorFrom(Draft::class.java).create(draft)
|
||||||
val contentResolver = context.contentResolver
|
val contentResolver = context.contentResolver
|
||||||
|
@ -349,8 +330,8 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
val FRAGMENT_TAG = "retweet_quote"
|
private const val FRAGMENT_TAG = "retweet_quote"
|
||||||
private val SHOW_PROTECTED_CONFIRM = java.lang.Boolean.parseBoolean("false")
|
private val showProtectedConfirm = false
|
||||||
|
|
||||||
fun show(fm: FragmentManager, accountKey: UserKey, statusId: String,
|
fun show(fm: FragmentManager, accountKey: UserKey, statusId: String,
|
||||||
status: ParcelableStatus? = null, text: String? = null):
|
status: ParcelableStatus? = null, text: String? = null):
|
||||||
|
|
|
@ -152,5 +152,10 @@ class AccountPreferences(
|
||||||
fun isNotificationHasVibration(flags: Int): Boolean {
|
fun isNotificationHasVibration(flags: Int): Boolean {
|
||||||
return VALUE_NOTIFICATION_FLAG_VIBRATION in flags
|
return VALUE_NOTIFICATION_FLAG_VIBRATION in flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getSharedPreferencesForAccount(context: Context, accountKey: UserKey): SharedPreferences {
|
||||||
|
return context.getSharedPreferences("$ACCOUNT_PREFERENCES_NAME_PREFIX$accountKey",
|
||||||
|
Context.MODE_PRIVATE)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.mariotaku.twidere.task.twitter.message
|
package org.mariotaku.twidere.task.twitter.message
|
||||||
|
|
||||||
|
import android.accounts.AccountManager
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
@ -336,7 +337,7 @@ class GetMessagesTask(
|
||||||
var taskTag: String? = null
|
var taskTag: String? = null
|
||||||
|
|
||||||
protected val accounts: Array<AccountDetails?> by lazy {
|
protected val accounts: Array<AccountDetails?> by lazy {
|
||||||
AccountUtils.getAllAccountDetails(android.accounts.AccountManager.get(context), accountKeys, false)
|
AccountUtils.getAllAccountDetails(AccountManager.get(context), accountKeys, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val defaultKeys: Array<UserKey?> by lazy {
|
protected val defaultKeys: Array<UserKey?> by lazy {
|
||||||
|
|
|
@ -20,10 +20,7 @@
|
||||||
package org.mariotaku.twidere.util
|
package org.mariotaku.twidere.util
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringEscapeUtils
|
import org.apache.commons.lang3.StringEscapeUtils
|
||||||
import org.apache.commons.lang3.text.translate.AggregateTranslator
|
import org.apache.commons.lang3.text.translate.*
|
||||||
import org.apache.commons.lang3.text.translate.CodePointTranslator
|
|
||||||
import org.apache.commons.lang3.text.translate.EntityArrays
|
|
||||||
import org.apache.commons.lang3.text.translate.LookupTranslator
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.Writer
|
import java.io.Writer
|
||||||
|
|
||||||
|
@ -36,8 +33,11 @@ object HtmlEscapeHelper {
|
||||||
val ESCAPE_BASIC = LookupTranslator(*EntityArrays.BASIC_ESCAPE())
|
val ESCAPE_BASIC = LookupTranslator(*EntityArrays.BASIC_ESCAPE())
|
||||||
|
|
||||||
val UNESCAPE_HTML = AggregateTranslator(
|
val UNESCAPE_HTML = AggregateTranslator(
|
||||||
StringEscapeUtils.UNESCAPE_HTML4,
|
LookupTranslator(*EntityArrays.BASIC_UNESCAPE()),
|
||||||
LookupTranslator(*EntityArrays.APOS_UNESCAPE())
|
LookupTranslator(*EntityArrays.ISO8859_1_UNESCAPE()),
|
||||||
|
LookupTranslator(*EntityArrays.HTML40_EXTENDED_UNESCAPE()),
|
||||||
|
LookupTranslator(*EntityArrays.APOS_UNESCAPE()),
|
||||||
|
IgnoreErrorNumericEntityUnescaper()
|
||||||
)
|
)
|
||||||
|
|
||||||
fun escape(text: CharSequence): String {
|
fun escape(text: CharSequence): String {
|
||||||
|
@ -72,4 +72,15 @@ object HtmlEscapeHelper {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class IgnoreErrorNumericEntityUnescaper : NumericEntityUnescaper() {
|
||||||
|
override fun translate(input: CharSequence?, index: Int, out: Writer?): Int {
|
||||||
|
try {
|
||||||
|
return super.translate(input, index, out)
|
||||||
|
} catch (e: IllegalArgumentException) {
|
||||||
|
// Ignore unsupported code points
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,30 +59,28 @@
|
||||||
android:id="@+id/commentTextCount"
|
android:id="@+id/commentTextCount"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/element_size_normal"
|
android:layout_height="@dimen/element_size_normal"
|
||||||
android:layout_alignBottom="@+id/commentMenu"
|
|
||||||
android:layout_alignLeft="@+id/editComment"
|
android:layout_alignLeft="@+id/editComment"
|
||||||
android:layout_alignStart="@+id/editComment"
|
android:layout_alignStart="@+id/editComment"
|
||||||
android:layout_alignTop="@+id/commentMenu"
|
|
||||||
android:layout_below="@+id/editComment"
|
android:layout_below="@+id/editComment"
|
||||||
android:layout_toLeftOf="@+id/commentMenu"
|
android:layout_toLeftOf="@+id/quoteOriginal"
|
||||||
android:layout_toStartOf="@+id/commentMenu"
|
android:layout_toStartOf="@+id/quoteOriginal"
|
||||||
android:gravity="center_vertical|start"
|
android:gravity="center_vertical|start"
|
||||||
android:paddingLeft="@dimen/element_spacing_normal"
|
android:paddingLeft="@dimen/element_spacing_normal"
|
||||||
android:paddingRight="@dimen/element_spacing_normal"
|
android:paddingRight="@dimen/element_spacing_normal"
|
||||||
android:textColor="?android:textColorSecondary"
|
android:textColor="?android:textColorSecondary"
|
||||||
tools:text="140"/>
|
tools:text="140"/>
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.IconActionButton
|
<android.support.v7.widget.AppCompatCheckBox
|
||||||
android:id="@+id/commentMenu"
|
android:id="@+id/quoteOriginal"
|
||||||
style="?cardActionButtonStyle"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="@dimen/element_size_normal"
|
|
||||||
android:layout_height="@dimen/element_size_normal"
|
android:layout_height="@dimen/element_size_normal"
|
||||||
android:layout_alignEnd="@+id/editComment"
|
android:layout_alignEnd="@+id/editComment"
|
||||||
android:layout_alignRight="@+id/editComment"
|
|
||||||
android:layout_below="@+id/editComment"
|
android:layout_below="@+id/editComment"
|
||||||
android:color="?android:textColorTertiary"
|
android:layout_alignRight="@+id/editComment"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:src="@drawable/ic_action_more_vertical"/>
|
android:gravity="center_vertical"
|
||||||
|
android:text="@string/quote_original_status"
|
||||||
|
android:visibility="gone"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
@ -94,6 +92,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/loadProgress"
|
android:id="@+id/loadProgress"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="@dimen/element_size_mlarge">
|
android:minHeight="@dimen/element_size_mlarge">
|
||||||
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?><!--
|
|
||||||
~ Twidere - Twitter client for Android
|
|
||||||
~
|
|
||||||
~ Copyright (C) 2012-2015 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/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item
|
|
||||||
android:id="@+id/quote_original_status"
|
|
||||||
android:checkable="true"
|
|
||||||
android:title="@string/quote_original_status" />
|
|
||||||
</menu>
|
|
|
@ -81,6 +81,7 @@
|
||||||
<item>mentions</item>
|
<item>mentions</item>
|
||||||
<item>messages</item>
|
<item>messages</item>
|
||||||
<item>trends</item>
|
<item>trends</item>
|
||||||
|
<item>saved_searches</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="values_notification_content">
|
<string-array name="values_notification_content">
|
||||||
<item>home</item>
|
<item>home</item>
|
||||||
|
|
Loading…
Reference in New Issue