diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-22 11:53:30 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-22 11:53:30 +0200 |
| commit | 01a5f2a67a43f268e2807e29e8664e6bbc5d655e (patch) | |
| tree | 2a239a13dcb22d5e3af423b74529b6a61701aacf | |
| parent | 1fb99957c3c04b3ab5ca7e7d63c31ab0a62a9186 (diff) | |
| download | mygram-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>
| -rw-r--r-- | app/src/main/java/mygram/droid/MainActivity.java | 20 | ||||
| -rw-r--r-- | app/src/main/java/mygram/droid/Ui.java | 38 | ||||
| -rw-r--r-- | app/src/main/res/drawable/focus_glow.xml | 17 | ||||
| -rw-r--r-- | app/src/main/res/drawable/ic_home.xml | 6 |
4 files changed, 45 insertions, 36 deletions
diff --git a/app/src/main/java/mygram/droid/MainActivity.java b/app/src/main/java/mygram/droid/MainActivity.java index 7c29e0a..877f180 100644 --- a/app/src/main/java/mygram/droid/MainActivity.java +++ b/app/src/main/java/mygram/droid/MainActivity.java @@ -60,7 +60,7 @@ public final class MainActivity extends Activity { private HomeRows homeRows; private int tab = HOME; private boolean ready, resumed, homeLoading; - private ImageView logo; + private LinearLayout homeButton, likedButton, foldersButton; @Override protected void onCreate(Bundle state) { @@ -93,19 +93,20 @@ public final class MainActivity extends Activity { connect(); } - /** [logo] [Reels] [Liked] [Folders] [Settings] */ + /** [logo] [Reels] [Liked] [Folders] [Settings]; the current view is marked. */ private View topBar() { LinearLayout bar = new LinearLayout(this); bar.setGravity(Gravity.CENTER_VERTICAL); int p = Ui.dp(this, 16); bar.setPadding(p * 2, p, p * 2, 0); - LinearLayout home = Ui.iconButton(this, R.drawable.ic_home, "Home", v -> show(HOME)); - logo = (ImageView) home.getChildAt(0); - bar.addView(home); + homeButton = Ui.iconButton(this, R.drawable.ic_launcher, "Home", v -> show(HOME)); + bar.addView(homeButton); bar.addView(new Space(this), new LinearLayout.LayoutParams(0, 1, 1)); bar.addView(Ui.iconButton(this, R.drawable.ic_reels, "Reels", v -> Playlist.openReels(this))); - bar.addView(Ui.iconButton(this, R.drawable.ic_favorite, "Liked", v -> show(LIKED))); - bar.addView(Ui.iconButton(this, R.drawable.ic_folder, "Folders", v -> show(FOLDERS))); + likedButton = Ui.iconButton(this, R.drawable.ic_favorite, "Liked", v -> show(LIKED)); + bar.addView(likedButton); + foldersButton = Ui.iconButton(this, R.drawable.ic_folder, "Folders", v -> show(FOLDERS)); + bar.addView(foldersButton); bar.addView(new Space(this), new LinearLayout.LayoutParams(0, 1, 1)); bar.addView(Ui.iconButton(this, R.drawable.ic_settings, "Settings", v -> startActivity(new Intent(this, SettingsActivity.class)))); @@ -123,8 +124,6 @@ public final class MainActivity extends Activity { if (isDestroyed()) return; ready = true; - // Foldergram's logo is AGPLv3: loaded from the instance after login, never bundled. - Glide.with(logo).load(Api.resolve(Prefs.server(), "/icon-192.png")).error(R.drawable.ic_home).into(logo); backgrounds = posts; handler.removeCallbacks(rotate); rotateBackground(); @@ -151,6 +150,9 @@ public final class MainActivity extends Activity { if (!ready) return; tab = t; + Ui.markCurrent(homeButton, t == HOME); + Ui.markCurrent(likedButton, t == LIKED); + Ui.markCurrent(foldersButton, t == FOLDERS); if (t == HOME) { if (homeList != null) { setContent(homeList); 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)); } diff --git a/app/src/main/res/drawable/focus_glow.xml b/app/src/main/res/drawable/focus_glow.xml deleted file mode 100644 index e90b268..0000000 --- a/app/src/main/res/drawable/focus_glow.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2026 Danilo M. <danix@danix.xyz> - Licensed under the GNU General Public License version 2 only. --> -<!-- Icon buttons: a soft highlight behind the icon instead of a ring. --> -<selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_focused="true"> - <shape> - <corners android:radius="16dp" /> - <solid android:color="#40FFFFFF" /> - </shape> - </item> - <item> - <shape> - <solid android:color="#00000000" /> - </shape> - </item> -</selector> diff --git a/app/src/main/res/drawable/ic_home.xml b/app/src/main/res/drawable/ic_home.xml deleted file mode 100644 index 5503d0c..0000000 --- a/app/src/main/res/drawable/ic_home.xml +++ /dev/null @@ -1,6 +0,0 @@ -<!-- Material Icons "home", Apache License 2.0 --> -<vector xmlns:android="http://schemas.android.com/apk/res/android" - android:width="24dp" android:height="24dp" - android:viewportWidth="24" android:viewportHeight="24"> - <path android:fillColor="#FFFFFFFF" android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" /> -</vector> |
