リスト名の変更。クラッシュレポート対応。
This commit is contained in:
parent
4c37c382b3
commit
d014fc8f46
|
@ -12,8 +12,8 @@ android {
|
|||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
|
||||
versionCode 214
|
||||
versionName "2.1.4"
|
||||
versionCode 215
|
||||
versionName "2.1.5"
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
|
|
@ -2036,7 +2036,7 @@ class ActMain : AppCompatActivity()
|
|||
private fun closeColumnSetting() : Boolean {
|
||||
phoneTab({ env ->
|
||||
val vh = env.pager_adapter.getColumnViewHolder(env.pager.currentItem)
|
||||
if(vh.isColumnSettingShown) {
|
||||
if(vh?.isColumnSettingShown == true ) {
|
||||
vh.closeColumnSetting()
|
||||
return@closeColumnSetting true
|
||||
}
|
||||
|
|
|
@ -879,6 +879,20 @@ class Column(
|
|||
}
|
||||
}
|
||||
|
||||
fun onListNameUpdated(account : SavedAccount, item : TootList) {
|
||||
if(access_info.acct != account.acct) return
|
||||
when(column_type) {
|
||||
TYPE_LIST_LIST -> {
|
||||
startLoading()
|
||||
}
|
||||
|
||||
TYPE_LIST_TL, TYPE_LIST_MEMBER -> {
|
||||
this.list_info = item
|
||||
fireShowColumnHeader()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onListMemberUpdated(
|
||||
account : SavedAccount,
|
||||
list_id : Long,
|
||||
|
@ -1110,7 +1124,7 @@ class Column(
|
|||
internal fun loadProfileAccount(client : TootApiClient, bForceReload : Boolean) {
|
||||
if(bForceReload || this.who_account == null) {
|
||||
val result = client.request(String.format(Locale.JAPAN, PATH_ACCOUNT, profile_id))
|
||||
val a = TootParser(context,access_info).account(result?.jsonObject)
|
||||
val a = TootParser(context, access_info).account(result?.jsonObject)
|
||||
if(a != null) {
|
||||
this.who_account = a
|
||||
client.publishApiProgress("") // カラムヘッダの再表示
|
||||
|
@ -1714,7 +1728,8 @@ class Column(
|
|||
max_id = TootApiClient.getMspMaxId(jsonArray, max_id)
|
||||
// リストデータの用意
|
||||
parser.serviceType = ServiceType.MSP
|
||||
list_tmp = addWithFilterStatus(null, parser.statusList(jsonArray))
|
||||
list_tmp =
|
||||
addWithFilterStatus(null, parser.statusList(jsonArray))
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
@ -1925,7 +1940,7 @@ class Column(
|
|||
var jsonArray = result?.jsonArray
|
||||
if(jsonArray != null) {
|
||||
saveRange(result, bBottom, ! bBottom)
|
||||
var src = parser.accountList( jsonArray)
|
||||
var src = parser.accountList(jsonArray)
|
||||
list_tmp = addAll(null, src)
|
||||
if(! bBottom) {
|
||||
var bGapAdded = false
|
||||
|
@ -1967,7 +1982,7 @@ class Column(
|
|||
break
|
||||
}
|
||||
|
||||
src = parser.accountList( jsonArray)
|
||||
src = parser.accountList(jsonArray)
|
||||
addAll(list_tmp, src)
|
||||
}
|
||||
if(Pref.bpForceGap(context) && ! isCancelled && ! bGapAdded && list_tmp?.isNotEmpty() == true) {
|
||||
|
@ -2527,7 +2542,10 @@ class Column(
|
|||
max_id = TootApiClient.getMspMaxId(jsonArray, max_id)
|
||||
// リストデータの用意
|
||||
parser.serviceType = ServiceType.MSP
|
||||
list_tmp = addWithFilterStatus(list_tmp, parser.statusList(jsonArray))
|
||||
list_tmp = addWithFilterStatus(
|
||||
list_tmp,
|
||||
parser.statusList(jsonArray)
|
||||
)
|
||||
}
|
||||
}
|
||||
result
|
||||
|
@ -2748,7 +2766,7 @@ class Column(
|
|||
break
|
||||
}
|
||||
result = r2
|
||||
val src = parser.accountList( jsonArray)
|
||||
val src = parser.accountList(jsonArray)
|
||||
|
||||
if(src.isEmpty()) {
|
||||
log.d("gap-account: empty.")
|
||||
|
|
|
@ -26,7 +26,7 @@ internal class ColumnPagerAdapter(private val activity : ActMain) : PagerAdapter
|
|||
return if(idx >= 0 && idx < column_list.size) column_list[idx] else null
|
||||
}
|
||||
|
||||
fun getColumnViewHolder(idx : Int) : ColumnViewHolder {
|
||||
fun getColumnViewHolder(idx : Int) : ColumnViewHolder? {
|
||||
return holder_list.get(idx)
|
||||
}
|
||||
|
||||
|
|
|
@ -892,6 +892,9 @@ internal class ItemViewHolder(
|
|||
.addAction(activity.getString(R.string.list_member)) {
|
||||
activity.addColumn(pos, access_info, Column.TYPE_LIST_MEMBER, item.id)
|
||||
}
|
||||
.addAction(activity.getString(R.string.rename)){
|
||||
Action_List.rename(activity, access_info, item)
|
||||
}
|
||||
.addAction(activity.getString(R.string.delete)) {
|
||||
DlgConfirm.openSimple(
|
||||
activity
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package jp.juggler.subwaytooter.action
|
||||
|
||||
import android.app.Dialog
|
||||
import org.json.JSONObject
|
||||
|
||||
import jp.juggler.subwaytooter.ActMain
|
||||
|
@ -10,6 +11,7 @@ import jp.juggler.subwaytooter.api.TootTask
|
|||
import jp.juggler.subwaytooter.api.TootTaskRunner
|
||||
import jp.juggler.subwaytooter.api.entity.TootList
|
||||
import jp.juggler.subwaytooter.api.entity.parseItem
|
||||
import jp.juggler.subwaytooter.dialog.DlgTextInput
|
||||
import jp.juggler.subwaytooter.table.SavedAccount
|
||||
import jp.juggler.subwaytooter.util.showToast
|
||||
import jp.juggler.subwaytooter.util.withCaption
|
||||
|
@ -41,7 +43,8 @@ object Action_List {
|
|||
val request_builder = Request.Builder().post(
|
||||
RequestBody.create(
|
||||
TootApiClient.MEDIA_TYPE_JSON, content.toString()
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
val result = client.request("/api/v1/lists", request_builder)
|
||||
|
||||
|
@ -97,4 +100,62 @@ object Action_List {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun rename(activity : ActMain, access_info : SavedAccount, item : TootList) {
|
||||
DlgTextInput.show(
|
||||
activity,
|
||||
activity.getString(R.string.rename),
|
||||
item.title,
|
||||
object : DlgTextInput.Callback {
|
||||
override fun onEmptyError() {
|
||||
showToast(activity, false, R.string.list_name_empty)
|
||||
}
|
||||
|
||||
override fun onOK(dialog : Dialog, text : String) {
|
||||
TootTaskRunner(activity).run(access_info, object : TootTask {
|
||||
internal var list : TootList? = null
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
val content = JSONObject()
|
||||
try {
|
||||
content.put("title", text)
|
||||
} catch(ex : Throwable) {
|
||||
return TootApiResult(ex.withCaption("can't encoding json parameter."))
|
||||
}
|
||||
|
||||
val request_builder = Request.Builder().put(
|
||||
RequestBody.create(
|
||||
TootApiClient.MEDIA_TYPE_JSON, content.toString()
|
||||
)
|
||||
)
|
||||
|
||||
val result = client.request("/api/v1/lists/${item.id}", request_builder)
|
||||
|
||||
client.publishApiProgress(activity.getString(R.string.parsing_response))
|
||||
list = parseItem(::TootList, result?.jsonObject)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
override fun handleResult(result : TootApiResult?) {
|
||||
if(result == null) return // cancelled.
|
||||
|
||||
val list = this.list
|
||||
if(list != null) {
|
||||
for(column in activity.app_state.column_list) {
|
||||
column.onListNameUpdated(access_info, list)
|
||||
}
|
||||
try {
|
||||
dialog.dismiss()
|
||||
} catch(ignored : Throwable) {
|
||||
|
||||
}
|
||||
} else {
|
||||
showToast(activity, false, result.error)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,17 +91,14 @@ class TootList(
|
|||
val oa = if(i >= sa) null else la[i]
|
||||
val ob = if(i >= sb) null else lb[i]
|
||||
|
||||
val delta = if(oa == null) {
|
||||
if(ob == null) 0 else - 1
|
||||
} else if(ob == null) {
|
||||
1
|
||||
} else {
|
||||
|
||||
when {
|
||||
oa is Long && ob is Long -> compareLong(oa, ob)
|
||||
oa is String && ob is String -> compareString(oa, ob)
|
||||
else -> (ob is Long).b2i() - (oa is Long).b2i()
|
||||
}
|
||||
if(oa == null && ob == null) return 0
|
||||
|
||||
val delta = when {
|
||||
oa == null -> - 1
|
||||
ob == null -> 1
|
||||
oa is Long && ob is Long -> compareLong(oa, ob)
|
||||
oa is String && ob is String -> compareString(oa, ob)
|
||||
else -> (ob is Long).b2i() - (oa is Long).b2i()
|
||||
}
|
||||
log.d(
|
||||
"%s %s %s"
|
||||
|
|
|
@ -21,7 +21,10 @@ object DlgTextInput {
|
|||
|
||||
@SuppressLint("InflateParams")
|
||||
fun show(
|
||||
activity : Activity, caption : CharSequence, initial_text : CharSequence?, callback : Callback
|
||||
activity : Activity,
|
||||
caption : CharSequence,
|
||||
initial_text : CharSequence?,
|
||||
callback : Callback
|
||||
) {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dlg_text_input, null, false)
|
||||
val etInput = view.findViewById<EditText>(R.id.etInput)
|
||||
|
|
|
@ -606,10 +606,9 @@
|
|||
<string name="avatar_icon_round_ratio">Avatar icon round ratio (unit:%. default:33. app restart required)</string>
|
||||
<string name="avatar_icon_dont_round">Don\'t round corner of avatar icon (app restart required)</string>
|
||||
<string name="share_view_pool">Share view pool between columns</string>
|
||||
<string name="rename">Rename…</string>
|
||||
|
||||
|
||||
|
||||
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>-->
|
||||
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>-->
|
||||
<!--<string name="abc_action_bar_home_description_format">%1$s, %2$s</string>-->
|
||||
<!--<string name="abc_action_bar_home_subtitle_description_format">%1$s, %2$s, %3$s</string>-->
|
||||
<!--<string name="abc_action_bar_up_description">Revenir en haut de la page</string>-->
|
||||
|
|
|
@ -889,5 +889,6 @@
|
|||
<string name="avatar_icon_round_ratio">ユーザ画像の角丸率(単位:%。デフォルト:33。アプリ再起動が必要)</string>
|
||||
<string name="avatar_icon_dont_round">ユーザ画像を角丸にしない(アプリ再起動が必要)</string>
|
||||
<string name="share_view_pool">カラム間でViewPoolを共有する</string>
|
||||
<string name="rename">名前の変更…</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -595,4 +595,5 @@
|
|||
<string name="avatar_icon_round_ratio">Avatar icon round ratio (unit:%. default:33. app restart required)</string>
|
||||
<string name="avatar_icon_dont_round">Don\'t round corner of avatar icon (app restart required)</string>
|
||||
<string name="share_view_pool">Share view pool between columns</string>
|
||||
<string name="rename">Rename…</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue