85 lines
2.4 KiB
Java
85 lines
2.4 KiB
Java
package com.ttstd.dialer.base;
|
|
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
|
|
import androidx.annotation.CallSuper;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
import androidx.core.graphics.Insets;
|
|
import androidx.core.view.OnApplyWindowInsetsListener;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.WindowInsetsCompat;
|
|
|
|
import com.ttstd.dialer.R;
|
|
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
|
|
|
public abstract class BaseTransparentActivity extends AppCompatActivity {
|
|
|
|
public BaseTransparentActivity() {
|
|
super();
|
|
}
|
|
|
|
@Override
|
|
@CallSuper
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
// StatusBarUtil.init(this);
|
|
UltimateBarX.statusBar(this)
|
|
.transparent()
|
|
// .colorRes(R.color.colorPrimaryDark)
|
|
.light(setNightMode())
|
|
.fitWindow(setfitWindow())
|
|
.apply();
|
|
UltimateBarX.navigationBar(this)
|
|
.transparent()
|
|
// .colorRes(R.color.colorPrimaryDark)
|
|
.light(setNightMode())
|
|
.fitWindow(setfitWindow())
|
|
.apply();
|
|
}
|
|
|
|
@Override
|
|
protected void onResume() {
|
|
super.onResume();
|
|
}
|
|
|
|
/**
|
|
* 设置布局
|
|
*/
|
|
protected abstract int getLayoutId();
|
|
|
|
/**
|
|
* @return 是否是黑色状态栏
|
|
*/
|
|
// protected abstract boolean setNightMode();
|
|
public boolean setNightMode() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* @return 是否是入侵
|
|
*/
|
|
// protected abstract boolean setNightMode();
|
|
public boolean setfitWindow() {
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* @param view android 15 edge-to-edge会覆盖导航栏
|
|
*/
|
|
public void addNavigationBarBottomPadding(View view) {
|
|
UltimateBarX.addNavigationBarBottomPadding(view);
|
|
if (Build.VERSION.SDK_INT >= 35) {
|
|
ViewCompat.setOnApplyWindowInsetsListener(view, new OnApplyWindowInsetsListener() {
|
|
@Override
|
|
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
|
|
Insets systemInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars());
|
|
v.setPadding(0, 0, 0, systemInsets.bottom);
|
|
return insets;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
} |