refactor
This commit is contained in:
parent
07865fe5e3
commit
e18af2bbe3
|
@ -1,10 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Kotlin2JsCompilerArguments">
|
|
||||||
<option name="sourceMapEmbedSources" />
|
|
||||||
<option name="sourceMapPrefix" />
|
|
||||||
</component>
|
|
||||||
<component name="KotlinCommonCompilerArguments">
|
|
||||||
<option name="coroutinesState" value="enable" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -403,9 +403,9 @@ class ActMain : AppCompatActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return when {
|
return when(accounts.size) {
|
||||||
// 候補が1つだけならアカウント選択は不要
|
// 候補が1つだけならアカウント選択は不要
|
||||||
accounts.size == 1 -> accounts.first()
|
1 -> accounts.first()
|
||||||
// 候補が2つ以上ならアカウント選択は必要
|
// 候補が2つ以上ならアカウント選択は必要
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
@ -500,11 +500,11 @@ class ActMain : AppCompatActivity()
|
||||||
phoneTab(
|
phoneTab(
|
||||||
{ env -> outState.putInt(STATE_CURRENT_PAGE, env.pager.currentItem) },
|
{ env -> outState.putInt(STATE_CURRENT_PAGE, env.pager.currentItem) },
|
||||||
{ env ->
|
{ env ->
|
||||||
val ve = env.tablet_layout_manager.findLastVisibleItemPosition()
|
env.tablet_layout_manager.findLastVisibleItemPosition()
|
||||||
if(ve != RecyclerView.NO_POSITION) {
|
.takeIf { it != RecyclerView.NO_POSITION }
|
||||||
outState.putInt(STATE_CURRENT_PAGE, ve)
|
?.let { outState.putInt(STATE_CURRENT_PAGE, it) }
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
|
|
||||||
for(column in app_state.column_list) {
|
for(column in app_state.column_list) {
|
||||||
column.saveScrollPosition()
|
column.saveScrollPosition()
|
||||||
|
@ -682,10 +682,47 @@ class ActMain : AppCompatActivity()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
|
||||||
log.d("onResume")
|
log.d("onResume")
|
||||||
isResumed = true
|
isResumed = true
|
||||||
|
|
||||||
|
super.onResume()
|
||||||
|
/*
|
||||||
|
super.onResume() から呼ばれる isTopOfTask() が android.os.RemoteException 例外をたまに出すが、放置することにした。
|
||||||
|
|
||||||
|
java.lang.RuntimeException:
|
||||||
|
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4430)
|
||||||
|
at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4470)
|
||||||
|
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence (TransactionExecutor.java:183)
|
||||||
|
at android.app.servertransaction.TransactionExecutor.cycleToPath (TransactionExecutor.java:165)
|
||||||
|
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:142)
|
||||||
|
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:70)
|
||||||
|
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2199)
|
||||||
|
at android.os.Handler.dispatchMessage (Handler.java:112)
|
||||||
|
at android.os.Looper.loop (Looper.java:216)
|
||||||
|
at android.app.ActivityThread.main (ActivityThread.java:7625)
|
||||||
|
at java.lang.reflect.Method.invoke (Native Method)
|
||||||
|
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524)
|
||||||
|
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:987)
|
||||||
|
Caused by: java.lang.IllegalArgumentException:
|
||||||
|
at android.os.Parcel.createException (Parcel.java:1957)
|
||||||
|
at android.os.Parcel.readException (Parcel.java:1921)
|
||||||
|
at android.os.Parcel.readException (Parcel.java:1871)
|
||||||
|
at android.app.IActivityManager$Stub$Proxy.isTopOfTask (IActivityManager.java:7912)
|
||||||
|
at android.app.Activity.isTopOfTask (Activity.java:6724)
|
||||||
|
at android.app.Activity.onResume (Activity.java:1425)
|
||||||
|
at androidx.fragment.app.FragmentActivity.onResume (FragmentActivity.java:456)
|
||||||
|
at jp.juggler.subwaytooter.ActMain.onResume (ActMain.kt:685)
|
||||||
|
at android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1456)
|
||||||
|
at android.app.Activity.performResume (Activity.java:7614)
|
||||||
|
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4412)
|
||||||
|
Caused by: android.os.RemoteException:
|
||||||
|
at com.android.server.am.ActivityManagerService.isTopOfTask (ActivityManagerService.java:16128)
|
||||||
|
at android.app.IActivityManager$Stub.onTransact (IActivityManager.java:2376)
|
||||||
|
at com.android.server.am.ActivityManagerService.onTransact (ActivityManagerService.java:3648)
|
||||||
|
at com.android.server.am.HwActivityManagerService.onTransact (HwActivityManagerService.java:609)
|
||||||
|
at android.os.Binder.execTransact (Binder.java:739)
|
||||||
|
*/
|
||||||
|
|
||||||
MyClickableSpan.link_callback = WeakReference(link_click_listener)
|
MyClickableSpan.link_callback = WeakReference(link_click_listener)
|
||||||
|
|
||||||
if(Pref.bpDontScreenOff(pref)) {
|
if(Pref.bpDontScreenOff(pref)) {
|
||||||
|
@ -1294,9 +1331,9 @@ class ActMain : AppCompatActivity()
|
||||||
when(Pref.ipJustifyWindowContentPortrait(pref)) {
|
when(Pref.ipJustifyWindowContentPortrait(pref)) {
|
||||||
Pref.JWCP_START -> {
|
Pref.JWCP_START -> {
|
||||||
val iconW = (stripIconSize * 1.5f + 0.5f).toInt()
|
val iconW = (stripIconSize * 1.5f + 0.5f).toInt()
|
||||||
val padding = resources.displayMetrics.widthPixels /2 -iconW
|
val padding = resources.displayMetrics.widthPixels / 2 - iconW
|
||||||
|
|
||||||
fun ViewGroup.addViewBeforeLast(v : View) = addView(v, childCount-1)
|
fun ViewGroup.addViewBeforeLast(v : View) = addView(v, childCount - 1)
|
||||||
(svColumnStrip.parent as LinearLayout).addViewBeforeLast(
|
(svColumnStrip.parent as LinearLayout).addViewBeforeLast(
|
||||||
View(this).apply {
|
View(this).apply {
|
||||||
layoutParams = LinearLayout.LayoutParams(padding, 0)
|
layoutParams = LinearLayout.LayoutParams(padding, 0)
|
||||||
|
@ -1312,7 +1349,7 @@ class ActMain : AppCompatActivity()
|
||||||
Pref.JWCP_END -> {
|
Pref.JWCP_END -> {
|
||||||
val iconW = (stripIconSize * 1.5f + 0.5f).toInt()
|
val iconW = (stripIconSize * 1.5f + 0.5f).toInt()
|
||||||
val borderWidth = (1f * density + 0.5f).toInt()
|
val borderWidth = (1f * density + 0.5f).toInt()
|
||||||
val padding = resources.displayMetrics.widthPixels /2 -iconW -borderWidth
|
val padding = resources.displayMetrics.widthPixels / 2 - iconW - borderWidth
|
||||||
|
|
||||||
fun ViewGroup.addViewAfterFirst(v : View) = addView(v, 1)
|
fun ViewGroup.addViewAfterFirst(v : View) = addView(v, 1)
|
||||||
(svColumnStrip.parent as LinearLayout).addViewAfterFirst(
|
(svColumnStrip.parent as LinearLayout).addViewAfterFirst(
|
||||||
|
@ -1511,12 +1548,12 @@ class ActMain : AppCompatActivity()
|
||||||
|
|
||||||
// 両端のメニューと投稿ボタンの大きさ
|
// 両端のメニューと投稿ボタンの大きさ
|
||||||
val pad = (rootH - iconSize) shr 1
|
val pad = (rootH - iconSize) shr 1
|
||||||
for(btn in arrayOf(btnToot,btnMenu,btnQuickTootMenu,btnQuickToot)){
|
for(btn in arrayOf(btnToot, btnMenu, btnQuickTootMenu, btnQuickToot)) {
|
||||||
btn.layoutParams.width = rootH // not W
|
btn.layoutParams.width = rootH // not W
|
||||||
btn.layoutParams.height = rootH
|
btn.layoutParams.height = rootH
|
||||||
btn.setPaddingRelative(pad, pad, pad, pad)
|
btn.setPaddingRelative(pad, pad, pad, pad)
|
||||||
}
|
}
|
||||||
|
|
||||||
llColumnStrip.removeAllViews()
|
llColumnStrip.removeAllViews()
|
||||||
for(i in 0 until app_state.column_list.size) {
|
for(i in 0 until app_state.column_list.size) {
|
||||||
|
|
||||||
|
@ -2344,11 +2381,11 @@ class ActMain : AppCompatActivity()
|
||||||
|
|
||||||
// opener.linkInfo をチェックしてメンションを判別する
|
// opener.linkInfo をチェックしてメンションを判別する
|
||||||
val mention = opener.linkInfo?.mention
|
val mention = opener.linkInfo?.mention
|
||||||
if( mention != null ){
|
if(mention != null) {
|
||||||
val fullAcct = getFullAcctOrNull(accessInfo,mention.acct,mention.url)
|
val fullAcct = getFullAcctOrNull(accessInfo, mention.acct, mention.url)
|
||||||
if( fullAcct != null){
|
if(fullAcct != null) {
|
||||||
val(user,host) = fullAcct.splitFullAcct()
|
val (user, host) = fullAcct.splitFullAcct()
|
||||||
if(host != null ) {
|
if(host != null) {
|
||||||
when(host.toLowerCase(Locale.JAPAN)) {
|
when(host.toLowerCase(Locale.JAPAN)) {
|
||||||
"github.com",
|
"github.com",
|
||||||
"twitter.com" ->
|
"twitter.com" ->
|
||||||
|
@ -2371,7 +2408,7 @@ class ActMain : AppCompatActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ユーザページをアプリ内で開く
|
// ユーザページをアプリ内で開く
|
||||||
var m = TootAccount.reAccountUrl.matcher(opener.url)
|
var m = TootAccount.reAccountUrl.matcher(opener.url)
|
||||||
if(m.find()) {
|
if(m.find()) {
|
||||||
|
@ -2432,7 +2469,6 @@ class ActMain : AppCompatActivity()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
App1.openCustomTab(this, opener.url)
|
App1.openCustomTab(this, opener.url)
|
||||||
|
|
|
@ -1114,8 +1114,9 @@ internal class ItemViewHolder(
|
||||||
whoRef.decoded_display_name
|
whoRef.decoded_display_name
|
||||||
}.intoStringResource(activity, string_id)
|
}.intoStringResource(activity, string_id)
|
||||||
|
|
||||||
if(misskeyReaction != null) {
|
val emojiResource = misskeyReaction.emojiResource
|
||||||
misskeyReaction.loadToImageView(activity, ivBoosted)
|
if(emojiResource != null) {
|
||||||
|
emojiResource.loadToImageView(activity, ivBoosted)
|
||||||
// TODO パディング少し変える?
|
// TODO パディング少し変える?
|
||||||
} else {
|
} else {
|
||||||
setIconDrawableId(
|
setIconDrawableId(
|
||||||
|
@ -2450,12 +2451,12 @@ internal class ItemViewHolder(
|
||||||
?.get(customCode)
|
?.get(customCode)
|
||||||
|
|
||||||
val emojiUrl = emoji?.let {
|
val emojiUrl = emoji?.let {
|
||||||
if(Pref.bpDisableEmojiAnimation(this@ItemViewHolder.activity.pref)) {
|
if(Pref.bpDisableEmojiAnimation(this@ItemViewHolder.activity.pref)) {
|
||||||
it.static_url
|
it.static_url
|
||||||
} else {
|
} else {
|
||||||
it.url
|
it.url
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val sb = SpannableStringBuilder("$name $count")
|
val sb = SpannableStringBuilder("$name $count")
|
||||||
if(emojiUrl != null) {
|
if(emojiUrl != null) {
|
||||||
|
@ -2503,7 +2504,7 @@ internal class ItemViewHolder(
|
||||||
addEmojiReaction(mr.shortcode, mr.emojiUtf16, count)
|
addEmojiReaction(mr.shortcode, mr.emojiUtf16, count)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// カスタム絵文字のリアクション
|
// カスタム絵文字のリアクション
|
||||||
val customCode = key.replace(":", "")
|
val customCode = key.replace(":", "")
|
||||||
if(key != customCode) {
|
if(key != customCode) {
|
||||||
|
|
|
@ -6,17 +6,30 @@ import com.bumptech.glide.Glide
|
||||||
import jp.juggler.emoji.EmojiMap
|
import jp.juggler.emoji.EmojiMap
|
||||||
import jp.juggler.subwaytooter.ActMain
|
import jp.juggler.subwaytooter.ActMain
|
||||||
|
|
||||||
private fun findSvgFile(utf16 : String):EmojiMap.EmojiResource{
|
private fun findSvgFile(utf16 : String) =
|
||||||
return EmojiMap.sUTF16ToEmojiResource[utf16]!!
|
EmojiMap.sUTF16ToEmojiResource[utf16]
|
||||||
|
|
||||||
|
fun EmojiMap.EmojiResource.loadToImageView(activity : ActMain, view : ImageView) {
|
||||||
|
if(isSvg) {
|
||||||
|
Glide.with(activity)
|
||||||
|
.`as`(PictureDrawable::class.java)
|
||||||
|
.load("file:///android_asset/${assetsName}")
|
||||||
|
.into(view)
|
||||||
|
} else {
|
||||||
|
Glide.with(activity)
|
||||||
|
.load(drawableId)
|
||||||
|
.into(view)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MisskeyReaction(
|
class MisskeyReaction(
|
||||||
val shortcode : String,
|
val shortcode : String,
|
||||||
val emojiUtf16 : String,
|
val emojiUtf16 : String,
|
||||||
private val emojiResource : EmojiMap.EmojiResource = findSvgFile(emojiUtf16),
|
val emojiResource : EmojiMap.EmojiResource? = findSvgFile(emojiUtf16),
|
||||||
val showOnPicker : Boolean = true
|
val showOnPicker : Boolean = true
|
||||||
) {
|
) {
|
||||||
companion object{
|
|
||||||
|
companion object {
|
||||||
private val LIST = listOf(
|
private val LIST = listOf(
|
||||||
MisskeyReaction(
|
MisskeyReaction(
|
||||||
"like",
|
"like",
|
||||||
|
@ -65,23 +78,10 @@ class MisskeyReaction(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun values() =LIST
|
fun values() = LIST
|
||||||
|
|
||||||
val shortcodeMap = HashMap<String, MisskeyReaction>().apply{
|
val shortcodeMap = HashMap<String, MisskeyReaction>().apply {
|
||||||
LIST.forEach { put(it.shortcode,it) }
|
LIST.forEach { put(it.shortcode, it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fun loadToImageView(activity: ActMain, view: ImageView){
|
|
||||||
if(emojiResource.isSvg) {
|
|
||||||
Glide.with(activity)
|
|
||||||
.`as`(PictureDrawable::class.java)
|
|
||||||
.load("file:///android_asset/${emojiResource.assetsName}")
|
|
||||||
.into(view)
|
|
||||||
} else {
|
|
||||||
Glide.with(activity)
|
|
||||||
.load(emojiResource.drawableId)
|
|
||||||
.into(view)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue