fixed fanfou status format
This commit is contained in:
parent
e81213f184
commit
26f16af5fc
|
@ -21,13 +21,13 @@
|
||||||
|
|
||||||
package org.mariotaku.microblog.library.fanfou.api;
|
package org.mariotaku.microblog.library.fanfou.api;
|
||||||
|
|
||||||
import org.mariotaku.restfu.annotation.method.GET;
|
|
||||||
import org.mariotaku.restfu.annotation.param.Query;
|
|
||||||
import org.mariotaku.microblog.library.MicroBlogException;
|
import org.mariotaku.microblog.library.MicroBlogException;
|
||||||
import org.mariotaku.microblog.library.twitter.model.Paging;
|
import org.mariotaku.microblog.library.twitter.model.Paging;
|
||||||
import org.mariotaku.microblog.library.twitter.model.ResponseList;
|
import org.mariotaku.microblog.library.twitter.model.ResponseList;
|
||||||
import org.mariotaku.microblog.library.twitter.model.Status;
|
import org.mariotaku.microblog.library.twitter.model.Status;
|
||||||
import org.mariotaku.microblog.library.twitter.model.User;
|
import org.mariotaku.microblog.library.twitter.model.User;
|
||||||
|
import org.mariotaku.restfu.annotation.method.GET;
|
||||||
|
import org.mariotaku.restfu.annotation.param.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mariotaku on 16/3/10.
|
* Created by mariotaku on 16/3/10.
|
||||||
|
|
|
@ -239,12 +239,6 @@ public class ThemeUtils implements Constants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getThemeBackgroundOption(final Context context) {
|
|
||||||
if (context == null) return VALUE_THEME_BACKGROUND_DEFAULT;
|
|
||||||
final SharedPreferencesWrapper pref = getSharedPreferencesWrapper(context);
|
|
||||||
return pref.getString(KEY_THEME_BACKGROUND, VALUE_THEME_BACKGROUND_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getThemeForegroundColor(final Context context) {
|
public static int getThemeForegroundColor(final Context context) {
|
||||||
return getThemeForegroundColor(context, 0);
|
return getThemeForegroundColor(context, 0);
|
||||||
}
|
}
|
||||||
|
@ -283,14 +277,6 @@ public class ThemeUtils implements Constants {
|
||||||
return pref.getInt(KEY_THEME_COLOR, def);
|
return pref.getInt(KEY_THEME_COLOR, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getUserThemeBackgroundAlpha(final Context context) {
|
|
||||||
if (context == null) return DEFAULT_THEME_BACKGROUND_ALPHA;
|
|
||||||
final SharedPreferencesWrapper pref = getSharedPreferencesWrapper(context);
|
|
||||||
return TwidereMathUtils.clamp(pref.getInt(KEY_THEME_BACKGROUND_ALPHA, DEFAULT_THEME_BACKGROUND_ALPHA),
|
|
||||||
ThemeBackgroundPreference.MIN_ALPHA, ThemeBackgroundPreference.MAX_ALPHA);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static int getActionBarAlpha(final int alpha) {
|
public static int getActionBarAlpha(final int alpha) {
|
||||||
final int normalizedAlpha = TwidereMathUtils.clamp(alpha, 0, 0xFF);
|
final int normalizedAlpha = TwidereMathUtils.clamp(alpha, 0, 0xFF);
|
||||||
final int delta = ThemeBackgroundPreference.MAX_ALPHA - normalizedAlpha;
|
final int delta = ThemeBackgroundPreference.MAX_ALPHA - normalizedAlpha;
|
||||||
|
@ -343,10 +329,6 @@ public class ThemeUtils implements Constants {
|
||||||
return VALUE_THEME_BACKGROUND_SOLID.equals(option);
|
return VALUE_THEME_BACKGROUND_SOLID.equals(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTransparentBackground(final Context context) {
|
|
||||||
return isTransparentBackground(getThemeBackgroundOption(context));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isTransparentBackground(final String option) {
|
public static boolean isTransparentBackground(final String option) {
|
||||||
return VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option);
|
return VALUE_THEME_BACKGROUND_TRANSPARENT.equals(option);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,11 @@ import org.mariotaku.kpreferences.get
|
||||||
import org.mariotaku.restfu.http.RestHttpClient
|
import org.mariotaku.restfu.http.RestHttpClient
|
||||||
import org.mariotaku.twidere.BuildConfig
|
import org.mariotaku.twidere.BuildConfig
|
||||||
import org.mariotaku.twidere.TwidereConstants.SHARED_PREFERENCES_NAME
|
import org.mariotaku.twidere.TwidereConstants.SHARED_PREFERENCES_NAME
|
||||||
import org.mariotaku.twidere.activity.iface.IControlBarActivity
|
|
||||||
import org.mariotaku.twidere.activity.iface.IBaseActivity
|
import org.mariotaku.twidere.activity.iface.IBaseActivity
|
||||||
|
import org.mariotaku.twidere.activity.iface.IControlBarActivity
|
||||||
import org.mariotaku.twidere.activity.iface.IThemedActivity
|
import org.mariotaku.twidere.activity.iface.IThemedActivity
|
||||||
|
import org.mariotaku.twidere.constant.themeBackgroundAlphaKey
|
||||||
|
import org.mariotaku.twidere.constant.themeBackgroundOptionKey
|
||||||
import org.mariotaku.twidere.constant.themeColorKey
|
import org.mariotaku.twidere.constant.themeColorKey
|
||||||
import org.mariotaku.twidere.constant.themeKey
|
import org.mariotaku.twidere.constant.themeKey
|
||||||
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCallback
|
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCallback
|
||||||
|
@ -102,6 +104,9 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
||||||
lateinit var restHttpClient: RestHttpClient
|
lateinit var restHttpClient: RestHttpClient
|
||||||
|
|
||||||
private val actionHelper = IBaseActivity.ActionHelper(this)
|
private val actionHelper = IBaseActivity.ActionHelper(this)
|
||||||
|
private val themePreferences by lazy {
|
||||||
|
getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
||||||
|
}
|
||||||
|
|
||||||
// Registered listeners
|
// Registered listeners
|
||||||
private val controlBarOffsetListeners = ArrayList<IControlBarActivity.ControlBarOffsetListener>()
|
private val controlBarOffsetListeners = ArrayList<IControlBarActivity.ControlBarOffsetListener>()
|
||||||
|
@ -115,7 +120,7 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
||||||
}
|
}
|
||||||
if (ThemeUtils.isTransparentBackground(themeBackgroundOption)) {
|
if (ThemeUtils.isTransparentBackground(themeBackgroundOption)) {
|
||||||
theme.colorToolbar = ColorUtils.setAlphaComponent(theme.colorToolbar,
|
theme.colorToolbar = ColorUtils.setAlphaComponent(theme.colorToolbar,
|
||||||
ThemeUtils.getActionBarAlpha(ThemeUtils.getUserThemeBackgroundAlpha(this)))
|
ThemeUtils.getActionBarAlpha(themePreferences[themeBackgroundAlphaKey]))
|
||||||
}
|
}
|
||||||
theme.statusBarColor = ChameleonUtils.darkenColor(theme.colorToolbar)
|
theme.statusBarColor = ChameleonUtils.darkenColor(theme.colorToolbar)
|
||||||
theme.lightStatusBarMode = LightStatusBarMode.AUTO
|
theme.lightStatusBarMode = LightStatusBarMode.AUTO
|
||||||
|
@ -272,11 +277,11 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity<BaseActivity>, IThe
|
||||||
}
|
}
|
||||||
|
|
||||||
override val themeBackgroundAlpha: Int
|
override val themeBackgroundAlpha: Int
|
||||||
get() = ThemeUtils.getUserThemeBackgroundAlpha(this)
|
get() = themePreferences[themeBackgroundAlphaKey]
|
||||||
|
|
||||||
|
|
||||||
override val themeBackgroundOption: String
|
override val themeBackgroundOption: String
|
||||||
get() = ThemeUtils.getThemeBackgroundOption(this)
|
get() = themePreferences[themeBackgroundOptionKey]
|
||||||
|
|
||||||
protected open val shouldApplyWindowBackground: Boolean
|
protected open val shouldApplyWindowBackground: Boolean
|
||||||
get() {
|
get() {
|
||||||
|
|
|
@ -778,7 +778,11 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
|
||||||
private fun setupBars() {
|
private fun setupBars() {
|
||||||
val backgroundOption = currentThemeBackgroundOption
|
val backgroundOption = currentThemeBackgroundOption
|
||||||
val isTransparent = ThemeUtils.isTransparentBackground(backgroundOption)
|
val isTransparent = ThemeUtils.isTransparentBackground(backgroundOption)
|
||||||
val actionBarAlpha = if (isTransparent) ThemeUtils.getActionBarAlpha(ThemeUtils.getUserThemeBackgroundAlpha(this)) else 0xFF
|
val actionBarAlpha = if (isTransparent) {
|
||||||
|
ThemeUtils.getActionBarAlpha(preferences[themeBackgroundAlphaKey])
|
||||||
|
} else {
|
||||||
|
0xFF
|
||||||
|
}
|
||||||
actionsButton.alpha = actionBarAlpha / 255f
|
actionsButton.alpha = actionBarAlpha / 255f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,11 @@ import com.soundcloud.android.crop.CropImageActivity
|
||||||
import org.mariotaku.kpreferences.get
|
import org.mariotaku.kpreferences.get
|
||||||
import org.mariotaku.twidere.R
|
import org.mariotaku.twidere.R
|
||||||
import org.mariotaku.twidere.TwidereConstants
|
import org.mariotaku.twidere.TwidereConstants
|
||||||
|
import org.mariotaku.twidere.TwidereConstants.SHARED_PREFERENCES_NAME
|
||||||
import org.mariotaku.twidere.activity.iface.IThemedActivity
|
import org.mariotaku.twidere.activity.iface.IThemedActivity
|
||||||
|
import org.mariotaku.twidere.constant.themeBackgroundAlphaKey
|
||||||
|
import org.mariotaku.twidere.constant.themeBackgroundOptionKey
|
||||||
import org.mariotaku.twidere.constant.themeKey
|
import org.mariotaku.twidere.constant.themeKey
|
||||||
import org.mariotaku.twidere.util.ThemeUtils
|
|
||||||
import org.mariotaku.twidere.util.theme.getCurrentThemeResource
|
import org.mariotaku.twidere.util.theme.getCurrentThemeResource
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +42,8 @@ class ImageCropperActivity : CropImageActivity(), IThemedActivity {
|
||||||
override val currentThemeBackgroundAlpha by lazy { themeBackgroundAlpha }
|
override val currentThemeBackgroundAlpha by lazy { themeBackgroundAlpha }
|
||||||
override val currentThemeBackgroundOption by lazy { themeBackgroundOption }
|
override val currentThemeBackgroundOption by lazy { themeBackgroundOption }
|
||||||
|
|
||||||
|
private val preferences by lazy { getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE) }
|
||||||
|
|
||||||
private var doneCancelBar: Toolbar? = null
|
private var doneCancelBar: Toolbar? = null
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -61,9 +65,9 @@ class ImageCropperActivity : CropImageActivity(), IThemedActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
override val themeBackgroundAlpha: Int
|
override val themeBackgroundAlpha: Int
|
||||||
get() = ThemeUtils.getUserThemeBackgroundAlpha(this)
|
get() = preferences[themeBackgroundAlphaKey]
|
||||||
|
|
||||||
override val themeBackgroundOption: String
|
override val themeBackgroundOption: String
|
||||||
get() = ThemeUtils.getThemeBackgroundOption(this)
|
get() = preferences[themeBackgroundOptionKey]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,8 @@ class TwidereApplication : Application(), Constants, OnSharedPreferenceChangeLis
|
||||||
listenExternalThemeChange()
|
listenExternalThemeChange()
|
||||||
|
|
||||||
loadDefaultFeatures()
|
loadDefaultFeatures()
|
||||||
|
|
||||||
|
Analyzer.preferencesChanged(sharedPreferences)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadDefaultFeatures() {
|
private fun loadDefaultFeatures() {
|
||||||
|
@ -267,6 +269,7 @@ class TwidereApplication : Application(), Constants, OnSharedPreferenceChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Analyzer.preferencesChanged(preferences)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTerminate() {
|
override fun onTerminate() {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.mariotaku.twidere.model.account.cred.Credentials
|
||||||
import org.mariotaku.twidere.model.sync.SyncProviderInfo
|
import org.mariotaku.twidere.model.sync.SyncProviderInfo
|
||||||
import org.mariotaku.twidere.preference.ThemeBackgroundPreference
|
import org.mariotaku.twidere.preference.ThemeBackgroundPreference
|
||||||
import org.mariotaku.twidere.util.sync.SyncProviderInfoFactory
|
import org.mariotaku.twidere.util.sync.SyncProviderInfoFactory
|
||||||
import org.mariotaku.twidere.view.ProfileImageView
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mariotaku on 16/8/25.
|
* Created by mariotaku on 16/8/25.
|
||||||
|
@ -73,6 +72,8 @@ val streamingEnabledKey = KBooleanKey("streaming_enabled", false)
|
||||||
val streamingNonMeteredNetworkKey = KBooleanKey("streaming_non_metered_network", true)
|
val streamingNonMeteredNetworkKey = KBooleanKey("streaming_non_metered_network", true)
|
||||||
val streamingPowerSavingKey = KBooleanKey("streaming_power_saving", true)
|
val streamingPowerSavingKey = KBooleanKey("streaming_power_saving", true)
|
||||||
|
|
||||||
|
val themeBackgroundOptionKey = KStringKey(KEY_THEME_BACKGROUND, VALUE_THEME_BACKGROUND_DEFAULT)
|
||||||
|
|
||||||
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 {
|
||||||
return preferences.getInt(KEY_THEME_BACKGROUND_ALPHA, DEFAULT_THEME_BACKGROUND_ALPHA)
|
return preferences.getInt(KEY_THEME_BACKGROUND_ALPHA, DEFAULT_THEME_BACKGROUND_ALPHA)
|
||||||
|
|
|
@ -127,6 +127,7 @@ fun <T> newMicroBlogInstance(context: Context, endpoint: Endpoint, auth: Authori
|
||||||
UserAgentExtraHeaders(MicroBlogAPIFactory.getTwidereUserAgent(context))
|
UserAgentExtraHeaders(MicroBlogAPIFactory.getTwidereUserAgent(context))
|
||||||
}
|
}
|
||||||
val holder = DependencyHolder.get(context)
|
val holder = DependencyHolder.get(context)
|
||||||
|
var extraRequestParams: Map<String, String>? = null
|
||||||
when (cls) {
|
when (cls) {
|
||||||
TwitterUpload::class.java -> {
|
TwitterUpload::class.java -> {
|
||||||
val conf = HttpClientFactory.HttpClientConfiguration(holder.preferences)
|
val conf = HttpClientFactory.HttpClientConfiguration(holder.preferences)
|
||||||
|
@ -158,11 +159,14 @@ fun <T> newMicroBlogInstance(context: Context, endpoint: Endpoint, auth: Authori
|
||||||
}
|
}
|
||||||
AccountType.FANFOU -> {
|
AccountType.FANFOU -> {
|
||||||
factory.setConstantPool(sFanfouConstantPool)
|
factory.setConstantPool(sFanfouConstantPool)
|
||||||
|
if (cls != FanfouStream::class.java) {
|
||||||
|
extraRequestParams = mapOf("format" to "html")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val converterFactory = TwitterConverterFactory()
|
val converterFactory = TwitterConverterFactory()
|
||||||
factory.setRestConverterFactory(converterFactory)
|
factory.setRestConverterFactory(converterFactory)
|
||||||
factory.setRestRequestFactory(MicroBlogAPIFactory.TwidereRestRequestFactory(null))
|
factory.setRestRequestFactory(MicroBlogAPIFactory.TwidereRestRequestFactory(extraRequestParams))
|
||||||
factory.setHttpRequestFactory(MicroBlogAPIFactory.TwidereHttpRequestFactory(extraHeaders))
|
factory.setHttpRequestFactory(MicroBlogAPIFactory.TwidereHttpRequestFactory(extraHeaders))
|
||||||
factory.setExceptionFactory(MicroBlogAPIFactory.TwidereExceptionFactory(converterFactory))
|
factory.setExceptionFactory(MicroBlogAPIFactory.TwidereExceptionFactory(converterFactory))
|
||||||
return factory.build<T>(cls)
|
return factory.build<T>(cls)
|
||||||
|
|
|
@ -1550,8 +1550,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
|
||||||
itemCounts[ITEM_IDX_REPLY_LOAD_MORE] = 1
|
itemCounts[ITEM_IDX_REPLY_LOAD_MORE] = 1
|
||||||
inflater = LayoutInflater.from(context)
|
inflater = LayoutInflater.from(context)
|
||||||
cardBackgroundColor = ThemeUtils.getCardBackgroundColor(context,
|
cardBackgroundColor = ThemeUtils.getCardBackgroundColor(context,
|
||||||
ThemeUtils.getThemeBackgroundOption(context),
|
preferences[themeBackgroundOptionKey], preferences[themeBackgroundAlphaKey])
|
||||||
ThemeUtils.getUserThemeBackgroundAlpha(context))
|
|
||||||
val listener = StatusAdapterLinkClickHandler<List<ParcelableStatus>>(context, preferences)
|
val listener = StatusAdapterLinkClickHandler<List<ParcelableStatus>>(context, preferences)
|
||||||
listener.setAdapter(this)
|
listener.setAdapter(this)
|
||||||
twidereLinkify = TwidereLinkify(listener)
|
twidereLinkify = TwidereLinkify(listener)
|
||||||
|
|
|
@ -100,11 +100,8 @@ import org.mariotaku.twidere.activity.iface.IBaseActivity
|
||||||
import org.mariotaku.twidere.adapter.SupportTabsAdapter
|
import org.mariotaku.twidere.adapter.SupportTabsAdapter
|
||||||
import org.mariotaku.twidere.annotation.AccountType
|
import org.mariotaku.twidere.annotation.AccountType
|
||||||
import org.mariotaku.twidere.annotation.Referral
|
import org.mariotaku.twidere.annotation.Referral
|
||||||
|
import org.mariotaku.twidere.constant.*
|
||||||
import org.mariotaku.twidere.constant.KeyboardShortcutConstants.*
|
import org.mariotaku.twidere.constant.KeyboardShortcutConstants.*
|
||||||
import org.mariotaku.twidere.constant.displaySensitiveContentsKey
|
|
||||||
import org.mariotaku.twidere.constant.lightFontKey
|
|
||||||
import org.mariotaku.twidere.constant.newDocumentApiKey
|
|
||||||
import org.mariotaku.twidere.constant.profileImageStyleKey
|
|
||||||
import org.mariotaku.twidere.extension.applyTheme
|
import org.mariotaku.twidere.extension.applyTheme
|
||||||
import org.mariotaku.twidere.extension.loadOriginalProfileImage
|
import org.mariotaku.twidere.extension.loadOriginalProfileImage
|
||||||
import org.mariotaku.twidere.extension.loadProfileBanner
|
import org.mariotaku.twidere.extension.loadProfileBanner
|
||||||
|
@ -673,8 +670,7 @@ class UserFragment : BaseFragment(), OnClickListener, OnLinkClickListener,
|
||||||
userColorNameManager.registerNicknameChangedListener(this)
|
userColorNameManager.registerNicknameChangedListener(this)
|
||||||
nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
|
nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
|
||||||
cardBackgroundColor = ThemeUtils.getCardBackgroundColor(activity,
|
cardBackgroundColor = ThemeUtils.getCardBackgroundColor(activity,
|
||||||
ThemeUtils.getThemeBackgroundOption(activity),
|
preferences[themeBackgroundOptionKey], preferences[themeBackgroundAlphaKey])
|
||||||
ThemeUtils.getUserThemeBackgroundAlpha(activity))
|
|
||||||
actionBarShadowColor = 0xA0000000.toInt()
|
actionBarShadowColor = 0xA0000000.toInt()
|
||||||
val args = arguments
|
val args = arguments
|
||||||
val accountId: UserKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
val accountId: UserKey = args.getParcelable<UserKey>(EXTRA_ACCOUNT_KEY)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.mariotaku.twidere.util
|
package org.mariotaku.twidere.util
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
import org.mariotaku.twidere.annotation.AccountType
|
import org.mariotaku.twidere.annotation.AccountType
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,6 +36,8 @@ abstract class Analyzer {
|
||||||
|
|
||||||
protected abstract fun init(application: Application)
|
protected abstract fun init(application: Application)
|
||||||
|
|
||||||
|
protected abstract fun preferencesChanged(preferences: SharedPreferences)
|
||||||
|
|
||||||
interface Event {
|
interface Event {
|
||||||
val name: String
|
val name: String
|
||||||
get() = "Custom Event"
|
get() = "Custom Event"
|
||||||
|
@ -66,5 +69,9 @@ abstract class Analyzer {
|
||||||
fun logException(throwable: Throwable) {
|
fun logException(throwable: Throwable) {
|
||||||
implementation?.logException(throwable)
|
implementation?.logException(throwable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun preferencesChanged(preferences: SharedPreferences) {
|
||||||
|
implementation?.preferencesChanged(preferences)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue