2025-12-18 17:33:36 +08:00
|
|
|
|
package com.example.livestreaming;
|
|
|
|
|
|
|
2025-12-23 12:39:14 +08:00
|
|
|
|
import android.app.AlertDialog;
|
2025-12-18 17:33:36 +08:00
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
import android.content.Intent;
|
2025-12-23 12:39:14 +08:00
|
|
|
|
import android.content.pm.PackageInfo;
|
|
|
|
|
|
import android.content.pm.PackageManager;
|
2025-12-18 17:33:36 +08:00
|
|
|
|
import android.os.Bundle;
|
2025-12-22 19:38:44 +08:00
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
import android.widget.EditText;
|
2025-12-18 17:33:36 +08:00
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
2025-12-22 19:38:44 +08:00
|
|
|
|
import androidx.appcompat.app.AlertDialog;
|
2025-12-18 17:33:36 +08:00
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
|
|
|
|
|
|
|
|
import com.example.livestreaming.databinding.ActivitySettingsPageBinding;
|
2025-12-22 19:38:44 +08:00
|
|
|
|
import com.example.livestreaming.net.ApiClient;
|
|
|
|
|
|
import com.example.livestreaming.net.StreamConfig;
|
2025-12-18 17:33:36 +08:00
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class SettingsPageActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
|
|
public static final String EXTRA_PAGE = "extra_page";
|
|
|
|
|
|
|
|
|
|
|
|
public static final String PAGE_ACCOUNT_SECURITY = "account_security";
|
|
|
|
|
|
public static final String PAGE_PRIVACY = "privacy";
|
|
|
|
|
|
public static final String PAGE_NOTIFICATIONS = "notifications";
|
|
|
|
|
|
public static final String PAGE_CLEAR_CACHE = "clear_cache";
|
|
|
|
|
|
public static final String PAGE_HELP = "help";
|
|
|
|
|
|
public static final String PAGE_ABOUT = "about";
|
2025-12-22 19:38:44 +08:00
|
|
|
|
public static final String PAGE_SERVER = "server";
|
2025-12-18 17:33:36 +08:00
|
|
|
|
|
|
|
|
|
|
private ActivitySettingsPageBinding binding;
|
2025-12-23 12:39:14 +08:00
|
|
|
|
private MoreAdapter adapter;
|
2025-12-22 19:38:44 +08:00
|
|
|
|
private String page;
|
2025-12-18 17:33:36 +08:00
|
|
|
|
|
|
|
|
|
|
public static void start(Context context, String page) {
|
|
|
|
|
|
Intent intent = new Intent(context, SettingsPageActivity.class);
|
|
|
|
|
|
intent.putExtra(EXTRA_PAGE, page);
|
|
|
|
|
|
context.startActivity(intent);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
binding = ActivitySettingsPageBinding.inflate(getLayoutInflater());
|
|
|
|
|
|
setContentView(binding.getRoot());
|
|
|
|
|
|
|
|
|
|
|
|
binding.backButton.setOnClickListener(v -> finish());
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
page = getIntent() != null ? getIntent().getStringExtra(EXTRA_PAGE) : null;
|
2025-12-18 17:33:36 +08:00
|
|
|
|
if (page == null) page = "";
|
|
|
|
|
|
|
2025-12-23 12:39:14 +08:00
|
|
|
|
String title = resolveTitle(currentPage);
|
2025-12-18 17:33:36 +08:00
|
|
|
|
binding.titleText.setText(title);
|
|
|
|
|
|
|
2025-12-23 12:39:14 +08:00
|
|
|
|
adapter = new MoreAdapter(item -> {
|
2025-12-18 17:33:36 +08:00
|
|
|
|
if (item == null) return;
|
|
|
|
|
|
if (item.getType() != MoreItem.Type.ROW) return;
|
|
|
|
|
|
String t = item.getTitle() != null ? item.getTitle() : "";
|
2025-12-22 19:38:44 +08:00
|
|
|
|
|
|
|
|
|
|
if ("服务器设置".equals(t)) {
|
|
|
|
|
|
SettingsPageActivity.start(this, PAGE_SERVER);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ("API服务器".equals(t)) {
|
|
|
|
|
|
showApiBaseUrlDialog();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ("恢复默认API服务器".equals(t)) {
|
|
|
|
|
|
ApiClient.clearCustomBaseUrl(getApplicationContext());
|
|
|
|
|
|
ApiClient.getService(getApplicationContext());
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
Toast.makeText(this, "已恢复默认API服务器", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ("直播流服务器".equals(t)) {
|
|
|
|
|
|
showStreamHostDialog();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ("清除直播流覆写".equals(t)) {
|
|
|
|
|
|
StreamConfig.clearStreamHostOverride(getApplicationContext());
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
Toast.makeText(this, "已清除直播流覆写", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ("返回".equals(t)) {
|
|
|
|
|
|
finish();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-18 17:33:36 +08:00
|
|
|
|
Toast.makeText(this, "点击:" + t, Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
binding.recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
|
|
|
|
|
binding.recyclerView.setAdapter(adapter);
|
|
|
|
|
|
|
2025-12-23 12:39:14 +08:00
|
|
|
|
refreshItems();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handleItemClick(MoreItem item) {
|
|
|
|
|
|
String title = item.getTitle() != null ? item.getTitle() : "";
|
|
|
|
|
|
|
|
|
|
|
|
switch (currentPage) {
|
|
|
|
|
|
case PAGE_ACCOUNT_SECURITY:
|
|
|
|
|
|
handleAccountSecurityClick(title);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case PAGE_PRIVACY:
|
|
|
|
|
|
handlePrivacyClick(title);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case PAGE_NOTIFICATIONS:
|
|
|
|
|
|
handleNotificationsClick(title);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case PAGE_CLEAR_CACHE:
|
|
|
|
|
|
handleClearCacheClick(title);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case PAGE_HELP:
|
|
|
|
|
|
handleHelpClick(title);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case PAGE_ABOUT:
|
|
|
|
|
|
handleAboutClick(title);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handleAccountSecurityClick(String title) {
|
|
|
|
|
|
if ("修改密码".equals(title)) {
|
|
|
|
|
|
showChangePasswordDialog();
|
|
|
|
|
|
} else if ("绑定手机号".equals(title)) {
|
|
|
|
|
|
showBindPhoneDialog();
|
|
|
|
|
|
} else if ("登录设备管理".equals(title)) {
|
|
|
|
|
|
showDeviceManagementDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handlePrivacyClick(String title) {
|
|
|
|
|
|
if ("黑名单".equals(title)) {
|
|
|
|
|
|
showBlacklistDialog();
|
|
|
|
|
|
} else if ("权限管理".equals(title)) {
|
|
|
|
|
|
showPermissionManagementDialog();
|
|
|
|
|
|
} else if ("隐私政策".equals(title)) {
|
|
|
|
|
|
showPrivacyPolicyDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handleNotificationsClick(String title) {
|
|
|
|
|
|
if ("系统通知".equals(title) || "免打扰".equals(title)) {
|
|
|
|
|
|
NotificationSettingsActivity.start(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handleClearCacheClick(String title) {
|
|
|
|
|
|
if ("缓存大小".equals(title)) {
|
|
|
|
|
|
showClearAllCacheDialog();
|
|
|
|
|
|
} else if ("图片缓存".equals(title)) {
|
|
|
|
|
|
showClearImageCacheDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handleHelpClick(String title) {
|
|
|
|
|
|
if ("常见问题".equals(title)) {
|
|
|
|
|
|
showFAQDialog();
|
|
|
|
|
|
} else if ("意见反馈".equals(title)) {
|
|
|
|
|
|
showFeedbackDialog();
|
|
|
|
|
|
} else if ("联系客服".equals(title)) {
|
|
|
|
|
|
showCustomerServiceDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handleAboutClick(String title) {
|
|
|
|
|
|
if ("版本".equals(title)) {
|
|
|
|
|
|
// 版本信息已在subtitle中显示,点击可显示详细信息
|
|
|
|
|
|
showVersionInfoDialog();
|
|
|
|
|
|
} else if ("用户协议".equals(title)) {
|
|
|
|
|
|
showUserAgreementDialog();
|
|
|
|
|
|
} else if ("隐私政策".equals(title)) {
|
|
|
|
|
|
showPrivacyPolicyDialog();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void refreshItems() {
|
|
|
|
|
|
if (PAGE_CLEAR_CACHE.equals(currentPage)) {
|
|
|
|
|
|
// 异步加载缓存大小
|
|
|
|
|
|
updateCacheSize();
|
|
|
|
|
|
} else if (PAGE_ABOUT.equals(currentPage)) {
|
|
|
|
|
|
// 更新版本信息
|
|
|
|
|
|
updateVersionInfo();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
adapter.submitList(buildItems(currentPage));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void updateCacheSize() {
|
|
|
|
|
|
new Thread(() -> {
|
|
|
|
|
|
long cacheSize = CacheManager.getCacheSize(this);
|
|
|
|
|
|
String sizeText = CacheManager.formatCacheSize(this, cacheSize);
|
|
|
|
|
|
|
|
|
|
|
|
runOnUiThread(() -> {
|
|
|
|
|
|
List<MoreItem> items = new ArrayList<>();
|
|
|
|
|
|
items.add(MoreItem.section("存储"));
|
|
|
|
|
|
items.add(MoreItem.row("缓存大小", sizeText, R.drawable.ic_grid_24));
|
|
|
|
|
|
items.add(MoreItem.row("图片缓存", "清理封面/头像缓存", R.drawable.ic_palette_24));
|
|
|
|
|
|
adapter.submitList(items);
|
|
|
|
|
|
});
|
|
|
|
|
|
}).start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void updateVersionInfo() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
|
|
|
|
|
String versionName = packageInfo.versionName;
|
|
|
|
|
|
int versionCode = packageInfo.versionCode;
|
|
|
|
|
|
String versionText = "Live Streaming " + versionName + " (Build " + versionCode + ")";
|
|
|
|
|
|
|
|
|
|
|
|
List<MoreItem> items = new ArrayList<>();
|
|
|
|
|
|
items.add(MoreItem.section("应用信息"));
|
|
|
|
|
|
items.add(MoreItem.row("版本", versionText, R.drawable.ic_menu_24));
|
|
|
|
|
|
items.add(MoreItem.row("用户协议", "服务条款与规则", R.drawable.ic_menu_24));
|
|
|
|
|
|
items.add(MoreItem.row("隐私政策", "隐私保护说明", R.drawable.ic_menu_24));
|
|
|
|
|
|
adapter.submitList(items);
|
|
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
|
|
|
|
List<MoreItem> items = new ArrayList<>();
|
|
|
|
|
|
items.add(MoreItem.section("应用信息"));
|
|
|
|
|
|
items.add(MoreItem.row("版本", "Live Streaming 1.0", R.drawable.ic_menu_24));
|
|
|
|
|
|
items.add(MoreItem.row("用户协议", "服务条款与规则", R.drawable.ic_menu_24));
|
|
|
|
|
|
items.add(MoreItem.row("隐私政策", "隐私保护说明", R.drawable.ic_menu_24));
|
|
|
|
|
|
adapter.submitList(items);
|
|
|
|
|
|
}
|
2025-12-18 17:33:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String resolveTitle(String page) {
|
|
|
|
|
|
switch (page) {
|
|
|
|
|
|
case PAGE_ACCOUNT_SECURITY:
|
|
|
|
|
|
return "账号与安全";
|
|
|
|
|
|
case PAGE_PRIVACY:
|
|
|
|
|
|
return "隐私";
|
|
|
|
|
|
case PAGE_NOTIFICATIONS:
|
|
|
|
|
|
return "通知";
|
|
|
|
|
|
case PAGE_CLEAR_CACHE:
|
|
|
|
|
|
return "清理缓存";
|
|
|
|
|
|
case PAGE_HELP:
|
|
|
|
|
|
return "帮助与反馈";
|
|
|
|
|
|
case PAGE_ABOUT:
|
|
|
|
|
|
return "关于";
|
2025-12-22 19:38:44 +08:00
|
|
|
|
case PAGE_SERVER:
|
|
|
|
|
|
return "服务器设置";
|
2025-12-18 17:33:36 +08:00
|
|
|
|
default:
|
|
|
|
|
|
return "设置";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private List<MoreItem> buildItems(String page) {
|
|
|
|
|
|
List<MoreItem> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
if (PAGE_ACCOUNT_SECURITY.equals(page)) {
|
|
|
|
|
|
list.add(MoreItem.section("登录与账号"));
|
|
|
|
|
|
list.add(MoreItem.row("修改密码", "设置登录密码", R.drawable.ic_person_24));
|
|
|
|
|
|
list.add(MoreItem.row("绑定手机号", "用于登录与找回", R.drawable.ic_people_24));
|
|
|
|
|
|
list.add(MoreItem.row("登录设备管理", "查看并管理已登录设备", R.drawable.ic_grid_24));
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (PAGE_PRIVACY.equals(page)) {
|
|
|
|
|
|
list.add(MoreItem.section("权限与安全"));
|
|
|
|
|
|
list.add(MoreItem.row("黑名单", "管理你屏蔽的用户", R.drawable.ic_people_24));
|
|
|
|
|
|
list.add(MoreItem.row("权限管理", "相机、麦克风、定位等", R.drawable.ic_mic_24));
|
|
|
|
|
|
list.add(MoreItem.row("隐私政策", "了解我们如何保护你的数据", R.drawable.ic_globe_24));
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (PAGE_NOTIFICATIONS.equals(page)) {
|
|
|
|
|
|
list.add(MoreItem.section("消息提醒"));
|
|
|
|
|
|
list.add(MoreItem.row("系统通知", "关注、评论、私信提醒", R.drawable.ic_notifications_24));
|
|
|
|
|
|
list.add(MoreItem.row("免打扰", "设置勿扰时段", R.drawable.ic_notifications_24));
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (PAGE_CLEAR_CACHE.equals(page)) {
|
2025-12-23 12:39:14 +08:00
|
|
|
|
// 缓存大小将在updateCacheSize中异步更新
|
|
|
|
|
|
return new ArrayList<>();
|
2025-12-18 17:33:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (PAGE_HELP.equals(page)) {
|
|
|
|
|
|
list.add(MoreItem.section("帮助"));
|
|
|
|
|
|
list.add(MoreItem.row("常见问题", "问题解答与使用指南", R.drawable.ic_chat_24));
|
|
|
|
|
|
list.add(MoreItem.row("意见反馈", "提交你的建议与问题", R.drawable.ic_chat_24));
|
2025-12-23 12:39:14 +08:00
|
|
|
|
list.add(MoreItem.row("联系客服", "在线客服", R.drawable.ic_chat_24));
|
2025-12-18 17:33:36 +08:00
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (PAGE_ABOUT.equals(page)) {
|
2025-12-23 12:39:14 +08:00
|
|
|
|
// 版本信息将在updateVersionInfo中更新
|
|
|
|
|
|
return new ArrayList<>();
|
2025-12-18 17:33:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
if (PAGE_SERVER.equals(page)) {
|
|
|
|
|
|
String apiCurrent = ApiClient.getCurrentBaseUrl(getApplicationContext());
|
|
|
|
|
|
String apiMode = ApiClient.isUsingCustomBaseUrl(getApplicationContext()) ? "自定义" : "自动";
|
|
|
|
|
|
String apiSub = (TextUtils.isEmpty(apiCurrent) ? "" : apiCurrent) + (TextUtils.isEmpty(apiMode) ? "" : ("(" + apiMode + ")"));
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
String streamHost = StreamConfig.getStreamHostOverride(getApplicationContext());
|
|
|
|
|
|
String streamSub = TextUtils.isEmpty(streamHost) ? "未覆写(使用服务端返回)" : ("当前覆写:" + streamHost);
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
list.add(MoreItem.section("API"));
|
|
|
|
|
|
list.add(MoreItem.row("API服务器", apiSub, R.drawable.ic_globe_24));
|
|
|
|
|
|
list.add(MoreItem.row("恢复默认API服务器", ApiClient.getDefaultAutoBaseUrl(getApplicationContext()), R.drawable.ic_globe_24));
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
list.add(MoreItem.section("直播流"));
|
|
|
|
|
|
list.add(MoreItem.row("直播流服务器", streamSub, R.drawable.ic_globe_24));
|
|
|
|
|
|
list.add(MoreItem.row("清除直播流覆写", "恢复为服务端返回的地址", R.drawable.ic_globe_24));
|
|
|
|
|
|
return list;
|
2025-12-23 12:39:14 +08:00
|
|
|
|
}
|
2025-12-22 19:38:44 +08:00
|
|
|
|
|
|
|
|
|
|
list.add(MoreItem.section("通用"));
|
|
|
|
|
|
list.add(MoreItem.row("服务器设置", "切换API与直播流地址", R.drawable.ic_globe_24));
|
|
|
|
|
|
list.add(MoreItem.row("关于", "版本信息、协议", R.drawable.ic_menu_24));
|
2025-12-18 17:33:36 +08:00
|
|
|
|
return list;
|
2025-12-23 12:39:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
private void refresh() {
|
|
|
|
|
|
if (adapter == null) return;
|
|
|
|
|
|
adapter.submitList(buildItems(page));
|
2025-12-23 12:39:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
private void showApiBaseUrlDialog() {
|
|
|
|
|
|
String current = ApiClient.getCurrentBaseUrl(getApplicationContext());
|
|
|
|
|
|
String[] history = ApiClient.getBaseUrlHistory(getApplicationContext());
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
List<String> options = new ArrayList<>();
|
|
|
|
|
|
options.add("输入自定义");
|
|
|
|
|
|
if (history != null && history.length > 0) options.add("从历史选择");
|
|
|
|
|
|
options.add("恢复默认(自动)");
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
|
|
|
|
|
new AlertDialog.Builder(this)
|
2025-12-22 19:38:44 +08:00
|
|
|
|
.setTitle("API服务器\n当前:" + (current != null ? current : ""))
|
|
|
|
|
|
.setItems(options.toArray(new String[0]), (d, which) -> {
|
|
|
|
|
|
String sel = options.get(which);
|
|
|
|
|
|
if ("输入自定义".equals(sel)) {
|
|
|
|
|
|
showApiBaseUrlInput();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if ("从历史选择".equals(sel)) {
|
|
|
|
|
|
showApiBaseUrlHistory();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if ("恢复默认(自动)".equals(sel)) {
|
|
|
|
|
|
ApiClient.clearCustomBaseUrl(getApplicationContext());
|
|
|
|
|
|
ApiClient.getService(getApplicationContext());
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
}
|
2025-12-23 12:39:14 +08:00
|
|
|
|
})
|
|
|
|
|
|
.setNegativeButton("取消", null)
|
|
|
|
|
|
.show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
private void showApiBaseUrlInput() {
|
|
|
|
|
|
EditText input = new EditText(this);
|
|
|
|
|
|
input.setHint("例如:http://192.168.1.164:8081/");
|
|
|
|
|
|
String current = ApiClient.getCurrentBaseUrl(getApplicationContext());
|
|
|
|
|
|
if (!TextUtils.isEmpty(current)) input.setText(current);
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
|
|
|
|
|
new AlertDialog.Builder(this)
|
2025-12-22 19:38:44 +08:00
|
|
|
|
.setTitle("输入API BaseUrl")
|
|
|
|
|
|
.setView(input)
|
2025-12-23 12:39:14 +08:00
|
|
|
|
.setNegativeButton("取消", null)
|
2025-12-22 19:38:44 +08:00
|
|
|
|
.setPositiveButton("保存", (d, w) -> {
|
|
|
|
|
|
String v = input.getText() != null ? input.getText().toString().trim() : "";
|
|
|
|
|
|
if (TextUtils.isEmpty(v)) return;
|
|
|
|
|
|
ApiClient.setCustomBaseUrl(getApplicationContext(), v);
|
|
|
|
|
|
ApiClient.getService(getApplicationContext());
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
})
|
2025-12-23 12:39:14 +08:00
|
|
|
|
.show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
private void showApiBaseUrlHistory() {
|
|
|
|
|
|
String[] history = ApiClient.getBaseUrlHistory(getApplicationContext());
|
|
|
|
|
|
if (history == null || history.length == 0) {
|
|
|
|
|
|
Toast.makeText(this, "暂无历史记录", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-12-23 12:39:14 +08:00
|
|
|
|
new AlertDialog.Builder(this)
|
2025-12-22 19:38:44 +08:00
|
|
|
|
.setTitle("选择历史API服务器")
|
|
|
|
|
|
.setItems(history, (d, which) -> {
|
|
|
|
|
|
String sel = history[which];
|
|
|
|
|
|
if (TextUtils.isEmpty(sel)) return;
|
|
|
|
|
|
ApiClient.setCustomBaseUrl(getApplicationContext(), sel);
|
|
|
|
|
|
ApiClient.getService(getApplicationContext());
|
|
|
|
|
|
refresh();
|
2025-12-23 12:39:14 +08:00
|
|
|
|
})
|
|
|
|
|
|
.setNegativeButton("取消", null)
|
|
|
|
|
|
.show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
private void showStreamHostDialog() {
|
|
|
|
|
|
String current = StreamConfig.getStreamHostOverride(getApplicationContext());
|
|
|
|
|
|
String[] history = StreamConfig.getStreamHostHistory(getApplicationContext());
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
List<String> options = new ArrayList<>();
|
|
|
|
|
|
options.add("输入/修改");
|
|
|
|
|
|
if (history != null && history.length > 0) options.add("从历史选择");
|
|
|
|
|
|
options.add("清除覆写");
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
|
|
|
|
|
new AlertDialog.Builder(this)
|
2025-12-22 19:38:44 +08:00
|
|
|
|
.setTitle("直播流服务器覆写\n当前:" + (!TextUtils.isEmpty(current) ? current : "未设置"))
|
|
|
|
|
|
.setItems(options.toArray(new String[0]), (d, which) -> {
|
|
|
|
|
|
String sel = options.get(which);
|
|
|
|
|
|
if ("输入/修改".equals(sel)) {
|
|
|
|
|
|
showStreamHostInput();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if ("从历史选择".equals(sel)) {
|
|
|
|
|
|
showStreamHostHistory();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if ("清除覆写".equals(sel)) {
|
|
|
|
|
|
StreamConfig.clearStreamHostOverride(getApplicationContext());
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.setNegativeButton("取消", null)
|
2025-12-23 12:39:14 +08:00
|
|
|
|
.show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
private void showStreamHostInput() {
|
|
|
|
|
|
EditText input = new EditText(this);
|
|
|
|
|
|
input.setHint("例如:192.168.1.164 或 192.168.1.164:1935");
|
|
|
|
|
|
String current = StreamConfig.getStreamHostOverride(getApplicationContext());
|
|
|
|
|
|
if (!TextUtils.isEmpty(current)) input.setText(current);
|
2025-12-23 12:39:14 +08:00
|
|
|
|
|
|
|
|
|
|
new AlertDialog.Builder(this)
|
2025-12-22 19:38:44 +08:00
|
|
|
|
.setTitle("输入直播流服务器")
|
|
|
|
|
|
.setView(input)
|
|
|
|
|
|
.setNegativeButton("取消", null)
|
|
|
|
|
|
.setPositiveButton("保存", (d, w) -> {
|
|
|
|
|
|
String v = input.getText() != null ? input.getText().toString().trim() : "";
|
|
|
|
|
|
if (TextUtils.isEmpty(v)) return;
|
|
|
|
|
|
StreamConfig.setStreamHostOverride(getApplicationContext(), v);
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
})
|
2025-12-23 12:39:14 +08:00
|
|
|
|
.show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-22 19:38:44 +08:00
|
|
|
|
private void showStreamHostHistory() {
|
|
|
|
|
|
String[] history = StreamConfig.getStreamHostHistory(getApplicationContext());
|
|
|
|
|
|
if (history == null || history.length == 0) {
|
|
|
|
|
|
Toast.makeText(this, "暂无历史记录", Toast.LENGTH_SHORT).show();
|
|
|
|
|
|
return;
|
2025-12-23 12:39:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
new AlertDialog.Builder(this)
|
2025-12-22 19:38:44 +08:00
|
|
|
|
.setTitle("选择历史直播流服务器")
|
|
|
|
|
|
.setItems(history, (d, which) -> {
|
|
|
|
|
|
String sel = history[which];
|
|
|
|
|
|
if (TextUtils.isEmpty(sel)) return;
|
|
|
|
|
|
StreamConfig.setStreamHostOverride(getApplicationContext(), sel);
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
})
|
|
|
|
|
|
.setNegativeButton("取消", null)
|
2025-12-23 12:39:14 +08:00
|
|
|
|
.show();
|
|
|
|
|
|
}
|
2025-12-18 17:33:36 +08:00
|
|
|
|
}
|