(Mastodon)投票の選択肢の文字数の上限を40にする。投票作成時にfriends.nico APIの選択肢をなくす。
This commit is contained in:
parent
2273f7f94c
commit
238845284a
|
@ -10,18 +10,22 @@ import android.os.Handler
|
|||
import android.text.Editable
|
||||
import android.text.InputType
|
||||
import android.text.TextWatcher
|
||||
import android.view.*
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.*
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import jp.juggler.subwaytooter.action.saveWindowSize
|
||||
import jp.juggler.subwaytooter.actpost.*
|
||||
import jp.juggler.subwaytooter.api.*
|
||||
import jp.juggler.subwaytooter.api.entity.*
|
||||
import jp.juggler.subwaytooter.api.entity.TootScheduled
|
||||
import jp.juggler.subwaytooter.api.entity.TootStatus
|
||||
import jp.juggler.subwaytooter.databinding.ActPostBinding
|
||||
import jp.juggler.subwaytooter.dialog.*
|
||||
import jp.juggler.subwaytooter.pref.PrefB
|
||||
import jp.juggler.subwaytooter.span.*
|
||||
import jp.juggler.subwaytooter.span.MyClickableSpan
|
||||
import jp.juggler.subwaytooter.span.MyClickableSpanHandler
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.subwaytooter.util.*
|
||||
import jp.juggler.subwaytooter.view.MyEditText
|
||||
|
@ -71,7 +75,7 @@ class ActPost : AppCompatActivity(),
|
|||
// 再編集する投稿。アカウントと同一のタンスであること
|
||||
redraftStatus: TootStatus? = null,
|
||||
// 編集する投稿。アカウントと同一のタンスであること
|
||||
editStatus:TootStatus? = null,
|
||||
editStatus: TootStatus? = null,
|
||||
// 返信対象の投稿。同一タンス上に同期済みであること
|
||||
replyStatus: TootStatus? = null,
|
||||
//初期テキスト
|
||||
|
@ -110,7 +114,7 @@ class ActPost : AppCompatActivity(),
|
|||
|
||||
var density: Float = 0f
|
||||
|
||||
val languages by lazy{
|
||||
val languages by lazy {
|
||||
loadLanguageList()
|
||||
}
|
||||
|
||||
|
@ -348,7 +352,6 @@ class ActPost : AppCompatActivity(),
|
|||
arrayOf(
|
||||
getString(R.string.poll_dont_make),
|
||||
getString(R.string.poll_make),
|
||||
getString(R.string.poll_make_friends_nico)
|
||||
)
|
||||
).apply {
|
||||
setDropDownViewResource(R.layout.lv_spinner_dropdown)
|
||||
|
@ -439,7 +442,7 @@ class ActPost : AppCompatActivity(),
|
|||
views.etContent.contentMineTypeArray = AttachmentUploader.acceptableMimeTypes.toTypedArray()
|
||||
views.etContent.contentCallback = { addAttachment(it) }
|
||||
|
||||
views.spLanguage.adapter =ArrayAdapter(
|
||||
views.spLanguage.adapter = ArrayAdapter(
|
||||
this,
|
||||
android.R.layout.simple_spinner_item,
|
||||
languages.map { it.second }.toTypedArray()
|
||||
|
|
|
@ -17,6 +17,7 @@ import jp.juggler.util.*
|
|||
import kotlinx.coroutines.isActive
|
||||
import okhttp3.Request
|
||||
import ru.gildor.coroutines.okhttp.await
|
||||
import kotlin.math.min
|
||||
|
||||
private val log = LogCategory("ActPostDrafts")
|
||||
|
||||
|
@ -254,11 +255,11 @@ fun ActPost.restoreDraft(draft: JsonObject) {
|
|||
|
||||
val sv = draft.string(DRAFT_POLL_TYPE)
|
||||
if (sv != null) {
|
||||
views.spPollType.setSelection(sv.toPollTypeIndex())
|
||||
views.spPollType.setSelection(min(1,sv.toPollTypeIndex()))
|
||||
} else {
|
||||
// old draft
|
||||
val bv = draft.optBoolean(DRAFT_IS_ENQUETE, false)
|
||||
views.spPollType.setSelection(if (bv) 2 else 0)
|
||||
views.spPollType.setSelection(if (bv) 1 else 0)
|
||||
}
|
||||
|
||||
views.cbMultipleChoice.isChecked = draft.optBoolean(DRAFT_POLL_MULTIPLE)
|
||||
|
@ -387,13 +388,7 @@ fun ActPost.initializeFromRedraftStatus(account: SavedAccount, jsonText: String)
|
|||
}
|
||||
|
||||
else -> {
|
||||
views.spPollType.setSelection(
|
||||
if (srcEnquete.pollType == TootPollsType.FriendsNico) {
|
||||
2
|
||||
} else {
|
||||
1
|
||||
}
|
||||
)
|
||||
views.spPollType.setSelection(1)
|
||||
text = decodeOptions.decodeHTML(srcEnquete.question)
|
||||
views.etContent.text = text
|
||||
views.etContent.setSelection(text.length)
|
||||
|
@ -488,13 +483,7 @@ fun ActPost.initializeFromEditStatus(account: SavedAccount, jsonText: String) {
|
|||
}
|
||||
|
||||
else -> {
|
||||
views.spPollType.setSelection(
|
||||
if (srcEnquete.pollType == TootPollsType.FriendsNico) {
|
||||
2
|
||||
} else {
|
||||
1
|
||||
}
|
||||
)
|
||||
views.spPollType.setSelection(1)
|
||||
text = decodeOptions.decodeHTML(srcEnquete.question)
|
||||
views.etContent.text = text
|
||||
views.etContent.setSelection(text.length)
|
||||
|
|
|
@ -311,17 +311,14 @@ fun ActPost.performPost() {
|
|||
var pollHideTotals = false
|
||||
var pollMultipleChoice = false
|
||||
when (views.spPollType.selectedItemPosition) {
|
||||
1 -> {
|
||||
0-> Unit // not poll
|
||||
else -> {
|
||||
pollType = TootPollsType.Mastodon
|
||||
pollItems = pollChoiceList()
|
||||
pollExpireSeconds = pollExpireSeconds()
|
||||
pollHideTotals = views.cbHideTotals.isChecked
|
||||
pollMultipleChoice = views.cbMultipleChoice.isChecked
|
||||
}
|
||||
2 -> {
|
||||
pollType = TootPollsType.FriendsNico
|
||||
pollItems = pollChoiceList()
|
||||
}
|
||||
}
|
||||
|
||||
val postResult = PostImpl(
|
||||
|
|
|
@ -55,7 +55,7 @@ class PostImpl(
|
|||
val editStatusId: EntityId?,
|
||||
val emojiMapCustom: HashMap<String, CustomEmoji>?,
|
||||
var useQuoteToot: Boolean,
|
||||
var lang : String,
|
||||
var lang: String,
|
||||
) {
|
||||
companion object {
|
||||
private val log = LogCategory("PostImpl")
|
||||
|
@ -76,7 +76,7 @@ class PostImpl(
|
|||
private val choiceMaxChars = when {
|
||||
account.isMisskey -> 15
|
||||
pollType == TootPollsType.FriendsNico -> 15
|
||||
else -> 25 // TootPollsType.Mastodon
|
||||
else -> 40 // TootPollsType.Mastodon
|
||||
}
|
||||
|
||||
private fun preCheckPollItemOne(list: List<String>, idx: Int, item: String) {
|
||||
|
@ -284,14 +284,14 @@ class PostImpl(
|
|||
|
||||
private fun encodeParamsMastodon(json: JsonObject, instance: TootInstance) {
|
||||
|
||||
when(val lang = lang.trim()){
|
||||
when (val lang = lang.trim()) {
|
||||
// Web設定に従うなら指定しない
|
||||
SavedAccount.LANG_WEB,"" -> Unit
|
||||
SavedAccount.LANG_WEB, "" -> Unit
|
||||
// 端末の言語コード
|
||||
SavedAccount.LANG_DEVICE->
|
||||
SavedAccount.LANG_DEVICE ->
|
||||
json["language"] = Locale.getDefault().language
|
||||
// その他
|
||||
else->
|
||||
else ->
|
||||
json["language"] = lang
|
||||
}
|
||||
|
||||
|
@ -378,13 +378,13 @@ class PostImpl(
|
|||
|
||||
suspend fun runSuspend(): PostResult {
|
||||
|
||||
if (account.isMisskey){
|
||||
if (account.isMisskey) {
|
||||
val duplicateCheck = buildMap {
|
||||
attachmentList?.forEach {
|
||||
put( it.id.toString(), (get(it.id.toString())?:0)+1)
|
||||
put(it.id.toString(), (get(it.id.toString()) ?: 0) + 1)
|
||||
}
|
||||
}
|
||||
if( duplicateCheck.values.all { it >=2 }){
|
||||
if (duplicateCheck.values.all { it >= 2 }) {
|
||||
activity.errorString(R.string.post_error_attachments_duplicated)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue