ViewCompat.setOnApplyWindowInsetsListener in SendPrivateMessageActivity.

This commit is contained in:
Docile-Alligator
2025-06-16 21:58:51 -04:00
parent a3f6025445
commit b37bcf2e02
2 changed files with 36 additions and 3 deletions

View File

@ -1,13 +1,17 @@
package ml.docilealligator.infinityforreddit.activities;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.core.graphics.Insets;
import androidx.core.view.OnApplyWindowInsetsListener;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import com.google.android.material.snackbar.Snackbar;
@ -57,8 +61,35 @@ public class SendPrivateMessageActivity extends BaseActivity {
applyCustomTheme();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(binding.appbarLayoutSendPrivateMessageActivity);
if (isImmersiveInterface()) {
if (isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(binding.appbarLayoutSendPrivateMessageActivity);
}
ViewCompat.setOnApplyWindowInsetsListener(binding.getRoot(), new OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
Insets allInsets = insets.getInsets(
WindowInsetsCompat.Type.systemBars()
| WindowInsetsCompat.Type.displayCutout()
);
setMargins(binding.toolbarSendPrivateMessageActivity,
allInsets.left,
allInsets.top,
allInsets.right,
BaseActivity.IGNORE_MARGIN);
binding.nestedScrollViewSendPrivateMesassgeActivity.setPadding(
allInsets.left,
0,
allInsets.right,
allInsets.bottom);
return WindowInsetsCompat.CONSUMED;
}
});
}
mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null);

View File

@ -23,8 +23,10 @@
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll_view_send_private_mesassge_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout