diff --git a/build.gradle b/build.gradle index 7bea7f1c..547399ba 100644 --- a/build.gradle +++ b/build.gradle @@ -101,7 +101,7 @@ def getVersionName = { } android { - compileSdk 34 + compileSdkPreview "VanillaIceCream" packagingOptions { resources { excludes += ['META-INF/LICENSE', 'META-INF/NOTICE'] @@ -114,7 +114,7 @@ android { defaultConfig { //noinspection OldTargetApi - targetSdkVersion 34 + targetSdkPreview "VanillaIceCream" minSdkVersion 21 // Android 5.0 versionCode getVersionCode() versionName getVersionName() diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index d7c45d01..bf378f7a 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -28,6 +28,7 @@ = Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + ViewCompat.requestApplyInsets(webviewContainer.getRootView()); +// ((View) webviewContainer.getParent()).requestApplyInsets(); + } // Add an alarming red border if using configurable (i.e. dev) // app with a medic production server. if (settings.allowsConfiguration() && appUrl != null && appUrl.contains("app.medicmobile.org")) { - View webviewContainer = findViewById(R.id.lytWebView); webviewContainer.setPadding(10, 10, 10, 10); webviewContainer.setBackgroundResource(R.drawable.warning_background); } // Add a noticeable border to easily identify a training app if (BuildConfig.IS_TRAINING_APP) { - View webviewContainer = findViewById(R.id.lytWebView); webviewContainer.setPadding(10, 10, 10, 10); webviewContainer.setBackgroundResource(R.drawable.training_background); } container = findViewById(R.id.wbvMain); + getFragmentManager() .beginTransaction() - .add(new OpenSettingsDialogFragment(container), OpenSettingsDialogFragment.class.getName()) + .add(new OpenSettingsDialogFragment(), OpenSettingsDialogFragment.class.getName()) .commit(); configureUserAgent(); diff --git a/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java b/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java index bc688d76..fc6fb012 100644 --- a/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java +++ b/src/main/java/org/medicmobile/webapp/mobile/OpenSettingsDialogFragment.java @@ -1,5 +1,7 @@ package org.medicmobile.webapp.mobile; +import static org.medicmobile.webapp.mobile.MedicLog.trace; + import android.annotation.SuppressLint; import android.app.Activity; import android.app.Fragment; @@ -16,7 +18,7 @@ @SuppressLint("ValidFragment") public class OpenSettingsDialogFragment extends Fragment { - private final View view; + private View view; private int fingerTapCount = 0; private long lastTimeTap = 0; private GestureHandler swipeGesture; @@ -32,14 +34,11 @@ public boolean onTouch(View view, MotionEvent event) { } }; - public OpenSettingsDialogFragment(View view) { - this.view = view; - } - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - view.setOnTouchListener(onTouchListener); + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + this.view = view.findViewById(R.id.wbvMain); + this.view.setOnTouchListener(onTouchListener); } private void countTaps(MotionEvent event) { diff --git a/src/main/java/org/medicmobile/webapp/mobile/SettingsDialogActivity.java b/src/main/java/org/medicmobile/webapp/mobile/SettingsDialogActivity.java index f36c929b..ea8f67f9 100644 --- a/src/main/java/org/medicmobile/webapp/mobile/SettingsDialogActivity.java +++ b/src/main/java/org/medicmobile/webapp/mobile/SettingsDialogActivity.java @@ -10,6 +10,7 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.XmlResourceParser; +import android.os.Build; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; @@ -19,6 +20,7 @@ import android.widget.ListView; import android.widget.TextView; +import androidx.core.view.ViewCompat; import androidx.fragment.app.FragmentActivity; import org.medicmobile.webapp.mobile.adapters.FilterableListAdapter; @@ -60,10 +62,16 @@ private void displayServerSelectList() { setContentView(R.layout.server_select_list); - ListView list = findViewById(R.id.lstServers); + // TODO: replace `UPSIDE_DOWN_CAKE` with `VANILLA_ICE_CREAM` when SDK 35 comes out of preview + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + View view = findViewById(R.id.serverSelectListLayout); + ViewCompat.requestApplyInsets(view.getRootView()); +// ((View) view.getParent()).requestApplyInsets(); + } List servers = serverRepo.getServers(); ServerMetadataAdapter adapter = ServerMetadataAdapter.createInstance(this, servers); + ListView list = findViewById(R.id.lstServers); list.setAdapter(adapter); list.setOnItemClickListener(new ServerClickListener(adapter)); @@ -80,6 +88,12 @@ private void displayCustomServerForm() { state = STATE_FORM; setContentView(R.layout.custom_server_form); + // TODO: replace `UPSIDE_DOWN_CAKE` with `VANILLA_ICE_CREAM` when SDK 35 comes out of preview + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + View view = findViewById(R.id.customServerFormLayout); + ViewCompat.requestApplyInsets(view.getRootView()); +// ((View) view.getParent()).requestApplyInsets(); + } if(!this.settings.hasWebappSettings()) { cancelButton().setVisibility(View.GONE); diff --git a/src/main/res/layout/custom_server_form.xml b/src/main/res/layout/custom_server_form.xml index a0c34725..f78d43eb 100644 --- a/src/main/res/layout/custom_server_form.xml +++ b/src/main/res/layout/custom_server_form.xml @@ -1,36 +1,42 @@ - - -