clarify add repo box

closes #216`

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/284/head
androidacy-user 1 year ago
parent 68bf2636c3
commit a277a7e18e

@ -20,9 +20,12 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.provider.Settings; import android.provider.Settings;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -1052,30 +1055,42 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
input.setHint(R.string.custom_url); input.setHint(R.string.custom_url);
builder.setIcon(R.drawable.ic_baseline_add_box_24); builder.setIcon(R.drawable.ic_baseline_add_box_24);
builder.setTitle(R.string.add_repo); builder.setTitle(R.string.add_repo);
// make link in message clickable
//noinspection deprecation
builder.setMessage(Html.fromHtml(getString(R.string.add_repo_message)));
builder.setView(input); builder.setView(input);
builder.setPositiveButton("OK", (dialog, which) -> { builder.setPositiveButton("OK", (dialog, which) -> {
String text = String.valueOf(input.getText()); String text = String.valueOf(input.getText());
if (customRepoManager.canAddRepo(text)) { // string should not be empty, start with https://, and not contain any spaces. http links are not allowed.
final CustomRepoData customRepoData = customRepoManager.addRepo(text); if (text.matches("^https://.*") && !text.contains(" ") && !text.isEmpty()) {
new Thread("Add Custom Repo Thread") { if (customRepoManager.canAddRepo(text)) {
@Override final CustomRepoData customRepoData = customRepoManager.addRepo(text);
public void run() { new Thread("Add Custom Repo Thread") {
try { @Override
customRepoData.quickPrePopulate(); public void run() {
UiThreadHandler.handler.post(() -> updateCustomRepoList(false)); try {
} catch ( customRepoData.quickPrePopulate();
Exception e) { UiThreadHandler.handler.post(() -> updateCustomRepoList(false));
Timber.e(e); } catch (
// show new dialog Exception e) {
new Handler(Looper.getMainLooper()).post(() -> new MaterialAlertDialogBuilder(context).setTitle(R.string.error_adding).setMessage(e.getMessage()).setPositiveButton(android.R.string.ok, (dialog1, which1) -> { Timber.e(e);
}).show()); // show new dialog
new Handler(Looper.getMainLooper()).post(() -> new MaterialAlertDialogBuilder(context).setTitle(R.string.error_adding).setMessage(e.getMessage()).setPositiveButton(android.R.string.ok, (dialog1, which1) -> {
}).show());
}
} }
} }.start();
}.start(); } else {
Snackbar.make(requireView(), R.string.invalid_repo_url, BaseTransientBottomBar.LENGTH_LONG).show();
}
} else {
Snackbar.make(requireView(), R.string.invalid_repo_url, BaseTransientBottomBar.LENGTH_LONG).show();
} }
}); });
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel()); builder.setNegativeButton("Cancel", (dialog, which) -> dialog.cancel());
AlertDialog alertDialog = builder.show(); AlertDialog alertDialog = builder.show();
//make message clickable
((TextView) Objects.requireNonNull(alertDialog.findViewById(android.R.id.message))).setMovementMethod(LinkMovementMethod.getInstance());
final Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); final Button positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
input.setValidator(new AutoCompleteTextView.Validator() { input.setValidator(new AutoCompleteTextView.Validator() {
@Override @Override

@ -340,5 +340,6 @@
<string name="error_download_update">An error occurred downloading the update information.</string> <string name="error_download_update">An error occurred downloading the update information.</string>
<string name="error_no_asset">ERROR: Failed to parse update information</string> <string name="error_no_asset">ERROR: Failed to parse update information</string>
<string name="downloading_update">Downloading update… %1$d%%</string> <string name="downloading_update">Downloading update… %1$d%%</string>
<string name="installing_update">Installing update…</string><string name="no_file_found">ERROR: Could not find update package.</string><string name="check_for_updates">Check for app updates</string><string name="update_debug_download_pref">Test update download mechanism</string><string name="changelog_none">No changes yet!</string><string name="update_cancel_button">Cancel update</string> <string name="installing_update">Installing update…</string><string name="no_file_found">ERROR: Could not find update package.</string><string name="check_for_updates">Check for app updates</string><string name="update_debug_download_pref">Test update download mechanism</string><string name="changelog_none">No changes yet!</string><string name="update_cancel_button">Cancel update</string><string name="invalid_repo_url">The URL you entered for the repo is invalid</string>
<string name="add_repo_message">Repos must be served over HTTPS, and must follow the spec outlined in the <a href="https://github.com/Fox2Code/FoxMagiskModuleManager/blob/master/docs/DEVELOPERS.md#custom-repo-format">docs</a>.</string>
</resources> </resources>

Loading…
Cancel
Save