Commit 3ad05091 authored by Varun Patil's avatar Varun Patil

Fix going/interested for dark theme

parent d184dc07
......@@ -3,6 +3,7 @@ package app.insti;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
......@@ -13,6 +14,7 @@ import android.support.transition.Transition;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.TypedValue;
import android.view.View;
import android.webkit.CookieManager;
import android.widget.ImageView;
......@@ -250,6 +252,13 @@ public final class Utils {
}
}
public static int getAttrColor(Context context, int attrId) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
theme.resolveAttribute(attrId, typedValue, true);
return typedValue.data;
}
@RequiresApi(21)
public static void clearCookies(Context context) {
CookieManager.getInstance().removeAllCookies(null);
......
......@@ -156,7 +156,8 @@ public class CalendarFragment extends BaseFragment {
/** Decorator for Calendar */
private class EventDecorator implements DayViewDecorator {
private final int color = getResources().getColor(R.color.colorAccent);
private final int white = getResources().getColor(R.color.primaryTextColor);
private final int white = Utils.getAttrColor(getContext(), R.attr.themeColor);
private final HashSet<CalendarDay> dates;
private final int alpha;
......
......@@ -27,9 +27,7 @@ import android.text.TextPaint;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -120,7 +118,6 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
// Set font face and color of badge
spannable.setSpan(new RelativeSizeSpan(0.75f), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
spannable.setSpan(new ForegroundColorSpan(Color.DKGRAY), text.length(), text.length() + 1 + countString.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
return spannable;
}
......@@ -358,9 +355,23 @@ public class EventFragment extends BackHandledFragment implements TransitionTarg
});
}
/** Setup button colors depending on status */
void setFollowButtonColors(int status) {
interestedButton.setBackgroundColor(getResources().getColor(status == Constants.STATUS_INTERESTED ? R.color.colorAccent : R.color.colorWhite));
goingButton.setBackgroundColor(getResources().getColor(status == Constants.STATUS_GOING ? R.color.colorAccent : R.color.colorWhite));
// Get background colors
final int themeColor = Utils.getAttrColor(getContext(), R.attr.themeColor);
final int accent = getResources().getColor(R.color.colorAccent);
// Get font colors
final int themeColorInverse = Utils.getAttrColor(getContext(), R.attr.themeColorInverse);
final int black = Color.BLACK;
// Set background colors
interestedButton.setBackgroundColor(status == Constants.STATUS_INTERESTED ? accent : themeColor);
goingButton.setBackgroundColor(status == Constants.STATUS_GOING ? accent : themeColor);
// Set font colors
interestedButton.setTextColor(status == Constants.STATUS_INTERESTED ? black : themeColorInverse);
goingButton.setTextColor(status == Constants.STATUS_GOING ? black : themeColorInverse);
// Show badges
interestedButton.setText(getCountBadgeSpannable("INTERESTED", event.getEventInterestedCount()));
......
......@@ -7,7 +7,6 @@ import android.content.Context;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.Typeface;
......@@ -40,7 +39,6 @@ import android.text.style.ClickableSpan;
import android.text.style.StyleSpan;
import android.text.util.Linkify;
import android.util.Log;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
......@@ -241,10 +239,7 @@ public class MapFragment extends Fragment implements TextWatcher,
if (response.isSuccessful()) {
// Setup fade animation for background
TypedValue typedValue = new TypedValue();
Resources.Theme theme = getContext().getTheme();
theme.resolveAttribute(R.attr.themeColor, typedValue, true);
int colorFrom = typedValue.data;
int colorFrom = Utils.getAttrColor(getContext(), R.attr.themeColor);
int colorTo = getResources().getColor(R.color.colorGray);
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.setDuration(250); // milliseconds
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment