File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
app/src/main/java/it/niedermann/owncloud/notes/edit Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 2020
2121import androidx .annotation .NonNull ;
2222import androidx .annotation .Nullable ;
23+ import androidx .core .graphics .Insets ;
24+ import androidx .core .view .ViewCompat ;
25+ import androidx .core .view .WindowCompat ;
26+ import androidx .core .view .WindowInsetsCompat ;
2327import androidx .fragment .app .Fragment ;
2428import androidx .preference .PreferenceManager ;
2529
@@ -101,6 +105,34 @@ protected void onCreate(final Bundle savedInstanceState) {
101105
102106 setSupportActionBar (binding .toolbar );
103107 binding .toolbar .setOnClickListener ((v ) -> fragment .showEditTitleDialog ());
108+ setImeInsets ();
109+ }
110+
111+ private void setImeInsets () {
112+ final var window = getWindow ();
113+ if (window == null ) {
114+ return ;
115+ }
116+
117+ WindowCompat .setDecorFitsSystemWindows (window , false );
118+
119+ final var decorView = window .getDecorView ();
120+ ViewCompat .setOnApplyWindowInsetsListener (decorView , (v , insets ) -> {
121+ Insets imeInsets = insets .getInsets (WindowInsetsCompat .Type .ime ());
122+ Insets navBarInsets = insets .getInsets (WindowInsetsCompat .Type .navigationBars ());
123+
124+ // Apply bottom padding when keyboard is shown
125+ int bottomPadding = Math .max (imeInsets .bottom , navBarInsets .bottom );
126+
127+ v .setPadding (
128+ v .getPaddingLeft (),
129+ v .getPaddingTop (),
130+ v .getPaddingRight (),
131+ bottomPadding
132+ );
133+
134+ return insets ;
135+ });
104136 }
105137
106138 @ Override
You can’t perform that action at this time.
0 commit comments