Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 5c37ee1

Browse files
committed
Make layout more compact + prepare code for expandable cards
1 parent f312071 commit 5c37ee1

File tree

6 files changed

+43
-23
lines changed

6 files changed

+43
-23
lines changed

app/src/main/java/com/fox2code/mmm/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ private void updateScreenInsets(Configuration configuration) {
252252
swipeRefreshLayoutOrigStartOffset + combinedBarsHeight,
253253
swipeRefreshLayoutOrigEndOffset + combinedBarsHeight);
254254
this.moduleViewListBuilder.setHeaderPx(Math.max(statusBarHeight,
255-
combinedBarsHeight - CompatDisplay.dpToPixel(12)));
256-
this.moduleViewListBuilder.setFooterPx(
255+
combinedBarsHeight - CompatDisplay.dpToPixel(4)));
256+
this.moduleViewListBuilder.setFooterPx(CompatDisplay.dpToPixel(4) +
257257
bottomInset + this.searchCard.getHeight());
258258
this.searchCard.setRadius(this.searchCard.getHeight() / 2F);
259259
this.moduleViewListBuilder.updateInsets();

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ public class AndroidacyRepoData extends RepoData {
3636
OK_HTTP_URL_BUILDER.setHost$okhttp(".androidacy.com");
3737
OK_HTTP_URL = OK_HTTP_URL_BUILDER.build();
3838
}
39+
// Avoid spamming requests to Androidacy
3940
private long androidacyBlockade = 0;
4041

