Make layout more compact + prepare code for expandable cards

pull/154/head
Fox2Code 2 years ago
parent f312071707
commit 5c37ee1dbb

@ -252,8 +252,8 @@ public class MainActivity extends CompatActivity implements SwipeRefreshLayout.O
swipeRefreshLayoutOrigStartOffset + combinedBarsHeight,
swipeRefreshLayoutOrigEndOffset + combinedBarsHeight);
this.moduleViewListBuilder.setHeaderPx(Math.max(statusBarHeight,
combinedBarsHeight - CompatDisplay.dpToPixel(12)));
this.moduleViewListBuilder.setFooterPx(
combinedBarsHeight - CompatDisplay.dpToPixel(4)));
this.moduleViewListBuilder.setFooterPx(CompatDisplay.dpToPixel(4) +
bottomInset + this.searchCard.getHeight());
this.searchCard.setRadius(this.searchCard.getHeight() / 2F);
this.moduleViewListBuilder.updateInsets();

@ -36,14 +36,15 @@ public class AndroidacyRepoData extends RepoData {
OK_HTTP_URL_BUILDER.setHost$okhttp(".androidacy.com");
OK_HTTP_URL = OK_HTTP_URL_BUILDER.build();
}
// Avoid spamming requests to Androidacy
private long androidacyBlockade = 0;
public AndroidacyRepoData(String url, File cacheRoot,
SharedPreferences cachedPreferences) {
super(url, cacheRoot, cachedPreferences);
if (this.metaDataCache.exists()) {
this.androidacyBlockade = this.metaDataCache.lastModified() + 5_000L;
if (this.androidacyBlockade - 10_000L > System.currentTimeMillis()) {
this.androidacyBlockade = this.metaDataCache.lastModified() + 30_000L;
if (this.androidacyBlockade - 60_000L > System.currentTimeMillis()) {
this.androidacyBlockade = 0; // Don't allow time travel. Well why not???
}
}

@ -81,6 +81,8 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
private boolean initState;
public ModuleHolder moduleHolder;
public Drawable background;
private boolean canExpand;
private boolean expanded;
public ViewHolder(@NonNull View itemView) {
super(itemView);
@ -112,6 +114,11 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
} else if (moduleHolder.notificationType != null) {
onClickListener = moduleHolder.notificationType.onClickListener;
if (onClickListener != null) onClickListener.onClick(v);
} else if (this.canExpand) {
this.cardView.setClickable(false);
if (this.expanded) return;
this.expanded = true;
// TODO Animated expand code
}
}
});
@ -171,13 +178,17 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
this.cardView.setVisibility(View.GONE);
this.moduleHolder = null;
this.initState = false;
this.expanded = false;
return true;
} else if (moduleHolder != this.moduleHolder) {
this.expanded = false;
}
ModuleHolder.Type type = moduleHolder.getType();
ModuleHolder.Type vType = moduleHolder.getCompareType(type);
this.cardView.setVisibility(View.VISIBLE);
boolean showCaseMode = MainApplication.isShowcaseMode();
if (moduleHolder.isModuleHolder()) {
this.canExpand = false;
this.buttonAction.setVisibility(View.GONE);
LocalModuleInfo localModuleInfo = moduleHolder.moduleInfo;
if (localModuleInfo != null) {
@ -235,6 +246,8 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
this.updateText.setText(R.string.substratum_builtin_module);
} else {
this.updateText.setVisibility(View.GONE);
this.canExpand = false;
this.expanded = true;
}
this.actionButtonsTypes.clear();
moduleHolder.getButtons(itemView.getContext(), this.actionButtonsTypes, showCaseMode);
@ -256,6 +269,10 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
imageButton.setContentDescription(null);
}
}
if (this.actionButtonsTypes.isEmpty()) {
this.canExpand = false;
this.expanded = false;
}
this.cardView.setClickable(false);
if (moduleHolder.isModuleHolder() &&
moduleHolder.hasFlag(ModuleInfo.FLAG_MODULE_ACTIVE)) {
@ -264,6 +281,8 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
this.titleText.setTypeface(Typeface.DEFAULT);
}
} else {
this.canExpand = false;
this.expanded = false;
if (type == ModuleHolder.Type.SEPARATOR && moduleHolder.filterLevel != 0) {
this.buttonAction.setVisibility(View.VISIBLE);
this.buttonAction.setImageResource(moduleHolder.filterLevel);
@ -312,6 +331,7 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
// Coloration system
Drawable drawable = this.cardView.getBackground();
if (drawable != null) this.background = drawable;
this.invalidPropsChip.setVisibility(View.GONE);
if (type.hasBackground) {
if (drawable == null) {
this.cardView.setBackground(this.background);
@ -323,18 +343,14 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
backgroundAttr = moduleHolder.notificationType.backgroundAttr;
} else if (type == ModuleHolder.Type.INSTALLED &&
moduleHolder.hasFlag(ModuleInfo.FLAG_METADATA_INVALID)) {
invalidPropsChip.setOnClickListener(_view -> {
this.invalidPropsChip.setOnClickListener(_view -> {
MaterialAlertDialogBuilder builder =
new MaterialAlertDialogBuilder(_view.getContext());
builder
.setTitle(R.string.low_quality_module)
builder.setTitle(R.string.low_quality_module)
.setMessage("Actual description for Low-quality module")
.setCancelable(true)
.setPositiveButton(R.string.ok, (x, y) -> x.dismiss()).show();
});
this.invalidPropsChip.setVisibility(View.VISIBLE);
// Backup restore
// foregroundAttr = R.attr.colorOnError;
// backgroundAttr = R.attr.colorError;
@ -365,6 +381,11 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
} else {
this.titleText.setMinHeight(0);
}
if (this.expanded) {
// TODO Static expand code
} else {
// TODO Static retract code
}
this.moduleHolder = moduleHolder;
this.initState = false;
return false;

@ -9,7 +9,8 @@
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:gravity="center_vertical"
android:orientation="vertical">
android:orientation="vertical"
tools:ignore="RtlHardcoded,RtlSymmetry">
<com.google.android.material.card.MaterialCardView
android:id="@+id/card_view"
@ -22,19 +23,11 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- Media -->
<ImageView
android:layout_width="match_parent"
android:layout_height="194dp"
android:visibility="gone"
android:scaleType="centerCrop"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">
android:padding="6dp">
<!-- Module components -->
<LinearLayout
@ -58,6 +51,7 @@
<TextView
android:id="@+id/title_text"
android:paddingStart="2dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -87,6 +81,7 @@
<TextView
android:id="@+id/credit_text"
android:paddingStart="2dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/loading"
@ -96,6 +91,7 @@
/>
<TextView
android:id="@+id/description_text"
android:paddingStart="2dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
@ -107,6 +103,7 @@
<TextView
android:id="@+id/updated_text"
android:paddingStart="2dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
@ -127,7 +124,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:padding="4dp"
android:paddingRight="4dp"
android:paddingLeft="4dp"
app:singleLine="true">
<com.google.android.material.chip.Chip

@ -38,7 +38,7 @@
<string name="cancel" translatable="false">@android:string/cancel</string>
<!-- Module section translation -->
<string name="module_last_update">Last version:</string>
<string name="module_last_update">Last update:</string>
<string name="module_repo">Repo:</string>
<string name="module_by">by</string>
<string name="module_downloads">Downloads:</string>

@ -78,7 +78,7 @@
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
<item name="android:dialogCornerRadius" tools:targetApi="p">@dimen/card_corner_radius</item>
<item name="dialogCornerRadius">@dimen/card_corner_radius</item>
<item name="colorBackgroundFloating">#FF1E1E1E</item>
<item name="colorBackgroundFloating">#FF202020</item>
<item name="backgroundColor">#FF111111</item>
<item name="chipStyle">@style/Widget.Material.Chip.Choice.Dark</item>
</style>

Loading…
Cancel
Save