mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-01 09:16:47 +01:00
close #801
This commit is contained in:
parent
a3b03d105c
commit
680b888f62
@ -30,7 +30,7 @@ subprojects {
|
||||
libVersions = [
|
||||
Kotlin : '1.1.1',
|
||||
SupportLib : '25.3.1',
|
||||
MariotakuCommons : '0.9.14',
|
||||
MariotakuCommons : '0.9.15',
|
||||
RestFu : '0.9.54',
|
||||
ObjectCursor : '0.9.16',
|
||||
PlayServices : '10.2.1',
|
||||
|
@ -148,6 +148,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
private var hasLocationOption: Boolean = false
|
||||
private var ignoreMentions: Boolean = false
|
||||
private var shouldSaveAccounts: Boolean = false
|
||||
private var shouldSaveVisibility: Boolean = false
|
||||
private var statusShortenerUsed: Boolean = false
|
||||
private var navigateBackPressed: Boolean = false
|
||||
private var replyToSelf: Boolean = false
|
||||
@ -164,7 +165,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
private var draft: Draft? = null
|
||||
private var nameFirst: Boolean = false
|
||||
private var draftUniqueId: String? = null
|
||||
private var statusVisibility: String? = StatusVisibility.PUBLIC
|
||||
private var statusVisibility: String? = null
|
||||
private var scheduleInfo: ScheduleInfo? = null
|
||||
set(value) {
|
||||
field = value
|
||||
@ -309,6 +310,9 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
accountsAdapter.selectedAccountKeys = intersection.toTypedArray()
|
||||
}
|
||||
}
|
||||
if (statusVisibility == null) {
|
||||
statusVisibility = preferences[composeStatusVisibilityKey]
|
||||
}
|
||||
originalText = ParseUtils.parseString(editText.text)
|
||||
}
|
||||
|
||||
@ -373,6 +377,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
|
||||
override fun onStop() {
|
||||
saveAccountSelection()
|
||||
saveVisibility()
|
||||
try {
|
||||
if (locationListener != null) {
|
||||
locationManager.removeUpdates(locationListener)
|
||||
@ -485,6 +490,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
mentionUser = savedInstanceState.getParcelable(EXTRA_USER)
|
||||
draft = savedInstanceState.getParcelable(EXTRA_DRAFT)
|
||||
shouldSaveAccounts = savedInstanceState.getBoolean(EXTRA_SHOULD_SAVE_ACCOUNTS)
|
||||
shouldSaveVisibility = savedInstanceState.getBoolean(EXTRA_SHOULD_SAVE_VISIBILITY)
|
||||
originalText = savedInstanceState.getString(EXTRA_ORIGINAL_TEXT)
|
||||
draftUniqueId = savedInstanceState.getString(EXTRA_DRAFT_UNIQUE_ID)
|
||||
scheduleInfo = savedInstanceState.getParcelable(EXTRA_SCHEDULE_INFO)
|
||||
@ -921,6 +927,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
|
||||
private fun handleIntent(intent: Intent): Boolean {
|
||||
shouldSaveAccounts = false
|
||||
shouldSaveVisibility = false
|
||||
mentionUser = intent.getParcelableExtra(EXTRA_USER)
|
||||
inReplyToStatus = intent.getParcelableExtra(EXTRA_STATUS)
|
||||
when (intent.action) {
|
||||
@ -1068,6 +1075,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
private fun handleDefaultIntent(intent: Intent?): Boolean {
|
||||
if (intent == null) return false
|
||||
val action = intent.action
|
||||
val hasVisibility = intent.hasExtra(EXTRA_VISIBILITY)
|
||||
val hasAccountKeys: Boolean
|
||||
if (intent.hasExtra(EXTRA_ACCOUNT_KEYS)) {
|
||||
val accountKeys = intent.getParcelableArrayExtra(EXTRA_ACCOUNT_KEYS).toTypedArray(UserKey.CREATOR)
|
||||
@ -1082,6 +1090,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
if (Intent.ACTION_SEND == action) {
|
||||
shouldSaveAccounts = false
|
||||
shouldSaveVisibility = false
|
||||
val stream = intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
|
||||
if (stream != null) {
|
||||
val src = arrayOf(stream)
|
||||
@ -1089,6 +1098,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
} else if (Intent.ACTION_SEND_MULTIPLE == action) {
|
||||
shouldSaveAccounts = false
|
||||
shouldSaveVisibility = false
|
||||
val extraStream = intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)
|
||||
if (extraStream != null) {
|
||||
val src = extraStream.toTypedArray()
|
||||
@ -1096,6 +1106,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
}
|
||||
} else {
|
||||
shouldSaveAccounts = !hasAccountKeys
|
||||
shouldSaveVisibility = !hasVisibility
|
||||
val data = intent.data
|
||||
if (data != null) {
|
||||
val src = arrayOf(data)
|
||||
@ -1279,6 +1290,11 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
preferences[composeAccountsKey] = accountsAdapter.selectedAccountKeys
|
||||
}
|
||||
|
||||
private fun saveVisibility() {
|
||||
if (!shouldSaveVisibility) return
|
||||
preferences[composeStatusVisibilityKey] = statusVisibility
|
||||
}
|
||||
|
||||
private fun setMenu() {
|
||||
if (menuBar == null) return
|
||||
val menu = menuBar.menu
|
||||
@ -1475,6 +1491,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
if (preferences[noCloseAfterTweetSentKey] && inReplyToStatus == null) {
|
||||
possiblySensitive = false
|
||||
shouldSaveAccounts = true
|
||||
shouldSaveVisibility = true
|
||||
inReplyToStatus = null
|
||||
mentionUser = null
|
||||
draft = null
|
||||
@ -1558,7 +1575,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
update.media = media
|
||||
update.in_reply_to_status = inReplyTo
|
||||
update.is_possibly_sensitive = possiblySensitive
|
||||
update.visibility = statusVisibility
|
||||
update.visibility = statusVisibility ?: StatusVisibility.PUBLIC
|
||||
update.draft_extras = update.updateStatusActionExtras().also {
|
||||
it.editingText = text
|
||||
}
|
||||
@ -2183,6 +2200,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||
|
||||
// Constants
|
||||
private const val EXTRA_SHOULD_SAVE_ACCOUNTS = "should_save_accounts"
|
||||
private const val EXTRA_SHOULD_SAVE_VISIBILITY = "should_save_visibility"
|
||||
private const val EXTRA_ORIGINAL_TEXT = "original_text"
|
||||
private const val EXTRA_DRAFT_UNIQUE_ID = "draft_unique_id"
|
||||
|
||||
|
@ -81,6 +81,7 @@ val refreshAfterTweetKey = KBooleanKey(KEY_REFRESH_AFTER_TWEET, false)
|
||||
val homeRefreshMentionsKey = KBooleanKey(KEY_HOME_REFRESH_MENTIONS, true)
|
||||
val homeRefreshDirectMessagesKey = KBooleanKey(KEY_HOME_REFRESH_DIRECT_MESSAGES, true)
|
||||
val homeRefreshSavedSearchesKey = KBooleanKey(KEY_HOME_REFRESH_SAVED_SEARCHES, true)
|
||||
val composeStatusVisibilityKey = KNullableStringKey("compose_status_visibility", null)
|
||||
object cacheSizeLimitKey : KSimpleKey<Int>(KEY_CACHE_SIZE_LIMIT, 300) {
|
||||
override fun read(preferences: SharedPreferences) = preferences.getInt(key, def).coerceIn(100,
|
||||
500)
|
||||
|
Loading…
x
Reference in New Issue
Block a user