From 90b5795b04fb55876c0e4466a6029aa3443a6c7f Mon Sep 17 00:00:00 2001 From: FongMi Date: Mon, 13 Mar 2023 17:08:29 +0800 Subject: [PATCH] [mobile] optimize UX --- .../com/fongmi/android/tv/utils/Utils.java | 6 +- .../tv/ui/activity/DetailActivity.java | 14 +- .../android/tv/ui/activity/MainActivity.java | 3 - app/src/mobile/res/layout/activity_detail.xml | 341 +++++++++--------- app/src/mobile/res/layout/activity_main.xml | 2 +- app/src/mobile/res/layout/adapter_search.xml | 2 +- app/src/mobile/res/layout/fragment_home.xml | 12 +- 7 files changed, 195 insertions(+), 185 deletions(-) diff --git a/app/src/main/java/com/fongmi/android/tv/utils/Utils.java b/app/src/main/java/com/fongmi/android/tv/utils/Utils.java index 9cf34e6e9..e26ddb587 100644 --- a/app/src/main/java/com/fongmi/android/tv/utils/Utils.java +++ b/app/src/main/java/com/fongmi/android/tv/utils/Utils.java @@ -6,7 +6,6 @@ import android.app.PictureInPictureParams; import android.content.ClipboardManager; import android.content.Context; import android.content.pm.PackageManager; -import android.graphics.Rect; import android.net.Uri; import android.os.Build; import android.os.IBinder; @@ -109,14 +108,11 @@ public class Utils { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && App.get().getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE); } - public static void enterPIP(Activity activity, Rect sourceRectHint, Rational rational) { + public static void enterPIP(Activity activity, Rational rational) { try { if (!hasPIP() || activity.isInPictureInPictureMode()) return; PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder(); builder.setAspectRatio(rational).build(); - builder.setSourceRectHint(sourceRectHint); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) builder.setAutoEnterEnabled(true); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) builder.setSeamlessResizeEnabled(true); activity.enterPictureInPictureMode(builder.build()); } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java index e569683f0..6806b2389 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/DetailActivity.java @@ -5,7 +5,6 @@ import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; -import android.graphics.Rect; import android.os.Bundle; import android.text.Html; import android.util.Rational; @@ -180,6 +179,7 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT); + mBinding.swipeLayout.setRefreshing(true); getIntent().putExtras(intent); setOrient(); getDetail(); @@ -189,6 +189,7 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis protected void initView(Bundle savedInstanceState) { mKeyDown = CustomKeyDownVod.create(this, mBinding.video); mFrameParams = mBinding.video.getLayoutParams(); + mBinding.progressLayout.showProgress(); mPlayers = new Players().init(); mR1 = this::hideControl; mR2 = this::setTraffic; @@ -204,7 +205,6 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis @Override @SuppressLint("ClickableViewAccessibility") protected void initEvent() { - mBinding.control.seek.setListener(mPlayers); mBinding.name.setOnClickListener(view -> onName()); mBinding.content.setOnClickListener(view -> onContent()); mBinding.reverse.setOnClickListener(view -> onReverse()); @@ -231,6 +231,8 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis mBinding.control.action.opening.setOnLongClickListener(view -> onOpeningReset()); mBinding.video.setOnTouchListener((view, event) -> mKeyDown.onTouchEvent(event)); mBinding.control.action.getRoot().setOnTouchListener(this::onActionTouch); + mBinding.swipeLayout.setOnRefreshListener(this::getDetail); + mBinding.control.seek.setListener(mPlayers); } private void setRecyclerView() { @@ -283,19 +285,20 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis mPlayers.start(result, isUseParse(), timeout); }); mViewModel.result.observe(this, result -> { + mBinding.swipeLayout.setRefreshing(false); if (result.getList().isEmpty()) setEmpty(); else setDetail(result.getList().get(0)); }); } private void getDetail() { - mBinding.progressLayout.showProgress(); mViewModel.detailContent(getKey(), getId()); } private void getDetail(Vod item) { getIntent().putExtra("key", item.getSiteKey()); getIntent().putExtra("id", item.getVodId()); + mBinding.swipeLayout.setRefreshing(true); mBinding.scroll.scrollTo(0, 0); Clock.get().setCallback(null); mPlayers.stop(); @@ -1046,9 +1049,8 @@ public class DetailActivity extends BaseActivity implements CustomKeyDownVod.Lis @Override protected void onUserLeaveHint() { super.onUserLeaveHint(); - Rect sourceRectHint = new Rect(); - mBinding.video.getGlobalVisibleRect(sourceRectHint); - Utils.enterPIP(this, sourceRectHint, getScale() == 2 ? new Rational(4, 3) : new Rational(16, 9)); + Utils.enterPIP(this, getScale() == 2 ? new Rational(4, 3) : new Rational(16, 9)); + if (isLock()) onLock(); } @Override diff --git a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/MainActivity.java b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/MainActivity.java index b98767ecf..08ffde5ec 100644 --- a/app/src/mobile/java/com/fongmi/android/tv/ui/activity/MainActivity.java +++ b/app/src/mobile/java/com/fongmi/android/tv/ui/activity/MainActivity.java @@ -45,7 +45,6 @@ public class MainActivity extends BaseActivity implements NavigationBarView.OnIt @Override protected void initView(Bundle savedInstanceState) { initFragment(savedInstanceState); - Notify.progress(this); Updater.get().start(); Server.get().start(); initConfig(); @@ -83,13 +82,11 @@ public class MainActivity extends BaseActivity implements NavigationBarView.OnIt public void success() { checkAction(getIntent()); RefreshEvent.video(); - Notify.dismiss(); } @Override public void error(int resId) { Notify.show(resId); - Notify.dismiss(); } }; } diff --git a/app/src/mobile/res/layout/activity_detail.xml b/app/src/mobile/res/layout/activity_detail.xml index edd535d9f..508967249 100644 --- a/app/src/mobile/res/layout/activity_detail.xml +++ b/app/src/mobile/res/layout/activity_detail.xml @@ -57,200 +57,207 @@ android:layout_height="4dp" android:layout_below="@+id/video" /> - - + android:layout_height="match_parent"> - - - + android:fillViewport="true"> - - - + - + - + - + - + - + - + - + - + - + - + - + - + + + - - - + + + + + + + + \ No newline at end of file diff --git a/app/src/mobile/res/layout/activity_main.xml b/app/src/mobile/res/layout/activity_main.xml index 769dd911f..df84cf336 100644 --- a/app/src/mobile/res/layout/activity_main.xml +++ b/app/src/mobile/res/layout/activity_main.xml @@ -16,7 +16,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" - android:background="@color/white_80" + android:background="@color/white_70" app:elevation="0dp" app:menu="@menu/menu_nav" /> diff --git a/app/src/mobile/res/layout/adapter_search.xml b/app/src/mobile/res/layout/adapter_search.xml index 5a550d12e..a0eab286f 100644 --- a/app/src/mobile/res/layout/adapter_search.xml +++ b/app/src/mobile/res/layout/adapter_search.xml @@ -1,7 +1,7 @@ + android:paddingStart="8dp" + android:paddingTop="0dp" + android:paddingEnd="8dp" + android:paddingBottom="4dp" /> + android:paddingStart="8dp" + android:paddingTop="0dp" + android:paddingEnd="8dp" + android:paddingBottom="8dp" />