Skip to content

Commit

Permalink
Target SDK 35 and push the preference activity down to allow insets a…
Browse files Browse the repository at this point in the history
…nd similar nonsense
  • Loading branch information
mendhak committed Oct 16, 2024
1 parent 74b9497 commit c417c4a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gpslogger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ repositories {
}

android {
compileSdk 34
compileSdk 35

defaultConfig {
applicationId "com.mendhak.gpslogger"
minSdkVersion 21

targetSdkVersion 34
targetSdkVersion 35
compileSdk 34
versionCode 132
versionName "132-test1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.preference.PreferenceFragmentCompat;

import android.view.MenuItem;
import android.view.ViewGroup;
import com.mendhak.gpslogger.common.PreferenceHelper;
import com.mendhak.gpslogger.common.Systems;
import com.mendhak.gpslogger.common.slf4j.Logs;
Expand All @@ -47,6 +51,25 @@ protected void onCreate(Bundle savedInstanceState) {
Systems.setLocale(PreferenceHelper.getInstance().getUserSpecifiedLocale(),getBaseContext(),getResources());
setContentView(R.layout.activity_preferences);

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.toolbar), (v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());

// Apply the insets as a margin to the view so it doesn't overlap with status bar
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
mlp.leftMargin = insets.left;
mlp.bottomMargin = insets.bottom;
mlp.rightMargin = insets.right;
mlp.topMargin = insets.top;
v.setLayoutParams(mlp);

// Alternatively set the padding on the view itself.
// v.setPadding(insets.left, 0, insets.right, insets.bottom);

// Return CONSUMED if you don't want want the window insets to keep passing
// down to descendant views.
return WindowInsetsCompat.CONSUMED;
});

Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if(getSupportActionBar() != null){
Expand Down
5 changes: 2 additions & 3 deletions gpslogger/src/main/res/layout/toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="55dp"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:contentInsetStart="72dp">
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</androidx.appcompat.widget.Toolbar>

0 comments on commit c417c4a

Please sign in to comment.