improved pure black/white theme

This commit is contained in:
Mariotaku Lee 2015-05-12 00:36:18 +08:00
parent 5689edf58e
commit 3ba340ba01
13 changed files with 527 additions and 48 deletions

View File

@ -58,6 +58,7 @@ public interface TwidereConstants extends SharedPreferenceConstants, IntentConst
String SCHEME_HTTPS = "https";
String SCHEME_CONTENT = "content";
String SCHEME_TWIDERE = "twidere";
String SCHEME_DATA = "data";
String PROTOCOL_HTTP = SCHEME_HTTP + "://";
String PROTOCOL_HTTPS = SCHEME_HTTPS + "://";

View File

@ -219,4 +219,5 @@ public final class ParseUtils {
return def;
}
}
}

View File

@ -0,0 +1,434 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.ooxi.jdatauri;
import android.util.Base64;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
/**
* A data URI parser
*
* @see https://tools.ietf.org/html/rfc2397
* @see http://shadow2531.com/opera/testcases/datauri/data_uri_rules.html
* @see https://en.wikipedia.org/wiki/Data_URI_scheme
*
* @author ooxi
*/
public class DataUri {
private static final String CHARSET_OPTION_NAME = "charset";
private static final String FILENAME_OPTION_NAME = "filename";
private static final String CONTENT_DISPOSITION_OPTION_NAME = "content-disposition";
private final String mime;
private final Charset charset;
private final String filename;
private final String contentDisposition;
private final byte[] data;
public DataUri(String mime, Charset charset, byte[] data) {
this(mime, charset, null, null, data);
}
public DataUri(String mime, Charset charset, String filename, String contentDisposition, byte[] data) {
this.mime = mime;
this.charset = charset;
this.filename = filename;
this.contentDisposition = contentDisposition;
this.data = data;
if (null == mime) {
throw new NullPointerException("`mime' must not be null");
}
if (null == data) {
throw new NullPointerException("`data' must not be null");
}
}
public String getMime() {
return mime;
}
/**
* @warning May be null
*/
public Charset getCharset() {
return charset;
}
/**
* @warning May be null
*/
public String getFilename() {
return filename;
}
/**
* @warning May be null
*/
public String getContentDisposition() {
return contentDisposition;
}
public byte[] getData() {
return data;
}
@Override
public int hashCode() {
int hash = 3;
hash = 23 * hash + (this.mime != null ? this.mime.hashCode() : 0);
hash = 23 * hash + (this.charset != null ? this.charset.hashCode() : 0);
hash = 23 * hash + (this.filename != null ? this.filename.hashCode() : 0);
hash = 23 * hash + (this.contentDisposition != null ? this.contentDisposition.hashCode() : 0);
hash = 23 * hash + Arrays.hashCode(this.data);
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final DataUri other = (DataUri) obj;
if ((this.mime == null) ? (other.mime != null) : !this.mime.equals(other.mime)) {
return false;
}
if (this.charset != other.charset && (this.charset == null || !this.charset.equals(other.charset))) {
return false;
}
if ((this.filename == null) ? (other.filename != null) : !this.filename.equals(other.filename)) {
return false;
}
if ((this.contentDisposition == null) ? (other.contentDisposition != null) : !this.contentDisposition.equals(other.contentDisposition)) {
return false;
}
if (!Arrays.equals(this.data, other.data)) {
return false;
}
return true;
}
/**
* Tries to parse a data URI described in RFC2397
*
* @param uri A string representing the data URI
* @param charset Charset to use when decoding percent encoded options
* like filename
*
* @return Parsed data URI
* @throws IllegalArgumentException iff an error occured during parse
* process
*/
public static DataUri parse(String uri, Charset charset) {
/* If URI does not start with a case-insensitive "data:":
* Throw a MALFORMED_URI exception.
*/
if (!uri.toLowerCase().startsWith("data:")) {
throw new IllegalArgumentException("URI must start with a case-insensitive `data:'");
}
/* If URI does not contain a ",":
* Throw a MALFORMED_URI exception.
*/
if (-1 == uri.indexOf(',')) {
throw new IllegalArgumentException("URI must contain a `,'");
}
/* Let supportedContentEncodings be an array of strings
* representing the supported content encodings. (["base64"] for
* example)
*/
Collection<String> supportedContentEncodings = Arrays.asList(
"base64"
);
/* Let mimeType be a string with the value "text/plain".
*/
String mimeType = "text/plain";
/* Let contentEncoding be an empy string.
*/
String contentEncoding = "";
/* Let contentEncodingAlreadySet be a boolean with a value of
* false.
*/
boolean contentEncodingAlreadySet = false;
/* Let supportedValues be a map of string:string pairs where the
* first string in each pair represents the name of the
* supported value and the second string in each pair represents
* an empty string or default string value. (Example: {"charset"
* : "", "filename" : "", "content-disposition" : ""})
*/
final Map<String, String> supportedValues = new HashMap<String, String>() {{
put(CHARSET_OPTION_NAME, "");
put(FILENAME_OPTION_NAME, "");
put(CONTENT_DISPOSITION_OPTION_NAME, "");
}};
/* Let supportedValueSetBits be a map of string:bool pairs
* representing each of the names in supportedValues with each
* name set to false.
*/
final Map<String, Boolean> supportedValueSetBits = new HashMap<String, Boolean>() {{
for (String key : supportedValues.keySet()) {
put(key, false);
}
}};
/* Let comma be the position of the first "," found in URI.
*/
int comma = uri.indexOf(',');
/* Let temp be the substring of URI from, and including,
* position 5 to, and excluding, the comma position. (between
* "data:" and first ",")
*/
String temp = uri.substring("data:".length(), comma);
/* Let headers be an array of strings returned by splitting temp
* by ";".
*/
String[] headers = temp.split(";");
/* For each string s in headers:
*/
for (int header = 0; header < headers.length; ++header) {
String s = headers[header];
/* Let s equal the lowercase version of s
*/
s = s.toLowerCase();
/* Let eq be the position result of searching for "=" in
* s.
*/
int eq = s.indexOf('=');
/* Let name and value be empty strings.
*/
String name;
String value = "";
/* If eq is not a valid position in s:
*/
if (-1 == eq) {
/* Let name equal the result of percent-decoding
* s.
*/
name = percentDecode(s, charset);
/* Let name equal the result of trimming leading
* and trailing white-space from name.
*/
name = name.trim();
/* Else:
*/
} else {
/* Let name equal the substring of s from
* position 0 to, but not including, position
* eq.
*/
name = s.substring(0, eq);
/* Let name equal the result of percent-decoding
* name.
*/
name = percentDecode(name, charset);
/* Let name equal the result of trimmnig leading
* and trailing white-space from name.
*/
name = name.trim();
/* Let value equal the substring of s from
* position eq + 1 to the end of s.
*/
value = s.substring(eq + 1);
/* Let value equal the result of precent-
* decoding value.
*/
value = percentDecode(value, charset);
/* Let value equal the result of trimming
* leading and trailing white-space from value.
*/
value = value.trim();
}
/* If s is the first element in headers and eq is not a
* valid position in s and the length of name is greater
* than 0:
*/
if ((0 == header) && (-1 == eq) && !name.isEmpty()) {
/* Let mimeType equal name.
*/
mimeType = name;
/* Else:
*/
} else {
/* If eq is not a valid position in s:
*/
if (-1 == eq) {
/* If name is found case-insensitively
* in supportedContentEncodings:
*/
final String nameCaseInsensitive = name.toLowerCase();
if (supportedContentEncodings.contains(nameCaseInsensitive)) {
/* If contentEncodingAlreadySet
* is false:
*/
if (!contentEncodingAlreadySet) {
/* Let contentEncoding
* equal name.
*/
contentEncoding = name;
/* Let contentEncodingAlreadySet
* equal true.
*/
contentEncodingAlreadySet = true;
}
}
/* Else:
*/
} else {
/* If the length of value is greater
* than 0 and name is found case-
* insensitively in supportedValues:
*/
final String nameCaseInsensitive = name.toLowerCase();
if (!value.isEmpty() && supportedValues.containsKey(nameCaseInsensitive)) {
/* If the corresponding value
* for name found (case-
* insensitivley) in
* supportedValueSetBits is
* false:
*/
boolean valueSet = supportedValueSetBits.get(nameCaseInsensitive);
if (!valueSet) {
/* Let the corresponding
* value for name found
* (case-insensitively)
* in supportedValues
* equal value.
*/
supportedValues.put(nameCaseInsensitive, value);
/* Let the corresponding
* value for name found
* (case-insensitively)
* in supportedValueSetBits
* equal true.
*/
supportedValueSetBits.put(nameCaseInsensitive, true);
}
}
}
}
}
/* Let data be the substring of URI from position comma + 1 to
* the end of URI.
*/
String data = uri.substring(comma + 1);
/* Let data be the result of percent-decoding data.
*/
data = percentDecode(data, charset);
/* Let dataURIObject be an object consisting of the mimeType,
* contentEncoding, data and supportedValues objects.
*/
final String finalMimeType = mimeType;
final Charset finalCharset = supportedValues.get(CHARSET_OPTION_NAME).isEmpty()
? null : Charset.forName(supportedValues.get(CHARSET_OPTION_NAME));
final String finalFilename = supportedValues.get(FILENAME_OPTION_NAME).isEmpty()
? null : supportedValues.get(FILENAME_OPTION_NAME);
final String finalContentDisposition = supportedValues.get(CONTENT_DISPOSITION_OPTION_NAME).isEmpty()
? null : supportedValues.get(CONTENT_DISPOSITION_OPTION_NAME);
final byte[] finalData = "base64".equalsIgnoreCase(contentEncoding)
? Base64.decode(data, Base64.DEFAULT) : data.getBytes(charset);
DataUri dataURIObject = new DataUri(
finalMimeType,
finalCharset,
finalFilename,
finalContentDisposition,
finalData
);
/* return dataURIObject.
*/
return dataURIObject;
}
/**
* @warning URLDecoder.decode does not do percentDecoding, but instead decodes
* application/x-www-form-urlencoded therefore the .replace hack
*/
private static String percentDecode(String s, Charset cs) {
try {
return URLDecoder.decode(s, cs.name()).replace(' ', '+');
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("Charset `"+ cs.name() +"' not supported", e);
}
}
}

