From cb295928198e3fa157440e54ade74810e4cb3777 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sat, 2 May 2015 20:55:16 +0800 Subject: [PATCH] updated translation --- .../twidere/model/ParcelableMedia.java | 3 + twidere/build.gradle | 2 +- .../activity/BasePreferenceActivity.java | 52 ++++++-------- .../twidere/activity/NyanActivity.java | 2 +- .../twidere/activity/SettingsActivity.java | 56 ++++++++++++--- .../activity/support/LinkHandlerActivity.java | 15 ++-- .../support/RequestPermissionsActivity.java | 2 +- .../activity/support/SignInActivity.java | 6 +- .../support/ThemedFragmentActivity.java | 13 ---- .../twidere/fragment/BaseFiltersFragment.java | 2 +- .../twidere/fragment/CustomTabsFragment.java | 6 +- .../AddUserListMemberDialogFragment.java | 2 +- .../fragment/support/InvalidTabFragment.java | 2 +- .../PhishingLinkWarningDialogFragment.java | 2 +- .../fragment/support/StatusFragment.java | 1 + .../fragment/support/UserFragment.java | 6 +- .../preference/SeekBarDialogPreference.java | 2 +- .../preference/ThemePreviewPreference.java | 2 +- .../twidere/text/SafeSpannableString.java | 22 ++++++ .../text/SafeSpannableStringBuilder.java | 22 ++++++ .../twidere/util/AsyncTwitterWrapper.java | 1 + .../mariotaku/twidere/util/ThemeUtils.java | 70 ++++++------------- .../util/ThemedLayoutInflaterFactory.java | 3 +- .../TwidereActionModeForChildListener.java | 27 +++---- .../twidere/view/StatusTextView.java | 38 +--------- .../res/layout/activity_content_fragment.xml | 1 - ...s.xml => activity_request_permissions.xml} | 4 +- .../src/main/res/layout/activity_settings.xml | 41 +++++++++-- .../layout/adapter_item_compose_account.xml | 4 +- ....xml => dialog_auto_complete_textview.xml} | 0 ...g.xml => dialog_phishing_link_warning.xml} | 0 ...log.xml => dialog_preference_seek_bar.xml} | 0 ...valid_tab.xml => fragment_invalid_tab.xml} | 0 .../res/layout/layout_actionbar_content.xml | 7 +- ...rface_view.xml => layout_surface_view.xml} | 0 twidere/src/main/res/layout/tab_item_ab.xml | 42 ----------- twidere/src/main/res/values/themes.xml | 6 +- 37 files changed, 225 insertions(+), 239 deletions(-) create mode 100644 twidere/src/main/java/org/mariotaku/twidere/text/SafeSpannableString.java create mode 100644 twidere/src/main/java/org/mariotaku/twidere/text/SafeSpannableStringBuilder.java rename twidere/src/main/res/layout/{request_permissions.xml => activity_request_permissions.xml} (96%) rename twidere/src/main/res/layout/{auto_complete_textview.xml => dialog_auto_complete_textview.xml} (100%) rename twidere/src/main/res/layout/{phishing_link_warning.xml => dialog_phishing_link_warning.xml} (100%) rename twidere/src/main/res/layout/{preference_seek_bar_dialog.xml => dialog_preference_seek_bar.xml} (100%) rename twidere/src/main/res/layout/{invalid_tab.xml => fragment_invalid_tab.xml} (100%) rename twidere/src/main/res/layout/{surface_view.xml => layout_surface_view.xml} (100%) delete mode 100644 twidere/src/main/res/layout/tab_item_ab.xml diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMedia.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMedia.java index f3d6514c0..efbff0fe9 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMedia.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/ParcelableMedia.java @@ -16,6 +16,8 @@ import org.mariotaku.twidere.util.ParseUtils; import org.mariotaku.twidere.util.TwidereArrayUtils; import java.io.IOException; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -317,6 +319,7 @@ public class ParcelableMedia implements Parcelable { } @IntDef({TYPE_UNKNOWN, TYPE_IMAGE, TYPE_VIDEO, TYPE_ANIMATED_GIF, TYPE_CARD_ANIMATED_GIF}) + @Retention(RetentionPolicy.SOURCE) public @interface MediaType { } diff --git a/twidere/build.gradle b/twidere/build.gradle index ef3a3df12..d3b6b5e00 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -11,7 +11,7 @@ android { applicationId "org.mariotaku.twidere" minSdkVersion 14 targetSdkVersion 22 - versionCode 111 + versionCode 112 versionName "0.3.0" multiDexEnabled true } diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/BasePreferenceActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/BasePreferenceActivity.java index 991a4c310..80e332d7a 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/BasePreferenceActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/BasePreferenceActivity.java @@ -25,12 +25,14 @@ import android.os.Build; import android.os.Bundle; import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; +import android.support.v4.view.ViewCompat; import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatDelegate; +import android.support.v7.app.ThemedAppCompatDelegateFactory; +import android.support.v7.app.ThemedAppCompatDelegateFactory.ThemedAppCompatDelegate; +import android.support.v7.internal.widget.NativeActionModeAwareLayout; import android.support.v7.widget.ActionMenuView; import android.support.v7.widget.Toolbar; -import android.text.SpannableStringBuilder; -import android.text.Spanned; -import android.text.style.ForegroundColorSpan; import android.view.KeyEvent; import android.view.Menu; import android.view.View; @@ -44,12 +46,15 @@ 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.graphic.EmptyDrawable; import org.mariotaku.twidere.util.KeyboardShortcutsHandler; import org.mariotaku.twidere.util.StrictModeUtils; import org.mariotaku.twidere.util.ThemeUtils; +import org.mariotaku.twidere.util.TwidereActionModeForChildListener; import org.mariotaku.twidere.util.TwidereColorUtils; import org.mariotaku.twidere.util.Utils; import org.mariotaku.twidere.util.support.ViewSupport; +import org.mariotaku.twidere.util.support.view.ViewOutlineProviderCompat; import org.mariotaku.twidere.view.ShapedImageView.ShapeStyle; import org.mariotaku.twidere.view.TintedStatusFrameLayout; @@ -167,23 +172,25 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity @Override public void setContentView(@LayoutRes int layoutResID) { final FrameLayout mainContent = initMainContent(); - getLayoutInflater().inflate(layoutResID, mainContent, true); + getLayoutInflater().inflate(layoutResID, (ViewGroup) mainContent.findViewById(R.id.settings_content), true); super.setContentView(mainContent); } @Override public void setContentView(View view) { final FrameLayout mainContent = initMainContent(); - mainContent.removeAllViews(); - mainContent.addView(view); + final ViewGroup settingsContent = (ViewGroup) mainContent.findViewById(R.id.settings_content); + settingsContent.removeAllViews(); + settingsContent.addView(view); super.setContentView(mainContent); } @Override public void setContentView(View view, ViewGroup.LayoutParams params) { final FrameLayout mainContent = initMainContent(); - mainContent.removeAllViews(); - mainContent.addView(view, params); + final ViewGroup settingsContent = (ViewGroup) mainContent.findViewById(R.id.settings_content); + settingsContent.removeAllViews(); + settingsContent.addView(view); super.setContentView(mainContent); } @@ -195,22 +202,11 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity final View mainLayout = getLayoutInflater().inflate(R.layout.activity_settings, null); mainContent = (FrameLayout) mainLayout.findViewById(R.id.main_content); } - mainContent.addView(view, params); + final ViewGroup settingsContent = (ViewGroup) mainContent.findViewById(R.id.settings_content); + settingsContent.addView(view, params); onContentChanged(); } - @Override - protected void onTitleChanged(CharSequence title, int color) { - final SpannableStringBuilder builder = new SpannableStringBuilder(title); - final int themeResId = getCurrentThemeResourceId(); - final int themeColor = getThemeColor(); - final int contrastColor = ThemeUtils.getContrastActionBarTitleColor(this, themeResId, themeColor); - if (!ThemeUtils.isDarkTheme(themeResId)) { - builder.setSpan(new ForegroundColorSpan(contrastColor), 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } - super.onTitleChanged(title, color); - } - protected boolean isActionBarOutlineEnabled() { return true; } @@ -235,7 +231,6 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity final int themeId = getCurrentThemeResourceId(); final int itemColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor); final Toolbar toolbar = (Toolbar) actionBarView; - ThemeUtils.setActionBarOverflowColor(toolbar, itemColor); final int popupColor = ThemeUtils.getThemeForegroundColor(toolbar.getContext(), toolbar.getPopupTheme()); ThemeUtils.wrapToolbarMenuIcon(ViewSupport.findViewByType(actionBarView, ActionMenuView.class), itemColor, popupColor); } @@ -251,9 +246,7 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity if (mainContent != null) { return mainContent; } - @SuppressLint("InflateParams") - final View view = getLayoutInflater().inflate(R.layout.activity_settings, null); - return (FrameLayout) view.findViewById(R.id.main_content); + return ((FrameLayout) getLayoutInflater().inflate(R.layout.activity_settings, null)); } @Override @@ -285,10 +278,10 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity final int themeColor = getCurrentThemeColor(); final int themeId = getCurrentThemeResourceId(); final String option = getThemeBackgroundOption(); - final int titleColor = ThemeUtils.getContrastActionBarTitleColor(this, themeId, themeColor); - final int actionBarItemsColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor); ThemeUtils.applyActionBarBackground(actionBar, this, themeId, themeColor, option, isActionBarOutlineEnabled()); - ThemeUtils.setActionBarColor(getWindow(), actionBar, titleColor, actionBarItemsColor); +// final int titleColor = ThemeUtils.getContrastActionBarTitleColor(this, themeId, themeColor); +// final int actionBarItemsColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor); +// ThemeUtils.setActionBarColor(getWindow(), actionBar, titleColor, actionBarItemsColor); } private void setupTintStatusBar() { @@ -313,9 +306,6 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS); } -// supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR); -// supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY); -// supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_MODE_OVERLAY); } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/NyanActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/NyanActivity.java index 1eab88795..d7a6133b9 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/NyanActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/NyanActivity.java @@ -69,7 +69,7 @@ public class NyanActivity extends Activity implements Constants, OnLongClickList super.onCreate(savedInstanceState); mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE); mPreferences.registerOnSharedPreferenceChangeListener(this); - setContentView(R.layout.surface_view); + setContentView(R.layout.layout_surface_view); mSurfaceView.setOnLongClickListener(this); final SurfaceHolder holder = mSurfaceView.getHolder(); mHelper = new NyanSurfaceHelper(this); diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/SettingsActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/SettingsActivity.java index 9fcc8afc0..264bf4208 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/SettingsActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/SettingsActivity.java @@ -33,7 +33,12 @@ import android.content.res.Resources; import android.graphics.PorterDuff.Mode; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.v4.view.ViewCompat; import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatDelegate; +import android.support.v7.app.ThemedAppCompatDelegateFactory; +import android.support.v7.internal.widget.NativeActionModeAwareLayout; +import android.support.v7.widget.Toolbar; import android.text.TextUtils; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -58,6 +63,9 @@ 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.util.TwidereActionModeForChildListener; +import org.mariotaku.twidere.util.support.ViewSupport; +import org.mariotaku.twidere.util.support.view.ViewOutlineProviderCompat; import org.mariotaku.twidere.view.holder.ViewListHolder; import java.util.ArrayList; @@ -71,6 +79,8 @@ public class SettingsActivity extends BasePreferenceActivity { private HeaderAdapter mAdapter; private boolean mShouldNotifyChange; + private TwidereActionModeForChildListener mTwidereActionModeForChildListener; + private ThemedAppCompatDelegateFactory.ThemedAppCompatDelegate mDelegate; public static void setShouldNotifyChange(Activity activity) { if (!(activity instanceof SettingsActivity)) return; @@ -82,6 +92,19 @@ public class SettingsActivity extends BasePreferenceActivity { return mAdapter = new HeaderAdapter(this); } + @Override + public void onBackPressed() { + if (mTwidereActionModeForChildListener.finishExisting()) { + return; + } + if (isTopSettings() && shouldNotifyChange()) { + final RestartConfirmDialogFragment df = new RestartConfirmDialogFragment(); + df.show(getFragmentManager().beginTransaction(), "restart_confirm"); + return; + } + super.onBackPressed(); + } + @Override public int getThemeColor() { return ThemeUtils.getUserAccentColor(this); @@ -89,7 +112,7 @@ public class SettingsActivity extends BasePreferenceActivity { @Override public int getThemeResourceId() { - return ThemeUtils.getThemeResource(this); + return ThemeUtils.getNoActionBarThemeResource(this); } @Override @@ -179,16 +202,6 @@ public class SettingsActivity extends BasePreferenceActivity { return true; } - @Override - public void onBackPressed() { - if (isTopSettings() && shouldNotifyChange()) { - final RestartConfirmDialogFragment df = new RestartConfirmDialogFragment(); - df.show(getFragmentManager().beginTransaction(), "restart_confirm"); - return; - } - super.onBackPressed(); - } - private boolean isTopSettings() { return getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT) == null; } @@ -258,6 +271,19 @@ public class SettingsActivity extends BasePreferenceActivity { protected void onCreate(final Bundle savedInstanceState) { // supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR); super.onCreate(savedInstanceState); + + setSupportActionBar((Toolbar) findViewById(R.id.action_bar)); + + mTwidereActionModeForChildListener = new TwidereActionModeForChildListener(this, this, false); + final NativeActionModeAwareLayout layout = (NativeActionModeAwareLayout) findViewById(android.R.id.content); + layout.setActionModeForChildListener(mTwidereActionModeForChildListener); + + ThemeUtils.setCompatContentViewOverlay(this, new EmptyDrawable()); + final View actionBarContainer = findViewById(R.id.twidere_action_bar_container); + ViewCompat.setElevation(actionBarContainer, ThemeUtils.getSupportActionBarElevation(this)); + ViewSupport.setOutlineProvider(actionBarContainer, ViewOutlineProviderCompat.BACKGROUND); + final View windowOverlay = findViewById(R.id.window_overlay); + ViewSupport.setBackground(windowOverlay, ThemeUtils.getNormalWindowContentOverlay(this, getCurrentThemeResourceId())); setIntent(getIntent().addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { @@ -295,6 +321,14 @@ public class SettingsActivity extends BasePreferenceActivity { return mShouldNotifyChange; } + @Override + public AppCompatDelegate getDelegate() { + if (mDelegate == null) { + mDelegate = ThemedAppCompatDelegateFactory.create(this, this); + } + return mDelegate; + } + public static class RestartConfirmDialogFragment extends DialogFragment implements DialogInterface.OnClickListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/LinkHandlerActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/LinkHandlerActivity.java index d83344a6d..cec7a8772 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/LinkHandlerActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/LinkHandlerActivity.java @@ -264,7 +264,6 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System final int themeColor = getCurrentThemeColor(); final int themeId = getCurrentThemeResourceId(); final int itemColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor); - ThemeUtils.setActionBarOverflowColor(toolbar, itemColor); ThemeUtils.wrapToolbarMenuIcon(ViewSupport.findViewByType(toolbar, ActionMenuView.class), itemColor, itemColor); } } @@ -354,13 +353,13 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System } } if (actionBarItemsColor != 0 && shouldSetActionItemColor()) { - final int titleColor = ThemeUtils.getContrastActionBarTitleColor(this, themeId, themeColor); - final Toolbar toolbar = peekActionBarToolbar(); - if (toolbar != null) { - ThemeUtils.setToolBarColor(toolbar, titleColor, actionBarItemsColor); - } else { - ThemeUtils.setActionBarColor(getWindow(), getSupportActionBar(), titleColor, actionBarItemsColor); - } +// final int titleColor = ThemeUtils.getContrastActionBarTitleColor(this, themeId, themeColor); +// final Toolbar toolbar = peekActionBarToolbar(); +// if (toolbar != null) { +// ThemeUtils.setToolBarColor(toolbar, titleColor, actionBarItemsColor); +// } else { +// ThemeUtils.setActionBarColor(getWindow(), getSupportActionBar(), titleColor, actionBarItemsColor); +// } } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/RequestPermissionsActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/RequestPermissionsActivity.java index db570e21c..7dc0c2b39 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/RequestPermissionsActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/RequestPermissionsActivity.java @@ -81,7 +81,7 @@ public class RequestPermissionsActivity extends BaseSupportDialogActivity implem requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); mPermissionsManager = new PermissionsManager(this); - setContentView(R.layout.request_permissions); + setContentView(R.layout.activity_request_permissions); mAcceptButton.setOnClickListener(this); mDenyButton.setOnClickListener(this); final String caller = getCallingPackage(); diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java index 363eaa2d2..21435e8ba 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java @@ -276,7 +276,6 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons final int themeColor = getCurrentThemeColor(); final int themeId = getCurrentThemeResourceId(); final int itemColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor); - ThemeUtils.setActionBarOverflowColor(toolbar, itemColor); ThemeUtils.wrapToolbarMenuIcon(ViewSupport.findViewByType(toolbar, ActionMenuView.class), itemColor, itemColor); } return result; @@ -545,14 +544,13 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons final int themeColor = getCurrentThemeColor(); final int themeId = getCurrentThemeResourceId(); final String option = getThemeBackgroundOption(); - final int titleColor = ThemeUtils.getContrastActionBarTitleColor(this, themeId, themeColor); final int actionBarItemsColor = ThemeUtils.getContrastActionBarItemColor(this, themeId, themeColor); ThemeUtils.applyActionBarBackground(actionBar, this, themeId, themeColor, option, isActionBarOutlineEnabled()); final Toolbar toolbar = peekActionBarToolbar(); if (toolbar != null) { - ThemeUtils.setToolBarColor(toolbar, titleColor, actionBarItemsColor); +// ThemeUtils.setToolBarColor(toolbar, titleColor, actionBarItemsColor); } else { - ThemeUtils.setActionBarColor(getWindow(), getSupportActionBar(), titleColor, actionBarItemsColor); +// ThemeUtils.setActionBarColor(getWindow(), getSupportActionBar(), titleColor, actionBarItemsColor); } } diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/ThemedFragmentActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/ThemedFragmentActivity.java index c8849f5ec..2b328ce45 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/ThemedFragmentActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/ThemedFragmentActivity.java @@ -134,19 +134,6 @@ public abstract class ThemedFragmentActivity extends FragmentActivity implements mKeyboardShortcutsHandler = TwidereApplication.getInstance(this).getKeyboardShortcutsHandler(); } - @Override - protected void onTitleChanged(CharSequence title, int color) { - final SpannableStringBuilder builder = new SpannableStringBuilder(title); - final int themeResId = getCurrentThemeResourceId(); - final int themeColor = getThemeColor(); - final int contrastColor = ThemeUtils.getContrastActionBarTitleColor(this, themeResId, themeColor); - if (!ThemeUtils.isDarkTheme(themeResId)) { - builder.setSpan(new ForegroundColorSpan(contrastColor), 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } - super.onTitleChanged(title, color); - } - - @Override public void setTheme(int resid) { super.setTheme(mCurrentThemeResource = getThemeResourceId()); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/BaseFiltersFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/BaseFiltersFragment.java index 83771dea9..f1c87c980 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/BaseFiltersFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/BaseFiltersFragment.java @@ -280,7 +280,7 @@ public abstract class BaseFiltersFragment extends AbsContentListViewFragment searches = twitter.getSavedSearches(); final ContentValues[] values = ContentValuesCreator.createSavedSearches(searches, accountId); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java index 7405fedab..866dc2d19 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ThemeUtils.java @@ -19,7 +19,6 @@ package org.mariotaku.twidere.util; -import android.annotation.SuppressLint; import android.app.ActionBar; import android.app.Activity; import android.content.Context; @@ -228,15 +227,18 @@ public class ThemeUtils implements Constants { } } if (!(contextView instanceof ActionBarContextView) || actionBarContext == null) return; - setActionBarContextViewColor(actionBarContext, contextView, themeRes, accentColor, backgroundOption, outlineEnabled); + setActionBarContextViewColor(actionBarContext, (ActionBarContextView) contextView, + themeRes, accentColor, backgroundOption, outlineEnabled); } catch (Exception e) { e.printStackTrace(); } } - private static void setActionBarContextViewColor(Context context, View contextView, int themeRes, int accentColor, String backgroundOption, boolean outlineEnabled) { - final TextView actionBarTitleView = (TextView) contextView.findViewById(android.support.v7.appcompat.R.id.action_bar_title); - final TextView actionBarSubtitleView = (TextView) contextView.findViewById(android.support.v7.appcompat.R.id.action_bar_subtitle); + public static void setActionBarContextViewColor(@NonNull Context context, + @NonNull ActionBarContextView contextView, + int themeRes, int accentColor, String backgroundOption, boolean outlineEnabled) { + contextView.setTitle(contextView.getTitle()); + contextView.setSubtitle(contextView.getSubtitle()); final ImageView actionModeCloseButton = (ImageView) contextView.findViewById(android.support.v7.appcompat.R.id.action_mode_close_button); final ActionMenuView menuView = ViewSupport.findViewByType(contextView, ActionMenuView.class); final int actionBarColor; @@ -245,14 +247,7 @@ public class ThemeUtils implements Constants { } else { actionBarColor = accentColor; } - final int titleColor = getContrastActionBarTitleColor(context, themeRes, actionBarColor); final int itemColor = getContrastActionBarItemColor(context, themeRes, actionBarColor); - if (actionBarTitleView != null) { - actionBarTitleView.setTextColor(titleColor); - } - if (actionBarSubtitleView != null) { - actionBarSubtitleView.setTextColor(titleColor); - } if (actionModeCloseButton != null) { actionModeCloseButton.setColorFilter(itemColor, Mode.SRC_ATOP); } @@ -406,17 +401,14 @@ public class ThemeUtils implements Constants { return context.getResources().getColor(R.color.action_icon_dark); } - public static int getContrastActionBarTitleColor(Context context, int theme, int color) { - if (isDarkTheme(theme)) { + public static int getContrastActionBarItemColor(Context context) { + final int colorBackground = getColorFromAttribute(context, android.R.attr.colorBackground, 0); + if (TwidereColorUtils.getYIQLuminance(colorBackground) <= ACCENT_COLOR_THRESHOLD) { //return light text color - return getColorFromAttribute(context, android.R.attr.colorForeground, Color.RED); - } else if (TwidereColorUtils.getYIQLuminance(color) <= ACCENT_COLOR_THRESHOLD) { - //return light text color - return getColorFromAttribute(context, android.R.attr.colorForegroundInverse, Color.RED); - } else { - //return dark text color - return getColorFromAttribute(context, android.R.attr.colorForeground, Color.RED); + return context.getResources().getColor(R.color.action_icon_light); } + //return dark text color + return context.getResources().getColor(R.color.action_icon_dark); } public static int getDialogThemeResource(final Context context) { @@ -1004,28 +996,26 @@ public class ThemeUtils implements Constants { public static void setActionBarColor(Window window, android.support.v7.app.ActionBar actionBar, int titleColor, int itemColor) { - final Drawable drawable = getActionBarHomeAsUpIndicator(actionBar); - if (drawable != null) { - drawable.setColorFilter(itemColor, Mode.SRC_ATOP); - } - actionBar.setHomeAsUpIndicator(drawable); +// final Drawable drawable = getActionBarHomeAsUpIndicator(actionBar); +// if (drawable != null) { +// drawable.setColorFilter(itemColor, Mode.SRC_ATOP); +// } +// actionBar.setHomeAsUpIndicator(drawable); // Ensure title view created if (actionBar instanceof WindowDecorActionBar) { actionBar.setTitle(actionBar.getTitle()); actionBar.setSubtitle(actionBar.getSubtitle()); - setActionBarTitleTextColor(window, titleColor); - setActionBarSubtitleTextColor(window, titleColor); } else if (actionBar instanceof ToolbarActionBar) { } } public static void setToolBarColor(@NonNull Toolbar toolbar, int titleColor, int itemColor) { - final Drawable drawable = toolbar.getNavigationIcon(); - if (drawable != null) { - drawable.setColorFilter(itemColor, Mode.SRC_ATOP); - } - toolbar.setNavigationIcon(drawable); +// final Drawable drawable = toolbar.getNavigationIcon(); +// if (drawable != null) { +// drawable.setColorFilter(itemColor, Mode.SRC_ATOP); +// } +// toolbar.setNavigationIcon(drawable); toolbar.setTitleTextColor(titleColor); toolbar.setSubtitleTextColor(titleColor); } @@ -1090,20 +1080,6 @@ public class ThemeUtils implements Constants { drawable.setColorFilter(itemColor, Mode.SRC_ATOP); } - public static void setActionBarSubtitleTextColor(Window window, int itemColor) { - final View actionBarView = window.findViewById(android.support.v7.appcompat.R.id.action_bar); - if (actionBarView instanceof Toolbar) { - ((Toolbar) actionBarView).setSubtitleTextColor(itemColor); - } - } - - public static void setActionBarTitleTextColor(Window window, int titleColor) { - final View actionBarView = window.findViewById(android.support.v7.appcompat.R.id.action_bar); - if (actionBarView instanceof Toolbar) { - ((Toolbar) actionBarView).setTitleTextColor(titleColor); - } - } - public static void setCompatToolbarOverlay(Activity activity, Drawable overlay) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return; final Window window = activity.getWindow(); diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java b/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java index cb0eeb8ad..615322d86 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/ThemedLayoutInflaterFactory.java @@ -190,7 +190,8 @@ public class ThemedLayoutInflaterFactory implements LayoutInflaterFactory { ViewCompat.setBackgroundTintList(view, ColorStateList.valueOf(backgroundTintColor)); } } else if (view instanceof ProgressBar) { - if (isAccentOptimal) { + if (isAccentOptimal || !isColorTint) { + ViewSupport.setIndeterminateTintList((ProgressBar) view, ColorStateList.valueOf(accentColor)); ViewSupport.setProgressTintList((ProgressBar) view, ColorStateList.valueOf(accentColor)); ViewSupport.setProgressBackgroundTintList((ProgressBar) view, ColorStateList.valueOf(accentColor)); } diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/TwidereActionModeForChildListener.java b/twidere/src/main/java/org/mariotaku/twidere/util/TwidereActionModeForChildListener.java index 88d93723e..cf4f7f1d5 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/util/TwidereActionModeForChildListener.java +++ b/twidere/src/main/java/org/mariotaku/twidere/util/TwidereActionModeForChildListener.java @@ -47,6 +47,7 @@ import org.mariotaku.twidere.activity.iface.IThemedActivity; */ public class TwidereActionModeForChildListener implements NativeActionModeAwareLayout.OnActionModeForChildListener { private final Activity mActivity; + private final IThemedActivity mThemed; private final AppCompatCallback mAppCompatCallback; private final Window mWindow; private final boolean mIsFloating; @@ -57,16 +58,12 @@ public class TwidereActionModeForChildListener implements NativeActionModeAwareL public PopupWindow mActionModePopup; public Runnable mShowActionModePopup; - public TwidereActionModeForChildListener(Activity activity, AppCompatCallback callback, boolean usePopup) { - mActivity = activity; - mWindow = activity.getWindow(); + public TwidereActionModeForChildListener(IThemedActivity activity, AppCompatCallback callback, boolean usePopup) { + mActivity = (Activity) activity; + mThemed = activity; + mWindow = mActivity.getWindow(); mAppCompatCallback = callback; - if (activity instanceof IThemedActivity) { - mIsFloating = ThemeUtils.isWindowFloating(mActivity, - ((IThemedActivity) activity).getCurrentThemeResourceId()); - } else { - mIsFloating = mWindow.isFloating(); - } + mIsFloating = ThemeUtils.isWindowFloating(mActivity, activity.getCurrentThemeResourceId()); mUsePopup = usePopup; } @@ -111,13 +108,8 @@ public class TwidereActionModeForChildListener implements NativeActionModeAwareL if (mIsFloating && mUsePopup) { // Use the action bar theme. final Context actionBarContext; - if (mActivity instanceof IThemedActivity) { - actionBarContext = ThemeUtils.getActionBarThemedContext(mActivity, - ((IThemedActivity) mActivity).getCurrentThemeResourceId(), - ((IThemedActivity) mActivity).getCurrentThemeColor()); - } else { - actionBarContext = ThemeUtils.getActionBarThemedContext(mActivity); - } + actionBarContext = ThemeUtils.getActionBarThemedContext(mActivity, mThemed.getCurrentThemeResourceId(), + mThemed.getCurrentThemeColor()); mActionModeView = new ActionBarContextView(actionBarContext); mActionModePopup = new PopupWindow(actionBarContext, null, @@ -131,6 +123,9 @@ public class TwidereActionModeForChildListener implements NativeActionModeAwareL final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics()); mActionModeView.setContentHeight(height); + ThemeUtils.setActionBarContextViewColor(actionBarContext, mActionModeView, + mThemed.getCurrentThemeResourceId(), mThemed.getCurrentThemeColor(), + mThemed.getCurrentThemeBackgroundOption(), false); mActionModePopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); mShowActionModePopup = new Runnable() { public void run() { diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/StatusTextView.java b/twidere/src/main/java/org/mariotaku/twidere/view/StatusTextView.java index aad55692f..26e6fc703 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/view/StatusTextView.java +++ b/twidere/src/main/java/org/mariotaku/twidere/view/StatusTextView.java @@ -4,10 +4,11 @@ import android.content.Context; import android.support.v7.widget.AppCompatTextView; import android.text.Editable; import android.text.Spannable; -import android.text.SpannableString; -import android.text.SpannableStringBuilder; import android.util.AttributeSet; +import org.mariotaku.twidere.text.SafeSpannableString; +import org.mariotaku.twidere.text.SafeSpannableStringBuilder; + public class StatusTextView extends AppCompatTextView { public StatusTextView(final Context context) { @@ -18,45 +19,12 @@ public class StatusTextView extends AppCompatTextView { this(context, attrs, 0); } - public StatusTextView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); setEditableFactory(new SafeEditableFactory()); setSpannableFactory(new SafeSpannableFactory()); } - private static class SafeSpannableString extends SpannableString { - - public SafeSpannableString(CharSequence source) { - super(source); - } - - @Override - public void setSpan(Object what, int start, int end, int flags) { - if (start < 0 || end < 0) { - // Silently ignore - return; - } - super.setSpan(what, start, end, flags); - } - } - - private static class SafeSpannableStringBuilder extends SpannableStringBuilder { - - public SafeSpannableStringBuilder(CharSequence source) { - super(source); - } - - @Override - public void setSpan(Object what, int start, int end, int flags) { - if (start < 0 || end < 0) { - // Silently ignore - return; - } - super.setSpan(what, start, end, flags); - } - } - private class SafeEditableFactory extends Editable.Factory { @Override public Editable newEditable(CharSequence source) { diff --git a/twidere/src/main/res/layout/activity_content_fragment.xml b/twidere/src/main/res/layout/activity_content_fragment.xml index 7b312da9f..8611cca00 100644 --- a/twidere/src/main/res/layout/activity_content_fragment.xml +++ b/twidere/src/main/res/layout/activity_content_fragment.xml @@ -18,7 +18,6 @@ --> + android:showDividers="middle" + tools:context=".activity.support.RequestPermissionsActivity"> - - + app:setPadding="true"> + + + + + + + + + + diff --git a/twidere/src/main/res/layout/adapter_item_compose_account.xml b/twidere/src/main/res/layout/adapter_item_compose_account.xml index ae9c9a030..b9033d61e 100644 --- a/twidere/src/main/res/layout/adapter_item_compose_account.xml +++ b/twidere/src/main/res/layout/adapter_item_compose_account.xml @@ -38,9 +38,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/element_spacing_msmall" - app:cardBackgroundColor="?android:colorBackgroundCacheHint" + app:cardBackgroundColor="?android:colorBackground" app:cardElevation="@dimen/elevation_card" - app:contentPadding="@dimen/element_spacing_small"> + app:contentPadding="@dimen/element_spacing_msmall"> - + + app:navigationContentDescription="@string/abc_action_bar_up_description" + app:navigationIcon="?homeAsUpIndicator" /> - - - - - - - - - \ No newline at end of file diff --git a/twidere/src/main/res/values/themes.xml b/twidere/src/main/res/values/themes.xml index 025d70cd0..5955fca48 100644 --- a/twidere/src/main/res/values/themes.xml +++ b/twidere/src/main/res/values/themes.xml @@ -52,7 +52,8 @@ @color/background_color_card_item_dark - @color/action_icon_light + + #fff ?menuIconColor @color/message_bubble_color_dark @@ -85,7 +86,8 @@ @color/background_color_card_item_dark - @color/action_icon_light + + #fff ?menuIconColor @color/message_bubble_color_dark