aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/mygram
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/mygram')
-rw-r--r--app/src/main/java/mygram/droid/MainActivity.java20
-rw-r--r--app/src/main/java/mygram/droid/Ui.java38
2 files changed, 45 insertions, 13 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));
}