close #704
This commit is contained in:
parent
b84db81c40
commit
213be5fa25
|
@ -24,6 +24,7 @@ import android.app.PendingIntent
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.nfc.NfcAdapter
|
import android.nfc.NfcAdapter
|
||||||
|
@ -188,7 +189,7 @@ open class BaseActivity : ChameleonActivity(), IExtendedActivity<BaseActivity>,
|
||||||
StrictModeUtils.detectAllThreadPolicy()
|
StrictModeUtils.detectAllThreadPolicy()
|
||||||
}
|
}
|
||||||
val prefs = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
val prefs = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||||
val themeResource = getThemeResource(prefs[themeKey], prefs[themeColorKey])
|
val themeResource = getThemeResource(prefs, prefs[themeKey], prefs[themeColorKey])
|
||||||
if (themeResource != 0) {
|
if (themeResource != 0) {
|
||||||
setTheme(themeResource)
|
setTheme(themeResource)
|
||||||
}
|
}
|
||||||
|
@ -373,7 +374,7 @@ open class BaseActivity : ChameleonActivity(), IExtendedActivity<BaseActivity>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@StyleRes
|
@StyleRes
|
||||||
protected open fun getThemeResource(theme: String, themeColor: Int): Int {
|
protected open fun getThemeResource(preferences: SharedPreferences, theme: String, themeColor: Int): Int {
|
||||||
return getCurrentThemeResource(this, theme)
|
return getCurrentThemeResource(this, theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.mariotaku.twidere.activity
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.BadParcelableException
|
import android.os.BadParcelableException
|
||||||
|
@ -33,6 +34,7 @@ import android.support.v7.widget.Toolbar
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.View
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
import kotlinx.android.synthetic.main.activity_link_handler.*
|
import kotlinx.android.synthetic.main.activity_link_handler.*
|
||||||
import org.mariotaku.kpreferences.get
|
import org.mariotaku.kpreferences.get
|
||||||
|
@ -60,6 +62,7 @@ import org.mariotaku.twidere.util.*
|
||||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback
|
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback
|
||||||
import org.mariotaku.twidere.util.Utils.LINK_ID_FILTERS_IMPORT_BLOCKS
|
import org.mariotaku.twidere.util.Utils.LINK_ID_FILTERS_IMPORT_BLOCKS
|
||||||
import org.mariotaku.twidere.util.linkhandler.TwidereLinkMatcher
|
import org.mariotaku.twidere.util.linkhandler.TwidereLinkMatcher
|
||||||
|
import org.mariotaku.twidere.util.theme.getCurrentThemeResource
|
||||||
|
|
||||||
class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IControlBarActivity,
|
class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IControlBarActivity,
|
||||||
SupportFragmentCallback {
|
SupportFragmentCallback {
|
||||||
|
@ -116,7 +119,14 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
||||||
} else {
|
} else {
|
||||||
setContentView(R.layout.activity_link_handler)
|
setContentView(R.layout.activity_link_handler)
|
||||||
toolbar?.let { toolbar ->
|
toolbar?.let { toolbar ->
|
||||||
setSupportActionBar(toolbar)
|
if (supportActionBar != null) {
|
||||||
|
toolbar.visibility = View.GONE
|
||||||
|
windowOverlay?.visibility = View.GONE
|
||||||
|
} else {
|
||||||
|
toolbar.visibility = View.VISIBLE
|
||||||
|
windowOverlay?.visibility = View.VISIBLE
|
||||||
|
setSupportActionBar(toolbar)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
contentFragmentId = R.id.contentFragment
|
contentFragmentId = R.id.contentFragment
|
||||||
}
|
}
|
||||||
|
@ -127,7 +137,7 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
||||||
ft.replace(contentFragmentId, fragment, "content_fragment")
|
ft.replace(contentFragmentId, fragment, "content_fragment")
|
||||||
ft.commit()
|
ft.commit()
|
||||||
setTitle(linkId, uri)
|
setTitle(linkId, uri)
|
||||||
finishOnly = java.lang.Boolean.parseBoolean(uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY))
|
finishOnly = uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY)?.toBoolean() ?: false
|
||||||
|
|
||||||
if (fragment is IToolBarSupportFragment) {
|
if (fragment is IToolBarSupportFragment) {
|
||||||
ThemeUtils.setCompatContentViewOverlay(window, EmptyDrawable())
|
ThemeUtils.setCompatContentViewOverlay(window, EmptyDrawable())
|
||||||
|
@ -288,6 +298,13 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
||||||
return actionBarHeight
|
return actionBarHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getThemeResource(preferences: SharedPreferences, theme: String, themeColor: Int): Int {
|
||||||
|
if (preferences[floatingDetailedContentsKey]) {
|
||||||
|
return super.getThemeResource(preferences, theme, themeColor)
|
||||||
|
}
|
||||||
|
return getCurrentThemeResource(this, theme, R.style.Theme_Twidere)
|
||||||
|
}
|
||||||
|
|
||||||
private fun setTitle(linkId: Int, uri: Uri): Boolean {
|
private fun setTitle(linkId: Int, uri: Uri): Boolean {
|
||||||
setSubtitle(null)
|
setSubtitle(null)
|
||||||
when (linkId) {
|
when (linkId) {
|
||||||
|
|
|
@ -64,6 +64,7 @@ val extraFeaturesNoticeVersionKey = KIntKey("extra_features_notice_version", 0)
|
||||||
val mediaPreloadKey = KBooleanKey(KEY_MEDIA_PRELOAD, false)
|
val mediaPreloadKey = KBooleanKey(KEY_MEDIA_PRELOAD, false)
|
||||||
val mediaPreloadOnWifiOnlyKey = KBooleanKey(KEY_PRELOAD_WIFI_ONLY, true)
|
val mediaPreloadOnWifiOnlyKey = KBooleanKey(KEY_PRELOAD_WIFI_ONLY, true)
|
||||||
val autoRefreshCompatibilityModeKey = KBooleanKey("auto_refresh_compatibility_mode", Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
val autoRefreshCompatibilityModeKey = KBooleanKey("auto_refresh_compatibility_mode", Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
val floatingDetailedContentsKey = KBooleanKey("floating_detailed_contents", true)
|
||||||
|
|
||||||
object themeBackgroundAlphaKey : KSimpleKey<Int>(KEY_THEME_BACKGROUND_ALPHA, 0xFF) {
|
object themeBackgroundAlphaKey : KSimpleKey<Int>(KEY_THEME_BACKGROUND_ALPHA, 0xFF) {
|
||||||
override fun read(preferences: SharedPreferences): Int {
|
override fun read(preferences: SharedPreferences): Int {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.mariotaku.twidere.util.theme
|
package org.mariotaku.twidere.util.theme
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.TypedArray
|
||||||
import org.mariotaku.twidere.R
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.VALUE_THEME_NAME_AUTO
|
import org.mariotaku.twidere.constant.SharedPreferenceConstants.VALUE_THEME_NAME_AUTO
|
||||||
import org.mariotaku.twidere.constant.SharedPreferenceConstants.VALUE_THEME_NAME_DARK
|
import org.mariotaku.twidere.constant.SharedPreferenceConstants.VALUE_THEME_NAME_DARK
|
||||||
|
@ -10,8 +11,13 @@ import org.mariotaku.twidere.util.ThemeUtils
|
||||||
* Created by mariotaku on 2017/1/7.
|
* Created by mariotaku on 2017/1/7.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun getCurrentThemeResource(context: Context, theme: String): Int {
|
fun getCurrentThemeResource(context: Context, theme: String, fromThemeResource: Int = 0): Int {
|
||||||
val a = context.obtainStyledAttributes(R.styleable.TwidereTheme)
|
val a: TypedArray
|
||||||
|
if (fromThemeResource == 0) {
|
||||||
|
a = context.obtainStyledAttributes(R.styleable.TwidereTheme)
|
||||||
|
} else {
|
||||||
|
a = context.obtainStyledAttributes(fromThemeResource, R.styleable.TwidereTheme)
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
val lightTheme = a.getResourceId(R.styleable.TwidereTheme_lightThemeResource, 0)
|
val lightTheme = a.getResourceId(R.styleable.TwidereTheme_lightThemeResource, 0)
|
||||||
val darkTheme = a.getResourceId(R.styleable.TwidereTheme_darkThemeResource, 0)
|
val darkTheme = a.getResourceId(R.styleable.TwidereTheme_darkThemeResource, 0)
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
<string name="action_deleting">deleting</string>
|
<string name="action_deleting">deleting</string>
|
||||||
<string name="action_deleting_search">deleting search</string>
|
<string name="action_deleting_search">deleting search</string>
|
||||||
<string name="action_denying_follow_request">denying follow request</string>
|
<string name="action_denying_follow_request">denying follow request</string>
|
||||||
|
<string name="action_dont_restart">Don\'t restart</string>
|
||||||
|
<string name="action_dont_terminate">Don\'t quit</string>
|
||||||
<!-- [verb] Edit image/settings etc. -->
|
<!-- [verb] Edit image/settings etc. -->
|
||||||
<string name="action_edit">Edit</string>
|
<string name="action_edit">Edit</string>
|
||||||
<string name="action_edit_filter_rule">Edit rule</string>
|
<string name="action_edit_filter_rule">Edit rule</string>
|
||||||
|
@ -392,9 +394,6 @@
|
||||||
<string name="dns_server">DNS Server</string>
|
<string name="dns_server">DNS Server</string>
|
||||||
<string name="dns_server_summary">Set DNS Server for network requests.</string>
|
<string name="dns_server_summary">Set DNS Server for network requests.</string>
|
||||||
|
|
||||||
<string name="action_dont_restart">Don\'t restart</string>
|
|
||||||
<string name="action_dont_terminate">Don\'t quit</string>
|
|
||||||
|
|
||||||
<string name="draft_saved">Draft saved</string>
|
<string name="draft_saved">Draft saved</string>
|
||||||
|
|
||||||
<string name="drafts_hint_messages">Your unsent tweets will save here</string>
|
<string name="drafts_hint_messages">Your unsent tweets will save here</string>
|
||||||
|
@ -883,6 +882,7 @@
|
||||||
<string name="preference_title_database_item_limit">Database size limit</string>
|
<string name="preference_title_database_item_limit">Database size limit</string>
|
||||||
<string name="preference_title_filter_manage_subscriptions">Manage</string>
|
<string name="preference_title_filter_manage_subscriptions">Manage</string>
|
||||||
<string name="preference_title_filter_subscriptions">Filter subscriptions</string>
|
<string name="preference_title_filter_subscriptions">Filter subscriptions</string>
|
||||||
|
<string name="preference_title_floating_detailed_view">Floating detailed view</string>
|
||||||
<string name="preference_title_landscape">Landscape</string>
|
<string name="preference_title_landscape">Landscape</string>
|
||||||
<string name="preference_title_light_font">Light font</string>
|
<string name="preference_title_light_font">Light font</string>
|
||||||
<string name="preference_title_media_preload_non_metered_network">Preload on free network</string>
|
<string name="preference_title_media_preload_non_metered_network">Preload on free network</string>
|
||||||
|
|
|
@ -23,4 +23,8 @@
|
||||||
android:value="true"/>
|
android:value="true"/>
|
||||||
</SwitchPreferenceCompat>
|
</SwitchPreferenceCompat>
|
||||||
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
|
</org.mariotaku.twidere.preference.TintedPreferenceCategory>
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="floating_detailed_contents"
|
||||||
|
android:title="@string/preference_title_floating_detailed_view"/>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue