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

Commit 5d941ae

Browse files
Tweaks and cleanup
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 16cf6d4 commit 5d941ae

File tree

19 files changed

+102
-24
lines changed

19 files changed

+102
-24
lines changed

app/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ android {
8181
flavorDimensions "type"
8282
productFlavors {
8383
"default" {
84+
// Latest commit hash as BuildConfig.COMMIT_HASH
85+
def gitCommitHash = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
86+
buildConfigField "String", "COMMIT_HASH", "\"${gitCommitHash}\""
87+
// Get the current branch name as BuildConfig.BRANCH_NAME
88+
def gitBranchName = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).text.trim()
89+
buildConfigField "String", "BRANCH_NAME", "\"${gitBranchName}\""
90+
// Get remote url as BuildConfig.REMOTE_URL
91+
def gitRemoteUrl = 'git config --get remote.origin.url'.execute([], project.rootDir).text.trim()
92+
buildConfigField "String", "REMOTE_URL", "\"${gitRemoteUrl}\""
8493
dimension "type"
8594
buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "true"
8695
buildConfigField "boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true"
@@ -119,6 +128,16 @@ android {
119128
dimension "type"
120129
applicationIdSuffix ".fdroid"
121130

131+
// Latest commit hash as BuildConfig.COMMIT_HASH
132+
def gitCommitHash = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
133+
buildConfigField "String", "COMMIT_HASH", "\"${gitCommitHash}\""
134+
// Get the current branch name as BuildConfig.BRANCH_NAME
135+
def gitBranchName = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).text.trim()
136+
buildConfigField "String", "BRANCH_NAME", "\"${gitBranchName}\""
137+
// Get remote url as BuildConfig.REMOTE_URL
138+
def gitRemoteUrl = 'git config --get remote.origin.url'.execute([], project.rootDir).text.trim()
139+
buildConfigField "String", "REMOTE_URL", "\"${gitRemoteUrl}\""
140+
122141
// Need to disable auto-updater for F-Droid flavor because their inclusion policy
123142
// forbids downloading blobs from third-party websites (and F-Droid APK isn't signed
124143
// with our keys, so the APK wouldn't install anyways).

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ public void commonNext() {
257257
Log.i("NoodleDebug", "Check Update");
258258
RepoManager.getINSTANCE().update(value -> runOnUiThread(max == 0 ? () -> progressIndicator.setProgressCompat((int) (value * PRECISION), true) : () -> progressIndicator.setProgressCompat((int) (value * PRECISION * 0.75F), true)));
259259
NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilder);
260-
260+
// Add debug notification for debug builds
261+
if (!NotificationType.DEBUG.shouldRemove()) {
262+
moduleViewListBuilder.addNotification(NotificationType.DEBUG);
263+
}
261264
if (!NotificationType.NO_INTERNET.shouldRemove()) {
262265
moduleViewListBuilder.addNotification(NotificationType.NO_INTERNET);
263266
} else if (!NotificationType.REPO_UPDATE_FAILED.shouldRemove()) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ public void onCreate() {
280280
INSTANCE = this;
281281
relPackageName = this.getPackageName();
282282
super.onCreate();
283+
if (BuildConfig.DEBUG) {
284+
Log.d("MainApplication", "Starting FoxMMM version " + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + "), commit " + BuildConfig.COMMIT_HASH);
285+
}
283286
SharedPreferences sharedPreferences = MainApplication.getSharedPreferences();
284287
// We are only one process so it's ok to do this
285288
SharedPreferences bootPrefs = MainApplication.bootSharedPreferences = this.getSharedPreferences("mmm_boot", MODE_PRIVATE);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public enum NotificationType implements NotificationTypeCst {
2929
DEBUG(R.string.debug_build, R.drawable.ic_baseline_bug_report_24) {
3030
@Override
3131
public boolean shouldRemove() {
32-
return BuildConfig.DEBUG;
32+
return !BuildConfig.DEBUG;
3333
}
3434
},
3535
SHOWCASE_MODE(R.string.showcase_mode, R.drawable.ic_baseline_lock_24,

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

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,26 +333,31 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
333333
});
334334

335335
// Warning! Locales that are't exist will crash the app
336+
// Anything that is commented out is supported but the translation is not complete to at least 60%
336337
HashSet<String> supportedLocales = new HashSet<>();
338+
// supportedLocales.add("ar");
339+
// supportedLocales.add("ar_SA");
337340
supportedLocales.add("cs");
338341
supportedLocales.add("de");
339-
supportedLocales.add("el");
342+
// supportedLocales.add("el");
343+
supportedLocales.add("es");
340344
supportedLocales.add("es-rMX");
341-
supportedLocales.add("et");
345+
// supportedLocales.add("et");
342346
supportedLocales.add("fr");
343347
supportedLocales.add("id");
344348
supportedLocales.add("it");
345-
supportedLocales.add("ja");
346-
supportedLocales.add("nb-rNO");
349+
// supportedLocales.add("ja");
350+
// supportedLocales.add("nb-rNO");
347351
supportedLocales.add("pl");
348352
supportedLocales.add("pt-rBR");
349353
supportedLocales.add("ro");
350354
supportedLocales.add("ru");
351355
supportedLocales.add("sk");
352356
supportedLocales.add("tr");
353-
supportedLocales.add("vi");
357+
supportedLocales.add("uk");
358+
// supportedLocales.add("vi");
354359
supportedLocales.add("zh-rCH");
355-
supportedLocales.add("zh-rTW");
360+
// supportedLocales.add("zh-rTW");
356361
supportedLocales.add("en");
357362

358363
Preference languageSelector = findPreference("pref_language_selector");
@@ -363,6 +368,23 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
363368
return true;
364369
});
365370

371+
// Handle pref_language_selector_cta by taking user to https://translate.nift4.org/engage/foxmmm/
372+
LongClickablePreference languageSelectorCta = findPreference("pref_language_selector_cta");
373+
languageSelectorCta.setOnPreferenceClickListener(preference -> {
374+
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://translate.nift4.org/engage/foxmmm/"));
375+
startActivity(browserIntent);
376+
return true;
377+
});
378+
379+
// Long click to copy url
380+
languageSelectorCta.setOnPreferenceLongClickListener(v -> {
381+
ClipboardManager clipboard = (ClipboardManager) requireContext().getSystemService(Context.CLIPBOARD_SERVICE);
382+
ClipData clip = ClipData.newPlainText("URL", "https://translate.nift4.org/engage/foxmmm/");
383+
clipboard.setPrimaryClip(clip);
384+
Toast.makeText(requireContext(), R.string.link_copied, Toast.LENGTH_SHORT).show();
385+
return true;
386+
});
387+
366388
int level = this.currentLanguageLevel();
367389
if (level != LANGUAGE_SUPPORT_LEVEL) {
368390
Log.e(TAG, "Detected language level " + level + ", latest is " + LANGUAGE_SUPPORT_LEVEL);
@@ -484,6 +506,8 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
484506
findPreference("pref_report_bug").setVisible(false);
485507
}
486508
linkClickable = findPreference("pref_source_code");
509+
// Set summary to the last commit this build was built from
510+
linkClickable.setSummary(String.format(getString(R.string.source_code_summary), BuildConfig.COMMIT_HASH));
487511
linkClickable.setOnPreferenceClickListener(p -> {
488512
if (devModeStep == 2) {
489513
devModeStep = 0;
@@ -499,7 +523,8 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
499523
ExternalHelper.INSTANCE.refreshHelper(getContext());
500524
return true;
501525
}
502-
IntentHelper.openUrl(p.getContext(), "https://github.com/Fox2Code/FoxMagiskModuleManager");
526+
// build url from BuildConfig.REMOTE_URL and BuildConfig.COMMIT_HASH. May have to remove the .git at the end
527+
IntentHelper.openUrl(p.getContext(), BuildConfig.REMOTE_URL + "/tree/" + BuildConfig.COMMIT_HASH);
503528
return true;
504529
});
505530
linkClickable.setOnPreferenceLongClickListener(p -> {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
android:layout_width="0dp"
5959
android:layout_height="wrap_content"
6060
android:layout_weight="1"
61-
android:maxLines="1"
61+
android:maxLines="2"
6262
android:text="@string/loading"
6363
android:textSize="16sp"
6464
android:textAppearance="?attr/textAppearanceTitleMedium"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
<string name="sentry_dialogue_success">Danke für dein Feedback</string>
180180
<string name="sentry_dialogue_no_description">Konnte nicht abgesendet werden, da keine Fehlerbeschreibung angegeben wurde</string>
181181
<string name="go_to_online_repo">Zu Online-Repos gehen</string>
182-
<string name="pref_pkg_info_summary">%1$s v%2$s (%3$o) | %4$s Build</string>
182+
<string name="pref_pkg_info_summary">%1$s v%2$s (%3$d) | %4$s Build</string>
183183
<string name="official">Offiziell</string>
184184
<string name="unofficial">Inoffiziell</string>
185185
<string name="setup_title">Willkommen</string>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
<string name="sentry_dialogue_no_description">Il n\’est pas possible d\’envoyer le retour d\’expérience etant donné qu\’aucune
219219
description n\’a été fournie</string>
220220
<string name="go_to_online_repo">Défiler jusqu\’aux dépôts en ligne</string>
221-
<string name="pref_pkg_info_summary">%1$s v%2$s (%3$o) | %4$s Fabrication</string>
221+
<string name="pref_pkg_info_summary">%1$s v%2$s (%3$d) | %4$s Fabrication</string>
222222
<string name="official">Officielle</string>
223223
<string name="unofficial">Non-officielle</string>
224224
<string name="setup_title">Première mise en service</string>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
<string name="sentry_dialogue_success">Feedback inviato correttamente. Lo esamineremo a breve</string>
200200
<string name="sentry_dialogue_no_description">Impossibile inviare il feedback in quanto non è stata fornita alcuna descrizione</string>
201201
<string name="go_to_online_repo">Scorri fino al repository online</string>
202-
<string name="pref_pkg_info_summary">%1$s v%2$s (%3$o) | %4$s Crea</string>
202+
<string name="pref_pkg_info_summary">%1$s v%2$s (%3$d) | %4$s Crea</string>
203203
<string name="official">Ufficiale</string>
204204
<string name="unofficial">Non ufficiale</string>
205205
<string name="setup_title">Configurazione per la prima volta</string>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
<string name="sentry_dialogue_success">Feedback met succes verzonden. We zullen het zo snel mogelijk bekijken</string>
151151
<string name="sentry_dialogue_no_description">Kan geen feedback verzenden omdat er geen beschrijving is gegeven</string>
152152
<string name="go_to_online_repo">Scroll naar online repo</string>
153-
<string name="pref_pkg_info_summary">%1$s v%2$s (%3$o) | %4$s Build</string>
153+
<string name="pref_pkg_info_summary">%1$s v%2$s (%3$d) | %4$s Build</string>
154154
<string name="official">Officieel</string>
155155
<string name="unofficial">Niet-officieel</string>
156156
<string name="setup_title">Eerste installatie</string>

0 commit comments

Comments
 (0)