ic_questionもVectorDrawableにする。トゥートやアカウントの同期時に検索結果0件だった場合にエラーを表示する。
|
@ -724,13 +724,9 @@ class ActAccountSetting
|
|||
|
||||
private fun initializeProfile() {
|
||||
// 初期状態
|
||||
ivProfileAvatar.setErrorImageResId(getAttributeResourceId(this, R.attr.ic_question))
|
||||
ivProfileAvatar.setDefaultImageResId(
|
||||
getAttributeResourceId(
|
||||
this,
|
||||
R.attr.ic_question
|
||||
)
|
||||
)
|
||||
val question_id = getAttributeResourceId(this, R.attr.ic_question)
|
||||
ivProfileAvatar.setErrorImageResId(question_id)
|
||||
ivProfileAvatar.setDefaultImageResId(question_id)
|
||||
|
||||
val loadingText = when(account.isPseudo) {
|
||||
true -> "(disabled for pseudo account)"
|
||||
|
|
|
@ -747,7 +747,7 @@ internal class ItemViewHolder(
|
|||
if(n_account != null) showBoost(
|
||||
n_accountRef,
|
||||
n.time_created_at,
|
||||
R.attr.ic_question,
|
||||
R.attr.ic_question, // not used
|
||||
R.string.display_name_reaction_by
|
||||
, reactionDrawableId = reaction?.btnDrawableId
|
||||
)
|
||||
|
|
|
@ -31,21 +31,17 @@ internal fun findAccountByName(
|
|||
|
||||
override fun background(client : TootApiClient) : TootApiResult? {
|
||||
|
||||
val path = "/api/v1/accounts/search" + "?q=" + user.encodePercent()
|
||||
|
||||
val result = client.request(path)
|
||||
val result = client.request("/api/v1/accounts/search?q=${user.encodePercent()}")
|
||||
val array = result?.jsonArray
|
||||
if(array != null) {
|
||||
val parser = TootParser(activity, access_info)
|
||||
for(i in 0 until array.length()) {
|
||||
val a = parser.account(array.optJSONObject(i))
|
||||
if(a != null) {
|
||||
if(a.username == user
|
||||
&& access_info.getFullAcct(a).equals("$user@$host", ignoreCase = true)
|
||||
) {
|
||||
who = a
|
||||
break
|
||||
}
|
||||
val a = parser.account(array.optJSONObject(i)) ?: continue
|
||||
if(a.username == user
|
||||
&& access_info.getFullAcct(a).equals("$user@$host", ignoreCase = true)
|
||||
) {
|
||||
who = a
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1337,91 +1337,77 @@ fun TootApiClient.syncAccountByUrl(accessInfo : SavedAccount, who_url : String)
|
|||
}
|
||||
}
|
||||
|
||||
if(accessInfo.isMisskey) {
|
||||
val parser = TootParser(context, accessInfo)
|
||||
|
||||
return if(accessInfo.isMisskey) {
|
||||
|
||||
val acct = TootAccount.getAcctFromUrl(who_url)
|
||||
?: return TootApiResult(context.getString(R.string.user_id_conversion_failed))
|
||||
|
||||
val delm = acct.indexOf('@')
|
||||
val params = accessInfo.putMisskeyApiToken(JSONObject())
|
||||
if(delm != - 1) {
|
||||
params.put("username", acct.substring(0, delm))
|
||||
params.put("host", acct.substring(delm + 1))
|
||||
} else {
|
||||
params.put("username", acct)
|
||||
}
|
||||
|
||||
val result = this.request("/api/users/show", params.toPostRequestBuilder())
|
||||
val jsonObject = result?.jsonObject
|
||||
|
||||
if(jsonObject != null) {
|
||||
val tmp = TootParser(this.context, accessInfo).account(jsonObject)
|
||||
if(tmp != null) {
|
||||
result.data = tmp
|
||||
} else {
|
||||
result.setError(context.getString(R.string.user_id_conversion_failed))
|
||||
request(
|
||||
"/api/users/show",
|
||||
accessInfo.putMisskeyApiToken(JSONObject()).apply {
|
||||
when(val delm = acct.indexOf('@')) {
|
||||
- 1 -> put("username", acct)
|
||||
|
||||
else -> {
|
||||
put("username", acct.substring(0, delm))
|
||||
put("host", acct.substring(delm + 1))
|
||||
}
|
||||
}
|
||||
}.toPostRequestBuilder()
|
||||
)
|
||||
?.apply {
|
||||
data = parser.account(jsonObject)
|
||||
if(data == null && error == null) {
|
||||
setError(context.getString(R.string.user_id_conversion_failed))
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
||||
} else {
|
||||
val path = String.format(
|
||||
Locale.JAPAN,
|
||||
Column.PATH_SEARCH,
|
||||
who_url.encodePercent()
|
||||
) + "&resolve=1"
|
||||
val result = this.request(path)
|
||||
val jsonObject = result?.jsonObject
|
||||
if(jsonObject != null) {
|
||||
val tmp = TootParser(this.context, accessInfo).results(jsonObject)
|
||||
if(tmp != null && tmp.accounts.isNotEmpty()) {
|
||||
result.data = tmp.accounts[0].get()
|
||||
} else {
|
||||
result.setError(context.getString(R.string.user_id_conversion_failed))
|
||||
request("/api/v1/search?q=${who_url.encodePercent()}&resolve=true")
|
||||
?.apply {
|
||||
data = parser.results(jsonObject)?.accounts?.firstOrNull()
|
||||
if(data == null && error == null) {
|
||||
setError(context.getString(R.string.user_id_conversion_failed))
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
fun TootApiClient.syncAccountByAcct(accessInfo : SavedAccount, acct : String) : TootApiResult? {
|
||||
if(accessInfo.isMisskey) {
|
||||
val delm = acct.indexOf('@')
|
||||
val params = accessInfo.putMisskeyApiToken(JSONObject())
|
||||
if(delm != - 1) {
|
||||
params.put("username", acct.substring(0, delm))
|
||||
params.put("host", acct.substring(delm + 1))
|
||||
} else {
|
||||
params.put("username", acct)
|
||||
}
|
||||
|
||||
val result = this.request("/api/users/show", params.toPostRequestBuilder())
|
||||
val jsonObject = result?.jsonObject
|
||||
|
||||
if(jsonObject != null) {
|
||||
val tmp = TootParser(this.context, accessInfo).account(jsonObject)
|
||||
if(tmp != null) {
|
||||
result.data = tmp
|
||||
} else {
|
||||
result.setError(context.getString(R.string.user_id_conversion_failed))
|
||||
|
||||
val parser = TootParser(context, accessInfo)
|
||||
return if(accessInfo.isMisskey) {
|
||||
request(
|
||||
"/api/users/show",
|
||||
accessInfo.putMisskeyApiToken()
|
||||
.apply {
|
||||
when(val delm = acct.indexOf('@')) {
|
||||
- 1 -> put("username", acct)
|
||||
|
||||
else -> {
|
||||
put("username", acct.substring(0, delm))
|
||||
put("host", acct.substring(delm + 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
.toPostRequestBuilder()
|
||||
)
|
||||
?.apply {
|
||||
data = parser.account(jsonObject)
|
||||
if(data == null && error == null) {
|
||||
setError(context.getString(R.string.user_id_conversion_failed))
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
} else {
|
||||
val path = String.format(
|
||||
Locale.JAPAN,
|
||||
Column.PATH_SEARCH,
|
||||
acct.encodePercent()
|
||||
) + "&resolve=1"
|
||||
val result = this.request(path)
|
||||
val jsonObject = result?.jsonObject
|
||||
if(jsonObject != null) {
|
||||
val tmp = TootParser(this.context, accessInfo).results(jsonObject)
|
||||
if(tmp != null && tmp.accounts.isNotEmpty()) {
|
||||
result.data = tmp.accounts[0].get()
|
||||
} else {
|
||||
result.setError(context.getString(R.string.user_id_conversion_failed))
|
||||
request("/api/v1/search?q=${acct.encodePercent()}&resolve=true")
|
||||
?.apply {
|
||||
data = parser.results(jsonObject)?.accounts?.firstOrNull()
|
||||
if(data == null && error == null) {
|
||||
setError(context.getString(R.string.user_id_conversion_failed))
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1437,9 +1423,7 @@ fun TootApiClient.syncStatus(accessInfo : SavedAccount, urlArg : String) : TootA
|
|||
val noteId = m.group(2)
|
||||
|
||||
TootApiClient(context, callback = callback)
|
||||
|
||||
.apply { instance = host }
|
||||
|
||||
.request(
|
||||
"/api/notes/show",
|
||||
JSONObject()
|
||||
|
@ -1468,22 +1452,27 @@ fun TootApiClient.syncStatus(accessInfo : SavedAccount, urlArg : String) : TootA
|
|||
|
||||
// 使いたいタンス上の投稿IDを取得する
|
||||
val parser = TootParser(context, accessInfo)
|
||||
return when {
|
||||
|
||||
accessInfo.isMisskey -> request(
|
||||
return if(accessInfo.isMisskey) {
|
||||
request(
|
||||
"/api/ap/show",
|
||||
accessInfo.putMisskeyApiToken()
|
||||
.put("uri", url)
|
||||
.toPostRequestBuilder()
|
||||
)?.apply {
|
||||
data = parser.parseMisskeyApShow(jsonObject)
|
||||
}
|
||||
|
||||
else -> request(
|
||||
"/api/v1/search?q=${url.encodePercent()}&resolve=true"
|
||||
)?.apply {
|
||||
data = parser.results(jsonObject)?.statuses?.firstOrNull()
|
||||
}
|
||||
)
|
||||
?.apply {
|
||||
data = parser.parseMisskeyApShow(jsonObject)
|
||||
if(data == null && error == null) {
|
||||
setError(context.getString(R.string.cant_sync_toot))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
request("/api/v1/search?q=${url.encodePercent()}&resolve=true")
|
||||
?.apply {
|
||||
data = parser.results(jsonObject)?.statuses?.firstOrNull()
|
||||
if(data == null && error == null) {
|
||||
setError(context.getString(R.string.cant_sync_toot))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 800 B |
Before Width: | Height: | Size: 604 B |
Before Width: | Height: | Size: 520 B |
Before Width: | Height: | Size: 406 B |
Before Width: | Height: | Size: 1014 B |
Before Width: | Height: | Size: 768 B |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.2 KiB |
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z"/>
|
||||
</vector>
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z"/>
|
||||
</vector>
|