font family option will work
This commit is contained in:
parent
bb3ac5e287
commit
f9e45f968f
|
@ -22,9 +22,11 @@ package android.support.v7.app;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.LayoutInflaterCompat;
|
||||
import android.support.v4.view.LayoutInflaterFactory;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.InflateException;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
@ -33,6 +35,11 @@ import org.mariotaku.twidere.Constants;
|
|||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/22.
|
||||
*/
|
||||
|
@ -56,6 +63,7 @@ public class ThemedAppCompatDelegate implements Constants {
|
|||
private static class ThemedAppCompatDelegateImplV11 extends AppCompatDelegateImplV11 {
|
||||
|
||||
private final IThemedActivity themed;
|
||||
private static final Map<String, Constructor> sConstructorCache = new HashMap<>();
|
||||
|
||||
private ThemedAppCompatDelegateImplV11(IThemedActivity themed, Context context, Window window, AppCompatCallback callback) {
|
||||
super(context, window, callback);
|
||||
|
@ -69,6 +77,26 @@ public class ThemedAppCompatDelegate implements Constants {
|
|||
LayoutInflaterCompat.setFactory(inflater, new ThemedLayoutInflaterFactory(themed, this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(View parent, String name, @NonNull Context context, @NonNull AttributeSet attrs) {
|
||||
View view = super.createView(parent, name, context, attrs);
|
||||
if (view == null && name.contains(".")) {
|
||||
try {
|
||||
Constructor<?> constructor = sConstructorCache.get(name);
|
||||
if (constructor == null) {
|
||||
final Class<?> viewCls = Class.forName(name);
|
||||
constructor = viewCls.getConstructor(Context.class, AttributeSet.class);
|
||||
sConstructorCache.put(name, constructor);
|
||||
}
|
||||
view = (View) constructor.newInstance(context, attrs);
|
||||
} catch (ClassNotFoundException ignore) {
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
throw new InflateException(e);
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +115,7 @@ public class ThemedAppCompatDelegate implements Constants {
|
|||
@Override
|
||||
public View onCreateView(View view, String s, Context context, AttributeSet attributeSet) {
|
||||
final View createdView = delegate.onCreateView(view, s, context, attributeSet);
|
||||
ThemeUtils.initView(createdView, activity.getCurrentThemeColor(), activity.getCurrentProfileImageStyle());
|
||||
ThemeUtils.initView(createdView, activity);
|
||||
return createdView;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.mariotaku.twidere.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.LayoutRes;
|
||||
|
@ -32,7 +31,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -42,6 +41,8 @@ import android.widget.FrameLayout;
|
|||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
|
@ -50,7 +51,7 @@ import org.mariotaku.twidere.view.ShapedImageView.ShapeStyle;
|
|||
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
|
||||
|
||||
public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity implements Constants,
|
||||
IThemedActivity {
|
||||
IThemedActivity, KeyboardShortcutsHandler.KeyboardShortcutCallback {
|
||||
|
||||
private TintedStatusFrameLayout mMainContent;
|
||||
|
||||
|
@ -58,6 +59,13 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
|
|||
@ShapeStyle
|
||||
private int mProfileImageStyle;
|
||||
private String mCurrentThemeBackgroundOption;
|
||||
private KeyboardShortcutsHandler mKeyboardShortcutsHandler;
|
||||
private String mCurrentThemeFontFamily;
|
||||
|
||||
@Override
|
||||
public String getCurrentThemeFontFamily() {
|
||||
return mCurrentThemeFontFamily;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentThemeBackgroundAlpha() {
|
||||
|
@ -95,6 +103,7 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
@ShapeStyle
|
||||
public int getCurrentProfileImageStyle() {
|
||||
return mProfileImageStyle;
|
||||
}
|
||||
|
@ -118,6 +127,16 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
|
|||
getCurrentThemeColor(), getThemeBackgroundOption(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutRepeat(@NonNull KeyboardShortcutsHandler handler, int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
if (Utils.isDebugBuild()) {
|
||||
|
@ -128,6 +147,20 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
|
|||
setupWindow();
|
||||
super.onCreate(savedInstanceState);
|
||||
setupActionBar();
|
||||
mKeyboardShortcutsHandler = TwidereApplication.getInstance(this).getKeyboardShortcutsHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
|
||||
if (handleKeyboardShortcutSingle(mKeyboardShortcutsHandler, keyCode, event)) return true;
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
|
||||
if (handleKeyboardShortcutRepeat(mKeyboardShortcutsHandler, keyCode, event.getRepeatCount(), event))
|
||||
return true;
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -208,13 +241,6 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(String name, @NonNull Context context, @NonNull AttributeSet attrs) {
|
||||
final View view = super.onCreateView(name, context, attrs);
|
||||
ThemeUtils.initView(view, getCurrentThemeColor(), mProfileImageStyle);
|
||||
return view;
|
||||
}
|
||||
|
||||
protected boolean shouldSetActionItemColor() {
|
||||
return true;
|
||||
}
|
||||
|
@ -235,6 +261,7 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
|
|||
mCurrentThemeBackgroundAlpha = getThemeBackgroundAlpha();
|
||||
mProfileImageStyle = Utils.getProfileImageStyle(this);
|
||||
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
|
||||
mCurrentThemeFontFamily = getThemeFontFamily();
|
||||
setTheme(mCurrentThemeResource);
|
||||
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource, mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.mariotaku.twidere.util.CompareUtils;
|
|||
import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.view.ShapedImageView;
|
||||
|
||||
public abstract class BaseThemedActivity extends Activity implements IThemedActivity {
|
||||
|
||||
|
@ -37,6 +38,11 @@ public abstract class BaseThemedActivity extends Activity implements IThemedActi
|
|||
private String mCurrentThemeBackgroundOption;
|
||||
private int mProfileImageStyle;
|
||||
|
||||
@Override
|
||||
public String getCurrentThemeFontFamily() {
|
||||
return mCurrentThemeFontFamily;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentThemeBackgroundAlpha() {
|
||||
return mCurrentThemeBackgroundAlpha;
|
||||
|
@ -74,6 +80,7 @@ public abstract class BaseThemedActivity extends Activity implements IThemedActi
|
|||
public abstract int getThemeResourceId();
|
||||
|
||||
@Override
|
||||
@ShapedImageView.ShapeStyle
|
||||
public int getCurrentProfileImageStyle() {
|
||||
return mProfileImageStyle;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v4.view.WindowCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -52,6 +53,7 @@ import org.mariotaku.twidere.R;
|
|||
import org.mariotaku.twidere.activity.support.DataExportActivity;
|
||||
import org.mariotaku.twidere.activity.support.DataImportActivity;
|
||||
import org.mariotaku.twidere.graphic.EmptyDrawable;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.view.holder.ViewListHolder;
|
||||
|
||||
|
@ -210,6 +212,21 @@ public class SettingsActivity extends BasePreferenceActivity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event) {
|
||||
final String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event);
|
||||
if (ACTION_NAVIGATION_BACK.equals(action)) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.handleKeyboardShortcutSingle(handler, keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutRepeat(@NonNull KeyboardShortcutsHandler handler, int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||
return super.handleKeyboardShortcutRepeat(handler, keyCode, repeatCount, event);
|
||||
}
|
||||
|
||||
public static void setShouldNotifyChange(Activity activity) {
|
||||
if (!(activity instanceof SettingsActivity)) return;
|
||||
((SettingsActivity) activity).setShouldNotifyChange(true);
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.mariotaku.twidere.activity.iface;
|
||||
|
||||
import org.mariotaku.twidere.view.ShapedImageView;
|
||||
|
||||
public interface IThemedActivity {
|
||||
|
||||
int getCurrentThemeBackgroundAlpha();
|
||||
|
@ -37,8 +39,11 @@ public interface IThemedActivity {
|
|||
|
||||
String getThemeFontFamily();
|
||||
|
||||
String getCurrentThemeFontFamily();
|
||||
|
||||
int getThemeResourceId();
|
||||
|
||||
@ShapedImageView.ShapeStyle
|
||||
int getCurrentProfileImageStyle();
|
||||
|
||||
void restart();
|
||||
|
|
|
@ -50,9 +50,9 @@ public class BaseAppCompatActivity extends ThemedAppCompatActivity implements Co
|
|||
// Registered listeners
|
||||
private ArrayList<ControlBarOffsetListener> mControlBarOffsetListeners = new ArrayList<>();
|
||||
|
||||
// Data fields
|
||||
private boolean mInstanceStateSaved;
|
||||
private boolean mIsVisible;
|
||||
|
||||
private Rect mSystemWindowsInsets;
|
||||
|
||||
@Override
|
||||
|
@ -129,10 +129,6 @@ public class BaseAppCompatActivity extends ThemedAppCompatActivity implements Co
|
|||
return false;
|
||||
}
|
||||
|
||||
protected boolean isStateSaved() {
|
||||
return mInstanceStateSaved;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -23,12 +23,11 @@ import android.annotation.SuppressLint;
|
|||
import android.os.Bundle;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
||||
@SuppressLint("Registered")
|
||||
public class BaseSupportDialogActivity extends ThemedFragmentActivity implements Constants, IThemedActivity {
|
||||
public class BaseSupportDialogActivity extends ThemedFragmentActivity implements Constants {
|
||||
|
||||
private boolean mInstanceStateSaved;
|
||||
|
||||
|
|
|
@ -115,6 +115,11 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
|||
@Override
|
||||
public boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event) {
|
||||
if (handleFragmentKeyboardShortcutSingle(handler, keyCode, event)) return true;
|
||||
final String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event);
|
||||
if (ACTION_NAVIGATION_BACK.equals(action)) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return handler.handleKey(this, null, keyCode, event);
|
||||
}
|
||||
|
||||
|
@ -142,7 +147,6 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
|||
mMainContent.setOnFitSystemWindowsListener(this);
|
||||
setStatusBarColor(linkId, data);
|
||||
setTaskInfo(linkId, data);
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
if (!showFragment(linkId, data)) {
|
||||
finish();
|
||||
}
|
||||
|
@ -224,11 +228,6 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
|||
return true;
|
||||
}
|
||||
}
|
||||
final String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event);
|
||||
if (ACTION_NAVIGATION_BACK.equals(action)) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,15 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
|
|||
@ShapeStyle
|
||||
private int mProfileImageStyle;
|
||||
private String mCurrentThemeBackgroundOption;
|
||||
private String mCurrentThemeFontFamily;
|
||||
|
||||
private AppCompatDelegate mDelegate;
|
||||
|
||||
@Override
|
||||
public String getCurrentThemeFontFamily() {
|
||||
return mCurrentThemeFontFamily;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentThemeBackgroundAlpha() {
|
||||
return mCurrentThemeBackgroundAlpha;
|
||||
|
@ -76,6 +82,7 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
@ShapeStyle
|
||||
public int getCurrentProfileImageStyle() {
|
||||
return mProfileImageStyle;
|
||||
}
|
||||
|
@ -114,6 +121,7 @@ public abstract class ThemedAppCompatActivity extends AppCompatActivity implemen
|
|||
mCurrentThemeBackgroundAlpha = getThemeBackgroundAlpha();
|
||||
mProfileImageStyle = Utils.getProfileImageStyle(this);
|
||||
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
|
||||
mCurrentThemeFontFamily = getThemeFontFamily();
|
||||
setTheme(mCurrentThemeResource);
|
||||
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource,
|
||||
mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
|
||||
|
|
|
@ -19,16 +19,13 @@
|
|||
|
||||
package org.mariotaku.twidere.activity.support;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
|
@ -51,6 +48,12 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
|
|||
@ShapeStyle
|
||||
private int mProfileImageStyle;
|
||||
private String mCurrentThemeBackgroundOption;
|
||||
private String mCurrentThemeFontFamily;
|
||||
|
||||
@Override
|
||||
public String getCurrentThemeFontFamily() {
|
||||
return mCurrentThemeFontFamily;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentThemeBackgroundAlpha() {
|
||||
|
@ -88,6 +91,7 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
|
|||
}
|
||||
|
||||
@Override
|
||||
@ShapeStyle
|
||||
public int getCurrentProfileImageStyle() {
|
||||
return mProfileImageStyle;
|
||||
}
|
||||
|
@ -108,13 +112,6 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
|
|||
mKeyboardShortcutsHandler = TwidereApplication.getInstance(this).getKeyboardShortcutsHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(String name, @NonNull Context context, @NonNull AttributeSet attrs) {
|
||||
final View view = super.onCreateView(name, context, attrs);
|
||||
ThemeUtils.initView(view, getCurrentThemeColor(), mProfileImageStyle);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTitleChanged(CharSequence title, int color) {
|
||||
final SpannableStringBuilder builder = new SpannableStringBuilder(title);
|
||||
|
@ -133,6 +130,7 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements
|
|||
mCurrentThemeBackgroundAlpha = getThemeBackgroundAlpha();
|
||||
mProfileImageStyle = Utils.getProfileImageStyle(this);
|
||||
mCurrentThemeBackgroundOption = getThemeBackgroundOption();
|
||||
mCurrentThemeFontFamily = getThemeFontFamily();
|
||||
setTheme(mCurrentThemeResource);
|
||||
ThemeUtils.applyWindowBackground(this, getWindow(), mCurrentThemeResource, mCurrentThemeBackgroundOption, mCurrentThemeBackgroundAlpha);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@ public abstract class AbsStatusesFragment<Data> extends AbsContentListFragment<A
|
|||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutSingle(@NonNull KeyboardShortcutsHandler handler, int keyCode, @NonNull KeyEvent event) {
|
||||
if (!KeyboardShortcutsHandler.isValidForHotkey(keyCode, event)) return false;
|
||||
String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event);
|
||||
if (ACTION_NAVIGATION_REFRESH.equals(action)) {
|
||||
triggerRefresh();
|
||||
|
|
|
@ -82,7 +82,7 @@ public class DirectMessagesFragment extends AbsContentListFragment<MessageEntrie
|
|||
// Utility classes
|
||||
private MultiSelectManager mMultiSelectManager;
|
||||
private RemoveUnreadCountsTask mRemoveUnreadCountsTask;
|
||||
private RecyclerViewNavigationHelper mRecyclerViewNavigationHelper;
|
||||
private RecyclerViewNavigationHelper mNavigationHelper;
|
||||
|
||||
// Data fields
|
||||
private final LongSparseArray<Set<Long>> mUnreadCountsToRemove = new LongSparseArray<>();
|
||||
|
@ -122,12 +122,17 @@ public class DirectMessagesFragment extends AbsContentListFragment<MessageEntrie
|
|||
public boolean handleKeyboardShortcutRepeat(@NonNull final KeyboardShortcutsHandler handler,
|
||||
final int keyCode, final int repeatCount,
|
||||
@NonNull final KeyEvent event) {
|
||||
return mRecyclerViewNavigationHelper.handleKeyboardShortcutRepeat(handler, keyCode, repeatCount, event);
|
||||
return mNavigationHelper.handleKeyboardShortcutRepeat(handler, keyCode, repeatCount, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleKeyboardShortcutSingle(@NonNull final KeyboardShortcutsHandler handler,
|
||||
final int keyCode, @NonNull final KeyEvent event) {
|
||||
String action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event);
|
||||
if (ACTION_NAVIGATION_REFRESH.equals(action)) {
|
||||
triggerRefresh();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -241,7 +246,7 @@ public class DirectMessagesFragment extends AbsContentListFragment<MessageEntrie
|
|||
final MessageEntriesAdapter adapter = getAdapter();
|
||||
final RecyclerView recyclerView = getRecyclerView();
|
||||
final LinearLayoutManager layoutManager = getLayoutManager();
|
||||
mRecyclerViewNavigationHelper = new RecyclerViewNavigationHelper(recyclerView, layoutManager, adapter);
|
||||
mNavigationHelper = new RecyclerViewNavigationHelper(recyclerView, layoutManager, adapter);
|
||||
|
||||
adapter.setListener(this);
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.annotation.SuppressLint;
|
|||
import android.app.ActionBar;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
|
@ -60,7 +59,6 @@ import android.view.View;
|
|||
import android.view.View.OnLongClickListener;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -700,6 +698,15 @@ public class ThemeUtils implements Constants {
|
|||
return Typeface.create(Typeface.DEFAULT, fontStyle);
|
||||
}
|
||||
|
||||
public static Typeface getUserTypeface(final Context context, final String fontFamily, final Typeface defTypeface) {
|
||||
if (context == null || Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
return Typeface.DEFAULT;
|
||||
final int fontStyle = defTypeface != null ? defTypeface.getStyle() : Typeface.NORMAL;
|
||||
final Typeface tf = Typeface.create(fontFamily, fontStyle);
|
||||
if (tf != null) return tf;
|
||||
return Typeface.create(Typeface.DEFAULT, fontStyle);
|
||||
}
|
||||
|
||||
public static int getViewerThemeResource(final Context context) {
|
||||
return R.style.Theme_Twidere_Viewer;
|
||||
}
|
||||
|
@ -763,12 +770,16 @@ public class ThemeUtils implements Constants {
|
|||
indicator.updateAppearance();
|
||||
}
|
||||
|
||||
public static void initView(View view, int themeColor, int profileImageStyle) {
|
||||
public static void initView(View view, IThemedActivity activity) {
|
||||
if (view == null) return;
|
||||
if (view instanceof ShapedImageView) {
|
||||
final ShapedImageView shapedImageView = (ShapedImageView) view;
|
||||
shapedImageView.setStyle(profileImageStyle);
|
||||
shapedImageView.setStyle(activity.getCurrentProfileImageStyle());
|
||||
} else if (view instanceof TextView) {
|
||||
final String fontFamily = activity.getCurrentThemeFontFamily();
|
||||
final TextView textView = (TextView) view;
|
||||
final Typeface defTypeface = textView.getTypeface();
|
||||
textView.setTypeface(getUserTypeface((Context) activity, fontFamily, defTypeface));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue