(chore) final bugfixes

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 2 years ago
parent 37c22ee35b
commit 0aa4abca53

@ -37,13 +37,13 @@ android {
applicationId = "com.fox2code.mmm" applicationId = "com.fox2code.mmm"
minSdk = 24 minSdk = 24
targetSdk = 33 targetSdk = 33
versionCode = 65 versionCode = 66
versionName = "2.0.0" versionName = "2.0.0"
vectorDrawables { vectorDrawables {
useSupportLibrary = true useSupportLibrary = true
} }
multiDexEnabled = true multiDexEnabled = true
resourceConfigurations += setOf() resourceConfigurations.addAll(listOf("ar", "bs", "de", "es-rMX", "fr", "hu", "id", "ja", "nl", "pl", "pt", "pt-rBR", "ro", "ru", "tr", "uk", "zh-rCN", "zh-rTW", "en"))
} }
splits { splits {
@ -94,6 +94,7 @@ android {
flavorDimensions.add("type") flavorDimensions.add("type")
productFlavors { productFlavors {
create("default") { create("default") {
dimension = "type"
// debug http requests. do not set this to true if you care about performance!!!!! // debug http requests. do not set this to true if you care about performance!!!!!
buildConfigField("boolean", "DEBUG_HTTP", "false") buildConfigField("boolean", "DEBUG_HTTP", "false")
// Latest commit hash as BuildConfig.COMMIT_HASH // Latest commit hash as BuildConfig.COMMIT_HASH
@ -102,18 +103,18 @@ android {
buildConfigField("String", "BRANCH_NAME", "\"$gitBranch\"") buildConfigField("String", "BRANCH_NAME", "\"$gitBranch\"")
// Get remote url as BuildConfig.REMOTE_URL // Get remote url as BuildConfig.REMOTE_URL
buildConfigField("String", "REMOTE_URL", "\"$gitRemote\"") buildConfigField("String", "REMOTE_URL", "\"$gitRemote\"")
dimension = "type"
buildConfigField("boolean", "ENABLE_AUTO_UPDATER", "true") buildConfigField("boolean", "ENABLE_AUTO_UPDATER", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true") buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING_PII", "true") buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING_PII", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "true") buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "true")
val properties = Properties() val properties = Properties()
if (project.rootProject.file("local.properties").exists()) { if (project.rootProject.file("local.properties").exists()) {
properties.load(project.rootProject.file("local.properties").reader())
// grab matomo.url // grab matomo.url
buildConfigField( buildConfigField(
"String", "ANALYTICS_ENDPOINT", "\"" + properties.getProperty( "String", "ANALYTICS_ENDPOINT", "\"" + properties.getProperty(
"matomo.url", "https://s-api.androidacy.com/matomo.php" + "\"" "matomo.url", "https://s-api.androidacy.com/matomo.php"
) ) + "\""
) )
} else { } else {
buildConfigField( buildConfigField(
@ -127,7 +128,7 @@ android {
// If androidacy.properties doesn"t exist, use the default client ID which is heavily // If androidacy.properties doesn"t exist, use the default client ID which is heavily
// rate limited to 30 requests per minute // rate limited to 30 requests per minute
if (project.rootProject.file("androidacy.properties").exists()) { if (project.rootProject.file("androidacy.properties").exists()) {
propertiesA.load(project.rootProject.file("androidacy.properties").inputStream()) propertiesA.load(project.rootProject.file("androidacy.properties").reader())
properties.setProperty( properties.setProperty(
"client_id", "\"" + propertiesA.getProperty( "client_id", "\"" + propertiesA.getProperty(
"client_id", "client_id",
@ -153,6 +154,8 @@ android {
// play variant. pretty similiar to default, but with an empty inital online repo list, and use play_client_id instead of client_id // 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") { create("play") {
dimension = "type"
applicationIdSuffix = ".play"
// debug http requests. do not set this to true if you care about performance!!!!! // debug http requests. do not set this to true if you care about performance!!!!!
buildConfigField("boolean", "DEBUG_HTTP", "false") buildConfigField("boolean", "DEBUG_HTTP", "false")
// Latest commit hash as BuildConfig.COMMIT_HASH // Latest commit hash as BuildConfig.COMMIT_HASH
@ -161,18 +164,18 @@ android {
buildConfigField("String", "BRANCH_NAME", "\"$gitBranch\"") buildConfigField("String", "BRANCH_NAME", "\"$gitBranch\"")
// Get remote url as BuildConfig.REMOTE_URL // Get remote url as BuildConfig.REMOTE_URL
buildConfigField("String", "REMOTE_URL", "\"$gitRemote\"") buildConfigField("String", "REMOTE_URL", "\"$gitRemote\"")
dimension = "type"
buildConfigField("boolean", "ENABLE_AUTO_UPDATER", "false") buildConfigField("boolean", "ENABLE_AUTO_UPDATER", "false")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true") buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING_PII", "true") buildConfigField("boolean", "DEFAULT_ENABLE_CRASH_REPORTING_PII", "true")
buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "true") buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "true")
val properties = Properties() val properties = Properties()
if (project.rootProject.file("local.properties").exists()) { if (project.rootProject.file("local.properties").exists()) {
properties.load(project.rootProject.file("local.properties").reader())
// grab matomo.url // grab matomo.url
buildConfigField( buildConfigField(
"String", "ANALYTICS_ENDPOINT", "\"" + properties.getProperty( "String", "ANALYTICS_ENDPOINT", "\"" + properties.getProperty(
"matomo.url", "https://s-api.androidacy.com/matomo.php" + "\"" "matomo.url", "https://s-api.androidacy.com/matomo.php"
) ) + "\""
) )
} else { } else {
buildConfigField( buildConfigField(
@ -186,7 +189,7 @@ android {
// If androidacy.properties doesn"t exist, use the default client ID which is heavily // If androidacy.properties doesn"t exist, use the default client ID which is heavily
// rate limited to 30 requests per minute // rate limited to 30 requests per minute
if (project.rootProject.file("androidacy.properties").exists()) { if (project.rootProject.file("androidacy.properties").exists()) {
propertiesA.load(project.rootProject.file("androidacy.properties").inputStream()) propertiesA.load(project.rootProject.file("androidacy.properties").reader())
properties.setProperty( properties.setProperty(
"client_id", "\"" + propertiesA.getProperty( "client_id", "\"" + propertiesA.getProperty(
"play_client_id", "play_client_id",
@ -234,6 +237,7 @@ android {
buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "false") buildConfigField("boolean", "DEFAULT_ENABLE_ANALYTICS", "false")
val properties = Properties() val properties = Properties()
if (project.rootProject.file("local.properties").exists()) { if (project.rootProject.file("local.properties").exists()) {
properties.load(project.rootProject.file("local.properties").reader())
// grab matomo.url // grab matomo.url
buildConfigField( buildConfigField(
"String", "ANALYTICS_ENDPOINT", "\"" + properties.getProperty( "String", "ANALYTICS_ENDPOINT", "\"" + properties.getProperty(
@ -463,8 +467,7 @@ android {
} }
//noinspection GrDeprecatedAPIUsage //noinspection GrDeprecatedAPIUsage
buildToolsVersion = "34.0.0 rc3" buildToolsVersion = "34.0.0 rc3"
@Suppress("DEPRECATION") @Suppress("DEPRECATION") packagingOptions {
packagingOptions {
jniLibs { jniLibs {
useLegacyPackaging = true useLegacyPackaging = true
} }

@ -83,7 +83,6 @@ import io.noties.markwon.image.network.OkHttpNetworkSchemeHandler;
import io.realm.Realm; import io.realm.Realm;
import timber.log.Timber; import timber.log.Timber;
@SuppressWarnings("CommentedOutCode")
public class MainApplication extends FoxApplication implements androidx.work.Configuration.Provider { public class MainApplication extends FoxApplication implements androidx.work.Configuration.Provider {
// Warning! Locales that don't exist will crash the app // Warning! Locales that don't exist will crash the app
// Anything that is commented out is supported but the translation is not complete to at least 60% // Anything that is commented out is supported but the translation is not complete to at least 60%
@ -380,51 +379,12 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
@Override @Override
public void onCreate() { public void onCreate() {
supportedLocales.add("ar"); supportedLocales.addAll(Arrays.asList("ar", "bs", "de", "es-rMX", "fr", "hu", "id", "ja", "nl", "pl", "pt", "pt-rBR", "ro", "ru", "tr", "uk", "zh-rCN", "zh-rTW", "en"));
// supportedLocales.add("ar_SA");
supportedLocales.add("bs");
supportedLocales.add("cs");
supportedLocales.add("de");
// supportedLocales.add("el");
// supportedLocales.add("es");
supportedLocales.add("es-rMX");
// supportedLocales.add("et");
supportedLocales.add("fr");
supportedLocales.add("hu");
// supportedLocales.add("hi");
supportedLocales.add("id");
supportedLocales.add("it");
supportedLocales.add("ja");
// supportedLocales.add("ko");
// supportedLocales.add("nb-rNO");
// supportedLocales.add("ne");
supportedLocales.add("pl");
supportedLocales.add("pt-rBR");
// supportedLocales.add("pt-rPT");
supportedLocales.add("ro");
supportedLocales.add("ru");
supportedLocales.add("sk");
supportedLocales.add("tr");
// supportedLocales.add("th");
supportedLocales.add("uk");
// supportedLocales.add("vi");
supportedLocales.add("zh-rCN");
supportedLocales.add("zh-rTW");
supportedLocales.add("en");
if (INSTANCE == null) INSTANCE = this; if (INSTANCE == null) INSTANCE = this;
relPackageName = this.getPackageName(); relPackageName = this.getPackageName();
super.onCreate(); super.onCreate();
SentryMain.initialize(this); SentryMain.initialize(this);
// Initialize Timber // Initialize Timber
/*if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
} else {
if (isCrashReportingEnabled()) {
Timber.plant(new SentryTimberTree(Sentry.getCurrentHub(), SentryLevel.ERROR, SentryLevel.ERROR));
} else {
Timber.plant(new ReleaseTree());
}
}*/
TimberUtils.configTimber(); TimberUtils.configTimber();
Timber.i("Starting FoxMMM version %s (%d) - commit %s", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.COMMIT_HASH); Timber.i("Starting FoxMMM version %s (%d) - commit %s", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.COMMIT_HASH);
// Update SSL Ciphers if update is possible // Update SSL Ciphers if update is possible
@ -500,6 +460,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
Timber.w("Androidacy client id is empty! Please set it in androidacy.properties. Will not enable Androidacy."); Timber.w("Androidacy client id is empty! Please set it in androidacy.properties. Will not enable Androidacy.");
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("pref_androidacy_repo_enabled", false); editor.putBoolean("pref_androidacy_repo_enabled", false);
Timber.w("ANDROIDACY_CLIENT_ID is empty, disabling AndroidacyRepoData 1");
editor.apply(); editor.apply();
} }
} }

@ -190,6 +190,7 @@ public final class AndroidacyRepoData extends RepoData {
SharedPreferences.Editor editor = MainApplication.getPreferences("mmm").edit(); SharedPreferences.Editor editor = MainApplication.getPreferences("mmm").edit();
editor.putBoolean("pref_androidacy_repo_enabled", false); editor.putBoolean("pref_androidacy_repo_enabled", false);
editor.apply(); editor.apply();
Timber.w("ANDROIDACY_CLIENT_ID is empty, disabling AndroidacyRepoData 2");
return false; return false;
} }
if (Http.needCaptchaAndroidacy()) return false; if (Http.needCaptchaAndroidacy()) return false;

@ -1014,7 +1014,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
}); });
// Disable toggling the pref_androidacy_repo_enabled on builds without an // Disable toggling the pref_androidacy_repo_enabled on builds without an
// ANDROIDACY_CLIENT_ID or where the ANDROIDACY_CLIENT_ID is empty // ANDROIDACY_CLIENT_ID or where the ANDROIDACY_CLIENT_ID is empty
Preference androidacyRepoEnabled = Objects.requireNonNull(findPreference("pref_androidacy_repo_enabled")); SwitchPreferenceCompat androidacyRepoEnabled = Objects.requireNonNull(findPreference("pref_androidacy_repo_enabled"));
if (Objects.equals(BuildConfig.ANDROIDACY_CLIENT_ID, "")) { if (Objects.equals(BuildConfig.ANDROIDACY_CLIENT_ID, "")) {
androidacyRepoEnabled.setOnPreferenceClickListener(preference -> { androidacyRepoEnabled.setOnPreferenceClickListener(preference -> {
new MaterialAlertDialogBuilder(this.requireContext()).setTitle(R.string.androidacy_repo_disabled).setCancelable(false).setMessage(R.string.androidacy_repo_disabled_message).setPositiveButton(R.string.download_full_app, (dialog, which) -> { new MaterialAlertDialogBuilder(this.requireContext()).setTitle(R.string.androidacy_repo_disabled).setCancelable(false).setMessage(R.string.androidacy_repo_disabled_message).setPositiveButton(R.string.download_full_app, (dialog, which) -> {
@ -1023,8 +1023,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
startActivity(browserIntent); startActivity(browserIntent);
}).show(); }).show();
// Revert the switch to off // Revert the switch to off
SwitchPreferenceCompat switchPreferenceCompat = (SwitchPreferenceCompat) androidacyRepoEnabled; androidacyRepoEnabled.setChecked(false);
switchPreferenceCompat.setChecked(false);
// Disable in realm db // Disable in realm db
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name("ReposList.realm").encryptionKey(MainApplication.getINSTANCE().getKey()).allowQueriesOnUiThread(true).allowWritesOnUiThread(true).directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1).build(); RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name("ReposList.realm").encryptionKey(MainApplication.getINSTANCE().getKey()).allowQueriesOnUiThread(true).allowWritesOnUiThread(true).directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1).build();
Realm realm = Realm.getInstance(realmConfiguration); Realm realm = Realm.getInstance(realmConfiguration);
@ -1037,20 +1036,27 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
}); });
return false; return false;
}); });
} } else {
// get if androidacy repo is enabled from realm db // get if androidacy repo is enabled from realm db
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name("ReposList.realm").encryptionKey(MainApplication.getINSTANCE().getKey()).allowQueriesOnUiThread(true).allowWritesOnUiThread(true).directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1).build(); RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name("ReposList.realm").encryptionKey(MainApplication.getINSTANCE().getKey()).allowQueriesOnUiThread(true).allowWritesOnUiThread(true).directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1).build();
Realm realm = Realm.getInstance(realmConfiguration); Realm realm = Realm.getInstance(realmConfiguration);
ReposList repoRealmResults = realm.where(ReposList.class).equalTo("id", "androidacy_repo").findFirst(); ReposList repoRealmResults = realm.where(ReposList.class).equalTo("id", "androidacy_repo").findFirst();
if (repoRealmResults == null) { if (repoRealmResults == null) {
// log the entries in the realm db and throw an illegal state exception
RealmResults<ReposList> reposListRealmResults = realm.where(ReposList.class).findAll();
if (reposListRealmResults.isEmpty()) {
throw new IllegalStateException("Realm db is empty");
}
throw new IllegalStateException("Androidacy repo not found in realm db"); throw new IllegalStateException("Androidacy repo not found in realm db");
} }
boolean androidacyRepoEnabledPref = repoRealmResults.isEnabled(); boolean androidacyRepoEnabledPref = repoRealmResults.isEnabled();
// set the switch to the current state
androidacyRepoEnabled.setChecked(androidacyRepoEnabledPref);
// add a click listener to the switch
androidacyRepoEnabled.setOnPreferenceClickListener(preference -> {
boolean enabled = androidacyRepoEnabled.isChecked();
// save the new state
realm.executeTransaction(realm2 -> {
ReposList repoRealmResults1 = realm2.where(ReposList.class).equalTo("id", "androidacy_repo").findFirst();
repoRealmResults1.setEnabled(enabled);
});
return true;
});
if (androidacyRepoEnabledPref) { if (androidacyRepoEnabledPref) {
// get user role from AndroidacyRepoData.userInfo // get user role from AndroidacyRepoData.userInfo
String[][] userInfo = AndroidacyRepoData.getInstance().userInfo; String[][] userInfo = AndroidacyRepoData.getInstance().userInfo;
@ -1198,6 +1204,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
}); });
} }
} }
}
@SuppressLint("RestrictedApi") @SuppressLint("RestrictedApi")
public void updateCustomRepoList(boolean initial) { public void updateCustomRepoList(boolean initial) {

Loading…
Cancel
Save