allow rotation in AddLocation

This commit is contained in:
woheller69 2023-10-12 10:39:32 +02:00
parent 5039510970
commit 0d53115e68

View file

@ -56,6 +56,7 @@ public class AddLocationDialogOmGeocodingAPI extends DialogFragment {
Activity activity;
View rootView;
SQLiteHelper database;
private WebView webview;
private AutoCompleteTextView autoCompleteTextView;
City selectedCity;
@ -70,6 +71,10 @@ public class AddLocationDialogOmGeocodingAPI extends DialogFragment {
String url="";
String lang="en";
public AddLocationDialogOmGeocodingAPI() {
setRetainInstance(true);
}
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
@ -84,6 +89,17 @@ public class AddLocationDialogOmGeocodingAPI extends DialogFragment {
if (savedInstanceState != null) dismiss();
}
@Override
public void onResume() {
super.onResume();
handler.removeMessages(TRIGGER_HIDE_KEYBOARD);
if(selectedCity != null && webview != null) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity);
String osmTiles = sp.getString("pref_OsmTiles_URL", BuildConfig.TILES_URL);
webview.loadUrl("file:///android_asset/map.html?lat=" + selectedCity.getLatitude() + "&lon=" + selectedCity.getLongitude() + "&tiles=" + osmTiles);
}
}
@NonNull
@SuppressLint("SetJavaScriptEnabled")
@Override
@ -106,7 +122,7 @@ public class AddLocationDialogOmGeocodingAPI extends DialogFragment {
this.database = SQLiteHelper.getInstance(activity);
final WebView webview= rootView.findViewById(R.id.webViewAddLocation);
webview = rootView.findViewById(R.id.webViewAddLocation);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setUserAgentString(BuildConfig.APPLICATION_ID+"/"+BuildConfig.VERSION_NAME);
webview.setBackgroundColor(0x00000000);