Skip to content

Commit c46b50e

Browse files
various fixes
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 4111b91 commit c46b50e

7 files changed

Lines changed: 61 additions & 12 deletions

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.fox2code.mmm.module.ModuleViewAdapter;
4747
import com.fox2code.mmm.module.ModuleViewListBuilder;
4848
import com.fox2code.mmm.repo.RepoManager;
49+
import com.fox2code.mmm.repo.RepoModule;
4950
import com.fox2code.mmm.settings.SettingsActivity;
5051
import com.fox2code.mmm.utils.ExternalHelper;
5152
import com.fox2code.mmm.utils.io.net.Http;
@@ -58,6 +59,8 @@
5859
import org.matomo.sdk.extra.TrackHelper;
5960

6061
import java.sql.Timestamp;
62+
import java.util.ArrayList;
63+
import java.util.List;
6164
import java.util.Objects;
6265

6366
import io.realm.Realm;
@@ -84,6 +87,8 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
8487
private CardView searchCard;
8588
private SearchView searchView;
8689
private boolean initMode;
90+
public static List<LocalModuleInfo> localModuleInfoList = new ArrayList<>();
91+
public static List<RepoModule> onlineModuleInfoList = new ArrayList<>();
8792

8893
public MainActivity() {
8994
this.moduleViewListBuilder = new ModuleViewListBuilder(this);
@@ -365,6 +370,8 @@ public void commonNext() {
365370
}
366371
if (BuildConfig.DEBUG) Timber.i("Apply");
367372
RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilderOnline::appendRemoteModules);
373+
moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter);
374+
moduleViewListBuilder.applyTo(moduleListOnline, moduleViewAdapterOnline);
368375
moduleViewListBuilderOnline.applyTo(moduleListOnline, moduleViewAdapterOnline);
369376
// if moduleViewListBuilderOnline has the upgradeable notification, show a badge on the online repo nav item
370377
if (MainApplication.getINSTANCE().modulesHaveUpdates) {
@@ -589,8 +596,8 @@ public void onRefresh() {
589596
NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilder);
590597
RepoManager.getINSTANCE().updateEnabledStates();
591598
RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilderOnline::appendRemoteModules);
592-
this.moduleViewListBuilderOnline.applyTo(moduleListOnline, moduleViewAdapterOnline);
593599
this.moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter);
600+
this.moduleViewListBuilderOnline.applyTo(moduleListOnline, moduleViewAdapterOnline);
594601
}, "Repo update thread").start();
595602
}
596603

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
import org.matomo.sdk.extra.TrackHelper;
2929

30+
import java.util.Objects;
31+
3032
import io.noties.markwon.Markwon;
3133
import timber.log.Timber;
3234

