diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-22 17:52:22 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-22 17:52:22 +0200 |
| commit | 9fba091bb394e8e4c7e8ccd0702081bd1a939047 (patch) | |
| tree | d21c451a94452d2b36dfccca35b1b45adfc2bc59 /app/src/main/java/mygram/droid/Ui.java | |
| parent | 899b1d9812c61a33554b67e3026850684e686ce1 (diff) | |
| download | mygram-droid-9fba091bb394e8e4c7e8ccd0702081bd1a939047.tar.gz mygram-droid-9fba091bb394e8e4c7e8ccd0702081bd1a939047.zip | |
Folder pictures, photo/video tile marks, folder in the viewer
Home rows and the folder header show the folder's round picture next to
its name. Post tiles carry a photo or video mark in the top left, on a
dark dot so it reads on bright thumbnails. The viewer shows the current
post's folder picture and name in the top left; pictures come from the
last loaded folder list, so before one loads only the name shows.
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.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/src/main/java/mygram/droid/Ui.java b/app/src/main/java/mygram/droid/Ui.java index 172fbff..6667d33 100644 --- a/app/src/main/java/mygram/droid/Ui.java +++ b/app/src/main/java/mygram/droid/Ui.java @@ -33,6 +33,8 @@ import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.bumptech.glide.Glide; + import java.util.ArrayList; import java.util.List; @@ -156,17 +158,42 @@ final class Ui { /** Back arrow and title, for screens outside the main view. */ static LinearLayout header(Activity a, String title) { + return header(a, title, null); + } + + /** Back arrow, the folder picture when there is one, and title. */ + static LinearLayout header(Activity a, String title, String avatarUrl) { LinearLayout header = new LinearLayout(a); header.setGravity(Gravity.CENTER_VERTICAL); int p = dp(a, 16); header.setPadding(p * 2, p, p * 2, 0); header.addView(iconButton(a, R.drawable.ic_arrow_back, "Back", v -> a.finish())); + ImageView avatar = avatar(a, 40); + ((LinearLayout.LayoutParams) avatar.getLayoutParams()).leftMargin = p; + header.addView(avatar); + setAvatar(avatar, avatarUrl); TextView t = text(a, title, 24); t.setPadding(p, 0, 0, 0); header.addView(t); return header; } + /** A round folder picture of size dp, for a horizontal LinearLayout. */ + static ImageView avatar(Context c, int size) { + ImageView v = new ImageView(c); + v.setLayoutParams(new LinearLayout.LayoutParams(dp(c, size), dp(c, size))); + return v; + } + + /** Loads url round, or hides the view when the folder has no picture. */ + static void setAvatar(ImageView v, String url) { + v.setVisibility(url == null ? View.GONE : View.VISIBLE); + if (url == null) + Glide.with(v).clear(v); + else + Glide.with(v).load(url).circleCrop().into(v); + } + static void blur(ImageView v, float radius) { v.setRenderEffect(RenderEffect.createBlurEffect(radius, radius, Shader.TileMode.CLAMP)); } |
