fixed kotlin fucked up my imports when refactoring

updated library version
This commit is contained in:
Mariotaku Lee 2017-04-29 22:32:02 +08:00
parent 2afe74d5fe
commit c4269a1885
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
15 changed files with 176 additions and 155 deletions

View File

@ -9,7 +9,7 @@ android:
- tools
- tools # To fix https://github.com/travis-ci/travis-ci/issues/6040
- platform-tools
- build-tools-25.0.2
- build-tools-25.0.3
- android-25
# Additional components

View File

@ -33,7 +33,7 @@ subprojects {
MariotakuCommons : '0.9.15',
RestFu : '0.9.54',
ObjectCursor : '0.9.20',
PlayServices : '10.2.1',
PlayServices : '10.2.4',
MapsUtils : '0.4.4',
Crashlyrics : '2.6.7',
FabricPlugin : '1.22.1',
@ -73,7 +73,7 @@ subprojects {
if (project.hasProperty('android')) {
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
buildToolsVersion '25.0.3'
lintOptions {
abortOnError false

View File

@ -374,7 +374,7 @@ class MediaViewerActivity : BaseActivity(), IMediaViewerActivity, MediaSwipeClos
val offsetFactor = 1 - (Math.abs(offset).toFloat() / swipeContainer.height)
swipeContainer.backgroundAlpha = offsetFactor
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))
}

View File

@ -40,6 +40,7 @@ import org.mariotaku.twidere.extension.model.setColor
import org.mariotaku.twidere.extension.model.setPosition
import org.mariotaku.twidere.loader.AccountDetailsLoader
import org.mariotaku.twidere.model.AccountDetails
import org.mariotaku.twidere.model.AccountPreferences
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.provider.TwidereDataStore.Activities
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses
@ -222,6 +223,8 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks<Li
DialogInterface.BUTTON_POSITIVE -> {
val accountKey = account.getAccountKey(am)
resolver.deleteAccountData(accountKey)
AccountPreferences.getSharedPreferencesForAccount(context, accountKey).edit()
.clear().apply()
am.removeAccountSupport(account)
}
}

View File

@ -179,7 +179,8 @@ abstract class CursorActivitiesFragment : AbsActivitiesFragment() {
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 sinceIds = DataStoreUtils.getRefreshNewestActivityMaxPositions(context,
contentUri, keys)

View File

@ -114,6 +114,6 @@ class SavedSearchesListFragment : AbsContentListViewFragment<SavedSearchesAdapte
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 }
}
}

View File

