mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-30 00:15:01 +01:00
trying to improve look and feel on tablets (not finished yet)
supported keyboard shortcut import/export
This commit is contained in:
parent
ee4c2a857c
commit
00281dce88
@ -141,8 +141,6 @@ public interface SharedPreferenceConstants {
|
||||
String KEY_THEME_BACKGROUND = "theme_background";
|
||||
@Preference(type = INT, hasDefault = true, defaultInt = DEFAULT_THEME_BACKGROUND_ALPHA)
|
||||
String KEY_THEME_BACKGROUND_ALPHA = "theme_background_alpha";
|
||||
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = true)
|
||||
String KEY_THEME_DARK_ACTIONBAR = "theme_dark_actionbar";
|
||||
@Preference(type = INT)
|
||||
String KEY_THEME_COLOR = "theme_color";
|
||||
@Preference(type = STRING, hasDefault = true, defaultString = DEFAULT_THEME_FONT_FAMILY)
|
||||
|
@ -80,8 +80,7 @@ dependencies {
|
||||
compile 'com.rengwuxian.materialedittext:library:2.0.3'
|
||||
compile 'com.pnikosis:materialish-progress:1.5'
|
||||
compile 'com.squareup.okhttp:okhttp:2.3.0'
|
||||
// Disabled temporarilly due to attribute clash with subsampling-scale-image-view
|
||||
// compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.3'
|
||||
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.5'
|
||||
compile 'com.github.mariotaku:MessageBubbleView:1.0'
|
||||
compile 'com.github.mariotaku:DragSortListView:0.6.1'
|
||||
compile 'com.github.mariotaku:SlidingMenu:1.3'
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest package="org.mariotaku.twidere"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:installLocation="auto">
|
||||
<manifest
|
||||
package="org.mariotaku.twidere"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-sdk/>
|
||||
|
||||
@ -276,6 +277,7 @@
|
||||
android:label="@string/set_color"
|
||||
android:theme="@style/Theme.Twidere.Light.NoDisplay"/>
|
||||
<activity
|
||||
android:theme="@style/Theme.Twidere.Light.DialogWhenLarge"
|
||||
android:name=".activity.support.LinkHandlerActivity"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<meta-data
|
||||
|
@ -114,6 +114,7 @@ public interface Constants extends TwidereConstants {
|
||||
int MENU_ACCOUNTS = R.id.accounts;
|
||||
int MENU_INVERSE_SELECTION = R.id.inverse_selection;
|
||||
int MENU_EDIT_MEDIA = R.id.edit_media;
|
||||
int MENU_RESET = R.id.reset;
|
||||
|
||||
int LINK_ID_STATUS = 1;
|
||||
int LINK_ID_USER = 2;
|
||||
@ -163,19 +164,6 @@ public interface Constants extends TwidereConstants {
|
||||
|
||||
float DEFAULT_PULL_TO_REFRESH_SCROLL_DISTANCE = 0.3f;
|
||||
|
||||
String ENTRY_PREFERENCES = "preferences.json";
|
||||
String ENTRY_NICKNAMES = "nicknames.json";
|
||||
String ENTRY_USER_COLORS = "user_colors.json";
|
||||
String ENTRY_HOST_MAPPING = "host_mapping.json";
|
||||
|
||||
int FLAG_PREFERENCES = 0x1;
|
||||
int FLAG_NICKNAMES = 0x2;
|
||||
int FLAG_USER_COLORS = 0x4;
|
||||
int FLAG_HOST_MAPPING = 0x8;
|
||||
|
||||
int FLAG_ALL = FLAG_PREFERENCES | FLAG_NICKNAMES | FLAG_USER_COLORS | FLAG_HOST_MAPPING;
|
||||
|
||||
|
||||
int[] PRESET_COLORS = {R.color.material_red, R.color.material_pink,
|
||||
R.color.material_purple, R.color.material_deep_purple, R.color.material_indigo,
|
||||
R.color.material_blue, R.color.material_light_blue, R.color.material_cyan,
|
||||
|
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.app.TwidereApplication;
|
||||
import org.mariotaku.twidere.fragment.support.BasePullToRefreshListFragment;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MessagesManager;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
|
||||
@SuppressLint("Registered")
|
||||
public class BaseActivity extends BaseThemedActivity implements Constants {
|
||||
|
||||
private boolean mInstanceStateSaved, mIsVisible, mIsOnTop;
|
||||
|
||||
public MessagesManager getMessagesManager() {
|
||||
return getTwidereApplication() != null ? getTwidereApplication().getMessagesManager() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThemeColor() {
|
||||
return ThemeUtils.getUserAccentColor(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId() {
|
||||
return ThemeUtils.getThemeResource(this);
|
||||
}
|
||||
|
||||
public TwidereApplication getTwidereApplication() {
|
||||
return (TwidereApplication) getApplication();
|
||||
}
|
||||
|
||||
public AsyncTwitterWrapper getTwitterWrapper() {
|
||||
return getTwidereApplication() != null ? getTwidereApplication().getTwitterWrapper() : null;
|
||||
}
|
||||
|
||||
public boolean isOnTop() {
|
||||
return mIsOnTop;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return mIsVisible;
|
||||
}
|
||||
|
||||
protected BasePullToRefreshListFragment getCurrentPullToRefreshFragment() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean isStateSaved() {
|
||||
return mInstanceStateSaved;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
mIsOnTop = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mInstanceStateSaved = false;
|
||||
mIsOnTop = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(final Bundle outState) {
|
||||
mInstanceStateSaved = true;
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mIsVisible = true;
|
||||
final MessagesManager croutons = getMessagesManager();
|
||||
if (croutons != null) {
|
||||
croutons.addMessageCallback(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
mIsVisible = false;
|
||||
final MessagesManager croutons = getMessagesManager();
|
||||
if (croutons != null) {
|
||||
croutons.removeMessageCallback(this);
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
}
|
@ -38,6 +38,7 @@ import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
||||
import android.support.v4.view.WindowCompat;
|
||||
import android.support.v4.widget.SimpleCursorAdapter;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBar.Tab;
|
||||
@ -131,6 +132,7 @@ public class FiltersActivity extends BaseActionBarActivity implements TabListene
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle savedInstanceState) {
|
||||
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
|
||||
super.onCreate(savedInstanceState);
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
|
||||
setContentView(R.layout.activity_filters);
|
||||
|
@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.WindowCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.view.MenuItem;
|
||||
|
||||
@ -40,6 +41,7 @@ public class AccountsManagerActivity extends BaseActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
|
||||
super.onCreate(savedInstanceState);
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
|
@ -40,6 +40,7 @@ import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v4.view.WindowCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.util.Log;
|
||||
import android.util.SparseBooleanArray;
|
||||
@ -193,6 +194,7 @@ public class DraftsActivity extends BaseActionBarActivity implements LoaderCallb
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
|
||||
super.onCreate(savedInstanceState);
|
||||
mResolver = getContentResolver();
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
|
@ -102,7 +102,7 @@ import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.accessor.ActivityAccessor;
|
||||
import org.mariotaku.twidere.util.accessor.ActivityAccessor.TaskDescriptionCompat;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.util.message.TaskStateChangedEvent;
|
||||
import org.mariotaku.twidere.util.message.UnreadCountUpdatedEvent;
|
||||
import org.mariotaku.twidere.view.ExtendedViewPager;
|
||||
@ -236,11 +236,6 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
||||
notifyControlBarOffsetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId() {
|
||||
return ThemeUtils.getNoActionBarThemeResource(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(final int keyCode, @NonNull final KeyEvent event) {
|
||||
switch (keyCode) {
|
||||
@ -789,7 +784,7 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
||||
final int actionBarAlpha = isTransparent ? ThemeUtils.getUserThemeBackgroundAlpha(this) : 0xFF;
|
||||
final IHomeActionButton homeActionButton = (IHomeActionButton) mActionsButton;
|
||||
mTabIndicator.setItemContext(ThemeUtils.getActionBarContext(this));
|
||||
ViewAccessor.setBackground(mActionBar, ThemeUtils.getActionBarBackground(this, themeResId, themeColor, true));
|
||||
ViewUtils.setBackground(mActionBar, ThemeUtils.getActionBarBackground(this, themeResId, themeColor, true));
|
||||
if (ThemeUtils.isDarkTheme(themeResId)) {
|
||||
final int backgroundColor = ThemeUtils.getThemeBackgroundColor(mTabIndicator.getItemContext());
|
||||
final int foregroundColor = ThemeUtils.getThemeForegroundColor(mTabIndicator.getItemContext());
|
||||
@ -817,7 +812,7 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
||||
}
|
||||
mTabIndicator.setAlpha(actionBarAlpha / 255f);
|
||||
mActionsButton.setAlpha(actionBarAlpha / 255f);
|
||||
ViewAccessor.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
|
||||
ViewUtils.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
|
||||
}
|
||||
|
||||
private void setupHomeTabs() {
|
||||
@ -859,7 +854,7 @@ public class HomeActivity extends BaseActionBarActivity implements OnClickListen
|
||||
mSlidingMenu.setBehindCanvasTransformer(new ListenerCanvasTransformer(this));
|
||||
final Window window = getWindow();
|
||||
final Drawable windowBackground = ThemeUtils.getWindowBackground(this, getCurrentThemeResourceId());
|
||||
ViewAccessor.setBackground(mSlidingMenu.getContent(), windowBackground);
|
||||
ViewUtils.setBackground(mSlidingMenu.getContent(), windowBackground);
|
||||
window.setBackgroundDrawable(new EmptyDrawable(windowBackground));
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.activity.support;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
@ -30,8 +31,11 @@ import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.WindowCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
|
||||
@ -43,6 +47,7 @@ import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCal
|
||||
import org.mariotaku.twidere.fragment.iface.IBasePullToRefreshFragment;
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
|
||||
import org.mariotaku.twidere.fragment.support.SearchFragment;
|
||||
import org.mariotaku.twidere.util.ColorUtils;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler;
|
||||
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.ShortcutCallback;
|
||||
import org.mariotaku.twidere.util.MultiSelectEventHandler;
|
||||
@ -66,12 +71,19 @@ public class LinkHandlerActivity extends BaseActionBarActivity implements System
|
||||
private TintedStatusFrameLayout mMainContent;
|
||||
|
||||
private boolean mFinishOnly;
|
||||
private int mActionBarItemsColor;
|
||||
|
||||
@Override
|
||||
public Fragment getCurrentVisibleFragment() {
|
||||
return getSupportFragmentManager().findFragmentById(R.id.main_content);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId() {
|
||||
return R.style.Theme_Twidere_Light_DialogWhenLarge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachFragment(Fragment fragment) {
|
||||
|
||||
@ -153,6 +165,19 @@ public class LinkHandlerActivity extends BaseActionBarActivity implements System
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onPrepareOptionsPanel(View view, Menu menu) {
|
||||
final boolean result = super.onPrepareOptionsPanel(view, menu);
|
||||
if (mActionBarItemsColor != 0) {
|
||||
final View actionBarView = getWindow().findViewById(android.support.v7.appcompat.R.id.action_bar);
|
||||
if (actionBarView instanceof Toolbar) {
|
||||
((Toolbar) actionBarView).setTitleTextColor(mActionBarItemsColor);
|
||||
ThemeUtils.setActionBarOverflowColor((Toolbar) actionBarView, mActionBarItemsColor);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
mMultiSelectHandler = new MultiSelectEventHandler(this);
|
||||
@ -166,7 +191,7 @@ public class LinkHandlerActivity extends BaseActionBarActivity implements System
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
setActionBarBackground(actionBar, linkId, data);
|
||||
setActionBarTheme(actionBar, linkId, data);
|
||||
}
|
||||
setContentView(R.layout.activity_content_fragment);
|
||||
mMainContent.setOnFitSystemWindowsListener(this);
|
||||
@ -206,6 +231,7 @@ public class LinkHandlerActivity extends BaseActionBarActivity implements System
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
window.addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
}
|
||||
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
|
||||
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY);
|
||||
supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_MODE_OVERLAY);
|
||||
final int transitionRes;
|
||||
@ -230,28 +256,34 @@ public class LinkHandlerActivity extends BaseActionBarActivity implements System
|
||||
}
|
||||
|
||||
@SuppressLint("AppCompatMethod")
|
||||
private void setActionBarBackground(ActionBar actionBar, int linkId, Uri data) {
|
||||
private void setActionBarTheme(ActionBar actionBar, int linkId, Uri data) {
|
||||
final int currentThemeColor = getCurrentThemeColor();
|
||||
int actionBarItemsColor = ColorUtils.getContrastYIQ(currentThemeColor, 192);
|
||||
switch (linkId) {
|
||||
case LINK_ID_USER: {
|
||||
actionBarItemsColor = Color.WHITE;
|
||||
break;
|
||||
}
|
||||
case LINK_ID_SEARCH:
|
||||
case LINK_ID_USER_LISTS: {
|
||||
ThemeUtils.applyActionBarBackground(actionBar, this, getCurrentThemeResourceId(),
|
||||
getCurrentThemeColor(), false);
|
||||
currentThemeColor, false);
|
||||
ThemeUtils.applyActionBarBackground(getActionBar(), this, getCurrentThemeResourceId(),
|
||||
getCurrentThemeColor(), true);
|
||||
currentThemeColor, true);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ThemeUtils.applyActionBarBackground(actionBar, this, getCurrentThemeResourceId(),
|
||||
getCurrentThemeColor(), true);
|
||||
currentThemeColor, true);
|
||||
ThemeUtils.applyActionBarBackground(getActionBar(), this, getCurrentThemeResourceId(),
|
||||
getCurrentThemeColor(), true);
|
||||
currentThemeColor, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (actionBarItemsColor != 0) {
|
||||
ThemeUtils.setActionBarItemsColor(getWindow(), actionBar, actionBarItemsColor);
|
||||
}
|
||||
mActionBarItemsColor = actionBarItemsColor;
|
||||
}
|
||||
|
||||
private void setStatusBarColor(int linkId, Uri uri) {
|
||||
|
@ -68,7 +68,7 @@ import org.mariotaku.twidere.util.ParseUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.TwitterContentUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.util.net.OkHttpClientFactory;
|
||||
import org.mariotaku.twidere.util.net.TwidereHostResolverFactory;
|
||||
|
||||
@ -327,7 +327,7 @@ public class SignInActivity extends BaseActionBarActivity implements TwitterCons
|
||||
mEditPassword.addTextChangedListener(this);
|
||||
final Resources resources = getResources();
|
||||
final ColorStateList color = ColorStateList.valueOf(resources.getColor(R.color.material_light_green));
|
||||
ViewAccessor.setBackgroundTintList(mSignInButton, color);
|
||||
ViewUtils.setBackgroundTintList(mSignInButton, color);
|
||||
setSignInButton();
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.TwitterWrapper;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.view.ForegroundColorView;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView.OnSizeChangedListener;
|
||||
|
||||
@ -118,7 +118,7 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
|
||||
|
||||
@Override
|
||||
public int getThemeResourceId() {
|
||||
return ThemeUtils.getNoActionBarThemeResource(this);
|
||||
return ThemeUtils.getThemeResource(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,8 +137,8 @@ public class UserProfileEditorActivity extends BaseActionBarActivity implements
|
||||
|
||||
setContentView(R.layout.activity_user_profile_editor);
|
||||
setSupportActionBar(mToolbar);
|
||||
ViewAccessor.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
|
||||
ViewAccessor.setBackground(mToolbar, ThemeUtils.getActionBarBackground(mToolbar.getContext(),
|
||||
ViewUtils.setBackground(mActionBarOverlay, ThemeUtils.getWindowContentOverlay(this));
|
||||
ViewUtils.setBackground(mToolbar, ThemeUtils.getActionBarBackground(mToolbar.getContext(),
|
||||
getCurrentThemeResourceId()));
|
||||
// setOverrideExitAniamtion(false);
|
||||
mEditName.addTextChangedListener(this);
|
||||
|
@ -88,6 +88,7 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
|
||||
}
|
||||
|
||||
public void drawVertical(Canvas c, RecyclerView parent) {
|
||||
if (mDivider == null) return;
|
||||
final int left = parent.getPaddingLeft();
|
||||
final int right = parent.getWidth() - parent.getPaddingRight();
|
||||
|
||||
@ -109,6 +110,7 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
|
||||
}
|
||||
|
||||
public void drawHorizontal(Canvas c, RecyclerView parent) {
|
||||
if (mDivider == null) return;
|
||||
final int top = parent.getPaddingTop();
|
||||
final int bottom = parent.getHeight() - parent.getPaddingBottom();
|
||||
|
||||
@ -131,6 +133,7 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, State state) {
|
||||
if (mDivider == null) return;
|
||||
final int childPos = parent.getChildAdapterPosition(view);
|
||||
final int start = getDecorationStart(), end = getDecorationEnd(parent);
|
||||
if (start >= 0 && childPos < start || end >= 0 && childPos > end) {
|
||||
|
@ -81,6 +81,7 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
|
||||
private static final String KEY_UCD_DATA_PROFILING = "ucd_data_profiling";
|
||||
private static final String KEY_SPICE_DATA_PROFILING = "spice_data_profiling";
|
||||
private static final String KEY_KEYBOARD_SHORTCUT_INITIALIZED = "keyboard_shortcut_initialized";
|
||||
|
||||
private Handler mHandler;
|
||||
private MediaLoaderWrapper mMediaLoaderWrapper;
|
||||
@ -143,8 +144,11 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
public KeyboardShortcutsHandler getKeyboardShortcutsHandler() {
|
||||
if (mKeyboardShortcutsHandler != null) return mKeyboardShortcutsHandler;
|
||||
mKeyboardShortcutsHandler = new KeyboardShortcutsHandler(this);
|
||||
if (mKeyboardShortcutsHandler.isEmpty()) {
|
||||
final SharedPreferences preferences = getSharedPreferences();
|
||||
if (mKeyboardShortcutsHandler.isEmpty()
|
||||
&& !preferences.getBoolean(KEY_KEYBOARD_SHORTCUT_INITIALIZED, false)) {
|
||||
mKeyboardShortcutsHandler.reset();
|
||||
preferences.edit().putBoolean(KEY_KEYBOARD_SHORTCUT_INITIALIZED, true);
|
||||
}
|
||||
return mKeyboardShortcutsHandler;
|
||||
}
|
||||
@ -225,8 +229,6 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
mDefaultUserAgent = UserAgentUtils.getDefaultUserAgentString(this);
|
||||
mHandler = new Handler();
|
||||
mMessageBus = new Bus();
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
|
||||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
initializeAsyncTask();
|
||||
initAccountColor(this);
|
||||
initUserColor(this);
|
||||
@ -258,12 +260,13 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
}
|
||||
|
||||
private void migrateUsageStatisticsPreferences() {
|
||||
final boolean hasUsageStatistics = mPreferences.contains(KEY_USAGE_STATISTICS);
|
||||
final SharedPreferences preferences = getSharedPreferences();
|
||||
final boolean hasUsageStatistics = preferences.contains(KEY_USAGE_STATISTICS);
|
||||
if (hasUsageStatistics) return;
|
||||
if (mPreferences.contains(KEY_UCD_DATA_PROFILING) || mPreferences.contains(KEY_SPICE_DATA_PROFILING)) {
|
||||
final boolean prevUsageEnabled = mPreferences.getBoolean(KEY_UCD_DATA_PROFILING, false)
|
||||
|| mPreferences.getBoolean(KEY_SPICE_DATA_PROFILING, false);
|
||||
final Editor editor = mPreferences.edit();
|
||||
if (preferences.contains(KEY_UCD_DATA_PROFILING) || preferences.contains(KEY_SPICE_DATA_PROFILING)) {
|
||||
final boolean prevUsageEnabled = preferences.getBoolean(KEY_UCD_DATA_PROFILING, false)
|
||||
|| preferences.getBoolean(KEY_SPICE_DATA_PROFILING, false);
|
||||
final Editor editor = preferences.edit();
|
||||
editor.putBoolean(KEY_USAGE_STATISTICS, prevUsageEnabled);
|
||||
editor.remove(KEY_UCD_DATA_PROFILING);
|
||||
editor.remove(KEY_SPICE_DATA_PROFILING);
|
||||
@ -271,6 +274,13 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
}
|
||||
}
|
||||
|
||||
private SharedPreferences getSharedPreferences() {
|
||||
if (mPreferences != null) return mPreferences;
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
|
||||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
return mPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
if (mMediaLoaderWrapper != null) {
|
||||
|
@ -23,8 +23,10 @@ import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface.OnKeyListener;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||
@ -38,6 +40,7 @@ import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -53,9 +56,22 @@ public class KeyboardShortcutsFragment extends BasePreferenceFragment {
|
||||
|
||||
private KeyboardShortcutsHandler mKeyboardShortcutHandler;
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_RESET: {
|
||||
final DialogFragment f = new ResetKeyboardShortcutConfirmDialogFragment();
|
||||
f.show(getFragmentManager().beginTransaction(), "reset_keyboard_shortcut_confirm");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
final Activity activity = getActivity();
|
||||
mKeyboardShortcutHandler = TwidereApplication.getInstance(activity).getKeyboardShortcutsHandler();
|
||||
final PreferenceScreen defaultScreen = getPreferenceScreen();
|
||||
@ -213,4 +229,27 @@ public class KeyboardShortcutsFragment extends BasePreferenceFragment {
|
||||
setSummary(spec != null ? spec.toKeyString() : null);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ResetKeyboardShortcutConfirmDialogFragment extends DialogFragment implements OnClickListener {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE: {
|
||||
TwidereApplication app = TwidereApplication.getInstance(getActivity());
|
||||
app.getKeyboardShortcutsHandler().reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.reset_keyboard_shortcuts_confirm);
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, this);
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
||||
import android.content.DialogInterface.OnShowListener;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.View;
|
||||
@ -40,165 +41,168 @@ import android.widget.TextView;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.adapter.ArrayAdapter;
|
||||
import org.mariotaku.twidere.fragment.iface.ISupportDialogFragmentCallback;
|
||||
import org.mariotaku.twidere.util.DataImportExportUtils;
|
||||
|
||||
public final class DataExportImportTypeSelectorDialogFragment extends BaseSupportDialogFragment implements
|
||||
OnMultiChoiceClickListener, OnClickListener, OnShowListener, OnItemClickListener {
|
||||
OnMultiChoiceClickListener, OnClickListener, OnShowListener, OnItemClickListener {
|
||||
|
||||
private TypeAdapter mAdapter;
|
||||
private ListView mListView;
|
||||
private TypeAdapter mAdapter;
|
||||
private ListView mListView;
|
||||
|
||||
@Override
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
final FragmentActivity a = getActivity();
|
||||
if (a instanceof Callback) {
|
||||
((Callback) a).onCancelled(this);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onCancel(final DialogInterface dialog) {
|
||||
super.onCancel(dialog);
|
||||
final FragmentActivity a = getActivity();
|
||||
if (a instanceof Callback) {
|
||||
((Callback) a).onCancelled(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onClick(final DialogInterface dialog, final int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE: {
|
||||
final int flags = getCheckedFlags();
|
||||
onPositiveButtonClicked(flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public final void onClick(final DialogInterface dialog, final int which) {
|
||||
switch (which) {
|
||||
case DialogInterface.BUTTON_POSITIVE: {
|
||||
final int flags = getCheckedFlags();
|
||||
onPositiveButtonClicked(flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onClick(final DialogInterface dialog, final int which, final boolean isChecked) {
|
||||
updatePositiveButton(dialog);
|
||||
}
|
||||
@Override
|
||||
public final void onClick(final DialogInterface dialog, final int which, final boolean isChecked) {
|
||||
updatePositiveButton(dialog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
final Context context = getActivity();
|
||||
final int flags = getEnabledFlags();
|
||||
mAdapter = new TypeAdapter(context, flags);
|
||||
mListView = new ListView(context);
|
||||
mAdapter.add(new Type(R.string.settings, FLAG_PREFERENCES));
|
||||
mAdapter.add(new Type(R.string.nicknames, FLAG_NICKNAMES));
|
||||
mAdapter.add(new Type(R.string.user_colors, FLAG_USER_COLORS));
|
||||
mAdapter.add(new Type(R.string.custom_host_mapping, FLAG_HOST_MAPPING));
|
||||
mListView.setAdapter(mAdapter);
|
||||
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||
mListView.setOnItemClickListener(this);
|
||||
for (int i = 0, j = mAdapter.getCount(); i < j; i++) {
|
||||
mListView.setItemChecked(i, mAdapter.isEnabled(i));
|
||||
}
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(getTitle());
|
||||
builder.setView(mListView);
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(this);
|
||||
return dialog;
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public final Dialog onCreateDialog(final Bundle savedInstanceState) {
|
||||
final Context context = getActivity();
|
||||
final int flags = getEnabledFlags();
|
||||
mAdapter = new TypeAdapter(context, flags);
|
||||
mListView = new ListView(context);
|
||||
mAdapter.add(new Type(R.string.settings, DataImportExportUtils.FLAG_PREFERENCES));
|
||||
mAdapter.add(new Type(R.string.nicknames, DataImportExportUtils.FLAG_NICKNAMES));
|
||||
mAdapter.add(new Type(R.string.user_colors, DataImportExportUtils.FLAG_USER_COLORS));
|
||||
mAdapter.add(new Type(R.string.custom_host_mapping, DataImportExportUtils.FLAG_HOST_MAPPING));
|
||||
mAdapter.add(new Type(R.string.keyboard_shortcuts, DataImportExportUtils.FLAG_KEYBOARD_SHORTCUTS));
|
||||
mListView.setAdapter(mAdapter);
|
||||
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||
mListView.setOnItemClickListener(this);
|
||||
for (int i = 0, j = mAdapter.getCount(); i < j; i++) {
|
||||
mListView.setItemChecked(i, mAdapter.isEnabled(i));
|
||||
}
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(getTitle());
|
||||
builder.setView(mListView);
|
||||
builder.setPositiveButton(android.R.string.ok, this);
|
||||
builder.setNegativeButton(android.R.string.cancel, null);
|
||||
final AlertDialog dialog = builder.create();
|
||||
dialog.setOnShowListener(this);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismiss(final DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
final FragmentActivity a = getActivity();
|
||||
if (a instanceof Callback) {
|
||||
((Callback) a).onDismissed(this);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDismiss(final DialogInterface dialog) {
|
||||
super.onDismiss(dialog);
|
||||
final FragmentActivity a = getActivity();
|
||||
if (a instanceof Callback) {
|
||||
((Callback) a).onDismissed(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(final AdapterView<?> view, final View child, final int position, final long id) {
|
||||
updatePositiveButton(getDialog());
|
||||
}
|
||||
@Override
|
||||
public void onItemClick(final AdapterView<?> view, final View child, final int position, final long id) {
|
||||
updatePositiveButton(getDialog());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onShow(final DialogInterface dialog) {
|
||||
updatePositiveButton(dialog);
|
||||
}
|
||||
@Override
|
||||
public final void onShow(final DialogInterface dialog) {
|
||||
updatePositiveButton(dialog);
|
||||
}
|
||||
|
||||
private int getCheckedFlags() {
|
||||
final SparseBooleanArray checked = mListView.getCheckedItemPositions();
|
||||
int flags = 0;
|
||||
for (int i = 0, j = checked.size(); i < j; i++) {
|
||||
final Type type = (Type) mListView.getItemAtPosition(i);
|
||||
if (checked.valueAt(i)) {
|
||||
flags |= type.flag;
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
private int getCheckedFlags() {
|
||||
final SparseBooleanArray checked = mListView.getCheckedItemPositions();
|
||||
int flags = 0;
|
||||
for (int i = 0, j = checked.size(); i < j; i++) {
|
||||
final Type type = (Type) mListView.getItemAtPosition(i);
|
||||
if (checked.valueAt(i)) {
|
||||
flags |= type.flag;
|
||||
}
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
private int getEnabledFlags() {
|
||||
final Bundle args = getArguments();
|
||||
if (args == null) return FLAG_ALL;
|
||||
return args.getInt(EXTRA_FLAGS, FLAG_ALL);
|
||||
}
|
||||
private int getEnabledFlags() {
|
||||
final Bundle args = getArguments();
|
||||
if (args == null) return DataImportExportUtils.FLAG_ALL;
|
||||
return args.getInt(EXTRA_FLAGS, DataImportExportUtils.FLAG_ALL);
|
||||
}
|
||||
|
||||
private CharSequence getTitle() {
|
||||
final Bundle args = getArguments();
|
||||
if (args == null) return null;
|
||||
return args.getCharSequence(EXTRA_TITLE);
|
||||
}
|
||||
private CharSequence getTitle() {
|
||||
final Bundle args = getArguments();
|
||||
if (args == null) return null;
|
||||
return args.getCharSequence(EXTRA_TITLE);
|
||||
}
|
||||
|
||||
private void onPositiveButtonClicked(final int flags) {
|
||||
final FragmentActivity a = getActivity();
|
||||
final Bundle args = getArguments();
|
||||
if (args == null) return;
|
||||
final String path = args.getString(EXTRA_PATH);
|
||||
if (a instanceof Callback) {
|
||||
((Callback) a).onPositiveButtonClicked(path, flags);
|
||||
}
|
||||
}
|
||||
private void onPositiveButtonClicked(final int flags) {
|
||||
final FragmentActivity a = getActivity();
|
||||
final Bundle args = getArguments();
|
||||
if (args == null) return;
|
||||
final String path = args.getString(EXTRA_PATH);
|
||||
if (a instanceof Callback) {
|
||||
((Callback) a).onPositiveButtonClicked(path, flags);
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePositiveButton(final DialogInterface dialog) {
|
||||
if (!(dialog instanceof AlertDialog)) return;
|
||||
final AlertDialog alertDialog = (AlertDialog) dialog;
|
||||
final Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
positiveButton.setEnabled(getCheckedFlags() != 0);
|
||||
}
|
||||
private void updatePositiveButton(final DialogInterface dialog) {
|
||||
if (!(dialog instanceof AlertDialog)) return;
|
||||
final AlertDialog alertDialog = (AlertDialog) dialog;
|
||||
final Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
positiveButton.setEnabled(getCheckedFlags() != 0);
|
||||
}
|
||||
|
||||
public static interface Callback extends ISupportDialogFragmentCallback {
|
||||
void onPositiveButtonClicked(String path, int flags);
|
||||
}
|
||||
public static interface Callback extends ISupportDialogFragmentCallback {
|
||||
void onPositiveButtonClicked(String path, int flags);
|
||||
}
|
||||
|
||||
private static class Type {
|
||||
private final int title, flag;
|
||||
private static class Type {
|
||||
private final int title, flag;
|
||||
|
||||
Type(final int title, final int flag) {
|
||||
this.title = title;
|
||||
this.flag = flag;
|
||||
}
|
||||
}
|
||||
Type(final int title, final int flag) {
|
||||
this.title = title;
|
||||
this.flag = flag;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TypeAdapter extends ArrayAdapter<Type> {
|
||||
private static class TypeAdapter extends ArrayAdapter<Type> {
|
||||
|
||||
private final int mEnabledFlags;
|
||||
private final int mEnabledFlags;
|
||||
|
||||
public TypeAdapter(final Context context, final int enabledFlags) {
|
||||
super(context, android.R.layout.simple_list_item_multiple_choice);
|
||||
mEnabledFlags = enabledFlags;
|
||||
}
|
||||
public TypeAdapter(final Context context, final int enabledFlags) {
|
||||
super(context, android.R.layout.simple_list_item_multiple_choice);
|
||||
mEnabledFlags = enabledFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areAllItemsEnabled() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean areAllItemsEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
||||
text1.setText(getItem(position).title);
|
||||
view.setEnabled(isEnabled(position));
|
||||
return view;
|
||||
}
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final View view = super.getView(position, convertView, parent);
|
||||
final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
|
||||
text1.setText(getItem(position).title);
|
||||
view.setEnabled(isEnabled(position));
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(final int position) {
|
||||
return (mEnabledFlags & getItem(position).flag) != 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabled(final int position) {
|
||||
return (mEnabledFlags & getItem(position).flag) != 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import org.mariotaku.twidere.fragment.support.TrendsSuggectionsFragment.TrendsAd
|
||||
import org.mariotaku.twidere.provider.TwidereDataStore.CachedTrends;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.view.ExtendedFrameLayout;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView.OnFitSystemWindowsListener;
|
||||
|
||||
@ -127,7 +127,7 @@ public class QuickMenuFragment extends BaseSupportFragment implements OnFitSyste
|
||||
mSlidingUpPanel = (SlidingUpPanelLayout) view.findViewById(R.id.activities_drawer);
|
||||
mActivitiesConfigButton = (ImageButton) view.findViewById(R.id.activities_config_button);
|
||||
final View activitiesContainer = view.findViewById(R.id.activities_container);
|
||||
ViewAccessor.setBackground(activitiesContainer, ThemeUtils.getWindowBackground(getThemedContext()));
|
||||
ViewUtils.setBackground(activitiesContainer, ThemeUtils.getWindowBackground(getThemedContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,6 +57,8 @@ import android.support.v4.content.res.ResourcesCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
@ -85,6 +87,7 @@ import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.AccountSelectorActivity;
|
||||
import org.mariotaku.twidere.activity.support.ColorPickerDialogActivity;
|
||||
import org.mariotaku.twidere.activity.support.LinkHandlerActivity;
|
||||
import org.mariotaku.twidere.activity.support.ThemedActionBarActivity;
|
||||
import org.mariotaku.twidere.activity.support.UserListSelectorActivity;
|
||||
import org.mariotaku.twidere.activity.support.UserProfileEditorActivity;
|
||||
import org.mariotaku.twidere.adapter.support.SupportTabsAdapter;
|
||||
@ -116,9 +119,9 @@ import org.mariotaku.twidere.util.TwidereLinkify;
|
||||
import org.mariotaku.twidere.util.TwidereLinkify.OnLinkClickListener;
|
||||
import org.mariotaku.twidere.util.UserColorNameUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ActivityAccessor;
|
||||
import org.mariotaku.twidere.util.accessor.ActivityAccessor.TaskDescriptionCompat;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
||||
import org.mariotaku.twidere.util.message.FriendshipUpdatedEvent;
|
||||
import org.mariotaku.twidere.util.message.ProfileUpdatedEvent;
|
||||
@ -218,9 +221,11 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
private boolean mGetUserInfoLoaderInitialized, mGetFriendShipLoaderInitialized;
|
||||
private int mBannerWidth;
|
||||
private int mCardBackgroundColor;
|
||||
private int mActionBarShadowColor;
|
||||
private int mUserUiColor;
|
||||
|
||||
private ActionBarDrawable mActionBarBackground;
|
||||
private Drawable mActionBarHomeAsUpIndicator;
|
||||
private Fragment mCurrentVisibleFragment;
|
||||
|
||||
|
||||
@ -413,7 +418,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
public boolean isScrollContent(float x, float y) {
|
||||
final ViewPager v = mViewPager;
|
||||
final int[] location = new int[2];
|
||||
v.getLocationOnScreen(location);
|
||||
v.getLocationInWindow(location);
|
||||
return x >= location[0] && x <= location[0] + v.getWidth()
|
||||
&& y >= location[1] && y <= location[1] + v.getHeight();
|
||||
}
|
||||
@ -652,6 +657,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
mLocale = getResources().getConfiguration().locale;
|
||||
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(activity);
|
||||
mActionBarShadowColor = 0xA0000000;
|
||||
mProfileImageLoader = getApplication().getMediaLoaderWrapper();
|
||||
final Bundle args = getArguments();
|
||||
long accountId = -1, userId = -1;
|
||||
@ -1233,7 +1239,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
if (mActionBarBackground == null) {
|
||||
setupBaseActionBar();
|
||||
}
|
||||
final FragmentActivity activity = getActivity();
|
||||
final ActionBarActivity activity = (ActionBarActivity) getActivity();
|
||||
final IThemedActivity themed = (IThemedActivity) activity;
|
||||
final int themeRes = themed.getCurrentThemeResourceId();
|
||||
if (ThemeUtils.isDarkTheme(themeRes)) {
|
||||
@ -1250,7 +1256,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
mProfileBannerView.setBackgroundColor(color);
|
||||
mLocationView.setLinkTextColor(color);
|
||||
mURLView.setLinkTextColor(color);
|
||||
ViewAccessor.setBackground(mPagerIndicator, ThemeUtils.getActionBarStackedBackground(activity, themeRes, color, true));
|
||||
ViewUtils.setBackground(mPagerIndicator, ThemeUtils.getActionBarStackedBackground(activity, themeRes, color, true));
|
||||
|
||||
final HeaderDrawerLayout drawer = mHeaderDrawerLayout;
|
||||
if (drawer != null) {
|
||||
@ -1270,6 +1276,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
mActionBarBackground.setAlpha(linkHandler.getCurrentThemeBackgroundAlpha());
|
||||
mProfileBannerView.setAlpha(linkHandler.getCurrentThemeBackgroundAlpha() / 255f);
|
||||
actionBar.setBackgroundDrawable(mActionBarBackground);
|
||||
mActionBarHomeAsUpIndicator = ThemeUtils.getActionBarHomeAsUpIndicator(actionBar);
|
||||
actionBar.setHomeAsUpIndicator(mActionBarHomeAsUpIndicator);
|
||||
}
|
||||
|
||||
private void setupUserPages() {
|
||||
@ -1358,35 +1366,43 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
}
|
||||
mActionBarBackground.setOutlineAlphaFactor(tabOutlineAlphaFactor);
|
||||
|
||||
final FragmentActivity activity = getActivity();
|
||||
final ThemedActionBarActivity activity = (ThemedActionBarActivity) getActivity();
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
setCompatToolbarOverlayAlpha(activity, factor * tabOutlineAlphaFactor);
|
||||
}
|
||||
|
||||
if (activity instanceof IThemedActivity) {
|
||||
final Drawable drawable = mPagerIndicator.getBackground();
|
||||
final int stackedTabColor;
|
||||
if (ThemeUtils.isDarkTheme(((IThemedActivity) activity).getCurrentThemeResourceId())) {
|
||||
stackedTabColor = getResources().getColor(R.color.background_color_action_bar_dark);
|
||||
final int contrastColor = ColorUtils.getContrastYIQ(stackedTabColor, 192);
|
||||
mPagerIndicator.setIconColor(contrastColor);
|
||||
mPagerIndicator.setLabelColor(contrastColor);
|
||||
mPagerIndicator.setStripColor(mUserUiColor);
|
||||
} else if (drawable instanceof ColorDrawable) {
|
||||
stackedTabColor = mUserUiColor;
|
||||
final int tabColor = (Integer) sArgbEvaluator.evaluate(tabOutlineAlphaFactor, stackedTabColor, mCardBackgroundColor);
|
||||
((ColorDrawable) drawable).setColor(tabColor);
|
||||
final int contrastColor = ColorUtils.getContrastYIQ(tabColor, 192);
|
||||
mPagerIndicator.setIconColor(contrastColor);
|
||||
mPagerIndicator.setLabelColor(contrastColor);
|
||||
mPagerIndicator.setStripColor(contrastColor);
|
||||
}
|
||||
} else {
|
||||
final int contrastColor = ColorUtils.getContrastYIQ(mUserUiColor, 192);
|
||||
final Drawable drawable = mPagerIndicator.getBackground();
|
||||
final int stackedTabColor;
|
||||
if (ThemeUtils.isDarkTheme(activity.getCurrentThemeResourceId())) {
|
||||
stackedTabColor = getResources().getColor(R.color.background_color_action_bar_dark);
|
||||
final int contrastColor = ColorUtils.getContrastYIQ(stackedTabColor, 192);
|
||||
mPagerIndicator.setIconColor(contrastColor);
|
||||
mPagerIndicator.setLabelColor(contrastColor);
|
||||
mPagerIndicator.setStripColor(mUserUiColor);
|
||||
} else if (drawable instanceof ColorDrawable) {
|
||||
stackedTabColor = mUserUiColor;
|
||||
final int tabColor = (Integer) sArgbEvaluator.evaluate(tabOutlineAlphaFactor, stackedTabColor, mCardBackgroundColor);
|
||||
((ColorDrawable) drawable).setColor(tabColor);
|
||||
final int contrastColor = ColorUtils.getContrastYIQ(tabColor, 192);
|
||||
mPagerIndicator.setIconColor(contrastColor);
|
||||
mPagerIndicator.setLabelColor(contrastColor);
|
||||
mPagerIndicator.setStripColor(contrastColor);
|
||||
} else {
|
||||
// This shouldn't happen, return
|
||||
return;
|
||||
}
|
||||
final int barColor = (Integer) sArgbEvaluator.evaluate(factor, mActionBarShadowColor, stackedTabColor);
|
||||
final int itemColor = ColorUtils.getContrastYIQ(barColor, 192);
|
||||
if (mActionBarHomeAsUpIndicator != null) {
|
||||
mActionBarHomeAsUpIndicator.setColorFilter(itemColor, Mode.SRC_ATOP);
|
||||
}
|
||||
final View actionBarView = activity.getWindow().findViewById(android.support.v7.appcompat.R.id.action_bar);
|
||||
if (actionBarView instanceof Toolbar) {
|
||||
final Toolbar toolbar = (Toolbar) actionBarView;
|
||||
toolbar.setTitleTextColor(itemColor);
|
||||
ThemeUtils.setActionBarOverflowColor(toolbar, itemColor);
|
||||
ThemeUtils.wrapToolbarMenuIcon(toolbar, itemColor, itemColor);
|
||||
}
|
||||
mPagerIndicator.updateAppearance();
|
||||
}
|
||||
@ -1395,7 +1411,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
|
||||
|
||||
private void updateTitleColor() {
|
||||
final int[] location = new int[2];
|
||||
mNameView.getLocationOnScreen(location);
|
||||
mNameView.getLocationInWindow(location);
|
||||
final float nameShowingRatio = (mHeaderDrawerLayout.getPaddingTop() - location[1])
|
||||
/ (float) mNameView.getHeight();
|
||||
final int textAlpha = Math.round(0xFF * MathUtils.clamp(nameShowingRatio, 0, 1));
|
||||
|
@ -30,7 +30,8 @@ import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
||||
*/
|
||||
public class ActionIconDrawable extends DrawableWrapper {
|
||||
|
||||
private final int mDefaultColor;
|
||||
private int mDefaultColor;
|
||||
private int mHighlightColor;
|
||||
|
||||
public ActionIconDrawable(Drawable drawable, int defaultColor) {
|
||||
super(drawable);
|
||||
@ -38,6 +39,16 @@ public class ActionIconDrawable extends DrawableWrapper {
|
||||
setHighlightColor(0);
|
||||
}
|
||||
|
||||
public int getDefaultColor() {
|
||||
return mDefaultColor;
|
||||
}
|
||||
|
||||
public void setDefaultColor(int defaultColor) {
|
||||
mDefaultColor = defaultColor;
|
||||
updateColorFilter();
|
||||
}
|
||||
|
||||
|
||||
public static void setMenuHighlight(MenuItem item, TwidereMenuInfo info) {
|
||||
final Drawable icon = item.getIcon();
|
||||
if (icon instanceof ActionIconDrawable) {
|
||||
@ -46,7 +57,12 @@ public class ActionIconDrawable extends DrawableWrapper {
|
||||
}
|
||||
|
||||
private void setHighlightColor(int color) {
|
||||
setColorFilter(color == 0 ? mDefaultColor : color, Mode.SRC_ATOP);
|
||||
mHighlightColor = color;
|
||||
updateColorFilter();
|
||||
}
|
||||
|
||||
private void updateColorFilter() {
|
||||
setColorFilter(mHighlightColor == 0 ? mDefaultColor : mHighlightColor, Mode.SRC_ATOP);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import android.widget.Switch;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.fragment.SettingsDetailsFragment;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/7.
|
||||
@ -63,7 +64,7 @@ public class SwitchSettingsDetailsPreference extends SwitchPreference implements
|
||||
if (view instanceof ViewGroup) {
|
||||
((ViewGroup) view).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
|
||||
}
|
||||
final Switch switchView = (Switch) findViewByType(view, Switch.class);
|
||||
final Switch switchView = (Switch) ViewUtils.findViewByType(view, Switch.class);
|
||||
if (switchView != null) {
|
||||
switchView.setClickable(true);
|
||||
switchView.setFocusable(true);
|
||||
@ -76,17 +77,6 @@ public class SwitchSettingsDetailsPreference extends SwitchPreference implements
|
||||
return mView = super.onCreateView(parent);
|
||||
}
|
||||
|
||||
private static View findViewByType(View view, Class<? extends View> cls) {
|
||||
if (cls.isAssignableFrom(view.getClass())) return view;
|
||||
if (view instanceof ViewGroup) {
|
||||
for (int i = 0, j = ((ViewGroup) view).getChildCount(); i < j; i++) {
|
||||
final View found = findViewByType(((ViewGroup) view).getChildAt(i), cls);
|
||||
if (found != null) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
|
||||
|
@ -24,7 +24,7 @@ import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.graphic.AlphaPatternDrawable;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 14/11/8.
|
||||
@ -173,7 +173,7 @@ public class ThemeBackgroundPreference extends DialogPreference implements Const
|
||||
mAlphaSlider.setOnSeekBarChangeListener(mAlphaSliderChangedListener);
|
||||
mAlphaSlider.setProgress(preferences.getInt(KEY_THEME_BACKGROUND_ALPHA, DEFAULT_THEME_BACKGROUND_ALPHA));
|
||||
final int patternSize = res.getDimensionPixelSize(R.dimen.element_spacing_msmall);
|
||||
ViewAccessor.setBackground(mAlphaPreview, new AlphaPatternDrawable(patternSize));
|
||||
ViewUtils.setBackground(mAlphaPreview, new AlphaPatternDrawable(patternSize));
|
||||
updateAlphaVisibility();
|
||||
updateAlphaPreview();
|
||||
|
||||
|
@ -42,7 +42,7 @@ import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.util.ColorUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView;
|
||||
import org.mariotaku.twidere.view.iface.IExtendedView.TouchInterceptor;
|
||||
|
||||
@ -109,10 +109,10 @@ public class ThemePreviewPreference extends Preference implements Constants, OnS
|
||||
final int cardBackgroundColor = ThemeUtils.getCardBackgroundColor(context);
|
||||
final int accentColor = ThemeUtils.getUserAccentColor(context);
|
||||
|
||||
ViewAccessor.setBackground(windowBackgroundView, ThemeUtils.getWindowBackground(context));
|
||||
ViewUtils.setBackground(windowBackgroundView, ThemeUtils.getWindowBackground(context));
|
||||
// ViewAccessor.setBackground(windowContentOverlayView, ThemeUtils.getWindowContentOverlay(context));
|
||||
ViewAccessor.setBackground(actionBarView, ThemeUtils.getActionBarBackground(context, themeRes, accentColor, true));
|
||||
ViewAccessor.setBackground(actionBarOverlay, ThemeUtils.getWindowContentOverlay(context));
|
||||
ViewUtils.setBackground(actionBarView, ThemeUtils.getActionBarBackground(context, themeRes, accentColor, true));
|
||||
ViewUtils.setBackground(actionBarOverlay, ThemeUtils.getWindowContentOverlay(context));
|
||||
cardView.setCardBackgroundColor(cardBackgroundColor);
|
||||
|
||||
actionBarView.setTitle(R.string.app_name);
|
||||
@ -122,7 +122,7 @@ public class ThemePreviewPreference extends Preference implements Constants, OnS
|
||||
inflater.inflate(R.menu.menu_status, menuBar.getMenu());
|
||||
ThemeUtils.wrapMenuIcon(menuBar, MENU_GROUP_STATUS_SHARE);
|
||||
if (statusContentView != null) {
|
||||
ViewAccessor.setBackground(statusContentView, ThemeUtils.getWindowBackground(context));
|
||||
ViewUtils.setBackground(statusContentView, ThemeUtils.getWindowBackground(context));
|
||||
|
||||
final View profileView = statusContentView.findViewById(R.id.profile_container);
|
||||
final ImageView profileImageView = (ImageView) statusContentView.findViewById(R.id.profile_image);
|
||||
|
@ -540,11 +540,15 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
final String[] credentialsCols = {Accounts.BASIC_AUTH_PASSWORD, Accounts.OAUTH_TOKEN,
|
||||
Accounts.OAUTH_TOKEN_SECRET, Accounts.CONSUMER_KEY, Accounts.CONSUMER_SECRET};
|
||||
if (projection == null || TwidereArrayUtils.contains(projection, credentialsCols)
|
||||
&& !checkPermission(PERMISSION_ACCOUNTS))
|
||||
&& !checkPermission(PERMISSION_ACCOUNTS)) {
|
||||
final String pkgName = mPermissionsManager.getPackageNameByUid(Binder.getCallingUid());
|
||||
throw new SecurityException("Access column " + TwidereArrayUtils.toString(projection, ',', true)
|
||||
+ " in database accounts requires level PERMISSION_LEVEL_ACCOUNTS");
|
||||
if (!checkPermission(PERMISSION_READ))
|
||||
throw new SecurityException("Access database " + table + " requires level PERMISSION_LEVEL_READ");
|
||||
+ " in database accounts requires level PERMISSION_LEVEL_ACCOUNTS, package: " + pkgName);
|
||||
}
|
||||
if (!checkPermission(PERMISSION_READ)) {
|
||||
final String pkgName = mPermissionsManager.getPackageNameByUid(Binder.getCallingUid());
|
||||
throw new SecurityException("Access database " + table + " requires level PERMISSION_LEVEL_READ, package: " + pkgName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TABLE_ID_DIRECT_MESSAGES:
|
||||
@ -734,9 +738,14 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
}
|
||||
|
||||
private void notifyContentObserver(final Uri uri) {
|
||||
final ContentResolver cr = getContentResolver();
|
||||
if (uri == null || cr == null) return;
|
||||
cr.notifyChange(uri, null);
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ContentResolver cr = getContentResolver();
|
||||
if (uri == null || cr == null) return;
|
||||
cr.notifyChange(uri, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.mariotaku.jsonserializer.JSONFileIO;
|
||||
@ -47,136 +48,158 @@ import static org.mariotaku.twidere.annotation.Preference.Type.INVALID;
|
||||
|
||||
public class DataImportExportUtils implements Constants {
|
||||
|
||||
public static void exportData(final Context context, final File dst, final int flags) throws IOException {
|
||||
if (dst == null) throw new FileNotFoundException();
|
||||
dst.delete();
|
||||
final FileOutputStream fos = new FileOutputStream(dst);
|
||||
final ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));
|
||||
if (hasFlag(flags, FLAG_PREFERENCES)) {
|
||||
writeSharedPreferencesData(zos, context, SHARED_PREFERENCES_NAME, ENTRY_PREFERENCES);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_NICKNAMES)) {
|
||||
writeRawSharedPreferencesData(zos, context, USER_NICKNAME_PREFERENCES_NAME, ENTRY_NICKNAMES);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_USER_COLORS)) {
|
||||
writeRawSharedPreferencesData(zos, context, USER_COLOR_PREFERENCES_NAME, ENTRY_USER_COLORS);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_HOST_MAPPING)) {
|
||||
writeRawSharedPreferencesData(zos, context, HOST_MAPPING_PREFERENCES_NAME, ENTRY_HOST_MAPPING);
|
||||
}
|
||||
zos.finish();
|
||||
zos.flush();
|
||||
Utils.closeSilently(zos);
|
||||
Utils.closeSilently(fos);
|
||||
}
|
||||
public static final String ENTRY_PREFERENCES = "preferences.json";
|
||||
public static final String ENTRY_NICKNAMES = "nicknames.json";
|
||||
public static final String ENTRY_USER_COLORS = "user_colors.json";
|
||||
public static final String ENTRY_HOST_MAPPING = "host_mapping.json";
|
||||
public static final String ENTRY_KEYBOARD_SHORTCUTS = "keyboard_shortcuts.json";
|
||||
|
||||
public static int getImportedSettingsFlags(final File src) throws IOException {
|
||||
if (src == null) return 0;
|
||||
final ZipFile zipFile = new ZipFile(src);
|
||||
int flags = 0;
|
||||
if (zipFile.getEntry(ENTRY_PREFERENCES) != null) {
|
||||
flags |= FLAG_PREFERENCES;
|
||||
}
|
||||
if (zipFile.getEntry(ENTRY_NICKNAMES) != null) {
|
||||
flags |= FLAG_NICKNAMES;
|
||||
}
|
||||
if (zipFile.getEntry(ENTRY_USER_COLORS) != null) {
|
||||
flags |= FLAG_USER_COLORS;
|
||||
}
|
||||
if (zipFile.getEntry(ENTRY_HOST_MAPPING) != null) {
|
||||
flags |= FLAG_HOST_MAPPING;
|
||||
}
|
||||
zipFile.close();
|
||||
return flags;
|
||||
}
|
||||
public static final int FLAG_PREFERENCES = 0x1;
|
||||
public static final int FLAG_NICKNAMES = 0x2;
|
||||
public static final int FLAG_USER_COLORS = 0x4;
|
||||
public static final int FLAG_HOST_MAPPING = 0x8;
|
||||
public static final int FLAG_KEYBOARD_SHORTCUTS = 0x10;
|
||||
public static final int FLAG_ALL = FLAG_PREFERENCES | FLAG_NICKNAMES | FLAG_USER_COLORS | FLAG_HOST_MAPPING | FLAG_KEYBOARD_SHORTCUTS;
|
||||
|
||||
public static HashMap<String, Preference> getSupportedPreferencesMap() {
|
||||
final Field[] fields = SharedPreferenceConstants.class.getDeclaredFields();
|
||||
final HashMap<String, Preference> supportedPrefsMap = new HashMap<String, Preference>();
|
||||
for (final Field field : fields) {
|
||||
final Preference annotation = field.getAnnotation(Preference.class);
|
||||
if (Modifier.isStatic(field.getModifiers()) && CompareUtils.classEquals(field.getType(), String.class)
|
||||
&& annotation != null && annotation.exportable() && annotation.type() != INVALID) {
|
||||
try {
|
||||
supportedPrefsMap.put((String) field.get(null), annotation);
|
||||
} catch (final IllegalAccessException e) {
|
||||
} catch (final IllegalArgumentException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return supportedPrefsMap;
|
||||
}
|
||||
public static void exportData(final Context context, final File dst, final int flags) throws IOException {
|
||||
if (dst == null) throw new FileNotFoundException();
|
||||
dst.delete();
|
||||
final FileOutputStream fos = new FileOutputStream(dst);
|
||||
final ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));
|
||||
if (hasFlag(flags, FLAG_PREFERENCES)) {
|
||||
writeSharedPreferencesData(zos, context, SHARED_PREFERENCES_NAME, ENTRY_PREFERENCES);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_NICKNAMES)) {
|
||||
writeRawSharedPreferencesData(zos, context, USER_NICKNAME_PREFERENCES_NAME, ENTRY_NICKNAMES);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_USER_COLORS)) {
|
||||
writeRawSharedPreferencesData(zos, context, USER_COLOR_PREFERENCES_NAME, ENTRY_USER_COLORS);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_HOST_MAPPING)) {
|
||||
writeRawSharedPreferencesData(zos, context, HOST_MAPPING_PREFERENCES_NAME, ENTRY_HOST_MAPPING);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_KEYBOARD_SHORTCUTS)) {
|
||||
writeRawSharedPreferencesData(zos, context, KEYBOARD_SHORTCUTS_PREFERENCES_NAME, ENTRY_KEYBOARD_SHORTCUTS);
|
||||
}
|
||||
zos.finish();
|
||||
zos.flush();
|
||||
Utils.closeSilently(zos);
|
||||
Utils.closeSilently(fos);
|
||||
}
|
||||
|
||||
public static void importData(final Context context, final File src, final int flags) throws IOException {
|
||||
if (src == null) throw new FileNotFoundException();
|
||||
final ZipFile zipFile = new ZipFile(src);
|
||||
if (hasFlag(flags, FLAG_PREFERENCES)) {
|
||||
readSharedPreferencesData(zipFile, context, SHARED_PREFERENCES_NAME, ENTRY_PREFERENCES);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_NICKNAMES)) {
|
||||
readRawSharedPreferencesData(zipFile, context, USER_NICKNAME_PREFERENCES_NAME, ENTRY_NICKNAMES);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_USER_COLORS)) {
|
||||
readRawSharedPreferencesData(zipFile, context, USER_COLOR_PREFERENCES_NAME, ENTRY_USER_COLORS);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_HOST_MAPPING)) {
|
||||
readRawSharedPreferencesData(zipFile, context, HOST_MAPPING_PREFERENCES_NAME, ENTRY_HOST_MAPPING);
|
||||
}
|
||||
zipFile.close();
|
||||
}
|
||||
public static int getImportedSettingsFlags(final File src) throws IOException {
|
||||
if (src == null) return 0;
|
||||
final ZipFile zipFile = new ZipFile(src);
|
||||
int flags = 0;
|
||||
if (zipFile.getEntry(ENTRY_PREFERENCES) != null) {
|
||||
flags |= FLAG_PREFERENCES;
|
||||
}
|
||||
if (zipFile.getEntry(ENTRY_NICKNAMES) != null) {
|
||||
flags |= FLAG_NICKNAMES;
|
||||
}
|
||||
if (zipFile.getEntry(ENTRY_USER_COLORS) != null) {
|
||||
flags |= FLAG_USER_COLORS;
|
||||
}
|
||||
if (zipFile.getEntry(ENTRY_HOST_MAPPING) != null) {
|
||||
flags |= FLAG_HOST_MAPPING;
|
||||
}
|
||||
if (zipFile.getEntry(ENTRY_KEYBOARD_SHORTCUTS) != null) {
|
||||
flags |= FLAG_KEYBOARD_SHORTCUTS;
|
||||
}
|
||||
zipFile.close();
|
||||
return flags;
|
||||
}
|
||||
|
||||
private static byte[] getSerializedRawSharedPreferencesData(final Context context, final String name) {
|
||||
final SharedPreferences prefs = context.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||
return JSONSerializer.getByteArray(new RawSharedPreferencesData(prefs));
|
||||
}
|
||||
public static HashMap<String, Preference> getSupportedPreferencesMap() {
|
||||
final Field[] fields = SharedPreferenceConstants.class.getDeclaredFields();
|
||||
final HashMap<String, Preference> supportedPrefsMap = new HashMap<String, Preference>();
|
||||
for (final Field field : fields) {
|
||||
final Preference annotation = field.getAnnotation(Preference.class);
|
||||
if (Modifier.isStatic(field.getModifiers()) && CompareUtils.classEquals(field.getType(), String.class)
|
||||
&& annotation != null && annotation.exportable() && annotation.type() != INVALID) {
|
||||
try {
|
||||
supportedPrefsMap.put((String) field.get(null), annotation);
|
||||
} catch (final IllegalAccessException | IllegalArgumentException e) {
|
||||
Log.w(LOGTAG, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return supportedPrefsMap;
|
||||
}
|
||||
|
||||
private static byte[] getSerializedSharedPreferencesData(final Context context, final String name) {
|
||||
final SharedPreferences prefs = context.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||
return JSONSerializer.getByteArray(new SharedPreferencesData(prefs));
|
||||
}
|
||||
public static void importData(final Context context, final File src, final int flags) throws IOException {
|
||||
if (src == null) throw new FileNotFoundException();
|
||||
final ZipFile zipFile = new ZipFile(src);
|
||||
if (hasFlag(flags, FLAG_PREFERENCES)) {
|
||||
readSharedPreferencesData(zipFile, context, SHARED_PREFERENCES_NAME, ENTRY_PREFERENCES);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_NICKNAMES)) {
|
||||
readRawSharedPreferencesData(zipFile, context, USER_NICKNAME_PREFERENCES_NAME, ENTRY_NICKNAMES);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_USER_COLORS)) {
|
||||
readRawSharedPreferencesData(zipFile, context, USER_COLOR_PREFERENCES_NAME, ENTRY_USER_COLORS);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_HOST_MAPPING)) {
|
||||
readRawSharedPreferencesData(zipFile, context, HOST_MAPPING_PREFERENCES_NAME, ENTRY_HOST_MAPPING);
|
||||
}
|
||||
if (hasFlag(flags, FLAG_KEYBOARD_SHORTCUTS)) {
|
||||
readRawSharedPreferencesData(zipFile, context, KEYBOARD_SHORTCUTS_PREFERENCES_NAME, ENTRY_KEYBOARD_SHORTCUTS);
|
||||
}
|
||||
zipFile.close();
|
||||
}
|
||||
|
||||
private static boolean hasFlag(final int flags, final int flag) {
|
||||
return (flags & flag) != 0;
|
||||
}
|
||||
private static byte[] getSerializedRawSharedPreferencesData(final Context context, final String name) {
|
||||
final SharedPreferences prefs = context.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||
return JSONSerializer.getByteArray(new RawSharedPreferencesData(prefs));
|
||||
}
|
||||
|
||||
private static void readRawSharedPreferencesData(final ZipFile zipFile, final Context context,
|
||||
final String preferencesName, final String entryName) throws IOException {
|
||||
final ZipEntry entry = zipFile.getEntry(entryName);
|
||||
if (entry == null) return;
|
||||
final JSONObject json = JSONFileIO.convertJSONObject(zipFile.getInputStream(entry));
|
||||
final RawSharedPreferencesData data = JSONSerializer.createObject(RawSharedPreferencesData.JSON_CREATOR, json);
|
||||
if (data != null) {
|
||||
data.writeToSharedPreferences(context.getSharedPreferences(preferencesName, Context.MODE_PRIVATE));
|
||||
}
|
||||
}
|
||||
private static byte[] getSerializedSharedPreferencesData(final Context context, final String name) {
|
||||
final SharedPreferences prefs = context.getSharedPreferences(name, Context.MODE_PRIVATE);
|
||||
return JSONSerializer.getByteArray(new SharedPreferencesData(prefs));
|
||||
}
|
||||
|
||||
private static void readSharedPreferencesData(final ZipFile zipFile, final Context context,
|
||||
final String preferencesName, final String entryName) throws IOException {
|
||||
final ZipEntry entry = zipFile.getEntry(entryName);
|
||||
if (entry == null) return;
|
||||
final JSONObject json = JSONFileIO.convertJSONObject(zipFile.getInputStream(entry));
|
||||
final SharedPreferencesData data = JSONSerializer.createObject(SharedPreferencesData.JSON_CREATOR, json);
|
||||
if (data != null) {
|
||||
data.writeToSharedPreferences(context.getSharedPreferences(preferencesName, Context.MODE_PRIVATE));
|
||||
}
|
||||
}
|
||||
private static boolean hasFlag(final int flags, final int flag) {
|
||||
return (flags & flag) != 0;
|
||||
}
|
||||
|
||||
private static void writeRawSharedPreferencesData(final ZipOutputStream zos, final Context context,
|
||||
final String preferencesName, final String entryName) throws IOException {
|
||||
final byte[] data = getSerializedRawSharedPreferencesData(context, preferencesName);
|
||||
if (data == null) return;
|
||||
zos.putNextEntry(new ZipEntry(entryName));
|
||||
zos.write(data);
|
||||
zos.closeEntry();
|
||||
}
|
||||
private static void readRawSharedPreferencesData(final ZipFile zipFile, final Context context,
|
||||
final String preferencesName, final String entryName) throws IOException {
|
||||
final ZipEntry entry = zipFile.getEntry(entryName);
|
||||
if (entry == null) return;
|
||||
final JSONObject json = JSONFileIO.convertJSONObject(zipFile.getInputStream(entry));
|
||||
final RawSharedPreferencesData data = JSONSerializer.createObject(RawSharedPreferencesData.JSON_CREATOR, json);
|
||||
if (data != null) {
|
||||
data.writeToSharedPreferences(context.getSharedPreferences(preferencesName, Context.MODE_PRIVATE));
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeSharedPreferencesData(final ZipOutputStream zos, final Context context,
|
||||
final String preferencesName, final String entryName) throws IOException {
|
||||
final byte[] data = getSerializedSharedPreferencesData(context, preferencesName);
|
||||
if (data == null) return;
|
||||
zos.putNextEntry(new ZipEntry(entryName));
|
||||
zos.write(data);
|
||||
zos.closeEntry();
|
||||
}
|
||||
private static void readSharedPreferencesData(final ZipFile zipFile, final Context context,
|
||||
final String preferencesName, final String entryName) throws IOException {
|
||||
final ZipEntry entry = zipFile.getEntry(entryName);
|
||||
if (entry == null) return;
|
||||
final JSONObject json = JSONFileIO.convertJSONObject(zipFile.getInputStream(entry));
|
||||
final SharedPreferencesData data = JSONSerializer.createObject(SharedPreferencesData.JSON_CREATOR, json);
|
||||
if (data != null) {
|
||||
data.writeToSharedPreferences(context.getSharedPreferences(preferencesName, Context.MODE_PRIVATE));
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeRawSharedPreferencesData(final ZipOutputStream zos, final Context context,
|
||||
final String preferencesName, final String entryName) throws IOException {
|
||||
final byte[] data = getSerializedRawSharedPreferencesData(context, preferencesName);
|
||||
if (data == null) return;
|
||||
zos.putNextEntry(new ZipEntry(entryName));
|
||||
zos.write(data);
|
||||
zos.closeEntry();
|
||||
}
|
||||
|
||||
private static void writeSharedPreferencesData(final ZipOutputStream zos, final Context context,
|
||||
final String preferencesName, final String entryName) throws IOException {
|
||||
final byte[] data = getSerializedSharedPreferencesData(context, preferencesName);
|
||||
if (data == null) return;
|
||||
zos.putNextEntry(new ZipEntry(entryName));
|
||||
zos.write(data);
|
||||
zos.closeEntry();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -76,8 +76,7 @@ public class PermissionsManager implements Constants {
|
||||
}
|
||||
|
||||
public boolean checkSignature(final int uid) {
|
||||
final String pname = getPackageNameByUid(uid);
|
||||
return checkSignature(pname);
|
||||
return checkSignature(getPackageNameByUid(uid));
|
||||
}
|
||||
|
||||
public boolean checkSignature(final String pname) {
|
||||
|
@ -43,6 +43,7 @@ import android.support.v7.internal.view.SupportActionModeWrapperTrojan;
|
||||
import android.support.v7.internal.view.menu.ActionMenuItemView;
|
||||
import android.support.v7.internal.widget.ActionBarOverlayLayout;
|
||||
import android.support.v7.widget.ActionMenuView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
@ -55,7 +56,9 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.Window;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
@ -66,7 +69,6 @@ import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.graphic.ActionBarColorDrawable;
|
||||
import org.mariotaku.twidere.graphic.ActionIconDrawable;
|
||||
import org.mariotaku.twidere.text.ParagraphSpacingSpan;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
|
||||
import org.mariotaku.twidere.view.TabPagerIndicator;
|
||||
import org.mariotaku.twidere.view.iface.IThemedView;
|
||||
@ -157,7 +159,7 @@ public class ThemeUtils implements Constants {
|
||||
contextViewField.setAccessible(true);
|
||||
final View view = (View) contextViewField.get(actionBar);
|
||||
if (view == null) return;
|
||||
ViewAccessor.setBackground(view, getActionBarBackground(activity, themeRes, accentColor, outlineEnabled));
|
||||
ViewUtils.setBackground(view, getActionBarBackground(activity, themeRes, accentColor, outlineEnabled));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -183,7 +185,7 @@ public class ThemeUtils implements Constants {
|
||||
final int themeRes = ((IThemedActivity) activity).getCurrentThemeResourceId();
|
||||
final int themeColor = ((IThemedActivity) activity).getCurrentThemeColor();
|
||||
final int contrastColor = ColorUtils.getContrastYIQ(themeColor, 192);
|
||||
ViewAccessor.setBackground(indicator, getActionBarStackedBackground(activity, themeRes, themeColor, true));
|
||||
ViewUtils.setBackground(indicator, getActionBarStackedBackground(activity, themeRes, themeColor, true));
|
||||
if (isDarkTheme(themeRes)) {
|
||||
final int foregroundColor = getThemeForegroundColor(activity);
|
||||
indicator.setIconColor(foregroundColor);
|
||||
@ -217,6 +219,26 @@ public class ThemeUtils implements Constants {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public static void setActionBarOverflowColor(Toolbar toolbar, int itemColor) {
|
||||
if (toolbar == null) return;
|
||||
final ActionMenuView actionMenuView = ViewUtils.findViewByType(toolbar, ActionMenuView.class);
|
||||
if (actionMenuView == null) return;
|
||||
View overflowView = null;
|
||||
for (int i = 0, j = actionMenuView.getChildCount(); i < j; i++) {
|
||||
final View child = actionMenuView.getChildAt(i);
|
||||
final ActionMenuView.LayoutParams lp = (ActionMenuView.LayoutParams) child.getLayoutParams();
|
||||
if (lp.isOverflowButton) {
|
||||
overflowView = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(overflowView instanceof ImageView)) return;
|
||||
final Drawable drawable = ((ImageView) overflowView).getDrawable();
|
||||
if (drawable == null) return;
|
||||
drawable.setColorFilter(itemColor, Mode.SRC_ATOP);
|
||||
}
|
||||
|
||||
public static void setCompatToolbarOverlay(Activity activity, Drawable background) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return;
|
||||
final View view = activity.getWindow().findViewById(android.support.v7.appcompat.R.id.decor_content_parent);
|
||||
@ -243,6 +265,11 @@ public class ThemeUtils implements Constants {
|
||||
if (ArrayUtils.contains(excludeGroups, item.getGroupId())) return;
|
||||
final Drawable icon = item.getIcon();
|
||||
if (icon == null) return;
|
||||
if (icon instanceof ActionIconDrawable) {
|
||||
((ActionIconDrawable) icon).setDefaultColor(itemColor);
|
||||
item.setIcon(icon);
|
||||
return;
|
||||
}
|
||||
icon.mutate();
|
||||
final Drawable.Callback callback = icon.getCallback();
|
||||
final ActionIconDrawable newIcon = new ActionIconDrawable(icon, itemColor);
|
||||
@ -250,12 +277,17 @@ public class ThemeUtils implements Constants {
|
||||
item.setIcon(newIcon);
|
||||
}
|
||||
|
||||
|
||||
public static void wrapMenuIcon(ActionMenuView view, int... excludeGroups) {
|
||||
final int itemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext());
|
||||
final int popupItemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext(), view.getPopupTheme());
|
||||
final Resources resources = view.getResources();
|
||||
final int colorDark = resources.getColor(R.color.action_icon_dark);
|
||||
final int colorLight = resources.getColor(R.color.action_icon_light);
|
||||
wrapMenuIcon(view, colorDark, colorLight, excludeGroups);
|
||||
}
|
||||
|
||||
public static void wrapMenuIcon(ActionMenuView view, int colorDark, int colorLight, int... excludeGroups) {
|
||||
final int itemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext());
|
||||
final int popupItemBackgroundColor = ThemeUtils.getThemeBackgroundColor(view.getContext(), view.getPopupTheme());
|
||||
final int itemColor = ColorUtils.getContrastYIQ(itemBackgroundColor, colorDark, colorLight);
|
||||
final int popupItemColor = ColorUtils.getContrastYIQ(popupItemBackgroundColor, colorDark, colorLight);
|
||||
final Menu menu = view.getMenu();
|
||||
@ -272,6 +304,21 @@ public class ThemeUtils implements Constants {
|
||||
}
|
||||
}
|
||||
|
||||
public static void wrapToolbarMenuIcon(Toolbar view, int itemColor, int popupItemColor, int... excludeGroups) {
|
||||
final Menu menu = view.getMenu();
|
||||
final int childCount = view.getChildCount();
|
||||
for (int i = 0, j = menu.size(), k = 0; i < j; i++) {
|
||||
final MenuItem item = menu.getItem(i);
|
||||
wrapMenuItemIcon(item, itemColor, excludeGroups);
|
||||
if (item.hasSubMenu()) {
|
||||
wrapMenuIcon(menu, popupItemColor, popupItemColor, excludeGroups);
|
||||
}
|
||||
if (item.isVisible()) {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void wrapMenuIcon(Context context, Menu menu, int... excludeGroups) {
|
||||
final int backgroundColor = ThemeUtils.getThemeBackgroundColor(context);
|
||||
@ -416,13 +463,13 @@ public class ThemeUtils implements Constants {
|
||||
} else if (view instanceof ProgressBar) {
|
||||
final ColorStateList tintList = ColorStateList.valueOf(tintColor);
|
||||
final ProgressBar progressBar = (ProgressBar) view;
|
||||
ViewAccessor.setProgressTintList(progressBar, tintList);
|
||||
ViewAccessor.setProgressBackgroundTintList(progressBar, tintList);
|
||||
ViewAccessor.setIndeterminateTintList(progressBar, tintList);
|
||||
ViewUtils.setProgressTintList(progressBar, tintList);
|
||||
ViewUtils.setProgressBackgroundTintList(progressBar, tintList);
|
||||
ViewUtils.setIndeterminateTintList(progressBar, tintList);
|
||||
} else if (view instanceof CompoundButton) {
|
||||
final ColorStateList tintList = ColorStateList.valueOf(tintColor);
|
||||
final CompoundButton compoundButton = (CompoundButton) view;
|
||||
ViewAccessor.setButtonTintList(compoundButton, tintList);
|
||||
ViewUtils.setButtonTintList(compoundButton, tintList);
|
||||
}
|
||||
// TODO support TintableBackgroundView
|
||||
}
|
||||
@ -521,23 +568,6 @@ public class ThemeUtils implements Constants {
|
||||
return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
|
||||
}
|
||||
|
||||
public static int getActionIconColor(final int themeRes) {
|
||||
switch (themeRes) {
|
||||
case R.style.Theme_Twidere_Light:
|
||||
case R.style.Theme_Twidere_Light_SolidBackground:
|
||||
case R.style.Theme_Twidere_Light_Transparent:
|
||||
case R.style.Theme_Twidere_Light_Compose:
|
||||
case R.style.Theme_Twidere_Light_Dialog:
|
||||
case R.style.Theme_Twidere_ActionBar_Colored_Light:
|
||||
case R.style.Theme_Twidere_Settings_Light:
|
||||
case R.style.Theme_Twidere_Drawer_Light:
|
||||
case R.style.Theme_Twidere_Drawer_Light_Transparent:
|
||||
case R.style.Theme_Twidere_Settings_Light_DarkActionBar_DarkIcon:
|
||||
return 0x99333333;
|
||||
}
|
||||
return 0xCCFFFFFF;
|
||||
}
|
||||
|
||||
public static int getColorBackgroundCacheHint(final Context context) {
|
||||
final TypedArray a = context.obtainStyledAttributes(new int[]{android.R.attr.colorBackgroundCacheHint});
|
||||
final int color = a.getColor(0, Color.TRANSPARENT);
|
||||
@ -554,20 +584,14 @@ public class ThemeUtils implements Constants {
|
||||
}
|
||||
|
||||
public static int getComposeThemeResource(final Context context) {
|
||||
return getComposeThemeResource(getThemeNameOption(context), getDarkActionBarOption(context));
|
||||
return getComposeThemeResource(getThemeNameOption(context));
|
||||
}
|
||||
|
||||
public static int getComposeThemeResource(final String name, final boolean darkActionBar) {
|
||||
public static int getComposeThemeResource(final String name) {
|
||||
if (VALUE_THEME_NAME_DARK.equals(name)) return R.style.Theme_Twidere_Dark_Compose;
|
||||
return R.style.Theme_Twidere_Light_Compose;
|
||||
}
|
||||
|
||||
public static boolean getDarkActionBarOption(final Context context) {
|
||||
if (context == null) return true;
|
||||
final SharedPreferencesWrapper pref = getSharedPreferencesWrapper(context);
|
||||
return pref.getBoolean(KEY_THEME_DARK_ACTIONBAR, true);
|
||||
}
|
||||
|
||||
public static Context getDialogThemedContext(final Context context) {
|
||||
return new ContextThemeWrapper(context, getDialogThemeResource(context));
|
||||
}
|
||||
@ -614,25 +638,6 @@ public class ThemeUtils implements Constants {
|
||||
return d;
|
||||
}
|
||||
|
||||
public static int getMenuIconColor(final Context context) {
|
||||
return getMenuIconColor(getThemeResource(context));
|
||||
}
|
||||
|
||||
public static int getMenuIconColor(final int themeRes) {
|
||||
switch (themeRes) {
|
||||
case R.style.Theme_Twidere_Light:
|
||||
case R.style.Theme_Twidere_Light_SolidBackground:
|
||||
case R.style.Theme_Twidere_Light_Transparent:
|
||||
case R.style.Theme_Twidere_Light_Compose:
|
||||
case R.style.Theme_Twidere_Light_Dialog:
|
||||
case R.style.Theme_Twidere_ActionBar_Colored_Light:
|
||||
case R.style.Theme_Twidere_Settings_Light:
|
||||
case R.style.Theme_Twidere_Settings_Light_DarkActionBar_DarkIcon:
|
||||
return 0x99333333;
|
||||
}
|
||||
return 0xCCFFFFFF;
|
||||
}
|
||||
|
||||
public static int getNoDisplayThemeResource(final Context context) {
|
||||
if (context == null) return R.style.Theme_Twidere_Dark_NoDisplay;
|
||||
final SharedPreferencesWrapper pref = getSharedPreferencesWrapper(context);
|
||||
@ -659,21 +664,16 @@ public class ThemeUtils implements Constants {
|
||||
}
|
||||
|
||||
public static int getSettingsThemeResource(final Context context) {
|
||||
return getSettingsThemeResource(getThemeNameOption(context), getDarkActionBarOption(context));
|
||||
return getSettingsThemeResource(getThemeNameOption(context));
|
||||
}
|
||||
|
||||
public static int getSettingsThemeResource(final String name, final boolean darkActionBar) {
|
||||
public static int getSettingsThemeResource(final String name) {
|
||||
if (VALUE_THEME_NAME_TWIDERE.equals(name) || VALUE_THEME_NAME_LIGHT.equals(name))
|
||||
return darkActionBar ? R.style.Theme_Twidere_Settings_Light_DarkActionBar
|
||||
: R.style.Theme_Twidere_Settings_Light;
|
||||
return R.style.Theme_Twidere_Settings_Light_DarkActionBar;
|
||||
else if (VALUE_THEME_NAME_DARK.equals(name)) return R.style.Theme_Twidere_Settings_Dark;
|
||||
return R.style.Theme_Twidere_Settings_Light_DarkActionBar;
|
||||
}
|
||||
|
||||
public static int getSettingsWizardThemeResource(final Context context) {
|
||||
return R.style.Theme_Twidere_Settings_Light;
|
||||
}
|
||||
|
||||
public static int getTextAppearanceLarge(final Context context) {
|
||||
// final Context wrapped = getThemedContext(context,
|
||||
// getResources(context));
|
||||
@ -798,33 +798,10 @@ public class ThemeUtils implements Constants {
|
||||
}
|
||||
|
||||
public static int getThemeResource(final Context context) {
|
||||
return getThemeResource(getThemeNameOption(context), getThemeBackgroundOption(context),
|
||||
getDarkActionBarOption(context));
|
||||
return getThemeResource(getThemeNameOption(context), getThemeBackgroundOption(context));
|
||||
}
|
||||
|
||||
public static int getNoActionBarThemeResource(final Context context) {
|
||||
return getNoActionBarThemeResource(getThemeNameOption(context), getThemeBackgroundOption(context),
|
||||
getDarkActionBarOption(context));
|
||||
}
|
||||
|
||||
public static int getNoActionBarThemeResource(final String name, final String background, final boolean darkActionBar) {
|
||||
if (VALUE_THEME_NAME_LIGHT.equals(name)) {
|
||||
if (VALUE_THEME_BACKGROUND_SOLID.equals(background))
|
||||
return R.style.Theme_Twidere_Light_SolidBackground_NoActionBar;
|
||||
else if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(background))
|
||||
return R.style.Theme_Twidere_Light_Transparent_NoActionBar;
|
||||
return R.style.Theme_Twidere_Light_NoActionBar;
|
||||
} else if (VALUE_THEME_NAME_DARK.equals(name)) {
|
||||
if (VALUE_THEME_BACKGROUND_SOLID.equals(background))
|
||||
return R.style.Theme_Twidere_Dark_SolidBackground_NoActionBar;
|
||||
else if (VALUE_THEME_BACKGROUND_TRANSPARENT.equals(background))
|
||||
return R.style.Theme_Twidere_Dark_Transparent_NoActionBar;
|
||||
return R.style.Theme_Twidere_Dark_NoActionBar;
|
||||
}
|
||||
return R.style.Theme_Twidere_Light_NoActionBar;
|
||||
}
|
||||
|
||||
public static int getThemeResource(final String name, final String background, final boolean darkActionBar) {
|
||||
public static int getThemeResource(final String name, final String background) {
|
||||
if (VALUE_THEME_NAME_LIGHT.equals(name)) {
|
||||
if (VALUE_THEME_BACKGROUND_SOLID.equals(background))
|
||||
return R.style.Theme_Twidere_Light_SolidBackground;
|
||||
@ -937,9 +914,6 @@ public class ThemeUtils implements Constants {
|
||||
case R.style.Theme_Twidere_Dark_Dialog:
|
||||
case R.style.Theme_Twidere_Dark_Compose:
|
||||
case R.style.Theme_Twidere_Dark_Transparent:
|
||||
case R.style.Theme_Twidere_Dark_NoActionBar:
|
||||
case R.style.Theme_Twidere_Dark_SolidBackground_NoActionBar:
|
||||
case R.style.Theme_Twidere_Dark_Transparent_NoActionBar:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -953,8 +927,6 @@ public class ThemeUtils implements Constants {
|
||||
switch (themeRes) {
|
||||
case R.style.Theme_Twidere_Dark_Transparent:
|
||||
case R.style.Theme_Twidere_Light_Transparent:
|
||||
case R.style.Theme_Twidere_Dark_Transparent_NoActionBar:
|
||||
case R.style.Theme_Twidere_Light_Transparent_NoActionBar:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1057,4 +1029,30 @@ public class ThemeUtils implements Constants {
|
||||
textView.setText(builder);
|
||||
}
|
||||
|
||||
public static void setActionBarItemsColor(Window window, android.support.v7.app.ActionBar actionBar, int itemColor) {
|
||||
final Drawable drawable = getActionBarHomeAsUpIndicator(actionBar);
|
||||
if (drawable != null) {
|
||||
drawable.setColorFilter(itemColor, Mode.SRC_ATOP);
|
||||
}
|
||||
actionBar.setHomeAsUpIndicator(drawable);
|
||||
setActionBarTitleTextColor(window, itemColor);
|
||||
}
|
||||
|
||||
public static void setActionBarTitleTextColor(Window window, int itemColor) {
|
||||
final View actionBarView = window.findViewById(android.support.v7.appcompat.R.id.action_bar);
|
||||
if (actionBarView instanceof Toolbar) {
|
||||
((Toolbar) actionBarView).setTitleTextColor(itemColor);
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable getActionBarHomeAsUpIndicator(android.support.v7.app.ActionBar actionBar) {
|
||||
final Context context = actionBar.getThemedContext();
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
final TypedArray a = context.obtainStyledAttributes(null, R.styleable.ActionBar, R.attr.actionBarStyle, 0);
|
||||
try {
|
||||
return a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator);
|
||||
} finally {
|
||||
a.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.mariotaku.twidere.util.accessor;
|
||||
package org.mariotaku.twidere.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.ColorStateList;
|
||||
@ -27,11 +27,12 @@ import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
public final class ViewAccessor {
|
||||
public final class ViewUtils {
|
||||
|
||||
public static boolean isInLayout(View view) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
@ -86,6 +87,18 @@ public final class ViewAccessor {
|
||||
ViewAccessorL.setProgressTintList(view, list);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends View> T findViewByType(View view, Class<T> cls) {
|
||||
if (cls.isAssignableFrom(view.getClass())) return (T) view;
|
||||
if (view instanceof ViewGroup) {
|
||||
for (int i = 0, j = ((ViewGroup) view).getChildCount(); i < j; i++) {
|
||||
final View found = findViewByType(((ViewGroup) view).getChildAt(i), cls);
|
||||
if (found != null) return (T) found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
static class ViewAccessorJB {
|
||||
static void setBackground(final View view, final Drawable background) {
|
||||
@ -142,7 +155,7 @@ public final class ViewAccessor {
|
||||
|
||||
|
||||
/**
|
||||
* Interface by which a View builds its {@link org.mariotaku.twidere.util.accessor.ViewAccessor.OutlineCompat}, used for shadow casting and clipping.
|
||||
* Interface by which a View builds its {@link ViewUtils.OutlineCompat}, used for shadow casting and clipping.
|
||||
*/
|
||||
public static abstract class ViewOutlineProviderCompat {
|
||||
/**
|
@ -23,6 +23,7 @@ import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
|
||||
@ -55,7 +56,7 @@ public final class SupportFragmentReloadCursorObserver extends ContentObserver i
|
||||
}
|
||||
|
||||
private static Handler createHandler() {
|
||||
if (Thread.currentThread().getId() != 1) return null;
|
||||
if (Thread.currentThread().getId() != 1) return new Handler(Looper.getMainLooper());
|
||||
return new Handler();
|
||||
}
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ import android.widget.ProgressBar;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor.OutlineCompat;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor.ViewOutlineProviderCompat;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.util.ViewUtils.OutlineCompat;
|
||||
import org.mariotaku.twidere.util.ViewUtils.ViewOutlineProviderCompat;
|
||||
import org.mariotaku.twidere.view.iface.IHomeActionButton;
|
||||
|
||||
import me.uucky.colorpicker.internal.EffectViewHelper;
|
||||
@ -92,14 +92,14 @@ public class HomeActionButton extends FrameLayout implements IHomeActionButton {
|
||||
}
|
||||
mIconView = (ImageView) findViewById(android.R.id.icon);
|
||||
mProgressBar = (ProgressBar) findViewById(android.R.id.progress);
|
||||
ViewAccessor.setOutlineProvider(this, new HomeActionButtonOutlineProvider());
|
||||
ViewUtils.setOutlineProvider(this, new HomeActionButtonOutlineProvider());
|
||||
setClipToOutline(true);
|
||||
setButtonColor(Color.WHITE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setButtonColor(int color) {
|
||||
ViewAccessor.setBackground(this, new ColorDrawable(color));
|
||||
ViewUtils.setBackground(this, new ColorDrawable(color));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ import android.widget.ProgressBar;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.util.ColorUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.view.iface.IHomeActionButton;
|
||||
|
||||
public class HomeActionButtonCompat extends FrameLayout implements IHomeActionButton {
|
||||
@ -66,7 +66,7 @@ public class HomeActionButtonCompat extends FrameLayout implements IHomeActionBu
|
||||
final Resources resources = getResources();
|
||||
final int radius = resources.getDimensionPixelSize(R.dimen.element_spacing_small);
|
||||
mBackground = new FloatingActionDrawable(this, radius);
|
||||
ViewAccessor.setBackground(this, mBackground);
|
||||
ViewUtils.setBackground(this, mBackground);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,7 @@ import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
|
||||
public class LeftDrawerFrameLayout extends FrameLayout {
|
||||
|
||||
@ -48,7 +48,7 @@ public class LeftDrawerFrameLayout extends FrameLayout {
|
||||
public LeftDrawerFrameLayout(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
final Drawable bg = ThemeUtils.getWindowBackground(context, ThemeUtils.getDrawerThemeResource(context));
|
||||
ViewAccessor.setBackground(this, bg);
|
||||
ViewUtils.setBackground(this, bg);
|
||||
setWillNotDraw(false);
|
||||
mClipPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.view.iface.PagerIndicator;
|
||||
|
||||
/**
|
||||
@ -84,7 +84,7 @@ public class LinePageIndicator extends View implements PagerIndicator {
|
||||
|
||||
final Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
|
||||
if (background != null) {
|
||||
ViewAccessor.setBackground(this, background);
|
||||
ViewUtils.setBackground(this, background);
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
|
@ -29,7 +29,7 @@ import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
|
||||
public class RightDrawerFrameLayout extends FrameLayout {
|
||||
|
||||
@ -48,7 +48,7 @@ public class RightDrawerFrameLayout extends FrameLayout {
|
||||
public RightDrawerFrameLayout(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
final Drawable bg = ThemeUtils.getWindowBackground(context, ThemeUtils.getDrawerThemeResource(context));
|
||||
ViewAccessor.setBackground(this, bg);
|
||||
ViewUtils.setBackground(this, bg);
|
||||
setWillNotDraw(false);
|
||||
mClipPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor.OutlineCompat;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor.ViewOutlineProviderCompat;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.util.ViewUtils.OutlineCompat;
|
||||
import org.mariotaku.twidere.util.ViewUtils.ViewOutlineProviderCompat;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@ -426,8 +426,8 @@ public class ShapedImageView extends ImageView {
|
||||
}
|
||||
|
||||
private void initOutlineProvider() {
|
||||
ViewAccessor.setClipToOutline(this, true);
|
||||
ViewAccessor.setOutlineProvider(this, new CircularOutlineProvider());
|
||||
ViewUtils.setClipToOutline(this, true);
|
||||
ViewUtils.setOutlineProvider(this, new CircularOutlineProvider());
|
||||
}
|
||||
|
||||
private void setBorderColorsInternal(int alpha, int... colors) {
|
||||
|
@ -23,7 +23,7 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/1/1.
|
||||
@ -47,7 +47,7 @@ public class TwitterCardContainer extends FrameLayout {
|
||||
public void setCardSize(int width, int height) {
|
||||
mCardWidth = width;
|
||||
mCardHeight = height;
|
||||
if (!ViewAccessor.isInLayout(this)) {
|
||||
if (!ViewUtils.isInLayout(this)) {
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import android.util.AttributeSet;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.view.iface.IThemedView;
|
||||
|
||||
public class ThemedAutoCompleteTextView extends AutoCompleteTextView implements IThemedView {
|
||||
@ -45,6 +45,6 @@ public class ThemedAutoCompleteTextView extends AutoCompleteTextView implements
|
||||
|
||||
@Override
|
||||
public void setThemeTintColor(ColorStateList color) {
|
||||
ViewAccessor.setBackgroundTintList(this, color);
|
||||
ViewUtils.setBackgroundTintList(this, color);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import android.util.AttributeSet;
|
||||
import android.widget.EditText;
|
||||
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.view.iface.IThemedView;
|
||||
|
||||
public class ThemedEditText extends EditText implements IThemedView {
|
||||
@ -45,6 +45,6 @@ public class ThemedEditText extends EditText implements IThemedView {
|
||||
|
||||
@Override
|
||||
public void setThemeTintColor(ColorStateList color) {
|
||||
ViewAccessor.setBackgroundTintList(this, color);
|
||||
ViewUtils.setBackgroundTintList(this, color);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import android.util.AttributeSet;
|
||||
import android.widget.MultiAutoCompleteTextView;
|
||||
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.accessor.ViewAccessor;
|
||||
import org.mariotaku.twidere.util.ViewUtils;
|
||||
import org.mariotaku.twidere.view.iface.IThemedView;
|
||||
|
||||
public class ThemedMultiAutoCompleteTextView extends MultiAutoCompleteTextView implements IThemedView {
|
||||
@ -45,7 +45,7 @@ public class ThemedMultiAutoCompleteTextView extends MultiAutoCompleteTextView i
|
||||
|
||||
@Override
|
||||
public void setThemeTintColor(ColorStateList color) {
|
||||
ViewAccessor.setBackgroundTintList(this, color);
|
||||
ViewUtils.setBackgroundTintList(this, color);
|
||||
setLinkTextColor(color);
|
||||
setHighlightColor(color.getDefaultColor());
|
||||
}
|
||||
|
@ -21,9 +21,7 @@
|
||||
<menu xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:showAsAction="always"
|
||||
android:id="@id/add"
|
||||
android:icon="@drawable/ic_action_add"
|
||||
android:title="@string/add"
|
||||
android:id="@id/reset"
|
||||
android:title="@string/reset_to_default"
|
||||
tools:ignore="AppCompatResource"/>
|
||||
</menu>
|
@ -76,4 +76,5 @@
|
||||
<item name="accounts" type="id"/>
|
||||
<item name="inverse_selection" type="id"/>
|
||||
<item name="edit_media" type="id"/>
|
||||
<item name="reset" type="id"/>
|
||||
</resources>
|
@ -743,5 +743,7 @@
|
||||
<string name="conflicts_with_name">Conflicts with <xliff:g id="name">%s</xliff:g></string>
|
||||
<string name="overwrite">Overwrite</string>
|
||||
<string name="navigation">Navigation</string>
|
||||
<string name="reset_to_default">Reset to default</string>
|
||||
<string name="reset_keyboard_shortcuts_confirm">Reset keyboard shortcuts to default?</string>
|
||||
|
||||
</resources>
|
@ -25,6 +25,7 @@
|
||||
|
||||
<style name="Theme.Twidere.Dark" parent="Theme.Compat.Base">
|
||||
|
||||
<item name="windowActionBar">false</item>
|
||||
<!-- Colors -->
|
||||
<!--<item name="android:colorBackgroundCacheHint">@color/bg_color_dark</item>-->
|
||||
|
||||
@ -52,6 +53,8 @@
|
||||
|
||||
<style name="Theme.Twidere.Light" parent="Theme.Compat.Base.Light.DarkActionBar">
|
||||
|
||||
<item name="windowActionBar">false</item>
|
||||
|
||||
<!-- Colors -->
|
||||
<!--<item name="android:colorBackgroundCacheHint">@color/bg_color_light</item>-->
|
||||
|
||||
@ -77,6 +80,62 @@
|
||||
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Dark.DialogWhenLarge" parent="Theme.Compat.Base.DialogWhenLarge">
|
||||
|
||||
<item name="windowActionBar">false</item>
|
||||
<!-- Colors -->
|
||||
<!--<item name="android:colorBackgroundCacheHint">@color/bg_color_dark</item>-->
|
||||
|
||||
<!-- Window attributes -->
|
||||
<!--<item name="android:windowAnimationStyle">@style/Animation.Twidere.Activity</item>-->
|
||||
<item name="android:windowBackground">@color/background_color_window_dark</item>
|
||||
|
||||
<!-- ActionBar styles -->
|
||||
<item name="android:actionBarStyle">@android:style/Widget.DeviceDefault.ActionBar.Solid
|
||||
</item>
|
||||
|
||||
<!-- Custom view styles -->
|
||||
|
||||
<!-- Card UI styles -->
|
||||
<item name="cardActionButtonStyle">@style/Widget.CardActionButton</item>
|
||||
<item name="profileImageStyle">@style/Widget.ProfileImage</item>
|
||||
<item name="profileImageStyleLarge">@style/Widget.ProfileImage.Large</item>
|
||||
<item name="cardItemBackgroundColor">@color/background_color_card_item_dark</item>
|
||||
|
||||
<!-- Twidere specific styles -->
|
||||
<item name="menuIconColor">@color/action_icon_light</item>
|
||||
<item name="menuIconColorActionBar">?menuIconColor</item>
|
||||
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Light.DialogWhenLarge" parent="Theme.Compat.Base.Light.DialogWhenLarge">
|
||||
|
||||
<item name="windowActionBar">false</item>
|
||||
<!-- Colors -->
|
||||
<!--<item name="android:colorBackgroundCacheHint">@color/bg_color_light</item>-->
|
||||
|
||||
<!-- Window attributes -->
|
||||
<!--<item name="android:windowAnimationStyle">@style/Animation.Twidere.Activity</item>-->
|
||||
<!--<item name="android:windowBackground">@color/background_color_window_light</item>-->
|
||||
|
||||
<!-- ActionBar styles -->
|
||||
<!--<item name="android:actionBarStyle">@style/Widget.Twidere.ActionBar.Light.DarkActionBar</item>-->
|
||||
<!--<item name="android:actionBarWidgetTheme">@style/Theme.Twidere.Dark</item>-->
|
||||
|
||||
<!-- Custom view styles -->
|
||||
|
||||
<!-- Card UI styles -->
|
||||
<item name="cardActionButtonStyle">@style/Widget.Light.CardActionButton</item>
|
||||
<item name="profileImageStyle">@style/Widget.Light.ProfileImage</item>
|
||||
<item name="profileImageStyleLarge">@style/Widget.Light.ProfileImage.Large</item>
|
||||
<item name="cardItemBackgroundColor">#f8f8f8</item>
|
||||
<!-- Twidere specific styles -->
|
||||
<item name="menuIconColor">@color/action_icon_dark</item>
|
||||
<item name="menuIconColorDisabled">@color/action_icon_dark_disabled</item>
|
||||
<item name="menuIconColorActionBar">@color/action_icon_light</item>
|
||||
<item name="messageBubbleColor">@color/message_bubble_color_light</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Dark.Transparent">
|
||||
|
||||
<!-- Colors -->
|
||||
@ -87,7 +146,6 @@
|
||||
<item name="android:windowShowWallpaper">true</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="Theme.Twidere.Light.Transparent">
|
||||
<!-- Colors -->
|
||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||
@ -109,46 +167,6 @@
|
||||
<item name="android:windowBackground">@android:color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.ActionBar.Colored.Light" parent="Theme.Twidere.Light">
|
||||
<!--<item name="android:actionBarItemBackground">@drawable/list_selector_white_light</item>-->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.ActionBar.Colored.Dark" parent="Theme.Twidere.Dark">
|
||||
<!--<item name="android:actionBarItemBackground">@drawable/list_selector_white</item>-->
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Dark.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Light.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Dark.Transparent.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Light.Transparent.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="Theme.Twidere.Dark.SolidBackground.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Light.SolidBackground.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="Theme.Twidere.Dark.Dialog" parent="Theme.Base.Dialog">
|
||||
|
||||
<!-- Custom view styles -->
|
||||
@ -184,6 +202,7 @@
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Dark.Compose" parent="Theme.Compat.Base.Dialog">
|
||||
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowActionModeOverlay">false</item>
|
||||
|
||||
@ -209,6 +228,7 @@
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Light.Compose" parent="Theme.Compat.Base.Light.Dialog">
|
||||
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowActionModeOverlay">false</item>
|
||||
|
||||
@ -395,8 +415,6 @@
|
||||
<item name="messageBubbleColor">@color/message_bubble_color_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Twidere.Settings.Light.DarkActionBar.DarkIcon"/>
|
||||
|
||||
<style name="Theme.Twidere.Wizard" parent="Theme.Twidere.Settings.Light">
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowActionBar">false</item>
|
||||
|
@ -21,6 +21,20 @@
|
||||
<resources>
|
||||
|
||||
<style name="Theme.Compat.Base" parent="Theme.AppCompat">
|
||||
|
||||
<!--<item name="colorPrimary">@color/material_light_blue</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/material_light_blue_700</item>-->
|
||||
<!--<item name="colorAccent">@color/material_light_blue_a200</item>-->
|
||||
|
||||
<!-- fix for https://github.com/TwidereProject/Twidere-Android/issues/76-->
|
||||
<item name="actionModeBackground">?android:colorBackground</item>
|
||||
|
||||
<item name="android:textColorTertiary">@color/tertiary_text_mtrl_dark</item>
|
||||
<item name="android:textColorTertiaryInverse">@color/tertiary_text_mtrl_light</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Compat.Base.DialogWhenLarge" parent="Theme.AppCompat.DialogWhenLarge">
|
||||
|
||||
<!--<item name="colorPrimary">@color/material_light_blue</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/material_light_blue_700</item>-->
|
||||
<!--<item name="colorAccent">@color/material_light_blue_a200</item>-->
|
||||
@ -33,6 +47,7 @@
|
||||
</style>
|
||||
|
||||
<style name="Theme.Compat.Base.NoActionBar" parent="Theme.AppCompat.NoActionBar">
|
||||
|
||||
<!--<item name="colorPrimary">@color/material_light_blue</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/material_light_blue_700</item>-->
|
||||
<!--<item name="colorAccent">@color/material_light_blue_a200</item>-->
|
||||
@ -45,6 +60,7 @@
|
||||
</style>
|
||||
|
||||
<style name="Theme.Compat.Base.Dialog" parent="Theme.AppCompat.Dialog">
|
||||
|
||||
<!--<item name="colorPrimary">@color/material_light_blue</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/material_light_blue_700</item>-->
|
||||
<!--<item name="colorAccent">@color/material_light_blue_a200</item>-->
|
||||
@ -57,6 +73,20 @@
|
||||
</style>
|
||||
|
||||
<style name="Theme.Compat.Base.Light" parent="Theme.AppCompat.Light">
|
||||
|
||||
<!--<item name="colorPrimary">@color/material_light_blue</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/material_light_blue_700</item>-->
|
||||
<!--<item name="colorAccent">@color/material_light_blue_a200</item>-->
|
||||
|
||||
<!-- fix for https://github.com/TwidereProject/Twidere-Android/issues/76-->
|
||||
<item name="actionModeBackground">?android:colorBackground</item>
|
||||
|
||||
<item name="android:textColorTertiary">@color/tertiary_text_mtrl_light</item>
|
||||
<item name="android:textColorTertiaryInverse">@color/tertiary_text_mtrl_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Compat.Base.Light.DialogWhenLarge" parent="Theme.AppCompat.Light.DialogWhenLarge">
|
||||
|
||||
<!--<item name="colorPrimary">@color/material_light_blue</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/material_light_blue_700</item>-->
|
||||
<!--<item name="colorAccent">@color/material_light_blue_a200</item>-->
|
||||
@ -69,6 +99,7 @@
|
||||
</style>
|
||||
|
||||
<style name="Theme.Compat.Base.Light.DarkActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
|
||||
<!--<item name="colorPrimary">@color/material_light_blue</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/material_light_blue_700</item>-->
|
||||
<!--<item name="colorAccent">@color/material_light_blue_a200</item>-->
|
||||
|
Loading…
x
Reference in New Issue
Block a user