Android. Update target sdk and compile sdk to 36.
Actual version of Android SDK is 36 and Android Studio suggests to update targetSdk and compileSdk properties. These fields were updated in module-level build.gradle.kts. In addition, the window insets listeners has been added (to avoid problems with enforced edge-to-edge mode, problem was described here: https://git.libreoffice.org/core/commit/2b77994d455b8d066baf6b67c1820fbb736b538f). Change-Id: Ice33930651a597bf2bf569c993dde3ea66ea2ca4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203108 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
committed by
Michael Weghorn
parent
5404fa395f
commit
4e3f695614
@@ -46,7 +46,7 @@ base {
|
||||
|
||||
android {
|
||||
namespace = "org.libreoffice"
|
||||
compileSdk = 35
|
||||
compileSdk = 36
|
||||
|
||||
ndkPath = androidNdkPath
|
||||
ndkVersion = androidNdkVersion
|
||||
@@ -84,7 +84,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
// minSdkVersion is set in liboSettings.gradle.kts
|
||||
targetSdk = 35
|
||||
targetSdk = 36
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- The toolbar -->
|
||||
@@ -47,6 +48,7 @@
|
||||
|
||||
<!-- The content -->
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/nestedScrollView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="#fff"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".LibreOfficeMainActivity">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="LibreOfficeTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||
<item name="android:windowOptOutEdgeToEdgeEnforcement">
|
||||
true
|
||||
</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -4,6 +4,10 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.GestureDetectorCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.KeyEvent;
|
||||
@@ -22,13 +26,24 @@ public class PresentationActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
View decorView = getWindow().getDecorView();
|
||||
// Hide the status bar.
|
||||
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
decorView.setSystemUiVisibility(uiOptions);
|
||||
|
||||
setContentView(R.layout.presentation_mode);
|
||||
ViewCompat.setOnApplyWindowInsetsListener(getWindow().getDecorView(), (v, windowInsets) -> {
|
||||
WindowInsetsCompat compat = WindowInsetsCompat.toWindowInsetsCompat(windowInsets.toWindowInsets(), v);
|
||||
Insets systemBars = compat.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
Insets displayCutout = compat.getInsets(WindowInsetsCompat.Type.displayCutout());
|
||||
int top = Math.max(systemBars.top, displayCutout.top);
|
||||
int bottom = Math.max(systemBars.bottom, displayCutout.bottom);
|
||||
int left = Math.max(systemBars.left, displayCutout.left);
|
||||
int right = Math.max(systemBars.right, displayCutout.right);
|
||||
v.setPadding(left, top, right, bottom);
|
||||
return windowInsets;
|
||||
});
|
||||
|
||||
// get intent and url
|
||||
Intent intent = getIntent();
|
||||
|
||||
@@ -8,7 +8,14 @@
|
||||
*/
|
||||
package org.libreoffice;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
@@ -17,11 +24,29 @@ public class SettingsActivity extends FragmentActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Window window = getWindow();
|
||||
View decorView = window.getDecorView();
|
||||
int systemUiVisibility = decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||
decorView.setSystemUiVisibility(systemUiVisibility);
|
||||
}
|
||||
|
||||
// Display the fragment as the main content.
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(android.R.id.content, new SettingsFragment())
|
||||
.commit();
|
||||
ViewCompat.setOnApplyWindowInsetsListener(getWindow().getDecorView().findViewById(android.R.id.content), (v, windowInsets) -> {
|
||||
WindowInsetsCompat compat = WindowInsetsCompat.toWindowInsetsCompat(windowInsets.toWindowInsets(), v);
|
||||
Insets systemBars = compat.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
Insets displayCutout = compat.getInsets(WindowInsetsCompat.Type.displayCutout());
|
||||
int top = Math.max(systemBars.top, displayCutout.top);
|
||||
int bottom = Math.max(systemBars.bottom, displayCutout.bottom);
|
||||
int left = Math.max(systemBars.left, displayCutout.left);
|
||||
int right = Math.max(systemBars.right, displayCutout.right);
|
||||
v.setPadding(left, top, right, bottom);
|
||||
return windowInsets;
|
||||
});
|
||||
}
|
||||
|
||||
public static class SettingsFragment extends PreferenceFragmentCompat {
|
||||
|
||||
@@ -17,11 +17,15 @@ import android.content.pm.ShortcutInfo;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
@@ -34,6 +38,8 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
@@ -49,6 +55,7 @@ import org.libreoffice.SettingsActivity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class LibreOfficeUIActivity extends AppCompatActivity implements View.OnClickListener{
|
||||
public enum DocumentType {
|
||||
@@ -128,13 +135,25 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements View.OnC
|
||||
private LinearLayout writerLayout;
|
||||
private LinearLayout impressLayout;
|
||||
private LinearLayout calcLayout;
|
||||
private Toolbar toolbar;
|
||||
private View rootView;
|
||||
private View drawerLayout;
|
||||
private View nestedScrollView;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
Window window = getWindow();
|
||||
View decorView = window.getDecorView();
|
||||
int systemUiVisibility = decorView.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||
decorView.setSystemUiVisibility(systemUiVisibility);
|
||||
}
|
||||
|
||||
// init UI
|
||||
createUI();
|
||||
|
||||
fabOpenAnimation = AnimationUtils.loadAnimation(this, R.anim.fab_open);
|
||||
fabCloseAnimation = AnimationUtils.loadAnimation(this, R.anim.fab_close);
|
||||
|
||||
@@ -156,8 +175,11 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements View.OnC
|
||||
public void createUI() {
|
||||
setContentView(R.layout.activity_document_browser);
|
||||
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
toolbar = findViewById(R.id.toolbar);
|
||||
rootView = findViewById(android.R.id.content);
|
||||
drawerLayout = findViewById(R.id.drawer_layout);
|
||||
nestedScrollView = findViewById(R.id.nestedScrollView);
|
||||
setSupportActionBar((Toolbar) toolbar);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
|
||||
if (actionBar != null) {
|
||||
@@ -204,6 +226,7 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements View.OnC
|
||||
|
||||
recentRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
recentRecyclerView.setAdapter(new RecentFilesAdapter(this, recentFiles));
|
||||
setupWindowInsetsListener();
|
||||
}
|
||||
|
||||
private void expandFabMenu() {
|
||||
@@ -219,6 +242,29 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements View.OnC
|
||||
isFabMenuOpen = true;
|
||||
}
|
||||
|
||||
private void setupWindowInsetsListener() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(toolbar, (v, windowInsets) -> {
|
||||
WindowInsetsCompat compat = WindowInsetsCompat.toWindowInsetsCompat(Objects.requireNonNull(windowInsets.toWindowInsets()), v);
|
||||
Insets systemBars = compat.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
Insets displayCutout = compat.getInsets(WindowInsetsCompat.Type.displayCutout());
|
||||
int top = Math.max(systemBars.top, displayCutout.top);
|
||||
v.setPadding(v.getPaddingLeft(), top, v.getPaddingRight(), v.getPaddingBottom());
|
||||
return windowInsets;
|
||||
});
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(nestedScrollView, (v, windowInsets) -> {
|
||||
WindowInsetsCompat compat = WindowInsetsCompat.toWindowInsetsCompat(Objects.requireNonNull(windowInsets.toWindowInsets()), v);
|
||||
Insets systemBars = compat.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
Insets displayCutout = compat.getInsets(WindowInsetsCompat.Type.displayCutout());
|
||||
int top = Math.max(systemBars.top, displayCutout.top);
|
||||
int bottom = Math.max(systemBars.bottom, displayCutout.bottom);
|
||||
int left = Math.max(systemBars.left, displayCutout.left);
|
||||
int right = Math.max(systemBars.right, displayCutout.right);
|
||||
v.setPadding(left, top, right, bottom);
|
||||
return windowInsets;
|
||||
});
|
||||
}
|
||||
|
||||
private void collapseFabMenu() {
|
||||
ViewCompat.animate(editFAB).rotation(0.0F).withLayer().setDuration(300).setInterpolator(new OvershootInterpolator(10.0F)).start();
|
||||
writerLayout.startAnimation(fabCloseAnimation);
|
||||
@@ -320,7 +366,10 @@ public class LibreOfficeUIActivity extends AppCompatActivity implements View.OnC
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Log.d(LOGTAG, "onResume");
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
createUI();
|
||||
ViewCompat.requestApplyInsets(toolbar);
|
||||
ViewCompat.requestApplyInsets(nestedScrollView);
|
||||
}
|
||||
|
||||
private void addDocumentToRecents(Uri fileUri) {
|
||||
|
||||
Reference in New Issue
Block a user