mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 15:01:57 +03:00
addSystemBarPaddings
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
5dab2604d2
commit
42a9c1fa69
4 changed files with 12 additions and 37 deletions
|
@ -9,28 +9,25 @@ package com.nextcloud.utils.extensions
|
|||
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updatePadding
|
||||
|
||||
fun Window?.makeStatusBarTransparent() {
|
||||
val flag = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
this?.setFlags(flag, flag)
|
||||
}
|
||||
|
||||
fun Window?.addStatusBarPadding() {
|
||||
fun Window?.addSystemBarPaddings() {
|
||||
if (this == null) {
|
||||
return
|
||||
}
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(decorView) { v: View, insets: WindowInsetsCompat ->
|
||||
val statusBarInsets = insets.getInsets(WindowInsetsCompat.Type.statusBars())
|
||||
v.setPadding(
|
||||
v.paddingLeft,
|
||||
statusBarInsets.top,
|
||||
v.paddingRight,
|
||||
v.paddingBottom
|
||||
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
|
||||
v.updatePadding(
|
||||
left = bars.left,
|
||||
top = bars.top,
|
||||
right = bars.right,
|
||||
bottom = bars.bottom,
|
||||
)
|
||||
insets
|
||||
|
||||
WindowInsetsCompat.CONSUMED
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.accounts.Account;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
|
@ -20,7 +19,6 @@ import com.nextcloud.client.mixins.MixinRegistry;
|
|||
import com.nextcloud.client.mixins.SessionMixin;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.nextcloud.utils.extensions.ActivityExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.WindowExtensionsKt;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
|
@ -35,7 +33,6 @@ import androidx.activity.EdgeToEdge;
|
|||
import androidx.activity.SystemBarStyle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
|
||||
/**
|
||||
* Base activity with common behaviour for activities dealing with ownCloud {@link Account}s .
|
||||
|
@ -72,8 +69,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
|
|||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
enableEdgeToEdge();
|
||||
WindowExtensionsKt.makeStatusBarTransparent(getWindow());
|
||||
WindowExtensionsKt.addStatusBarPadding(getWindow());
|
||||
WindowExtensionsKt.addSystemBarPaddings(getWindow());
|
||||
super.onCreate(savedInstanceState);
|
||||
sessionMixin = new SessionMixin(this, accountManager);
|
||||
mixinRegistry.add(sessionMixin);
|
||||
|
|
|
@ -50,8 +50,6 @@ import com.nextcloud.client.network.ConnectivityService;
|
|||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.nextcloud.utils.extensions.ViewExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.WindowExtensionsKt;
|
||||
import com.nextcloud.utils.mdm.MDMConfig;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
|
@ -146,8 +144,6 @@ public class SettingsActivity extends PreferenceActivity
|
|||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
WindowExtensionsKt.makeStatusBarTransparent(getWindow());
|
||||
WindowExtensionsKt.addStatusBarPadding(getWindow());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getDelegate().installViewFactory();
|
||||
|
@ -191,19 +187,6 @@ public class SettingsActivity extends PreferenceActivity
|
|||
// workaround for mismatched color when app dark mode and system dark mode don't agree
|
||||
setListBackground();
|
||||
showPasscodeDialogIfEnforceAppProtection();
|
||||
adjustTopMarginForActionBar();
|
||||
}
|
||||
|
||||
private void adjustTopMarginForActionBar() {
|
||||
if (getListView() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
float topMarginInDp = getResources().getDimension(R.dimen.settings_activity_padding);
|
||||
int topMarginInPx = DisplayUtils.convertDpToPixel(topMarginInDp, this);
|
||||
ViewExtensionsKt.setMargins(getListView(), 0, topMarginInPx, 0, 0);
|
||||
|
||||
getWindow().getDecorView().setBackgroundColor(ContextCompat.getColor(this, R.color.bg_default));
|
||||
}
|
||||
|
||||
private void showPasscodeDialogIfEnforceAppProtection() {
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
<dimen name="list_item_share_right_margin">12dp</dimen>
|
||||
<dimen name="live_photo_indicator_vertical_padding">3dp</dimen>
|
||||
<dimen name="live_photo_indicator_horizontal_padding">16dp</dimen>
|
||||
<dimen name="settings_activity_padding">24dp</dimen>
|
||||
<dimen name="file_list_item_avatar_icon_radius">10dp</dimen>
|
||||
<dimen name="account_action_layout_height">72dp</dimen>
|
||||
<dimen name="zero">0dp</dimen>
|
||||
|
|
Loading…
Reference in a new issue