View File

@ -284,12 +284,7 @@ public abstract class BasePreferenceActivity extends AppCompatPreferenceActivity
if (mMainContent == null) return;
final int alpha = ThemeUtils.isTransparentBackground(getThemeBackgroundOption()) ? getCurrentThemeBackgroundAlpha() : 0xFF;
final int statusBarColor;
if (ThemeUtils.isDarkTheme(getCurrentThemeResourceId())) {
statusBarColor = getResources().getColor(R.color.background_color_action_bar_dark);
} else {
statusBarColor = getCurrentThemeColor();
}
final int statusBarColor=ThemeUtils.getActionBarColor(this, getCurrentThemeColor(), getCurrentThemeResourceId(), getThemeBackgroundOption());
mMainContent.setColor(statusBarColor, alpha);
StatusBarProxy.setStatusBarDarkIcon(getWindow(), TwidereColorUtils.getYIQLuminance(statusBarColor) > ThemeUtils.ACCENT_COLOR_THRESHOLD);

View File

@ -323,12 +323,17 @@ public class SettingsActivity extends BasePreferenceActivity {
if (mTwidereActionModeForChildListener.finishExisting()) {
return;
}
onBackPressed();
}
@Override
public void onBackPressed() {
if (isTopSettings() && shouldNotifyChange()) {
final RestartConfirmDialogFragment df = new RestartConfirmDialogFragment();
df.show(getFragmentManager().beginTransaction(), "restart_confirm");
return;
}
onBackPressed();
super.onBackPressed();
}
public static class RestartConfirmDialogFragment extends DialogFragment implements DialogInterface.OnClickListener {

View File

@ -62,6 +62,7 @@ import android.support.v7.widget.RecyclerView.State;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.Editable;
import android.text.Spannable;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
@ -108,6 +109,7 @@ import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.preference.ServicePickerPreference;
import org.mariotaku.twidere.provider.TwidereDataStore.Drafts;
import org.mariotaku.twidere.service.BackgroundOperationService;
import org.mariotaku.twidere.text.MarkForDeleteSpan;
import org.mariotaku.twidere.util.AsyncTaskUtils;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ContentValuesCreator;
@ -739,12 +741,18 @@ public class ComposeActivity extends ThemedFragmentActivity implements LocationL
intent.setData(Uri.parse(imageSpans[0].getSource()));
startActivityForResult(intent, REQUEST_PICK_IMAGE);
}
((Spannable) s).setSpan(new MarkForDeleteSpan(), start, start + count,
Spanned.SPAN_INCLUSIVE_INCLUSIVE);
}
}
@Override
public void afterTextChanged(final Editable s) {
mTextChanged = s.length() == 0;
final MarkForDeleteSpan[] deletes = s.getSpans(0, s.length(), MarkForDeleteSpan.class);
for (MarkForDeleteSpan delete : deletes) {
s.delete(s.getSpanStart(delete), s.getSpanEnd(delete));
}
}
});
mEditText.setCustomSelectionActionModeCallback(this);

