Skip to content

Commit 4991432

Browse files
committed
setImeInsets
Signed-off-by: alperozturk <[email protected]>
1 parent 5c319f4 commit 4991432

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@
2020

2121
import androidx.annotation.NonNull;
2222
import 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;
2327
import androidx.fragment.app.Fragment;
2428
import androidx.preference.PreferenceManager;
2529

30+
import com.nextcloud.android.common.ui.util.extensions.AppCompatActivityExtensionsKt;
2631
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
2732
import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException;
2833
import com.nextcloud.android.sso.helper.SingleAccountHelper;
@@ -101,6 +106,26 @@ protected void onCreate(final Bundle savedInstanceState) {
101106

102107
setSupportActionBar(binding.toolbar);
103108
binding.toolbar.setOnClickListener((v) -> fragment.showEditTitleDialog());
109+
setImeInsets();
110+
}
111+
112+
private void setImeInsets() {
113+
ViewCompat.setOnApplyWindowInsetsListener(this.getWindow().getDecorView(), (v, insets) -> {
114+
Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
115+
Insets navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars());
116+
117+
// Apply bottom padding when keyboard is shown
118+
int bottomPadding = Math.max(imeInsets.bottom, navBarInsets.bottom);
119+
120+
v.setPadding(
121+
v.getPaddingLeft(),
122+
v.getPaddingTop(),
123+
v.getPaddingRight(),
124+
bottomPadding
125+
);
126+
127+
return insets;
128+
});
104129
}
105130

106131
@Override

0 commit comments

Comments
 (0)