Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f7eb94047 | ||
|
|
32c3e76888 | ||
|
|
b805abd153 | ||
|
|
e1f8265636 | ||
|
|
93c78c8fbc | ||
|
|
d5837e76a5 | ||
|
|
f78695077a | ||
|
|
7139e4d1fd | ||
|
|
3a7635d459 | ||
|
|
f64bc219e3 |
No files matched your search
@@ -27,7 +27,8 @@
|
|||||||
"mcp__plugin_serena_serena__replace_content",
|
"mcp__plugin_serena_serena__replace_content",
|
||||||
"Bash(git reset:*)",
|
"Bash(git reset:*)",
|
||||||
"mcp__plugin_serena_serena__create_text_file",
|
"mcp__plugin_serena_serena__create_text_file",
|
||||||
"Bash(powershell:*)"
|
"Bash(powershell:*)",
|
||||||
|
"Bash(find:*)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,5 +81,13 @@
|
|||||||
android:theme="@style/Theme.BzForGk2"
|
android:theme="@style/Theme.BzForGk2"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden" />
|
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||||
|
|
||||||
|
<!-- Slideshow Player Activity -->
|
||||||
|
<activity
|
||||||
|
android:name=".ui.SlideshowPlayerActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:theme="@style/Theme.BzForGk2"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -14,7 +14,7 @@ import cn.hugh.bz.gk2.wallpaper.AlbumPreferences;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存扫描接收器
|
* 缓存扫描接收器
|
||||||
* 定时清除缓存并重新扫描相册文件夹
|
* 使用智能扫描策略:只在文件夹有变化时才重新扫描,大幅减少扫描耗时
|
||||||
*/
|
*/
|
||||||
public class CacheScanReceiver extends BroadcastReceiver {
|
public class CacheScanReceiver extends BroadcastReceiver {
|
||||||
private static final String TAG = "CacheScanReceiver";
|
private static final String TAG = "CacheScanReceiver";
|
||||||
@@ -44,7 +44,7 @@ public class CacheScanReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫描所有相册的文件夹
|
* 扫描所有相册的文件夹(使用智能扫描策略)
|
||||||
*/
|
*/
|
||||||
private void scanAllAlbums(Context context, FileLogger fileLogger) {
|
private void scanAllAlbums(Context context, FileLogger fileLogger) {
|
||||||
AlbumPreferences albumPrefs = new AlbumPreferences(context);
|
AlbumPreferences albumPrefs = new AlbumPreferences(context);
|
||||||
@@ -60,6 +60,7 @@ public class CacheScanReceiver extends BroadcastReceiver {
|
|||||||
MediaScanner scanner = new MediaScanner(context);
|
MediaScanner scanner = new MediaScanner(context);
|
||||||
int totalFolders = 0;
|
int totalFolders = 0;
|
||||||
int scannedFolders = 0;
|
int scannedFolders = 0;
|
||||||
|
int unchangedFolders = 0; // 统计未变化的文件夹
|
||||||
|
|
||||||
// 遍历所有相册
|
// 遍历所有相册
|
||||||
for (Album album : albums) {
|
for (Album album : albums) {
|
||||||
@@ -74,16 +75,17 @@ public class CacheScanReceiver extends BroadcastReceiver {
|
|||||||
// 扫描每个文件夹
|
// 扫描每个文件夹
|
||||||
for (String folder : folders) {
|
for (String folder : folders) {
|
||||||
try {
|
try {
|
||||||
String scanMsg = "Scanning folder: " + folder + " (album: " + album.getName() + ")";
|
String scanMsg = "Smart scanning folder: " + folder + " (album: " + album.getName() + ")";
|
||||||
Log.i(TAG, scanMsg);
|
Log.i(TAG, scanMsg);
|
||||||
fileLogger.log(TAG, scanMsg);
|
fileLogger.log(TAG, scanMsg);
|
||||||
|
|
||||||
// 清除缓存并重新扫描
|
// 使用智能扫描代替强制重新扫描
|
||||||
scanner.rescanFolder(folder);
|
// 只在文件夹有变化时才重新扫描,大幅减少扫描耗时
|
||||||
|
scanner.smartScanFolder(folder);
|
||||||
scannedFolders++;
|
scannedFolders++;
|
||||||
albumScanned = true;
|
albumScanned = true;
|
||||||
|
|
||||||
String successMsg = "Successfully scanned folder: " + folder;
|
String successMsg = "Smart scan completed for folder: " + folder;
|
||||||
Log.i(TAG, successMsg);
|
Log.i(TAG, successMsg);
|
||||||
fileLogger.log(TAG, successMsg);
|
fileLogger.log(TAG, successMsg);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -106,7 +108,11 @@ public class CacheScanReceiver extends BroadcastReceiver {
|
|||||||
// 关闭扫描器
|
// 关闭扫描器
|
||||||
scanner.shutdown();
|
scanner.shutdown();
|
||||||
|
|
||||||
String summaryMsg = "Cache scan completed: scanned " + scannedFolders + "/" + totalFolders + " folders";
|
// 详细的统计信息
|
||||||
|
String summaryMsg = "Smart scan completed: " +
|
||||||
|
"total=" + totalFolders +
|
||||||
|
", processed=" + scannedFolders +
|
||||||
|
" folders";
|
||||||
Log.i(TAG, summaryMsg);
|
Log.i(TAG, summaryMsg);
|
||||||
fileLogger.log(TAG, summaryMsg);
|
fileLogger.log(TAG, summaryMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,255 +0,0 @@
|
|||||||
package cn.hugh.bz.gk2.ui;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.provider.OpenableColumns;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import com.google.android.material.button.MaterialButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import cn.hugh.bz.gk2.R;
|
|
||||||
import cn.hugh.bz.gk2.utils.BackgroundHelper;
|
|
||||||
import cn.hugh.bz.gk2.utils.ImageLoader;
|
|
||||||
import cn.hugh.bz.gk2.wallpaper.WallpaperPreferences;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当前壁纸 Fragment
|
|
||||||
* 显示当前壁纸大图预览、壁纸信息和操作按钮
|
|
||||||
*/
|
|
||||||
public class CurrentWallpaperFragment extends Fragment {
|
|
||||||
|
|
||||||
private ImageView ivWallpaper;
|
|
||||||
private View touchOverlay;
|
|
||||||
private TextView tvWallpaperName;
|
|
||||||
private TextView tvResolution;
|
|
||||||
private TextView tvFileSize;
|
|
||||||
private TextView tvPath;
|
|
||||||
private MaterialButton btnNext;
|
|
||||||
private MaterialButton btnOpenGallery;
|
|
||||||
|
|
||||||
private WallpaperPreferences prefs;
|
|
||||||
private ImageLoader imageLoader;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
return inflater.inflate(R.layout.fragment_current_wallpaper, container, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
|
|
||||||
prefs = new WallpaperPreferences(requireContext());
|
|
||||||
imageLoader = new ImageLoader(requireContext());
|
|
||||||
|
|
||||||
initViews(view);
|
|
||||||
loadCurrentWallpaper();
|
|
||||||
|
|
||||||
// 应用背景图片
|
|
||||||
BackgroundHelper.applyBackground(requireContext(), view);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initViews(View view) {
|
|
||||||
ivWallpaper = view.findViewById(R.id.ivWallpaper);
|
|
||||||
touchOverlay = view.findViewById(R.id.touchOverlay);
|
|
||||||
tvWallpaperName = view.findViewById(R.id.tvWallpaperName);
|
|
||||||
tvResolution = view.findViewById(R.id.tvResolution);
|
|
||||||
tvFileSize = view.findViewById(R.id.tvFileSize);
|
|
||||||
tvPath = view.findViewById(R.id.tvPath);
|
|
||||||
btnNext = view.findViewById(R.id.btnNext);
|
|
||||||
btnOpenGallery = view.findViewById(R.id.btnOpenGallery);
|
|
||||||
|
|
||||||
btnNext.setOnClickListener(v -> showNextWallpaper());
|
|
||||||
btnOpenGallery.setOnClickListener(v -> openInGallery());
|
|
||||||
touchOverlay.setOnClickListener(v -> openInGallery());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadCurrentWallpaper() {
|
|
||||||
String currentUri = prefs.getLastUri();
|
|
||||||
|
|
||||||
if (currentUri == null || currentUri.isEmpty()) {
|
|
||||||
showNoWallpaper();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 显示加载状态
|
|
||||||
tvWallpaperName.setText("加载中...");
|
|
||||||
tvResolution.setText("-- x --");
|
|
||||||
tvFileSize.setText("-- MB");
|
|
||||||
tvPath.setText(currentUri);
|
|
||||||
btnNext.setEnabled(false);
|
|
||||||
|
|
||||||
// 获取文件大小和名称
|
|
||||||
new Thread(() -> {
|
|
||||||
String fileSizeStr = getFileSize(Uri.parse(currentUri));
|
|
||||||
String displayName = getDisplayName(currentUri);
|
|
||||||
|
|
||||||
requireActivity().runOnUiThread(() -> {
|
|
||||||
tvFileSize.setText(fileSizeStr);
|
|
||||||
tvWallpaperName.setText(displayName);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 加载图片
|
|
||||||
Bitmap bitmap = imageLoader.loadImage(currentUri, 1080, 1920);
|
|
||||||
|
|
||||||
requireActivity().runOnUiThread(() -> {
|
|
||||||
if (bitmap != null) {
|
|
||||||
ivWallpaper.setImageBitmap(bitmap);
|
|
||||||
tvResolution.setText(bitmap.getWidth() + " x " + bitmap.getHeight());
|
|
||||||
btnNext.setEnabled(true);
|
|
||||||
} else {
|
|
||||||
showError();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getFileSize(Uri uri) {
|
|
||||||
try (Cursor cursor = requireContext().getContentResolver().query(uri, null, null, null, null)) {
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
|
||||||
int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
|
|
||||||
if (sizeIndex != -1) {
|
|
||||||
long size = cursor.getLong(sizeIndex);
|
|
||||||
return formatFileSize(size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return "未知大小";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formatFileSize(long size) {
|
|
||||||
if (size <= 0) return "0 B";
|
|
||||||
final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
|
|
||||||
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
|
|
||||||
return String.format("%.1f %s", size / Math.pow(1024, digitGroups), units[digitGroups]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showNoWallpaper() {
|
|
||||||
ivWallpaper.setImageDrawable(null);
|
|
||||||
tvWallpaperName.setText("未设置壁纸");
|
|
||||||
tvResolution.setText("--");
|
|
||||||
tvFileSize.setText("--");
|
|
||||||
tvPath.setText("");
|
|
||||||
btnNext.setEnabled(false);
|
|
||||||
btnOpenGallery.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showError() {
|
|
||||||
ivWallpaper.setImageDrawable(null);
|
|
||||||
tvWallpaperName.setText("加载失败");
|
|
||||||
btnNext.setEnabled(true); // 允许尝试下一张
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showNextWallpaper() {
|
|
||||||
android.util.Log.i("CurrentWallpaperFragment", "showNextWallpaper() called");
|
|
||||||
|
|
||||||
cn.hugh.bz.gk2.model.AppConfig config = prefs.loadConfig();
|
|
||||||
|
|
||||||
if (config.getSelectedFolders().isEmpty() &&
|
|
||||||
(config.getImageUris() == null || config.getImageUris().isEmpty())) {
|
|
||||||
Toast.makeText(requireContext(), "请先在相册页面添加图片", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 禁用按钮防止重复点击
|
|
||||||
btnNext.setEnabled(false);
|
|
||||||
btnNext.setText("切换中...");
|
|
||||||
|
|
||||||
// 发送广播
|
|
||||||
cn.hugh.bz.gk2.receiver.WallpaperChangeReceiver receiver = new cn.hugh.bz.gk2.receiver.WallpaperChangeReceiver();
|
|
||||||
Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER");
|
|
||||||
intent.putExtra("force_change", true);
|
|
||||||
intent.putExtra("scheduled", false);
|
|
||||||
receiver.onReceive(requireContext(), intent);
|
|
||||||
|
|
||||||
Toast.makeText(requireContext(), "已切换", Toast.LENGTH_SHORT).show();
|
|
||||||
|
|
||||||
// 延迟刷新
|
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
|
||||||
loadCurrentWallpaper();
|
|
||||||
btnNext.setText("切换下一张");
|
|
||||||
btnNext.setEnabled(true);
|
|
||||||
}, 800);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openInGallery() {
|
|
||||||
String currentUri = prefs.getLastUri();
|
|
||||||
if (currentUri != null) {
|
|
||||||
try {
|
|
||||||
Uri uri = Uri.parse(currentUri);
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
||||||
startActivity(intent);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Toast.makeText(requireContext(), "无法打开图片", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDisplayName(String uriString) {
|
|
||||||
if (uriString == null || uriString.isEmpty()) {
|
|
||||||
return "未知图片";
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Uri uri = Uri.parse(uriString);
|
|
||||||
|
|
||||||
// 尝试从 ContentResolver 获取文件名
|
|
||||||
try (Cursor cursor = requireContext().getContentResolver().query(uri, null, null, null, null)) {
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
|
||||||
int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
|
||||||
if (nameIndex != -1) {
|
|
||||||
return cursor.getString(nameIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果失败,回退到路径解析
|
|
||||||
String path = uri.getLastPathSegment();
|
|
||||||
if (path != null) {
|
|
||||||
if (path.contains(":")) {
|
|
||||||
String[] parts = path.split(":");
|
|
||||||
if (parts.length > 1) {
|
|
||||||
path = parts[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (path.contains("/")) {
|
|
||||||
String[] segments = path.split("/");
|
|
||||||
path = segments[segments.length - 1];
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
return "未命名图片";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
loadCurrentWallpaper();
|
|
||||||
|
|
||||||
View rootView = getView();
|
|
||||||
if (rootView != null) {
|
|
||||||
BackgroundHelper.applyBackground(requireContext(), rootView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,17 @@ package cn.hugh.bz.gk2.ui;
|
|||||||
|
|
||||||
import android.app.WallpaperManager;
|
import android.app.WallpaperManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.provider.OpenableColumns;
|
||||||
|
import android.database.Cursor;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -15,7 +20,7 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.airbnb.lottie.LottieAnimationView;
|
import com.google.android.material.button.MaterialButton;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -23,30 +28,41 @@ import cn.hugh.bz.gk2.R;
|
|||||||
import cn.hugh.bz.gk2.model.Album;
|
import cn.hugh.bz.gk2.model.Album;
|
||||||
import cn.hugh.bz.gk2.model.AppConfig;
|
import cn.hugh.bz.gk2.model.AppConfig;
|
||||||
import cn.hugh.bz.gk2.utils.BackgroundHelper;
|
import cn.hugh.bz.gk2.utils.BackgroundHelper;
|
||||||
|
import cn.hugh.bz.gk2.utils.ImageLoader;
|
||||||
import cn.hugh.bz.gk2.utils.WallpaperServiceHelper;
|
import cn.hugh.bz.gk2.utils.WallpaperServiceHelper;
|
||||||
import cn.hugh.bz.gk2.wallpaper.AlbumPreferences;
|
import cn.hugh.bz.gk2.wallpaper.AlbumPreferences;
|
||||||
import cn.hugh.bz.gk2.wallpaper.WallpaperPreferences;
|
import cn.hugh.bz.gk2.wallpaper.WallpaperPreferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主页 Fragment
|
* 主页 Fragment (Dashboard)
|
||||||
* 负责显示服务状态和启用/禁用服务
|
* 负责显示当前壁纸、服务状态和快速操作
|
||||||
*/
|
*/
|
||||||
public class HomeFragment extends Fragment {
|
public class HomeFragment extends Fragment {
|
||||||
private static final String TAG = "HomeFragment";
|
private static final String TAG = "HomeFragment";
|
||||||
|
|
||||||
|
// 状态相关
|
||||||
private TextView tvStatus;
|
private TextView tvStatus;
|
||||||
private LottieAnimationView statusAnimation;
|
private View viewStatusDot;
|
||||||
private TextView tvFolderInfo;
|
private MaterialButton btnToggle;
|
||||||
private TextView tvSingleImageInfo;
|
|
||||||
private Button btnToggle;
|
// 壁纸预览相关
|
||||||
private Button btnChangeNow;
|
private ImageView ivBlurBackground;
|
||||||
|
private ImageView ivCurrentWallpaper;
|
||||||
|
private View touchOverlay;
|
||||||
|
private MaterialButton btnChangeNow;
|
||||||
|
private MaterialButton btnOpenGallery;
|
||||||
|
|
||||||
|
// 信息相关
|
||||||
|
private TextView tvWallpaperName;
|
||||||
|
private TextView tvResolution;
|
||||||
|
private TextView tvFileSize;
|
||||||
private TextView tvAlbumName;
|
private TextView tvAlbumName;
|
||||||
private TextView tvAlbumInfo;
|
private MaterialButton btnManageAlbums;
|
||||||
private Button btnManageAlbums;
|
|
||||||
|
|
||||||
private WallpaperPreferences prefs;
|
private WallpaperPreferences prefs;
|
||||||
private AppConfig config;
|
private AppConfig config;
|
||||||
private AlbumPreferences albumPrefs;
|
private AlbumPreferences albumPrefs;
|
||||||
|
private ImageLoader imageLoader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
@@ -60,226 +76,205 @@ public class HomeFragment extends Fragment {
|
|||||||
prefs = new WallpaperPreferences(requireContext());
|
prefs = new WallpaperPreferences(requireContext());
|
||||||
config = prefs.loadConfig();
|
config = prefs.loadConfig();
|
||||||
albumPrefs = new AlbumPreferences(requireContext());
|
albumPrefs = new AlbumPreferences(requireContext());
|
||||||
|
imageLoader = new ImageLoader(requireContext());
|
||||||
|
|
||||||
// 创建默认相册(如果不存在)
|
|
||||||
albumPrefs.createDefaultAlbumIfNeeded();
|
albumPrefs.createDefaultAlbumIfNeeded();
|
||||||
|
|
||||||
initViews(view);
|
initViews(view);
|
||||||
updateUI();
|
updateUI();
|
||||||
updateAlbumInfo();
|
loadCurrentWallpaper();
|
||||||
|
|
||||||
// 应用背景图片
|
// 应用自定义背景(如果有)
|
||||||
BackgroundHelper.applyBackground(requireContext(), view);
|
BackgroundHelper.applyBackground(requireContext(), view);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initViews(View view) {
|
private void initViews(View view) {
|
||||||
|
// 状态
|
||||||
tvStatus = view.findViewById(R.id.tvStatus);
|
tvStatus = view.findViewById(R.id.tvStatus);
|
||||||
statusAnimation = view.findViewById(R.id.statusAnimation);
|
viewStatusDot = view.findViewById(R.id.viewStatusDot);
|
||||||
tvFolderInfo = view.findViewById(R.id.tvFolderInfo);
|
|
||||||
tvSingleImageInfo = view.findViewById(R.id.tvSingleImageInfo);
|
|
||||||
btnToggle = view.findViewById(R.id.btnToggle);
|
btnToggle = view.findViewById(R.id.btnToggle);
|
||||||
|
|
||||||
|
// 预览
|
||||||
|
ivBlurBackground = view.findViewById(R.id.ivBlurBackground);
|
||||||
|
ivCurrentWallpaper = view.findViewById(R.id.ivCurrentWallpaper);
|
||||||
|
touchOverlay = view.findViewById(R.id.touchOverlay);
|
||||||
btnChangeNow = view.findViewById(R.id.btnChangeNow);
|
btnChangeNow = view.findViewById(R.id.btnChangeNow);
|
||||||
|
btnOpenGallery = view.findViewById(R.id.btnOpenGallery);
|
||||||
|
|
||||||
|
// 信息
|
||||||
|
tvWallpaperName = view.findViewById(R.id.tvWallpaperName);
|
||||||
|
tvResolution = view.findViewById(R.id.tvResolution);
|
||||||
|
tvFileSize = view.findViewById(R.id.tvFileSize);
|
||||||
tvAlbumName = view.findViewById(R.id.tvAlbumName);
|
tvAlbumName = view.findViewById(R.id.tvAlbumName);
|
||||||
tvAlbumInfo = view.findViewById(R.id.tvAlbumInfo);
|
|
||||||
btnManageAlbums = view.findViewById(R.id.btnManageAlbums);
|
btnManageAlbums = view.findViewById(R.id.btnManageAlbums);
|
||||||
|
|
||||||
btnToggle.setOnClickListener(v -> toggleService());
|
btnToggle.setOnClickListener(v -> toggleService());
|
||||||
btnChangeNow.setOnClickListener(v -> changeWallpaperNow());
|
btnChangeNow.setOnClickListener(v -> changeWallpaperNow());
|
||||||
|
btnOpenGallery.setOnClickListener(v -> openInGallery());
|
||||||
|
touchOverlay.setOnClickListener(v -> openInGallery());
|
||||||
btnManageAlbums.setOnClickListener(v -> openAlbumManagement());
|
btnManageAlbums.setOnClickListener(v -> openAlbumManagement());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggleService() {
|
private void toggleService() {
|
||||||
if (!config.hasMedia()) {
|
if (!config.hasMedia()) {
|
||||||
Toast.makeText(requireContext(), "请先在相册页面添加文件夹或图片", Toast.LENGTH_SHORT).show();
|
Toast.makeText(requireContext(), "请先在相册页面添加图片", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean newState = !config.isEnabled();
|
boolean newState = !config.isEnabled();
|
||||||
|
|
||||||
if (newState) {
|
if (newState) {
|
||||||
// 每次启用都弹出壁纸设置引导
|
|
||||||
showSetWallpaperDialog();
|
showSetWallpaperDialog();
|
||||||
} else {
|
} else {
|
||||||
config.setEnabled(newState);
|
config.setEnabled(false);
|
||||||
prefs.saveConfig(config);
|
prefs.saveConfig(config);
|
||||||
|
new cn.hugh.bz.gk2.utils.AlarmScheduler(requireContext()).cancelSchedule();
|
||||||
cn.hugh.bz.gk2.utils.AlarmScheduler scheduler = new cn.hugh.bz.gk2.utils.AlarmScheduler(requireContext());
|
|
||||||
scheduler.cancelSchedule();
|
|
||||||
Toast.makeText(requireContext(), "已禁用", Toast.LENGTH_SHORT).show();
|
Toast.makeText(requireContext(), "已禁用", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 显示引导设置壁纸的对话框
|
|
||||||
*/
|
|
||||||
private void showSetWallpaperDialog() {
|
private void showSetWallpaperDialog() {
|
||||||
new androidx.appcompat.app.AlertDialog.Builder(requireContext())
|
new androidx.appcompat.app.AlertDialog.Builder(requireContext())
|
||||||
.setTitle("设置动态壁纸")
|
.setTitle("启用壁纸服务")
|
||||||
.setMessage("点击「确定」后将打开壁纸选择界面,请选择「BzForGk2」作为动态壁纸。\n\n设置完成后返回应用即可自动启用。")
|
.setMessage("点击确定后请选择「BzForGk2」作为动态壁纸。")
|
||||||
.setPositiveButton("确定", (dialog, which) -> {
|
.setPositiveButton("确定", (dialog, which) -> {
|
||||||
cn.hugh.bz.gk2.utils.FileLogger fileLogger = cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext());
|
|
||||||
String msg = "User confirmed wallpaper service enable";
|
|
||||||
android.util.Log.i(TAG, msg);
|
|
||||||
fileLogger.log(TAG, msg);
|
|
||||||
|
|
||||||
openWallpaperSelector();
|
openWallpaperSelector();
|
||||||
// 启用服务
|
|
||||||
config.setEnabled(true);
|
config.setEnabled(true);
|
||||||
prefs.saveConfig(config);
|
prefs.saveConfig(config);
|
||||||
|
new cn.hugh.bz.gk2.utils.AlarmScheduler(requireContext()).scheduleWallpaperChange(config.getIntervalMinutes());
|
||||||
String scheduleMsg = "Scheduling alarm with interval: " + config.getIntervalMinutes() + " minutes";
|
|
||||||
android.util.Log.i(TAG, scheduleMsg);
|
|
||||||
fileLogger.log(TAG, scheduleMsg);
|
|
||||||
|
|
||||||
cn.hugh.bz.gk2.utils.AlarmScheduler scheduler = new cn.hugh.bz.gk2.utils.AlarmScheduler(requireContext());
|
|
||||||
scheduler.scheduleWallpaperChange(config.getIntervalMinutes());
|
|
||||||
|
|
||||||
Toast.makeText(requireContext(), "已启用,请选择壁纸", Toast.LENGTH_LONG).show();
|
|
||||||
updateUI();
|
updateUI();
|
||||||
})
|
})
|
||||||
.setNegativeButton("取消", null)
|
.setNegativeButton("取消", null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 打开系统壁纸选择界面
|
|
||||||
*/
|
|
||||||
private void openWallpaperSelector() {
|
private void openWallpaperSelector() {
|
||||||
try {
|
try {
|
||||||
Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
|
Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
|
||||||
intent.putExtra(
|
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
|
||||||
WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
|
new android.content.ComponentName(requireContext(), cn.hugh.bz.gk2.wallpaper.AutoWallpaperService.class));
|
||||||
new android.content.ComponentName(requireContext(), cn.hugh.bz.gk2.wallpaper.AutoWallpaperService.class)
|
|
||||||
);
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 如果上述方法失败,尝试打开壁纸选择器
|
|
||||||
try {
|
try {
|
||||||
Intent intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
|
startActivity(new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER));
|
||||||
startActivity(intent);
|
|
||||||
Toast.makeText(requireContext(), "请选择 BzForGk2 动态壁纸", Toast.LENGTH_LONG).show();
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// 最后的备用方案:打开壁纸设置页面
|
Toast.makeText(requireContext(), "无法打开壁纸设置", Toast.LENGTH_SHORT).show();
|
||||||
try {
|
|
||||||
Intent intent = new Intent("android.settings.WALLPAPER_SETTINGS");
|
|
||||||
startActivity(intent);
|
|
||||||
Toast.makeText(requireContext(), "请选择 动态壁纸 → BzForGk2", Toast.LENGTH_LONG).show();
|
|
||||||
} catch (Exception exc) {
|
|
||||||
Toast.makeText(requireContext(), "无法打开壁纸设置,请手动去系统设置中选择", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeWallpaperNow() {
|
private void changeWallpaperNow() {
|
||||||
android.util.Log.i(TAG, "changeWallpaperNow() called");
|
|
||||||
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log(TAG, "changeWallpaperNow() called");
|
|
||||||
|
|
||||||
android.util.Log.i(TAG, "Selected folders count: " + config.getSelectedFolders().size());
|
|
||||||
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log(TAG, "Selected folders count: " + config.getSelectedFolders().size());
|
|
||||||
|
|
||||||
List<String> imageUris = config.getImageUris();
|
|
||||||
int imageCount = (imageUris != null) ? imageUris.size() : 0;
|
|
||||||
android.util.Log.i(TAG, "Image URIs count: " + imageCount);
|
|
||||||
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log(TAG, "Image URIs count: " + imageCount);
|
|
||||||
|
|
||||||
if (!config.hasMedia()) {
|
if (!config.hasMedia()) {
|
||||||
android.util.Log.w(TAG, "No media available, showing toast");
|
Toast.makeText(requireContext(), "请先添加图片", Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(requireContext(), "请先在相册页面添加文件夹或图片", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
android.util.Log.i(TAG, "changeWallpaperNow: sending broadcast");
|
btnChangeNow.setEnabled(false);
|
||||||
cn.hugh.bz.gk2.utils.FileLogger.getInstance(requireContext()).log(TAG, "changeWallpaperNow: sending broadcast");
|
|
||||||
|
|
||||||
// 直接实例化 BroadcastReceiver 并调用 onReceive(避免隐式广播限制)
|
|
||||||
cn.hugh.bz.gk2.receiver.WallpaperChangeReceiver receiver = new cn.hugh.bz.gk2.receiver.WallpaperChangeReceiver();
|
cn.hugh.bz.gk2.receiver.WallpaperChangeReceiver receiver = new cn.hugh.bz.gk2.receiver.WallpaperChangeReceiver();
|
||||||
Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER");
|
Intent intent = new Intent("cn.hugh.bz.gk2.ACTION_CHANGE_WALLPAPER");
|
||||||
intent.putExtra("force_change", true); // 用户主动触发
|
intent.putExtra("force_change", true);
|
||||||
intent.putExtra("scheduled", false); // 非定时触发
|
|
||||||
receiver.onReceive(requireContext(), intent);
|
receiver.onReceive(requireContext(), intent);
|
||||||
|
|
||||||
Toast.makeText(requireContext(), "壁纸已更换", Toast.LENGTH_SHORT).show();
|
Toast.makeText(requireContext(), "正在更换...", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
loadCurrentWallpaper();
|
||||||
|
btnChangeNow.setEnabled(true);
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadCurrentWallpaper() {
|
||||||
|
String currentUri = prefs.getLastUri();
|
||||||
|
if (currentUri == null || currentUri.isEmpty()) {
|
||||||
|
tvWallpaperName.setText("未设置壁纸");
|
||||||
|
ivCurrentWallpaper.setImageResource(R.drawable.ic_image);
|
||||||
|
ivBlurBackground.setImageDrawable(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
String fileName = getDisplayName(currentUri);
|
||||||
|
String size = getFileSize(Uri.parse(currentUri));
|
||||||
|
Bitmap bitmap = imageLoader.loadImage(currentUri, 500, 800); // 预览图不需要太大
|
||||||
|
|
||||||
|
if (isAdded()) {
|
||||||
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
tvWallpaperName.setText(fileName);
|
||||||
|
tvFileSize.setText(size);
|
||||||
|
if (bitmap != null) {
|
||||||
|
ivCurrentWallpaper.setImageBitmap(bitmap);
|
||||||
|
ivBlurBackground.setImageBitmap(bitmap); // 布局中 alpha 已经设为 0.4
|
||||||
|
tvResolution.setText(bitmap.getWidth() + " x " + bitmap.getHeight());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDisplayName(String uriString) {
|
||||||
|
try {
|
||||||
|
Uri uri = Uri.parse(uriString);
|
||||||
|
try (Cursor cursor = requireContext().getContentResolver().query(uri, null, null, null, null)) {
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||||
|
if (nameIndex != -1) return cursor.getString(nameIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uri.getLastPathSegment();
|
||||||
|
} catch (Exception e) { return "未知文件"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFileSize(Uri uri) {
|
||||||
|
try (Cursor cursor = requireContext().getContentResolver().query(uri, null, null, null, null)) {
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
|
||||||
|
if (sizeIndex != -1) {
|
||||||
|
long size = cursor.getLong(sizeIndex);
|
||||||
|
if (size <= 0) return "0 B";
|
||||||
|
final String[] units = new String[]{"B", "KB", "MB", "GB"};
|
||||||
|
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
|
||||||
|
return String.format("%.1f %s", size / Math.pow(1024, digitGroups), units[digitGroups]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {}
|
||||||
|
return "未知大小";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openInGallery() {
|
||||||
|
String uriStr = prefs.getLastUri();
|
||||||
|
if (uriStr != null) {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriStr));
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Toast.makeText(requireContext(), "无法打开图片", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openAlbumManagement() {
|
private void openAlbumManagement() {
|
||||||
// 切换到相册页面(ViewPager 的第 3 个页面,索引为 2)
|
|
||||||
if (getActivity() instanceof MainActivity) {
|
if (getActivity() instanceof MainActivity) {
|
||||||
MainActivity activity = (MainActivity) getActivity();
|
((MainActivity) getActivity()).switchToPage(1); // 调整后的相册页索引为 1
|
||||||
activity.switchToPage(2); // 2 是相册管理页面的索引
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
// 检测壁纸服务是否真实在运行
|
boolean isRunning = WallpaperServiceHelper.isServiceRunning(requireContext()) && config.isEnabled();
|
||||||
boolean isServiceActuallyRunning = WallpaperServiceHelper.isServiceRunning(requireContext());
|
|
||||||
boolean isConfigEnabled = config.isEnabled();
|
if (isRunning) {
|
||||||
|
tvStatus.setText("服务已开启");
|
||||||
// Update status - 优先使用实际运行状态
|
viewStatusDot.setBackgroundResource(R.drawable.status_indicator_enabled);
|
||||||
if (isServiceActuallyRunning && isConfigEnabled) {
|
btnToggle.setText("禁用");
|
||||||
// 服务真正在运行
|
|
||||||
tvStatus.setText(R.string.status_enabled);
|
|
||||||
btnToggle.setText(R.string.disable);
|
|
||||||
btnChangeNow.setEnabled(true);
|
|
||||||
// 启动 Lottie 动画
|
|
||||||
if (statusAnimation != null) {
|
|
||||||
statusAnimation.setAnimation(R.raw.status_active);
|
|
||||||
statusAnimation.playAnimation();
|
|
||||||
}
|
|
||||||
} else if (isConfigEnabled && !isServiceActuallyRunning) {
|
|
||||||
// 配置已启用但服务未运行(用户可能还没选择壁纸)
|
|
||||||
tvStatus.setText("等待设置壁纸");
|
|
||||||
btnToggle.setText(R.string.disable);
|
|
||||||
btnChangeNow.setEnabled(false);
|
|
||||||
// 停止 Lottie 动画
|
|
||||||
if (statusAnimation != null) {
|
|
||||||
statusAnimation.cancelAnimation();
|
|
||||||
statusAnimation.setProgress(0f);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// 服务已禁用
|
tvStatus.setText("服务已禁用");
|
||||||
tvStatus.setText(R.string.status_disabled);
|
viewStatusDot.setBackgroundResource(R.drawable.status_indicator_disabled);
|
||||||
btnToggle.setText(R.string.enable);
|
btnToggle.setText("启用");
|
||||||
btnChangeNow.setEnabled(false);
|
|
||||||
// 停止 Lottie 动画
|
|
||||||
if (statusAnimation != null) {
|
|
||||||
statusAnimation.cancelAnimation();
|
|
||||||
statusAnimation.setProgress(0f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update folder info
|
|
||||||
int folderCount = config.getSelectedFolders().size();
|
|
||||||
if (folderCount == 0) {
|
|
||||||
tvFolderInfo.setText("未选择文件夹");
|
|
||||||
} else {
|
|
||||||
tvFolderInfo.setText("已选择 " + folderCount + " 个文件夹");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update single image info
|
|
||||||
List<String> imageUris = config.getImageUris();
|
|
||||||
if (imageUris != null && !imageUris.isEmpty()) {
|
|
||||||
tvSingleImageInfo.setText("已选择 " + imageUris.size() + " 张图片");
|
|
||||||
tvSingleImageInfo.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
tvSingleImageInfo.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新相册信息显示
|
|
||||||
*/
|
|
||||||
private void updateAlbumInfo() {
|
|
||||||
Album activeAlbum = albumPrefs.getActiveAlbum();
|
Album activeAlbum = albumPrefs.getActiveAlbum();
|
||||||
if (activeAlbum != null) {
|
tvAlbumName.setText(activeAlbum != null ? activeAlbum.getName() : "默认相册");
|
||||||
tvAlbumName.setText(activeAlbum.getName());
|
|
||||||
tvAlbumInfo.setText(activeAlbum.getMediaSummary());
|
|
||||||
} else {
|
|
||||||
tvAlbumName.setText("默认相册");
|
|
||||||
tvAlbumInfo.setText("无媒体内容");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -287,12 +282,6 @@ public class HomeFragment extends Fragment {
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
config = prefs.loadConfig();
|
config = prefs.loadConfig();
|
||||||
updateUI();
|
updateUI();
|
||||||
updateAlbumInfo();
|
loadCurrentWallpaper();
|
||||||
|
|
||||||
// 重新应用背景图片(从设置页面返回时可能需要更新)
|
|
||||||
View rootView = getView();
|
|
||||||
if (rootView != null) {
|
|
||||||
BackgroundHelper.applyBackground(requireContext(), rootView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,8 +170,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
// 导航容器 ID(LinearLayout,用于点击事件)
|
// 导航容器 ID(LinearLayout,用于点击事件)
|
||||||
int[] navContainerIds = {
|
int[] navContainerIds = {
|
||||||
R.id.navHome,
|
R.id.navHome,
|
||||||
R.id.navWallpaper,
|
|
||||||
R.id.navAlbum,
|
R.id.navAlbum,
|
||||||
|
R.id.navSlideshow,
|
||||||
R.id.navHistory,
|
R.id.navHistory,
|
||||||
R.id.navSettings
|
R.id.navSettings
|
||||||
};
|
};
|
||||||
@@ -179,8 +179,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
// 导航文本 ID(TextView,用于更新选中状态)
|
// 导航文本 ID(TextView,用于更新选中状态)
|
||||||
int[] navTextIds = {
|
int[] navTextIds = {
|
||||||
R.id.tvNavHome,
|
R.id.tvNavHome,
|
||||||
R.id.tvNavWallpaper,
|
|
||||||
R.id.tvNavAlbum,
|
R.id.tvNavAlbum,
|
||||||
|
R.id.tvNavSlideshow,
|
||||||
R.id.tvNavHistory,
|
R.id.tvNavHistory,
|
||||||
R.id.tvNavSettings
|
R.id.tvNavSettings
|
||||||
};
|
};
|
||||||
@@ -188,8 +188,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
// 图标 ID
|
// 图标 ID
|
||||||
int[] navIconIds = {
|
int[] navIconIds = {
|
||||||
R.id.ivNavHome,
|
R.id.ivNavHome,
|
||||||
R.id.ivNavWallpaper,
|
|
||||||
R.id.ivNavAlbum,
|
R.id.ivNavAlbum,
|
||||||
|
R.id.ivNavSlideshow,
|
||||||
R.id.ivNavHistory,
|
R.id.ivNavHistory,
|
||||||
R.id.ivNavSettings
|
R.id.ivNavSettings
|
||||||
};
|
};
|
||||||
@@ -254,7 +254,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 切换到指定的页面
|
* 切换到指定的页面
|
||||||
* @param position 页面索引(0=主页,1=壁纸,2=相册,3=历史,4=设置)
|
* @param position 页面索引(0=主页,1=相册,2=幻灯片,3=历史,4=设置)
|
||||||
*/
|
*/
|
||||||
public void switchToPage(int position) {
|
public void switchToPage(int position) {
|
||||||
if (viewPager != null && position >= 0 && position < 5) {
|
if (viewPager != null && position >= 0 && position < 5) {
|
||||||
|
|||||||
@@ -0,0 +1,271 @@
|
|||||||
|
package cn.hugh.bz.gk2.ui;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.google.android.material.button.MaterialButton;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import cn.hugh.bz.gk2.R;
|
||||||
|
import cn.hugh.bz.gk2.model.Album;
|
||||||
|
import cn.hugh.bz.gk2.utils.FileLogger;
|
||||||
|
import cn.hugh.bz.gk2.utils.MediaScanner;
|
||||||
|
import cn.hugh.bz.gk2.wallpaper.AlbumPreferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 幻灯片 Fragment
|
||||||
|
* 显示数量选择界面,从当前激活相册随机选择图片
|
||||||
|
*/
|
||||||
|
public class SlideshowFragment extends Fragment {
|
||||||
|
private static final String TAG = "SlideshowFragment";
|
||||||
|
|
||||||
|
private TextView tvAlbumName;
|
||||||
|
private TextView tvImageCount;
|
||||||
|
private MaterialButton btn10;
|
||||||
|
private MaterialButton btn20;
|
||||||
|
private MaterialButton btn50;
|
||||||
|
private MaterialButton btnAll;
|
||||||
|
|
||||||
|
private AlbumPreferences albumPrefs;
|
||||||
|
private MediaScanner mediaScanner;
|
||||||
|
private Album activeAlbum;
|
||||||
|
private List<String> allImages;
|
||||||
|
private FileLogger logger;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
return inflater.inflate(R.layout.fragment_slideshow, container, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
logger = FileLogger.getInstance(requireContext());
|
||||||
|
logger.log(TAG, "onViewCreated: start");
|
||||||
|
|
||||||
|
try {
|
||||||
|
albumPrefs = new AlbumPreferences(requireContext());
|
||||||
|
logger.log(TAG, "onViewCreated: albumPrefs created");
|
||||||
|
|
||||||
|
mediaScanner = new MediaScanner(requireContext());
|
||||||
|
logger.log(TAG, "onViewCreated: mediaScanner created");
|
||||||
|
|
||||||
|
allImages = new ArrayList<>();
|
||||||
|
logger.log(TAG, "onViewCreated: allImages initialized");
|
||||||
|
|
||||||
|
initViews(view);
|
||||||
|
logger.log(TAG, "onViewCreated: initViews done");
|
||||||
|
|
||||||
|
setupButtons();
|
||||||
|
logger.log(TAG, "onViewCreated: setupButtons done");
|
||||||
|
|
||||||
|
loadAlbumData();
|
||||||
|
logger.log(TAG, "onViewCreated: loadAlbumData done");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(TAG, "onViewCreated: ERROR", e);
|
||||||
|
Log.e(TAG, "onViewCreated error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initViews(View view) {
|
||||||
|
tvAlbumName = view.findViewById(R.id.tvAlbumName);
|
||||||
|
tvImageCount = view.findViewById(R.id.tvImageCount);
|
||||||
|
btn10 = view.findViewById(R.id.btn10);
|
||||||
|
btn20 = view.findViewById(R.id.btn20);
|
||||||
|
btn50 = view.findViewById(R.id.btn50);
|
||||||
|
btnAll = view.findViewById(R.id.btnAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadAlbumData() {
|
||||||
|
logger.log(TAG, "loadAlbumData: start");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 获取激活相册
|
||||||
|
String activeAlbumId = albumPrefs.getActiveAlbumId();
|
||||||
|
logger.log(TAG, "loadAlbumData: activeAlbumId=" + activeAlbumId);
|
||||||
|
|
||||||
|
List<Album> albums = albumPrefs.loadAlbums();
|
||||||
|
logger.log(TAG, "loadAlbumData: albums count=" + (albums != null ? albums.size() : "null"));
|
||||||
|
|
||||||
|
if (albums != null) {
|
||||||
|
for (Album album : albums) {
|
||||||
|
if (album.getId().equals(activeAlbumId)) {
|
||||||
|
activeAlbum = album;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeAlbum == null) {
|
||||||
|
logger.log(TAG, "loadAlbumData: activeAlbum is null");
|
||||||
|
tvAlbumName.setText("未找到激活相册");
|
||||||
|
tvImageCount.setText("0 张图片");
|
||||||
|
disableAllButtons();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.log(TAG, "loadAlbumData: activeAlbum=" + activeAlbum.getName());
|
||||||
|
|
||||||
|
// 扫描相册图片
|
||||||
|
allImages = new ArrayList<>();
|
||||||
|
|
||||||
|
// 扫描文件夹
|
||||||
|
List<String> folders = activeAlbum.getFolders();
|
||||||
|
logger.log(TAG, "loadAlbumData: folders=" + (folders != null ? folders.size() : "null"));
|
||||||
|
|
||||||
|
if (folders != null) {
|
||||||
|
for (String folderUri : folders) {
|
||||||
|
logger.log(TAG, "loadAlbumData: scanning folder=" + folderUri);
|
||||||
|
List<cn.hugh.bz.gk2.model.WallpaperMedia> mediaList = mediaScanner.scanFolder(folderUri);
|
||||||
|
logger.log(TAG, "loadAlbumData: mediaList=" + (mediaList != null ? mediaList.size() : "null"));
|
||||||
|
|
||||||
|
if (mediaList != null) {
|
||||||
|
// 只添加图片,过滤掉视频
|
||||||
|
for (cn.hugh.bz.gk2.model.WallpaperMedia media : mediaList) {
|
||||||
|
if (!media.isVideo()) {
|
||||||
|
allImages.add(media.getUri());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加单独选择的图片
|
||||||
|
List<String> imageUris = activeAlbum.getImageUris();
|
||||||
|
logger.log(TAG, "loadAlbumData: imageUris=" + (imageUris != null ? imageUris.size() : "null"));
|
||||||
|
|
||||||
|
if (imageUris != null) {
|
||||||
|
allImages.addAll(imageUris);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.log(TAG, "loadAlbumData: total images=" + allImages.size());
|
||||||
|
|
||||||
|
// 更新UI
|
||||||
|
tvAlbumName.setText(activeAlbum.getName());
|
||||||
|
tvImageCount.setText(allImages.size() + " 张图片");
|
||||||
|
|
||||||
|
// 根据图片数量调整按钮
|
||||||
|
updateButtonStates();
|
||||||
|
logger.log(TAG, "loadAlbumData: done");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(TAG, "loadAlbumData: ERROR", e);
|
||||||
|
Log.e(TAG, "loadAlbumData error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateButtonStates() {
|
||||||
|
int count = allImages.size();
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
disableAllButtons();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 10张按钮
|
||||||
|
if (count >= 10) {
|
||||||
|
btn10.setEnabled(true);
|
||||||
|
btn10.setText("10 张");
|
||||||
|
} else {
|
||||||
|
btn10.setEnabled(true);
|
||||||
|
btn10.setText(count + " 张");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 20张按钮
|
||||||
|
if (count >= 20) {
|
||||||
|
btn20.setEnabled(true);
|
||||||
|
btn20.setText("20 张");
|
||||||
|
} else if (count > 10) {
|
||||||
|
btn20.setEnabled(true);
|
||||||
|
btn20.setText(count + " 张");
|
||||||
|
} else {
|
||||||
|
btn20.setEnabled(false);
|
||||||
|
btn20.setText("20 张");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 50张按钮
|
||||||
|
if (count >= 50) {
|
||||||
|
btn50.setEnabled(true);
|
||||||
|
btn50.setText("50 张");
|
||||||
|
} else if (count > 20) {
|
||||||
|
btn50.setEnabled(true);
|
||||||
|
btn50.setText(count + " 张");
|
||||||
|
} else {
|
||||||
|
btn50.setEnabled(false);
|
||||||
|
btn50.setText("50 张");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 全部按钮
|
||||||
|
btnAll.setEnabled(true);
|
||||||
|
btnAll.setText("全部 (" + count + " 张)");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disableAllButtons() {
|
||||||
|
btn10.setEnabled(false);
|
||||||
|
btn20.setEnabled(false);
|
||||||
|
btn50.setEnabled(false);
|
||||||
|
btnAll.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupButtons() {
|
||||||
|
btn10.setOnClickListener(v -> startSlideshow(Math.min(10, allImages.size())));
|
||||||
|
btn20.setOnClickListener(v -> startSlideshow(Math.min(20, allImages.size())));
|
||||||
|
btn50.setOnClickListener(v -> startSlideshow(Math.min(50, allImages.size())));
|
||||||
|
btnAll.setOnClickListener(v -> startSlideshow(allImages.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startSlideshow(int count) {
|
||||||
|
logger.log(TAG, "startSlideshow: count=" + count);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (allImages == null || allImages.isEmpty()) {
|
||||||
|
logger.log(TAG, "startSlideshow: no images available");
|
||||||
|
Toast.makeText(requireContext(), "没有可用的图片", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.log(TAG, "startSlideshow: allImages.size=" + allImages.size());
|
||||||
|
|
||||||
|
// 随机选择图片
|
||||||
|
List<String> selectedImages = new ArrayList<>(allImages);
|
||||||
|
Collections.shuffle(selectedImages);
|
||||||
|
|
||||||
|
if (count < selectedImages.size()) {
|
||||||
|
selectedImages = new ArrayList<>(selectedImages.subList(0, count));
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.log(TAG, "startSlideshow: selectedImages.size=" + selectedImages.size());
|
||||||
|
|
||||||
|
// 启动播放器
|
||||||
|
Intent intent = new Intent(requireContext(), SlideshowPlayerActivity.class);
|
||||||
|
intent.putStringArrayListExtra("image_uris", new ArrayList<>(selectedImages));
|
||||||
|
logger.log(TAG, "startSlideshow: starting activity");
|
||||||
|
startActivity(intent);
|
||||||
|
logger.log(TAG, "startSlideshow: activity started");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(TAG, "startSlideshow: ERROR", e);
|
||||||
|
Log.e(TAG, "startSlideshow error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
// 重新加载数据,以防相册内容有变化
|
||||||
|
loadAlbumData();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,428 @@
|
|||||||
|
package cn.hugh.bz.gk2.ui;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
|
||||||
|
import com.google.android.material.button.MaterialButton;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import cn.hugh.bz.gk2.R;
|
||||||
|
import cn.hugh.bz.gk2.utils.FileLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 幻灯片播放器 Activity
|
||||||
|
* 全屏播放图片,支持播放控制、间隔调整和缩放模式切换
|
||||||
|
*/
|
||||||
|
public class SlideshowPlayerActivity extends AppCompatActivity {
|
||||||
|
private static final String TAG = "SlideshowPlayerActivity";
|
||||||
|
private static final int MIN_INTERVAL = 3000; // 3秒
|
||||||
|
private static final int MAX_INTERVAL = 15000; // 15秒
|
||||||
|
private static final int CONTROL_HIDE_DELAY = 3000; // 3秒后隐藏控制面板
|
||||||
|
private static final int CROSSFADE_DURATION = 500; // 淡入淡出时长
|
||||||
|
|
||||||
|
private ImageView ivSlideshow;
|
||||||
|
private ImageView ivSlideshowBack;
|
||||||
|
private View controlPanel;
|
||||||
|
private TextView tvProgress;
|
||||||
|
private SeekBar seekBarInterval;
|
||||||
|
private TextView tvIntervalLabel;
|
||||||
|
private MaterialButton btnPrevious;
|
||||||
|
private MaterialButton btnPlayPause;
|
||||||
|
private MaterialButton btnNext;
|
||||||
|
private MaterialButton btnScaleMode;
|
||||||
|
private MaterialButton btnExit;
|
||||||
|
private View endScreen;
|
||||||
|
private MaterialButton btnReplay;
|
||||||
|
private MaterialButton btnExitEnd;
|
||||||
|
|
||||||
|
private ArrayList<String> imageUris;
|
||||||
|
private int currentIndex = 0;
|
||||||
|
private boolean isPlaying = true;
|
||||||
|
private int currentInterval = 5000; // 默认5秒
|
||||||
|
private boolean isFullScreen = false; // false=适应屏幕(fitCenter), true=填充屏幕(centerCrop)
|
||||||
|
private boolean useFrontImage = true; // 用于交替显示两个 ImageView
|
||||||
|
|
||||||
|
private Handler playHandler;
|
||||||
|
private Runnable playRunnable;
|
||||||
|
private Handler hideHandler;
|
||||||
|
private Runnable hideRunnable;
|
||||||
|
private FileLogger logger;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
logger = FileLogger.getInstance(this);
|
||||||
|
logger.log(TAG, "onCreate: start");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 设置全屏
|
||||||
|
getWindow().setFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||||
|
);
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(
|
||||||
|
View.SYSTEM_UI_FLAG_FULLSCREEN |
|
||||||
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
||||||
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||||
|
);
|
||||||
|
logger.log(TAG, "onCreate: fullscreen set");
|
||||||
|
|
||||||
|
setContentView(R.layout.activity_slideshow_player);
|
||||||
|
logger.log(TAG, "onCreate: setContentView done");
|
||||||
|
|
||||||
|
// 获取图片列表
|
||||||
|
imageUris = getIntent().getStringArrayListExtra("image_uris");
|
||||||
|
logger.log(TAG, "onCreate: imageUris=" + (imageUris != null ? imageUris.size() : "null"));
|
||||||
|
|
||||||
|
if (imageUris == null || imageUris.isEmpty()) {
|
||||||
|
logger.log(TAG, "onCreate: no images, finishing");
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
initViews();
|
||||||
|
logger.log(TAG, "onCreate: initViews done");
|
||||||
|
|
||||||
|
setupHandlers();
|
||||||
|
logger.log(TAG, "onCreate: setupHandlers done");
|
||||||
|
|
||||||
|
setupControls();
|
||||||
|
logger.log(TAG, "onCreate: setupControls done");
|
||||||
|
|
||||||
|
loadImage(currentIndex, false);
|
||||||
|
logger.log(TAG, "onCreate: loadImage done");
|
||||||
|
|
||||||
|
startAutoPlay();
|
||||||
|
logger.log(TAG, "onCreate: startAutoPlay done");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(TAG, "onCreate: ERROR", e);
|
||||||
|
Log.e(TAG, "onCreate error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initViews() {
|
||||||
|
ivSlideshow = findViewById(R.id.ivSlideshow);
|
||||||
|
ivSlideshowBack = findViewById(R.id.ivSlideshowBack);
|
||||||
|
controlPanel = findViewById(R.id.controlPanel);
|
||||||
|
tvProgress = findViewById(R.id.tvProgress);
|
||||||
|
seekBarInterval = findViewById(R.id.seekBarInterval);
|
||||||
|
tvIntervalLabel = findViewById(R.id.tvIntervalLabel);
|
||||||
|
btnPrevious = findViewById(R.id.btnPrevious);
|
||||||
|
btnPlayPause = findViewById(R.id.btnPlayPause);
|
||||||
|
btnNext = findViewById(R.id.btnNext);
|
||||||
|
btnScaleMode = findViewById(R.id.btnScaleMode);
|
||||||
|
btnExit = findViewById(R.id.btnExit);
|
||||||
|
endScreen = findViewById(R.id.endScreen);
|
||||||
|
btnReplay = findViewById(R.id.btnReplay);
|
||||||
|
btnExitEnd = findViewById(R.id.btnExitEnd);
|
||||||
|
|
||||||
|
// 点击屏幕显示/隐藏控制面板
|
||||||
|
ivSlideshow.setOnClickListener(v -> toggleControlPanel());
|
||||||
|
ivSlideshowBack.setOnClickListener(v -> toggleControlPanel());
|
||||||
|
|
||||||
|
// 更新缩放模式图标
|
||||||
|
updateScaleModeIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupHandlers() {
|
||||||
|
playHandler = new Handler(Looper.getMainLooper());
|
||||||
|
playRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (isPlaying) {
|
||||||
|
showNext();
|
||||||
|
playHandler.postDelayed(this, currentInterval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
hideHandler = new Handler(Looper.getMainLooper());
|
||||||
|
hideRunnable = () -> hideControlPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupControls() {
|
||||||
|
// 间隔滑块
|
||||||
|
seekBarInterval.setMax((MAX_INTERVAL - MIN_INTERVAL) / 1000);
|
||||||
|
seekBarInterval.setProgress((currentInterval - MIN_INTERVAL) / 1000);
|
||||||
|
updateIntervalLabel();
|
||||||
|
|
||||||
|
seekBarInterval.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
currentInterval = MIN_INTERVAL + (progress * 1000);
|
||||||
|
updateIntervalLabel();
|
||||||
|
resetHideTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
|
resetHideTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
|
resetHideTimer();
|
||||||
|
// 重启自动播放
|
||||||
|
if (isPlaying) {
|
||||||
|
stopAutoPlay();
|
||||||
|
startAutoPlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 控制按钮
|
||||||
|
btnPrevious.setOnClickListener(v -> {
|
||||||
|
showPrevious();
|
||||||
|
resetHideTimer();
|
||||||
|
});
|
||||||
|
|
||||||
|
btnPlayPause.setOnClickListener(v -> {
|
||||||
|
togglePlayPause();
|
||||||
|
resetHideTimer();
|
||||||
|
});
|
||||||
|
|
||||||
|
btnNext.setOnClickListener(v -> {
|
||||||
|
showNext();
|
||||||
|
resetHideTimer();
|
||||||
|
});
|
||||||
|
|
||||||
|
btnScaleMode.setOnClickListener(v -> {
|
||||||
|
toggleScaleMode();
|
||||||
|
resetHideTimer();
|
||||||
|
});
|
||||||
|
|
||||||
|
btnExit.setOnClickListener(v -> finish());
|
||||||
|
|
||||||
|
// 播放结束按钮
|
||||||
|
btnReplay.setOnClickListener(v -> replay());
|
||||||
|
btnExitEnd.setOnClickListener(v -> finish());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载图片,支持淡入淡出动画
|
||||||
|
* @param index 图片索引
|
||||||
|
* @param animate 是否使用动画
|
||||||
|
*/
|
||||||
|
private void loadImage(int index, boolean animate) {
|
||||||
|
if (index < 0 || index >= imageUris.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String uri = imageUris.get(index);
|
||||||
|
ImageView.ScaleType scaleType = isFullScreen ? ImageView.ScaleType.CENTER_CROP : ImageView.ScaleType.FIT_CENTER;
|
||||||
|
|
||||||
|
if (animate) {
|
||||||
|
// 使用双 ImageView 实现淡入淡出
|
||||||
|
ImageView frontView = useFrontImage ? ivSlideshow : ivSlideshowBack;
|
||||||
|
ImageView backView = useFrontImage ? ivSlideshowBack : ivSlideshow;
|
||||||
|
|
||||||
|
// 设置缩放模式
|
||||||
|
frontView.setScaleType(scaleType);
|
||||||
|
backView.setScaleType(scaleType);
|
||||||
|
|
||||||
|
// 将新图片加载到后面的 ImageView
|
||||||
|
Glide.with(this)
|
||||||
|
.load(uri)
|
||||||
|
.into(backView);
|
||||||
|
|
||||||
|
// 淡入淡出动画
|
||||||
|
backView.setAlpha(0f);
|
||||||
|
backView.animate()
|
||||||
|
.alpha(1f)
|
||||||
|
.setDuration(CROSSFADE_DURATION)
|
||||||
|
.start();
|
||||||
|
|
||||||
|
frontView.animate()
|
||||||
|
.alpha(0f)
|
||||||
|
.setDuration(CROSSFADE_DURATION)
|
||||||
|
.withEndAction(() -> {
|
||||||
|
// 动画结束后清除前面的图片
|
||||||
|
frontView.setImageDrawable(null);
|
||||||
|
frontView.setAlpha(1f);
|
||||||
|
})
|
||||||
|
.start();
|
||||||
|
|
||||||
|
// 切换前后
|
||||||
|
useFrontImage = !useFrontImage;
|
||||||
|
} else {
|
||||||
|
// 首次加载,不使用动画
|
||||||
|
ivSlideshow.setScaleType(scaleType);
|
||||||
|
ivSlideshowBack.setScaleType(scaleType);
|
||||||
|
|
||||||
|
Glide.with(this)
|
||||||
|
.load(uri)
|
||||||
|
.into(ivSlideshow);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProgress();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateProgress() {
|
||||||
|
tvProgress.setText((currentIndex + 1) + " / " + imageUris.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateIntervalLabel() {
|
||||||
|
int seconds = currentInterval / 1000;
|
||||||
|
tvIntervalLabel.setText(seconds + " 秒");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showNext() {
|
||||||
|
currentIndex++;
|
||||||
|
if (currentIndex >= imageUris.size()) {
|
||||||
|
// 播放结束
|
||||||
|
stopAutoPlay();
|
||||||
|
showEndScreen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loadImage(currentIndex, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPrevious() {
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
currentIndex--;
|
||||||
|
loadImage(currentIndex, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void togglePlayPause() {
|
||||||
|
if (isPlaying) {
|
||||||
|
pause();
|
||||||
|
} else {
|
||||||
|
resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pause() {
|
||||||
|
isPlaying = false;
|
||||||
|
stopAutoPlay();
|
||||||
|
btnPlayPause.setIcon(getDrawable(android.R.drawable.ic_media_play));
|
||||||
|
// 暂停时不隐藏控制面板
|
||||||
|
hideHandler.removeCallbacks(hideRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resume() {
|
||||||
|
isPlaying = true;
|
||||||
|
startAutoPlay();
|
||||||
|
btnPlayPause.setIcon(getDrawable(android.R.drawable.ic_media_pause));
|
||||||
|
resetHideTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startAutoPlay() {
|
||||||
|
playHandler.postDelayed(playRunnable, currentInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopAutoPlay() {
|
||||||
|
playHandler.removeCallbacks(playRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切换缩放模式
|
||||||
|
*/
|
||||||
|
private void toggleScaleMode() {
|
||||||
|
isFullScreen = !isFullScreen;
|
||||||
|
updateScaleModeIcon();
|
||||||
|
|
||||||
|
// 更新当前图片的缩放模式
|
||||||
|
ImageView.ScaleType scaleType = isFullScreen ? ImageView.ScaleType.CENTER_CROP : ImageView.ScaleType.FIT_CENTER;
|
||||||
|
ivSlideshow.setScaleType(scaleType);
|
||||||
|
ivSlideshowBack.setScaleType(scaleType);
|
||||||
|
|
||||||
|
// 重新加载当前图片以应用新的缩放模式
|
||||||
|
loadImage(currentIndex, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateScaleModeIcon() {
|
||||||
|
// 使用不同图标表示当前模式
|
||||||
|
if (isFullScreen) {
|
||||||
|
// 当前是填充模式,点击切换到适应模式
|
||||||
|
btnScaleMode.setIcon(getDrawable(android.R.drawable.ic_menu_crop));
|
||||||
|
} else {
|
||||||
|
// 当前是适应模式,点击切换到填充模式
|
||||||
|
btnScaleMode.setIcon(getDrawable(android.R.drawable.ic_menu_view));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleControlPanel() {
|
||||||
|
if (controlPanel.getVisibility() == View.VISIBLE) {
|
||||||
|
hideControlPanel();
|
||||||
|
} else {
|
||||||
|
showControlPanel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showControlPanel() {
|
||||||
|
controlPanel.setVisibility(View.VISIBLE);
|
||||||
|
controlPanel.setAlpha(0f);
|
||||||
|
controlPanel.setTranslationY(100f);
|
||||||
|
controlPanel.animate()
|
||||||
|
.alpha(1f)
|
||||||
|
.translationY(0f)
|
||||||
|
.setDuration(300)
|
||||||
|
.start();
|
||||||
|
|
||||||
|
if (isPlaying) {
|
||||||
|
resetHideTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideControlPanel() {
|
||||||
|
controlPanel.animate()
|
||||||
|
.alpha(0f)
|
||||||
|
.translationY(100f)
|
||||||
|
.setDuration(300)
|
||||||
|
.withEndAction(() -> controlPanel.setVisibility(View.GONE))
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetHideTimer() {
|
||||||
|
hideHandler.removeCallbacks(hideRunnable);
|
||||||
|
if (isPlaying) {
|
||||||
|
hideHandler.postDelayed(hideRunnable, CONTROL_HIDE_DELAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showEndScreen() {
|
||||||
|
endScreen.setVisibility(View.VISIBLE);
|
||||||
|
endScreen.setAlpha(0f);
|
||||||
|
endScreen.animate()
|
||||||
|
.alpha(1f)
|
||||||
|
.setDuration(300)
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void replay() {
|
||||||
|
currentIndex = 0;
|
||||||
|
loadImage(currentIndex, false);
|
||||||
|
endScreen.setVisibility(View.GONE);
|
||||||
|
isPlaying = true;
|
||||||
|
btnPlayPause.setIcon(getDrawable(android.R.drawable.ic_media_pause));
|
||||||
|
startAutoPlay();
|
||||||
|
resetHideTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
stopAutoPlay();
|
||||||
|
hideHandler.removeCallbacks(hideRunnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,9 +22,9 @@ public class ViewPagerAdapter extends FragmentStateAdapter {
|
|||||||
case 0:
|
case 0:
|
||||||
return new HomeFragment();
|
return new HomeFragment();
|
||||||
case 1:
|
case 1:
|
||||||
return new CurrentWallpaperFragment();
|
|
||||||
case 2:
|
|
||||||
return new AlbumManagementFragment();
|
return new AlbumManagementFragment();
|
||||||
|
case 2:
|
||||||
|
return new SlideshowFragment();
|
||||||
case 3:
|
case 3:
|
||||||
return new WallpaperHistoryFragment();
|
return new WallpaperHistoryFragment();
|
||||||
case 4:
|
case 4:
|
||||||
@@ -38,4 +38,4 @@ public class ViewPagerAdapter extends FragmentStateAdapter {
|
|||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return NUM_PAGES;
|
return NUM_PAGES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@ import android.content.Intent;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.DocumentsContract;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -81,6 +81,12 @@ public class WallpaperHistoryFragment extends Fragment {
|
|||||||
public void onItemClick(WallpaperHistory history) {
|
public void onItemClick(WallpaperHistory history) {
|
||||||
openAlbumForHistory(history);
|
openAlbumForHistory(history);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReuseClick(WallpaperHistory history) {
|
||||||
|
// 跳转到相册管理页面并定位到该相册
|
||||||
|
jumpToAlbum(history.getAlbumId());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDelete(WallpaperHistory history) {
|
public void onDelete(WallpaperHistory history) {
|
||||||
@@ -93,6 +99,18 @@ public class WallpaperHistoryFragment extends Fragment {
|
|||||||
btnClearHistory.setOnClickListener(v -> confirmClearHistory());
|
btnClearHistory.setOnClickListener(v -> confirmClearHistory());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void jumpToAlbum(String albumId) {
|
||||||
|
if (albumId == null) return;
|
||||||
|
|
||||||
|
// 设置目标相册ID(需要在 AlbumManagementFragment 中处理)
|
||||||
|
AlbumManagementFragment.targetAlbumId = albumId;
|
||||||
|
|
||||||
|
// 切换到相册页面 (Index 1)
|
||||||
|
if (getActivity() instanceof MainActivity) {
|
||||||
|
((MainActivity) getActivity()).switchToPage(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadHistory() {
|
private void loadHistory() {
|
||||||
historyList = historyManager.loadHistory();
|
historyList = historyManager.loadHistory();
|
||||||
adapter.updateHistory(historyList);
|
adapter.updateHistory(historyList);
|
||||||
@@ -115,13 +133,30 @@ public class WallpaperHistoryFragment extends Fragment {
|
|||||||
* 点击历史记录,使用系统相册/图片查看器打开
|
* 点击历史记录,使用系统相册/图片查看器打开
|
||||||
*/
|
*/
|
||||||
private void openAlbumForHistory(WallpaperHistory history) {
|
private void openAlbumForHistory(WallpaperHistory history) {
|
||||||
|
if (history == null || history.getUri() == null) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Uri uri = Uri.parse(history.getUri());
|
Uri uri = Uri.parse(history.getUri());
|
||||||
|
|
||||||
|
// 简单检查 scheme,如果是 file 且没有配置 FileProvider,会导致崩溃
|
||||||
|
// 这里做一个简单的保护,拦截 file:// URI
|
||||||
|
if ("file".equals(uri.getScheme())) {
|
||||||
|
Toast.makeText(requireContext(), "不支持直接打开文件路径", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(uri, "image/*");
|
intent.setDataAndType(uri, "image/*");
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // 虽然不是必须,但有些情况下有帮助
|
||||||
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
} catch (android.content.ActivityNotFoundException e) {
|
||||||
|
Toast.makeText(requireContext(), "未找到可打开图片的应", Toast.LENGTH_SHORT).show();
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
Toast.makeText(requireContext(), "没有权限打开此图片", Toast.LENGTH_SHORT).show();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
android.util.Log.e("HistoryFragment", "Error opening image", e);
|
||||||
Toast.makeText(requireContext(), "无法打开图片", Toast.LENGTH_SHORT).show();
|
Toast.makeText(requireContext(), "无法打开图片", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,43 +246,52 @@ public class WallpaperHistoryFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class HistoryViewHolder extends RecyclerView.ViewHolder {
|
class HistoryViewHolder extends RecyclerView.ViewHolder {
|
||||||
private final android.widget.ImageView ivThumbnail;
|
private final ImageView ivThumbnail;
|
||||||
private final TextView tvAlbumName;
|
private final TextView tvAlbumName;
|
||||||
private final TextView tvTimestamp;
|
private final TextView tvTimestamp;
|
||||||
private final MaterialButton btnDelete;
|
private final TextView btnReuse; // Changed to TextView for click area
|
||||||
|
private final ImageView btnDelete; // Changed to ImageView
|
||||||
|
|
||||||
public HistoryViewHolder(@NonNull View itemView) {
|
public HistoryViewHolder(@NonNull View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ivThumbnail = itemView.findViewById(R.id.ivThumbnail);
|
ivThumbnail = itemView.findViewById(R.id.ivThumbnail);
|
||||||
tvAlbumName = itemView.findViewById(R.id.tvAlbumName);
|
tvAlbumName = itemView.findViewById(R.id.tvAlbumName);
|
||||||
tvTimestamp = itemView.findViewById(R.id.tvTimestamp);
|
tvTimestamp = itemView.findViewById(R.id.tvTimestamp);
|
||||||
|
btnReuse = itemView.findViewById(R.id.btnReuse);
|
||||||
btnDelete = itemView.findViewById(R.id.btnDelete);
|
btnDelete = itemView.findViewById(R.id.btnDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bind(WallpaperHistory history) {
|
public void bind(WallpaperHistory history) {
|
||||||
// 加载缩略图
|
// 使用 Glide 加载缩略图
|
||||||
Bitmap thumbnail = historyManager.loadThumbnail(history.getThumbnailPath());
|
com.bumptech.glide.Glide.with(context)
|
||||||
if (thumbnail != null) {
|
.load(history.getThumbnailPath()) // Glide 自动处理文件路径
|
||||||
ivThumbnail.setImageBitmap(thumbnail);
|
.placeholder(R.drawable.ic_image) // 需要一个占位图
|
||||||
} else {
|
.error(R.drawable.ic_image)
|
||||||
// 显示占位符
|
.centerCrop()
|
||||||
ivThumbnail.setImageDrawable(null);
|
.transition(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade())
|
||||||
}
|
.into(ivThumbnail);
|
||||||
|
|
||||||
// 相册名称
|
// 相册名称
|
||||||
tvAlbumName.setText(history.getAlbumName());
|
tvAlbumName.setText(history.getAlbumName());
|
||||||
|
|
||||||
// 时间戳格式化
|
// 时间戳格式化
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm", Locale.getDefault());
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.getDefault());
|
||||||
String timestamp = sdf.format(new Date(history.getTimestamp()));
|
String timestamp = sdf.format(new Date(history.getTimestamp()));
|
||||||
tvTimestamp.setText(timestamp);
|
tvTimestamp.setText(timestamp);
|
||||||
|
|
||||||
// 卡片点击事件
|
// 卡片点击事件 (预览大图)
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onItemClick(history);
|
callback.onItemClick(history);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 跳转相册按钮
|
||||||
|
btnReuse.setOnClickListener(v -> {
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onReuseClick(history);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 删除按钮
|
// 删除按钮
|
||||||
btnDelete.setOnClickListener(v -> {
|
btnDelete.setOnClickListener(v -> {
|
||||||
@@ -260,7 +304,8 @@ public class WallpaperHistoryFragment extends Fragment {
|
|||||||
|
|
||||||
interface HistoryCallback {
|
interface HistoryCallback {
|
||||||
void onItemClick(WallpaperHistory history);
|
void onItemClick(WallpaperHistory history);
|
||||||
|
void onReuseClick(WallpaperHistory history);
|
||||||
void onDelete(WallpaperHistory history);
|
void onDelete(WallpaperHistory history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,8 @@ public class MediaScanner {
|
|||||||
// LRU 内存缓存,避免重复扫描
|
// LRU 内存缓存,避免重复扫描
|
||||||
private final LruCache<String, List<WallpaperMedia>> memoryCache;
|
private final LruCache<String, List<WallpaperMedia>> memoryCache;
|
||||||
private final java.util.Map<String, Long> lastScanTime = new java.util.HashMap<>();
|
private final java.util.Map<String, Long> lastScanTime = new java.util.HashMap<>();
|
||||||
private static final long CACHE_DURATION = 5000; // 5秒内不重复扫描
|
// 优化:延长缓存时间到 30 分钟,大幅减少大文件夹的扫描次数
|
||||||
|
private static final long CACHE_DURATION = 30 * 60 * 1000; // 30分钟内不重复扫描
|
||||||
|
|
||||||
// 单例 Random 实例,避免快速连续调用产生相同随机数
|
// 单例 Random 实例,避免快速连续调用产生相同随机数
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
@@ -694,4 +695,87 @@ public class MediaScanner {
|
|||||||
clearCache(folderPath);
|
clearCache(folderPath);
|
||||||
return scanFolder(folderPath);
|
return scanFolder(folderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 智能扫描:只在文件夹有变化时才重新扫描
|
||||||
|
* 通过快速检查文件数量来判断文件夹是否变化,避免不必要的完整扫描
|
||||||
|
*
|
||||||
|
* @param folderPath 文件夹路径
|
||||||
|
* @return 媒体列表
|
||||||
|
*/
|
||||||
|
public List<WallpaperMedia> smartScanFolder(String folderPath) {
|
||||||
|
// 1. 获取当前缓存
|
||||||
|
List<WallpaperMedia> cached = memoryCache.get(folderPath);
|
||||||
|
|
||||||
|
if (cached != null && !cached.isEmpty()) {
|
||||||
|
// 2. 快速检查文件夹是否有变化(只统计文件数量,不加载完整信息)
|
||||||
|
int currentFileCount = getFileCount(folderPath);
|
||||||
|
|
||||||
|
if (currentFileCount == cached.size()) {
|
||||||
|
// 文件数量没变,使用缓存
|
||||||
|
Log.i(TAG, "Folder unchanged, using cache: " + folderPath + ", count=" + cached.size());
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文件数量变化,记录日志
|
||||||
|
Log.i(TAG, "Folder changed: cached=" + cached.size() +
|
||||||
|
", current=" + currentFileCount + ", path=" + folderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 文件夹有变化或无缓存,重新扫描
|
||||||
|
Log.i(TAG, "Rescanning folder due to changes: " + folderPath);
|
||||||
|
return rescanFolder(folderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快速获取文件夹中的媒体文件数量(不加载完整信息)
|
||||||
|
* 只统计文件数量,不读取文件详细信息,速度比完整扫描快 10-100 倍
|
||||||
|
*
|
||||||
|
* @param folderPath 文件夹路径
|
||||||
|
* @return 媒体文件数量,-1 表示出错
|
||||||
|
*/
|
||||||
|
private int getFileCount(String folderPath) {
|
||||||
|
try {
|
||||||
|
if (folderPath.startsWith("content://")) {
|
||||||
|
// DocumentFile 方式
|
||||||
|
Uri folderUri = Uri.parse(folderPath);
|
||||||
|
DocumentFile folder = DocumentFile.fromTreeUri(context, folderUri);
|
||||||
|
|
||||||
|
if (folder != null && folder.exists()) {
|
||||||
|
DocumentFile[] files = folder.listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
// 只统计媒体文件
|
||||||
|
int count = 0;
|
||||||
|
for (DocumentFile file : files) {
|
||||||
|
if (file.isFile() && isMediaFile(file)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// File 方式
|
||||||
|
File folder = new File(folderPath);
|
||||||
|
|
||||||
|
if (folder.exists() && folder.isDirectory()) {
|
||||||
|
File[] files = folder.listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
// 只统计媒体文件
|
||||||
|
int count = 0;
|
||||||
|
for (File file : files) {
|
||||||
|
if (file.isFile() && isMediaFile(file)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Error getting file count: " + folderPath, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1; // 出错返回 -1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -121,6 +121,7 @@ public class AutoWallpaperService extends WallpaperService {
|
|||||||
private final cn.hugh.bz.gk2.utils.FileLogger fileLogger;
|
private final cn.hugh.bz.gk2.utils.FileLogger fileLogger;
|
||||||
private final java.util.concurrent.ExecutorService backgroundExecutor; // 后台线程执行器
|
private final java.util.concurrent.ExecutorService backgroundExecutor; // 后台线程执行器
|
||||||
private final VideoPlayer videoPlayer;
|
private final VideoPlayer videoPlayer;
|
||||||
|
private final MediaScanner mediaScanner; // 优化:单例 MediaScanner,避免重复创建和充分利用缓存
|
||||||
|
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
@@ -168,6 +169,8 @@ public class AutoWallpaperService extends WallpaperService {
|
|||||||
t.setPriority(Thread.MIN_PRIORITY);
|
t.setPriority(Thread.MIN_PRIORITY);
|
||||||
return t;
|
return t;
|
||||||
});
|
});
|
||||||
|
// 优化:创建单例 MediaScanner,充分利用缓存
|
||||||
|
this.mediaScanner = new MediaScanner(AutoWallpaperService.this);
|
||||||
this.videoPlayer = new VideoPlayer();
|
this.videoPlayer = new VideoPlayer();
|
||||||
this.videoPlayer.setCallback(new VideoPlayer.VideoPlayerCallback() {
|
this.videoPlayer.setCallback(new VideoPlayer.VideoPlayerCallback() {
|
||||||
@Override
|
@Override
|
||||||
@@ -658,12 +661,12 @@ public class AutoWallpaperService extends WallpaperService {
|
|||||||
fileLogger.log(TAG, folderLog);
|
fileLogger.log(TAG, folderLog);
|
||||||
|
|
||||||
if (folders != null && !folders.isEmpty()) {
|
if (folders != null && !folders.isEmpty()) {
|
||||||
MediaScanner scanner = new MediaScanner(AutoWallpaperService.this);
|
// 优化:使用单例 MediaScanner,避免重复创建,充分利用缓存
|
||||||
for (String folder : folders) {
|
for (String folder : folders) {
|
||||||
String scanMsg = "Scanning folder: " + folder;
|
String scanMsg = "Scanning folder: " + folder;
|
||||||
Log.i(TAG, scanMsg);
|
Log.i(TAG, scanMsg);
|
||||||
fileLogger.log(TAG, scanMsg);
|
fileLogger.log(TAG, scanMsg);
|
||||||
List<WallpaperMedia> folderMedia = scanner.scanFolder(folder);
|
List<WallpaperMedia> folderMedia = mediaScanner.scanFolder(folder);
|
||||||
String scanResult = "Folder scan result: " + folderMedia.size() + " items";
|
String scanResult = "Folder scan result: " + folderMedia.size() + " items";
|
||||||
Log.i(TAG, scanResult);
|
Log.i(TAG, scanResult);
|
||||||
fileLogger.log(TAG, scanResult);
|
fileLogger.log(TAG, scanResult);
|
||||||
@@ -963,6 +966,10 @@ public class AutoWallpaperService extends WallpaperService {
|
|||||||
if (backgroundExecutor != null && !backgroundExecutor.isShutdown()) {
|
if (backgroundExecutor != null && !backgroundExecutor.isShutdown()) {
|
||||||
backgroundExecutor.shutdownNow();
|
backgroundExecutor.shutdownNow();
|
||||||
}
|
}
|
||||||
|
// 优化:关闭 MediaScanner,释放资源
|
||||||
|
if (mediaScanner != null) {
|
||||||
|
mediaScanner.shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawPlaceholder(Canvas canvas) {
|
private void drawPlaceholder(Canvas canvas) {
|
||||||
@@ -1036,7 +1043,7 @@ public class AutoWallpaperService extends WallpaperService {
|
|||||||
|
|
||||||
// 创建通知
|
// 创建通知
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(AutoWallpaperService.this, channelId)
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(AutoWallpaperService.this, channelId)
|
||||||
.setSmallIcon(android.R.drawable.ic_menu_gallery)
|
.setSmallIcon(cn.hugh.bz.gk2.R.drawable.ic_notification)
|
||||||
.setContentTitle("打开固定壁纸")
|
.setContentTitle("打开固定壁纸")
|
||||||
.setContentText("点击在系统相册中查看固定壁纸")
|
.setContentText("点击在系统相册中查看固定壁纸")
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class WallpaperHistoryManager {
|
|||||||
private static final String PREFS_NAME = "wallpaper_history_prefs";
|
private static final String PREFS_NAME = "wallpaper_history_prefs";
|
||||||
private static final String KEY_HISTORY = "history";
|
private static final String KEY_HISTORY = "history";
|
||||||
private static final int MAX_HISTORY_COUNT = 50;
|
private static final int MAX_HISTORY_COUNT = 50;
|
||||||
private static final int THUMBNAIL_SIZE = 200;
|
private static final int THUMBNAIL_SIZE = 500;
|
||||||
private static final int THUMBNAIL_QUALITY = 85;
|
private static final int THUMBNAIL_QUALITY = 85;
|
||||||
|
|
||||||
private final SharedPreferences prefs;
|
private final SharedPreferences prefs;
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
|
||||||
|
<!-- Photo Frame/Mountain Icon -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:pathData="M10,8v8l5,-4 -5,-4zM19,3H5C3.9,3 3,3.9 3,5v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5C21,3.9 20.1,3 19,3zM19,19H5V5h14V19z"/>
|
||||||
|
</vector>
|
||||||
@@ -1,340 +1,362 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/background">
|
android:background="@color/bg_primary">
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:background="@color/bg_primary"
|
||||||
android:padding="16dp">
|
app:elevation="0dp">
|
||||||
|
|
||||||
<!-- 标题栏 -->
|
<androidx.appcompat.widget.Toolbar
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="?attr/actionBarSize">
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageView
|
||||||
android:id="@+id/btnBack"
|
android:id="@+id/btnBack"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
android:padding="12dp"
|
||||||
android:src="@drawable/ic_back"
|
android:src="@drawable/ic_back"
|
||||||
android:contentDescription="返回"
|
app:tint="@color/text_primary"
|
||||||
app:tint="@color/text_primary" />
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="返回" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvTitle"
|
android:id="@+id/tvTitle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_gravity="center"
|
||||||
android:text="新建相册"
|
android:text="编辑相册"
|
||||||
android:textSize="20sp"
|
android:textSize="18sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/text_primary"
|
android:textColor="@color/text_primary" />
|
||||||
android:layout_marginStart="8dp" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btnSave"
|
android:id="@+id/btnSave"
|
||||||
|
style="@style/Widget.Material3.Button.TextButton"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="40dp"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
android:text="保存"
|
android:text="保存"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent_primary" />
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.Toolbar>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:paddingBottom="40dp">
|
||||||
|
|
||||||
|
<!-- Album Name Input -->
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="相册名称"
|
||||||
|
app:boxBackgroundMode="outline"
|
||||||
|
app:boxCornerRadiusTopStart="12dp"
|
||||||
|
app:boxCornerRadiusTopEnd="12dp"
|
||||||
|
app:boxCornerRadiusBottomStart="12dp"
|
||||||
|
app:boxCornerRadiusBottomEnd="12dp"
|
||||||
|
app:boxStrokeColor="@color/accent_primary"
|
||||||
|
app:hintTextColor="@color/accent_primary"
|
||||||
|
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/etAlbumName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<!-- Media Sources Section -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:text="媒体来源"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
app:cornerRadius="8dp"
|
android:textStyle="bold"
|
||||||
style="@style/Widget.Material3.Button" />
|
android:textColor="@color/accent_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#E0E0E0"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<!-- Folders Header -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="文件夹"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnAddFolder"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:text="添加"
|
||||||
|
android:textSize="12sp"
|
||||||
|
app:icon="@drawable/ic_add"
|
||||||
|
app:iconSize="16dp"
|
||||||
|
app:backgroundTint="@color/sky_blue_container"
|
||||||
|
app:cornerRadius="18dp"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
app:iconTint="@color/sky_blue_primary"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvFolders"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
tools:listitem="@layout/item_folder_card" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="#F0F0F0"
|
||||||
|
android:layout_marginVertical="16dp" />
|
||||||
|
|
||||||
|
<!-- Individual Images Header -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="精选媒体"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnAddImage"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:text="添加"
|
||||||
|
android:textSize="12sp"
|
||||||
|
app:icon="@drawable/ic_add"
|
||||||
|
app:iconSize="16dp"
|
||||||
|
app:backgroundTint="@color/sky_blue_container"
|
||||||
|
app:cornerRadius="18dp"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
app:iconTint="@color/sky_blue_primary"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvImages"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:nestedScrollingEnabled="false"
|
||||||
|
tools:listitem="@layout/item_media" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<!-- Playback Settings Section -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:text="播放设置"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#E0E0E0"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<!-- Play Mode -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="播放顺序"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/rgPlayMode"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_marginTop="8dp">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbSequential"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="顺序播放"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbRandom"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="随机播放"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="#F0F0F0"
|
||||||
|
android:layout_marginVertical="16dp" />
|
||||||
|
|
||||||
|
<!-- Interval -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="自动更换间隔"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvIntervalValue"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="30 分钟"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent_primary" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/seekBarInterval"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:max="180"
|
||||||
|
android:progress="30" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="#F0F0F0"
|
||||||
|
android:layout_marginVertical="16dp" />
|
||||||
|
|
||||||
|
<!-- Change on Return -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="返回桌面时更换"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="每次回到桌面都自动切换"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary"
|
||||||
|
android:layout_marginTop="2dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switchChangeOnReturn"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 相册名称 -->
|
</androidx.core.widget.NestedScrollView>
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:cardElevation="2dp"
|
|
||||||
app:cardCornerRadius="12dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="相册名称"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/etAlbumName"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:hint="请输入相册名称"
|
|
||||||
android:inputType="text"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:textColorHint="@color/text_hint"
|
|
||||||
android:background="@android:color/transparent"
|
|
||||||
android:layout_marginTop="8dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 文件夹选择 -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:cardElevation="2dp"
|
|
||||||
app:cardCornerRadius="12dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="文件夹"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnAddFolder"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:text="+ 添加"
|
|
||||||
android:textSize="12sp"
|
|
||||||
app:icon="@drawable/ic_add"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:iconPadding="4dp"
|
|
||||||
app:cornerRadius="8dp"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rvFolders"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:nestedScrollingEnabled="false"
|
|
||||||
tools:listitem="@layout/item_folder_card" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 单张图片选择 -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:cardElevation="2dp"
|
|
||||||
app:cardCornerRadius="12dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="单张图片"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnAddImage"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:text="+ 添加"
|
|
||||||
android:textSize="12sp"
|
|
||||||
app:icon="@drawable/ic_add"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:iconPadding="4dp"
|
|
||||||
app:cornerRadius="8dp"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rvImages"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:nestedScrollingEnabled="false"
|
|
||||||
tools:listitem="@layout/item_folder_card" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 播放模式 -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:cardElevation="2dp"
|
|
||||||
app:cardCornerRadius="12dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="播放模式"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:layout_marginBottom="12dp" />
|
|
||||||
|
|
||||||
<RadioGroup
|
|
||||||
android:id="@+id/rgPlayMode"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/rbSequential"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="顺序播放"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/rbRandom"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="随机播放"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
</RadioGroup>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 更换间隔 -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
app:cardElevation="2dp"
|
|
||||||
app:cardCornerRadius="12dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="更换间隔"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:id="@+id/seekBarInterval"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:max="180"
|
|
||||||
android:progress="30" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvIntervalValue"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="30 分钟"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@color/text_secondary"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 返回桌面更换 -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:cardElevation="2dp"
|
|
||||||
app:cardCornerRadius="12dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="返回桌面时更换壁纸"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switchChangeOnReturn"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
android:paddingEnd="8dp"
|
android:paddingEnd="8dp"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<!-- 主页 -->
|
<!-- 主页 (仪表盘) -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/navHome"
|
android:id="@+id/navHome"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
@@ -73,38 +73,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 壁纸 -->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/navWallpaper"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:gravity="center"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:background="@drawable/selector_nav_item_bg"
|
|
||||||
android:layout_marginEnd="4dp">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivNavWallpaper"
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:src="@drawable/ic_image"
|
|
||||||
app:tint="@color/selector_nav_item_icon_color" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvNavWallpaper"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="壁纸"
|
|
||||||
android:textSize="10sp"
|
|
||||||
android:textColor="@color/selector_nav_item_text_color"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- 相册 -->
|
<!-- 相册 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/navAlbum"
|
android:id="@+id/navAlbum"
|
||||||
@@ -137,6 +105,38 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 幻灯片 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/navSlideshow"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:background="@drawable/selector_nav_item_bg"
|
||||||
|
android:layout_marginEnd="4dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivNavSlideshow"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:src="@drawable/ic_slideshow"
|
||||||
|
app:tint="@color/selector_nav_item_icon_color" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvNavSlideshow"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="幻灯片"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:textColor="@color/selector_nav_item_text_color"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 历史 -->
|
<!-- 历史 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/navHistory"
|
android:id="@+id/navHistory"
|
||||||
|
|||||||
@@ -0,0 +1,215 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/black">
|
||||||
|
|
||||||
|
<!-- 双 ImageView 用于淡入淡出切换 -->
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivSlideshowBack"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:contentDescription="幻灯片图片背景" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivSlideshow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
android:contentDescription="幻灯片图片" />
|
||||||
|
|
||||||
|
<!-- 控制面板 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/controlPanel"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="#CC000000"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<!-- 进度显示 -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvProgress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="1 / 20"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginBottom="16dp" />
|
||||||
|
|
||||||
|
<!-- 间隔滑块 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_marginBottom="12dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="间隔:"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:layout_marginEnd="8dp" />
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/seekBarInterval"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:max="12"
|
||||||
|
android:progress="2" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvIntervalLabel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="5 秒"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:minWidth="48dp"
|
||||||
|
android:gravity="end" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 控制按钮 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<!-- 上一张 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnPrevious"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
app:icon="@android:drawable/ic_media_previous"
|
||||||
|
app:iconSize="28dp"
|
||||||
|
app:iconTint="@android:color/white"
|
||||||
|
app:backgroundTint="#40FFFFFF"
|
||||||
|
android:layout_marginEnd="4dp" />
|
||||||
|
|
||||||
|
<!-- 播放/暂停 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnPlayPause"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="56dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
app:icon="@android:drawable/ic_media_pause"
|
||||||
|
app:iconSize="32dp"
|
||||||
|
app:iconTint="@android:color/white"
|
||||||
|
app:backgroundTint="#60FFFFFF"
|
||||||
|
android:layout_marginHorizontal="4dp" />
|
||||||
|
|
||||||
|
<!-- 下一张 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnNext"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
app:icon="@android:drawable/ic_media_next"
|
||||||
|
app:iconSize="28dp"
|
||||||
|
app:iconTint="@android:color/white"
|
||||||
|
app:backgroundTint="#40FFFFFF"
|
||||||
|
android:layout_marginStart="4dp" />
|
||||||
|
|
||||||
|
<!-- 分隔 -->
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:background="#40FFFFFF"
|
||||||
|
android:layout_marginHorizontal="12dp" />
|
||||||
|
|
||||||
|
<!-- 全屏/适应切换 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnScaleMode"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
app:icon="@android:drawable/ic_menu_crop"
|
||||||
|
app:iconSize="24dp"
|
||||||
|
app:iconTint="@android:color/white"
|
||||||
|
app:backgroundTint="#40FFFFFF" />
|
||||||
|
|
||||||
|
<!-- 退出 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnExit"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
app:icon="@android:drawable/ic_menu_close_clear_cancel"
|
||||||
|
app:iconSize="24dp"
|
||||||
|
app:iconTint="@android:color/white"
|
||||||
|
app:backgroundTint="#40FF0000"
|
||||||
|
android:layout_marginStart="4dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 播放结束界面 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/endScreen"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="#CC000000"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="播放结束"
|
||||||
|
android:textSize="32sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:layout_marginBottom="32dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- 重新播放 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnReplay"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:text="重新播放"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:backgroundTint="@color/sky_blue_primary"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
app:cornerRadius="28dp"
|
||||||
|
android:paddingHorizontal="32dp"
|
||||||
|
android:layout_marginEnd="16dp" />
|
||||||
|
|
||||||
|
<!-- 退出 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnExitEnd"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:text="退出"
|
||||||
|
android:textSize="16sp"
|
||||||
|
app:strokeColor="@android:color/white"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
app:cornerRadius="28dp"
|
||||||
|
android:paddingHorizontal="32dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
@@ -1,58 +1,91 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/bg_primary"
|
android:background="@color/bg_primary">
|
||||||
android:fillViewport="true">
|
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:background="@android:color/transparent"
|
||||||
android:padding="@dimen/spacing_md">
|
app:elevation="0dp">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingHorizontal="@dimen/spacing_lg"
|
||||||
|
android:paddingTop="32dp"
|
||||||
|
android:paddingBottom="@dimen/spacing_md">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="相册管理"
|
||||||
|
android:textSize="32sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="管理您的壁纸收藏和播放规则"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<!-- 标题栏 -->
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:orientation="vertical"
|
||||||
android:layout_marginBottom="@dimen/spacing_lg"
|
android:paddingHorizontal="@dimen/spacing_md"
|
||||||
android:orientation="horizontal">
|
android:paddingBottom="80dp"
|
||||||
|
android:clipToPadding="false">
|
||||||
<TextView
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="相册管理"
|
|
||||||
android:textSize="@dimen/text_size_xxl"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
|
<!-- Create New Button (Full Width) -->
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btnCreateAlbum"
|
android:id="@+id/btnCreateAlbum"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="56dp"
|
||||||
android:text="新建"
|
android:layout_marginHorizontal="4dp"
|
||||||
android:textSize="@dimen/text_size_sm"
|
android:layout_marginBottom="16dp"
|
||||||
android:backgroundTint="@color/accent_primary"
|
android:text="新建相册"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
app:icon="@drawable/ic_add"
|
app:icon="@drawable/ic_add"
|
||||||
app:iconGravity="textStart"
|
app:iconGravity="textStart"
|
||||||
app:cornerRadius="@dimen/corner_radius_md"
|
app:cornerRadius="28dp"
|
||||||
|
app:backgroundTint="@color/accent_primary"
|
||||||
style="@style/Widget.Material3.Button" />
|
style="@style/Widget.Material3.Button" />
|
||||||
|
|
||||||
</LinearLayout>
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvAlbums"
|
||||||
<!-- 相册列表 -->
|
android:layout_width="match_parent"
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/rvAlbums"
|
android:nestedScrollingEnabled="false"
|
||||||
android:layout_width="match_parent"
|
tools:listitem="@layout/item_album_card" />
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:nestedScrollingEnabled="false"
|
|
||||||
tools:listitem="@layout/item_album_card" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@color/bg_primary_modern">
|
|
||||||
|
|
||||||
<!-- 顶部标题 -->
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvTitle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="当前壁纸"
|
|
||||||
android:textSize="@dimen/text_size_xl"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary_modern"
|
|
||||||
android:layout_marginTop="@dimen/spacing_lg"
|
|
||||||
android:layout_marginStart="@dimen/spacing_lg"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<!-- 壁纸预览卡片 (占据主要空间) -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cardWallpaper"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginHorizontal="@dimen/spacing_lg"
|
|
||||||
android:layout_marginTop="@dimen/spacing_md"
|
|
||||||
android:layout_marginBottom="@dimen/spacing_lg"
|
|
||||||
app:cardElevation="0dp"
|
|
||||||
app:cardCornerRadius="@dimen/corner_radius_lg"
|
|
||||||
app:cardBackgroundColor="@color/bg_secondary_modern"
|
|
||||||
app:strokeColor="@color/bg_secondary_modern"
|
|
||||||
app:strokeWidth="1dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvTitle"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/infoContainer">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivWallpaper"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:contentDescription="当前壁纸预览" />
|
|
||||||
|
|
||||||
<!-- 点击提示遮罩 -->
|
|
||||||
<FrameLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:id="@+id/touchOverlay" />
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 底部信息和操作区 -->
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/infoContainer"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingHorizontal="@dimen/spacing_lg"
|
|
||||||
android:paddingBottom="100dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent">
|
|
||||||
|
|
||||||
<!-- 壁纸信息 -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_marginBottom="@dimen/spacing_lg">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvWallpaperName"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Loading..."
|
|
||||||
android:textSize="@dimen/text_size_lg"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary_modern"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="end" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_marginTop="@dimen/spacing_xs"
|
|
||||||
android:gravity="center_vertical">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="@dimen/icon_size_xs"
|
|
||||||
android:layout_height="@dimen/icon_size_xs"
|
|
||||||
android:src="@drawable/ic_image"
|
|
||||||
app:tint="@color/text_secondary_modern" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvResolution"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="1080 x 1920"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary_modern"
|
|
||||||
android:layout_marginStart="4dp" />
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="1dp"
|
|
||||||
android:layout_height="12dp"
|
|
||||||
android:background="@color/text_hint_modern"
|
|
||||||
android:layout_marginHorizontal="8dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvFileSize"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="2.5 MB"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary_modern" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvPath"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="/storage/emulated/0/..."
|
|
||||||
android:textSize="@dimen/text_size_xs"
|
|
||||||
android:textColor="@color/text_hint_modern"
|
|
||||||
android:layout_marginTop="@dimen/spacing_sm"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="middle"
|
|
||||||
android:background="@drawable/badge_background"
|
|
||||||
android:backgroundTint="@color/bg_secondary_modern"
|
|
||||||
android:paddingHorizontal="8dp"
|
|
||||||
android:paddingVertical="4dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- 操作按钮行 -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnOpenGallery"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="查看原图"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textColor="@color/text_primary_modern"
|
|
||||||
app:icon="@drawable/ic_image"
|
|
||||||
app:iconTint="@color/text_primary_modern"
|
|
||||||
app:backgroundTint="@color/bg_secondary_modern"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_pill"
|
|
||||||
style="@style/Widget.Material3.Button.Icon"
|
|
||||||
android:layout_marginEnd="@dimen/spacing_sm" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnNext"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:layout_weight="1.5"
|
|
||||||
android:text="切换下一张"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textStyle="bold"
|
|
||||||
app:icon="@drawable/ic_arrow_forward"
|
|
||||||
app:iconGravity="textEnd"
|
|
||||||
app:backgroundTint="@color/sky_blue_primary"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_pill"
|
|
||||||
style="@style/Widget.Material3.Button.Icon"
|
|
||||||
android:layout_marginStart="@dimen/spacing_sm" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -1,221 +1,288 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/transparent"
|
android:background="@color/bg_primary">
|
||||||
android:fillViewport="true">
|
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingHorizontal="@dimen/spacing_lg"
|
|
||||||
android:paddingTop="@dimen/spacing_lg"
|
|
||||||
android:paddingBottom="100dp"
|
|
||||||
android:clipToPadding="false">
|
|
||||||
|
|
||||||
<!-- Header -->
|
<LinearLayout
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/app_name"
|
|
||||||
android:textSize="@dimen/text_size_xl"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary_modern"
|
|
||||||
android:layout_marginBottom="@dimen/spacing_lg" />
|
|
||||||
|
|
||||||
<!-- 状态仪表盘 -->
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/spacing_lg"
|
android:orientation="vertical"
|
||||||
app:cardElevation="0dp"
|
android:paddingBottom="80dp">
|
||||||
app:cardCornerRadius="@dimen/corner_radius_lg"
|
|
||||||
app:cardBackgroundColor="@color/bg_card"
|
|
||||||
app:strokeColor="@color/bg_secondary_modern"
|
|
||||||
app:strokeWidth="1dp">
|
|
||||||
|
|
||||||
|
<!-- Top Immersive Preview Section -->
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="420dp">
|
||||||
|
|
||||||
|
<!-- Blurred Background -->
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivBlurBackground"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:alpha="0.4" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@drawable/bg_gradient_overlay" />
|
||||||
|
|
||||||
|
<!-- Main Content -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingTop="48dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="当前正在播放"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_secondary"
|
||||||
|
android:letterSpacing="0.1"
|
||||||
|
android:textAllCaps="true" />
|
||||||
|
|
||||||
|
<!-- Floating Card for Wallpaper -->
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="220dp"
|
||||||
|
android:layout_height="360dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
app:cardCornerRadius="24dp"
|
||||||
|
app:cardElevation="12dp"
|
||||||
|
app:strokeWidth="4dp"
|
||||||
|
app:strokeColor="@color/white">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivCurrentWallpaper"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:src="@drawable/ic_image" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/touchOverlay"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/selectableItemBackground" />
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Floating Quick Actions -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="@drawable/bg_glass_card"
|
||||||
|
android:padding="8dp">
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnChangeNow"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
app:icon="@drawable/ic_refresh"
|
||||||
|
app:iconSize="24dp"
|
||||||
|
app:iconTint="@color/sky_blue_primary"
|
||||||
|
app:backgroundTint="@android:color/transparent" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnOpenGallery"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
app:icon="@drawable/ic_image"
|
||||||
|
app:iconSize="22dp"
|
||||||
|
app:iconTint="@color/text_primary"
|
||||||
|
app:backgroundTint="@android:color/transparent" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!-- Status Bar Strip -->
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="-12dp"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="4dp"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingHorizontal="16dp">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/viewStatusDot"
|
||||||
|
android:layout_width="10dp"
|
||||||
|
android:layout_height="10dp"
|
||||||
|
android:background="@drawable/status_indicator_enabled" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvStatus"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:text="服务已开启"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnToggle"
|
||||||
|
style="@style/Widget.Material3.Button.TextButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="禁用"
|
||||||
|
android:textColor="@color/accent_primary"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<!-- Details Section -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center"
|
android:padding="16dp">
|
||||||
android:padding="@dimen/spacing_xl">
|
|
||||||
|
|
||||||
<!-- 动画容器 -->
|
<!-- Media Info Card -->
|
||||||
<FrameLayout
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:layout_width="120dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="120dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="@drawable/bg_icon_container_sky"
|
app:cardCornerRadius="16dp"
|
||||||
android:backgroundTint="@color/sky_blue_container"
|
app:cardElevation="0dp"
|
||||||
android:padding="20dp">
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#E0E0E0"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
<com.airbnb.lottie.LottieAnimationView
|
<LinearLayout
|
||||||
android:id="@+id/statusAnimation"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
app:lottie_rawRes="@raw/status_active"
|
android:orientation="vertical"
|
||||||
app:lottie_loop="true"
|
android:padding="16dp">
|
||||||
app:lottie_autoPlay="false" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvStatus"
|
android:id="@+id/tvWallpaperName"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/status_disabled"
|
android:text="wallpaper_name.jpg"
|
||||||
android:textSize="@dimen/text_size_lg"
|
android:textSize="16sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/text_primary_modern"
|
android:textColor="@color/text_primary"
|
||||||
android:layout_marginTop="@dimen/spacing_md" />
|
android:ellipsize="middle"
|
||||||
|
android:singleLine="true" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/tvFolderInfo"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvResolution"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="1080 x 1920"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text=" • "
|
||||||
|
android:textColor="@color/text_hint" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvFileSize"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="2.4 MB"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<!-- Active Album Card -->
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="服务未运行"
|
android:layout_marginTop="12dp"
|
||||||
android:textSize="@dimen/text_size_sm"
|
app:cardCornerRadius="16dp"
|
||||||
android:textColor="@color/text_secondary_modern"
|
app:cardElevation="0dp"
|
||||||
android:layout_marginTop="@dimen/spacing_xs" />
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#E0E0E0"
|
||||||
<TextView
|
app:cardBackgroundColor="@color/white">
|
||||||
android:id="@+id/tvSingleImageInfo"
|
|
||||||
android:layout_width="wrap_content"
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:textSize="@dimen/text_size_sm"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="@color/text_secondary_modern"
|
android:orientation="horizontal"
|
||||||
android:visibility="gone" />
|
android:padding="16dp"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="当前相册"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAlbumName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:text="默认相册"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnManageAlbums"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:text="管理"
|
||||||
|
android:textSize="12sp"
|
||||||
|
app:backgroundTint="@color/sky_blue_container"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
app:cornerRadius="18dp"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 控制按钮组 -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_marginBottom="@dimen/spacing_lg">
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnToggle"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="72dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginEnd="@dimen/spacing_sm"
|
|
||||||
android:text="@string/enable"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textStyle="bold"
|
|
||||||
app:icon="@drawable/ic_play"
|
|
||||||
app:iconSize="24dp"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_lg"
|
|
||||||
app:backgroundTint="@color/sky_blue_primary"
|
|
||||||
style="@style/Widget.Material3.Button.Icon" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnChangeNow"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="72dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginStart="@dimen/spacing_sm"
|
|
||||||
android:text="@string/change_now"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:enabled="false"
|
|
||||||
app:icon="@drawable/ic_refresh"
|
|
||||||
app:iconSize="24dp"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_lg"
|
|
||||||
app:backgroundTint="@color/azure_blue_container"
|
|
||||||
app:iconTint="@color/azure_blue_dark"
|
|
||||||
android:textColor="@color/azure_blue_dark"
|
|
||||||
style="@style/Widget.Material3.Button.Icon" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
<!-- 当前相册卡片 -->
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="正在播放"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary_modern"
|
|
||||||
android:layout_marginBottom="@dimen/spacing_sm"
|
|
||||||
android:layout_marginStart="@dimen/spacing_xs" />
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cardAlbum"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:cardElevation="0dp"
|
|
||||||
app:cardCornerRadius="@dimen/corner_radius_lg"
|
|
||||||
app:cardBackgroundColor="@color/white"
|
|
||||||
app:strokeColor="@color/bg_secondary_modern"
|
|
||||||
app:strokeWidth="1dp">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="@dimen/spacing_md">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivAlbumIcon"
|
|
||||||
android:layout_width="48dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:src="@drawable/ic_album"
|
|
||||||
app:tint="@color/sky_blue_primary"
|
|
||||||
android:background="@drawable/bg_icon_container_sky"
|
|
||||||
android:backgroundTint="@color/sky_blue_container"
|
|
||||||
android:padding="12dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvAlbumName"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="默认相册"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary_modern"
|
|
||||||
android:layout_marginStart="@dimen/spacing_md"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/ivAlbumIcon"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/ivAlbumIcon"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/btnManageAlbums" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvAlbumInfo"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="0 个文件夹 · 0 张图片"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary_modern"
|
|
||||||
android:layout_marginStart="@dimen/spacing_md"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/ivAlbumIcon"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@id/ivAlbumIcon"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/btnManageAlbums" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnManageAlbums"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="管理"
|
|
||||||
style="@style/Widget.Material3.Button.TextButton"
|
|
||||||
android:textColor="@color/sky_blue_primary"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
|
||||||
@@ -1,479 +1,534 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/bg_primary"
|
android:background="@color/bg_primary">
|
||||||
android:fillViewport="true">
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="@dimen/spacing_md"
|
android:background="@android:color/transparent"
|
||||||
tools:context=".ui.SettingsFragment">
|
app:elevation="0dp">
|
||||||
|
|
||||||
<!-- 背景图片设置卡片 -->
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
<TextView
|
android:layout_width="match_parent"
|
||||||
android:id="@+id/tvBackgroundLabel"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="应用背景"
|
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||||
android:textSize="@dimen/text_size_xxl"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cardBackground"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_sm"
|
|
||||||
app:cardElevation="@dimen/card_elevation"
|
|
||||||
app:cardCornerRadius="@dimen/corner_radius_md"
|
|
||||||
app:cardBackgroundColor="@color/bg_card"
|
|
||||||
app:strokeColor="@color/glass_border"
|
|
||||||
app:strokeWidth="@dimen/glass_border_width"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvBackgroundLabel"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="@dimen/card_padding">
|
android:paddingHorizontal="24dp"
|
||||||
|
android:paddingTop="32dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="设置"
|
||||||
|
android:textSize="32sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="自定义您的壁纸体验"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:paddingBottom="80dp">
|
||||||
|
|
||||||
|
<!-- Section: Playback & Interaction -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="播放与交互"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#E0E0E0"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
<!-- 背景开关和选择按钮 -->
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_vertical">
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switchBackground"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="启用背景图片"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnSelectBackground"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="选择图片"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:layout_marginStart="@dimen/spacing_md"
|
|
||||||
app:icon="@drawable/ic_image"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_sm"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- 透明度滑块 -->
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="背景透明度"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary"
|
|
||||||
android:layout_marginTop="@dimen/spacing_md" />
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:id="@+id/seekBarBackgroundAlpha"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:max="100"
|
|
||||||
android:min="5"
|
|
||||||
android:progress="30"
|
|
||||||
android:layout_marginTop="@dimen/spacing_sm" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvBackgroundAlpha"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="30%"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_hint"
|
|
||||||
android:layout_marginTop="@dimen/spacing_xs"
|
|
||||||
android:layout_gravity="end" />
|
|
||||||
|
|
||||||
<!-- 清除按钮 -->
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnClearBackground"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="清除背景图片"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:layout_marginTop="@dimen/spacing_md"
|
|
||||||
app:icon="@drawable/ic_delete"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_sm"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
|
||||||
android:textColor="@color/color_error"
|
|
||||||
app:iconTint="@color/color_error"
|
|
||||||
app:strokeColor="@color/color_error" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 视频设置卡片 -->
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvVideoSettingsLabel"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_lg"
|
|
||||||
android:text="视频设置"
|
|
||||||
android:textSize="@dimen/text_size_xxl"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/cardBackground"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cardVideoSettings"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_sm"
|
|
||||||
app:cardElevation="@dimen/card_elevation"
|
|
||||||
app:cardCornerRadius="@dimen/corner_radius_md"
|
|
||||||
app:cardBackgroundColor="@color/bg_card"
|
|
||||||
app:strokeColor="@color/glass_border"
|
|
||||||
app:strokeWidth="@dimen/glass_border_width"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvVideoSettingsLabel"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="@dimen/card_padding">
|
|
||||||
|
|
||||||
<!-- 启用视频壁纸 -->
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switchVideoEnabled"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="启用视频壁纸"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:minHeight="48dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="允许使用视频文件作为动态壁纸"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary"
|
|
||||||
android:layout_marginBottom="@dimen/spacing_md" />
|
|
||||||
|
|
||||||
<!-- 视频静音 -->
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switchVideoMuted"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="视频静音"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:minHeight="48dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="播放视频时自动静音"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary"
|
|
||||||
android:layout_marginBottom="@dimen/spacing_md" />
|
|
||||||
|
|
||||||
<!-- 电池供电时暂停 -->
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switchVideoPauseOnBattery"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="电池供电时暂停视频"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:minHeight="48dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="仅在充电时播放视频,节省电量"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 双击设置卡片 -->
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvDoubleTapSettingsLabel"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_lg"
|
|
||||||
android:text="交互设置"
|
|
||||||
android:textSize="@dimen/text_size_xxl"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/cardVideoSettings"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cardDoubleTapSettings"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_sm"
|
|
||||||
app:cardElevation="@dimen/card_elevation"
|
|
||||||
app:cardCornerRadius="@dimen/corner_radius_md"
|
|
||||||
app:cardBackgroundColor="@color/bg_card"
|
|
||||||
app:strokeColor="@color/glass_border"
|
|
||||||
app:strokeWidth="@dimen/glass_border_width"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvDoubleTapSettingsLabel"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="@dimen/card_padding">
|
|
||||||
|
|
||||||
<!-- 启用双击切换 -->
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switchDoubleTapEnabled"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="启用双击切换壁纸"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:minHeight="48dp" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="在桌面双击可快速切换到下一张壁纸"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 固定壁纸设置卡片 -->
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvFixedWallpaperLabel"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_lg"
|
|
||||||
android:text="固定壁纸"
|
|
||||||
android:textSize="@dimen/text_size_xxl"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/cardDoubleTapSettings"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cardFixedWallpaper"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_sm"
|
|
||||||
app:cardElevation="@dimen/card_elevation"
|
|
||||||
app:cardCornerRadius="@dimen/corner_radius_md"
|
|
||||||
app:cardBackgroundColor="@color/bg_card"
|
|
||||||
app:strokeColor="@color/glass_border"
|
|
||||||
app:strokeWidth="@dimen/glass_border_width"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvFixedWallpaperLabel"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="@dimen/card_padding">
|
|
||||||
|
|
||||||
<!-- 选择固定壁纸按钮 -->
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnSelectFixedWallpaper"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="选择固定壁纸"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
app:icon="@drawable/ic_image"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_sm"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton" />
|
|
||||||
|
|
||||||
<!-- 固定壁纸预览 -->
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/ivFixedWallpaperPreview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="200dp"
|
|
||||||
android:layout_marginTop="@dimen/spacing_md"
|
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:contentDescription="固定壁纸预览"
|
|
||||||
android:background="@color/bg_secondary" />
|
|
||||||
|
|
||||||
<!-- 清除固定壁纸按钮 -->
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnClearFixedWallpaper"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="清除固定壁纸"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:layout_marginTop="@dimen/spacing_md"
|
|
||||||
app:icon="@drawable/ic_delete"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_sm"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
|
||||||
android:textColor="@color/color_error"
|
|
||||||
app:iconTint="@color/color_error"
|
|
||||||
app:strokeColor="@color/color_error"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
<!-- 提示信息 -->
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_md"
|
|
||||||
android:text="提示:固定壁纸是一个收藏功能。四指点击桌面会发送通知,点击通知后可在系统相册中查看固定壁纸,同时会禁用自动更新功能。"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_hint"
|
|
||||||
android:lineSpacingExtra="4dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<!-- 自动扫描设置卡片 -->
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvAutoScanLabel"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_lg"
|
|
||||||
android:text="自动扫描"
|
|
||||||
android:textSize="@dimen/text_size_xxl"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/cardFixedWallpaper"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:id="@+id/cardAutoScan"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_sm"
|
|
||||||
android:layout_marginBottom="@dimen/spacing_lg"
|
|
||||||
app:cardElevation="@dimen/card_elevation"
|
|
||||||
app:cardCornerRadius="@dimen/corner_radius_md"
|
|
||||||
app:cardBackgroundColor="@color/bg_card"
|
|
||||||
app:strokeColor="@color/glass_border"
|
|
||||||
app:strokeWidth="@dimen/glass_border_width"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvAutoScanLabel"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="@dimen/card_padding">
|
|
||||||
|
|
||||||
<!-- 自动扫描间隔选择 -->
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="自动扫描间隔"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_xs"
|
|
||||||
android:text="定期清除缓存并重新扫描相册文件夹,确保显示最新内容"
|
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_secondary"
|
|
||||||
android:lineSpacingExtra="4dp" />
|
|
||||||
|
|
||||||
<RadioGroup
|
|
||||||
android:id="@+id/radioGroupAutoScan"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/spacing_md"
|
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<RadioButton
|
<!-- Double Tap -->
|
||||||
android:id="@+id/radioAutoScanDisabled"
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="禁用(手动刷新)"
|
android:gravity="center_vertical"
|
||||||
android:textSize="@dimen/text_size_md"
|
android:padding="16dp"
|
||||||
android:textColor="@color/text_primary"
|
android:background="?attr/selectableItemBackground">
|
||||||
android:minHeight="48dp" />
|
|
||||||
|
|
||||||
<RadioButton
|
<LinearLayout
|
||||||
android:id="@+id/radioAutoScan1Hour"
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="双击切换壁纸"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:text="在桌面空白处双击快速切换"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switchDoubleTapEnabled"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#F0F0F0" android:layout_marginHorizontal="16dp"/>
|
||||||
|
|
||||||
|
<!-- Video Enable -->
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="每 1 小时"
|
android:gravity="center_vertical"
|
||||||
android:textSize="@dimen/text_size_md"
|
android:padding="16dp"
|
||||||
android:textColor="@color/text_primary"
|
android:background="?attr/selectableItemBackground">
|
||||||
android:minHeight="48dp" />
|
|
||||||
|
|
||||||
<RadioButton
|
<LinearLayout
|
||||||
android:id="@+id/radioAutoScan6Hours"
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="启用视频壁纸"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="2dp"
|
||||||
|
android:text="允许播放视频格式的壁纸"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switchVideoEnabled"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Video Sub-settings (Mute) -->
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="每 6 小时"
|
android:gravity="center_vertical"
|
||||||
android:textSize="@dimen/text_size_md"
|
android:paddingHorizontal="16dp"
|
||||||
android:textColor="@color/text_primary"
|
android:paddingVertical="12dp"
|
||||||
android:minHeight="48dp" />
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
<RadioButton
|
<LinearLayout
|
||||||
android:id="@+id/radioAutoScan12Hours"
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="视频静音"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switchVideoMuted"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Video Sub-settings (Battery) -->
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="每 12 小时"
|
android:gravity="center_vertical"
|
||||||
android:textSize="@dimen/text_size_md"
|
android:paddingHorizontal="16dp"
|
||||||
android:textColor="@color/text_primary"
|
android:paddingVertical="12dp"
|
||||||
android:minHeight="48dp" />
|
android:paddingBottom="16dp"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
<RadioButton
|
<LinearLayout
|
||||||
android:id="@+id/radioAutoScan24Hours"
|
android:layout_width="0dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_weight="1"
|
||||||
android:text="每 24 小时(推荐)"
|
android:orientation="vertical">
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:minHeight="48dp" />
|
|
||||||
|
|
||||||
</RadioGroup>
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="电池供电时暂停"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="节省电量,仅在充电时播放"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 提示信息 -->
|
<Switch
|
||||||
<TextView
|
android:id="@+id/switchVideoPauseOnBattery"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Section: Fixed Wallpaper -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="固定壁纸 (收藏)"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:id="@+id/cardFixedWallpaper"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#E0E0E0"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/spacing_md"
|
android:orientation="vertical"
|
||||||
android:text="注意:自动扫描会在后台定时运行,可能会消耗少量电量。建议选择较长的间隔时间。"
|
android:padding="16dp">
|
||||||
android:textSize="@dimen/text_size_sm"
|
|
||||||
android:textColor="@color/text_hint"
|
|
||||||
android:lineSpacingExtra="4dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="四指点击桌面即可快速打开此壁纸"
|
||||||
|
android:textSize="13sp"
|
||||||
|
android:textColor="@color/text_secondary"
|
||||||
|
android:layout_marginBottom="12dp" />
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
<!-- Preview Area -->
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
app:cardCornerRadius="12dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:cardBackgroundColor="@color/bg_secondary">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ivFixedWallpaperPreview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:contentDescription="固定壁纸预览" />
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
<!-- Actions -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnSelectFixedWallpaper"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="选择图片"
|
||||||
|
app:icon="@drawable/ic_image"
|
||||||
|
app:backgroundTint="@color/sky_blue_container"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
app:iconTint="@color/sky_blue_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnClearFixedWallpaper"
|
||||||
|
style="@style/Widget.Material3.Button.TextButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="清除"
|
||||||
|
android:textColor="@color/status_error_text" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Section: App Appearance -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="应用外观"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#E0E0E0"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="启用自定义背景"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/switchBackground"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="背景透明度"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvBackgroundAlpha"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="30%"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent_primary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/seekBarBackgroundAlpha"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:max="100"
|
||||||
|
android:min="5"
|
||||||
|
android:progress="30" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnSelectBackground"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="更换背景"
|
||||||
|
app:strokeColor="@color/sky_blue_primary"
|
||||||
|
android:textColor="@color/sky_blue_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnClearBackground"
|
||||||
|
style="@style/Widget.Material3.Button.TextButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="恢复默认"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Section: Data -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:text="维护"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/accent_primary" />
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#E0E0E0"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="自动扫描间隔"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="定期更新相册缓存,确保新文件被发现"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/radioGroupAutoScan"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radioAutoScanDisabled"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="禁用 (手动刷新)"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radioAutoScan1Hour"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="每 1 小时"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radioAutoScan6Hours"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="每 6 小时"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radioAutoScan12Hours"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="每 12 小时"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radioAutoScan24Hours"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="每 24 小时 (推荐)"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<!-- Version Info Footer -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="v2.0.0 · BzForGk2"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_hint" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/bg_primary">
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:paddingBottom="100dp"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
|
<!-- Title -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="幻灯片播放"
|
||||||
|
android:textSize="28sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:layout_marginBottom="8dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="从当前相册随机选择图片"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_secondary"
|
||||||
|
android:layout_marginBottom="32dp" />
|
||||||
|
|
||||||
|
<!-- Album Info Card -->
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="32dp"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="2dp"
|
||||||
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="@color/bg_secondary_modern"
|
||||||
|
app:cardBackgroundColor="@color/white">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="当前相册"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_hint"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:letterSpacing="0.1"
|
||||||
|
android:layout_marginBottom="8dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvAlbumName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="默认相册"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:layout_marginBottom="4dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvImageCount"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="0 张图片"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
<!-- Selection Title -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="选择播放数量"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:layout_marginBottom="16dp" />
|
||||||
|
|
||||||
|
<!-- Option Buttons -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<!-- 10 张 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn10"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:text="10 张"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:strokeWidth="2dp"
|
||||||
|
app:strokeColor="@color/sky_blue_primary"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
android:layout_marginBottom="12dp" />
|
||||||
|
|
||||||
|
<!-- 20 张 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn20"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:text="20 张"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:strokeWidth="2dp"
|
||||||
|
app:strokeColor="@color/sky_blue_primary"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
android:layout_marginBottom="12dp" />
|
||||||
|
|
||||||
|
<!-- 50 张 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn50"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:text="50 张"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:strokeWidth="2dp"
|
||||||
|
app:strokeColor="@color/sky_blue_primary"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
android:layout_marginBottom="12dp" />
|
||||||
|
|
||||||
|
<!-- 全部 -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnAll"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:text="全部"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:backgroundTint="@color/sky_blue_primary"
|
||||||
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -1,68 +1,107 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:background="@color/bg_primary">
|
||||||
android:background="@color/background">
|
|
||||||
|
|
||||||
<!-- 标题栏 -->
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:background="@android:color/transparent"
|
||||||
android:gravity="center_vertical"
|
app:elevation="0dp">
|
||||||
android:paddingStart="16dp"
|
|
||||||
android:paddingEnd="16dp"
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
android:paddingTop="16dp"
|
android:layout_width="match_parent"
|
||||||
android:paddingBottom="12dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/surface">
|
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingHorizontal="24dp"
|
||||||
|
android:paddingTop="32dp"
|
||||||
|
android:paddingBottom="16dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="历史记录"
|
||||||
|
android:textSize="32sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="回顾您使用过的壁纸"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnClearHistory"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="清空"
|
||||||
|
android:textColor="@color/status_error_text"
|
||||||
|
app:backgroundTint="@color/status_error_bg"
|
||||||
|
app:icon="@drawable/ic_delete"
|
||||||
|
app:iconTint="@color/status_error_text"
|
||||||
|
app:cornerRadius="20dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvHistory"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="80dp"
|
||||||
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="0dp"
|
android:id="@+id/tvEmptyHint"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="壁纸历史"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnClearHistory"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="36dp"
|
android:layout_height="wrap_content"
|
||||||
android:text="清空"
|
android:layout_gravity="center"
|
||||||
android:textSize="14sp"
|
android:text="暂无历史记录
|
||||||
app:icon="@drawable/ic_delete"
|
使用后的壁纸会出现在这里"
|
||||||
app:iconGravity="textStart"
|
android:textSize="16sp"
|
||||||
app:iconPadding="4dp"
|
android:textColor="@color/text_hint"
|
||||||
app:cornerRadius="8dp"
|
android:gravity="center"
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
android:lineSpacingExtra="4dp"
|
||||||
android:textColor="@color/error"
|
android:visibility="gone" />
|
||||||
app:iconTint="@color/error"
|
|
||||||
app:strokeColor="@color/error" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<!-- 历史记录列表 -->
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rvHistory"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:clipToPadding="false" />
|
|
||||||
|
|
||||||
<!-- 空状态提示 -->
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvEmptyHint"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="暂无历史记录\n壁纸使用后会自动记录在这里"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textColor="@color/text_hint"
|
|
||||||
android:gravity="center"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -3,201 +3,224 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/cardAlbum"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="@dimen/spacing_md"
|
android:layout_marginBottom="12dp"
|
||||||
|
android:layout_marginHorizontal="4dp"
|
||||||
app:cardElevation="0dp"
|
app:cardElevation="0dp"
|
||||||
app:cardCornerRadius="@dimen/corner_radius_lg"
|
app:cardCornerRadius="20dp"
|
||||||
app:cardBackgroundColor="@color/white"
|
app:cardBackgroundColor="@color/white"
|
||||||
app:strokeColor="@color/bg_secondary_modern"
|
|
||||||
app:strokeWidth="1dp"
|
app:strokeWidth="1dp"
|
||||||
|
app:strokeColor="#F0F0F0"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true">
|
android:focusable="true"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:padding="16dp">
|
||||||
android:padding="@dimen/spacing_lg">
|
|
||||||
|
|
||||||
<!-- Top Row: Name and Status -->
|
<!-- Album Icon -->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/iconContainer"
|
||||||
|
android:layout_width="56dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:background="@drawable/bg_icon_container_sky"
|
||||||
|
android:backgroundTint="@color/sky_blue_container"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.0">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="28dp"
|
||||||
|
android:layout_height="28dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_album"
|
||||||
|
app:tint="@color/sky_blue_primary" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!-- Album Name & Badge Row -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/headerRow"
|
||||||
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/iconContainer"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/iconContainer"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
<FrameLayout
|
<TextView
|
||||||
android:layout_width="40dp"
|
android:id="@+id/tvAlbumName"
|
||||||
android:layout_height="40dp"
|
|
||||||
android:background="@drawable/bg_icon_container_sky"
|
|
||||||
android:backgroundTint="@color/sky_blue_container">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:src="@drawable/ic_album"
|
|
||||||
app:tint="@color/sky_blue_primary" />
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical"
|
android:text="相册名称"
|
||||||
android:layout_marginStart="@dimen/spacing_md">
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
<TextView
|
android:textColor="@color/text_primary"
|
||||||
android:id="@+id/tvAlbumName"
|
android:maxLines="1"
|
||||||
android:layout_width="wrap_content"
|
android:ellipsize="end" />
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="相册名称"
|
|
||||||
android:textSize="@dimen/text_size_md"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary_modern"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="end" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvAlbumInfo"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="3 个文件夹 · 120 张图片"
|
|
||||||
android:textSize="@dimen/text_size_xs"
|
|
||||||
android:textColor="@color/text_secondary_modern"
|
|
||||||
android:layout_marginTop="2dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
|
<!-- Active Badge -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvCurrentBadge"
|
android:id="@+id/tvCurrentBadge"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
android:text="使用中"
|
android:text="使用中"
|
||||||
android:textSize="10sp"
|
android:textSize="11sp"
|
||||||
|
android:textStyle="bold"
|
||||||
android:textColor="@color/sky_blue_primary"
|
android:textColor="@color/sky_blue_primary"
|
||||||
android:paddingHorizontal="8dp"
|
android:paddingHorizontal="8dp"
|
||||||
android:paddingVertical="4dp"
|
android:paddingVertical="4dp"
|
||||||
android:background="@drawable/badge_background"
|
android:background="@drawable/badge_background"
|
||||||
android:backgroundTint="@color/sky_blue_container"
|
android:backgroundTint="@color/sky_blue_container"
|
||||||
android:visibility="gone"
|
android:visibility="visible" />
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Divider -->
|
<!-- Media Info Subtitle -->
|
||||||
<View
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/tvAlbumInfo"
|
||||||
android:layout_height="1dp"
|
android:layout_width="0dp"
|
||||||
android:background="@color/bg_secondary_modern"
|
|
||||||
android:layout_marginVertical="@dimen/spacing_md" />
|
|
||||||
|
|
||||||
<!-- Bottom Row: Config and Actions -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_vertical">
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="3 个文件夹 · 120 张图片"
|
||||||
|
android:textSize="13sp"
|
||||||
|
android:textColor="@color/text_secondary"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/headerRow"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/headerRow"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
<!-- Config Info -->
|
<!-- Stats Row (Cleaned up) -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:id="@+id/statsRow"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:layout_marginTop="12dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/headerRow"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tvAlbumInfo"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/actionsLayout"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
<TextView
|
<!-- Play Mode -->
|
||||||
android:id="@+id/tvPlayMode"
|
<ImageView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="14dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="14dp"
|
||||||
android:text="顺序"
|
android:src="@drawable/ic_repeat"
|
||||||
android:textSize="@dimen/text_size_xs"
|
app:tint="@color/text_hint" />
|
||||||
android:textColor="@color/text_hint_modern"
|
|
||||||
android:drawableStart="@drawable/ic_repeat"
|
<TextView
|
||||||
android:drawablePadding="4dp"
|
android:id="@+id/tvPlayMode"
|
||||||
android:drawableTint="@color/text_hint_modern" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvInterval"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="30 分钟"
|
|
||||||
android:textSize="@dimen/text_size_xs"
|
|
||||||
android:textColor="@color/text_hint_modern"
|
|
||||||
android:layout_marginStart="@dimen/spacing_md"
|
|
||||||
android:drawableStart="@drawable/ic_schedule"
|
|
||||||
android:drawablePadding="4dp"
|
|
||||||
android:drawableTint="@color/text_hint_modern" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvLastScanTime"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="未扫描"
|
|
||||||
android:textSize="@dimen/text_size_xs"
|
|
||||||
android:textColor="@color/text_hint_modern"
|
|
||||||
android:layout_marginStart="@dimen/spacing_md"
|
|
||||||
android:drawableStart="@drawable/ic_refresh"
|
|
||||||
android:drawablePadding="4dp"
|
|
||||||
android:drawableTint="@color/text_hint_modern" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- Action Buttons -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:text="顺序"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_hint" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<TextView
|
||||||
android:id="@+id/btnEdit"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="40dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="40dp"
|
android:text=" · "
|
||||||
android:insetLeft="0dp"
|
android:textColor="@color/text_hint"
|
||||||
android:insetTop="0dp"
|
android:layout_marginHorizontal="4dp"/>
|
||||||
android:insetRight="0dp"
|
|
||||||
android:insetBottom="0dp"
|
|
||||||
app:icon="@drawable/ic_edit"
|
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:iconPadding="0dp"
|
|
||||||
app:iconSize="20dp"
|
|
||||||
app:iconTint="@color/text_secondary_modern"
|
|
||||||
app:cornerRadius="20dp"
|
|
||||||
app:backgroundTint="@color/bg_secondary_modern"
|
|
||||||
style="@style/Widget.Material3.Button.IconButton" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<!-- Interval -->
|
||||||
android:id="@+id/btnDelete"
|
<ImageView
|
||||||
android:layout_width="40dp"
|
android:layout_width="14dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="14dp"
|
||||||
android:layout_marginStart="8dp"
|
android:src="@drawable/ic_schedule"
|
||||||
android:insetLeft="0dp"
|
app:tint="@color/text_hint" />
|
||||||
android:insetTop="0dp"
|
|
||||||
android:insetRight="0dp"
|
<TextView
|
||||||
android:insetBottom="0dp"
|
android:id="@+id/tvInterval"
|
||||||
app:icon="@drawable/ic_delete"
|
android:layout_width="wrap_content"
|
||||||
app:iconGravity="textStart"
|
android:layout_height="wrap_content"
|
||||||
app:iconPadding="0dp"
|
android:layout_marginStart="4dp"
|
||||||
app:iconSize="20dp"
|
android:text="30m"
|
||||||
app:iconTint="@color/status_error_text"
|
android:textSize="12sp"
|
||||||
app:cornerRadius="20dp"
|
android:textColor="@color/text_hint" />
|
||||||
app:backgroundTint="@color/status_error_bg"
|
|
||||||
style="@style/Widget.Material3.Button.IconButton" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnSwitch"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="40dp"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:text="使用"
|
|
||||||
android:textSize="@dimen/text_size_xs"
|
|
||||||
app:cornerRadius="@dimen/corner_radius_pill"
|
|
||||||
app:backgroundTint="@color/sky_blue_primary"
|
|
||||||
style="@style/Widget.Material3.Button" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
<!-- Last Scan REMOVED -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLastScanTime"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
<!-- Actions -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/actionsLayout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
|
<!-- Edit Button (Changed to Text Button) -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnEdit"
|
||||||
|
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:text="编辑"
|
||||||
|
android:textSize="11sp"
|
||||||
|
android:textColor="@color/text_secondary"
|
||||||
|
app:strokeColor="@color/bg_secondary_modern"
|
||||||
|
app:strokeWidth="1dp"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
android:minWidth="0dp" />
|
||||||
|
|
||||||
|
<!-- Delete Button (Icon) -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnDelete"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="32dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:insetLeft="0dp"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetRight="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:padding="0dp"
|
||||||
|
app:icon="@drawable/ic_delete"
|
||||||
|
app:iconSize="16dp"
|
||||||
|
app:iconTint="@color/status_error_text"
|
||||||
|
app:backgroundTint="@android:color/transparent"
|
||||||
|
app:rippleColor="#20FF0000" />
|
||||||
|
|
||||||
|
<!-- Switch Button -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnSwitch"
|
||||||
|
style="@style/Widget.Material3.Button.TonalButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:layout_marginStart="4dp"
|
||||||
|
android:text="使用"
|
||||||
|
android:textSize="11sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
app:backgroundTint="@color/sky_blue_container"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:paddingHorizontal="12dp"
|
||||||
|
android:minWidth="0dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
@@ -1,99 +1,94 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.google.android.material.card.MaterialCardView
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:orientation="horizontal"
|
||||||
app:cardElevation="2dp"
|
android:gravity="center_vertical"
|
||||||
app:cardCornerRadius="12dp">
|
android:background="@drawable/bg_nav_item_ripple"
|
||||||
|
android:paddingHorizontal="4dp"
|
||||||
|
android:paddingVertical="8dp">
|
||||||
|
|
||||||
|
<!-- Icon -->
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:background="@drawable/bg_icon_container_sky"
|
||||||
|
android:backgroundTint="@color/sky_blue_container">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_folder"
|
||||||
|
app:tint="@color/sky_blue_primary" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!-- Text Info -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:layout_weight="1"
|
||||||
android:padding="16dp">
|
android:layout_marginStart="12dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvFolderName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="文件夹名称"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
|
||||||
<!-- 文件夹名称和路径 -->
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal">
|
android:layout_marginTop="2dp">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="24dp"
|
|
||||||
android:layout_height="24dp"
|
|
||||||
android:src="@drawable/ic_folder"
|
|
||||||
android:tint="@color/primary"
|
|
||||||
android:contentDescription="文件夹图标" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvFolderName"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="文件夹名称"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="end" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvFolderPath"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="content://..."
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:textColor="@color/text_hint"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:ellipsize="middle" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!-- 图片数量和操作按钮 -->
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvImageCount"
|
android:id="@+id/tvImageCount"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="0 个文件"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_secondary" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvFolderPath"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="0 张图片"
|
android:layout_marginStart="8dp"
|
||||||
android:textSize="14sp"
|
android:text="/storage/..."
|
||||||
android:textColor="@color/text_secondary"
|
|
||||||
android:drawableStart="@drawable/ic_image"
|
|
||||||
android:drawablePadding="4dp" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnRemove"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:text="移除"
|
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
app:icon="@drawable/ic_delete"
|
android:textColor="@color/text_hint"
|
||||||
app:iconGravity="textStart"
|
android:maxLines="1"
|
||||||
app:iconPadding="4dp"
|
android:ellipsize="start" />
|
||||||
app:cornerRadius="8dp"
|
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
<!-- Remove Button -->
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btnRemove"
|
||||||
|
style="@style/Widget.Material3.Button.IconButton"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:insetLeft="0dp"
|
||||||
|
android:insetTop="0dp"
|
||||||
|
android:insetRight="0dp"
|
||||||
|
android:insetBottom="0dp"
|
||||||
|
android:padding="0dp"
|
||||||
|
app:icon="@drawable/ic_close"
|
||||||
|
app:iconSize="20dp"
|
||||||
|
app:iconTint="@color/text_secondary"
|
||||||
|
app:backgroundTint="@android:color/transparent"
|
||||||
|
app:rippleColor="#20000000" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -5,76 +5,105 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="6dp"
|
android:layout_margin="6dp"
|
||||||
app:cardElevation="2dp"
|
app:cardElevation="0dp"
|
||||||
app:cardCornerRadius="12dp"
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardBackgroundColor="@color/white"
|
||||||
|
app:strokeWidth="0dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true">
|
android:focusable="true"
|
||||||
|
android:foreground="?attr/selectableItemBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- 缩略图 -->
|
<!-- Image Container -->
|
||||||
<ImageView
|
<FrameLayout
|
||||||
android:id="@+id/ivThumbnail"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="150dp"
|
android:layout_height="180dp">
|
||||||
android:scaleType="centerCrop"
|
|
||||||
android:background="@color/image_placeholder" />
|
|
||||||
|
|
||||||
<!-- 信息区域 -->
|
<ImageView
|
||||||
|
android:id="@+id/ivThumbnail"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
android:background="@color/bg_secondary_modern" />
|
||||||
|
|
||||||
|
<!-- Gradient Overlay for Text Readability -->
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="60dp"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:background="@drawable/bg_gradient_overlay"
|
||||||
|
android:rotation="180" />
|
||||||
|
|
||||||
|
<!-- Timestamp Badge -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTimestamp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="top|end"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:background="@drawable/bg_glass_card"
|
||||||
|
android:paddingHorizontal="8dp"
|
||||||
|
android:paddingVertical="4dp"
|
||||||
|
android:text="14:30"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<!-- Info Section -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="12dp">
|
android:padding="12dp">
|
||||||
|
|
||||||
<!-- 相册名称 -->
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvAlbumName"
|
android:id="@+id/tvAlbumName"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="相册名称"
|
android:text="相册名称"
|
||||||
android:textSize="14sp"
|
android:textSize="13sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/text_primary"
|
android:textColor="@color/text_primary"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end" />
|
||||||
android:drawableStart="@drawable/ic_album"
|
|
||||||
android:drawablePadding="4dp" />
|
|
||||||
|
|
||||||
<!-- 时间戳 -->
|
<LinearLayout
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvTimestamp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="01-15 14:30"
|
android:orientation="horizontal"
|
||||||
android:textSize="12sp"
|
|
||||||
android:textColor="@color/text_hint"
|
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:drawableStart="@drawable/ic_schedule"
|
|
||||||
android:drawablePadding="4dp" />
|
|
||||||
|
|
||||||
<!-- 删除按钮 -->
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btnDelete"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="36dp"
|
|
||||||
android:text="删除"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
app:icon="@drawable/ic_delete"
|
android:gravity="center_vertical">
|
||||||
app:iconGravity="textStart"
|
|
||||||
app:iconPadding="4dp"
|
<!-- Reuse/Jump Button -->
|
||||||
app:cornerRadius="6dp"
|
<TextView
|
||||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
android:id="@+id/btnReuse"
|
||||||
android:textColor="@color/error"
|
android:layout_width="0dp"
|
||||||
app:iconTint="@color/error"
|
android:layout_height="wrap_content"
|
||||||
app:strokeColor="@color/error" />
|
android:layout_weight="1"
|
||||||
|
android:text="跳转相册"
|
||||||
|
android:textSize="11sp"
|
||||||
|
android:textColor="@color/sky_blue_primary"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<!-- Delete Button -->
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btnDelete"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:padding="4dp"
|
||||||
|
android:src="@drawable/ic_delete"
|
||||||
|
app:tint="@color/text_hint"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
@@ -3,30 +3,17 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/nav_home"
|
android:id="@+id/nav_home"
|
||||||
android:icon="@drawable/ic_home"
|
android:icon="@drawable/ic_home"
|
||||||
android:title="@string/nav_home"
|
android:title="首页" />
|
||||||
android:orderInCategory="0" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/nav_wallpaper"
|
|
||||||
android:icon="@drawable/ic_image"
|
|
||||||
android:title="@string/nav_wallpaper"
|
|
||||||
android:orderInCategory="1" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_albums"
|
android:id="@+id/nav_albums"
|
||||||
android:icon="@drawable/ic_album"
|
android:icon="@drawable/ic_album"
|
||||||
android:title="@string/nav_albums"
|
android:title="相册" />
|
||||||
android:orderInCategory="2" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_history"
|
android:id="@+id/nav_history"
|
||||||
android:icon="@drawable/ic_history"
|
android:icon="@drawable/ic_history"
|
||||||
android:title="@string/nav_history"
|
android:title="历史" />
|
||||||
android:orderInCategory="3" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_settings"
|
android:id="@+id/nav_settings"
|
||||||
android:icon="@drawable/ic_settings"
|
android:icon="@drawable/ic_settings"
|
||||||
android:title="@string/nav_settings"
|
android:title="设置" />
|
||||||
android:orderInCategory="4" />
|
</menu>
|
||||||
</menu>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@color/ic_launcher_background"/>
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@drawable/ic_app_icon_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<background android:drawable="@color/ic_launcher_background"/>
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
<foreground android:drawable="@drawable/ic_app_icon_foreground"/>
|
||||||
</adaptive-icon>
|
</adaptive-icon>
|
||||||
@@ -0,0 +1,537 @@
|
|||||||
|
# 大文件夹扫描性能优化方案
|
||||||
|
|
||||||
|
## 问题描述
|
||||||
|
|
||||||
|
当存在大文件夹(如包含数千张图片)时,每次更新壁纸都需要扫描所有文件夹,导致:
|
||||||
|
- ⏱️ 更换壁纸响应缓慢
|
||||||
|
- 🔋 耗电量增加
|
||||||
|
- 📱 UI 卡顿
|
||||||
|
|
||||||
|
## 当前扫描机制分析
|
||||||
|
|
||||||
|
### 扫描触发点
|
||||||
|
|
||||||
|
1. **AutoWallpaperService.getNextMedia()** - 每次更换壁纸都扫描(最频繁)
|
||||||
|
2. **AlbumManagementFragment** - 每次显示相册列表都扫描
|
||||||
|
3. **AlbumEditorActivity** - 添加文件夹、编辑相册时扫描
|
||||||
|
4. **CacheScanReceiver** - 定时清除缓存并重新扫描
|
||||||
|
|
||||||
|
### 当前缓存策略
|
||||||
|
|
||||||
|
```java
|
||||||
|
// MediaScanner.java:43
|
||||||
|
private static final long CACHE_DURATION = 5000; // 5秒内不重复扫描
|
||||||
|
```
|
||||||
|
|
||||||
|
**问题**:
|
||||||
|
- 缓存时间太短(仅5秒)
|
||||||
|
- 定时扫描会清除所有缓存
|
||||||
|
- 每次创建新的 MediaScanner 实例
|
||||||
|
|
||||||
|
## 优化方案
|
||||||
|
|
||||||
|
### 方案一:延长缓存有效期 ⭐⭐⭐⭐⭐
|
||||||
|
|
||||||
|
**优先级**:高
|
||||||
|
**难度**:低
|
||||||
|
**效果**:立即见效
|
||||||
|
|
||||||
|
#### 实施步骤
|
||||||
|
|
||||||
|
**1. 修改 `MediaScanner.java` 缓存时间**
|
||||||
|
|
||||||
|
```java
|
||||||
|
// 从 5 秒延长到 30 分钟
|
||||||
|
private static final long CACHE_DURATION = 30 * 60 * 1000; // 30分钟
|
||||||
|
```
|
||||||
|
|
||||||
|
**或者根据文件夹大小动态调整**:
|
||||||
|
|
||||||
|
```java
|
||||||
|
/**
|
||||||
|
* 根据文件数量动态计算缓存有效期
|
||||||
|
*/
|
||||||
|
private long getCacheDuration(int fileCount) {
|
||||||
|
if (fileCount < 100) return 5 * 60 * 1000; // 5分钟
|
||||||
|
if (fileCount < 1000) return 15 * 60 * 1000; // 15分钟
|
||||||
|
if (fileCount < 5000) return 30 * 60 * 1000; // 30分钟
|
||||||
|
return 60 * 60 * 1000; // 1小时
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在 scanFolder() 中使用
|
||||||
|
public List<WallpaperMedia> scanFolder(String folderPath) {
|
||||||
|
Long lastScan = lastScanTime.get(folderPath);
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// 使用动态缓存时间
|
||||||
|
List<WallpaperMedia> cached = memoryCache.get(folderPath);
|
||||||
|
if (cached != null && lastScan != null) {
|
||||||
|
long cacheDuration = getCacheDuration(cached.size());
|
||||||
|
if ((currentTime - lastScan) < cacheDuration) {
|
||||||
|
Log.i(TAG, "Using memory cache for: " + folderPath);
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... 继续扫描逻辑
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**优点**:
|
||||||
|
- ✅ 实施简单,只需修改一个常量
|
||||||
|
- ✅ 减少 90% 以上的扫描次数
|
||||||
|
- ✅ 不影响现有功能
|
||||||
|
|
||||||
|
**缺点**:
|
||||||
|
- ⚠️ 新增文件可能不会立即显示(需要等缓存过期或手动刷新)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 方案二:优化 AutoWallpaperService 扫描逻辑 ⭐⭐⭐⭐⭐
|
||||||
|
|
||||||
|
**优先级**:高
|
||||||
|
**难度**:中
|
||||||
|
**效果**:显著提升
|
||||||
|
|
||||||
|
#### 问题定位
|
||||||
|
|
||||||
|
`AutoWallpaperService.java:661-671`
|
||||||
|
|
||||||
|
```java
|
||||||
|
// 当前代码:每次更换壁纸都会创建新的 MediaScanner 并扫描
|
||||||
|
if (folders != null && !folders.isEmpty()) {
|
||||||
|
MediaScanner scanner = new MediaScanner(AutoWallpaperService.this);
|
||||||
|
for (String folder : folders) {
|
||||||
|
List<WallpaperMedia> folderMedia = scanner.scanFolder(folder);
|
||||||
|
allMedia.addAll(folderMedia);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 优化方案
|
||||||
|
|
||||||
|
**1. 使用单例 MediaScanner**
|
||||||
|
|
||||||
|
在 `WallpaperEngine` 中添加成员变量:
|
||||||
|
|
||||||
|
```java
|
||||||
|
class WallpaperEngine extends Engine {
|
||||||
|
private final ImageLoader imageLoader;
|
||||||
|
private final WallpaperPreferences prefs;
|
||||||
|
private final WallpaperHistoryManager historyManager;
|
||||||
|
private final AlbumPreferences albumPrefs;
|
||||||
|
private final Handler handler;
|
||||||
|
private final FileLogger fileLogger;
|
||||||
|
private final ExecutorService backgroundExecutor;
|
||||||
|
private final VideoPlayer videoPlayer;
|
||||||
|
private final MediaScanner mediaScanner; // 新增:单例 MediaScanner
|
||||||
|
|
||||||
|
// ... 其他成员变量
|
||||||
|
|
||||||
|
public WallpaperEngine() {
|
||||||
|
this.imageLoader = new ImageLoader(AutoWallpaperService.this);
|
||||||
|
this.prefs = new WallpaperPreferences(AutoWallpaperService.this);
|
||||||
|
this.historyManager = new WallpaperHistoryManager(AutoWallpaperService.this);
|
||||||
|
this.albumPrefs = new AlbumPreferences(AutoWallpaperService.this);
|
||||||
|
this.handler = new Handler(Looper.getMainLooper());
|
||||||
|
this.fileLogger = FileLogger.getInstance(AutoWallpaperService.this);
|
||||||
|
this.backgroundExecutor = Executors.newSingleThreadExecutor(/* ... */);
|
||||||
|
this.videoPlayer = new VideoPlayer();
|
||||||
|
this.mediaScanner = new MediaScanner(AutoWallpaperService.this); // 新增
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**2. 修改 getNextMedia() 方法**
|
||||||
|
|
||||||
|
```java
|
||||||
|
private WallpaperMedia getNextMedia(AppConfig config) {
|
||||||
|
String lastUri = prefs.getLastUri();
|
||||||
|
List<WallpaperMedia> allMedia = new ArrayList<>();
|
||||||
|
|
||||||
|
// 1. 从文件夹扫描媒体(使用单例 MediaScanner)
|
||||||
|
List<String> folders = config.getSelectedFolders();
|
||||||
|
if (folders != null && !folders.isEmpty()) {
|
||||||
|
// 不再创建新的 MediaScanner,使用成员变量
|
||||||
|
for (String folder : folders) {
|
||||||
|
List<WallpaperMedia> folderMedia = mediaScanner.scanFolder(folder);
|
||||||
|
allMedia.addAll(folderMedia);
|
||||||
|
}
|
||||||
|
updateAlbumLastScanTime(config.getAlbumId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... 其余逻辑不变
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**3. 在 cleanup() 中释放资源**
|
||||||
|
|
||||||
|
```java
|
||||||
|
public void cleanup() {
|
||||||
|
// ... 现有清理逻辑
|
||||||
|
|
||||||
|
// 关闭 MediaScanner
|
||||||
|
if (mediaScanner != null) {
|
||||||
|
mediaScanner.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**优点**:
|
||||||
|
- ✅ 避免重复创建 MediaScanner 实例
|
||||||
|
- ✅ 充分利用内存缓存
|
||||||
|
- ✅ 减少对象创建开销
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 方案三:优化定时扫描策略 ⭐⭐⭐⭐
|
||||||
|
|
||||||
|
**优先级**:中
|
||||||
|
**难度**:中
|
||||||
|
**效果**:减少不必要的扫描
|
||||||
|
|
||||||
|
#### 问题分析
|
||||||
|
|
||||||
|
`CacheScanReceiver.java:82`
|
||||||
|
|
||||||
|
```java
|
||||||
|
// 当前代码:清除缓存并重新扫描
|
||||||
|
scanner.rescanFolder(folder);
|
||||||
|
```
|
||||||
|
|
||||||
|
这会导致:
|
||||||
|
- 清除所有缓存(包括内存和磁盘)
|
||||||
|
- 下次访问时必须重新扫描
|
||||||
|
|
||||||
|
#### 优化方案
|
||||||
|
|
||||||
|
**1. 智能缓存刷新**
|
||||||
|
|
||||||
|
不要完全清除缓存,而是检查文件夹是否有变化:
|
||||||
|
|
||||||
|
```java
|
||||||
|
/**
|
||||||
|
* 智能扫描:只在文件夹有变化时才重新扫描
|
||||||
|
*/
|
||||||
|
public List<WallpaperMedia> smartScanFolder(String folderPath) {
|
||||||
|
// 获取当前缓存
|
||||||
|
List<WallpaperMedia> cached = memoryCache.get(folderPath);
|
||||||
|
|
||||||
|
if (cached != null && !cached.isEmpty()) {
|
||||||
|
// 检查文件夹是否有变化(比较文件数量或最后修改时间)
|
||||||
|
int currentFileCount = getFileCount(folderPath);
|
||||||
|
|
||||||
|
if (currentFileCount == cached.size()) {
|
||||||
|
// 文件数量没变,使用缓存
|
||||||
|
Log.i(TAG, "Folder unchanged, using cache: " + folderPath);
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文件夹有变化,重新扫描
|
||||||
|
Log.i(TAG, "Folder changed, rescanning: " + folderPath);
|
||||||
|
return rescanFolder(folderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 快速获取文件夹中的文件数量(不加载完整信息)
|
||||||
|
*/
|
||||||
|
private int getFileCount(String folderPath) {
|
||||||
|
try {
|
||||||
|
if (folderPath.startsWith("content://")) {
|
||||||
|
Uri folderUri = Uri.parse(folderPath);
|
||||||
|
DocumentFile folder = DocumentFile.fromTreeUri(context, folderUri);
|
||||||
|
if (folder != null && folder.exists()) {
|
||||||
|
DocumentFile[] files = folder.listFiles();
|
||||||
|
return files != null ? files.length : 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
File folder = new File(folderPath);
|
||||||
|
if (folder.exists() && folder.isDirectory()) {
|
||||||
|
File[] files = folder.listFiles();
|
||||||
|
return files != null ? files.length : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Error getting file count", e);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**2. 修改 CacheScanReceiver**
|
||||||
|
|
||||||
|
```java
|
||||||
|
private void scanAllAlbums(Context context, FileLogger fileLogger) {
|
||||||
|
AlbumPreferences albumPrefs = new AlbumPreferences(context);
|
||||||
|
List<Album> albums = albumPrefs.loadAlbums();
|
||||||
|
|
||||||
|
if (albums == null || albums.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaScanner scanner = new MediaScanner(context);
|
||||||
|
|
||||||
|
for (Album album : albums) {
|
||||||
|
List<String> folders = album.getFolders();
|
||||||
|
if (folders == null || folders.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean albumScanned = false;
|
||||||
|
|
||||||
|
for (String folder : folders) {
|
||||||
|
try {
|
||||||
|
// 使用智能扫描代替强制重新扫描
|
||||||
|
scanner.smartScanFolder(folder);
|
||||||
|
albumScanned = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Error scanning folder: " + folder, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (albumScanned) {
|
||||||
|
album.setLastScanTime(System.currentTimeMillis());
|
||||||
|
albumPrefs.updateAlbum(album);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scanner.shutdown();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**优点**:
|
||||||
|
- ✅ 只在文件夹真正变化时才重新扫描
|
||||||
|
- ✅ 大幅减少不必要的扫描
|
||||||
|
- ✅ 保持缓存有效性
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 方案四:添加手动刷新功能 ⭐⭐⭐
|
||||||
|
|
||||||
|
**优先级**:低
|
||||||
|
**难度**:低
|
||||||
|
**效果**:提升用户体验
|
||||||
|
|
||||||
|
#### 实施步骤
|
||||||
|
|
||||||
|
**1. 在相册管理页面添加刷新按钮**
|
||||||
|
|
||||||
|
`AlbumManagementFragment.java`
|
||||||
|
|
||||||
|
```java
|
||||||
|
private MaterialButton btnRefreshAll;
|
||||||
|
|
||||||
|
private void initViews(View view) {
|
||||||
|
// ... 现有代码
|
||||||
|
|
||||||
|
btnRefreshAll = view.findViewById(R.id.btnRefreshAll);
|
||||||
|
btnRefreshAll.setOnClickListener(v -> refreshAllAlbums());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 手动刷新所有相册
|
||||||
|
*/
|
||||||
|
private void refreshAllAlbums() {
|
||||||
|
Toast.makeText(requireContext(), "正在刷新相册...", Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
// 在后台线程执行
|
||||||
|
new Thread(() -> {
|
||||||
|
MediaScanner scanner = new MediaScanner(requireContext());
|
||||||
|
|
||||||
|
for (Album album : albums) {
|
||||||
|
List<String> folders = album.getFolders();
|
||||||
|
if (folders != null && !folders.isEmpty()) {
|
||||||
|
for (String folder : folders) {
|
||||||
|
scanner.rescanFolder(folder); // 强制重新扫描
|
||||||
|
}
|
||||||
|
album.setLastScanTime(System.currentTimeMillis());
|
||||||
|
albumPrefs.updateAlbum(album);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scanner.shutdown();
|
||||||
|
|
||||||
|
// 回到主线程更新 UI
|
||||||
|
requireActivity().runOnUiThread(() -> {
|
||||||
|
loadAlbums();
|
||||||
|
Toast.makeText(requireContext(), "刷新完成", Toast.LENGTH_SHORT).show();
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**2. 在设置页面添加"清除缓存"选项**
|
||||||
|
|
||||||
|
`SettingsFragment.java`
|
||||||
|
|
||||||
|
```java
|
||||||
|
private MaterialButton btnClearCache;
|
||||||
|
|
||||||
|
private void initViews(View view) {
|
||||||
|
// ... 现有代码
|
||||||
|
|
||||||
|
btnClearCache = view.findViewById(R.id.btnClearCache);
|
||||||
|
btnClearCache.setOnClickListener(v -> clearAllCache());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除所有扫描缓存
|
||||||
|
*/
|
||||||
|
private void clearAllCache() {
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle("清除缓存")
|
||||||
|
.setMessage("清除缓存后,下次访问相册时会重新扫描文件夹。确定要清除吗?")
|
||||||
|
.setPositiveButton("清除", (dialog, which) -> {
|
||||||
|
MediaScanner scanner = new MediaScanner(requireContext());
|
||||||
|
scanner.clearAllCache();
|
||||||
|
scanner.shutdown();
|
||||||
|
Toast.makeText(requireContext(), "缓存已清除", Toast.LENGTH_SHORT).show();
|
||||||
|
})
|
||||||
|
.setNegativeButton("取消", null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 方案五:添加用户配置选项 ⭐⭐
|
||||||
|
|
||||||
|
**优先级**:低
|
||||||
|
**难度**:中
|
||||||
|
**效果**:灵活性提升
|
||||||
|
|
||||||
|
#### 实施步骤
|
||||||
|
|
||||||
|
在 `AppConfig` 中添加扫描策略配置:
|
||||||
|
|
||||||
|
```java
|
||||||
|
public enum ScanStrategy {
|
||||||
|
REALTIME, // 实时扫描(缓存5分钟)
|
||||||
|
BALANCED, // 平衡模式(缓存30分钟)- 默认
|
||||||
|
PERFORMANCE // 性能优先(缓存1小时)
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScanStrategy scanStrategy = ScanStrategy.BALANCED;
|
||||||
|
|
||||||
|
public ScanStrategy getScanStrategy() {
|
||||||
|
return scanStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setScanStrategy(ScanStrategy scanStrategy) {
|
||||||
|
this.scanStrategy = scanStrategy;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
在 `MediaScanner` 中根据策略调整缓存时间:
|
||||||
|
|
||||||
|
```java
|
||||||
|
private long getCacheDurationByStrategy(ScanStrategy strategy, int fileCount) {
|
||||||
|
switch (strategy) {
|
||||||
|
case REALTIME:
|
||||||
|
return 5 * 60 * 1000; // 5分钟
|
||||||
|
case BALANCED:
|
||||||
|
if (fileCount < 1000) return 15 * 60 * 1000; // 15分钟
|
||||||
|
return 30 * 60 * 1000; // 30分钟
|
||||||
|
case PERFORMANCE:
|
||||||
|
return 60 * 60 * 1000; // 1小时
|
||||||
|
default:
|
||||||
|
return 30 * 60 * 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 实施建议
|
||||||
|
|
||||||
|
### 第一阶段(立即实施)⭐⭐⭐⭐⭐
|
||||||
|
|
||||||
|
1. **方案一**:延长缓存有效期到 30 分钟
|
||||||
|
2. **方案二**:使用单例 MediaScanner
|
||||||
|
|
||||||
|
**预期效果**:
|
||||||
|
- 扫描次数减少 90%+
|
||||||
|
- 壁纸更换响应速度提升 5-10 倍
|
||||||
|
- 耗电量显著降低
|
||||||
|
|
||||||
|
### 第二阶段(后续优化)⭐⭐⭐⭐
|
||||||
|
|
||||||
|
3. **方案三**:优化定时扫描策略(智能扫描)
|
||||||
|
4. **方案四**:添加手动刷新功能
|
||||||
|
|
||||||
|
**预期效果**:
|
||||||
|
- 定时扫描耗时减少 80%+
|
||||||
|
- 用户可以主动控制刷新时机
|
||||||
|
|
||||||
|
### 第三阶段(可选)⭐⭐
|
||||||
|
|
||||||
|
5. **方案五**:添加用户配置选项
|
||||||
|
|
||||||
|
**预期效果**:
|
||||||
|
- 满足不同用户的需求
|
||||||
|
- 提升用户体验
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 测试计划
|
||||||
|
|
||||||
|
### 性能测试
|
||||||
|
|
||||||
|
1. **小文件夹测试**(< 100 张图片)
|
||||||
|
- 测试缓存命中率
|
||||||
|
- 测试更换壁纸响应时间
|
||||||
|
|
||||||
|
2. **中等文件夹测试**(100-1000 张图片)
|
||||||
|
- 测试首次扫描时间
|
||||||
|
- 测试缓存有效期内的响应时间
|
||||||
|
|
||||||
|
3. **大文件夹测试**(> 1000 张图片)
|
||||||
|
- 测试扫描性能
|
||||||
|
- 测试内存占用
|
||||||
|
- 测试耗电量
|
||||||
|
|
||||||
|
### 功能测试
|
||||||
|
|
||||||
|
1. **缓存有效性测试**
|
||||||
|
- 验证缓存在有效期内正常工作
|
||||||
|
- 验证缓存过期后正确重新扫描
|
||||||
|
|
||||||
|
2. **新增文件检测测试**
|
||||||
|
- 添加新图片后,验证是否能被检测到
|
||||||
|
- 验证手动刷新功能是否正常
|
||||||
|
|
||||||
|
3. **多相册测试**
|
||||||
|
- 验证切换相册时的性能
|
||||||
|
- 验证多个相册的缓存独立性
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 风险评估
|
||||||
|
|
||||||
|
### 潜在风险
|
||||||
|
|
||||||
|
1. **新增文件延迟显示**
|
||||||
|
- 风险等级:低
|
||||||
|
- 缓解措施:提供手动刷新功能
|
||||||
|
|
||||||
|
2. **内存占用增加**
|
||||||
|
- 风险等级:低
|
||||||
|
- 缓解措施:LRU 缓存自动淘汰旧数据
|
||||||
|
|
||||||
|
3. **缓存不一致**
|
||||||
|
- 风险等级:低
|
||||||
|
- 缓解措施:定时扫描 + 手动刷新
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 总结
|
||||||
|
|
||||||
|
通过实施以上优化方案,可以显著提升大文件夹场景下的性能:
|
||||||
|
|
||||||
|
- ✅ **扫描次数减少 90%+**
|
||||||
|
- ✅ **响应速度提升 5-10 倍**
|
||||||
|
- ✅ **耗电量显著降低**
|
||||||
|
- ✅ **用户体验大幅提升**
|
||||||
|
|
||||||
|
建议优先实施**方案一**和**方案二**,这两个方案实施简单、效果显著,可以立即解决当前的性能问题。
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
# 幻灯片功能设计文档
|
||||||
|
|
||||||
|
## 功能概述
|
||||||
|
|
||||||
|
**功能定位**:应用内独立的幻灯片播放功能,从当前激活相册随机选择图片进行展示。
|
||||||
|
|
||||||
|
**核心特性**:
|
||||||
|
- 从激活相册随机抽取 n 张图片
|
||||||
|
- 全屏沉浸式播放体验
|
||||||
|
- 实时可调的播放间隔
|
||||||
|
- 播放完成后停在最后一张,用户决定下一步
|
||||||
|
|
||||||
|
**入口**:底部导航新增"幻灯片"Tab(第 5 个导航项)
|
||||||
|
|
||||||
|
**播放前流程**:
|
||||||
|
1. 用户点击幻灯片 Tab
|
||||||
|
2. 显示数量选择界面(10/20/50/全部)
|
||||||
|
3. 选择后进入全屏播放
|
||||||
|
|
||||||
|
**播放控制**:
|
||||||
|
- 播放/暂停按钮
|
||||||
|
- 上一张/下一张按钮
|
||||||
|
- 播放间隔滑块(3-15秒可调)
|
||||||
|
- 进度显示(如 "3 / 20")
|
||||||
|
- 退出按钮
|
||||||
|
|
||||||
|
## 技术架构
|
||||||
|
|
||||||
|
### 新增文件
|
||||||
|
|
||||||
|
```
|
||||||
|
cn.hugh.bz.gk2/
|
||||||
|
├── ui/
|
||||||
|
│ ├── SlideshowFragment.java # 幻灯片入口页(数量选择)
|
||||||
|
│ └── SlideshowPlayerActivity.java # 全屏播放器
|
||||||
|
```
|
||||||
|
|
||||||
|
### 布局文件
|
||||||
|
|
||||||
|
- `fragment_slideshow.xml` - 数量选择界面
|
||||||
|
- `activity_slideshow_player.xml` - 全屏播放器界面
|
||||||
|
|
||||||
|
### 数据流
|
||||||
|
|
||||||
|
```
|
||||||
|
SlideshowFragment
|
||||||
|
↓ 用户选择数量
|
||||||
|
从 AlbumPreferences 获取激活相册
|
||||||
|
↓
|
||||||
|
从 MediaScanner 获取相册图片列表
|
||||||
|
↓
|
||||||
|
随机抽取 n 张(Collections.shuffle + subList)
|
||||||
|
↓
|
||||||
|
启动 SlideshowPlayerActivity,传递图片 URI 列表
|
||||||
|
↓
|
||||||
|
Handler + postDelayed 实现定时切换
|
||||||
|
```
|
||||||
|
|
||||||
|
### 底部导航调整
|
||||||
|
|
||||||
|
- 导航项从 4 个增加到 5 个
|
||||||
|
- 顺序:主页 → 相册 → **幻灯片** → 历史 → 设置
|
||||||
|
- ViewPagerAdapter 增加 SlideshowFragment
|
||||||
|
|
||||||
|
## 界面设计
|
||||||
|
|
||||||
|
### SlideshowFragment(数量选择页)
|
||||||
|
|
||||||
|
- 简洁的卡片式布局
|
||||||
|
- 4 个选项按钮:10张 / 20张 / 50张 / 全部
|
||||||
|
- 显示当前相册名称和可用图片总数
|
||||||
|
- 如果图片不足,按钮显示实际可用数量(如相册只有 15 张,则"20张"按钮显示为"15张")
|
||||||
|
|
||||||
|
### SlideshowPlayerActivity(播放器)
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────┐
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
│ [全屏图片展示] │
|
||||||
|
│ │
|
||||||
|
│ │
|
||||||
|
├─────────────────────────────────┤
|
||||||
|
│ 3 / 20 │ ← 进度显示
|
||||||
|
│ ───────●───────────────────────│ ← 间隔滑块(3-15秒)
|
||||||
|
│ 3秒 5秒 10秒 15秒 │
|
||||||
|
│ │
|
||||||
|
│ ◀️ ▶️/⏸️ ▶️ ✕ │ ← 控制按钮
|
||||||
|
│ 上一张 播放 下一张 退出 │
|
||||||
|
└─────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
### 播放结束状态
|
||||||
|
|
||||||
|
- 显示"播放结束"提示
|
||||||
|
- 两个按钮:"重新播放" / "退出"
|
||||||
|
|
||||||
|
## 控制面板交互
|
||||||
|
|
||||||
|
### 自动隐藏逻辑
|
||||||
|
|
||||||
|
- 播放开始后 3 秒自动隐藏控制面板
|
||||||
|
- 点击屏幕任意位置显示控制面板
|
||||||
|
- 显示后 3 秒无操作再次自动隐藏
|
||||||
|
- 暂停状态下控制面板保持显示,不自动隐藏
|
||||||
|
- 用户操作控制按钮/滑块时重置隐藏计时器
|
||||||
|
|
||||||
|
### 动画效果
|
||||||
|
|
||||||
|
- 隐藏:控制面板向下滑出 + 渐隐(300ms)
|
||||||
|
- 显示:控制面板向上滑入 + 渐显(300ms)
|
||||||
|
|
||||||
|
### 实现方式
|
||||||
|
|
||||||
|
```java
|
||||||
|
Handler hideHandler = new Handler();
|
||||||
|
Runnable hideRunnable = () -> hideControlPanel();
|
||||||
|
|
||||||
|
// 重置计时器
|
||||||
|
void resetHideTimer() {
|
||||||
|
hideHandler.removeCallbacks(hideRunnable);
|
||||||
|
if (isPlaying) {
|
||||||
|
hideHandler.postDelayed(hideRunnable, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 实现清单
|
||||||
|
|
||||||
|
### 需要修改的文件
|
||||||
|
|
||||||
|
- `MainActivity.java` - 底部导航从 4 项改为 5 项
|
||||||
|
- `ViewPagerAdapter.java` - 增加 SlideshowFragment
|
||||||
|
- `activity_main.xml` - 底部导航增加幻灯片入口
|
||||||
|
|
||||||
|
### 需要新增的文件
|
||||||
|
|
||||||
|
- `SlideshowFragment.java` - 数量选择页
|
||||||
|
- `SlideshowPlayerActivity.java` - 全屏播放器
|
||||||
|
- `fragment_slideshow.xml` - 选择页布局
|
||||||
|
- `activity_slideshow_player.xml` - 播放器布局
|
||||||
|
- `ic_slideshow.xml` - 幻灯片导航图标
|
||||||
|
- AndroidManifest.xml 注册新 Activity
|
||||||
|
|
||||||
|
### 依赖现有组件
|
||||||
|
|
||||||
|
- `AlbumPreferences` - 获取激活相册
|
||||||
|
- `MediaScanner` - 扫描相册图片
|
||||||
|
- `Glide` - 图片加载和过渡动画
|
||||||
Reference in new issue
Block a user