(misc) small tweaks

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 3 years ago
parent 0a6fd7316a
commit dd9823ad5b

@ -43,6 +43,7 @@ android {
useSupportLibrary = true useSupportLibrary = true
} }
multiDexEnabled = true multiDexEnabled = true
resourceConfigurations += setOf()
} }
splits { splits {
@ -74,10 +75,14 @@ android {
proguardFiles( proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
) )
renderscriptOptimLevel = 3
} }
getByName("debug") { getByName("debug") {
applicationIdSuffix = ".debug" applicationIdSuffix = ".debug"
isDebuggable = true isDebuggable = true
versionNameSuffix = "-debug"
isJniDebuggable = true
isRenderscriptDebuggable = true
// ONLY FOR TESTING SENTRY // ONLY FOR TESTING SENTRY
// minifyEnabled true // minifyEnabled true
@ -137,7 +142,7 @@ android {
buildConfigField( buildConfigField(
"String", "ANDROIDACY_CLIENT_ID", "\"" + propertiesA.getProperty("client_id") + "\"" "String", "ANDROIDACY_CLIENT_ID", "\"" + propertiesA.getProperty("client_id") + "\""
) )
// If client ID is empty, disable androidacy
buildConfigField( buildConfigField(
"java.util.List<String>", "java.util.List<String>",
"ENABLED_REPOS", "ENABLED_REPOS",
@ -146,6 +151,65 @@ android {
} }
// play variant. pretty similiar to default, but with an empty inital online repo list, and use play_client_id instead of client_id
create("play") {
// debug http requests. do not set this to true if you care about performance!!!!!
buildConfigField("boolean", "DEBUG_HTTP", "false")
// Latest commit hash as BuildConfig.COMMIT_HASH
buildConfigField("String", "COMMIT_HASH", "\"$gitCommitHash\"")
// Get the current branch name as BuildConfig.BRANCH_NAME
buildConfigField("String", "BRANCH_NAME", "\"$gitBranch\"")
// Get remote url as BuildConfig.REMOTE_URL
buildConfigField("String", "REMOTE_URL", "\"$gitRemote\"")
dimension = "type"
buildConfigField("boolean", "ENABLE_AUTO_UPDATER", "false")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING_PII", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "true")
val properties = Properties()
if (project.rootProject.file("local.properties").exists()) {
// grab matomo.url
buildConfigField(
"String", "ANALYTICS_ENDPOINT", "\"" + properties.getProperty(
"matomo.url", "https://s-api.androidacy.com/matomo.php" + "\""
)
)
} else {
buildConfigField(
"String", "ANALYTICS_ENDPOINT", "\"https://s-api.androidacy.com/matomo.php\""
)
}
buildConfigField("boolean", "ENABLE_PROTECTION", "true")
// Get the androidacy client ID from the androidacy.properties
val propertiesA = Properties()
// If androidacy.properties doesn"t exist, use the default client ID which is heavily
// rate limited to 30 requests per minute
if (project.rootProject.file("androidacy.properties").exists()) {
propertiesA.load(project.rootProject.file("androidacy.properties").inputStream())
properties.setProperty(
"client_id", "\"" + propertiesA.getProperty(
"play_client_id",
"5KYccdYxWB2RxMq5FTbkWisXi2dS6yFN9R7RVlFCG98FRdz6Mf5ojY2fyJCUlXJZ"
) + "\""
)
} else {
properties.setProperty(
"client_id", "5KYccdYxWB2RxMq5FTbkWisXi2dS6yFN9R7RVlFCG98FRdz6Mf5ojY2fyJCUlXJZ"
)
}
buildConfigField(
"String", "ANDROIDACY_CLIENT_ID", "\"" + propertiesA.getProperty("client_id") + "\""
)
buildConfigField(
"java.util.List<String>",
"ENABLED_REPOS",
"java.util.Arrays.asList(\"\")",
)
}
create("fdroid") { create("fdroid") {
dimension = "type" dimension = "type"
applicationIdSuffix = ".fdroid" applicationIdSuffix = ".fdroid"

@ -104,6 +104,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
private static MainApplication INSTANCE; private static MainApplication INSTANCE;
private static boolean firstBoot; private static boolean firstBoot;
private static HashMap<Object, Object> mSharedPrefs; private static HashMap<Object, Object> mSharedPrefs;
public static String updateCheckBg;
static { static {
Shell.setDefaultBuilder(shellBuilder = Shell.Builder.create().setFlags(Shell.FLAG_REDIRECT_STDERR).setTimeout(10).setInitializers(InstallerInitializer.class)); Shell.setDefaultBuilder(shellBuilder = Shell.Builder.create().setFlags(Shell.FLAG_REDIRECT_STDERR).setTimeout(10).setInitializers(InstallerInitializer.class));
@ -248,7 +249,13 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
} }
public static boolean isBackgroundUpdateCheckEnabled() { public static boolean isBackgroundUpdateCheckEnabled() {
return !wrapped && getPreferences("mmm").getBoolean("pref_background_update_check", true); if (updateCheckBg != null) {
return Boolean.parseBoolean(updateCheckBg);
}
boolean wrapped = isWrapped();
boolean updateCheckBgTemp = !wrapped && getPreferences("mmm").getBoolean("pref_background_update_check", true);
updateCheckBg = String.valueOf(updateCheckBgTemp);
return Boolean.parseBoolean(updateCheckBg);
} }
public static boolean isAndroidacyTestMode() { public static boolean isAndroidacyTestMode() {

@ -67,7 +67,7 @@ public final class AndroidacyRepoData extends RepoData {
this.defaultName = "Androidacy Modules Repo"; this.defaultName = "Androidacy Modules Repo";
this.defaultWebsite = RepoManager.ANDROIDACY_MAGISK_REPO_HOMEPAGE; this.defaultWebsite = RepoManager.ANDROIDACY_MAGISK_REPO_HOMEPAGE;
this.defaultSupport = "https://t.me/androidacy_discussions"; this.defaultSupport = "https://t.me/androidacy_discussions";
this.defaultDonate = "https://www.androidacy.com/membership-account/membership-checkout/?level=2&discount_code=FOXWINTER2&utm_souce=foxmmm&utm_medium=android-app&utm_campaign=fox-upgrade-promo"; this.defaultDonate = "https://www.androidacy.com/membership-account/membership-checkout/?level=2&discount_code=FOX2CODE&utm_souce=foxmmm&utm_medium=android-app&utm_campaign=fox-upgrade-promo";
this.defaultSubmitModule = "https://www.androidacy.com/module-repository-applications/"; this.defaultSubmitModule = "https://www.androidacy.com/module-repository-applications/";
this.host = testMode ? "staging-api.androidacy.com" : "production-api.androidacy.com"; this.host = testMode ? "staging-api.androidacy.com" : "production-api.androidacy.com";
this.testMode = testMode; this.testMode = testMode;

@ -846,6 +846,40 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
} }
return true; return true;
}); });
LongClickablePreference pref_donate_fox = findPreference("pref_donate_fox");
pref_donate_fox.setOnPreferenceClickListener(p -> {
// open fox
IntentHelper.openUrl(getFoxActivity(this), "https://paypal.me/fox2code");
return true;
});
// handle long click on pref_donate_fox
pref_donate_fox.setOnPreferenceLongClickListener(p -> {
// copy to clipboard
String toastText = requireContext().getString(R.string.link_copied);
clipboard.setPrimaryClip(ClipData.newPlainText(toastText, "https://paypal.me/fox2code"));
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show();
return true;
});
// now handle pref_donate_androidacy
LongClickablePreference pref_donate_androidacy = findPreference("pref_donate_androidacy");
pref_donate_androidacy.setOnPreferenceClickListener(p -> {
// copy FOX2CODE promo code to clipboard and toast user that they can use it for half off any subscription
String toastText = requireContext().getString(R.string.promo_code_copied);
clipboard.setPrimaryClip(ClipData.newPlainText(toastText, "FOX2CODE"));
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show();
// open androidacy
IntentHelper.openUrl(getFoxActivity(this), "https://www.androidacy.com/membership-join/?utm_source=foxmmm&utm_medium=app&utm_campaign=donate");
return true;
});
// handle long click on pref_donate_androidacy
pref_donate_androidacy.setOnPreferenceLongClickListener(p -> {
// copy to clipboard
String toastText = requireContext().getString(R.string.link_copied);
clipboard.setPrimaryClip(ClipData.newPlainText(toastText, "https://www.androidacy.com/membership-join/?utm_source=foxmmm&utm_medium=app&utm_campaign=donate"));
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show();
return true;
});
} }
private void openFragment(Fragment fragment, @StringRes int title) { private void openFragment(Fragment fragment, @StringRes int title) {
@ -1015,12 +1049,17 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
if (userInfo != null) { if (userInfo != null) {
String userRole = userInfo[0][1]; String userRole = userInfo[0][1];
if (Objects.nonNull(userRole) && !Objects.equals(userRole, "Guest")) { if (Objects.nonNull(userRole) && !Objects.equals(userRole, "Guest")) {
// Disable the pref_androidacy_repo_api_token preference // Disable the pref_androidacy_repo_api_donate preference
LongClickablePreference prefAndroidacyRepoApiD = Objects.requireNonNull(findPreference("pref_androidacy_repo_donate")); LongClickablePreference prefAndroidacyRepoApiD = Objects.requireNonNull(findPreference("pref_androidacy_repo_donate"));
prefAndroidacyRepoApiD.setEnabled(false); prefAndroidacyRepoApiD.setEnabled(false);
prefAndroidacyRepoApiD.setSummary(R.string.upgraded_summary); prefAndroidacyRepoApiD.setSummary(R.string.upgraded_summary);
prefAndroidacyRepoApiD.setTitle(R.string.upgraded); prefAndroidacyRepoApiD.setTitle(R.string.upgraded);
prefAndroidacyRepoApiD.setIcon(R.drawable.baseline_check_24); prefAndroidacyRepoApiD.setIcon(R.drawable.baseline_check_24);
} else if (BuildConfig.FLAVOR.equals("play")) {
// Disable the pref_androidacy_repo_api_token preference and hide the donate button
LongClickablePreference prefAndroidacyRepoApiD = Objects.requireNonNull(findPreference("pref_androidacy_repo_donate"));
prefAndroidacyRepoApiD.setEnabled(false);
prefAndroidacyRepoApiD.setVisible(false);
} }
} }
String[] originalApiKeyRef = new String[]{MainApplication.getPreferences("androidacy").getString("pref_androidacy_api_token", "")}; String[] originalApiKeyRef = new String[]{MainApplication.getPreferences("androidacy").getString("pref_androidacy_api_token", "")};
@ -1093,8 +1132,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
new Handler(Looper.getMainLooper()).post(() -> { new Handler(Looper.getMainLooper()).post(() -> {
Snackbar.make(requireView(), R.string.api_key_invalid, BaseTransientBottomBar.LENGTH_SHORT).show(); Snackbar.make(requireView(), R.string.api_key_invalid, BaseTransientBottomBar.LENGTH_SHORT).show();
// Save the original key // Save the original key
MainApplication.getPreferences( MainApplication.getPreferences("androidacy").edit().putString("pref_androidacy_api_token", originalApiKeyRef[0]).apply();
"androidacy").edit().putString("pref_androidacy_api_token", originalApiKeyRef[0]).apply();
// Re-show the dialog with an error // Re-show the dialog with an error
prefAndroidacyRepoApiKey.performClick(); prefAndroidacyRepoApiKey.performClick();
// Show error // Show error

@ -2,6 +2,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="4dp"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <FrameLayout

@ -202,7 +202,7 @@
<string name="monet_disabled_summary">Monet is not compatible with transparent themes.</string> <string name="monet_disabled_summary">Monet is not compatible with transparent themes.</string>
<string name="blur_disabled_summary">Blur is not compatible with transparent themes.</string> <string name="blur_disabled_summary">Blur is not compatible with transparent themes.</string>
<string name="transparent_theme_dialogue_title">You are setting a transparent theme</string> <string name="transparent_theme_dialogue_title">You are setting a transparent theme</string>
<string name="transparent_theme_dialogue_message">Transparent themes may have some inconsistencies and may not work on all ROMs. In additon, monet and blur will be disabled. You can change back at any time.</string> <string name="transparent_theme_dialogue_message">Transparent themes may have some inconsistencies and may not work on all ROMs. In addition, monet and blur will be disabled. You can change back at any time.</string>
<string name="custom_repo_always_on">Custom repos are always on until you remove them.</string> <string name="custom_repo_always_on">Custom repos are always on until you remove them.</string>
<string name="sentry_dialogue_message">We encountered an error! Please help us improve the app <string name="sentry_dialogue_message">We encountered an error! Please help us improve the app
by adding some information about the error below.\nName and email are optional but will by adding some information about the error below.\nName and email are optional but will
@ -233,14 +233,14 @@
<string name="setup_magisk_alt_repo">Enable the Magisk Alt Repo</string> <string name="setup_magisk_alt_repo">Enable the Magisk Alt Repo</string>
<string name="setup_magisk_alt_repo_summary">Much more lax than the original. Has a lot of modules at the cost of some safety.</string> <string name="setup_magisk_alt_repo_summary">Much more lax than the original. Has a lot of modules at the cost of some safety.</string>
<string name="setup_crash_reporting">Enable Sentry</string> <string name="setup_crash_reporting">Enable Sentry</string>
<string name="setup_crash_reporting_summary">Crash reporting and performance monitoring. All reports are striclty anonymous and confidential.</string> <string name="setup_crash_reporting_summary">Crash reporting and performance monitoring. All reports are strictly anonymous and confidential.</string>
<string name="setup_custom_repos">You can add custom repos later in settings.</string> <string name="setup_custom_repos">You can add custom repos later in settings.</string>
<string name="repos">Repos</string> <string name="repos">Repos</string>
<string name="misc">Miscellaneous</string> <string name="misc">Miscellaneous</string>
<string name="setup_button_skip">Skip</string> <string name="setup_button_skip">Skip</string>
<string name="low_performance_device_dialogue_title">Enabling blur on lower-end device</string> <string name="low_performance_device_dialogue_title">Enabling blur on lower-end device</string>
<string name="low_performance_device_dialogue_message">You are trying to enable blur on a device that may not perform well with it.\nYou may enable it, but this may lead to a poor user experience and we recommend you don\'t.</string> <string name="low_performance_device_dialogue_message">You are trying to enable blur on a device that may not perform well with it.\nYou may enable it, but this may lead to a poor user experience and we recommend you don\'t.</string>
<string name="alt_repo_info">This repo has less restrictions and reviews, which may lead to lower quality modules. Pretty barebones but has a lot of modules.</string> <string name="alt_repo_info">This repo has less restrictions and reviews, which may lead to lower quality modules. Pretty bare bones but has a lot of modules.</string>
<string name="install_terminal_reboot_now_message">You are about to reboot your device. If you\'ve saved your work, hit OK to continue. Otherwise, hit cancel.</string> <string name="install_terminal_reboot_now_message">You are about to reboot your device. If you\'ve saved your work, hit OK to continue. Otherwise, hit cancel.</string>
<string name="install_terminal_config_missing">Package %s is missing for module config, so we cannot launch it.</string> <string name="install_terminal_config_missing">Package %s is missing for module config, so we cannot launch it.</string>
<string name="clear_app_data">Clear app data</string> <string name="clear_app_data">Clear app data</string>
@ -392,7 +392,7 @@
<string name="crash_reporting_pii_desc">Allows sending additional information in crash reports, some of which may contain personally identifiable information such as IP address and device identifiers.</string> <string name="crash_reporting_pii_desc">Allows sending additional information in crash reports, some of which may contain personally identifiable information such as IP address and device identifiers.</string>
<string name="crash_reporting_pii">Send additional information</string> <string name="crash_reporting_pii">Send additional information</string>
<string name="setup_crash_reporting_pii">Send additional info in crash reports.</string> <string name="setup_crash_reporting_pii">Send additional info in crash reports.</string>
<string name="setup_crash_reporting_pii_summary"> This may include device identifiers and IP addresses. No data will be used for any other purpose besides analyzing crashes and improving performance.</string> <string name="setup_crash_reporting_pii_summary">This may include device identifiers and IP addresses. No data will be used for any other purpose besides analyzing crashes and improving performance.</string>
<string name="error_creating_cookie_database">Error accessing WebView. Functionality may be impacted.</string> <string name="error_creating_cookie_database">Error accessing WebView. Functionality may be impacted.</string>
<string name="setup_scroll_down">To enable the finish button, please scroll down and view all the options.</string> <string name="setup_scroll_down">To enable the finish button, please scroll down and view all the options.</string>
<string name="empty_field">URL is required</string> <string name="empty_field">URL is required</string>
@ -407,4 +407,9 @@
<string name="debug_cat">Debugging</string> <string name="debug_cat">Debugging</string>
<string name="announcements">News and updates</string> <string name="announcements">News and updates</string>
<string name="back">Go back</string> <string name="back">Go back</string>
<string name="donate_fox">Donate to Fox2Code</string>
<string name="donate_androidacy">Donate to Androidacy</string>
<string name="donate_androidacy_sum">Buy a premium subscription to Androidacy to support the app and the repo.</string>
<string name="promo_code_copied">Use the copied code for half off your first month!</string>
<string name="warning_pls_restart">Please note that some settings may not take effect until you restart the app.</string>
</resources> </resources>

@ -1,6 +1,15 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory>
<Preference
app:icon="@drawable/ic_baseline_info_24"
app:key="pref_warning_restart"
app:enabled="false"
app:singleLineTitle="false"
app:title="@string/warning_pls_restart" />
</PreferenceCategory>
<!-- Custom repos has been announced, check https://github.com/Fox2Code/FoxMagiskModuleManager/issues/131 --> <!-- Custom repos has been announced, check https://github.com/Fox2Code/FoxMagiskModuleManager/issues/131 -->
<PreferenceCategory app:title="@string/pref_category_repos"> <PreferenceCategory app:title="@string/pref_category_repos">
<Preference <Preference
@ -197,8 +206,8 @@
<SwitchPreferenceCompat <SwitchPreferenceCompat
app:defaultValue="false" app:defaultValue="false"
app:icon="@drawable/ic_baseline_info_24" app:icon="@drawable/ic_baseline_info_24"
app:singleLineTitle="false"
app:key="pref_analytics_enabled" app:key="pref_analytics_enabled"
app:singleLineTitle="false"
app:summary="@string/analytics_desc" app:summary="@string/analytics_desc"
app:title="@string/setup_app_analytics" /> app:title="@string/setup_app_analytics" />
@ -232,6 +241,18 @@
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory app:title="@string/pref_category_info"> <PreferenceCategory app:title="@string/pref_category_info">
<!-- donate buttons for fox2code and androidacy -->
<com.fox2code.mmm.settings.LongClickablePreference
app:icon="@drawable/ic_baseline_monetization_on_24"
app:key="pref_donate_fox"
app:singleLineTitle="false"
app:title="@string/donate_fox" />
<com.fox2code.mmm.settings.LongClickablePreference
app:icon="@drawable/ic_baseline_monetization_on_24"
app:key="pref_donate_androidacy"
app:singleLineTitle="false"
app:summary="@string/donate_androidacy_sum"
app:title="@string/donate_androidacy" />
<com.fox2code.mmm.settings.LongClickablePreference <com.fox2code.mmm.settings.LongClickablePreference
app:icon="@drawable/ic_baseline_bug_report_24" app:icon="@drawable/ic_baseline_bug_report_24"
app:key="pref_report_bug" app:key="pref_report_bug"

Loading…
Cancel
Save