Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
package com.amaze.filemanager.ui.activities.superclasses;

import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.KITKAT;
import static android.os.Build.VERSION_CODES.KITKAT_WATCH;
import static android.os.Build.VERSION_CODES.LOLLIPOP;
import static android.os.Build.VERSION_CODES.M;
import static android.os.Build.VERSION_CODES.O;
import static com.amaze.filemanager.ui.fragments.preferencefragments.PreferencesConstants.PREFERENCE_COLORED_NAVIGATION;

import com.amaze.filemanager.R;
Expand All @@ -44,7 +48,6 @@
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.drawable.BitmapDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.View;
Expand All @@ -58,6 +61,11 @@
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.preference.PreferenceManager;

/** Created by arpitkh996 on 03-03-2016. */
Expand Down Expand Up @@ -86,6 +94,38 @@ public void onReceive(Context context, Intent i) {
}
};

@Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
setupEdgeToEdgeInsets();
}

@Override
public void setContentView(View view) {
super.setContentView(view);
setupEdgeToEdgeInsets();
}

/**
* Apply system bar insets as padding on the content view to handle Android 15+ edge-to-edge
* enforcement. This ensures content is laid out below the status bar and above the navigation
* bar.
*/
private void setupEdgeToEdgeInsets() {
if (SDK_INT >= 35) {
View contentView = findViewById(android.R.id.content);
if (contentView != null) {
ViewCompat.setOnApplyWindowInsetsListener(
contentView,
(v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
v.setPadding(insets.left, insets.top, insets.right, insets.bottom);
return WindowInsetsCompat.CONSUMED;
});
}
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -108,7 +148,7 @@ public void onCreate(Bundle savedInstanceState) {
getColorPreference().saveColorPreferences(getPrefs(), ColorPreferenceHelper.randomize(this));
}

if (SDK_INT >= 21) {
if (SDK_INT >= LOLLIPOP) {
ActivityManager.TaskDescription taskDescription =
new ActivityManager.TaskDescription(
getString(R.string.appbar_name),
Expand All @@ -132,8 +172,13 @@ public void initStatusBarResources(View parentView) {
}

Window window = getWindow();
if (SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (findViewById(R.id.tab_frame) != null || findViewById(R.id.drawer_layout) == null) {
if (SDK_INT >= LOLLIPOP) {
boolean useSolidStatusBar =
findViewById(R.id.tab_frame) != null
|| findViewById(R.id.drawer_layout) == null
|| getAppTheme().equals(AppTheme.LIGHT);

if (useSolidStatusBar) {
window.setStatusBarColor(PreferenceUtils.getStatusColor(getPrimary()));
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
} else {
Expand All @@ -150,8 +195,18 @@ public void initStatusBarResources(View parentView) {
window.setNavigationBarColor(Utils.getColor(this, R.color.holo_dark_background));
}
}
} else if (SDK_INT == Build.VERSION_CODES.KITKAT_WATCH
|| SDK_INT == Build.VERSION_CODES.KITKAT) {

// Set light/dark icon appearance for system bars based on theme
if (SDK_INT >= M) {
WindowInsetsControllerCompat insetsController =
WindowCompat.getInsetsController(window, window.getDecorView());
boolean isLightTheme = getAppTheme().equals(AppTheme.LIGHT);
insetsController.setAppearanceLightStatusBars(isLightTheme);
if (SDK_INT >= O) {
insetsController.setAppearanceLightNavigationBars(isLightTheme);
}
}
} else if (SDK_INT == KITKAT_WATCH || SDK_INT == KITKAT) {
setKitkatStatusBarMargin(parentView);
setKitkatStatusBarTint();
}
Expand Down Expand Up @@ -212,7 +267,7 @@ private Toolbar getToolbar() {

void setTheme() {
AppTheme theme = getAppTheme();
if (Build.VERSION.SDK_INT >= 21) {
if (SDK_INT >= LOLLIPOP) {

String stringRepresentation = String.format("#%06X", (0xFFFFFF & getAccent()));

Expand Down
Loading