Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
proper label background as mentioned #243
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosh committed Apr 4, 2017
1 parent 821dad8 commit e37474e
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ dependencies {
compile "com.android.support:recyclerview-v7:${supportVersion}"
compile "com.android.support:preference-v14:${supportVersion}"
compile "com.android.support:customtabs:${supportVersion}"
compile "com.android.support:palette-v7:${supportVersion}"
compile "com.google.firebase:firebase-ads:${firebase}"
releaseCompile "com.google.firebase:firebase-crash:${firebase}"
compile "net.grandcentrix.thirtyinch:thirtyinch:${thirtyinchVersion}"
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/fastaccess/helper/ViewHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.graphics.ColorUtils;
import android.support.v7.graphics.Palette;
import android.text.Layout;
import android.util.TypedValue;
import android.view.View;
Expand Down Expand Up @@ -175,8 +175,9 @@ public static void hideKeyboard(@NonNull View view) {
inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

@ColorInt public static int generateTextColor(int color, int background) {
return ColorUtils.compositeColors(color, background);
@ColorInt public static int generateTextColor(int background) {
Palette.Swatch swatch = new Palette.Swatch(background, 0);
return swatch.getBodyTextColor();
}

public static boolean isEllipsed(@NonNull TextView textView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public static void launchUri(@NonNull Context context, @NonNull Uri data, boolea
Intent intent = convert(context, data, showRepoBtn);
if (intent != null) {
if (context instanceof Service || context instanceof Application) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Logger.e("instanceof");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
context.startActivity(intent);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static LabelColorsViewHolder newInstance(ViewGroup parent, BaseRecyclerAd
@Override public void bind(@NonNull String labelModel) {
int labelColor = Color.parseColor(labelModel);
itemView.setBackgroundColor(labelColor);
color.setTextColor(ViewHelper.generateTextColor(Color.WHITE, labelColor));
color.setTextColor(ViewHelper.generateTextColor(labelColor));
color.setText(labelModel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static LabelsViewHolder newInstance(@NonNull ViewGroup parent, @NonNull L
colorImage.setBackgroundColor(color);
name.setText(labelModel.getName());
if (onSelectLabel.isLabelSelected(getAdapterPosition())) {
name.setTextColor(ViewHelper.generateTextColor(Color.WHITE, color));
name.setTextColor(ViewHelper.generateTextColor(color));
} else {
name.setTextColor(ViewHelper.getPrimaryTextColor(itemView.getContext()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.fastaccess.ui.widgets;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.FontMetricsInt;
import android.graphics.RectF;
Expand Down Expand Up @@ -30,7 +29,7 @@ public int getSize(@NonNull Paint paint, CharSequence charSequence, int start, i
final float width = paint.measureText(charSequence.subSequence(start, end).toString());
RectF rectF = new RectF(x, top + 10, x + width + 2 * 10, bottom + 5);
canvas.drawRoundRect(rectF, this.radius, this.radius, this.paint);
paint.setColor(ViewHelper.generateTextColor(Color.WHITE, this.paint.getColor()));
paint.setColor(ViewHelper.generateTextColor(this.paint.getColor()));
canvas.drawText(charSequence, start, end, x + 10, y + 5, paint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

<include layout="@layout/fragment_container"/>

<include layout="@layout/bottom_fab"/>

<include layout="@layout/main_bottom_navigation"/>

</android.support.design.widget.CoordinatorLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing_normal"
android:layout_marginTop="@dimen/spacing_normal"
android:gravity="center"
android:orientation="vertical">

Expand All @@ -30,7 +32,6 @@
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
app:cardBackgroundColor="?card_background"
app:cardUseCompatPadding="true"
app:contentPaddingBottom="@dimen/spacing_normal"
Expand Down

0 comments on commit e37474e

Please sign in to comment.