partial impl of #9

also misc fixes

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 2 years ago
parent 6408bb713a
commit ae41a47f57

@ -413,7 +413,7 @@ dependencies {
// implementation("com.google.protobuf:protobuf-javalite:3.22.2")
// google guava, maybe fix a bug
implementation("com.google.guava:guava:31.1-jre")
implementation("com.google.guava:guava:31.1-android")
val libsuVersion = "5.0.5"

@ -12,7 +12,7 @@ import androidx.core.content.FileProvider;
import com.fox2code.foxcompat.app.FoxActivity;
import com.fox2code.mmm.utils.io.net.Http;
import com.google.android.material.bottomnavigation.BottomNavigationItemView;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.google.android.material.textview.MaterialTextView;
@ -42,8 +42,9 @@ public class UpdateActivity extends FoxActivity {
// Get the progress bar and make it indeterminate for now
LinearProgressIndicator progressIndicator = findViewById(R.id.update_progress);
progressIndicator.setIndeterminate(true);
// get update_cancel button
MaterialButton updateCancel = findViewById(R.id.update_cancel_button);
// get update_cancel item on bottom navigation
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
BottomNavigationItemView updateCancel = bottomNavigationView.findViewById(R.id.update_cancel_button);
// get status text view
MaterialTextView statusTextView = findViewById(R.id.update_progress_text);
// set status text to please wait
@ -85,8 +86,7 @@ public class UpdateActivity extends FoxActivity {
} else if (action == ACTIONS.DOWNLOAD) {
try {
downloadUpdate();
} catch (
JSONException e) {
} catch (JSONException e) {
runOnUiThread(() -> {
// set status text to error
statusTextView.setText(R.string.error_download_update);
@ -97,7 +97,7 @@ public class UpdateActivity extends FoxActivity {
}
} else if (action == ACTIONS.INSTALL) {
// ensure path was passed and points to a file within our cache directory. replace .. and url encoded characters
String path = getIntent().getStringExtra("path").trim().replaceAll("\\.\\.", "").replaceAll("%2e%2e", "");
String path = Objects.requireNonNull(getIntent().getStringExtra("path")).trim().replaceAll("\\.\\.", "").replaceAll("%2e%2e", "");
if (path.isEmpty()) {
runOnUiThread(() -> {
// set status text to error
@ -119,8 +119,7 @@ public class UpdateActivity extends FoxActivity {
if (parentFile == null || !parentFile.getCanonicalPath().startsWith(getCacheDir().getCanonicalPath())) {
throw new SecurityException("Path is not in cache directory: " + path);
}
} catch (
IOException e) {
} catch (IOException e) {
throw new SecurityException("Path is not in cache directory: " + path);
}
if (!file.exists()) {
@ -164,6 +163,7 @@ public class UpdateActivity extends FoxActivity {
updateThread.start();
}
@SuppressLint("RestrictedApi")
public void checkForUpdate() {
// get status text view
MaterialTextView statusTextView = findViewById(R.id.update_progress_text);
@ -184,7 +184,9 @@ public class UpdateActivity extends FoxActivity {
statusTextView.setText(R.string.update_available);
// set button text to download
BottomNavigationItemView button = findViewById(R.id.action_update);
button.setTooltipText(R.string.download_update);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
button.setTooltipText(getString(R.string.download_update));
}
button.setEnabled(true);
});
// return
@ -211,8 +213,7 @@ public class UpdateActivity extends FoxActivity {
byte[] lastestJSON = new byte[0];
try {
lastestJSON = Http.doHttpGet(AppUpdateManager.RELEASES_API_URL, false);
} catch (
Exception e) {
} catch (Exception e) {
// when logging, REMOVE the json from the log
Timber.e(e, "Error downloading update info");
runOnUiThread(() -> {
@ -274,8 +275,7 @@ public class UpdateActivity extends FoxActivity {
// update status text
statusTextView.setText(getString(R.string.downloading_update, (int) (((float) downloaded / (float) total) * 100)));
}));
} catch (
Exception e) {
} catch (Exception e) {
runOnUiThread(() -> {
progressIndicator.setIndeterminate(false);
progressIndicator.setProgressCompat(100, false);
@ -320,8 +320,7 @@ public class UpdateActivity extends FoxActivity {
updateFile = new File(getCacheDir(), "update.apk");
fileOutputStream = new FileOutputStream(updateFile);
fileOutputStream.write(update);
} catch (
IOException e) {
} catch (IOException e) {
runOnUiThread(() -> {
progressIndicator.setIndeterminate(false);
progressIndicator.setProgressCompat(100, false);
@ -333,8 +332,7 @@ public class UpdateActivity extends FoxActivity {
}
try {
Objects.requireNonNull(fileOutputStream).close();
} catch (
IOException ignored) {
} catch (IOException ignored) {
}
}
// install the update

@ -6,7 +6,9 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.fox2code.mmm.BuildConfig;
import com.fox2code.mmm.utils.io.net.Http;
import java.io.IOException;
import java.util.Objects;
public enum AndroidacyUtil {
@ -103,4 +105,33 @@ public enum AndroidacyUtil {
}
return null;
}
/**
* Check if the url is a premium direct download link
* @param url url to check
* @return true if it is a premium direct download link
* @noinspection unused
*/
public static boolean isPremiumDirectDownloadLink(String url) {
return url.contains("/magisk/ddl/");
}
/**
* Returns the markdown directly from the API for rendering. Premium only, and internal testing only currently.
* @param url URL to get markdown from
* @return String of markdown
* @noinspection unused
*/
public static String getMarkdownFromAPI(String url) {
byte[] md;
try {
md = Http.doHttpGet(url, false);
} catch (IOException ignored) {
return null;
}
if (md == null) {
return null;
}
return new String(md);
}
}

@ -300,6 +300,8 @@ public final class ModuleViewAdapter extends RecyclerView.Adapter<ModuleViewAdap
} else {
this.cardView.setClickable(moduleHolder.onClickListener != null);
this.titleText.setTypeface(Typeface.DEFAULT);
this.titleText.setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_BodyMedium);
this.titleText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);
}
}
if (type == ModuleHolder.Type.SEPARATOR) {

@ -511,6 +511,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
}
Preference debugNotification = findPreference("pref_background_update_check_debug");
Preference updateCheckExcludes = findPreference("pref_background_update_check_excludes");
Preference updateCheckVersionExcludes = findPreference("pref_background_update_check_excludes_version");
debugNotification.setEnabled(MainApplication.isBackgroundUpdateCheckEnabled());
debugNotification.setVisible(MainApplication.isDeveloper() && !MainApplication.isWrapped() && MainApplication.isBackgroundUpdateCheckEnabled());
debugNotification.setOnPreferenceClickListener(preference -> {

@ -416,4 +416,6 @@
<string name="warning_pls_restart">Please note that some settings may not take effect until you restart the app.</string>
<string name="reinstall">Reinstall</string>
<string name="setup_scroll_down_v2">To enable the finish button, scroll to the bottom and acknowledge you have read and agree to the EULA and license(s).</string>
<string name="notification_update_ignore_version_desc">Ignore specific versions when checking for module updates. Disabling update checks per-module above overrides this setting!</string>
<string name="notification_update_ignore_version_pref">Exclude version(s) from update checks</string>
</resources>

@ -73,6 +73,15 @@
app:summary="@string/notification_update_ignore_desc"
app:title="@string/notification_update_ignore_pref" />
<!-- exclude specific versions -->
<Preference
app:icon="@drawable/baseline_block_24"
app:key="pref_background_update_check_excludes_version"
app:singleLineTitle="false"
app:summary="@string/notification_update_ignore_version_desc"
app:title="@string/notification_update_ignore_version_pref" />
<Preference
app:icon="@drawable/baseline_notification_important_24"
app:key="pref_background_update_check_debug"

@ -10,7 +10,7 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Tue Apr 25 12:57:16 EDT 2023
#Mon May 08 13:44:15 EDT 2023
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=false
android.enableR8.fullMode=true
@ -18,5 +18,5 @@ android.useAndroidX=true
org.gradle.caching=true
org.gradle.configuration-cache=true
org.gradle.configuration-cache.problems=warn
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1536M" -Dfile.encoding\=UTF-8 -XX\:+UseParallelGC -XX\:ReservedCodeCacheSize\=768m
org.gradle.jvmargs=-Xmx1024M -Dkotlin.daemon.jvm.options\="-Xmx1024M" -Dfile.encoding\=UTF-8 -XX\:+UseParallelGC -XX\:ReservedCodeCacheSize\=768m
org.gradle.parallel=true

Loading…
Cancel
Save