version:1.0.0
update:更换包名 bugfixes:
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
package com.xxpatx.os.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xxpatx.os.R;
|
||||
import com.xxpatx.os.base.rx.BaseRxActivity;
|
||||
import com.xxpatx.os.config.CommonConfig;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
public abstract class BaseTransparentActivity extends BaseRxActivity {
|
||||
private static final String TAG = BaseTransparentActivity.class.getSimpleName();
|
||||
|
||||
|
||||
private MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置布局
|
||||
*/
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
/**
|
||||
* @return 是否是黑色状态栏
|
||||
*/
|
||||
// protected abstract boolean setNightMode();
|
||||
public boolean setNightMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 是否是入侵
|
||||
*/
|
||||
// protected abstract boolean setNightMode();
|
||||
public boolean setfitWindow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_VOLUME_UP://增大系统媒体音量
|
||||
case KeyEvent.KEYCODE_VOLUME_DOWN://减小系统媒体音量
|
||||
return getVolumeKeyStatus();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
public boolean getVolumeKeyStatus() {
|
||||
boolean disableKey = mmkv.decodeBool(CommonConfig.DISABLE_VOLUME_KEY, false);
|
||||
Log.e(TAG, "getVolumeKeyStatus: disableKey = " + disableKey);
|
||||
if (disableKey){
|
||||
Toaster.showLong("音量键已被禁用");
|
||||
}
|
||||
return disableKey;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user