updated translation

This commit is contained in:
Mariotaku Lee 2015-05-02 20:55:16 +08:00
parent 3c83963ff0
commit cb29592819
37 changed files with 225 additions and 239 deletions

View File

@ -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 {
}

View File

@ -11,7 +11,7 @@ android {
applicationId "org.mariotaku.twidere"
minSdkVersion 14
targetSdkVersion 22
versionCode 111
versionCode 112
versionName "0.3.0"
multiDexEnabled true
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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) {

View File

@ -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);
// }
}
}

View File

@ -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();

View File

@ -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);
}
}

View File

@ -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());

View File

@ -280,7 +280,7 @@ public abstract class BaseFiltersFragment extends AbsContentListViewFragment<Sim
final Context wrapped = ThemeUtils.getDialogThemedContext(activity);
final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
buildDialog(builder);
final View view = LayoutInflater.from(wrapped).inflate(R.layout.auto_complete_textview, null);
final View view = LayoutInflater.from(wrapped).inflate(R.layout.dialog_auto_complete_textview, null);
builder.setView(view);
mEditText = (AutoCompleteTextView) view.findViewById(R.id.edit_text);
final Bundle args = getArguments();

View File

@ -69,7 +69,6 @@ import org.mariotaku.twidere.model.CustomTabConfiguration.CustomTabConfiguration
import org.mariotaku.twidere.provider.TwidereDataStore.Tabs;
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.TwidereColorUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.holder.TwoLineWithIconViewHolder;
@ -315,10 +314,11 @@ public class CustomTabsFragment extends BaseFragment implements LoaderCallbacks<
final Activity activity = getActivity();
if (activity instanceof BasePreferenceActivity) {
final ActionBar actionBar = ((BasePreferenceActivity) activity).getSupportActionBar();
final int themeResId = ((IThemedActivity) activity).getThemeResourceId();
final int themeColor = ((IThemedActivity) activity).getCurrentThemeColor();
final int itemColor = TwidereColorUtils.getContrastYIQ(themeColor, ThemeUtils.ACCENT_COLOR_THRESHOLD);
final int itemColor = ThemeUtils.getContrastActionBarItemColor(actionBar.getThemedContext());
final int popupTheme = ThemeUtils.getActionBarPopupThemeRes(actionBar.getThemedContext());
final int popupColor = ThemeUtils.getThemeForegroundColor(activity, popupTheme);
final int popupColor = ThemeUtils.getContrastActionBarItemColor(activity);
ThemeUtils.applyColorFilterToMenuIcon(menu, itemColor, popupColor, 0, Mode.SRC_ATOP);
}
}

View File

@ -65,7 +65,7 @@ public class AddUserListMemberDialogFragment extends BaseSupportDialogFragment i
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final Context wrapped = ThemeUtils.getDialogThemedContext(getActivity());
final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
final View view = LayoutInflater.from(wrapped).inflate(R.layout.auto_complete_textview, null);
final View view = LayoutInflater.from(wrapped).inflate(R.layout.dialog_auto_complete_textview, null);
builder.setView(view);
mEditText = (AutoCompleteTextView) view.findViewById(R.id.edit_text);
if (savedInstanceState != null) {

View File

@ -11,7 +11,7 @@ public class InvalidTabFragment extends BaseSupportFragment {
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
return inflater.inflate(R.layout.invalid_tab, container, false);
return inflater.inflate(R.layout.fragment_invalid_tab, container, false);
}
}

View File

@ -59,7 +59,7 @@ public class PhishingLinkWarningDialogFragment extends BaseSupportDialogFragment
final AlertDialog.Builder builder = new AlertDialog.Builder(wrapped);
final LayoutInflater inflater = LayoutInflater.from(wrapped);
builder.setTitle(android.R.string.dialog_alert_title);
builder.setView(inflater.inflate(R.layout.phishing_link_warning, null));
builder.setView(inflater.inflate(R.layout.dialog_phishing_link_warning, null));
builder.setPositiveButton(android.R.string.ok, this);
builder.setNegativeButton(android.R.string.cancel, null);
return builder.create();

View File

@ -953,6 +953,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mode.getMenuInflater().inflate(R.menu.action_status_text_selection, menu);
mode.setTitle(android.R.string.selectTextMode);
return true;
}

View File

