aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/mygram/droid/Ui.java
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-22 11:53:30 +0200
committerDanilo M. <danix@danix.xyz>2026-10-22 11:53:30 +0200
commit01a5f2a67a43f268e2807e29e8664e6bbc5d655e (patch)
tree2a239a13dcb22d5e3af423b74529b6a61701aacf /app/src/main/java/mygram/droid/Ui.java
parent1fb99957c3c04b3ab5ca7e7d63c31ab0a62a9186 (diff)
downloadmygram-droid-01a5f2a67a43f268e2807e29e8664e6bbc5d655e.tar.gz
mygram-droid-01a5f2a67a43f268e2807e29e8664e6bbc5d655e.zip
Pink scaled focus, current-view mark, app logo as Home
From on-device testing: the grey focus box looked heavy, the current tab was not visible once focus moved into the content, and "Settings" was clipped. Focus now scales the icon and tints it with the logo pink; a pink bar marks the current view; the label is WRAP_CONTENT (the vertical default, MATCH_PARENT, did not widen its box). Home uses the app logo instead of loading Foldergram's from the instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'app/src/main/java/mygram/droid/Ui.java')
-rw-r--r--app/src/main/java/mygram/droid/Ui.java38
1 files changed, 34 insertions, 4 deletions
diff --git a/app/src/main/java/mygram/droid/Ui.java b/app/src/main/java/mygram/droid/Ui.java
index 586aa65..ab6db38 100644
--- a/app/src/main/java/mygram/droid/Ui.java
+++ b/app/src/main/java/mygram/droid/Ui.java
@@ -18,9 +18,11 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.RenderEffect;
import android.graphics.Shader;
+import android.graphics.drawable.GradientDrawable;
import android.text.InputType;
import android.view.Gravity;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -36,6 +38,8 @@ import java.util.List;
/** View helpers. The UI is built in code, there are no layout files. */
final class Ui {
static final int RED = 0xFFFF3B5C;
+ /** Pink end of the app icon gradient. */
+ static final int ACCENT = 0xFFEC4899;
/** Post tiles: portrait, most media is 9:16. */
static final int POST_W = 128, POST_H = 228;
@@ -97,7 +101,10 @@ final class Ui {
v.animate().scaleX(in ? 1.08f : 1f).scaleY(in ? 1.08f : 1f).setDuration(120).start();
}
- /** Icon-only button; its label shows under it while it has focus. Child 0 is the ImageView. */
+ /**
+ * Icon-only button. Focus scales the icon and turns it accent pink, and
+ * shows the label under it. Child 1 is the current-view mark.
+ */
static LinearLayout iconButton(Context c, int icon, String label, View.OnClickListener click) {
LinearLayout box = new LinearLayout(c);
box.setOrientation(LinearLayout.VERTICAL);
@@ -107,21 +114,44 @@ final class Ui {
ImageView image = new ImageView(c);
image.setImageResource(icon);
image.setContentDescription(label);
+ image.setAlpha(0.7f);
int s = dp(c, 36);
box.addView(image, new LinearLayout.LayoutParams(s, s));
+ GradientDrawable bar = new GradientDrawable();
+ bar.setColor(ACCENT);
+ bar.setCornerRadius(dp(c, 2));
+ View mark = new View(c);
+ mark.setBackground(bar);
+ mark.setVisibility(View.INVISIBLE);
+ LinearLayout.LayoutParams mp = new LinearLayout.LayoutParams(dp(c, 20), dp(c, 3));
+ mp.topMargin = dp(c, 6);
+ box.addView(mark, mp);
TextView t = text(c, label, 12);
+ t.setSingleLine(true);
t.setVisibility(View.INVISIBLE);
- box.addView(t);
+ // WRAP_CONTENT: the vertical default, MATCH_PARENT, does not widen the box, so long labels were clipped
+ box.addView(t, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT));
+ boolean tint = icon != R.drawable.ic_launcher; // the logo keeps its colours
box.setFocusable(true);
- box.setBackground(c.getDrawable(R.drawable.focus_glow));
box.setOnFocusChangeListener((v, has) -> {
t.setVisibility(has ? View.VISIBLE : View.INVISIBLE);
- zoom(v, has);
+ image.setAlpha(has ? 1f : 0.7f);
+ if (tint && has)
+ image.setColorFilter(ACCENT);
+ else
+ image.clearColorFilter();
+ image.animate().scaleX(has ? 1.25f : 1f).scaleY(has ? 1.25f : 1f).setDuration(120).start();
});
box.setOnClickListener(click);
return box;
}
+ /** Shows or hides the mark under an iconButton that stands for the current view. */
+ static void markCurrent(LinearLayout button, boolean current) {
+ button.getChildAt(1).setVisibility(current ? View.VISIBLE : View.INVISIBLE);
+ }
+
static void blur(ImageView v, float radius) {
v.setRenderEffect(RenderEffect.createBlurEffect(radius, radius, Shader.TileMode.CLAMP));
}