@@ -66,20 +68,24 @@ public boolean doActionLong(Chip button, ModuleHolder moduleHolder) {
6668
}, UPDATE_INSTALL() {
6769
@Override
6870
public void update(Chip button, ModuleHolder moduleHolder) {
69-
int icon = moduleHolder.hasUpdate() ? R.drawable.ic_baseline_update_24 : R.drawable.ic_baseline_system_update_24;
70-
button.setChipIcon(button.getContext().getDrawable(icon));
71+
int icon;
7172
if (moduleHolder.hasUpdate()) {
73+
icon = R.drawable.ic_baseline_update_24;
7274
button.setText(R.string.update);
75+
} else if (moduleHolder.moduleInfo != null) {
76+
icon = R.drawable.ic_baseline_refresh_24;
77+
button.setText(R.string.reinstall);
7378
} else {
79+
icon = R.drawable.ic_baseline_system_update_24;
7480
button.setText(R.string.install);
7581
}
82+
button.setChipIcon(button.getContext().getDrawable(icon));
7683
}
7784

7885
@Override
7986
public void doAction(Chip button, ModuleHolder moduleHolder) {
8087
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();
81-
if (moduleInfo == null)
82-
return;
88+
if (moduleInfo == null) return;
8389

8490
String name;
8591
if (moduleHolder.moduleInfo != null) {
@@ -89,8 +95,7 @@ public void doAction(Chip button, ModuleHolder moduleHolder) {
8995
}
9096
TrackHelper.track().event("view_update_install", name).with(MainApplication.getINSTANCE().getTracker());
9197
String updateZipUrl = moduleHolder.getUpdateZipUrl();
92-
if (updateZipUrl == null)
93-
return;
98+
if (updateZipUrl == null) return;
9499
// Androidacy manage the selection between download and install
95100
if (AndroidacyUtil.isAndroidacyLink(updateZipUrl)) {
96101
IntentHelper.openUrlAndroidacy(button.getContext(), updateZipUrl, true, moduleInfo.name, moduleInfo.config);
@@ -132,7 +137,7 @@ public void doAction(Chip button, ModuleHolder moduleHolder) {
132137
}
133138
}
134139
if (markwon != null) {
135-
TextView messageView = alertDialog.getWindow().findViewById(android.R.id.message);
140+
TextView messageView = Objects.requireNonNull(alertDialog.getWindow()).findViewById(android.R.id.message);
136141
markwon.setParsedMarkdown(messageView, (Spanned) desc);
137142
}
138143
}
@@ -197,8 +202,7 @@ public void update(Chip button, ModuleHolder moduleHolder) {
197202
@Override
198203
public void doAction(Chip button, ModuleHolder moduleHolder) {
199204
String config = moduleHolder.getMainModuleConfig();
200-
if (config == null)
201-
return;
205+
if (config == null) return;
202206

203207
String name;
204208
if (moduleHolder.moduleInfo != null) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
3232
public final Type separator;
3333
public int footerPx;
3434
public View.OnClickListener onClickListener;
35+
3536
public LocalModuleInfo moduleInfo;
3637
public RepoModule repoModule;
3738
public int filterLevel;

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import com.fox2code.mmm.AppUpdateManager;
1010
import com.fox2code.mmm.BuildConfig;
11+
import com.fox2code.mmm.MainActivity;
1112
import com.fox2code.mmm.MainApplication;
1213
import com.fox2code.mmm.NotificationType;
1314
import com.fox2code.mmm.installer.InstallerInitializer;
@@ -84,6 +85,8 @@ public void appendInstalledModules() {
8485
moduleManager.runAfterScan(() -> {
8586
Timber.i("A1: %s", moduleManager.getModules().size());
8687
for (LocalModuleInfo moduleInfo : moduleManager.getModules().values()) {
88+
// add the local module to the list in MainActivity
89+
MainActivity.localModuleInfoList.add(moduleInfo);
8790
ModuleHolder moduleHolder = this.mappedModuleHolders.get(moduleInfo.id);
8891
if (moduleHolder == null) {
8992
this.mappedModuleHolders.put(moduleInfo.id,
@@ -109,6 +112,8 @@ public void appendRemoteModules() {
109112
Timber.i("A2: %s", repoManager.getModules().size());
110113
boolean no32bitSupport = Build.SUPPORTED_32_BIT_ABIS.length == 0;
111114
for (RepoModule repoModule : repoManager.getModules().values()) {
115+
// add the remote module to the list in MainActivity
116+
MainActivity.onlineModuleInfoList.add(repoModule);
112117
// if repoData is null, something is wrong
113118
if (repoModule.repoData == null) {
114119
Timber.w("RepoData is null for module %s", repoModule.id);
@@ -138,6 +143,14 @@ public void appendRemoteModules() {
138143
moduleHolder = new ModuleHolder(repoModule.id));
139144
}
140145
moduleHolder.repoModule = repoModule;
146+
// check if local module is installed
147+
// iterate over MainActivity.localModuleInfoList until we hit the module with the same id
148+
for (LocalModuleInfo localModuleInfo : MainActivity.localModuleInfoList) {
149+
if (localModuleInfo.id.equals(repoModule.id)) {
150+
moduleHolder.moduleInfo = localModuleInfo;
151+
break;
152+
}
153+
}
141154
}
142155
});
143156
}
@@ -174,7 +187,7 @@ private boolean matchFilter(ModuleHolder moduleHolder) {
174187
return false;
175188
}
176189

177-
public void applyTo(final RecyclerView moduleList,final ModuleViewAdapter moduleViewAdapter) {
190+
public void applyTo(final RecyclerView moduleList, final ModuleViewAdapter moduleViewAdapter) {
178191
if (this.updating) return;
179192
this.updating = true;
180193
ModuleManager.getINSTANCE().afterScan();

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<item name="android:windowActionBar">false</item>
1616
<item name="android:windowNoTitle">true</item>
1717
<item name="android:actionBarStyle">@style/Theme.Design.NoActionBar</item>
18+
<item name="cornerRadius">@dimen/card_corner_radius</item>
19+
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
1820
</style>
1921

2022
<style name="Widget.Material3.Chip.Choice.Light" parent="Widget.Material3.Chip.Assist">
@@ -36,6 +38,8 @@
3638
<item name="android:windowActionBar">false</item>
3739
<item name="android:windowNoTitle">true</item>
3840
<item name="android:actionBarStyle">@style/Theme.Design.NoActionBar</item>
41+
<item name="cornerRadius">@dimen/card_corner_radius</item>
42+
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
3943
</style>
4044

4145
<!-- Black monet theme, which is just dark monet theme with black background -->
@@ -63,6 +67,8 @@
6367
<item name="android:windowActionBar">false</item>
6468
<item name="android:windowNoTitle">true</item>
6569
<item name="android:actionBarStyle">@style/Theme.Design.NoActionBar</item>
70+
<item name="cornerRadius">@dimen/card_corner_radius</item>
71+
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
6672
</style>
6773

6874
<style name="Widget.Material3.Chip.Choice.Dark" parent="Widget.Material3.Chip.Assist">

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,5 @@
412412
<string name="donate_androidacy_sum">Buy a premium subscription to Androidacy to support the app and the repo.</string>
413413
<string name="promo_code_copied">Use the copied code for half off your first month!</string>
414414
<string name="warning_pls_restart">Please note that some settings may not take effect until you restart the app.</string>
415+
<string name="reinstall">Reinstall</string>
415416
</resources>

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<item name="windowNoTitle">true</item>
3636
<item name="android:windowActionBar">false</item>
3737
<item name="android:windowNoTitle">true</item>
38+
<item name="cornerRadius">@dimen/card_corner_radius</item>
3839
</style>
3940

4041
<style name="Widget.Material3.Chip.Choice.Light" parent="Widget.Material3.Chip.Assist">
@@ -68,6 +69,8 @@
6869
<item name="windowNoTitle">true</item>
6970
<item name="android:windowActionBar">false</item>
7071
<item name="android:windowNoTitle">true</item>
72+
<item name="cornerRadius">@dimen/card_corner_radius</item>
73+
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
7174
</style>
7275

7376
<style name="Theme.MagiskModuleManager.Dark" parent="Theme.Material3.Dark">
@@ -104,6 +107,8 @@
104107
<item name="windowNoTitle">true</item>
105108
<item name="android:windowActionBar">false</item>
106109
<item name="android:windowNoTitle">true</item>
110+
<item name="cornerRadius">@dimen/card_corner_radius</item>
111+
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
107112
</style>
108113

109114
<!-- Black theme, which is just a dark theme with a black background -->
@@ -118,7 +123,6 @@
118123
<item name="colorPrimaryVariant">@color/orange_700</item>
119124
<item name="colorSecondary">@color/orange_500</item>
120125
<item name="colorSecondaryVariant">@color/orange_700</item>
121-
<!-- Fix some unthemed dialogs -->
122126
<item name="android:colorAccent">@color/orange_200</item>
123127
<item name="android:colorBackground">@color/black</item>
124128
<item name="android:colorForeground">@color/white</item>
@@ -133,6 +137,8 @@
133137
<item name="windowNoTitle">true</item>
134138
<item name="android:windowActionBar">false</item>
135139
<item name="android:windowNoTitle">true</item>
140+
<item name="cornerRadius">@dimen/card_corner_radius</item>
141+
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
136142
</style>
137143

138144
<style name="Widget.Material.Chip.Choice.Dark" parent="Widget.MaterialComponents.Chip.Action">
@@ -159,6 +165,8 @@
159165
<!-- fonts -->
160166
<item name="android:fontFamily">@font/inter</item>
161167
<item name="font">@font/inter</item>
168+
<item name="cornerRadius">@dimen/card_corner_radius</item>
169+
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
162170
</style>
163171

164172
<style name="Theme.MagiskModuleManager" parent="Theme.MagiskModuleManager.Light" />
@@ -173,4 +181,13 @@
173181
<style name="Theme.MagiskModuleManager.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
174182

175183
<style name="Theme.MagiskModuleManager.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
184+
185+
186+
187+
<style name="Theme.MagiskModuleManager.AlertDialog" parent="ThemeOverlay.Material3.MaterialAlertDialog">
188+
<item name="dialogCornerRadius">28dp</item>
189+
<item name="cornerFamily">rounded</item>
190+
<item name="android:colorBackground">?attr/colorSurface</item>
191+
<item name="android:layout" tools:ignore="PrivateResource">@layout/m3_alert_dialog</item>
192+
</style>
176193
</resources>

0 commit comments

Comments
 (0)