@ -1515,11 +1515,11 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
if (mPreviousActionBarItemIsDark == 0 || (actionItemIsDark ? 1 : -1) != mPreviousActionBarItemIsDark) {
StatusBarProxy.setStatusBarDarkIcon(activity.getWindow(), actionItemIsDark);
final int itemColor = ThemeUtils.getContrastActionBarItemColor(activity, themeId, barColor);
final int titleColor = ThemeUtils.getContrastActionBarTitleColor(activity, themeId, barColor);
// final int titleColor = ThemeUtils.getContrastActionBarTitleColor(activity, themeId, barColor);
final Toolbar actionBarView = activity.getActionBarToolbar();
if (actionBarView != null) {
actionBarView.setTitleTextColor(titleColor);
actionBarView.setSubtitleTextColor(titleColor);
// actionBarView.setTitleTextColor(titleColor);
// actionBarView.setSubtitleTextColor(titleColor);
ThemeUtils.setActionBarOverflowColor(actionBarView, itemColor);
ThemeUtils.wrapToolbarMenuIcon(ViewSupport.findViewByType(actionBarView, ActionMenuView.class), itemColor, itemColor);
final Drawable navigationIcon = actionBarView.getNavigationIcon();

View File

@ -79,7 +79,7 @@ public class SeekBarDialogPreference extends DialogPreference {
}
// set layout
setDialogLayoutResource(R.layout.preference_seek_bar_dialog);
setDialogLayoutResource(R.layout.dialog_preference_seek_bar);
setPositiveButtonText(android.R.string.ok);
setNegativeButtonText(android.R.string.cancel);
setDialogIcon(null);

View File

@ -120,7 +120,7 @@ public class ThemePreviewPreference extends Preference implements Constants, OnS
cardView.setCardBackgroundColor(cardBackgroundColor);
actionBarView.setTitle(R.string.app_name);
actionBarView.setTitleTextColor(ThemeUtils.getContrastActionBarTitleColor(context, themeId, accentColor));
// actionBarView.setTitleTextColor(ThemeUtils.getContrastActionBarTitleColor(context, themeId, accentColor));
menuBar.setEnabled(false);
final MenuInflater inflater = new SupportMenuInflater(context);
inflater.inflate(R.menu.menu_status, menuBar.getMenu());

View File

@ -0,0 +1,22 @@
package org.mariotaku.twidere.text;
import android.text.SpannableString;
/**
* Created by Ningyuan on 2015/5/1.
*/
public 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);
}
}

View File

@ -0,0 +1,22 @@
package org.mariotaku.twidere.text;
import android.text.SpannableStringBuilder;
/**
* Created by Ningyuan on 2015/5/1.
*/
public 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);
}
}

View File

@ -528,6 +528,7 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
final ContentResolver cr = mContext.getContentResolver();
for (long accountId : params) {
final Twitter twitter = Utils.getTwitterInstance(mContext, accountId, true);
if (twitter == null) continue;
try {
final ResponseList<SavedSearch> searches = twitter.getSavedSearches();
final ContentValues[] values = ContentValuesCreator.createSavedSearches(searches, accountId);

View File

@ -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();

View File

@ -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));
}

View File

@ -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() {

View File

@ -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) {

View File

@ -18,7 +18,6 @@
-->
<org.mariotaku.twidere.view.TintedStatusFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"

View File

@ -20,11 +20,13 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="?android:dividerVertical"
android:orientation="vertical"
android:showDividers="middle">
android:showDividers="middle"
tools:context=".activity.support.RequestPermissionsActivity">
<ScrollView
android:layout_width="match_parent"

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
~ Copyright (C) 2012-2014 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
@ -18,10 +17,38 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<org.mariotaku.twidere.view.TintedStatusFrameLayout
android:id="@+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
<org.mariotaku.twidere.view.TintedStatusFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:setPadding="true"/>
app:setPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/settings_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/twidere_action_bar_container" />
<org.mariotaku.twidere.view.TwidereActionBarContainer
android:id="@+id/twidere_action_bar_container"
style="?attr/actionBarStyle"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:layout_alignParentTop="true"
android:touchscreenBlocksFocus="true"
tools:ignore="UnusedAttribute" />
<View
android:id="@+id/window_overlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/twidere_action_bar_container"
android:background="?android:windowContentOverlay" />
</RelativeLayout>
</org.mariotaku.twidere.view.TintedStatusFrameLayout>

View File

@ -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">
<TextView
android:id="@android:id/text1"

View File

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<org.mariotaku.twidere.view.TwidereToolbar
android:id="@+id/action_bar"
style="?attr/toolbarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:navigationContentDescription="@string/abc_action_bar_up_description" />
app:navigationContentDescription="@string/abc_action_bar_up_description"
app:navigationIcon="?homeAsUpIndicator" />
<android.support.v7.internal.widget.ActionBarContextView
android:id="@+id/action_context_bar"

View File

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 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/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@android:id/icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:contentDescription="@string/icon"
android:scaleType="centerInside"/>
<TextView
android:id="@android:id/title"
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"/>
</LinearLayout>

View File

@ -52,7 +52,8 @@
<item name="cardItemBackgroundColor">@color/background_color_card_item_dark</item>
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_light</item>
<!--<item name="menuIconColor">@color/action_icon_light</item>-->
<item name="menuIconColor">#fff</item>
<item name="menuIconColorActionBar">?menuIconColor</item>
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
</style>
@ -85,7 +86,8 @@
<item name="cardItemBackgroundColor">@color/background_color_card_item_dark</item>
<!-- Twidere specific styles -->
<item name="menuIconColor">@color/action_icon_light</item>
<!--<item name="menuIconColor">@color/action_icon_light</item>-->
<item name="menuIconColor">#fff</item>
<item name="menuIconColorActionBar">?menuIconColor</item>
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
</style>