feat: 优化播放页面电池显示和搜索页面布局
✨ 新增功能 - 播放页面添加电池电量显示功能 - 充电时显示闪电图标 - 时间、闪电图标、电量百分比分离显示 🎨 界面优化 - 优化搜索页面左侧视频源列表间距和字体大小 - 改进布局紧凑性,提升视觉体验 🐛 问题修复 - 修复全屏播放模式下电池百分比无法显示的问题 - 修复普通布局缺少电量显示控件的问题 🔧 其他改进 - 删除隐私协议页面顶部应用图标 - 优化通知权限请求时机(改为用户同意隐私协议后请求)
This commit is contained in:
@@ -126,7 +126,6 @@ public class App extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Notify.createChannel();
|
||||
Logger.addLogAdapter(getLogAdapter());
|
||||
OkHttp.get().setProxy(Setting.getProxy());
|
||||
OkHttp.get().setDoh(Doh.objectFrom(Setting.getDoh()));
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M13,2L3,14h8l-1,8l10,-12h-8l1,-8z"/>
|
||||
</vector>
|
||||
|
||||
@@ -15,13 +15,6 @@
|
||||
android:orientation="vertical"
|
||||
android:padding="24dp">
|
||||
|
||||
<!-- 应用图标 -->
|
||||
<ImageView
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:src="@mipmap/ic_launcher"
|
||||
android:contentDescription="@string/app_name" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -72,6 +72,9 @@ public class HomeActivity extends BaseActivity implements NavigationBarView.OnIt
|
||||
return;
|
||||
}
|
||||
|
||||
// 确保通知渠道已创建(用户已同意协议的情况)
|
||||
com.fongmi.android.tv.utils.Notify.createChannel();
|
||||
|
||||
orientation = getResources().getConfiguration().orientation;
|
||||
Updater.create().release().start(this);
|
||||
initFragment(savedInstanceState);
|
||||
|
||||
@@ -42,6 +42,9 @@ public class PrivacyAgreementActivity extends BaseActivity {
|
||||
// 用户同意协议
|
||||
Setting.setPrivacyAgreed(true);
|
||||
|
||||
// 创建通知渠道(此时才请求通知权限)
|
||||
com.fongmi.android.tv.utils.Notify.createChannel();
|
||||
|
||||
// 跳转到主界面,清除任务栈避免用户通过任务管理器回到协议页面
|
||||
Intent intent = new Intent(this, HomeActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
|
||||
@@ -163,6 +163,7 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
|
||||
private Runnable mTimeUpdateRunnable;
|
||||
private BroadcastReceiver mBatteryReceiver;
|
||||
private int mBatteryLevel = -1;
|
||||
private boolean mIsCharging = false;
|
||||
|
||||
public static void push(FragmentActivity activity, String text) {
|
||||
if (FileChooser.isValid(activity, Uri.parse(text))) file(activity, FileChooser.getPathFromUri(activity, Uri.parse(text)));
|
||||
@@ -328,8 +329,12 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
|
||||
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
|
||||
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
|
||||
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
|
||||
if (level != -1 && scale != -1) {
|
||||
mBatteryLevel = (int) ((level / (float) scale) * 100);
|
||||
mIsCharging = (status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||
status == BatteryManager.BATTERY_STATUS_FULL);
|
||||
updateTimeBattery();
|
||||
}
|
||||
}
|
||||
@@ -346,18 +351,41 @@ public class VideoActivity extends BaseActivity implements Clock.Callback, Custo
|
||||
}
|
||||
|
||||
private void updateTimeBattery() {
|
||||
TextView timeBattery = mBinding.getRoot().findViewById(R.id.time_battery);
|
||||
if (timeBattery == null) return;
|
||||
TextView timeBattery = findViewById(R.id.time_battery);
|
||||
TextView batteryText = findViewById(R.id.battery_icon);
|
||||
android.widget.ImageView chargingIndicator = findViewById(R.id.charging_indicator);
|
||||
|
||||
// 只在横屏模式下显示
|
||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
String time = DateFormat.getTimeFormat(this).format(System.currentTimeMillis());
|
||||
String battery = mBatteryLevel >= 0 ? mBatteryLevel + "%" : "";
|
||||
String text = time + (battery.isEmpty() ? "" : " | " + battery);
|
||||
timeBattery.setText(text);
|
||||
timeBattery.setVisibility(View.VISIBLE);
|
||||
// 只在全屏模式下显示
|
||||
if (isFullscreen()) {
|
||||
// 更新时间
|
||||
if (timeBattery != null) {
|
||||
String time = DateFormat.getTimeFormat(this).format(System.currentTimeMillis());
|
||||
timeBattery.setText(time);
|
||||
timeBattery.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
// 更新充电图标
|
||||
if (chargingIndicator != null) {
|
||||
chargingIndicator.setVisibility(mIsCharging && mBatteryLevel >= 0 ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
// 更新电池百分比文字
|
||||
if (batteryText != null && mBatteryLevel >= 0) {
|
||||
batteryText.setText(mBatteryLevel + "%");
|
||||
batteryText.setVisibility(View.VISIBLE);
|
||||
} else if (batteryText != null) {
|
||||
batteryText.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
timeBattery.setVisibility(View.GONE);
|
||||
if (timeBattery != null) {
|
||||
timeBattery.setVisibility(View.GONE);
|
||||
}
|
||||
if (batteryText != null) {
|
||||
batteryText.setVisibility(View.GONE);
|
||||
}
|
||||
if (chargingIndicator != null) {
|
||||
chargingIndicator.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,30 @@
|
||||
android:paddingEnd="8dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
tools:text="21:30 | 85%" />
|
||||
tools:text="21:30" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/charging_indicator"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:src="@drawable/ic_charging_bolt"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/battery_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingEnd="8dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
tools:text="85%"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cast"
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/shape_item"
|
||||
android:gravity="center"
|
||||
android:padding="8dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/text"
|
||||
android:textSize="14sp"
|
||||
android:textSize="12sp"
|
||||
tools:text="泥巴" />
|
||||
|
||||
@@ -56,8 +56,30 @@
|
||||
android:paddingEnd="8dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="16sp"
|
||||
tools:text="21:30" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/charging_indicator"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:src="@drawable/ic_charging_bolt"
|
||||
android:visibility="gone"
|
||||
tools:text="21:30 | 85%" />
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/battery_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingEnd="8dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp"
|
||||
android:visibility="gone"
|
||||
tools:text="85%"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cast"
|
||||
|
||||
Reference in New Issue
Block a user