@ -19,107 +19,139 @@
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.Builder
import android.view.View
import android.widget.Toast
import com.bumptech.glide.Glide
import nl.komponents.kovenant.Promise
import nl.komponents.kovenant.combine.and
import nl.komponents.kovenant.task
import nl.komponents.kovenant.ui.failUi
import nl.komponents.kovenant.ui.promiseOnUi
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.extension.applyTheme
import org.mariotaku.twidere.extension.model.api.toParcelable
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.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 android.app.Dialog.itemContent: android.view.View
protected abstract val Dialog.loadProgress: View
protected abstract val Dialog.itemContent: View
protected val status: org.mariotaku.twidere.model.ParcelableStatus?
get() = arguments.getParcelable<org.mariotaku.twidere.model.ParcelableStatus>(EXTRA_STATUS)
protected val status: ParcelableStatus?
get() = arguments.getParcelable<ParcelableStatus>(EXTRA_STATUS)
protected val statusId: String
get() = arguments.getString(EXTRA_STATUS_ID)
protected val accountKey: org.mariotaku.twidere.model.UserKey
protected val accountKey: UserKey
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 {
val builder = android.support.v7.app.AlertDialog.Builder(context)
override final fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = Builder(context)
val accountKey = this.accountKey
builder.setupAlertDialog()
adapter = org.mariotaku.twidere.adapter.DummyItemAdapter(context, requestManager = Glide.with(this))
adapter = DummyItemAdapter(context, requestManager = Glide.with(this))
adapter.showCardActions = false
adapter.showAccountsColor = true
val dialog = builder.create()
dialog.setOnShowListener { dialog ->
dialog as android.support.v7.app.AlertDialog
dialog as AlertDialog
dialog.applyTheme()
val am = android.accounts.AccountManager.get(context)
val details = org.mariotaku.twidere.model.util.AccountUtils.getAccountDetails(am, accountKey, true) ?: run {
val am = AccountManager.get(context)
val details = AccountUtils.getAccountDetails(am, accountKey, true) ?: run {
dismiss()
return@setOnShowListener
}
val weakThis = java.lang.ref.WeakReference(this)
val weakHolder = java.lang.ref.WeakReference(org.mariotaku.twidere.view.holder.StatusViewHolder(adapter, dialog.itemContent).apply {
val weakThis = WeakReference(this)
val weakHolder = WeakReference(StatusViewHolder(adapter = adapter, itemView = dialog.itemContent).apply {
setupViewOptions()
})
nl.komponents.kovenant.ui.promiseOnUi {
val currentDialog = weakThis.get()?.dialog as? AlertDialog ?: return@promiseOnUi
currentDialog.loadProgress.visibility = View.VISIBLE
currentDialog.itemContent.visibility = View.GONE
currentDialog.getButton(android.content.DialogInterface.BUTTON_POSITIVE)?.isEnabled = false
currentDialog.getButton(android.content.DialogInterface.BUTTON_NEUTRAL)?.isEnabled = false
} 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 extraStatus = status
if (extraStatus != null) {
showStatus(weakHolder.get()!!, extraStatus, details, savedInstanceState)
} else promiseOnUi {
weakThis.get()?.showProgress()
} and AbsStatusDialogFragment.showStatus(context, details, statusId, extraStatus).successUi { status ->
val holder = weakHolder.get() ?: return@successUi
currentDialog.getButton(android.content.DialogInterface.BUTTON_POSITIVE)?.isEnabled = true
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)
weakThis.get()?.showStatus(holder, status, details, savedInstanceState)
}.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()
}
}
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,
savedInstanceState: android.os.Bundle?)
private fun showStatus(holder: StatusViewHolder, status: ParcelableStatus,
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 {
fun showStatus(context: android.content.Context, details: org.mariotaku.twidere.model.AccountDetails, statusId: String,
status: org.mariotaku.twidere.model.ParcelableStatus?): nl.komponents.kovenant.Promise<ParcelableStatus, Exception> {
fun showStatus(context: Context, details: AccountDetails, statusId: String,
status: ParcelableStatus?): Promise<ParcelableStatus, Exception> {
if (status != null) {
status.apply {
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)
return Promise.ofSuccess(status)
}
val microBlog = details.newMicroBlogInstance(context, org.mariotaku.microblog.library.MicroBlog::class.java)
val profileImageSize = context.getString(org.mariotaku.twidere.R.string.profile_image_size)
return nl.komponents.kovenant.task { microBlog.showStatus(statusId).toParcelable(details, profileImageSize) }
val microBlog = details.newMicroBlogInstance(context, MicroBlog::class.java)
val profileImageSize = context.getString(R.string.profile_image_size)
return task { microBlog.showStatus(statusId).toParcelable(details, profileImageSize) }
}
}

View File

@ -19,9 +19,21 @@
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.ktextension.Bundle
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.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.
@ -30,35 +42,35 @@ import org.mariotaku.twidere.constant.IntentConstants.*
*/
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() {
if (preferences[org.mariotaku.twidere.constant.iWantMyStarsBackKey]) {
setTitle(org.mariotaku.twidere.R.string.title_favorite_confirm)
override fun AlertDialog.Builder.setupAlertDialog() {
if (preferences[iWantMyStarsBackKey]) {
setTitle(R.string.title_favorite_confirm)
} 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)
setPositiveButton(org.mariotaku.twidere.R.string.action_favorite, null)
setView(R.layout.dialog_status_favorite_confirm)
setPositiveButton(R.string.action_favorite, 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,
savedInstanceState: android.os.Bundle?) {
val positiveButton = getButton(android.content.DialogInterface.BUTTON_POSITIVE)
if (preferences[org.mariotaku.twidere.constant.iWantMyStarsBackKey]) {
override fun AlertDialog.onStatusLoaded(details: AccountDetails, status: ParcelableStatus,
savedInstanceState: Bundle?) {
val positiveButton = getButton(BUTTON_POSITIVE)
if (preferences[iWantMyStarsBackKey]) {
if (status.is_favorite) {
positiveButton.setText(org.mariotaku.twidere.R.string.action_unfavorite)
positiveButton.setText(R.string.action_unfavorite)
} else {
positiveButton.setText(org.mariotaku.twidere.R.string.action_favorite)
positiveButton.setText(R.string.action_favorite)
}
} else {
if (status.is_favorite) {
positiveButton.setText(org.mariotaku.twidere.R.string.action_undo_like)
positiveButton.setText(R.string.action_undo_like)
} else {
positiveButton.setText(org.mariotaku.twidere.R.string.action_like)
positiveButton.setText(R.string.action_like)
}
}
positiveButton.setOnClickListener {
@ -72,18 +84,18 @@ class FavoriteConfirmDialogFragment : AbsStatusDialogFragment() {
}
override fun onCancel(dialog: android.content.DialogInterface) {
override fun onCancel(dialog: DialogInterface) {
finishFavoriteConfirmActivity()
}
override fun onDismiss(dialog: android.content.DialogInterface) {
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
finishFavoriteConfirmActivity()
}
private fun finishFavoriteConfirmActivity() {
val activity = this.activity
if (activity is org.mariotaku.twidere.activity.content.FavoriteConfirmDialogActivity && !activity.isFinishing) {
if (activity is FavoriteConfirmDialogActivity && !activity.isFinishing) {
activity.finish()
}
}
@ -92,15 +104,15 @@ class FavoriteConfirmDialogFragment : AbsStatusDialogFragment() {
val FRAGMENT_TAG = "favorite_confirm"
fun show(fm: android.support.v4.app.FragmentManager, accountKey: org.mariotaku.twidere.model.UserKey, statusId: String,
status: org.mariotaku.twidere.model.ParcelableStatus? = null): org.mariotaku.twidere.fragment.status.FavoriteConfirmDialogFragment {
val f = org.mariotaku.twidere.fragment.status.FavoriteConfirmDialogFragment()
f.arguments = org.mariotaku.ktextension.Bundle {
fun show(fm: android.support.v4.app.FragmentManager, accountKey: UserKey, statusId: String,
status: ParcelableStatus? = null): FavoriteConfirmDialogFragment {
val f = FavoriteConfirmDialogFragment()
f.arguments = Bundle {
this[EXTRA_ACCOUNT_KEY] = accountKey
this[EXTRA_STATUS_ID] = statusId
this[EXTRA_STATUS] = status
}
f.show(fm, org.mariotaku.twidere.fragment.status.FavoriteConfirmDialogFragment.Companion.FRAGMENT_TAG)
f.show(fm, FavoriteConfirmDialogFragment.FRAGMENT_TAG)
return f
}
}

View File

@ -28,11 +28,8 @@ import android.provider.BaseColumns
import android.support.annotation.CheckResult
import android.support.v4.app.FragmentManager
import android.support.v7.app.AlertDialog
import android.support.v7.widget.PopupMenu
import android.view.Gravity
import android.view.View
import android.widget.EditText
import android.widget.ImageButton
import android.widget.RelativeLayout
import android.widget.Toast
import com.twitter.Validator
@ -68,15 +65,11 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
override val Dialog.loadProgress: View get() = findViewById(R.id.loadProgress)
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.commentContainer get() = findViewById(R.id.commentContainer) as RelativeLayout
private val Dialog.editComment get() = findViewById(R.id.editComment) as ComposeEditText
private val Dialog.commentMenu get() = findViewById(R.id.commentMenu) as ImageButton
private val PopupMenu.quoteOriginalStatus get() = menu.isItemChecked(R.id.quote_original_status)
private val Dialog.quoteOriginal get() = findViewById(R.id.quoteOriginal) as android.widget.CheckBox
private val text: String?
get() = arguments.getString(EXTRA_TEXT)
@ -104,7 +97,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
}
override fun onHitEnter(): Boolean {
if (retweetOrQuote(details, status, SHOW_PROTECTED_CONFIRM)) {
if (retweetOrQuote(details, status, showProtectedConfirm)) {
dismiss()
return true
}
@ -114,35 +107,25 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
enterHandler.addTextChangedListener(object : SimpleTextWatcher {
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,
R.attr.actionOverflowMenuStyle, 0).apply {
inflate(R.menu.menu_dialog_comment)
menu.setItemAvailability(R.id.quote_original_status, status.retweet_id != null || status.quoted_id != null)
setOnMenuItemClickListener(PopupMenu.OnMenuItemClickListener { item ->
if (item.isCheckable) {
item.isChecked = !item.isChecked
return@OnMenuItemClickListener true
}
false
})
quoteOriginal.visibility = if (status.retweet_id != null || status.quoted_id != null) {
View.VISIBLE
} else {
View.GONE
}
commentMenu.setOnClickListener { popupMenu.show() }
commentMenu.setOnTouchListener(popupMenu.dragToOpenListener)
commentMenu.visibility = if (popupMenu.menu.hasVisibleItems()) View.VISIBLE else View.GONE
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
var dismissDialog = false
if (editComment.length() > 0) {
dismissDialog = retweetOrQuote(details, status, SHOW_PROTECTED_CONFIRM)
dismissDialog = retweetOrQuote(details, status, showProtectedConfirm)
} else if (isMyRetweet(status)) {
twitterWrapper.cancelRetweetAsync(details.key, status.id, status.my_retweet_id)
dismissDialog = true
} else if (useQuote(!status.user_is_protected, details)) {
dismissDialog = retweetOrQuote(details, status, SHOW_PROTECTED_CONFIRM)
dismissDialog = retweetOrQuote(details, status, showProtectedConfirm)
} else {
Analyzer.logException(IllegalStateException(status.toString()))
}
@ -152,10 +135,8 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
}
getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener {
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_QUOTE_ORIGINAL_STATUS, quoteOriginalStatus.isChecked)
intent.putExtra(EXTRA_QUOTE_ORIGINAL_STATUS, quoteOriginal.isChecked)
startActivity(intent)
dismiss()
}
@ -216,7 +197,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
val dialog = dialog ?: return false
val editComment = dialog.findViewById(R.id.editComment) as EditText
if (useQuote(editComment.length() > 0, account)) {
val quoteOriginalStatus = popupMenu.quoteOriginalStatus
val quoteOriginalStatus = dialog.quoteOriginal.isChecked
var commentText: String
val update = ParcelableStatusUpdate()
@ -283,7 +264,7 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
draft.timestamp = System.currentTimeMillis()
draft.action_extras = QuoteStatusActionExtras().apply {
this.status = this@RetweetQuoteDialogFragment.status
this.isQuoteOriginalStatus = popupMenu.quoteOriginalStatus
this.isQuoteOriginalStatus = quoteOriginal.isChecked
}
val values = ObjectCursor.valuesCreatorFrom(Draft::class.java).create(draft)
val contentResolver = context.contentResolver
@ -349,8 +330,8 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() {
companion object {
val FRAGMENT_TAG = "retweet_quote"
private val SHOW_PROTECTED_CONFIRM = java.lang.Boolean.parseBoolean("false")
private const val FRAGMENT_TAG = "retweet_quote"
private val showProtectedConfirm = false
fun show(fm: FragmentManager, accountKey: UserKey, statusId: String,
status: ParcelableStatus? = null, text: String? = null):

View File

@ -152,5 +152,10 @@ class AccountPreferences(
fun isNotificationHasVibration(flags: Int): Boolean {
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)
}
}
}

View File

@ -19,6 +19,7 @@
package org.mariotaku.twidere.task.twitter.message
import android.accounts.AccountManager
import android.annotation.SuppressLint
import android.content.ContentValues
import android.content.Context
@ -336,7 +337,7 @@ class GetMessagesTask(
var taskTag: String? = null
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 {

View File

@ -20,10 +20,7 @@
package org.mariotaku.twidere.util
import org.apache.commons.lang3.StringEscapeUtils
import org.apache.commons.lang3.text.translate.AggregateTranslator
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 org.apache.commons.lang3.text.translate.*
import java.io.IOException
import java.io.Writer
@ -36,8 +33,11 @@ object HtmlEscapeHelper {
val ESCAPE_BASIC = LookupTranslator(*EntityArrays.BASIC_ESCAPE())
val UNESCAPE_HTML = AggregateTranslator(
StringEscapeUtils.UNESCAPE_HTML4,
LookupTranslator(*EntityArrays.APOS_UNESCAPE())
LookupTranslator(*EntityArrays.BASIC_UNESCAPE()),
LookupTranslator(*EntityArrays.ISO8859_1_UNESCAPE()),
LookupTranslator(*EntityArrays.HTML40_EXTENDED_UNESCAPE()),
LookupTranslator(*EntityArrays.APOS_UNESCAPE()),
IgnoreErrorNumericEntityUnescaper()
)
fun escape(text: CharSequence): String {
@ -72,4 +72,15 @@ object HtmlEscapeHelper {
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
}
}
}
}

View File

@ -59,30 +59,28 @@
android:id="@+id/commentTextCount"
android:layout_width="match_parent"
android:layout_height="@dimen/element_size_normal"
android:layout_alignBottom="@+id/commentMenu"
android:layout_alignLeft="@+id/editComment"
android:layout_alignStart="@+id/editComment"
android:layout_alignTop="@+id/commentMenu"
android:layout_below="@+id/editComment"
android:layout_toLeftOf="@+id/commentMenu"
android:layout_toStartOf="@+id/commentMenu"
android:layout_toLeftOf="@+id/quoteOriginal"
android:layout_toStartOf="@+id/quoteOriginal"
android:gravity="center_vertical|start"
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_normal"
android:textColor="?android:textColorSecondary"
tools:text="140"/>
<org.mariotaku.twidere.view.IconActionButton
android:id="@+id/commentMenu"
style="?cardActionButtonStyle"
android:layout_width="@dimen/element_size_normal"
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/quoteOriginal"
android:layout_width="wrap_content"
android:layout_height="@dimen/element_size_normal"
android:layout_alignEnd="@+id/editComment"
android:layout_alignRight="@+id/editComment"
android:layout_below="@+id/editComment"
android:color="?android:textColorTertiary"
android:layout_alignRight="@+id/editComment"
android:focusable="false"
android:src="@drawable/ic_action_more_vertical"/>
android:gravity="center_vertical"
android:text="@string/quote_original_status"
android:visibility="gone"/>
</RelativeLayout>
<FrameLayout
@ -94,6 +92,7 @@
<FrameLayout
android:id="@+id/loadProgress"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content"
android:minHeight="@dimen/element_size_mlarge">

View File

@ -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>

View File

@ -81,6 +81,7 @@
<item>mentions</item>
<item>messages</item>
<item>trends</item>
<item>saved_searches</item>
</string-array>
<string-array name="values_notification_content">
<item>home</item>