Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Apr 26, 2019
1 parent 7824231 commit a4839bb
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 47 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/io/plaidapp/ui/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ public class HomeActivity extends AppCompatActivity {
private ImageButton fab;
private RecyclerView filtersList;
private ProgressBar loading;
@Nullable
private ImageView noConnection;
@Nullable private ImageView noConnection;
private ImageButton fabPosting;
private GridLayoutManager layoutManager;
private int columns;
Expand Down Expand Up @@ -420,6 +419,7 @@ public void onBackPressed() {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case RC_SEARCH:
// reset the search icon which we hid
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_comment_add.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:pathData="@string/path_comment_add"
android:strokeColor="?attr/colorSurface"
android:strokeLineCap="square"
android:strokeWidth="2" />
android:strokeWidth="@integer/comment_line_stroke_width" />

</group>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/ic_comment_lines.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
android:pathData="@string/path_comment_lines"
android:strokeColor="?attr/colorSurface"
android:strokeLineCap="square"
android:strokeWidth="2" />
android:strokeWidth="@integer/comment_line_stroke_width" />

</group>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/drawable/ic_reply.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
Copyright 2015 Google Inc.
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/comment_lines_add.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<string name="comment_lines">comment_lines</string>
<string name="comment_add">comment_add</string>

<!-- drawing -->
<integer name="comment_line_stroke_width">2</integer>

<!-- timing -->
<integer name="comment_lines_add_duration">300</integer>

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ buildscript { scriptHandler ->
'compileSdk' : 28,
'minSdk' : 23,
'targetSdk' : 28,
'appcompat' : '1.1.0-alpha03',
'appcompat' : '1.1.0-alpha04',
'androidx' : '1.0.0',
'androidxCollection' : '1.0.0',
'androidxCoreRuntime': '2.0.1-alpha01',
'androidxArch' : '2.0.0',
'constraintLayout' : '2.0.0-alpha2',
'coreKtx' : '1.0.0',
'coroutines' : '1.1.1',
'crashlytics' : '2.9.9',
'crashlytics' : '2.9.8',
'dagger' : '2.16',
'espresso' : '3.1.0-beta02',
'extJunit' : '1.1.0',
'fabric' : '1.25.4',
'firebase' : '16.0.8',
'firebase' : '16.0.6',
'glide' : '4.8.0',
'googleServices' : '4.0.1',
'gson' : '2.8.5',
'jsoup' : '1.11.3',
'junit' : '4.12',
'kotlin' : '1.3.21',
'kotlin' : '1.3.20',
'ktlint' : '0.24.0',
'legacyCoreUtils' : '1.0.0',
'lifecycle' : '2.1.0-alpha01',
Expand Down
42 changes: 18 additions & 24 deletions core/src/main/java/io/plaidapp/core/util/ColorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
*/
public class ColorUtils {

private ColorUtils() {
}
private ColorUtils() { }

public static final int IS_LIGHT = 0;
public static final int IS_DARK = 1;
Expand All @@ -51,20 +50,16 @@ private ColorUtils() {
/**
* Set the alpha component of {@code color} to be {@code alpha}.
*/
public static @CheckResult
@ColorInt
int modifyAlpha(@ColorInt int color,
@IntRange(from = 0, to = 255) int alpha) {
public static @CheckResult @ColorInt int modifyAlpha(@ColorInt int color,
@IntRange(from = 0, to = 255) int alpha) {
return (color & 0x00ffffff) | (alpha << 24);
}

/**
* Set the alpha component of {@code color} to be {@code alpha}.
*/
public static @CheckResult
@ColorInt
int modifyAlpha(@ColorInt int color,
@FloatRange(from = 0f, to = 1f) float alpha) {
public static @CheckResult @ColorInt int modifyAlpha(@ColorInt int color,
@FloatRange(from = 0f, to = 1f) float alpha) {
return modifyAlpha(color, (int) (255f * alpha));
}

Expand All @@ -74,15 +69,13 @@ int modifyAlpha(@ColorInt int color,
* Annoyingly we have to return this Lightness 'enum' rather than a boolean as palette isn't
* guaranteed to find the most populous color.
*/
public static @Lightness
int isDark(Palette palette) {
public static @Lightness int isDark(Palette palette) {
Palette.Swatch mostPopulous = getMostPopulousSwatch(palette);
if (mostPopulous == null) return LIGHTNESS_UNKNOWN;
return isDark(mostPopulous.getRgb()) ? IS_DARK : IS_LIGHT;
}

public static @Nullable
Palette.Swatch getMostPopulousSwatch(Palette palette) {
public static @Nullable Palette.Swatch getMostPopulousSwatch(Palette palette) {
Palette.Swatch mostPopulous = null;
if (palette != null) {
for (Palette.Swatch swatch : palette.getSwatches()) {
Expand Down Expand Up @@ -130,15 +123,14 @@ public static boolean isDark(@ColorInt int color) {
* Calculate a variant of the color to make it more suitable for overlaying information. Light
* colors will be lightened and dark colors will be darkened
*
* @param color the color to adjust
* @param isDark whether {@code color} is light or dark
* @param color the color to adjust
* @param isDark whether {@code color} is light or dark
* @param lightnessMultiplier the amount to modify the color e.g. 0.1f will alter it by 10%
* @return the adjusted color
*/
public static @ColorInt
int scrimify(@ColorInt int color,
boolean isDark,
@FloatRange(from = 0f, to = 1f) float lightnessMultiplier) {
public static @ColorInt int scrimify(@ColorInt int color,
boolean isDark,
@FloatRange(from = 0f, to = 1f) float lightnessMultiplier) {
float[] hsl = new float[3];
androidx.core.graphics.ColorUtils.colorToHSL(color, hsl);

Expand All @@ -152,16 +144,15 @@ int scrimify(@ColorInt int color,
return androidx.core.graphics.ColorUtils.HSLToColor(hsl);
}

public static @ColorInt
int scrimify(@ColorInt int color,
@FloatRange(from = 0f, to = 1f) float lightnessMultiplier) {
public static @ColorInt int scrimify(@ColorInt int color,
@FloatRange(from = 0f, to = 1f) float lightnessMultiplier) {
return scrimify(color, isDark(color), lightnessMultiplier);
}

/**
* Queries the theme of the given {@code context} for a theme color.
*
* @param context the context holding the current theme.
* @param context the context holding the current theme.
* @param attrResId the theme color attribute to resolve.
* @return the theme color
*/
Expand All @@ -175,6 +166,9 @@ public static int getThemeColor(@NonNull Context context, @AttrRes int attrResId
}
}

/**
* Whether the current configuration is a dark theme i.e. in Night configuration.
*/
public static boolean isDarkTheme(@NonNull Context context) {
return (context.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@

<!-- designer news -->
<color name="designer_news">#03a9f4</color> <!--light blue 500 -->-->
<color name="designer_news_secondary">#03a9f4</color> <!--*not* varied in -night -->-->
<color name="designer_news_secondary">#03a9f4</color> <!--*not* varied in -night -->
<color name="designer_news_variant">#039be5</color> <!-- light blue 600 -->
<color name="designer_news_link_highlight">#b303a9f4</color>
<color name="designer_news_story_comment_background">@android:color/transparent</color>

<color name="designer_news_super_dark">#000133</color>

<!-- product hunt-->
<color name="product_hunt">#ffff9800</color> <!--orange 500 -->-->
<color name="product_hunt">#ffff9800</color> <!--orange 500 -->

<array name="loading_placeholders_dark">
<item>#ff191919</item>
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<dimen name="comment_actions_height">40dp</dimen>
<dimen name="comment_like_margin_adjustment">-8dp</dimen>

<!-- dribbble player -->
<dimen name="large_avatar_size">120dp</dimen> <!-- 2 * actionBarSize - 2 * avatar_padding -->
<dimen name="large_avatar_height">160dp</dimen> <!-- large_avatar_margin + large_avatar_size + avatar_margin -->

<!-- bottom sheet -->
<dimen name="bottom_sheet_width">@dimen/match_parent</dimen>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import io.plaidapp.designernews.databinding.ActivityDesignerNewsLoginBinding
import io.plaidapp.designernews.databinding.ToastLoggedInConfirmationBinding
import javax.inject.Inject
import io.plaidapp.R as appR
import io.plaidapp.core.R as coreR

class LoginActivity : AppCompatActivity() {

Expand Down Expand Up @@ -82,7 +83,7 @@ class LoginActivity : AppCompatActivity() {
MorphTransform.setup(
this,
binding.container,
ColorUtils.getThemeColor(this, io.plaidapp.core.R.attr.colorSurface),
ColorUtils.getThemeColor(this, coreR.attr.colorSurface),
resources.getDimensionPixelSize(appR.dimen.dialog_corners)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@
import java.util.List;

import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
import static io.plaidapp.core.util.AnimUtils.*;
import static io.plaidapp.core.util.AnimUtils.getFastOutLinearInInterpolator;
import static io.plaidapp.core.util.AnimUtils.getFastOutSlowInInterpolator;
import static io.plaidapp.core.util.AnimUtils.getLinearOutSlowInInterpolator;

public class StoryActivity extends AppCompatActivity {

Expand Down Expand Up @@ -118,12 +120,9 @@ public class StoryActivity extends AppCompatActivity {

private Story story;

@Inject
StoryViewModel viewModel;
@Inject
LoginRepository loginRepository;
@Inject
Markdown markdown;
@Inject StoryViewModel viewModel;
@Inject LoginRepository loginRepository;
@Inject Markdown markdown;

private CustomTabActivityHelper customTab;

Expand Down Expand Up @@ -229,6 +228,7 @@ protected void onResume() {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case RC_LOGIN_UPVOTE:
if (resultCode == RESULT_OK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ class ThreadedCommentDrawable(

override fun setAlpha(i: Int) {
paint.alpha = i
invalidateSelf()
}

override fun setColorFilter(colorFilter: ColorFilter?) {
paint.colorFilter = colorFilter
invalidateSelf()
}

override fun setTintList(tint: ColorStateList?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class PasswordEntry extends TextInputEditText {

private boolean passwordMasked;
private MaskMorphDrawable maskDrawable;
ColorStateList textColor;
private ColorStateList textColor;

public PasswordEntry(Context context) {
super(context);
Expand Down Expand Up @@ -127,9 +127,9 @@ static class MaskMorphDrawable extends Drawable {
private final long hidePasswordDuration;
private final Interpolator fastOutSlowIn;

CharSequence password;
PasswordCharacter[] characters;
float morphProgress;
private CharSequence password;
private PasswordCharacter[] characters;
private float morphProgress;

MaskMorphDrawable(Context context, TextPaint textPaint,
int baseline, float charWidth, int insetStart) {
Expand Down Expand Up @@ -217,7 +217,7 @@ public void onAnimationEnd(Animator animation) {
return anim;
}

void updateBounds() {
private void updateBounds() {
Rect oldBounds = getBounds();
if (password != null) {
setBounds(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class ShotActivity : AppCompatActivity() {
R.layout.activity_dribbble_shot
)

private var largeAvatarSize: Int = 0

private val shotLoadListener = object : RequestListener<Drawable> {
override fun onResourceReady(
resource: Drawable,
Expand Down Expand Up @@ -114,6 +116,8 @@ class ShotActivity : AppCompatActivity() {

inject(shotId)

largeAvatarSize = resources.getDimensionPixelSize(io.plaidapp.R.dimen.large_avatar_size)

binding.viewModel = viewModel.also { vm ->
vm.openLink.observe(this, EventObserver { openLink(it) })
vm.shareShot.observe(this, EventObserver { shareShot(it) })
Expand Down

0 comments on commit a4839bb

Please sign in to comment.