内蔵メディアビューアの背景タイルをより暗くした。アプリ設定に「挙動/カラムの重複を許容」カラム設定に「システム通知のタップで選ばれない」を追加。

This commit is contained in:
tateisu 2018-02-07 05:41:30 +09:00
parent d014fc8f46
commit 1f85fb49cc
22 changed files with 227 additions and 35 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

After

Width:  |  Height:  |  Size: 150 B

View File

@ -2,6 +2,7 @@
package jp.juggler.subwaytooter.api
import android.content.Context
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import jp.juggler.subwaytooter.table.SavedAccount
@ -30,11 +31,11 @@ class TestTootApiClient {
override var currentCallCallback : CurrentCallCallback? = null
override fun getResponse(request : Request) : Response {
override fun getResponse(context: Context, request : Request) : Response {
return responseGenerator(request)
}
override fun getWebSocket(request : Request, webSocketListener : WebSocketListener) : WebSocket {
override fun getWebSocket(context: Context,request : Request, webSocketListener : WebSocketListener) : WebSocket {
return webSocketGenerator(request, webSocketListener)
}
}

View File

@ -772,6 +772,7 @@ class ActMain : AppCompatActivity()
if(resultCode == ActText.RESULT_SEARCH_MSP) {
val text = data?.getStringExtra(Intent.EXTRA_TEXT)
addColumn(
false,
defaultInsertPosition,
SavedAccount.na,
Column.TYPE_SEARCH_MSP,
@ -779,7 +780,13 @@ class ActMain : AppCompatActivity()
)
} else if(resultCode == ActText.RESULT_SEARCH_TS) {
val text = data?.getStringExtra(Intent.EXTRA_TEXT)
addColumn(defaultInsertPosition, SavedAccount.na, Column.TYPE_SEARCH_TS, text ?: "")
addColumn(
false,
defaultInsertPosition,
SavedAccount.na,
Column.TYPE_SEARCH_TS,
text ?: ""
)
}
}
@ -1516,8 +1523,23 @@ class ActMain : AppCompatActivity()
val dataId = dataIdString.toLong(10)
val account = SavedAccount.loadAccount(this@ActMain, dataId)
if(account != null) {
val column =
addColumn(defaultInsertPosition, account, Column.TYPE_NOTIFICATIONS)
var column = app_state.column_list.firstOrNull {
it.column_type == Column.TYPE_NOTIFICATIONS
&& account.acct == it.access_info.acct
&& ! it.system_notification_not_related
}
if( column != null){
val index = app_state.column_list.indexOf(column)
scrollToColumn(index)
}else {
column = addColumn(
true,
defaultInsertPosition,
account,
Column.TYPE_NOTIFICATIONS
)
}
// 通知を読み直す
if(! column.bInitialLoading) {
column.startLoading()
@ -1693,12 +1715,12 @@ class ActMain : AppCompatActivity()
// 適当にカラムを追加する
val count = SavedAccount.count
if(count > 1) {
addColumn(defaultInsertPosition, account, Column.TYPE_HOME)
addColumn(false,defaultInsertPosition, account, Column.TYPE_HOME)
} else {
addColumn(defaultInsertPosition, account, Column.TYPE_HOME)
addColumn(defaultInsertPosition, account, Column.TYPE_NOTIFICATIONS)
addColumn(defaultInsertPosition, account, Column.TYPE_LOCAL)
addColumn(defaultInsertPosition, account, Column.TYPE_FEDERATE)
addColumn(false,defaultInsertPosition, account, Column.TYPE_HOME)
addColumn(false,defaultInsertPosition, account, Column.TYPE_NOTIFICATIONS)
addColumn(false,defaultInsertPosition, account, Column.TYPE_LOCAL)
addColumn(false,defaultInsertPosition, account, Column.TYPE_FEDERATE)
}
return true
@ -1839,20 +1861,41 @@ class ActMain : AppCompatActivity()
//////////////////////////////////////////////////////////////
// カラム追加系
fun addColumn(indexArg : Int, ai : SavedAccount, type : Int, vararg params : Any) : Column {
var index = indexArg
// 既に同じカラムがあればそこに移動する
for(column in app_state.column_list) {
if(column.isSameSpec(ai, type, params)) {
index = app_state.column_list.indexOf(column)
scrollToColumn(index)
return column
fun addColumn(
indexArg : Int,
ai : SavedAccount,
type : Int,
vararg params : Any
) : Column {
return addColumn(
Pref.bpAllowColumnDuplication(pref),
indexArg,
ai,
type,
*params
)
}
fun addColumn(
allowColumnDuplication:Boolean,
indexArg : Int,
ai : SavedAccount,
type : Int,
vararg params : Any
) : Column {
if( ! allowColumnDuplication) {
// 既に同じカラムがあればそこに移動する
for(column in app_state.column_list) {
if(column.isSameSpec(ai, type, params)) {
val indexColumn = app_state.column_list.indexOf(column)
scrollToColumn(indexColumn)
return column
}
}
}
//
val col = Column(app_state, ai, this, type, *params)
index = addColumn(col, index)
val index = addColumn(col, indexArg)
scrollToColumn(index)
if(! col.bFirstInitialized) {
col.startLoading()

View File

@ -97,6 +97,8 @@ class Column(
private const val KEY_DONT_STREAMING = "dont_streaming"
private const val KEY_DONT_AUTO_REFRESH = "dont_auto_refresh"
private const val KEY_HIDE_MEDIA_DEFAULT = "hide_media_default"
private const val KEY_SYSTEM_NOTIFICATION_NOT_RELATED = "system_notification_not_related"
private const val KEY_ENABLE_SPEECH = "enable_speech"
private const val KEY_REGEX_TEXT = "regex_text"
@ -269,6 +271,7 @@ class Column(
internal var dont_streaming : Boolean = false
internal var dont_auto_refresh : Boolean = false
internal var hide_media_default : Boolean = false
internal var system_notification_not_related : Boolean = false
var enable_speech : Boolean = false
internal var regex_text : String = ""
@ -443,6 +446,8 @@ class Column(
dont_streaming = src.optBoolean(KEY_DONT_STREAMING)
dont_auto_refresh = src.optBoolean(KEY_DONT_AUTO_REFRESH)
hide_media_default = src.optBoolean(KEY_HIDE_MEDIA_DEFAULT)
system_notification_not_related = src.optBoolean(KEY_SYSTEM_NOTIFICATION_NOT_RELATED)
enable_speech = src.optBoolean(KEY_ENABLE_SPEECH)
regex_text = src.parseString(KEY_REGEX_TEXT) ?: ""
@ -494,6 +499,8 @@ class Column(
dst.put(KEY_DONT_STREAMING, dont_streaming)
dst.put(KEY_DONT_AUTO_REFRESH, dont_auto_refresh)
dst.put(KEY_HIDE_MEDIA_DEFAULT, hide_media_default)
dst.put(KEY_SYSTEM_NOTIFICATION_NOT_RELATED, system_notification_not_related)
dst.put(KEY_ENABLE_SPEECH, enable_speech)
dst.put(KEY_REGEX_TEXT, regex_text)
@ -607,10 +614,43 @@ class Column(
if(bLong) context.getString(R.string.instance_information_of, instance_uri)
else getColumnTypeName(context, column_type)
TYPE_NOTIFICATIONS ->
context.getString(R.string.notifications) + getNotificationTypeString()
else -> getColumnTypeName(context, column_type)
}
}
private fun getNotificationTypeString() : String {
return if(! dont_show_reply && ! dont_show_follow && ! dont_show_boost && ! dont_show_favourite) {
""
} else if(dont_show_reply && dont_show_follow && dont_show_boost && dont_show_favourite) {
""
} else {
val sb = StringBuilder()
if(! dont_show_reply) {
if(sb.isNotEmpty()) sb.append(", ")
sb.append(context.getString(R.string.notification_type_mention))
}
if(! dont_show_follow) {
if(sb.isNotEmpty()) sb.append(", ")
sb.append(context.getString(R.string.notification_type_follow))
}
if(! dont_show_boost) {
if(sb.isNotEmpty()) sb.append(", ")
sb.append(context.getString(R.string.notification_type_boost))
}
if(! dont_show_favourite) {
if(sb.isNotEmpty()) sb.append(", ")
sb.append(context.getString(R.string.notification_type_favourite))
}
sb.insert(0, "(")
sb.append(")")
sb.toString()
}
}
internal fun dispose() {
is_dispose.set(true)
stopStreaming()
@ -1103,6 +1143,11 @@ class Column(
return true
}
if(dont_show_reply && TootNotification.TYPE_MENTION == item.type) {
log.d("isFiltered: mention notification filtered.")
return true
}
val status = item.status
if(status != null) {
if(status.checkMuted(muted_app, muted_word)) {
@ -3247,10 +3292,10 @@ class Column(
}
}
// カラム設定に「変身を表示しない」ボタンを含めるなら真
// カラム設定に「返信を表示しない」ボタンを含めるなら真
fun canFilterReply() : Boolean {
return when(column_type) {
TYPE_HOME, TYPE_PROFILE, TYPE_LIST_TL -> true
TYPE_HOME, TYPE_PROFILE, TYPE_LIST_TL, TYPE_NOTIFICATIONS -> true
else -> false
}
}

View File

@ -103,6 +103,7 @@ class ColumnViewHolder(
private val cbDontStreaming : CheckBox
private val cbDontAutoRefresh : CheckBox
private val cbHideMediaDefault : CheckBox
private val cbSystemNotificationNotRelated : CheckBox
private val cbEnableSpeech : CheckBox
private val llRegexFilter : View
private val btnDeleteNotification : Button
@ -232,6 +233,7 @@ class ColumnViewHolder(
cbDontStreaming = viewRoot.findViewById(R.id.cbDontStreaming)
cbDontAutoRefresh = viewRoot.findViewById(R.id.cbDontAutoRefresh)
cbHideMediaDefault = viewRoot.findViewById(R.id.cbHideMediaDefault)
cbSystemNotificationNotRelated = viewRoot.findViewById(R.id.cbSystemNotificationNotRelated)
cbEnableSpeech = viewRoot.findViewById(R.id.cbEnableSpeech)
etRegexFilter = viewRoot.findViewById(R.id.etRegexFilter)
llRegexFilter = viewRoot.findViewById(R.id.llRegexFilter)
@ -261,6 +263,7 @@ class ColumnViewHolder(
cbDontStreaming.setOnCheckedChangeListener(this)
cbDontAutoRefresh.setOnCheckedChangeListener(this)
cbHideMediaDefault.setOnCheckedChangeListener(this)
cbSystemNotificationNotRelated.setOnCheckedChangeListener(this)
cbEnableSpeech.setOnCheckedChangeListener(this)
// 入力の追跡
@ -428,6 +431,7 @@ class ColumnViewHolder(
cbDontStreaming.isChecked = column.dont_streaming
cbDontAutoRefresh.isChecked = column.dont_auto_refresh
cbHideMediaDefault.isChecked = column.hide_media_default
cbSystemNotificationNotRelated.isChecked = column.system_notification_not_related
cbEnableSpeech.isChecked = column.enable_speech
etRegexFilter.setText(column.regex_text)
@ -447,6 +451,7 @@ class ColumnViewHolder(
vg(cbDontStreaming, column.canStreaming())
vg(cbDontAutoRefresh, column.canAutoRefresh())
vg(cbHideMediaDefault, column.canNSFWDefault())
vg(cbSystemNotificationNotRelated,column.column_type == Column.TYPE_NOTIFICATIONS)
vg(cbEnableSpeech, column.canSpeech())
vg(btnDeleteNotification, column.column_type == Column.TYPE_NOTIFICATIONS)
@ -744,7 +749,11 @@ class ColumnViewHolder(
activity.app_state.saveColumnList()
column.fireShowContent(reason = "HideMediaDefault in ColumnSetting", reset = true)
}
R.id.cbSystemNotificationNotRelated -> {
column.system_notification_not_related = isChecked
activity.app_state.saveColumnList()
}
R.id.cbEnableSpeech -> {
column.enable_speech = isChecked
activity.app_state.saveColumnList()

View File

@ -369,11 +369,11 @@ internal class DlgContextMenu(
}
R.id.btnBoostedBy -> status?.let {
activity.addColumn(pos, access_info, Column.TYPE_BOOSTED_BY, it.id)
activity.addColumn(false,pos, access_info, Column.TYPE_BOOSTED_BY, it.id)
}
R.id.btnFavouritedBy -> status?.let {
activity.addColumn(pos, access_info, Column.TYPE_FAVOURITED_BY, it.id)
activity.addColumn(false,pos, access_info, Column.TYPE_FAVOURITED_BY, it.id)
}
R.id.btnFollow -> who?.let { who ->

View File

@ -890,7 +890,7 @@ internal class ItemViewHolder(
activity.addColumn(pos, access_info, Column.TYPE_LIST_TL, item.id)
}
.addAction(activity.getString(R.string.list_member)) {
activity.addColumn(pos, access_info, Column.TYPE_LIST_MEMBER, item.id)
activity.addColumn(false,pos, access_info, Column.TYPE_LIST_MEMBER, item.id)
}
.addAction(activity.getString(R.string.rename)){
Action_List.rename(activity, access_info, item)

View File

@ -282,6 +282,12 @@ object Pref {
R.id.swShareViewPool
)
val bpAllowColumnDuplication = BooleanPref(
"AllowColumnDuplication",
true,
R.id.swShareViewPool
)
// int
val ipBackButtonAction = IntPref("back_button_action", 0)

View File

@ -23,7 +23,7 @@ object Action_Instance {
fun information(
activity : ActMain, pos : Int, host : String
) {
activity.addColumn(pos, SavedAccount.na, Column.TYPE_INSTANCE_INFORMATION, host)
activity.addColumn(false,pos, SavedAccount.na, Column.TYPE_INSTANCE_INFORMATION, host)
}
// 指定タンスのローカルタイムラインを開く

View File

@ -19,7 +19,7 @@ import java.util.regex.Pattern
class TootApiClient(
internal val context : Context,
internal val httpClient : SimpleHttpClient = SimpleHttpClientImpl(App1.ok_http_client),
internal val httpClient : SimpleHttpClient = SimpleHttpClientImpl(context, App1.ok_http_client),
internal val callback : TootApiCallback
) {

View File

@ -1,6 +1,9 @@
package jp.juggler.subwaytooter.util
import android.content.Context
import okhttp3.*
import android.net.ConnectivityManager
import android.net.NetworkInfo
// okhttpそのままだとモックしづらいので
// リクエストを投げてレスポンスを得る部分をインタフェースにまとめる
@ -12,13 +15,33 @@ interface CurrentCallCallback {
interface SimpleHttpClient {
var currentCallCallback : CurrentCallCallback?
fun getResponse(request : Request) : Response
fun getWebSocket(request : Request, webSocketListener : WebSocketListener) : WebSocket
fun getWebSocket(
request : Request,
webSocketListener : WebSocketListener
) : WebSocket
}
class SimpleHttpClientImpl(private val okHttpClient : OkHttpClient) : SimpleHttpClient {
class SimpleHttpClientImpl(
context : Context,
private val okHttpClient : OkHttpClient
) : SimpleHttpClient {
companion object {
val log = LogCategory("SimpleHttpClientImpl")
var connectivityManager : ConnectivityManager? = null
}
init {
if(connectivityManager == null) {
connectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager
}
}
override var currentCallCallback : CurrentCallCallback? = null
override fun getResponse(request : Request) : Response {
checkNetworkState()
val call = okHttpClient.newCall(request)
currentCallCallback?.onCallCreated(call)
return call.execute()
@ -28,7 +51,33 @@ class SimpleHttpClientImpl(private val okHttpClient : OkHttpClient) : SimpleHttp
request : Request,
webSocketListener : WebSocketListener
) : WebSocket {
checkNetworkState()
return okHttpClient.newWebSocket(request, webSocketListener)
}
private fun checkNetworkState() {
val cm = connectivityManager
if(cm == null) {
log.d("missing ConnectivityManager")
} else {
val networkInfo = cm.activeNetworkInfo
?: throw RuntimeException("missing ActiveNetwork")
val state = networkInfo.state
val detailedState = networkInfo.detailedState
if(! networkInfo.isConnected) {
throw RuntimeException("network not ready. state=$state detail=$detailedState")
}
if(state == NetworkInfo.State.CONNECTED && detailedState == NetworkInfo.DetailedState.CONNECTED) {
// no logging
} else {
log.d("checkNetworkState state=$state detail=$detailedState")
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 350 B

After

Width:  |  Height:  |  Size: 372 B

View File

@ -207,6 +207,22 @@
<View style="@style/setting_divider"/>
<TextView
style="@style/setting_row_label"
android:text="@string/allow_column_duplication"
/>
<LinearLayout style="@style/setting_row_form">
<Switch
android:id="@+id/swAllowColumnDuplication"
style="@style/setting_horizontal_stretch"
/>
</LinearLayout>
<View style="@style/setting_divider"/>
<TextView
style="@style/setting_row_label"
android:text="@string/force_gap_when_refresh"

View File

@ -205,7 +205,12 @@
android:layout_height="wrap_content"
android:text="@string/hide_media_default"
/>
<CheckBox
android:id="@+id/cbSystemNotificationNotRelated"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/system_notification_not_related"
/>
<CheckBox
android:id="@+id/cbEnableSpeech"
android:layout_width="match_parent"

View File

@ -607,8 +607,14 @@
<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="allow_column_duplication">Allow column duplication</string>
<string name="system_notification_not_related">Not chosen when tapping system notification</string>
<string name="notification_type_mention">mention</string>
<string name="notification_type_follow">follow</string>
<string name="notification_type_boost">boost</string>
<string name="notification_type_favourite">fav.</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>-->

View File

@ -890,5 +890,11 @@
<string name="avatar_icon_dont_round">ユーザ画像を角丸にしない(アプリ再起動が必要)</string>
<string name="share_view_pool">カラム間でViewPoolを共有する</string>
<string name="rename">名前の変更…</string>
<string name="allow_column_duplication">カラムの重複を許容する</string>
<string name="system_notification_not_related">システム通知をタップした時に選ばれない</string>
<string name="notification_type_mention">返信</string>
<string name="notification_type_follow">フォロー</string>
<string name="notification_type_boost">ブースト</string>
<string name="notification_type_favourite">お気に入り</string>
</resources>

View File

@ -596,4 +596,10 @@
<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="allow_column_duplication">Allow column duplication</string>
<string name="system_notification_not_related">Not chosen when tapping system notification</string>
<string name="notification_type_mention">mention</string>
<string name="notification_type_follow">follow</string>
<string name="notification_type_boost">boost</string>
<string name="notification_type_favourite">fav.</string>
</resources>

View File

@ -111,7 +111,7 @@ my $res_dir = "app/src/main/res";
#resize_scales( "_ArtWork/ic_list_tl_dark.png" ,$res_dir,"drawable","ic_list_tl_dark",0,32);
#resize_scales( "_ArtWork/ic_list_member_dark.png" ,$res_dir,"drawable","ic_list_member_dark",0,32);
#resize_scales( "_ArtWork/media_bg_dark.png" ,$res_dir,"drawable","media_bg_dark",0,24);
resize_scales( "_ArtWork/media_bg_dark.png" ,$res_dir,"drawable","media_bg_dark",0,24);
resize_scales( "_ArtWork/v0.5.1/ic_launcher_foreground.png" ,$res_dir,"mipmap","ic_launcher_foreground",0,108);
resize_scales( "_ArtWork/v0.5.1/ic_launcher_background.png" ,$res_dir,"mipmap","ic_launcher_background",0,108);
#resize_scales( "_ArtWork/v0.5.1/ic_launcher_foreground.png" ,$res_dir,"mipmap","ic_launcher_foreground",0,108);
#resize_scales( "_ArtWork/v0.5.1/ic_launcher_background.png" ,$res_dir,"mipmap","ic_launcher_background",0,108);