View File

@ -799,22 +799,17 @@ public class HomeActivity extends BaseAppCompatActivity implements OnClickListen
mTabIndicator.setItemContext(ThemeUtils.getActionBarThemedContext(this, themeResId, themeColor));
ViewSupport.setBackground(mActionBarContainer, ThemeUtils.getActionBarBackground(this, themeResId, themeColor,
backgroundOption, true));
final int actionBarColor;
final int actionBarColor = ThemeUtils.getActionBarColor(this, themeColor, themeResId, backgroundOption);
final int actionItemColor = ThemeUtils.getContrastForegroundColor(this, getCurrentThemeResourceId(), themeColor);
final int[] foregroundColors = new int[2];
ThemeUtils.getColorForegroundAndInverse(this, foregroundColors);
if (ThemeUtils.isDarkTheme(themeResId)) {
actionBarColor = getResources().getColor(R.color.background_color_action_bar_dark);
final int actionItemColor = ThemeUtils.getContrastForegroundColor(this,
getCurrentThemeResourceId(), themeColor);
homeActionButton.setButtonColor(actionBarColor);
homeActionButton.setIconColor(actionItemColor, Mode.SRC_ATOP);
mTabIndicator.setStripColor(themeColor);
mTabIndicator.setIconColor(foregroundColors[0]);
mTabIndicator.setLabelColor(foregroundColors[0]);
} else {
actionBarColor = themeColor;
final int actionItemColor = ThemeUtils.getContrastForegroundColor(this,
getCurrentThemeResourceId(), themeColor);
final int contrastColor = TwidereColorUtils.getContrastYIQ(themeColor,
ThemeUtils.ACCENT_COLOR_THRESHOLD, foregroundColors[0], foregroundColors[1]);
homeActionButton.setButtonColor(themeColor);

View File

@ -20,6 +20,7 @@ import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.webkit.MimeTypeMap;
import com.github.ooxi.jdatauri.DataUri;
import com.nostra13.universalimageloader.utils.IoUtils;
import org.mariotaku.simplerestapi.http.ContentType;
@ -35,11 +36,13 @@ import org.mariotaku.twidere.model.SingleResponse;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.TwitterAPIUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import static android.os.Environment.getExternalStorageState;
@ -195,7 +198,8 @@ public class ImagePickerActivity extends ThemedFragmentActivity {
final File cacheDir = mActivity.getCacheDir();
final Uri uri = this.mUri;
final String mimeType;
if (SCHEME_HTTP.equals(uri.getScheme()) || SCHEME_HTTPS.equals(uri.getScheme())) {
final String scheme = uri.getScheme();
if (SCHEME_HTTP.equals(scheme) || SCHEME_HTTPS.equals(scheme)) {
final RestHttpClient client = TwitterAPIUtils.getDefaultHttpClient(mActivity);
final RestHttpRequest.Builder builder = new RestHttpRequest.Builder();
builder.method(GET.METHOD);
@ -209,6 +213,10 @@ public class ImagePickerActivity extends ThemedFragmentActivity {
} else {
throw new IOException("Unable to get " + uri);
}
} else if (SCHEME_DATA.equals(scheme)) {
final DataUri dataUri = DataUri.parse(uri.toString(), Charset.defaultCharset());
is = new ByteArrayInputStream(dataUri.getData());
mimeType = dataUri.getMime();
} else {
is = cr.openInputStream(uri);
final BitmapFactory.Options opts = new BitmapFactory.Options();

View File

@ -365,12 +365,7 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
mMainContent.setDrawColor(true);
mMainContent.setFactor(1);
final int alpha = ThemeUtils.isTransparentBackground(getThemeBackgroundOption()) ? getCurrentThemeBackgroundAlpha() : 0xFF;
final int statusBarColor;
if (ThemeUtils.isDarkTheme(getCurrentThemeResourceId())) {
statusBarColor = getResources().getColor(R.color.background_color_action_bar_dark);
} else {
statusBarColor = getCurrentThemeColor();
}
final int statusBarColor=ThemeUtils.getActionBarColor(this, getCurrentThemeColor(), getCurrentThemeResourceId(), getThemeBackgroundOption());
mMainContent.setColor(statusBarColor, alpha);
StatusBarProxy.setStatusBarDarkIcon(getWindow(), TwidereColorUtils.getYIQLuminance(statusBarColor) > ThemeUtils.ACCENT_COLOR_THRESHOLD);
break;

View File

@ -521,12 +521,7 @@ public class SignInActivity extends BaseAppCompatActivity implements TwitterCons
if (mMainContent == null) return;
final int alpha = ThemeUtils.isTransparentBackground(getThemeBackgroundOption()) ? getCurrentThemeBackgroundAlpha() : 0xFF;
final int statusBarColor;
if (ThemeUtils.isDarkTheme(getCurrentThemeResourceId())) {
statusBarColor = getResources().getColor(R.color.background_color_action_bar_dark);
} else {
statusBarColor = getCurrentThemeColor();
}
final int statusBarColor = ThemeUtils.getActionBarColor(this, getCurrentThemeColor(), getCurrentThemeResourceId(), getThemeBackgroundOption());
mMainContent.setColor(statusBarColor, alpha);
StatusBarProxy.setStatusBarDarkIcon(getWindow(), TwidereColorUtils.getYIQLuminance(statusBarColor) > ThemeUtils.ACCENT_COLOR_THRESHOLD);

View File

@ -95,6 +95,9 @@ import org.mariotaku.twidere.activity.support.LinkHandlerActivity;
import org.mariotaku.twidere.activity.support.ThemedAppCompatActivity;
import org.mariotaku.twidere.activity.support.UserListSelectorActivity;
import org.mariotaku.twidere.adapter.support.SupportTabsAdapter;
import org.mariotaku.twidere.api.twitter.Twitter;
import org.mariotaku.twidere.api.twitter.TwitterException;
import org.mariotaku.twidere.api.twitter.model.Relationship;
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.constant.SharedPreferenceConstants;
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCallback;
@ -148,10 +151,6 @@ import org.mariotaku.twidere.view.iface.IExtendedView.OnSizeChangedListener;
import java.util.List;
import java.util.Locale;
import org.mariotaku.twidere.api.twitter.model.Relationship;
import org.mariotaku.twidere.api.twitter.Twitter;
import org.mariotaku.twidere.api.twitter.TwitterException;
public class UserFragment extends BaseSupportFragment implements OnClickListener,
OnLinkClickListener, OnSizeChangedListener, OnSharedPreferenceChangeListener,
OnTouchListener, DrawerCallback, SupportFragmentCallback, SystemWindowsInsetsCallback,
@ -1351,12 +1350,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final AppCompatActivity activity = (AppCompatActivity) getActivity();
final IThemedActivity themed = (IThemedActivity) activity;
final int themeRes = themed.getCurrentThemeResourceId();
final int actionBarColor;
if (ThemeUtils.isDarkTheme(themeRes)) {
actionBarColor = getResources().getColor(R.color.background_color_action_bar_dark);
} else {
actionBarColor = color;
}
final int actionBarColor = ThemeUtils.getActionBarColor(activity, color,
themed.getCurrentThemeResourceId(), themed.getThemeBackgroundOption());
if (mTintedStatusContent != null) {
mTintedStatusContent.setColor(actionBarColor, themed.getCurrentThemeBackgroundAlpha());
}
@ -1485,13 +1480,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
final Drawable tabBackground = mPagerIndicator.getBackground();
int stackedTabColor;
final int themeId = activity.getCurrentThemeResourceId();
if (ThemeUtils.isDarkTheme(themeId)) {
stackedTabColor = getResources().getColor(R.color.background_color_action_bar_dark);
} else {
stackedTabColor = mUiColor;
}
int stackedTabColor = ThemeUtils.getActionBarColor(activity, mUiColor, themeId,
activity.getThemeBackgroundOption());
if (ThemeUtils.isTransparentBackground(activity.getCurrentThemeBackgroundOption())) {
stackedTabColor = ColorUtils.setAlphaComponent(stackedTabColor, activity.getCurrentThemeBackgroundAlpha());

View File

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

View File

@ -65,6 +65,7 @@ import org.apache.commons.lang3.ArrayUtils;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.iface.IThemedActivity;
import org.mariotaku.twidere.activity.support.HomeActivity;
import org.mariotaku.twidere.graphic.ActionBarColorDrawable;
import org.mariotaku.twidere.graphic.ActionIconDrawable;
import org.mariotaku.twidere.text.ParagraphSpacingSpan;
@ -228,10 +229,12 @@ public class ThemeUtils implements Constants {
final int accentColor, final String backgroundOption,
final boolean outlineEnabled) {
final int actionBarColor;
if (isDarkTheme(themeRes)) {
actionBarColor = context.getResources().getColor(R.color.background_color_action_bar_dark);
} else {
if (!isDarkTheme(themeRes)) {
actionBarColor = accentColor;
} else if (isSolidBackground(backgroundOption)) {
actionBarColor = Color.BLACK;
} else {
actionBarColor = context.getResources().getColor(R.color.background_color_action_bar_dark);
}
return ActionBarColorDrawable.create(actionBarColor, outlineEnabled);
}
@ -950,8 +953,14 @@ public class ThemeUtils implements Constants {
final int drawerThemeRes = getDrawerThemeResource(themeRes);
final String backgroundOption = ((IThemedActivity) context).getThemeBackgroundOption();
final int alpha = ((IThemedActivity) context).getCurrentThemeBackgroundAlpha();
final Drawable d = getWindowBackgroundFromTheme(context, drawerThemeRes);
if (d != null && isTransparentBackground(backgroundOption)) {
final Drawable d;
if (isSolidBackground(backgroundOption)) {
d = new ColorDrawable(Color.BLACK);
} else {
d = getWindowBackgroundFromTheme(context, drawerThemeRes);
}
if (d == null) throw new NullPointerException();
if (isTransparentBackground(backgroundOption)) {
d.setAlpha(alpha);
}
ViewSupport.setBackground(view, d);
@ -1078,6 +1087,15 @@ public class ThemeUtils implements Constants {
return actionBarContext;
}
public static int getActionBarColor(Context context, int themeColor, int themeResId, String backgroundOption) {
if (!isDarkTheme(themeResId)) {
return themeColor;
} else if (isSolidBackground(backgroundOption)) {
return Color.BLACK;
}
return context.getResources().getColor(R.color.background_color_action_bar_dark);
}
public static final class ActionBarContextThemeWrapper extends android.support.v7.internal.view.ContextThemeWrapper {
public ActionBarContextThemeWrapper(Context base, int themeres) {