mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
add App Picker URL setting
This commit is contained in:
@@ -22,6 +22,7 @@ import com.b44t.messenger.rpc.Rpc;
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
import org.thoughtcrime.securesms.providers.PersistentBlobProvider;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
import org.thoughtcrime.securesms.util.Prefs;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.HashMap;
|
||||
@@ -80,9 +81,7 @@ public class WebxdcStoreActivity extends PassphraseRequiredActionBarActivity {
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webView.setNetworkAvailable(true); // this does not block network but sets `window.navigator.isOnline` in js land
|
||||
|
||||
// TODO: use setting
|
||||
String storeURL = "https://webxdc.org/apps/";
|
||||
webView.loadUrl(storeURL);
|
||||
webView.loadUrl(Prefs.getWebxdcStoreUrl(this));
|
||||
}
|
||||
|
||||
private WebResourceResponse interceptRequest(String url) {
|
||||
|
||||
@@ -156,6 +156,10 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
|
||||
webrtcInstance.setOnPreferenceClickListener(new WebrtcInstanceListener());
|
||||
updateWebrtcSummary();
|
||||
|
||||
Preference webxdcStore = this.findPreference(Prefs.WEBXDC_STORE_URL_PREF);
|
||||
webxdcStore.setOnPreferenceClickListener(new WebxdcStoreUrlListener());
|
||||
updateWebxdcStoreSummary();
|
||||
|
||||
Preference newBroadcastList = this.findPreference("pref_new_broadcast_list");
|
||||
newBroadcastList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
if ((Boolean)newValue) {
|
||||
@@ -345,6 +349,29 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
private class WebxdcStoreUrlListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
View gl = View.inflate(getActivity(), R.layout.single_line_input, null);
|
||||
EditText inputField = gl.findViewById(R.id.input_field);
|
||||
inputField.setHint(Prefs.DEFAULT_WEBXDC_STORE_URL);
|
||||
inputField.setText(Prefs.getWebxdcStoreUrl(getActivity()));
|
||||
inputField.setSelection(inputField.getText().length());
|
||||
inputField.setInputType(TYPE_TEXT_VARIATION_URI);
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.webxdc_store_url)
|
||||
.setMessage(R.string.webxdc_store_url_explain)
|
||||
.setView(gl)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(android.R.string.ok, (dlg, btn) -> {
|
||||
Prefs.setWebxdcStoreUrl(getActivity(), inputField.getText().toString());
|
||||
updateWebxdcStoreSummary();
|
||||
})
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWebrtcSummary() {
|
||||
Preference webrtcInstance = this.findPreference("pref_webrtc_instance");
|
||||
if (webrtcInstance != null) {
|
||||
@@ -353,6 +380,13 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWebxdcStoreSummary() {
|
||||
Preference preference = this.findPreference(Prefs.WEBXDC_STORE_URL_PREF);
|
||||
if (preference != null) {
|
||||
preference.setSummary(Prefs.getWebxdcStoreUrl(getActivity()));
|
||||
}
|
||||
}
|
||||
|
||||
private void openRegistrationActivity() {
|
||||
Intent intent = new Intent(getActivity(), RegistrationActivity.class);
|
||||
startActivity(intent);
|
||||
|
||||
@@ -62,6 +62,8 @@ public class Prefs {
|
||||
public static final boolean ALWAYS_LOAD_REMOTE_CONTENT_DEFAULT = false;
|
||||
|
||||
public static final String LAST_DEVICE_MSG_LABEL = "pref_last_device_msg_id";
|
||||
public static final String WEBXDC_STORE_URL_PREF = "pref_webxdc_store_url";
|
||||
public static final String DEFAULT_WEBXDC_STORE_URL = "https://webxdc.org/apps/";
|
||||
|
||||
public enum VibrateState {
|
||||
DEFAULT(0), ENABLED(1), DISABLED(2);
|
||||
@@ -144,6 +146,15 @@ public class Prefs {
|
||||
return getStringPreference(context, THEME_PREF, DynamicTheme.systemThemeAvailable() ? DynamicTheme.SYSTEM : DynamicTheme.LIGHT);
|
||||
}
|
||||
|
||||
public static String getWebxdcStoreUrl(Context context) {
|
||||
return getStringPreference(context, WEBXDC_STORE_URL_PREF, DEFAULT_WEBXDC_STORE_URL);
|
||||
}
|
||||
|
||||
public static void setWebxdcStoreUrl(Context context, String url) {
|
||||
if (url == null || url.trim().isEmpty() || DEFAULT_WEBXDC_STORE_URL.equals(url)) url = null;
|
||||
setStringPreference(context, WEBXDC_STORE_URL_PREF, url);
|
||||
}
|
||||
|
||||
public static void setPromptedDozeMsgId(Context context, int msg_id) {
|
||||
setIntegerPreference(context, PROMPTED_DOZE_MSG_ID_PREF, msg_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user