Skip to content

Commit

Permalink
design tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed May 29, 2024
1 parent 071fb95 commit 3351238
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 232 deletions.
3 changes: 3 additions & 0 deletions Habitica/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/brand_300" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="default" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="@string/content_provider"
Expand Down
Binary file added Habitica/res/drawable-hdpi/limited.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Habitica/res/drawable-mdpi/limited.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Habitica/res/drawable-xhdpi/limited.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Habitica/res/drawable-xxhdpi/limited.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Habitica/res/drawable/pill_bg_purple_300.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<solid android:color="@color/background_brand"/>
<corners android:radius="20dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</shape>
14 changes: 14 additions & 0 deletions Habitica/res/drawable/shop_limited.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="@color/brand_300"/>
<corners android:radius="20dip"/>
<padding android:left="0dip" android:top="0dip" android:right="0dip" android:bottom="0dip" />
</shape>
</item>
<item android:width="14dp" android:height="14dp" android:gravity="center">
<bitmap android:src="@drawable/limited" android:tintMode="src_atop" android:tint="@color/white">
</bitmap>
</item>
</layer-list>
2 changes: 1 addition & 1 deletion Habitica/res/drawable/shop_locked.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="24dp" android:height="24dp">
<item>
<shape>
<solid android:color="@color/offset_background"/>
<corners android:radius="20dip"/>
Expand Down
2 changes: 1 addition & 1 deletion Habitica/res/drawable/shop_locked_limited.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="24dp" android:height="24dp">
<item>
<shape>
<solid android:color="@color/brand_300"/>
<corners android:radius="20dip"/>
Expand Down
1 change: 1 addition & 0 deletions Habitica/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@
<string name="rogues">Rogues</string>
<string name="warriors">Warriors</string>
<string name="mages">Mages</string>
<string name="customization_shop">Customization Shop</string>

