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

Commit 08989be

Browse files
tweak some last things
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent efd5391 commit 08989be

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,42 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
541541
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show();
542542
return true;
543543
});
544+
// Next, the pref_androidacy_thanks should lead to the androidacy website
545+
linkClickable = findPreference("pref_androidacy_thanks");
546+
linkClickable.setOnPreferenceClickListener(p -> {
547+
IntentHelper.openUrl(p.getContext(), "https://www.androidacy.com?utm_source=FoxMagiskModuleManager&utm_medium=app&utm_campaign=FoxMagiskModuleManager");
548+
return true;
549+
});
550+
linkClickable.setOnPreferenceLongClickListener(p -> {
551+
String toastText = requireContext().getString(R.string.link_copied);
552+
clipboard.setPrimaryClip(ClipData.newPlainText(toastText, "https://www.androidacy.com?utm_source=FoxMagiskModuleManager&utm_medium=app&utm_campaign=FoxMagiskModuleManager"));
553+
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show();
554+
return true;
555+
});
556+
// pref_contributors should lead to the contributors page
557+
linkClickable = findPreference("pref_contributors");
558+
linkClickable.setOnPreferenceClickListener(p -> {
559+
// Remove the .git if it exists and add /graphs/contributors
560+
String url = BuildConfig.REMOTE_URL;
561+
if (url.endsWith(".git")) {
562+
url = url.substring(0, url.length() - 4);
563+
}
564+
url += "/graphs/contributors";
565+
IntentHelper.openUrl(p.getContext(), url);
566+
return true;
567+
});
568+
linkClickable.setOnPreferenceLongClickListener(p -> {
569+
String toastText = requireContext().getString(R.string.link_copied);
570+
// Remove the .git if it exists and add /graphs/contributors
571+
String url = BuildConfig.REMOTE_URL;
572+
if (url.endsWith(".git")) {
573+
url = url.substring(0, url.length() - 4);
574+
}
575+
url += "/graphs/contributors";
576+
clipboard.setPrimaryClip(ClipData.newPlainText(toastText, url));
577+
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show();
578+
return true;
579+
});
544580
linkClickable = findPreference("pref_support");
545581
linkClickable.setOnPreferenceClickListener(p -> {
546582
devModeStep = 0;

app/src/main/java/com/fox2code/mmm/utils/ZipFileOpener.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.io.File;
1717
import java.io.FileOutputStream;
18+
import java.io.IOException;
1819
import java.io.InputStream;
1920

2021
public class ZipFileOpener extends FoxActivity {
@@ -30,6 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
3031
File zipFile;
3132
Uri uri = getIntent().getData();
3233
if (uri == null) {
34+
Log.e("ZipFileOpener", "onCreate: No data provided");
3335
Toast.makeText(this, R.string.zip_load_failed, Toast.LENGTH_LONG).show();
3436
finish();
3537
return;
@@ -63,6 +65,30 @@ protected void onCreate(Bundle savedInstanceState) {
6365
Toast.makeText(this, R.string.zip_load_failed, Toast.LENGTH_LONG).show();
6466
finishAndRemoveTask();
6567
return;
68+
} else {
69+
if (BuildConfig.DEBUG) {
70+
Log.d("ZipFileOpener", "onCreate: Zip file is " + zipFile.length() + " bytes");
71+
}
72+
}
73+
// Unpack the zip to validate it's a valid magisk module
74+
// It needs to have, at the bare minimum, a module.prop file. Everything else is technically optional.
75+
// First, check if it's a zip file
76+
try (java.util.zip.ZipFile zip = new java.util.zip.ZipFile(zipFile)) {
77+
if (zip.getEntry("module.prop") == null) {
78+
Log.e(TAG, "onCreate: Zip file is not a valid magisk module");
79+
Toast.makeText(this, R.string.invalid_format, Toast.LENGTH_LONG).show();
80+
finishAndRemoveTask();
81+
return;
82+
}
83+
} catch (
84+
IOException e) {
85+
Log.e(TAG, "onCreate: Failed to open zip file", e);
86+
Toast.makeText(this, R.string.zip_load_failed, Toast.LENGTH_LONG).show();
87+
finishAndRemoveTask();
88+
return;
89+
}
90+
if (BuildConfig.DEBUG) {
91+
Log.d("ZipFileOpener", "onCreate: Zip file is valid");
6692
}
6793
// Pass the file to the installer
6894
FoxActivity compatActivity = FoxActivity.getFoxActivity(this);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp"
2+
android:height="24dp" android:autoMirrored="true"
3+
android:tint="?attr/colorControlNormal" android:viewportWidth="24" android:viewportHeight="24">
4+
<path
5+
android:fillColor="@android:color/white" android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z" />
6+
</vector>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,5 +267,7 @@
267267
<string name="androidacy_update_needed">This app is outdated.</string>
268268
<string name="androidacy_update_needed_message">Please update the app to the latest version.</string>
269269
<string name="androidacy_webview_update_required">Your webview is outdated! Please update it.</string><string name="language_cta">Don\'t see your language?</string><string name="language_cta_desc">Help us by translating it! Tap here to find out more.</string>
270-
<string name="source_code_summary"><b>Commit</b> %1$s @ %2$s</string><string name="no_file_provided">No file was provided when trying to open zip.</string><string name="zip_load_failed">Could not load the zip file</string>
270+
<string name="source_code_summary"><b>Commit</b> %1$s @ %2$s</string>
271+
<string name="no_file_provided">No file was provided when trying to open zip.</string>
272+
<string name="zip_load_failed">Could not load the zip file</string><string name="androidacy_thanks">Developed in part by Androidacy</string><string name="androidacy_thanks_desc">Huge shoutout to Androidacy for their integration and contributions to the app.</string><string name="contributors">And of course, thanks to all of our contributors, whether it\'s translations, code, or just being fun to hang out with! We love you all.</string>
271273
</resources>

app/src/main/res/xml/root_preferences.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@
174174
app:key="pref_show_licenses"
175175
app:singleLineTitle="false"
176176
app:title="@string/show_licenses" />
177+
<!-- Small lil thanks to Androidacy -->
178+
<com.fox2code.mmm.settings.LongClickablePreference
179+
app:icon="@drawable/baseline_favorite_24"
180+
app:key="pref_androidacy_thanks"
181+
app:singleLineTitle="false"
182+
app:summary="@string/androidacy_thanks_desc"
183+
app:title="@string/androidacy_thanks" />
184+
<!-- OKay, so we'll thank all the other contributors too -->
185+
<com.fox2code.mmm.settings.LongClickablePreference
186+
android:textAppearance="?android:attr/textAppearanceSmall"
187+
app:iconSpaceReserved="false"
188+
app:key="pref_contributors"
189+
app:singleLineTitle="false"
190+
app:title="@string/contributors" />
191+
<!-- And the translators -->
177192
<Preference
178193
app:enabled="false"
179194
app:iconSpaceReserved="false"

0 commit comments

Comments
 (0)