mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-31 02:54:57 +01:00
アプリ設定/色/ステータスバーの色を追加
This commit is contained in:
parent
cb8a8816bc
commit
a1ca016558
@ -110,7 +110,7 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
)
|
||||
|
||||
root?.scan {
|
||||
(it as? Switch)?.apply{
|
||||
(it as? Switch)?.apply {
|
||||
if(Build.VERSION.SDK_INT < 23) {
|
||||
// android 5
|
||||
thumbDrawable?.setTintList(thumbStates)
|
||||
@ -158,6 +158,8 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
internal const val COLOR_DIALOG_ID_EVENT_BG_FOLLOWREQUEST = 25
|
||||
|
||||
internal const val COLOR_DIALOG_ID_SWITCH_BUTTON = 26
|
||||
internal const val COLOR_DIALOG_ID_STATUS_BAR = 27
|
||||
internal const val COLOR_DIALOG_ID_NAVIGATION_BAR = 28
|
||||
|
||||
internal const val REQUEST_CODE_TIMELINE_FONT = 1
|
||||
internal const val REQUEST_CODE_TIMELINE_FONT_BOLD = 2
|
||||
@ -212,6 +214,8 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
private var event_bg_color_vote : Int = 0
|
||||
private var event_bg_color_follow_request : Int = 0
|
||||
private var switch_button_color = 0
|
||||
private var status_bar_color = 0
|
||||
private var navigation_bar_color = 0
|
||||
|
||||
private var color_column_header_bg : Int = 0
|
||||
private var color_column_header_fg : Int = 0
|
||||
@ -511,6 +515,11 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
, R.id.btnCustomShare3Reset
|
||||
, R.id.btnSwitchButtonColorEdit
|
||||
, R.id.btnSwitchButtonColorReset
|
||||
, R.id.btnStatusBarColorEdit
|
||||
, R.id.btnStatusBarColorReset
|
||||
, R.id.btnNavigationBarColorEdit
|
||||
, R.id.btnNavigationBarColorReset
|
||||
|
||||
).forEach {
|
||||
findViewById<View>(it)?.setOnClickListener(this)
|
||||
}
|
||||
@ -697,6 +706,8 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
event_bg_color_vote = Pref.ipEventBgColorVote(pref)
|
||||
event_bg_color_follow_request = Pref.ipEventBgColorFollowRequest(pref)
|
||||
switch_button_color = Pref.ipSwitchOnColor(pref)
|
||||
status_bar_color = Pref.ipStatusBarColor(pref)
|
||||
navigation_bar_color = Pref.ipNavigationBarColor(pref)
|
||||
|
||||
color_column_header_bg = Pref.ipCcdHeaderBg(pref)
|
||||
color_column_header_fg = Pref.ipCcdHeaderFg(pref)
|
||||
@ -873,6 +884,8 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
put(Pref.ipEventBgColorVote, event_bg_color_vote)
|
||||
put(Pref.ipEventBgColorFollowRequest, event_bg_color_follow_request)
|
||||
put(Pref.ipSwitchOnColor, switch_button_color)
|
||||
put(Pref.ipStatusBarColor, status_bar_color)
|
||||
put(Pref.ipNavigationBarColor, navigation_bar_color)
|
||||
}
|
||||
|
||||
|
||||
@ -1275,6 +1288,31 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
|
||||
}
|
||||
|
||||
R.id.btnStatusBarColorEdit -> openColorPicker(
|
||||
COLOR_DIALOG_ID_STATUS_BAR,
|
||||
status_bar_color,
|
||||
false
|
||||
)
|
||||
|
||||
R.id.btnStatusBarColorReset -> {
|
||||
status_bar_color = Pref.ipStatusBarColor.defVal
|
||||
saveUIToData()
|
||||
App1.setStatusBarColor(this)
|
||||
|
||||
}
|
||||
|
||||
R.id.btnNavigationBarColorEdit -> openColorPicker(
|
||||
COLOR_DIALOG_ID_NAVIGATION_BAR,
|
||||
navigation_bar_color,
|
||||
false
|
||||
)
|
||||
|
||||
R.id.btnNavigationBarColorReset -> {
|
||||
navigation_bar_color = Pref.ipNavigationBarColor.defVal
|
||||
saveUIToData()
|
||||
App1.setStatusBarColor(this)
|
||||
}
|
||||
|
||||
R.id.btnTranslateAppComponentEdit -> openCustomShareChooser(CustomShareTarget.Translate)
|
||||
R.id.btnCustomShare1Edit -> openCustomShareChooser(CustomShareTarget.CustomShare1)
|
||||
R.id.btnCustomShare2Edit -> openCustomShareChooser(CustomShareTarget.CustomShare2)
|
||||
@ -1468,6 +1506,18 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
saveUIToData()
|
||||
setSwitchColor(this, pref, svContent)
|
||||
}
|
||||
|
||||
COLOR_DIALOG_ID_STATUS_BAR -> {
|
||||
status_bar_color = colorOpaque
|
||||
saveUIToData()
|
||||
App1.setStatusBarColor(this)
|
||||
}
|
||||
|
||||
COLOR_DIALOG_ID_NAVIGATION_BAR -> {
|
||||
navigation_bar_color = colorOpaque
|
||||
saveUIToData()
|
||||
App1.setStatusBarColor(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1553,7 +1603,7 @@ class ActAppSettingChild : AppCompatActivity()
|
||||
if(src.isNotEmpty()) {
|
||||
val f = NumberFormat.getInstance(Locale.getDefault()).parse(src)?.toFloat()
|
||||
return when {
|
||||
f==null -> Float.NaN
|
||||
f == null -> Float.NaN
|
||||
f.isNaN() -> Float.NaN
|
||||
f < 0f -> 0f
|
||||
f > 999f -> 999f
|
||||
|
@ -412,8 +412,6 @@ class ActMain : AppCompatActivity()
|
||||
notification_tl_font_size_sp = validateFloat(Pref.fpNotificationTlFontSize(pref))
|
||||
header_text_size_sp = validateFloat(Pref.fpHeaderTextSize(pref))
|
||||
|
||||
|
||||
|
||||
initUI()
|
||||
|
||||
updateColumnStrip()
|
||||
|
@ -9,9 +9,11 @@ import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import android.view.WindowManager
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.GlideBuilder
|
||||
@ -492,6 +494,7 @@ class App1 : Application() {
|
||||
}
|
||||
)
|
||||
|
||||
setStatusBarColor(activity)
|
||||
}
|
||||
|
||||
internal val CACHE_CONTROL = CacheControl.Builder()
|
||||
@ -639,5 +642,20 @@ class App1 : Application() {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
fun setStatusBarColor(activity : Activity) {
|
||||
|
||||
activity.window?.apply{
|
||||
var c = Pref.ipStatusBarColor(pref).notZero() ?: getAttributeColor(activity,R.attr.colorPrimaryDark)
|
||||
clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
||||
addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
|
||||
statusBarColor = c or Color.BLACK
|
||||
|
||||
c = Pref.ipNavigationBarColor(pref)
|
||||
if(c!=0){
|
||||
navigationBarColor = c or Color.BLACK
|
||||
} // else: need restart app.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -476,6 +476,9 @@ object Pref {
|
||||
|
||||
val ipSwitchOnColor = IntPref("SwitchOnColor", Color.BLACK or 0x0080ff)
|
||||
|
||||
val ipStatusBarColor = IntPref("StatusBarColor", 0)
|
||||
val ipNavigationBarColor = IntPref("NavigationBarColor", 0)
|
||||
|
||||
val ipTootColorUnlisted = IntPref("ipTootColorUnlisted", 0)
|
||||
val ipTootColorFollower = IntPref("ipTootColorFollower", 0)
|
||||
val ipTootColorDirectUser = IntPref("ipTootColorDirectUser", 0)
|
||||
|
@ -924,5 +924,60 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<View style="@style/setting_divider"/>
|
||||
|
||||
<TextView
|
||||
style="@style/setting_row_label"
|
||||
android:text="@string/status_bar_color"
|
||||
/>
|
||||
<LinearLayout style="@style/setting_row_form">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnStatusBarColorEdit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/edit"
|
||||
android:textAllCaps="false"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnStatusBarColorReset"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reset"
|
||||
android:textAllCaps="false"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<View style="@style/setting_divider"/>
|
||||
|
||||
<TextView
|
||||
style="@style/setting_row_label"
|
||||
android:text="@string/navigation_bar_color"
|
||||
/>
|
||||
<LinearLayout style="@style/setting_row_form">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnNavigationBarColorEdit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/edit"
|
||||
android:textAllCaps="false"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnNavigationBarColorReset"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reset"
|
||||
android:textAllCaps="false"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View style="@style/setting_divider"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
@ -936,5 +936,7 @@
|
||||
<string name="show_in_directory">ディレクトリに表示</string>
|
||||
<string name="featured_hashtags">注目のハッシュタグ</string>
|
||||
<string name="custom_emoji">カスタム絵文字</string>
|
||||
<string name="status_bar_color">ステータスバーの色(アプリ再起動が必要)</string>
|
||||
<string name="navigation_bar_color">ナビゲーションバーの色(アプリ再起動が必要)</string>
|
||||
|
||||
</resources>
|
||||
|
@ -929,5 +929,7 @@
|
||||
<string name="show_in_directory">Show in directory</string>
|
||||
<string name="featured_hashtags">Featured hashtags</string>
|
||||
<string name="custom_emoji">Custom emoji</string>
|
||||
<string name="status_bar_color">Status bar color (app restart required)</string>
|
||||
<string name="navigation_bar_color">Navigation bar color (app restart required)</string>
|
||||
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user