<plurals name="you_x_others">
<item quantity="zero">You</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ class ComposeAvatarCustomizationFragment :
userRepository.useCustomization(type ?: "", category, activeCustomization ?: "")
} else if (customization.identifier == activeCustomization && customization.type == "hair" && customization.category != "color") {
userRepository.useCustomization(type ?: "", category, "0")
} else if (customization.identifier == activeCustomization && customization.type == "chair") {
userRepository.useCustomization(type ?: "", category, "none")
} else if (customization.type == "background" && ownedCustomizations.value.firstOrNull { it.key == customization.identifier } == null) {
userRepository.unlockPath(customization)
userRepository.retrieveUser(false, true, true)
Expand Down Expand Up @@ -357,7 +359,7 @@ class ComposeAvatarCustomizationFragment :
"skin" -> prefs?.skin
"shirt" -> prefs?.shirt
"background" -> prefs?.background
"chair" -> prefs?.chair
"chair" -> prefs?.chair?.replace("chair_", "")
"hair" ->
when (this.category) {
"bangs" -> prefs?.hair?.bangs.toString()
Expand Down Expand Up @@ -519,7 +521,7 @@ private fun AvatarCustomizationView(
}
.background(colorResource(id = R.color.window_background)),
) {
if (item.identifier.isNullOrBlank() || item.identifier == "0") {
if (item.identifier.isNullOrBlank() || item.identifier == "0" || item.identifier == "none") {
Image(painterResource(R.drawable.empty_slot), contentDescription = null, contentScale = ContentScale.None, modifier = Modifier.size(68.dp))
} else {
PixelArtView(
Expand All @@ -541,7 +543,7 @@ private fun AvatarCustomizationView(
}
}
item(span = { GridItemSpan(3) }) {
EmptyFooter(type, items.size <= 1)
EmptyFooter(type, items.size > 1)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.foundation.lazy.grid.GridItemSpan
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand All @@ -38,8 +39,11 @@ import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.fragment.app.viewModels
Expand Down Expand Up @@ -273,7 +277,7 @@ private fun AvatarEquipmentView(
Image(painterResource(R.drawable.empty_slot), contentDescription = null, contentScale = ContentScale.None, modifier = Modifier.size(68.dp))
} else {
PixelArtView(
imageName = "icon_" + item.key,
imageName = "shop_" + item.key,
Modifier.size(68.dp),
)
}
Expand All @@ -291,7 +295,7 @@ private fun AvatarEquipmentView(
}
}
item(span = { GridItemSpan(3) }) {
EmptyFooter(type, items.size <= 1)
EmptyFooter(type, items.size > 1)
}
}
}
Expand All @@ -318,13 +322,33 @@ internal fun EmptyFooter(type: String?, hasItems: Boolean) {
stringResource(R.string.customizations_no_owned), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = colorResource(R.color.text_secondary),
modifier = Modifier.padding(bottom = 2.dp)
)
Text(stringResource(R.string.customization_shop_check_out), fontSize = 14.sp, color = colorResource(R.color.text_ternary), textAlign = TextAlign.Center)
Text(buildAnnotatedString {
val original = stringResource(id = R.string.customization_shop_check_out)
val customizationShopName = stringResource(id = R.string.customization_shop)
val first = original.substring(0, original.indexOf(customizationShopName))
val second = original.substring(original.indexOf(customizationShopName) + customizationShopName.length, original.length)
append(first)
withStyle(SpanStyle(color = HabiticaTheme.colors.tintedUiMain)) {
append(customizationShopName)
}
append(second)
}, fontSize = 14.sp, fontWeight = FontWeight.Normal, color = colorResource(R.color.text_ternary), textAlign = TextAlign.Center)
} else {
Text(
stringResource(R.string.looking_for_more), fontSize = 16.sp, fontWeight = FontWeight.Bold, color = colorResource(R.color.text_secondary),
modifier = Modifier.padding(bottom = 2.dp)
)
Text(stringResource(R.string.customization_shop_more), fontSize = 14.sp, color = colorResource(R.color.text_ternary), textAlign = TextAlign.Center)
Text(buildAnnotatedString {
val original = stringResource(id = R.string.customization_shop_more)
val customizationShopName = stringResource(id = R.string.customization_shop)
val first = original.substring(0, original.indexOf(customizationShopName))
val second = original.substring(original.indexOf(customizationShopName) + customizationShopName.length, original.length)
append(first)
withStyle(SpanStyle(color = HabiticaTheme.colors.tintedUiMain)) {
append(customizationShopName)
}
append(second)
}, fontSize = 14.sp, fontWeight = FontWeight.Normal, color = colorResource(R.color.text_ternary), textAlign = TextAlign.Center)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,9 @@ class ShopItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Vi
binding.itemDetailIndicator.visibility = View.VISIBLE
} else if (isLimited) {
if (numberOwned == 0) {
binding.itemDetailIndicator.background =
BitmapDrawable(
context.resources,
HabiticaIconsHelper.imageOfItemIndicatorLimited(),
)
binding.itemDetailIndicator.background = AppCompatResources.getDrawable(context, R.drawable.shop_limited)
} else {
binding.itemDetailIndicator.background =
AppCompatResources.getDrawable(context, R.drawable.pill_bg_purple_300)
binding.itemDetailIndicator.background = AppCompatResources.getDrawable(context, R.drawable.pill_bg_purple_300)
}
binding.itemDetailIndicator.visibility = View.VISIBLE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3522,143 +3522,6 @@ public static void drawAddRemovePin(Canvas canvas, RectF targetFrame, ResizingBe

canvas.restore();
}

private static class CacheForItemIndicator {
private static final Paint paint = new Paint();
private static final Paint shadowPaint = new Paint();
private static final PaintCodeShadow shadow = new PaintCodeShadow();
private static final RectF originalFrame = new RectF(0f, 0f, 28f, 28f);
private static final RectF resizedFrame = new RectF();
private static final RectF oval2Rect = new RectF();
private static final Path oval2Path = new Path();
private static final RectF bezierRect = new RectF();
private static final Path bezierPath = new Path();
private static final RectF bezier2Rect = new RectF();
private static final Path bezier2Path = new Path();
private static final RectF symbolRect = new RectF();
private static final RectF symbolTargetRect = new RectF();
}

public static void drawItemIndicator(Canvas canvas, int indicatorLocked, int lockColor, int indicatorLockedDark, int itemIndicatorColorBackground, boolean isLocked, boolean isLimited, boolean isDark) {
HabiticaIcons.drawItemIndicator(canvas, new RectF(0f, 0f, 28f, 28f), ResizingBehavior.AspectFit, indicatorLocked, lockColor, indicatorLockedDark, itemIndicatorColorBackground, isLocked, isLimited, isDark);
}

public static void drawItemIndicator(Canvas canvas, RectF targetFrame, ResizingBehavior resizing, int indicatorLocked, int lockColor, int indicatorLockedDark, int itemIndicatorColorBackground, boolean isLocked, boolean isLimited, boolean isDark) {
// General Declarations
Paint paint = CacheForItemIndicator.paint;

// Local Colors
int shadowTint = Color.argb(255, 26, 24, 29);
int fillColor39 = Color.argb(255, 189, 168, 255);
int strokeColor2 = Color.argb(255, 189, 168, 255);
int strokeColor = Color.argb(255, 97, 51, 180);

// Local Shadows
PaintCodeShadow shadow = CacheForItemIndicator.shadow.get(PaintCodeColor.colorByChangingAlpha(shadowTint, (int) (Color.alpha(shadowTint) * 0.12f * 255f)));

// Local Variables
int itemIndicatorColor = isLocked ? (isDark ? indicatorLockedDark : indicatorLocked) : (isLimited ? strokeColor : (isDark ? indicatorLockedDark : itemIndicatorColorBackground));

// Resize to Target Frame
canvas.save();
RectF resizedFrame = CacheForItemIndicator.resizedFrame;
HabiticaIcons.resizingBehaviorApply(resizing, CacheForItemIndicator.originalFrame, targetFrame, resizedFrame);
canvas.translate(resizedFrame.left, resizedFrame.top);
canvas.scale(resizedFrame.width() / 28f, resizedFrame.height() / 28f);

// Oval 2
RectF oval2Rect = CacheForItemIndicator.oval2Rect;
oval2Rect.set(2f, 2f, 26f, 26f);
Path oval2Path = CacheForItemIndicator.oval2Path;
oval2Path.reset();
oval2Path.addOval(oval2Rect, Path.Direction.CW);

paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
canvas.saveLayerAlpha(null, 255, Canvas.ALL_SAVE_FLAG);
{
canvas.translate(shadow.dx, shadow.dy);

Paint shadowPaint = CacheForItemIndicator.shadowPaint;
shadowPaint.set(paint);
shadow.setBlurOfPaint(shadowPaint);
canvas.drawPath(oval2Path, shadowPaint);
shadowPaint.setXfermode(GlobalCache.blendModeSourceIn);
canvas.saveLayer(null, shadowPaint, Canvas.ALL_SAVE_FLAG);
{
canvas.drawColor(shadow.color);
}
canvas.restore();
}
canvas.restore();
paint.setStyle(Paint.Style.FILL);
paint.setColor(itemIndicatorColor);
canvas.drawPath(oval2Path, paint);

// Group 2
if (isLimited) {
// Bezier
RectF bezierRect = CacheForItemIndicator.bezierRect;
bezierRect.set(6f, 6f, 22f, 22f);
Path bezierPath = CacheForItemIndicator.bezierPath;
bezierPath.reset();
bezierPath.moveTo(14f, 6f);
bezierPath.cubicTo(9.58f, 6f, 6f, 9.58f, 6f, 14f);
bezierPath.cubicTo(6f, 18.42f, 9.58f, 22f, 14f, 22f);
bezierPath.cubicTo(18.42f, 22f, 22f, 18.42f, 22f, 14f);
bezierPath.cubicTo(22f, 9.58f, 18.42f, 6f, 14f, 6f);
bezierPath.close();
bezierPath.moveTo(14f, 8f);
bezierPath.cubicTo(17.31f, 8f, 20f, 10.69f, 20f, 14f);
bezierPath.cubicTo(20f, 17.31f, 17.31f, 20f, 14f, 20f);
bezierPath.cubicTo(10.69f, 20f, 8f, 17.31f, 8f, 14f);
bezierPath.cubicTo(8f, 10.69f, 10.69f, 8f, 14f, 8f);
bezierPath.close();

paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
bezierPath.setFillType(Path.FillType.EVEN_ODD);
paint.setStyle(Paint.Style.FILL);
paint.setColor(fillColor39);
canvas.drawPath(bezierPath, paint);

// Bezier 2
RectF bezier2Rect = CacheForItemIndicator.bezier2Rect;
bezier2Rect.set(14f, 11f, 16f, 16f);
Path bezier2Path = CacheForItemIndicator.bezier2Path;
bezier2Path.reset();
bezier2Path.moveTo(14f, 11f);
bezier2Path.lineTo(14f, 14.03f);
bezier2Path.lineTo(16f, 16f);

paint.reset();
paint.setFlags(Paint.ANTI_ALIAS_FLAG);
paint.setStrokeWidth(2f);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeMiter(10f);
canvas.save();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(strokeColor2);
canvas.drawPath(bezier2Path, paint);
canvas.restore();
}

// Symbol
if (isLocked) {
RectF symbolRect = CacheForItemIndicator.symbolRect;
symbolRect.set(9f, 7f, 19f, 19f);
canvas.save();
canvas.clipRect(symbolRect);
canvas.translate(symbolRect.left, symbolRect.top);
RectF symbolTargetRect = CacheForItemIndicator.symbolTargetRect;
symbolTargetRect.set(0f, 0f, symbolRect.width(), symbolRect.height());
HabiticaIcons.drawLocked(canvas, symbolTargetRect, ResizingBehavior.Stretch, lockColor);
canvas.restore();
}

canvas.restore();
}

private static class CacheForWarriorLightBg {
private static final RectF originalFrame = new RectF(0f, 0f, 32f, 32f);
private static final RectF resizedFrame = new RectF();
Expand Down
Loading

0 comments on commit 3351238

Please sign in to comment.