fixed tab on rtl locale

fixed edit text background
fixed status bar color in user fragment
This commit is contained in:
Mariotaku Lee 2015-05-20 01:54:56 +08:00
parent 0e4e7887fd
commit c45bcaa261
13 changed files with 161 additions and 51 deletions

View File

@ -96,7 +96,8 @@ dependencies {
compile 'com.bluelinelabs:logansquare:1.0.6'
compile 'ch.acra:acra:4.6.2'
compile 'com.github.boxme:AsyncManager:9391ed71d7@aar'
googleCompile 'com.google.android.gms:play-services-maps:7.0.0'
compile 'org.jraf:android-switch-backport:2.0.1'
googleCompile 'com.google.android.gms:play-services-maps:7.3.0'
googleCompile 'com.google.maps.android:android-maps-utils:0.3.4'
fdroidCompile 'org.osmdroid:osmdroid-android:4.3'
fdroidCompile 'org.slf4j:slf4j-simple:1.7.12'

View File

@ -836,7 +836,7 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
final boolean hasNoTab = mPagerAdapter.getCount() == 0;
mEmptyTabHint.setVisibility(hasNoTab ? View.VISIBLE : View.GONE);
mViewPager.setVisibility(hasNoTab ? View.GONE : View.VISIBLE);
mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() / 2);
// mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() / 2);
}
private void setupSlidingMenu() {

View File

@ -28,18 +28,18 @@ import android.view.ViewGroup;
public abstract class SupportFixedFragmentStatePagerAdapter extends FragmentStatePagerAdapter {
public SupportFixedFragmentStatePagerAdapter(final FragmentManager fm) {
super(fm);
}
public SupportFixedFragmentStatePagerAdapter(final FragmentManager fm) {
super(fm);
}
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final Fragment f = (Fragment) super.instantiateItem(container, position);
final Bundle savedFragmentState = f != null ? FragmentTrojan.getSavedFragmentState(f) : null;
if (savedFragmentState != null) {
savedFragmentState.setClassLoader(f.getClass().getClassLoader());
}
return f;
}
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
final Fragment f = (Fragment) super.instantiateItem(container, position);
final Bundle savedFragmentState = f != null ? FragmentTrojan.getSavedFragmentState(f) : null;
if (savedFragmentState != null) {
savedFragmentState.setClassLoader(f.getClass().getClassLoader());
}
return f;
}
}

View File