4142
public AndroidacyRepoData(String url, File cacheRoot,
4243
SharedPreferences cachedPreferences) {
4344
super(url, cacheRoot, cachedPreferences);
4445
if (this.metaDataCache.exists()) {
45-
this.androidacyBlockade = this.metaDataCache.lastModified() + 5_000L;
46-
if (this.androidacyBlockade - 10_000L > System.currentTimeMillis()) {
46+
this.androidacyBlockade = this.metaDataCache.lastModified() + 30_000L;
47+
if (this.androidacyBlockade - 60_000L > System.currentTimeMillis()) {
4748
this.androidacyBlockade = 0; // Don't allow time travel. Well why not???
4849
}
4950
}

app/src/main/java/com/fox2code/mmm/module/ModuleViewAdapter.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public static class ViewHolder extends RecyclerView.ViewHolder {
8181
private boolean initState;
8282
public ModuleHolder moduleHolder;
8383
public Drawable background;
84+
private boolean canExpand;
85+
private boolean expanded;
8486

8587
public ViewHolder(@NonNull View itemView) {
8688
super(itemView);
@@ -112,6 +114,11 @@ public ViewHolder(@NonNull View itemView) {
112114
} else if (moduleHolder.notificationType != null) {
113115
onClickListener = moduleHolder.notificationType.onClickListener;
114116
if (onClickListener != null) onClickListener.onClick(v);
117+
} else if (this.canExpand) {
118+
this.cardView.setClickable(false);
119+
if (this.expanded) return;
120+
this.expanded = true;
121+
// TODO Animated expand code
115122
}
116123
}
117124
});
@@ -171,13 +178,17 @@ public boolean update(ModuleHolder moduleHolder) {
171178
this.cardView.setVisibility(View.GONE);
172179
this.moduleHolder = null;
173180
this.initState = false;
181+
this.expanded = false;
174182
return true;
183+
} else if (moduleHolder != this.moduleHolder) {
184+
this.expanded = false;
175185
}
176186
ModuleHolder.Type type = moduleHolder.getType();
177187
ModuleHolder.Type vType = moduleHolder.getCompareType(type);
178188
this.cardView.setVisibility(View.VISIBLE);
179189
boolean showCaseMode = MainApplication.isShowcaseMode();
180190
if (moduleHolder.isModuleHolder()) {
191+
this.canExpand = false;
181192
this.buttonAction.setVisibility(View.GONE);
182193
LocalModuleInfo localModuleInfo = moduleHolder.moduleInfo;
183194
if (localModuleInfo != null) {
@@ -235,6 +246,8 @@ public boolean update(ModuleHolder moduleHolder) {
235246
this.updateText.setText(R.string.substratum_builtin_module);
236247
} else {
237248
this.updateText.setVisibility(View.GONE);
249+
this.canExpand = false;
250+
this.expanded = true;
238251
}
239252
this.actionButtonsTypes.clear();
240253
moduleHolder.getButtons(itemView.getContext(), this.actionButtonsTypes, showCaseMode);
@@ -256,6 +269,10 @@ public boolean update(ModuleHolder moduleHolder) {
256269
imageButton.setContentDescription(null);
257270
}
258271
}
272+
if (this.actionButtonsTypes.isEmpty()) {
273+
this.canExpand = false;
274+
this.expanded = false;
275+
}
259276
this.cardView.setClickable(false);
260277
if (moduleHolder.isModuleHolder() &&
261278
moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_ACTIVE)) {
@@ -264,6 +281,8 @@ public boolean update(ModuleHolder moduleHolder) {
264281
this.titleText.setTypeface(Typeface.DEFAULT);
265282
}
266283
} else {
284+
this.canExpand = false;
285+
this.expanded = false;
267286
if (type == ModuleHolder.Type.SEPARATOR && moduleHolder.filterLevel != 0) {
268287
this.buttonAction.setVisibility(View.VISIBLE);
269288
this.buttonAction.setImageResource(moduleHolder.filterLevel);
@@ -312,6 +331,7 @@ public boolean update(ModuleHolder moduleHolder) {
312331
// Coloration system
313332
Drawable drawable = this.cardView.getBackground();
314333
if (drawable != null) this.background = drawable;
334+
this.invalidPropsChip.setVisibility(View.GONE);
315335
if (type.hasBackground) {
316336
if (drawable == null) {
317337
this.cardView.setBackground(this.background);
@@ -323,18 +343,14 @@ public boolean update(ModuleHolder moduleHolder) {
323343
backgroundAttr = moduleHolder.notificationType.backgroundAttr;
324344
} else if (type == ModuleHolder.Type.INSTALLED &&
325345
moduleHolder.hasFlag(ModuleInfo.FLAG_METADATA_INVALID)) {
326-
invalidPropsChip.setOnClickListener(_view -> {
346+
this.invalidPropsChip.setOnClickListener(_view -> {
327347
MaterialAlertDialogBuilder builder =
328348
new MaterialAlertDialogBuilder(_view.getContext());
329-
330-
builder
331-
.setTitle(R.string.low_quality_module)
349+
builder.setTitle(R.string.low_quality_module)
332350
.setMessage("Actual description for Low-quality module")
333351
.setCancelable(true)
334352
.setPositiveButton(R.string.ok, (x, y) -> x.dismiss()).show();
335-
336353
});
337-
this.invalidPropsChip.setVisibility(View.VISIBLE);
338354
// Backup restore
339355
// foregroundAttr = R.attr.colorOnError;
340356
// backgroundAttr = R.attr.colorError;
@@ -365,6 +381,11 @@ public boolean update(ModuleHolder moduleHolder) {
365381
} else {
366382
this.titleText.setMinHeight(0);
367383
}
384+
if (this.expanded) {
385+
// TODO Static expand code
386+
} else {
387+
// TODO Static retract code
388+
}
368389
this.moduleHolder = moduleHolder;
369390
this.initState = false;
370391
return false;

app/src/main/res/layout/module_entry.xml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
android:layout_marginTop="2dp"
1010
android:layout_marginBottom="2dp"
1111
android:gravity="center_vertical"
12-
android:orientation="vertical">
12+
android:orientation="vertical"
13+
tools:ignore="RtlHardcoded,RtlSymmetry">
1314

1415
<com.google.android.material.card.MaterialCardView
1516
android:id="@+id/card_view"
@@ -22,19 +23,11 @@
2223
android:layout_height="wrap_content"
2324
android:orientation="vertical">
2425

25-
<!-- Media -->
26-
<ImageView
27-
android:layout_width="match_parent"
28-
android:layout_height="194dp"
29-
android:visibility="gone"
30-
android:scaleType="centerCrop"
31-
tools:ignore="ContentDescription" />
32-
3326
<LinearLayout
3427
android:layout_width="match_parent"
3528
android:layout_height="wrap_content"
3629
android:orientation="vertical"
37-
android:padding="8dp">
30+
android:padding="6dp">
3831

3932
<!-- Module components -->
4033
<LinearLayout
@@ -58,6 +51,7 @@
5851

5952
<TextView
6053
android:id="@+id/title_text"
54+
android:paddingStart="2dp"
6155
android:layout_width="0dp"
6256
android:layout_height="wrap_content"
6357
android:layout_weight="1"
@@ -87,6 +81,7 @@
8781

8882
<TextView
8983
android:id="@+id/credit_text"
84+
android:paddingStart="2dp"
9085
android:layout_width="wrap_content"
9186
android:layout_height="wrap_content"
9287
android:text="@string/loading"
@@ -96,6 +91,7 @@
9691
/>
9792
<TextView
9893
android:id="@+id/description_text"
94+
android:paddingStart="2dp"
9995
android:layout_width="wrap_content"
10096
android:layout_height="wrap_content"
10197
android:layout_marginTop="4dp"
@@ -107,6 +103,7 @@
107103

108104
<TextView
109105
android:id="@+id/updated_text"
106+
android:paddingStart="2dp"
110107
android:layout_width="wrap_content"
111108
android:layout_height="wrap_content"
112109
android:layout_gravity="center_vertical"
@@ -127,7 +124,8 @@
127124
android:layout_width="wrap_content"
128125
android:layout_height="wrap_content"
129126
android:layout_gravity="end"
130-
android:padding="4dp"
127+
android:paddingRight="4dp"
128+
android:paddingLeft="4dp"
131129
app:singleLine="true">
132130

133131
<com.google.android.material.chip.Chip

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<string name="cancel" translatable="false">@android:string/cancel</string>
3939

4040
<!-- Module section translation -->
41-
<string name="module_last_update">Last version:</string>
41+
<string name="module_last_update">Last update:</string>
4242
<string name="module_repo">Repo:</string>
4343
<string name="module_by">by</string>
4444
<string name="module_downloads">Downloads:</string>

app/src/main/res/values/themes.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
7979
<item name="android:dialogCornerRadius" tools:targetApi="p">@dimen/card_corner_radius</item>
8080
<item name="dialogCornerRadius">@dimen/card_corner_radius</item>
81-
<item name="colorBackgroundFloating">#FF1E1E1E</item>
81+
<item name="colorBackgroundFloating">#FF202020</item>
8282
<item name="backgroundColor">#FF111111</item>
8383
<item name="chipStyle">@style/Widget.Material.Chip.Choice.Dark</item>
8484
</style>

0 commit comments

Comments
 (0)