Skip to content

Commit

Permalink
fix: Attempt to fix the FAB's weird margin behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
aikrq committed Dec 29, 2024
1 parent f711aeb commit 83427f8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@
android:configChanges="orientation|screenSize" />
<activity
android:name="dev.aldi.sayuti.editor.manage.ManageLocalLibraryActivity"
android:configChanges="orientation|screenSize" />
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="adjustResize" />
<activity
android:name="mod.agus.jcoderz.editor.manage.permission.ManagePermissionActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ protected void onCreate(Bundle savedInstanceState) {
binding = ManageLocallibrariesBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

ViewCompat.setOnApplyWindowInsetsListener(binding.downloadLibraryButton, new AddMarginOnApplyWindowInsetsListener(WindowInsetsCompat.Type.navigationBars(), WindowInsetsCompat.CONSUMED));
ViewCompat.setOnApplyWindowInsetsListener(binding.downloadLibraryButton,
new AddMarginOnApplyWindowInsetsListener(WindowInsetsCompat.Type.navigationBars() |
WindowInsetsCompat.Type.ime(), WindowInsetsCompat.CONSUMED));

if (getIntent().hasExtra("sc_id")) {
String scId = Objects.requireNonNull(getIntent().getStringExtra("sc_id"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public class AddMarginOnApplyWindowInsetsListener implements OnApplyWindowInsets
private final int insetsTypeMask;
private final WindowInsetsCompat returnValue;

/**
* @param insetsTypeMask Bit mask of {@link WindowInsetsCompat.Type}s to query the insets for.
*/
public AddMarginOnApplyWindowInsetsListener(int insetsTypeMask) {
this(insetsTypeMask, null);
}

/**
* @param insetsTypeMask Bit mask of {@link WindowInsetsCompat.Type}s to query the insets for.
* @param returnValue What {@link #onApplyWindowInsets(View, WindowInsetsCompat)} should return.
Expand All @@ -36,6 +43,6 @@ public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowIn
} else {
throw new IllegalArgumentException("View's layout params must extend ViewGroup.MarginLayoutParams");
}
return returnValue;
return returnValue != null ? returnValue : insets;
}
}
4 changes: 3 additions & 1 deletion app/src/main/res/layout/manage_locallibraries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/libraries_list"
Expand Down Expand Up @@ -37,6 +38,7 @@
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
android:hint="Search for libraries"
app:layout_anchor="@id/search_bar">

Expand Down

0 comments on commit 83427f8

Please sign in to comment.