@ -1382,7 +1382,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final String backgroundOption = themed.getThemeBackgroundOption();
final int actionBarColor = ThemeUtils.getActionBarColor(activity, color, themeRes, backgroundOption);
if (mTintedStatusContent != null) {
mTintedStatusContent.setColor(actionBarColor, ThemeUtils.getActionBarAlpha(themed.getCurrentThemeBackgroundAlpha()));
final int alpha = ThemeUtils.isTransparentBackground(backgroundOption) ? themed.getCurrentThemeBackgroundAlpha() : 0xFF;
mTintedStatusContent.setColor(actionBarColor, ThemeUtils.getActionBarAlpha(alpha));
}
if (mActionBarBackground != null) {
mActionBarBackground.setColor(actionBarColor);

View File

@ -0,0 +1,57 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.preference;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.AttributeSet;
import android.view.View;
import org.jraf.android.backport.switchwidget.SwitchPreference;
public class AutoFixSwitchPreference extends SwitchPreference {
private View mCachedView;
public AutoFixSwitchPreference(final Context context) {
super(context);
}
public AutoFixSwitchPreference(final Context context, final AttributeSet attrs) {
super(context, attrs);
}
public AutoFixSwitchPreference(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void onSetInitialValue(final boolean restoreValue, final Object defaultValue) {
try {
super.onSetInitialValue(restoreValue, defaultValue);
} catch (final ClassCastException e) {
final SharedPreferences prefs = getSharedPreferences();
if (prefs != null) {
prefs.edit().remove(getKey()).apply();
}
}
}
}

View File

@ -85,7 +85,6 @@ public class ThemeUtils implements Constants {
private static final int[] ANIM_CLOSE_STYLE_ATTRS = {android.R.attr.activityCloseEnterAnimation,
android.R.attr.activityCloseExitAnimation};
public static final int[] ATTRS_TEXT_COLOR_PRIMARY = {android.R.attr.textColorPrimary};
public static final int[] ATTRS_TEXT_COLOR_PRIMARY_INVERSE = {android.R.attr.textColorPrimaryInverse};
public static final int[] ATTRS_TEXT_COLOR_PRIMARY_AND_INVERSE = {android.R.attr.textColorPrimary,
android.R.attr.textColorPrimaryInverse};
public static final int[] ATTRS_COLOR_FOREGROUND_AND_INVERSE = {android.R.attr.colorForeground,
@ -642,7 +641,9 @@ public class ThemeUtils implements Constants {
}
public static int getActionBarAlpha(final int alpha) {
return MathUtils.clamp(ThemeBackgroundPreference.MIN_ALPHA + (ThemeBackgroundPreference.MAX_ALPHA - alpha) / 2,
final int normalizedAlpha = MathUtils.clamp(alpha, 0, 0xFF);
final int delta = (ThemeBackgroundPreference.MAX_ALPHA - normalizedAlpha);
return MathUtils.clamp(ThemeBackgroundPreference.MAX_ALPHA - delta / 2,
ThemeBackgroundPreference.MIN_ALPHA, ThemeBackgroundPreference.MAX_ALPHA);
}

View File

@ -50,6 +50,7 @@ import org.mariotaku.twidere.activity.iface.IThemedActivity;
import org.mariotaku.twidere.util.support.ViewSupport;
import org.mariotaku.twidere.view.ShapedImageView;
import org.mariotaku.twidere.view.TwidereToolbar;
import org.mariotaku.twidere.view.iface.ICustomTypefaceTextView;
import org.mariotaku.twidere.view.iface.IThemeAccentView;
import org.mariotaku.twidere.view.iface.IThemeBackgroundTintView;
@ -94,6 +95,7 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
}
}
if (!whiteListed) return null;
//noinspection TryWithIdenticalCatches
try {
Constructor<?> constructor = sConstructorCache.get(name);
if (constructor == null) {
@ -104,7 +106,13 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
}
return (View) constructor.newInstance(context, attrs);
} catch (ClassNotFoundException ignore) {
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
} catch (NoSuchMethodException e) {
throw new InflateException(e);
} catch (InvocationTargetException e) {
throw new InflateException(e);
} catch (InstantiationException e) {
throw new InflateException(e);
} catch (IllegalAccessException e) {
throw new InflateException(e);
}
return null;
@ -116,7 +124,7 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
final ShapedImageView shapedImageView = (ShapedImageView) view;
shapedImageView.setStyle(activity.getCurrentProfileImageStyle());
}
if (view instanceof TextView) {
if (view instanceof TextView && (!(view instanceof ICustomTypefaceTextView))) {
final String fontFamily = activity.getCurrentThemeFontFamily();
final TextView textView = (TextView) view;
final Typeface defTypeface = textView.getTypeface();
@ -130,7 +138,8 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
final boolean isColorTint;
// View context is not derived from ActionBar, apply color tint directly
final Resources resources = ((Activity) activity).getResources();
final boolean isActionBarContext = isActionBarContext(view.getContext(), getActionBarContext((Activity) activity));
final Context viewContext = view.getContext();
final boolean isActionBarContext = isActionBarContext(viewContext, getActionBarContext((Activity) activity));
final int themeResourceId = activity.getCurrentThemeResourceId();
final boolean isDarkTheme = ThemeUtils.isDarkTheme(themeResourceId);
final int backgroundColorApprox;
@ -156,12 +165,8 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
// View context is derived from ActionBar and it's light theme, so we use contrast color
final int actionBarColor = activity.getCurrentThemeColor();
final int actionBarTheme = ThemeUtils.getActionBarThemeResource(activity.getThemeResourceId(), actionBarColor);
final int[] darkLightColors = new int[2];
ThemeUtils.getDarkLightForegroundColors((Context) activity, actionBarTheme, darkLightColors);
accentColor = TwidereColorUtils.getContrastYIQ(actionBarColor, ThemeUtils.ACCENT_COLOR_THRESHOLD,
darkLightColors[0], darkLightColors[1]);
noTintColor = TwidereColorUtils.getContrastYIQ(accentColor, ThemeUtils.ACCENT_COLOR_THRESHOLD,
darkLightColors[0], darkLightColors[1]);
accentColor = ThemeUtils.getColorFromAttribute(viewContext,android.R.attr.colorForeground, 0);
noTintColor = ThemeUtils.getColorFromAttribute(viewContext,android.R.attr.colorBackground, 0);
backgroundTintColor = accentColor;
backgroundColorApprox = Color.WHITE;
isColorTint = false;
@ -177,7 +182,7 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
if (isAccentOptimal || !isColorTint) {
((IThemeAccentView) view).setAccentTintColor(ColorStateList.valueOf(accentColor));
} else {
final int defaultAccentColor = ThemeUtils.getColorFromAttribute(view.getContext(),
final int defaultAccentColor = ThemeUtils.getColorFromAttribute(viewContext,
R.attr.colorAccent, resources.getColor(R.color.branding_color));
((IThemeAccentView) view).setAccentTintColor(ColorStateList.valueOf(defaultAccentColor));
}
@ -191,7 +196,7 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory {
applyTintableBackgroundViewTint(tintable, accentColor, noTintColor, backgroundTintColor, isColorTint);
}
} else if (view instanceof TwidereToolbar) {
final Context context = view.getContext();
final Context context = viewContext;
if (context instanceof android.support.v7.internal.view.ContextThemeWrapper) {
((TwidereToolbar) view).setItemColor(ThemeUtils.getThemeForegroundColor(context,
((ContextThemeWrapper) context).getThemeResId()));

View File

@ -7,11 +7,12 @@ import android.util.AttributeSet;
import android.widget.TextView;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.view.iface.ICustomTypefaceTextView;
/**
* Created by mariotaku on 14/11/14.
*/
public class AssetFontTextView extends TextView {
public class AssetFontTextView extends TextView implements ICustomTypefaceTextView {
public AssetFontTextView(Context context) {
this(context, null);
}

View File

@ -57,6 +57,7 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator, C
public TabPagerIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
ViewCompat.setLayoutDirection(this, ViewCompat.LAYOUT_DIRECTION_LTR);
final Resources res = getResources();
mIndicatorAdapter = new TabPagerIndicatorAdapter(this);
mItemDecoration = new DividerItemDecoration(context, HORIZONTAL);

View File

@ -0,0 +1,26 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.view.iface;
/**
* Created by mariotaku on 15/5/18.
*/
public interface ICustomTypefaceTextView {
}

View File

@ -21,6 +21,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_light</item>
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Light.NoActionBar" parent="Theme.Compat.Base.Light.NoActionBar">
@ -37,6 +39,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_dark</item>
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Dark" parent="Theme.Compat.Base">
@ -53,6 +57,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_light</item>
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Light" parent="Theme.Compat.Base.Light">
@ -69,6 +75,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_dark</item>
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Dark.DialogWhenLarge.NoActionBar" parent="Theme.Compat.Base.DialogWhenLarge">
@ -85,6 +93,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_light</item>
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Light.DialogWhenLarge.NoActionBar" parent="Theme.Compat.Base.Light.DialogWhenLarge">
@ -101,6 +111,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_dark</item>
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Dark.Dialog" parent="Theme.Compat.Base.Dialog">
@ -117,6 +129,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_light</item>
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Light.Dialog" parent="Theme.Compat.Base.Light.Dialog">
@ -133,6 +147,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_dark</item>
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Dark.Compose" parent="Theme.Compat.Base.Dialog">
@ -160,6 +176,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_light</item>
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Light.Compose" parent="Theme.Compat.Base.Light.Dialog">
@ -187,6 +205,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_dark</item>
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Light.QuickSearchBar" parent="Theme.Twidere.Light.Dialog">
@ -227,6 +247,8 @@
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_light</item>
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
<item name="asb_switchPreferenceStyle">@style/asb_Preference.SwitchPreference</item>
</style>
<style name="Theme.Twidere.Drawer.Dark" parent="Theme.Twidere.Dark.NoActionBar">

View File

@ -9,7 +9,7 @@
<org.mariotaku.twidere.preference.CardPreviewPreference android:key="card_preview" />
</PreferenceCategory>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="true"
android:key="name_first"
android:order="22"
@ -19,9 +19,9 @@
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
</org.mariotaku.twidere.preference.AutoFixSwitchPreference>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="true"
android:key="display_profile_image"
android:order="23"
@ -29,7 +29,7 @@
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
</org.mariotaku.twidere.preference.AutoFixSwitchPreference>
<org.mariotaku.twidere.preference.SummaryListPreference
android:defaultValue="@string/default_profile_image_style"
android:entries="@array/entries_profile_image_style"
@ -42,7 +42,7 @@
android:value="true" />
</org.mariotaku.twidere.preference.SummaryListPreference>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="false"
android:key="media_preview"
android:order="25"
@ -50,7 +50,7 @@
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
</org.mariotaku.twidere.preference.AutoFixSwitchPreference>
<org.mariotaku.twidere.preference.SummaryListPreference
android:defaultValue="crop"
android:entries="@array/entries_media_preview_style"
@ -73,7 +73,7 @@
android:value="true" />
</org.mariotaku.twidere.preference.LinkHighlightPreference>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="false"
android:key="show_absolute_time"
android:order="30"
@ -82,8 +82,8 @@
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
</org.mariotaku.twidere.preference.AutoFixSwitchPreference>
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="true"
android:key="card_animation"
android:order="31"
@ -91,8 +91,8 @@
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
</org.mariotaku.twidere.preference.AutoFixSwitchPreference>
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="false"
android:key="compact_cards"
android:order="32"
@ -101,8 +101,8 @@
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
</org.mariotaku.twidere.preference.AutoFixSwitchPreference>
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="false"
android:key="hide_card_actions"
android:order="33"
@ -110,6 +110,6 @@
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
</org.mariotaku.twidere.preference.AutoFixSwitchPreference>
</PreferenceScreen>

View File

@ -29,26 +29,21 @@
</org.mariotaku.twidere.preference.SeekBarDialogPreference>
</PreferenceCategory>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="true"
android:key="unread_count"
android:title="@string/unread_count">
<extra
android:name="notify_change"
android:value="true" />
</org.mariotaku.twidere.preference.AutoFixCheckBoxPreference>
</org.mariotaku.twidere.preference.AutoFixSwitchPreference>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
<org.mariotaku.twidere.preference.AutoFixSwitchPreference
android:defaultValue="false"
android:key="leftside_compose_button"
android:summary="@string/leftside_compose_button_summary"
android:title="@string/leftside_compose_button" />
<!--<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference-->
<!--android:defaultValue="false"-->
<!--android:key="fast_scroll_thumb"-->
<!--android:title="@string/fast_scroll_thumb" />-->
<org.mariotaku.twidere.preference.SummaryListPreference
android:defaultValue="@string/default_tab_display_option"
android:entries="@array/entries_tab_display_option"