1.开机或按Home键默认Layout_video第1个广告位获取焦点,任意按钮并且进入第三方应用返回也是第1个广告位获取焦点

2.主页加号展开后返回时取消1-10随机缩小动画,焦点定位于gv_short上
This commit is contained in:
2026-03-24 14:10:21 +08:00
parent ad72e265c1
commit de66321ea8
6 changed files with 45 additions and 9 deletions

View File

@@ -61,6 +61,7 @@ import com.ik.mboxlauncher.ui.fragment.AppsFragment;
import com.ik.mboxlauncher.ui.fragment.MusicFragment;
import com.ik.mboxlauncher.ui.fragment.RecommendFragment;
import com.ik.mboxlauncher.ui.fragment.VideoFragment;
import com.ik.mboxlauncher.view.HomeMultiView;
import com.ik.mboxlauncher.view.MultiView;
import com.ik.mboxlauncher.view.CustomRecyclerView;
import com.ik.mboxlauncher.view.SplashView;
@@ -211,6 +212,9 @@ public class Launcher extends FragmentActivity implements SplashView.SplashAdLi
LogUtils.loge("open app custom view");
if(selectIndex == 0){
gotoAction(AppsFragment.ACTION);
handler.postDelayed(()->{
layout_video.requestFocus();
},120);
} else {
if (!isShowCustomApp()) {
showCustomApps();
@@ -220,6 +224,9 @@ public class Launcher extends FragmentActivity implements SplashView.SplashAdLi
}else {
LogUtils.loge("open app package name is "+shortAppInfoBean.getPackageName());
IntentUtil.startApp(Launcher.this,shortAppInfoBean.getPackageName(),getResources().getString(R.string.app_not_exist));
handler.postDelayed(()->{
layout_video.requestFocus();
},120);
}
}
});
@@ -268,7 +275,6 @@ public class Launcher extends FragmentActivity implements SplashView.SplashAdLi
gv_shortcut.setAdapter(mShortAppInfoAdapter);
gv_shortcut.setCanFocusOutHorizontal(false);
gv_shortcut.setCanFocusOutVertical(true);
GridLayoutManager customLayoutManager = new GridLayoutManager(Launcher.this,9);
grid_coustom_apps.setLayoutManager(customLayoutManager);
grid_coustom_apps.setAdapter(mCustomAppAdapter);
@@ -323,6 +329,9 @@ public class Launcher extends FragmentActivity implements SplashView.SplashAdLi
// }
mHomeHeight = findViewById(R.id.layout_homepage).getHeight();
if(!isShowCustomApp()){
layout_video.requestFocus();
}
}
@Override
@@ -915,6 +924,7 @@ public boolean onGenericMotionEvent(MotionEvent event) {
grid_coustom_apps.disScrollFocus();
loadShortAppList();
coustom_view.clearFocus();
disableMultiViewFocusAnimation(true);
}
@Override
@@ -922,7 +932,7 @@ public boolean onGenericMotionEvent(MotionEvent event) {
LogUtils.loge("dismissCustomApp onAnimationEnd()");
coustom_view.setVisibility(View.GONE);
gv_shortcut.requestFocus();
disableMultiViewFocusAnimation(false);
}
@Override
@@ -988,7 +998,17 @@ public boolean onGenericMotionEvent(MotionEvent event) {
ADSWindowManager.getInstance().bindSourceData(multiViewArrayList,adsDatas);
}
/**
* 批量设置 HomeMultiView 的焦点动画开关
* @param disable true-禁用焦点动画false-启用焦点动画
*/
private void disableMultiViewFocusAnimation(boolean disable) {
for (MultiView multiView : multiViewArray) {
if (multiView != null && multiView instanceof HomeMultiView) {
((HomeMultiView) multiView).setFocusAnimationDisable(disable);
}
}
}
@Override
public void popBackStackFragment() {

View File

@@ -68,7 +68,7 @@ public class HomeMultiView extends MultiView {
private View mMultiInsideLayout;
private int imageResId;
private boolean mFocusAnimationDisable;
public HomeMultiView(@NonNull Context context) {
super(context);
}
@@ -169,7 +169,13 @@ public class HomeMultiView extends MultiView {
}
}
/**
* 设置焦点动画是不可用
* @param disable true-启用false-禁用
*/
public void setFocusAnimationDisable(boolean disable) {
this.mFocusAnimationDisable = disable;
}
@Override
public void onImageRestart(String uri){
img_view.setVisibility(VISIBLE);
@@ -300,6 +306,7 @@ public class HomeMultiView extends MultiView {
setBackgroundResource(R.drawable.app_item_border);
setTranslationZ(10);
setElevation(10);
if(mFocusAnimationDisable) return;
ScaleAnimation anim = new ScaleAnimation(1f, 1.1f, 1f, 1.1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setZAdjustment(Animation.ZORDER_TOP);
anim.setDuration(animDuration);
@@ -310,6 +317,7 @@ public class HomeMultiView extends MultiView {
setBackgroundResource(R.color.transparent_background);
setTranslationZ(0);
setElevation(0);
if(mFocusAnimationDisable) return;
ScaleAnimation anim = new ScaleAnimation(1.1f, 1f, 1.1f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
anim.setZAdjustment(Animation.ZORDER_TOP);
anim.setDuration(animDuration);

View File

@@ -19,7 +19,9 @@
app:multiViewImage="@drawable/img_video"
app:multiViewTitle="@string/str_video"
android:nextFocusRight="@id/layout_youtube"
android:descendantFocusability="beforeDescendants" />
android:descendantFocusability="beforeDescendants" >
<requestFocus/>
</com.ik.mboxlauncher.view.HomeMultiView>
<com.ik.mboxlauncher.view.HomeMultiView

View File

@@ -19,7 +19,9 @@
app:multiViewImage="@drawable/img_video"
app:multiViewTitle="@string/str_video"
android:nextFocusRight="@id/layout_youtube"
android:descendantFocusability="beforeDescendants" />
android:descendantFocusability="beforeDescendants" >
<requestFocus/>
</com.ik.mboxlauncher.view.HomeMultiView>
<com.ik.mboxlauncher.view.HomeMultiView

View File

@@ -19,7 +19,9 @@
app:multiViewImage="@drawable/img_video"
app:multiViewTitle="@string/str_video"
android:nextFocusRight="@id/layout_youtube"
android:descendantFocusability="beforeDescendants" />
android:descendantFocusability="beforeDescendants" >
<requestFocus />
</com.ik.mboxlauncher.view.HomeMultiView>
<com.ik.mboxlauncher.view.HomeMultiView

View File

@@ -18,7 +18,9 @@
app:multiViewImage="@drawable/img_video"
app:multiViewTitle="@string/str_video"
android:nextFocusRight="@id/layout_youtube"
android:descendantFocusability="beforeDescendants" />
android:descendantFocusability="beforeDescendants" >
<requestFocus/>
</com.ik.mboxlauncher.view.HomeMultiView>
<com.ik.mboxlauncher.view.HomeMultiView