Skip to content

Commit

Permalink
安卓P以上版本的刘海屏适配; 搜索界面不自动拉取软键盘;
Browse files Browse the repository at this point in the history
  • Loading branch information
q215613905 committed Nov 9, 2022
1 parent c85f0a8 commit ab7429c
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 40 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/com/github/tvbox/osc/base/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import me.jessyan.autosize.AutoSizeCompat;
import me.jessyan.autosize.internal.CustomAdapt;
import xyz.doikki.videoplayer.util.CutoutUtil;

/**
* @author pj567
Expand Down Expand Up @@ -59,6 +60,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutResID());
mContext = this;
CutoutUtil.adaptCutoutAboveAndroidP(mContext, true);//设置刘海
AppManager.getInstance().addActivity(this);
init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@ public boolean onLongClick(View view) {
mPlayerBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// myHandle.removeCallbacks(myRunnable);
// myHandle.postDelayed(myRunnable, myHandleSeconds);
myHandle.removeCallbacks(myRunnable);
myHandle.postDelayed(myRunnable, myHandleSeconds);
try {
int playerType = mPlayerConfig.getInt("pl");
ArrayList<Integer> exsitPlayerTypes = PlayerHelper.getExistPlayerTypes();
Expand All @@ -376,14 +376,15 @@ public void onClick(View view) {
e.printStackTrace();
}
mPlayerBtn.requestFocus();
mPlayerBtn.requestFocusFromTouch();
}
});

mPlayerBtn.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
// myHandle.removeCallbacks(myRunnable);
// myHandle.postDelayed(myRunnable, myHandleSeconds);
myHandle.removeCallbacks(myRunnable);
myHandle.postDelayed(myRunnable, myHandleSeconds);
FastClickCheckUtil.check(view);
try {
int playerType = mPlayerConfig.getInt("pl");
Expand All @@ -409,12 +410,13 @@ public void click(Integer value, int pos) {
updatePlayerCfgView();
listener.updatePlayerCfg();
listener.replay(false);
mPlayerBtn.requestFocus();
// hideBottom();
// hideBottom();
}
} catch (Exception e) {
e.printStackTrace();
}
mPlayerBtn.requestFocus();
mPlayerBtn.requestFocusFromTouch();
}

@Override
Expand Down Expand Up @@ -443,8 +445,8 @@ public boolean areContentsTheSame(@NonNull @NotNull Integer oldItem, @NonNull @N
mPlayerIJKBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
// myHandle.removeCallbacks(myRunnable);
// myHandle.postDelayed(myRunnable, myHandleSeconds);
myHandle.removeCallbacks(myRunnable);
myHandle.postDelayed(myRunnable, myHandleSeconds);
try {
String ijk = mPlayerConfig.getString("ijk");
List<IJKCode> codecs = ApiConfig.get().getIjkCodes();
Expand All @@ -467,6 +469,7 @@ public void onClick(View view) {
e.printStackTrace();
}
mPlayerIJKBtn.requestFocus();
mPlayerIJKBtn.requestFocusFromTouch();
}
});
// 增加播放页面片头片尾时间重置
Expand All @@ -491,13 +494,6 @@ public void onClick(View view) {
myHandle.removeCallbacks(myRunnable);
myHandle.postDelayed(myRunnable, myHandleSeconds);
try {
// int step = Hawk.get(HawkConfig.PLAY_TIME_STEP, 5);
// int st = mPlayerConfig.getInt("st");
// st += step;
// //片头最大跳过时间10分钟
// if (st > 60 * 10)
// st = 0;
// mPlayerConfig.put("st", st);
int current = (int) mControlWrapper.getCurrentPosition();
int duration = (int) mControlWrapper.getDuration();
if (current > duration / 2) return;
Expand All @@ -509,7 +505,6 @@ public void onClick(View view) {
}
}
});
// takagen99: Add long press to reset counter
mPlayerTimeStartBtn.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Expand All @@ -529,13 +524,6 @@ public void onClick(View view) {
myHandle.removeCallbacks(myRunnable);
myHandle.postDelayed(myRunnable, myHandleSeconds);
try {
// int step = Hawk.get(HawkConfig.PLAY_TIME_STEP, 5);
// int et = mPlayerConfig.getInt("et");
// et += step;
// //片尾最大跳过时间10分钟
// if (et > 60 * 10)
// et = 0;
// mPlayerConfig.put("et", et);
int current = (int) mControlWrapper.getCurrentPosition();
int duration = (int) mControlWrapper.getDuration();
if (current < duration / 2) return;
Expand All @@ -560,20 +548,6 @@ public boolean onLongClick(View view) {
return true;
}
});
// mPlayerTimeStepBtn.setOnClickListener(new OnClickListener() {
// @Override
// public void onClick(View view) {
// myHandle.removeCallbacks(myRunnable);
// myHandle.postDelayed(myRunnable, myHandleSeconds);
// int step = Hawk.get(HawkConfig.PLAY_TIME_STEP, 5);
// step += 5;
// if (step > 30) {
// step = 5;
// }
// Hawk.put(HawkConfig.PLAY_TIME_STEP, step);
// updatePlayerCfgView();
// }
// });
mZimuBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ protected void init() {
initView();
initViewModel();
initData();
hasKeyBoard = true;
}

/*
Expand Down Expand Up @@ -138,6 +139,13 @@ protected void onResume() {
pauseRunnable.clear();
pauseRunnable = null;
}
if (hasKeyBoard) {
tvSearch.requestFocus();
tvSearch.requestFocusFromTouch();
}else {
etSearch.requestFocus();
etSearch.requestFocusFromTouch();
}
}

private void initView() {
Expand Down Expand Up @@ -186,6 +194,7 @@ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
} catch (Throwable th) {
th.printStackTrace();
}
hasKeyBoard = false;
Bundle bundle = new Bundle();
bundle.putString("id", video.id);
bundle.putString("sourceKey", video.sourceKey);
Expand All @@ -197,6 +206,7 @@ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
@Override
public void onClick(View v) {
FastClickCheckUtil.check(v);
hasKeyBoard = true;
String wd = etSearch.getText().toString().trim();
if (!TextUtils.isEmpty(wd)) {
search(wd);
Expand Down Expand Up @@ -374,7 +384,7 @@ public String convertResponse(okhttp3.Response response) throws Throwable {
private void refreshQRCode() {
String address = ControlManager.get().getAddress(false);
tvAddress.setText(String.format("远程搜索使用手机/电脑扫描下面二维码或者直接浏览器访问地址\n%s", address));
ivQRCode.setImageBitmap(QRCodeGen.generateBitmap(address, 300, 300));
ivQRCode.setImageBitmap(QRCodeGen.generateBitmap(address + "search.html", 300, 300));
}

@Subscribe(threadMode = ThreadMode.MAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.NonNull;

import com.github.tvbox.osc.R;

import xyz.doikki.videoplayer.util.CutoutUtil;

public class BaseDialog extends Dialog {
public BaseDialog(@NonNull Context context) {
super(context, R.style.CustomDialogStyle);
Expand All @@ -19,6 +22,12 @@ public BaseDialog(Context context, int customDialogStyle) {
super(context, customDialogStyle);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
CutoutUtil.adaptCutoutAboveAndroidP(this, true);//设置刘海
super.onCreate(savedInstanceState);
}

@Override
public void show() {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface XWalkState {

public static String downUrl() {
// return String.format("https://download.01.org/crosswalk/releases/crosswalk/android/stable/23.53.589.4/%s/crosswalk-apks-23.53.589.4-%s.zip", getRuntimeAbi(), getRuntimeAbi());
return String.format("http://home.jundie.top:81/xwalk/maven2/crosswalk-apks-23.53.589.4-%s.zip", getRuntimeAbi(), getRuntimeAbi());
return String.format("http://home.jundie.top:81/xwalk/maven2/crosswalk-apks-23.53.589.4-%s.zip", getRuntimeAbi());
}

public static String saveZipFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ protected void onPlayerStateChanged(int playerState) {
mOrientationHelper.disable();
}
if (hasCutout()) {
CutoutUtil.adaptCutoutAboveAndroidP(getContext(), false);
CutoutUtil.adaptCutoutAboveAndroidP(getContext(), true);
}
break;
case VideoView.PLAYER_FULL_SCREEN:
Expand Down
16 changes: 16 additions & 0 deletions player/src/main/java/xyz/doikki/videoplayer/util/CutoutUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;
Expand Down Expand Up @@ -143,4 +144,19 @@ public static void adaptCutoutAboveAndroidP(Context context, boolean isAdapt) {
}
}


/**
* 适配刘海屏,针对Android P以上系统
*/
public static void adaptCutoutAboveAndroidP(Dialog dialog, boolean isAdapt) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
if (isAdapt) {
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
} else {
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
}
dialog.getWindow().setAttributes(lp);
}
}
}

0 comments on commit ab7429c

Please sign in to comment.