V1.0(1)
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
4
build.gradle.kts
Normal file
@ -0,0 +1,4 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
}
|
||||
21
gradle.properties
Normal file
@ -0,0 +1,21 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. For more details, visit
|
||||
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Enables namespacing of each library's R class so that its R class includes only the
|
||||
# resources declared in the library itself and none from the library's dependencies,
|
||||
# thereby reducing the size of the R class for that library
|
||||
android.nonTransitiveRClass=true
|
||||
22
gradle/libs.versions.toml
Normal file
@ -0,0 +1,22 @@
|
||||
[versions]
|
||||
agp = "8.13.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.3.0"
|
||||
espressoCore = "3.7.0"
|
||||
appcompat = "1.7.1"
|
||||
material = "1.13.0"
|
||||
activity = "1.11.0"
|
||||
constraintlayout = "2.2.1"
|
||||
|
||||
[libraries]
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
|
||||
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
8
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
#Thu Nov 20 16:49:11 CST 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
251
gradlew
vendored
Normal file
@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
94
gradlew.bat
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
26
settings.gradle.kts
Normal file
@ -0,0 +1,26 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
google {
|
||||
content {
|
||||
includeGroupByRegex("com\\.android.*")
|
||||
includeGroupByRegex("com\\.google.*")
|
||||
includeGroupByRegex("androidx.*")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jitpack.io") }
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "My Application"
|
||||
|
||||
include(":test2")
|
||||
1
test2/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
||||
BIN
test2/WallpaperEngine
Normal file
70
test2/build.gradle.kts
Normal file
@ -0,0 +1,70 @@
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
}
|
||||
val timestamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
|
||||
android {
|
||||
namespace = "com.wall.engine.wallpaper"
|
||||
compileSdk = 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.wall.engine.wallpaper"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
setProperty("archivesBaseName","Wallpaper Engine_v"+versionName+"(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.appcompat)
|
||||
implementation(libs.material)
|
||||
implementation(libs.activity)
|
||||
implementation(libs.constraintlayout)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.ext.junit)
|
||||
androidTestImplementation(libs.espresso.core)
|
||||
|
||||
// 图片加载库
|
||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||
annotationProcessor("com.github.bumptech.glide:compiler:4.16.0")
|
||||
|
||||
// JSON解析
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
|
||||
// 其他UI组件
|
||||
implementation("androidx.viewpager2:viewpager2:1.0.0")
|
||||
implementation("androidx.recyclerview:recyclerview:1.3.2")
|
||||
// 图片缩放库(必加,否则无法缩放大图)
|
||||
implementation("com.github.chrisbanes:PhotoView:2.3.0")
|
||||
|
||||
|
||||
implementation("androidx.core:core-ktx:1.12.0")
|
||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||
}
|
||||
31
test2/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-keep class com.wall.engine.wallpaper.WallpaperItem { *; }
|
||||
|
||||
-keep class com.wall.engine.wallpaper.Urls { *; }
|
||||
-keep class com.wall.engine.wallpaper.User { *; }
|
||||
-keep class com.wall.engine.wallpaper.WallpaperItem { *; }
|
||||
-keep class com.google.gson.** { *; }
|
||||
-keepattributes Signature
|
||||
-keepattributes AnnotationDefault,RuntimeVisibleAnnotations
|
||||
-keep class com.google.gson.reflect.TypeToken { *; }
|
||||
-keep class * extends com.google.gson.reflect.TypeToken
|
||||
BIN
test2/release/Wallpaper Engine_v1.0(1)_11_28_17_11-release.apk
Normal file
BIN
test2/release/Wallpaper Engine_v1.0(1)_11_28_17_24-release.aab
Normal file
37
test2/release/output-metadata.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.wall.engine.wallpaper",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"outputFile": "Wallpaper Engine_v1.0(1)_11_28_17_11-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File",
|
||||
"baselineProfiles": [
|
||||
{
|
||||
"minApi": 28,
|
||||
"maxApi": 30,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/1/Wallpaper Engine_v1.0(1)_11_28_17_11-release.dm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minApi": 31,
|
||||
"maxApi": 2147483647,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/0/Wallpaper Engine_v1.0(1)_11_28_17_11-release.dm"
|
||||
]
|
||||
}
|
||||
],
|
||||
"minSdkVersionForDexing": 24
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.ll.zz.nn", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
42
test2/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/img"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/img"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.MyApplication">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity2"
|
||||
android:exported="false" />
|
||||
|
||||
<activity
|
||||
android:name=".FullImageActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar" />
|
||||
|
||||
<activity
|
||||
android:name=".FavoriteActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
20703
test2/src/main/assets/Animals.json
Normal file
20703
test2/src/main/assets/Experimental.json
Normal file
20703
test2/src/main/assets/Featured.json
Normal file
20703
test2/src/main/assets/Film.json
Normal file
20702
test2/src/main/assets/Nature.json
Normal file
20702
test2/src/main/assets/Patterns.json
Normal file
20702
test2/src/main/assets/Street.json
Normal file
20702
test2/src/main/assets/Travel.json
Normal file
BIN
test2/src/main/assets/custfont.ttf
Normal file
@ -0,0 +1,88 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class D4Fragment extends Fragment {
|
||||
|
||||
private RecyclerView rv4dImages;
|
||||
private D4ImageAdapter adapter;
|
||||
private List<WallpaperItem> wallpaperList;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_d4, container, false);
|
||||
|
||||
rv4dImages = view.findViewById(R.id.rv_4d_images);
|
||||
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
|
||||
gridLayoutManager.setAutoMeasureEnabled(true);
|
||||
rv4dImages.setLayoutManager(gridLayoutManager);
|
||||
|
||||
rv4dImages.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
|
||||
rv4dImages.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.HORIZONTAL));
|
||||
rv4dImages.setHasFixedSize(true);
|
||||
|
||||
|
||||
loadWallpaperData();
|
||||
|
||||
adapter = new D4ImageAdapter(getContext(), wallpaperList);
|
||||
rv4dImages.setAdapter(adapter);
|
||||
|
||||
|
||||
adapter.setOnItemClickListener((position, wallpaperItem) -> {
|
||||
|
||||
if (getContext() == null || wallpaperItem == null) {
|
||||
Toast.makeText(getContext(), "Data error", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String highResImageUrl = wallpaperItem.getUrls().getRegular();
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
highResImageUrl = wallpaperItem.getUrls().getFull();
|
||||
}
|
||||
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
Toast.makeText(getContext(), "NULL", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(getContext(), FullImageActivity.class);
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_URL, highResImageUrl);
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_ID, wallpaperItem.getId());
|
||||
String description = wallpaperItem.getAlt_description();
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = "Beautiful wallpapers";
|
||||
}
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_DESC, description);
|
||||
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void loadWallpaperData() {
|
||||
wallpaperList = JsonUtils.loadWallpapersFromJson(getContext(), "Animals.json");
|
||||
if (wallpaperList == null) {
|
||||
wallpaperList = new ArrayList<>();
|
||||
Toast.makeText(getContext(), "Failed to load wallpaper data", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import java.util.List;
|
||||
|
||||
public class D4ImageAdapter extends RecyclerView.Adapter<D4ImageAdapter.ImageViewHolder> {
|
||||
|
||||
private final Context mContext;
|
||||
private final List<WallpaperItem> mWallpaperList;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
private final RequestOptions glideOptions = new RequestOptions()
|
||||
.centerCrop()
|
||||
.placeholder(R.drawable.load_ing)
|
||||
.error(R.drawable.load_ing)
|
||||
.override(400, 600);
|
||||
public D4ImageAdapter(Context context, List<WallpaperItem> wallpaperList) {
|
||||
this.mContext = context;
|
||||
this.mWallpaperList = wallpaperList;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int position, WallpaperItem wallpaperItem);
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.mOnItemClickListener = listener;
|
||||
}
|
||||
|
||||
static class ImageViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView ivItem4d;
|
||||
|
||||
public ImageViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ivItem4d = itemView.findViewById(R.id.iv_item_4d);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.item_4d_image, parent, false);
|
||||
return new ImageViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
|
||||
WallpaperItem wallpaperItem = mWallpaperList.get(position);
|
||||
|
||||
|
||||
Glide.with(mContext)
|
||||
.load(wallpaperItem.getUrls().getSmall())
|
||||
.apply(glideOptions)
|
||||
.into(holder.ivItem4d);
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(position, wallpaperItem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mWallpaperList == null ? 0 : mWallpaperList.size();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,137 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FavoriteActivity extends AppCompatActivity {
|
||||
|
||||
private RecyclerView rvFavoriteImages;
|
||||
private TextView tvEmpty;
|
||||
private D4ImageAdapter adapter;
|
||||
private FavoriteManager favoriteManager;
|
||||
private List<WallpaperItem> favoriteList;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_favorite);
|
||||
|
||||
setupStatusBar();
|
||||
initViews();
|
||||
setupRecyclerView();
|
||||
loadFavoriteData();
|
||||
}
|
||||
|
||||
private void setupStatusBar() {
|
||||
Window window = getWindow();
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(getResources().getColor(android.R.color.transparent));
|
||||
|
||||
WindowInsetsControllerCompat insetsController = WindowCompat.getInsetsController(window, window.getDecorView());
|
||||
if (insetsController != null) {
|
||||
insetsController.setAppearanceLightStatusBars(true);
|
||||
}
|
||||
|
||||
View statusBarPlaceholder = findViewById(R.id.status_bar_placeholder);
|
||||
int statusBarHeight = getStatusBarHeight();
|
||||
if (statusBarHeight > 0) {
|
||||
ViewGroup.LayoutParams params = statusBarPlaceholder.getLayoutParams();
|
||||
params.height = statusBarHeight;
|
||||
statusBarPlaceholder.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
|
||||
private int getStatusBarHeight() {
|
||||
int result = 0;
|
||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
result = getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
rvFavoriteImages = findViewById(R.id.rv_favorite_images);
|
||||
tvEmpty = findViewById(R.id.tv_empty);
|
||||
|
||||
findViewById(R.id.btn_back).setOnClickListener(v -> finish());
|
||||
|
||||
favoriteManager = new FavoriteManager(this);
|
||||
favoriteList = new ArrayList<>();
|
||||
}
|
||||
|
||||
private void setupRecyclerView() {
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 2);
|
||||
rvFavoriteImages.setLayoutManager(gridLayoutManager);
|
||||
|
||||
adapter = new D4ImageAdapter(this, favoriteList);
|
||||
rvFavoriteImages.setAdapter(adapter);
|
||||
|
||||
adapter.setOnItemClickListener((position, wallpaperItem) -> {
|
||||
if (wallpaperItem == null) {
|
||||
Toast.makeText(FavoriteActivity.this, "Data error", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String highResImageUrl = wallpaperItem.getUrls().getRegular();
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
highResImageUrl = wallpaperItem.getUrls().getFull();
|
||||
}
|
||||
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
Toast.makeText(FavoriteActivity.this, "Image URL is empty", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(FavoriteActivity.this, FullImageActivity.class);
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_URL, highResImageUrl);
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_ID, wallpaperItem.getId());
|
||||
|
||||
String description = wallpaperItem.getAlt_description();
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = "Favorited wallpapers";
|
||||
}
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_DESC, description);
|
||||
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
private void loadFavoriteData() {
|
||||
favoriteList.clear();
|
||||
favoriteList.addAll(favoriteManager.getFavoriteItems());
|
||||
|
||||
Log.d("FavoriteActivity", "加载收藏数据,数量: " + favoriteList.size());
|
||||
|
||||
if (favoriteList.isEmpty()) {
|
||||
tvEmpty.setVisibility(View.VISIBLE);
|
||||
rvFavoriteImages.setVisibility(View.GONE);
|
||||
|
||||
} else {
|
||||
tvEmpty.setVisibility(View.GONE);
|
||||
rvFavoriteImages.setVisibility(View.VISIBLE);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
loadFavoriteData();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.util.List;
|
||||
|
||||
public class FavoriteFragment extends Fragment {
|
||||
private RecyclerView rvFavoriteImages;
|
||||
private D4ImageAdapter adapter;
|
||||
private FavoriteManager favoriteManager;
|
||||
private List<WallpaperItem> favoriteList;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_d4, container, false);
|
||||
|
||||
rvFavoriteImages = view.findViewById(R.id.rv_4d_images);
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
|
||||
rvFavoriteImages.setLayoutManager(gridLayoutManager);
|
||||
|
||||
favoriteManager = new FavoriteManager(getContext());
|
||||
loadFavoriteData();
|
||||
|
||||
adapter = new D4ImageAdapter(getContext(), favoriteList);
|
||||
rvFavoriteImages.setAdapter(adapter);
|
||||
|
||||
adapter.setOnItemClickListener((position, wallpaperItem) -> {
|
||||
if (getContext() == null || wallpaperItem == null) {
|
||||
Toast.makeText(getContext(), "Data error", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String highResImageUrl = wallpaperItem.getUrls().getRegular();
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
highResImageUrl = wallpaperItem.getUrls().getFull();
|
||||
}
|
||||
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
Toast.makeText(getContext(), "NULL", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(getContext(), FullImageActivity.class);
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_URL, highResImageUrl);
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_ID, wallpaperItem.getId());
|
||||
|
||||
String description = wallpaperItem.getAlt_description();
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = "Favorited wallpapers";
|
||||
}
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_DESC, description);
|
||||
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void loadFavoriteData() {
|
||||
favoriteList = favoriteManager.getFavoriteItems();
|
||||
// 移除此处的Toast提示,避免重复触发
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
loadFavoriteData();
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class FavoriteManager {
|
||||
private static final String TAG = "FavoriteManager";
|
||||
private static final String PREF_NAME = "favorite_wallpapers";
|
||||
private static final String KEY_FAVORITE_IDS = "favorite_ids";
|
||||
private static final String KEY_FAVORITE_ITEMS = "favorite_items";
|
||||
|
||||
private SharedPreferences sharedPreferences;
|
||||
private Gson gson;
|
||||
|
||||
public FavoriteManager(Context context) {
|
||||
sharedPreferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||
gson = new Gson();
|
||||
}
|
||||
|
||||
// 添加收藏
|
||||
public void addFavorite(WallpaperItem item) {
|
||||
try {
|
||||
String itemId = item.getId();
|
||||
Log.d(TAG, "Add to Favorites: " + itemId);
|
||||
|
||||
|
||||
Set<String> favoriteIds = getFavoriteIds();
|
||||
favoriteIds.add(itemId);
|
||||
|
||||
List<WallpaperItem> favorites = getFavoriteItems();
|
||||
|
||||
|
||||
for (int i = favorites.size() - 1; i >= 0; i--) {
|
||||
if (favorites.get(i).getId().equals(itemId)) {
|
||||
favorites.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
favorites.add(item);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putStringSet(KEY_FAVORITE_IDS, new HashSet<>(favoriteIds)); // 创建新的HashSet避免并发问题
|
||||
editor.putString(KEY_FAVORITE_ITEMS, gson.toJson(favorites));
|
||||
editor.apply();
|
||||
|
||||
Log.d(TAG, "Added to Favorites: " + favorites.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to add to favorites", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 移除收藏
|
||||
public void removeFavorite(String itemId) {
|
||||
try {
|
||||
Log.d(TAG, "Unfavorite: " + itemId);
|
||||
|
||||
|
||||
Set<String> favoriteIds = getFavoriteIds();
|
||||
favoriteIds.remove(itemId);
|
||||
|
||||
|
||||
List<WallpaperItem> favorites = getFavoriteItems();
|
||||
for (int i = favorites.size() - 1; i >= 0; i--) {
|
||||
if (favorites.get(i).getId().equals(itemId)) {
|
||||
favorites.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putStringSet(KEY_FAVORITE_IDS, new HashSet<>(favoriteIds));
|
||||
editor.putString(KEY_FAVORITE_ITEMS, gson.toJson(favorites));
|
||||
editor.apply();
|
||||
|
||||
Log.d(TAG, "Unfavorited successfully: " + favorites.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to unfavorite", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否已收藏
|
||||
public boolean isFavorite(String itemId) {
|
||||
Set<String> favoriteIds = getFavoriteIds();
|
||||
boolean isFav = favoriteIds.contains(itemId);
|
||||
Log.d(TAG, "检查收藏状态: " + itemId + " -> " + isFav);
|
||||
return isFav;
|
||||
}
|
||||
|
||||
// 获取所有收藏的ID
|
||||
public Set<String> getFavoriteIds() {
|
||||
Set<String> ids = sharedPreferences.getStringSet(KEY_FAVORITE_IDS, new HashSet<>());
|
||||
Log.d(TAG, "获取收藏ID数量: " + ids.size());
|
||||
return new HashSet<>(ids); // 返回新的HashSet避免并发问题
|
||||
}
|
||||
|
||||
// 获取所有收藏项
|
||||
public List<WallpaperItem> getFavoriteItems() {
|
||||
try {
|
||||
String json = sharedPreferences.getString(KEY_FAVORITE_ITEMS, "[]");
|
||||
Type listType = new TypeToken<List<WallpaperItem>>(){}.getType();
|
||||
List<WallpaperItem> items = gson.fromJson(json, listType);
|
||||
if (items == null) {
|
||||
items = new ArrayList<>();
|
||||
}
|
||||
Log.d(TAG, "获取收藏项数量: " + items.size());
|
||||
return items;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "获取收藏项失败", e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,440 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.DecodeFormat;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.wall.engine.wallpaper.databinding.ActivityFullImageBinding;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
// 壁纸设置类型常量
|
||||
interface WallpaperType {
|
||||
int TYPE_HOME = 1; // 桌面
|
||||
int TYPE_LOCK = 2; // 锁屏
|
||||
int TYPE_BOTH = 3; // 桌面+锁屏
|
||||
}
|
||||
|
||||
public class FullImageActivity extends AppCompatActivity implements WallpaperType {
|
||||
// 传递参数Key
|
||||
public static final String EXTRA_IMAGE_URL = "extra_image_url";
|
||||
public static final String EXTRA_IMAGE_ID = "extra_image_id";
|
||||
public static final String EXTRA_IMAGE_DESC = "extra_image_desc";
|
||||
|
||||
private ActivityFullImageBinding binding;
|
||||
private String imageUrl;
|
||||
private String imageId;
|
||||
private String imageDesc;
|
||||
private File tempFile; // 仅用于设置壁纸的临时文件
|
||||
private WallpaperManager wallpaperManager;
|
||||
private FavoriteManager favoriteManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityFullImageBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
// 沉浸式全屏
|
||||
initFullScreen();
|
||||
|
||||
// 初始化管理器
|
||||
wallpaperManager = WallpaperManager.getInstance(this);
|
||||
favoriteManager = new FavoriteManager(this);
|
||||
|
||||
// 获取传递的参数
|
||||
getIntentData();
|
||||
// 加载图片
|
||||
loadImage(imageUrl);
|
||||
// 初始化点击事件
|
||||
initClick();
|
||||
// 初始化点赞状态
|
||||
initFavoriteState();
|
||||
}
|
||||
|
||||
private void initFullScreen() {
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().hide();
|
||||
}
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
WindowInsetsControllerCompat insetsController = WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
|
||||
if (insetsController != null) {
|
||||
insetsController.hide(WindowInsetsCompat.Type.statusBars() | WindowInsetsCompat.Type.navigationBars());
|
||||
insetsController.setSystemBarsBehavior(WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
||||
}
|
||||
}
|
||||
|
||||
private void getIntentData() {
|
||||
Intent intent = getIntent();
|
||||
imageUrl = intent.getStringExtra(EXTRA_IMAGE_URL);
|
||||
imageId = intent.getStringExtra(EXTRA_IMAGE_ID);
|
||||
imageDesc = intent.getStringExtra(EXTRA_IMAGE_DESC);
|
||||
|
||||
if (imageDesc != null && !imageDesc.isEmpty()) {
|
||||
binding.tvContent.setText(imageDesc);
|
||||
} else {
|
||||
binding.tvContent.setText(getString(R.string.app_name));
|
||||
}
|
||||
|
||||
// 初始化临时文件路径(应用私有目录,无需权限)
|
||||
if (imageId == null) {
|
||||
imageId = "wallpaper_" + System.currentTimeMillis();
|
||||
}
|
||||
tempFile = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES), imageId + ".jpg");
|
||||
}
|
||||
|
||||
private void loadImage(String imageUrl) {
|
||||
if (imageUrl == null || imageUrl.isEmpty()) {
|
||||
Toast.makeText(this, "Image URL is empty, cannot load", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
RequestOptions options = new RequestOptions()
|
||||
.format(DecodeFormat.PREFER_RGB_565)
|
||||
.placeholder(R.drawable.load_ing)
|
||||
.error(R.drawable.load_ing);
|
||||
|
||||
// 检查临时文件是否存在
|
||||
if (tempFile.exists()) {
|
||||
Glide.with(this)
|
||||
.load(tempFile)
|
||||
.apply(options)
|
||||
.transition(DrawableTransitionOptions.withCrossFade(500))
|
||||
.into(binding.imageviewPreview);
|
||||
} else {
|
||||
// 从网络加载
|
||||
Glide.with(this)
|
||||
.asDrawable()
|
||||
.load(imageUrl)
|
||||
.apply(options)
|
||||
.skipMemoryCache(true)
|
||||
.transition(DrawableTransitionOptions.withCrossFade(500))
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||
Log.e("FullImage", "Failed to load image:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.centerCrop()
|
||||
.into(binding.imageviewPreview);
|
||||
}
|
||||
}
|
||||
|
||||
private void initFavoriteState() {
|
||||
if (imageId == null) return;
|
||||
boolean isFavorited = favoriteManager.isFavorite(imageId);
|
||||
binding.imageFavorite.setSelected(isFavorited);
|
||||
binding.imageFavorite.setImageResource(isFavorited ? R.drawable.like_red : R.drawable.like);
|
||||
}
|
||||
|
||||
private void initClick() {
|
||||
// 返回按钮
|
||||
binding.imageviewBack.setOnClickListener(v -> finish());
|
||||
|
||||
// 下载按钮(无需权限)
|
||||
binding.layoutDownload.setOnClickListener(v -> startDownload());
|
||||
|
||||
// 修正:设置壁纸按钮ID为button_set1(与布局一致)
|
||||
binding.buttonSet1.setOnClickListener(v -> showWallpaperTypeDialog());
|
||||
|
||||
// 点赞按钮
|
||||
binding.imageFavorite.setOnClickListener(v -> toggleFavorite());
|
||||
}
|
||||
|
||||
private void toggleFavorite() {
|
||||
if (imageId == null) {
|
||||
Toast.makeText(this, "Cannot add to favorites", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
WallpaperItem item = new WallpaperItem();
|
||||
item.setId(imageId);
|
||||
item.setAlt_description(imageDesc);
|
||||
|
||||
Urls urls = new Urls();
|
||||
urls.setRegular(imageUrl);
|
||||
urls.setSmall(imageUrl);
|
||||
urls.setFull(imageUrl);
|
||||
item.setUrls(urls);
|
||||
|
||||
boolean isFavorited = favoriteManager.isFavorite(imageId);
|
||||
|
||||
if (isFavorited) {
|
||||
favoriteManager.removeFavorite(imageId);
|
||||
binding.imageFavorite.setSelected(false);
|
||||
binding.imageFavorite.setImageResource(R.drawable.like);
|
||||
Toast.makeText(this, "Cancel collection", Toast.LENGTH_SHORT).show();
|
||||
Log.d("FullImageActivity", "Cancel collection: " + imageId);
|
||||
} else {
|
||||
favoriteManager.addFavorite(item);
|
||||
binding.imageFavorite.setSelected(true);
|
||||
binding.imageFavorite.setImageResource(R.drawable.like_red);
|
||||
Toast.makeText(this, "Favorited", Toast.LENGTH_SHORT).show();
|
||||
Log.d("FullImageActivity", "Favorited: " + imageId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核心:无需存储权限,直接通过MediaStore保存到相册
|
||||
*/
|
||||
private void startDownload() {
|
||||
// 修正:加载进度条与下载按钮ID(与布局一致)
|
||||
showLoading(binding.pbDownload, binding.imageDownload, true);
|
||||
|
||||
// 异步下载并写入相册
|
||||
new Thread(() -> {
|
||||
try {
|
||||
// 1. 下载图片到内存流
|
||||
URL url = new URL(imageUrl);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream is = conn.getInputStream();
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
|
||||
if (bitmap == null) {
|
||||
throw new IOException("Failed to decode image");
|
||||
}
|
||||
|
||||
// 2. 写入MediaStore(无需权限)
|
||||
ContentValues values = new ContentValues();
|
||||
// 设置图片信息
|
||||
values.put(MediaStore.Images.Media.DISPLAY_NAME, imageId + ".jpg");
|
||||
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
|
||||
// 相册显示路径:DCIM/Wallpaper
|
||||
values.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_DCIM + "/Wallpaper");
|
||||
values.put(MediaStore.Images.Media.WIDTH, bitmap.getWidth());
|
||||
values.put(MediaStore.Images.Media.HEIGHT, bitmap.getHeight());
|
||||
|
||||
// Android 10+ 标记为待处理
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 1);
|
||||
}
|
||||
|
||||
// 插入到媒体库
|
||||
Uri imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
|
||||
if (imageUri == null) {
|
||||
throw new IOException("Failed to import to media library");
|
||||
}
|
||||
|
||||
// 写入图片数据
|
||||
try (OutputStream os = getContentResolver().openOutputStream(imageUri)) {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os);
|
||||
}
|
||||
|
||||
// 完成插入(Android 10+)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
values.clear();
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 0);
|
||||
getContentResolver().update(imageUri, values, null, null);
|
||||
}
|
||||
|
||||
// 保存临时文件(用于设置壁纸)
|
||||
saveTempFile(bitmap);
|
||||
|
||||
// 主线程更新UI
|
||||
runOnUiThread(() -> {
|
||||
showLoading(binding.pbDownload, binding.imageDownload, false);
|
||||
Toast.makeText(this, "Download successful. Saved to your photo library", Toast.LENGTH_LONG).show();
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
runOnUiThread(() -> {
|
||||
showLoading(binding.pbDownload, binding.imageDownload, false);
|
||||
Toast.makeText(FullImageActivity.this, "Download failed:" + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存临时文件到应用私有目录(用于设置壁纸,无需权限)
|
||||
*/
|
||||
private void saveTempFile(Bitmap bitmap) throws IOException {
|
||||
if (!tempFile.getParentFile().exists()) {
|
||||
tempFile.getParentFile().mkdirs();
|
||||
}
|
||||
try (OutputStream os = new java.io.FileOutputStream(tempFile)) {
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, os);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void showWallpaperTypeDialog() {
|
||||
// 1. 加载自定义弹窗布局
|
||||
View dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_wallpaper_type, null);
|
||||
|
||||
// 2. 获取布局中的三个选项容器
|
||||
LinearLayout layoutHome = dialogView.findViewById(R.id.layout_ic_home);
|
||||
LinearLayout layoutLock = dialogView.findViewById(R.id.layout_ic_lock);
|
||||
LinearLayout layoutBoth = dialogView.findViewById(R.id.layout_ic_both);
|
||||
|
||||
// 3. 创建AlertDialog并设置透明背景(避免遮挡圆角)
|
||||
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||
.setView(dialogView)
|
||||
.create();
|
||||
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
// 4. 绑定选项点击事件
|
||||
layoutHome.setOnClickListener(v -> {
|
||||
setWallpaper(TYPE_HOME);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
layoutLock.setOnClickListener(v -> {
|
||||
setWallpaper(TYPE_LOCK);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
layoutBoth.setOnClickListener(v -> {
|
||||
setWallpaper(TYPE_BOTH);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
// 5. 显示弹窗并调整宽度
|
||||
dialog.show();
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setWallpaper(int type) {
|
||||
// 修正:设置壁纸的进度条与按钮ID(与布局一致)
|
||||
showLoading(binding.pbSet1, binding.buttonSet1, true);
|
||||
|
||||
// 修复Lambda变量问题:创建final变量
|
||||
final int finalType = type;
|
||||
|
||||
if (!tempFile.exists()) {
|
||||
// 临时文件不存在,先下载
|
||||
new Thread(() -> {
|
||||
try {
|
||||
URL url = new URL(imageUrl);
|
||||
URLConnection conn = url.openConnection();
|
||||
InputStream is = conn.getInputStream();
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
is.close();
|
||||
|
||||
if (bitmap == null) {
|
||||
throw new IOException("Failed to decode image");
|
||||
}
|
||||
|
||||
// 保存临时文件
|
||||
saveTempFile(bitmap);
|
||||
// 设置壁纸
|
||||
setWallpaperFromFile(tempFile, finalType);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
runOnUiThread(() -> {
|
||||
showLoading(binding.pbSet1, binding.buttonSet1, false);
|
||||
Toast.makeText(FullImageActivity.this, "Setup failed", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
// 临时文件存在,直接设置
|
||||
new Thread(() -> setWallpaperFromFile(tempFile, finalType)).start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从临时文件设置壁纸
|
||||
*/
|
||||
private void setWallpaperFromFile(File file, int type) {
|
||||
try {
|
||||
InputStream is = new java.io.FileInputStream(file);
|
||||
switch (type) {
|
||||
case TYPE_HOME:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
wallpaperManager.setStream(is, null, true, WallpaperManager.FLAG_SYSTEM);
|
||||
} else {
|
||||
wallpaperManager.setStream(is);
|
||||
}
|
||||
break;
|
||||
case TYPE_LOCK:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
wallpaperManager.setStream(is, null, true, WallpaperManager.FLAG_LOCK);
|
||||
} else {
|
||||
wallpaperManager.setStream(is);
|
||||
}
|
||||
break;
|
||||
case TYPE_BOTH:
|
||||
wallpaperManager.setStream(is);
|
||||
break;
|
||||
}
|
||||
is.close();
|
||||
|
||||
runOnUiThread(() -> {
|
||||
showLoading(binding.pbSet1, binding.buttonSet1, false);
|
||||
Toast.makeText(this, "Wallpaper Updated", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
runOnUiThread(() -> {
|
||||
showLoading(binding.pbSet1, binding.buttonSet1, false);
|
||||
Toast.makeText(this, "Wallpaper setup failed:" + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void showLoading(ProgressBar pb, View view, boolean show) {
|
||||
pb.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||
view.setVisibility(show ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
initFullScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.wall.engine.wallpaper.R;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_home, container, false);
|
||||
|
||||
TabLayout innerTabLayout = view.findViewById(R.id.innerTabLayout);
|
||||
ViewPager2 innerViewPager = view.findViewById(R.id.innerViewPager);
|
||||
|
||||
InnerTabAdapter innerTabAdapter = new InnerTabAdapter(requireActivity());
|
||||
innerViewPager.setAdapter(innerTabAdapter);
|
||||
|
||||
new TabLayoutMediator(innerTabLayout, innerViewPager, (tab, position) -> {
|
||||
View tabView = inflater.inflate(R.layout.custom_tab_item, null);
|
||||
TextView tabText = tabView.findViewById(R.id.tab_text);
|
||||
switch (position) {
|
||||
case 0: tabText.setText("Animals"); break;
|
||||
case 1: tabText.setText("Nature"); break;
|
||||
case 2: tabText.setText("Experimental"); break;
|
||||
}
|
||||
tab.setCustomView(tabView);
|
||||
|
||||
// 强制Tab宽度填满父布局(关键!)
|
||||
ViewGroup.LayoutParams params = tabView.getLayoutParams();
|
||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
tabView.setLayoutParams(params);
|
||||
}).attach();
|
||||
|
||||
innerTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
TextView tabText = tab.getCustomView().findViewById(R.id.tab_text);
|
||||
tabText.setTextColor(getResources().getColor(android.R.color.white));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
TextView tabText = tab.getCustomView().findViewById(R.id.tab_text);
|
||||
tabText.setTextColor(getResources().getColor(android.R.color.black));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {}
|
||||
});
|
||||
|
||||
innerTabLayout.selectTab(innerTabLayout.getTabAt(0));
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
// 内层 4D/LIVE/4K 适配器
|
||||
public class InnerTabAdapter extends FragmentStateAdapter {
|
||||
public InnerTabAdapter(@NonNull FragmentActivity fragmentActivity) {
|
||||
super(fragmentActivity);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
|
||||
switch (position) {
|
||||
case 0:
|
||||
return new D4Fragment();
|
||||
case 1:
|
||||
return new LiveFragment();
|
||||
case 2:
|
||||
return new K4Fragment();
|
||||
default:
|
||||
return new D4Fragment();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
74
test2/src/main/java/com/wall/engine/wallpaper/JsonUtils.java
Normal file
@ -0,0 +1,74 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
|
||||
public class JsonUtils {
|
||||
|
||||
public static List<WallpaperItem> loadWallpapersFromJson(Context context, String fileName) {
|
||||
try {
|
||||
String jsonString = loadJSONFromAsset(context, fileName);
|
||||
Gson gson = new Gson();
|
||||
Type listType = new TypeToken<List<WallpaperItem>>(){}.getType();
|
||||
List<WallpaperItem> items = gson.fromJson(jsonString, listType);
|
||||
|
||||
// 新增:确保每个item都有有效的ID
|
||||
if (items != null) {
|
||||
for (WallpaperItem item : items) {
|
||||
ensureItemHasId(item);
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
} catch (Exception e) {
|
||||
Log.e("JsonUtils", "Error loading JSON from " + fileName, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String loadJSONFromAsset(Context context, String fileName) {
|
||||
String json;
|
||||
try {
|
||||
InputStream is = context.getAssets().open(fileName);
|
||||
int size = is.available();
|
||||
byte[] buffer = new byte[size];
|
||||
is.read(buffer);
|
||||
is.close();
|
||||
json = new String(buffer, "UTF-8");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
private static void ensureItemHasId(WallpaperItem item) {
|
||||
if (item != null && item.getUrls() != null) {
|
||||
// 如果item没有设置id,或者id为空,则生成一个
|
||||
try {
|
||||
// 使用反射检查id字段是否为空
|
||||
java.lang.reflect.Field idField = WallpaperItem.class.getDeclaredField("id");
|
||||
idField.setAccessible(true);
|
||||
String currentId = (String) idField.get(item);
|
||||
|
||||
if (currentId == null || currentId.isEmpty()) {
|
||||
// 使用regular URL的hashCode作为唯一ID
|
||||
String regularUrl = item.getUrls().getRegular();
|
||||
if (regularUrl != null) {
|
||||
String generatedId = "img_" + Math.abs(regularUrl.hashCode());
|
||||
idField.set(item, generatedId);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("JsonUtils", "Error ensuring item ID", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class K4Fragment extends Fragment {
|
||||
|
||||
private RecyclerView rv4kImages;
|
||||
private K4ImageAdapter adapter;
|
||||
private List<WallpaperItem> wallpaperList;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_4k, container, false);
|
||||
|
||||
rv4kImages = view.findViewById(R.id.rv_4k_images);
|
||||
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
|
||||
gridLayoutManager.setAutoMeasureEnabled(true);
|
||||
rv4kImages.setLayoutManager(gridLayoutManager);
|
||||
|
||||
rv4kImages.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
|
||||
rv4kImages.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.HORIZONTAL));
|
||||
rv4kImages.setHasFixedSize(true);
|
||||
|
||||
|
||||
loadWallpaperData();
|
||||
|
||||
|
||||
adapter = new K4ImageAdapter(getContext(), wallpaperList);
|
||||
rv4kImages.setAdapter(adapter);
|
||||
|
||||
adapter.setOnItemClickListener((position, wallpaperItem) -> {
|
||||
// 1. 校验Context和WallpaperItem非空
|
||||
if (getContext() == null || wallpaperItem == null) {
|
||||
Toast.makeText(getContext(), "Data error", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String highResImageUrl = wallpaperItem.getUrls().getRegular();
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
highResImageUrl = wallpaperItem.getUrls().getFull();
|
||||
}
|
||||
|
||||
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
Toast.makeText(getContext(), "NULL", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Intent intent = new Intent(getContext(), FullImageActivity.class);
|
||||
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_URL, highResImageUrl);
|
||||
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_ID, wallpaperItem.getId());
|
||||
|
||||
String description = wallpaperItem.getAlt_description();
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = "4K超清壁纸";
|
||||
}
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_DESC, description);
|
||||
|
||||
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void loadWallpaperData() {
|
||||
|
||||
wallpaperList = JsonUtils.loadWallpapersFromJson(getContext(), "Experimental.json");
|
||||
if (wallpaperList == null) {
|
||||
wallpaperList = new ArrayList<>();
|
||||
Toast.makeText(getContext(), "Failed to load wallpaper data", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import java.util.List;
|
||||
|
||||
public class K4ImageAdapter extends RecyclerView.Adapter<K4ImageAdapter.ImageViewHolder> {
|
||||
|
||||
private final Context mContext;
|
||||
private final List<WallpaperItem> mWallpaperList;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
private final RequestOptions glideOptions = new RequestOptions()
|
||||
.centerCrop()
|
||||
.placeholder(R.drawable.load_ing)
|
||||
.error(R.drawable.load_ing)
|
||||
.override(400, 600); // 统一缩略图尺寸(宽400,高600)
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int position, WallpaperItem wallpaperItem);
|
||||
}
|
||||
|
||||
public K4ImageAdapter(Context context, List<WallpaperItem> wallpaperList) {
|
||||
this.mContext = context;
|
||||
this.mWallpaperList = wallpaperList;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.mOnItemClickListener = listener;
|
||||
}
|
||||
|
||||
static class ImageViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView ivItem4k;
|
||||
|
||||
public ImageViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ivItem4k = itemView.findViewById(R.id.iv_item_4k);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.item_4k_image, parent, false);
|
||||
return new ImageViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
|
||||
WallpaperItem wallpaperItem = mWallpaperList.get(position);
|
||||
|
||||
Glide.with(mContext)
|
||||
.load(wallpaperItem.getUrls().getSmall()) // 加载小图作为缩略图
|
||||
.apply(glideOptions) // 应用统一配置
|
||||
.into(holder.ivItem4k);
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(position, wallpaperItem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mWallpaperList == null ? 0 : mWallpaperList.size();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveFragment extends Fragment {
|
||||
|
||||
private RecyclerView rvLiveImages;
|
||||
private LiveImageAdapter adapter;
|
||||
private List<WallpaperItem> wallpaperList;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_live, container, false);
|
||||
|
||||
rvLiveImages = view.findViewById(R.id.rv_live_images);
|
||||
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
|
||||
gridLayoutManager.setAutoMeasureEnabled(true);
|
||||
rvLiveImages.setLayoutManager(gridLayoutManager);
|
||||
|
||||
rvLiveImages.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
|
||||
rvLiveImages.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.HORIZONTAL));
|
||||
rvLiveImages.setHasFixedSize(true);
|
||||
|
||||
|
||||
loadWallpaperData();
|
||||
|
||||
|
||||
adapter = new LiveImageAdapter(getContext(), wallpaperList);
|
||||
rvLiveImages.setAdapter(adapter);
|
||||
|
||||
adapter.setOnItemClickListener((position, wallpaperItem) -> {
|
||||
|
||||
if (getContext() == null || wallpaperItem == null) {
|
||||
Toast.makeText(getContext(), "Data error", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String highResImageUrl = wallpaperItem.getUrls().getRegular();
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
highResImageUrl = wallpaperItem.getUrls().getFull();
|
||||
}
|
||||
|
||||
if (highResImageUrl == null || highResImageUrl.isEmpty()) {
|
||||
Toast.makeText(getContext(), "NULL", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(getContext(), FullImageActivity.class);
|
||||
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_URL, highResImageUrl);
|
||||
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_ID, wallpaperItem.getId());
|
||||
|
||||
String description = wallpaperItem.getAlt_description();
|
||||
if (description == null || description.isEmpty()) {
|
||||
description = "精美壁纸";
|
||||
}
|
||||
intent.putExtra(FullImageActivity.EXTRA_IMAGE_DESC, description);
|
||||
|
||||
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void loadWallpaperData() {
|
||||
// 从Featured.json加载壁纸数据
|
||||
wallpaperList = JsonUtils.loadWallpapersFromJson(getContext(), "Featured.json");
|
||||
if (wallpaperList == null) {
|
||||
wallpaperList = new ArrayList<>();
|
||||
Toast.makeText(getContext(), "Wallpaper data loading failed", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveImageAdapter extends RecyclerView.Adapter<LiveImageAdapter.ImageViewHolder> {
|
||||
|
||||
private final Context mContext;
|
||||
private final List<WallpaperItem> mWallpaperList;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
private final RequestOptions glideOptions = new RequestOptions()
|
||||
.centerCrop()
|
||||
.placeholder(R.drawable.load_ing)
|
||||
.error(R.drawable.load_ing)
|
||||
.override(400, 600);
|
||||
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int position, WallpaperItem wallpaperItem);
|
||||
}
|
||||
|
||||
public LiveImageAdapter(Context context, List<WallpaperItem> wallpaperList) {
|
||||
this.mContext = context;
|
||||
this.mWallpaperList = wallpaperList;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener listener) {
|
||||
this.mOnItemClickListener = listener;
|
||||
}
|
||||
|
||||
|
||||
static class ImageViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView ivItemLive;
|
||||
|
||||
public ImageViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
ivItemLive = itemView.findViewById(R.id.iv_item_live);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(mContext).inflate(R.layout.item_live_image, parent, false);
|
||||
return new ImageViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
|
||||
WallpaperItem wallpaperItem = mWallpaperList.get(position);
|
||||
|
||||
Glide.with(mContext)
|
||||
.load(wallpaperItem.getUrls().getSmall())
|
||||
.apply(glideOptions)
|
||||
.into(holder.ivItemLive);
|
||||
|
||||
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (mOnItemClickListener != null) {
|
||||
mOnItemClickListener.onItemClick(position, wallpaperItem);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mWallpaperList == null ? 0 : mWallpaperList.size();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private ProgressBar progressBar;
|
||||
private int progress = 0;
|
||||
private Handler handler;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// 初始化控件
|
||||
progressBar = findViewById(R.id.progressBar);
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
// 进度条更新逻辑
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 循环更新进度,直到100
|
||||
while (progress < 100) {
|
||||
progress += 1; // 每次+1
|
||||
// 切回主线程更新UI
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
progressBar.setProgress(progress);
|
||||
}
|
||||
});
|
||||
try {
|
||||
// 控制进度条加载速度(总时长约1.5秒,可调整)
|
||||
Thread.sleep(15);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// 进度到100后,跳转到MainActivity2
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent = new Intent(MainActivity.this, MainActivity2.class);
|
||||
startActivity(intent);
|
||||
finish(); // 关闭启动页,避免返回键回到此页面
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
|
||||
// 适配系统状态栏(保留原有逻辑)
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
}
|
||||
|
||||
// 防止页面销毁时Handler内存泄漏
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
import com.wall.engine.wallpaper.R;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
|
||||
public class MainActivity2 extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
|
||||
|
||||
Window window = getWindow();
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(getResources().getColor(android.R.color.transparent));
|
||||
|
||||
setContentView(R.layout.activity_main2);
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(android.R.id.content), (v, insets) -> {
|
||||
int systemBarsTop = insets.getInsets(WindowInsetsCompat.Type.systemBars()).top;
|
||||
int systemBarsBottom = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom;
|
||||
v.setPadding(0, systemBarsTop, 0, systemBarsBottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
TabLayout innerTabLayout = findViewById(R.id.innerTabLayout);
|
||||
TabLayout outerTabLayout = findViewById(R.id.outerTabLayout);
|
||||
ViewPager2 outerViewPager = findViewById(R.id.outerViewPager);
|
||||
|
||||
OuterTabAdapter outerTabAdapter = new OuterTabAdapter(this);
|
||||
outerViewPager.setAdapter(outerTabAdapter);
|
||||
|
||||
new TabLayoutMediator(outerTabLayout, outerViewPager, (tab, position) -> {
|
||||
if (position == 0) {
|
||||
tab.setText("Home");
|
||||
tab.setIcon(R.drawable.home);
|
||||
} else {
|
||||
tab.setText("Setting");
|
||||
tab.setIcon(R.drawable.setting);
|
||||
}
|
||||
}).attach();
|
||||
}
|
||||
}
|
||||
47
test2/src/main/java/com/wall/engine/wallpaper/MyData.java
Normal file
@ -0,0 +1,47 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
// 移除 ObjectBox 导入
|
||||
// import io.objectbox.annotation.Entity;
|
||||
// import io.objectbox.annotation.Id;
|
||||
|
||||
public class MyData {
|
||||
// 移除 ObjectBox 注解
|
||||
// @Id
|
||||
private long id;
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
|
||||
// 构造函数、getter、setter 方法...
|
||||
public MyData() {
|
||||
}
|
||||
|
||||
public MyData(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
public class OuterTabAdapter extends FragmentStateAdapter {
|
||||
public OuterTabAdapter(@NonNull FragmentActivity fragmentActivity) {
|
||||
super(fragmentActivity);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return new HomeFragment();
|
||||
case 1:
|
||||
return new SettingFragment();
|
||||
default:
|
||||
return new HomeFragment();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.RatingBar;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class SettingFragment extends Fragment {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_setting, container, false);
|
||||
|
||||
// 1. 设置“收藏”按钮点击事件
|
||||
setupCollectionButton(view);
|
||||
// 2. 设置“Rate Us”按钮点击事件(评分弹窗)
|
||||
setupRateUsButton(view);
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
// 收藏按钮逻辑(原代码保留)
|
||||
private void setupCollectionButton(View view) {
|
||||
View collectionLayout = view.findViewById(R.id.linearLayout1_image3);
|
||||
if (collectionLayout != null) {
|
||||
collectionLayout.setOnClickListener(v -> navigateToFavoriteActivity());
|
||||
}
|
||||
}
|
||||
|
||||
private void navigateToFavoriteActivity() {
|
||||
Intent intent = new Intent(getActivity(), FavoriteActivity.class);
|
||||
startActivity(intent);
|
||||
if (getActivity() != null) {
|
||||
getActivity().overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupRateUsButton(View view) {
|
||||
View rateUsLayout = view.findViewById(R.id.linearLayout1);
|
||||
if (rateUsLayout != null) {
|
||||
rateUsLayout.setOnClickListener(v -> showRateUsDialog());
|
||||
}
|
||||
}
|
||||
|
||||
private void showRateUsDialog() {
|
||||
Context context = getContext();
|
||||
if (context == null) return;
|
||||
|
||||
View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_rate_us, null);
|
||||
RatingBar ratingBar = dialogView.findViewById(R.id.ratingBar);
|
||||
Button btnCancel = dialogView.findViewById(R.id.btn_cancel);
|
||||
Button btnRateIt = dialogView.findViewById(R.id.btn_rate_it);
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(context)
|
||||
.setView(dialogView)
|
||||
.create();
|
||||
|
||||
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
btnCancel.setOnClickListener(v -> dialog.dismiss());
|
||||
|
||||
btnRateIt.setOnClickListener(v -> {
|
||||
float userRating = ratingBar.getRating();
|
||||
dialog.dismiss();
|
||||
String toastMsg;
|
||||
if (userRating == 5) {
|
||||
toastMsg = "Thank you so much for your five-star review!";
|
||||
} else if (userRating >= 3) {
|
||||
toastMsg = "Thank you" + userRating + "Star rating!";
|
||||
} else {
|
||||
toastMsg = "We apologize for not meeting your expectations, and we will continue to improve!";
|
||||
}
|
||||
Toast.makeText(context, toastMsg, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
}
|
||||
20
test2/src/main/java/com/wall/engine/wallpaper/Urls.java
Normal file
@ -0,0 +1,20 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
public class Urls {
|
||||
private String full;
|
||||
private String raw;
|
||||
private String regular;
|
||||
private String small;
|
||||
private String thumb;
|
||||
|
||||
public String getFull() { return full; }
|
||||
public void setFull(String full) { this.full = full; }
|
||||
public String getRaw() { return raw; }
|
||||
public void setRaw(String raw) { this.raw = raw; }
|
||||
public String getRegular() { return regular; }
|
||||
public void setRegular(String regular) { this.regular = regular; }
|
||||
public String getSmall() { return small; }
|
||||
public void setSmall(String small) { this.small = small; }
|
||||
public String getThumb() { return thumb; }
|
||||
public void setThumb(String thumb) { this.thumb = thumb; }
|
||||
}
|
||||
11
test2/src/main/java/com/wall/engine/wallpaper/User.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
public class User {
|
||||
private String name;
|
||||
private String portfolio_url;
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getPortfolio_url() { return portfolio_url; }
|
||||
public void setPortfolio_url(String portfolio_url) { this.portfolio_url = portfolio_url; }
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package com.wall.engine.wallpaper;
|
||||
|
||||
public class WallpaperItem {
|
||||
private String id; // 确保这个字段存在
|
||||
private String alt_description;
|
||||
private Urls urls;
|
||||
private User user;
|
||||
|
||||
|
||||
public String getId() {
|
||||
|
||||
if (id != null && !id.isEmpty()) {
|
||||
return id;
|
||||
}
|
||||
|
||||
if (urls != null && urls.getRegular() != null) {
|
||||
|
||||
return "wallpaper_" + Math.abs(urls.getRegular().hashCode());
|
||||
}
|
||||
|
||||
return "wallpaper_" + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAlt_description() {
|
||||
return alt_description;
|
||||
}
|
||||
|
||||
public void setAlt_description(String alt_description) {
|
||||
this.alt_description = alt_description;
|
||||
}
|
||||
|
||||
public Urls getUrls() {
|
||||
return urls;
|
||||
}
|
||||
|
||||
public void setUrls(Urls urls) {
|
||||
this.urls = urls;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
// public class Urls {
|
||||
//
|
||||
// }
|
||||
|
||||
// public class User {
|
||||
//
|
||||
// }
|
||||
}
|
||||
BIN
test2/src/main/res/drawable/apptub.png
Normal file
|
After Width: | Height: | Size: 222 KiB |
BIN
test2/src/main/res/drawable/beij2.jpg
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
test2/src/main/res/drawable/beij3.webp
Normal file
|
After Width: | Height: | Size: 788 B |
8
test2/src/main/res/drawable/dialog_pink_rounded_bg.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<!-- 粉色背景-->
|
||||
<solid android:color="#FFD1C9E0"/>
|
||||
<!-- 圆角 -->
|
||||
<corners android:radius="12dp"/>
|
||||
</shape>
|
||||
7
test2/src/main/res/drawable/dialog_rounded_bg.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@android:color/white"/> <!-- 保留原有白色背景色 -->
|
||||
<corners android:radius="15dp"/> <!-- 圆角大小(可调整,如12dp/18dp) -->
|
||||
<stroke android:width="1dp" android:color="#E0E0E0"/> <!-- 轻微边框(可选,优化视觉) -->
|
||||
</shape>
|
||||
BIN
test2/src/main/res/drawable/home.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
test2/src/main/res/drawable/ic_both.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
test2/src/main/res/drawable/ic_home.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
170
test2/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
||||
30
test2/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
BIN
test2/src/main/res/drawable/ic_lock.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
12
test2/src/main/res/drawable/image_wallpaper.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="256dp"
|
||||
android:height="256dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="@color/white"
|
||||
android:pathData="M261.9,492.9c20.6,11.9 46,11.9 66.6,0 20.6,-11.9 33.3,-33.9 33.3,-57.6 0,-36.8 -29.8,-66.5 -66.6,-66.5s-66.5,29.8 -66.5,66.5c0,23.8 12.7,45.7 33.2,57.6z"/>
|
||||
<path
|
||||
android:fillColor="@color/white"
|
||||
android:pathData="M804,153.4L221.4,153.4c-78.3,0 -142,63.7 -142,142v436.9c0,78.3 63.7,142 142,142L804,874.3c78.3,0 142,-63.7 142,-142L946,295.4c-0.1,-78.3 -63.7,-142 -142,-142zM144.9,295.4c0,-42.2 34.3,-76.5 76.4,-76.5L804,218.9c42.1,0 76.4,34.3 76.4,76.5v331.1l-95.3,-86.2 -13.6,-9.7c-71.9,-46.1 -164.2,-45.1 -233.9,1.3l-385,232.6c-4.7,-9.9 -7.7,-20.6 -7.7,-32.2L144.9,295.4zM804,808.8L221.4,808.8c-4.1,0 -7.6,-1.7 -11.4,-2.3l362.8,-219.2c49.5,-32.9 113.6,-33.4 162.8,-1.9l143.7,128.5 1.2,-1.3v19.8c-0.1,42.1 -34.4,76.4 -76.5,76.4z"/>
|
||||
</vector>
|
||||
BIN
test2/src/main/res/drawable/left.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
test2/src/main/res/drawable/like.png
Normal file
|
After Width: | Height: | Size: 5.0 KiB |
BIN
test2/src/main/res/drawable/like_red.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test2/src/main/res/drawable/load.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
test2/src/main/res/drawable/load_ing.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
6
test2/src/main/res/drawable/oval.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/color_main_view"/>
|
||||
|
||||
</shape>
|
||||
7
test2/src/main/res/drawable/retc_16.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="16dp" />
|
||||
<solid android:color="@color/color_main_view" />
|
||||
|
||||
</shape>
|
||||
10
test2/src/main/res/drawable/retc_19.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="19dp"/>
|
||||
<gradient
|
||||
android:angle="45"
|
||||
android:endColor="@color/color_4202cb"
|
||||
android:startColor="@color/color_4202cb" />
|
||||
|
||||
</shape>
|
||||
BIN
test2/src/main/res/drawable/right.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
test2/src/main/res/drawable/right1.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
test2/src/main/res/drawable/right2.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
test2/src/main/res/drawable/right_version.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
12
test2/src/main/res/drawable/rounded_corner.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<!-- 圆角半径(12dp) -->
|
||||
<corners android:radius="12dp" />
|
||||
<!-- 修复:改用纯色背景(透明/白色,避免图片引用) -->
|
||||
<solid android:color="#FFFFFF" />
|
||||
<!-- 可选:边框(浅灰色,宽度1dp) -->
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#F0F0F0" />
|
||||
</shape>
|
||||
18
test2/src/main/res/drawable/rounded_glow_bg.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 发光层 -->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="30dp" /> <!-- 与图片圆角一致 -->
|
||||
<solid android:color="#4064B5FF" />
|
||||
<padding android:top="4dp" android:bottom="4dp" android:left="4dp" android:right="4dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<!-- 图片容器层 -->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="30dp" /> <!-- 与图片圆角一致 -->
|
||||
<solid android:color="@android:color/white" /> <!-- 避免透明背景透出底层 -->
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
||||
BIN
test2/src/main/res/drawable/set.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
test2/src/main/res/drawable/setting.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
7
test2/src/main/res/drawable/tab_background_selector.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 选中状态 -->
|
||||
<item android:drawable="@drawable/tab_selected_bg" android:state_selected="true" />
|
||||
<!-- 未选中状态 -->
|
||||
<item android:drawable="@drawable/tab_unselected_bg" android:state_selected="false" />
|
||||
</selector>
|
||||
17
test2/src/main/res/drawable/tab_bg_selector.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- 选中状态:紫色+圆角(与容器一致) -->
|
||||
<item android:state_selected="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="20dp" />
|
||||
<solid android:color="#7B2CBF" />
|
||||
</shape>
|
||||
</item>
|
||||
<!-- 未选中状态:透明 -->
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="20dp" />
|
||||
<solid android:color="@android:color/transparent" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
7
test2/src/main/res/drawable/tab_container_bg.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="20dp" />
|
||||
<solid android:color="#F5F5F5" />
|
||||
<!-- 取消所有内边距,让Tab完全贴边 -->
|
||||
<padding android:top="0dp" android:bottom="0dp" android:left="0dp" android:right="0dp"/>
|
||||
</shape>
|
||||
5
test2/src/main/res/drawable/tab_rounded_bg.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="20dp" /> <!-- 圆角半径 -->
|
||||
<solid android:color="#7B2CBF" /> <!-- 紫色背景 -->
|
||||
</shape>
|
||||
8
test2/src/main/res/drawable/tab_selected_bg.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<!-- 选中时的背景色(示例:紫色) -->
|
||||
<solid android:color="#9C27B0" />
|
||||
<!-- 圆角(根据需求调整) -->
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
||||
8
test2/src/main/res/drawable/tab_unselected_bg.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<!-- 未选中时的背景色(示例:浅灰色) -->
|
||||
<solid android:color="#F5F5F5" />
|
||||
<!-- 圆角(和选中状态保持一致) -->
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
||||
BIN
test2/src/main/res/drawable/tub4.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
test2/src/main/res/drawable/tub6.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
test2/src/main/res/drawable/tub7.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
test2/src/main/res/drawable/tup4.jpg
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
test2/src/main/res/drawable/tup5.jpg
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
test2/src/main/res/drawable/tup7.jpg
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
test2/src/main/res/drawable/version.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
test2/src/main/res/drawable/xih2.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
78
test2/src/main/res/layout/activity_favorite.xml
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@drawable/beij3">
|
||||
|
||||
<!-- 状态栏占位View,避免内容重叠 -->
|
||||
<View
|
||||
android:id="@+id/status_bar_placeholder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:background="@android:color/transparent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<!-- 顶部栏 - 移除白色背景,仅保留文字/图标 -->
|
||||
<LinearLayout
|
||||
android:id="@+id/top_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/status_bar_placeholder"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn_back"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/left"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:padding="5dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="Collection"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/title_color"
|
||||
android:gravity="center"
|
||||
android:layout_marginStart="10dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_favorite_images"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintTop_toBottomOf="@id/top_bar"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="No favorite wallpapers yet"
|
||||
android:textSize="18sp"
|
||||
android:textColor="@color/title_color"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
126
test2/src/main/res/layout/activity_full_image.xml
Normal file
@ -0,0 +1,126 @@
|
||||
<?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"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageview_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageview_back"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="42dp"
|
||||
android:background="@drawable/oval"
|
||||
android:padding="13dp"
|
||||
android:src="@drawable/left"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<TextView
|
||||
android:id="@+id/tv_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="40dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:background="@drawable/retc_16"
|
||||
android:gravity="center"
|
||||
android:minHeight="40dp"
|
||||
android:padding="10dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp"
|
||||
android:text="@string/app_name"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"/>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layout_set1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:layout_marginEnd="70dp"
|
||||
android:background="@drawable/oval"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/tv_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/button_set1"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
|
||||
android:layout_centerInParent="true"
|
||||
android:padding="13dp"
|
||||
android:src="@drawable/set" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/pb_set1"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:indeterminateTint="@color/white"
|
||||
android:padding="13dp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layout_download"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="26dp"
|
||||
android:background="@drawable/oval"
|
||||
app:layout_constraintBottom_toBottomOf="@id/layout_set1"
|
||||
app:layout_constraintRight_toLeftOf="@id/layout_set1"
|
||||
app:layout_constraintTop_toTopOf="@id/layout_set1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_download"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:padding="13dp"
|
||||
android:src="@drawable/load"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/pb_download"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:indeterminateTint="@color/white"
|
||||
android:padding="13dp"
|
||||
android:visibility="gone" />
|
||||
</RelativeLayout>
|
||||
<ImageView
|
||||
android:id="@+id/image_favorite"
|
||||
android:layout_width="46dp"
|
||||
android:layout_height="46dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginStart="26dp"
|
||||
android:background="@drawable/oval"
|
||||
android:padding="13dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:src="@drawable/like"
|
||||
app:layout_constraintBottom_toBottomOf="@id/layout_set1"
|
||||
app:layout_constraintLeft_toRightOf="@id/layout_set1"
|
||||
app:layout_constraintTop_toTopOf="@id/layout_set1" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
40
test2/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/beij2"
|
||||
android:orientation="vertical"
|
||||
|
||||
tools:context="com.wall.engine.wallpaper.MainActivity">
|
||||
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="#FFDE59"
|
||||
android:layout_marginTop="150dp"
|
||||
android:layout_gravity="center"
|
||||
android:textSize="30sp"
|
||||
android:textStyle="bold"
|
||||
/>
|
||||
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="10dp"
|
||||
android:progress="0"
|
||||
android:progressTint="#FFDE59"
|
||||
android:backgroundTint="#E0E0E0"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginTop="500dp"
|
||||
android:layout_gravity="center"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
48
test2/src/main/res/layout/activity_main2.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<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="@drawable/beij3"
|
||||
tools:context="com.wall.engine.wallpaper.MainActivity2">
|
||||
|
||||
<!-- 内层Tab(4D/LIVE/4K)- 顶部 -->
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/innerTabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:visibility="gone"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="#E4080A"
|
||||
app:tabMode="fixed"
|
||||
app:tabSelectedTextColor="#060270"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<!-- 外层ViewPager2 - 中间 -->
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/outerViewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/innerTabLayout"
|
||||
app:layout_constraintBottom_toTopOf="@+id/outerTabLayout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<!-- 外层Tab(Home/Setting)- 底部 -->
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/outerTabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabGravity="fill"
|
||||
app:tabIndicatorColor="#E4080A"
|
||||
app:tabMode="fixed"
|
||||
app:tabSelectedTextColor="#060270"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:tabInlineLabel="false"
|
||||
app:iconSize="24dp" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
11
test2/src/main/res/layout/custom_tab_item.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tab_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textColor="#000000"
|
||||
android:gravity="center"
|
||||
android:textSize="14sp"
|
||||
android:background="@drawable/tab_bg_selector"
|
||||
android:paddingHorizontal="0dp"
|
||||
android:paddingVertical="0dp" />
|
||||
58
test2/src/main/res/layout/dialog_rate_us.xml
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp"
|
||||
|
||||
android:background="@drawable/dialog_rounded_bg"
|
||||
android:gravity="center">
|
||||
|
||||
<!-- 提示文本(保留原有) -->
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="We hope this app is useful for you. If you like us, would you mind taking a moment to rate us on Google Play? It really helps!"
|
||||
android:textSize="16sp"
|
||||
android:gravity="center"
|
||||
android:layout_marginBottom="20dp"/>
|
||||
|
||||
<!-- 星级评分条(核心修改:星星颜色) -->
|
||||
<RatingBar
|
||||
android:id="@+id/ratingBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:numStars="5"
|
||||
android:rating="2"
|
||||
android:stepSize="1"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:progressTint="#FFFFCC00"
|
||||
android:secondaryProgressTint="#E0E0E0"
|
||||
android:backgroundTint="#E0E0E0"/>
|
||||
|
||||
<!-- 按钮栏(保留原有) -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_cancel"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="CANCEL"
|
||||
android:backgroundTint="@android:color/darker_gray"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_rate_it"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="RATE IT"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:backgroundTint="@android:color/holo_blue_light"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
97
test2/src/main/res/layout/dialog_wallpaper_type.xml
Normal file
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:background="@drawable/retc_19"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_ic_home"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_home" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_home"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="21dp"
|
||||
android:text="@string/type_home"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginEnd="25dp"
|
||||
android:background="@color/white" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_ic_lock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_lock" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_lock"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="22dp"
|
||||
android:text="@string/type_lock"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0.5dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginEnd="25dp"
|
||||
android:background="@color/white" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_ic_both"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_both" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text_both"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="22dp"
|
||||
android:text="@string/type_both"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
14
test2/src/main/res/layout/fragment_4k.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/beij3">
|
||||
|
||||
<!-- RecyclerView 显示壁纸列表 -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_4k_images"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="4dp" />
|
||||
</LinearLayout>
|
||||