V1.0.0(1)完成版
This commit is contained in:
parent
51e835a92e
commit
743d4c6fc0
BIN
app/WallpaperDream.jks
Normal file
BIN
app/WallpaperDream.jks
Normal file
Binary file not shown.
@ -1,9 +1,12 @@
|
|||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.application)
|
alias(libs.plugins.android.application)
|
||||||
alias(libs.plugins.kotlin.android)
|
alias(libs.plugins.kotlin.android)
|
||||||
id("kotlin-kapt")
|
id("kotlin-kapt")
|
||||||
}
|
}
|
||||||
|
val timestamp: String = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||||
android {
|
android {
|
||||||
namespace = "com.wallpaper.wallpaperdream"
|
namespace = "com.wallpaper.wallpaperdream"
|
||||||
compileSdk = 34
|
compileSdk = 34
|
||||||
@ -14,7 +17,7 @@ android {
|
|||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 1
|
versionCode = 1
|
||||||
versionName = "1.0.0"
|
versionName = "1.0.0"
|
||||||
|
setProperty("archivesBaseName", "Wallpaper Dream_" + versionName + "(${versionCode})_$timestamp")
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +55,7 @@ dependencies {
|
|||||||
androidTestImplementation(libs.androidx.espresso.core)
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
|
||||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||||
kapt("com.github.bumptech.glide:compiler:4.15.1")
|
kapt("com.github.bumptech.glide:compiler:4.16.0")
|
||||||
|
|
||||||
implementation("androidx.room:room-runtime:2.6.1")
|
implementation("androidx.room:room-runtime:2.6.1")
|
||||||
kapt("androidx.room:room-compiler:2.6.1")
|
kapt("androidx.room:room-compiler:2.6.1")
|
||||||
|
|||||||
13
app/proguard-rules.pro
vendored
13
app/proguard-rules.pro
vendored
@ -19,3 +19,16 @@
|
|||||||
# If you keep the line number information, uncomment this to
|
# If you keep the line number information, uncomment this to
|
||||||
# hide the original source file name.
|
# hide the original source file name.
|
||||||
#-renamesourcefileattribute SourceFile
|
#-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
|
-keepclassmembers class com.wallpaper.wallpaperdream.MyApplication {
|
||||||
|
public static final java.lang.String DB_NAME;
|
||||||
|
public static final int DB_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keepclassmembers class * {
|
||||||
|
@androidx.room.Query <methods>;
|
||||||
|
}
|
||||||
|
|
||||||
|
-keep class com.wallpaper.wallpaperdream.data.database.AppDatabase { *; }
|
||||||
|
-keep class com.wallpaper.wallpaperdream.data.database.dao.WallpaperDataDao { *; }
|
||||||
|
-keep class com.wallpaper.wallpaperdream.data.database.entity.WallpaperData { *; }
|
||||||
@ -19,6 +19,9 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.WallpaperDream"
|
android:theme="@style/Theme.WallpaperDream"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".ui.activity.MainActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activity.CategoryActivity"
|
android:name=".ui.activity.CategoryActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
@ -26,7 +29,7 @@
|
|||||||
android:name=".ui.activity.ImageActivity"
|
android:name=".ui.activity.ImageActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activity.MainActivity"
|
android:name=".ui.activity.SplashActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
@ -32,6 +32,7 @@ interface WallpaperDataDao {
|
|||||||
@Query("SELECT isLike FROM wallpapers WHERE source = :imagePath")
|
@Query("SELECT isLike FROM wallpapers WHERE source = :imagePath")
|
||||||
fun getWallpaperLike(imagePath: String): LiveData<Boolean>
|
fun getWallpaperLike(imagePath: String): LiveData<Boolean>
|
||||||
|
|
||||||
@Query("UPDATE wallpapers SET isLike = :isLike WHERE source = :imagePath")
|
@Query("UPDATE wallpapers SET isLike = :isLike WHERE source = :imagePath AND name = :name")
|
||||||
suspend fun updateIsLike(imagePath: String, isLike: Boolean)
|
suspend fun updateIsLike(imagePath: String, name: String, isLike: Boolean)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,8 +23,8 @@ class WallpaperRepository(context: Context) {
|
|||||||
dao.update(wallpaper)
|
dao.update(wallpaper)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun updateIsLike(imagePath: String, isLike: Boolean) {
|
suspend fun updateIsLike(imagePath: String, name: String, isLike: Boolean) {
|
||||||
dao.updateIsLike(imagePath, isLike)
|
dao.updateIsLike(imagePath, name, isLike)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getWallpapers(limit: Int, offset: Int): LiveData<List<WallpaperData>> {
|
fun getWallpapers(limit: Int, offset: Int): LiveData<List<WallpaperData>> {
|
||||||
|
|||||||
@ -63,8 +63,8 @@ class CategoryActivity : AppCompatActivity() {
|
|||||||
private fun loadImage() {
|
private fun loadImage() {
|
||||||
viewModel
|
viewModel
|
||||||
.getAllCategory(name)
|
.getAllCategory(name)
|
||||||
.observe(this, Observer { wallpapers ->
|
.observe(this) { wallpapers ->
|
||||||
adapter.updateData(wallpapers)
|
adapter.updateData(wallpapers)
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ package com.wallpaper.wallpaperdream.ui.activity
|
|||||||
import android.app.WallpaperManager
|
import android.app.WallpaperManager
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@ -12,6 +13,7 @@ import android.widget.Toast
|
|||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.ViewCompat
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
@ -32,6 +34,7 @@ import kotlinx.coroutines.withContext
|
|||||||
class ImageActivity : AppCompatActivity() {
|
class ImageActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityImageBinding
|
private lateinit var binding: ActivityImageBinding
|
||||||
private lateinit var imagePath: String
|
private lateinit var imagePath: String
|
||||||
|
private lateinit var name: String
|
||||||
private lateinit var bitmap: Bitmap
|
private lateinit var bitmap: Bitmap
|
||||||
private var isFavorite = false
|
private var isFavorite = false
|
||||||
private lateinit var gallerySaver: GallerySaver
|
private lateinit var gallerySaver: GallerySaver
|
||||||
@ -47,16 +50,20 @@ class ImageActivity : AppCompatActivity() {
|
|||||||
ViewCompat.setOnApplyWindowInsetsListener(
|
ViewCompat.setOnApplyWindowInsetsListener(
|
||||||
findViewById(R.id.main)
|
findViewById(R.id.main)
|
||||||
) { v: View, insets: WindowInsetsCompat ->
|
) { v: View, insets: WindowInsetsCompat ->
|
||||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
val navigationBars = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
|
||||||
|
v.setPadding(0, 0, 0, navigationBars.bottom)
|
||||||
|
|
||||||
insets
|
insets
|
||||||
}
|
}
|
||||||
|
|
||||||
initData()
|
initData()
|
||||||
initEvent()
|
initEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initData() {
|
private fun initData() {
|
||||||
imagePath = intent.getStringExtra("imagePath").toString()
|
imagePath = intent.getStringExtra("imagePath").toString()
|
||||||
|
name = intent.getStringExtra("name").toString()
|
||||||
|
|
||||||
viewModel = ViewModelProvider(this)[WallpaperViewModel::class.java]
|
viewModel = ViewModelProvider(this)[WallpaperViewModel::class.java]
|
||||||
|
|
||||||
@ -70,11 +77,14 @@ class ImageActivity : AppCompatActivity() {
|
|||||||
showProgress()
|
showProgress()
|
||||||
|
|
||||||
binding.back.setOnClickListener { finish() }
|
binding.back.setOnClickListener { finish() }
|
||||||
|
|
||||||
binding.favorite.setOnClickListener {
|
binding.favorite.setOnClickListener {
|
||||||
isFavorite = !isFavorite
|
isFavorite = !isFavorite
|
||||||
viewModel.updateIsLike(imagePath, isFavorite)
|
viewModel.updateIsLike(imagePath, name, isFavorite)
|
||||||
}
|
}
|
||||||
binding.setWallpaper.setOnClickListener { v -> showCustomBottomSheetDialog() }
|
|
||||||
|
binding.setWallpaper.setOnClickListener { showCustomBottomSheetDialog() }
|
||||||
|
|
||||||
binding.download.setOnClickListener { v ->
|
binding.download.setOnClickListener { v ->
|
||||||
showProgress()
|
showProgress()
|
||||||
val activity = v.context as ImageActivity
|
val activity = v.context as ImageActivity
|
||||||
@ -148,14 +158,22 @@ class ImageActivity : AppCompatActivity() {
|
|||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
hideProgress()
|
hideProgress()
|
||||||
binding.setWallpaper.isEnabled = true
|
binding.setWallpaper.isEnabled = true
|
||||||
Toast.makeText(applicationContext, "Wallpaper setting is successful", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
"Wallpaper setting is successful",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
hideProgress()
|
hideProgress()
|
||||||
Toast.makeText(applicationContext, "Failed to set wallpaper", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
"Failed to set wallpaper",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,14 +196,22 @@ class ImageActivity : AppCompatActivity() {
|
|||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
hideProgress()
|
hideProgress()
|
||||||
binding.setWallpaper.isEnabled = true
|
binding.setWallpaper.isEnabled = true
|
||||||
Toast.makeText(applicationContext, "Wallpaper setting is successful", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
"Wallpaper setting is successful",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
hideProgress()
|
hideProgress()
|
||||||
Toast.makeText(applicationContext, "Failed to set wallpaper", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
"Failed to set wallpaper",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,14 +234,22 @@ class ImageActivity : AppCompatActivity() {
|
|||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
hideProgress()
|
hideProgress()
|
||||||
binding.setWallpaper.isEnabled = true
|
binding.setWallpaper.isEnabled = true
|
||||||
Toast.makeText(applicationContext, "Wallpaper setting is successful", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
"Wallpaper setting is successful",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
hideProgress()
|
hideProgress()
|
||||||
Toast.makeText(applicationContext, "Failed to set wallpaper", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
"Failed to set wallpaper",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +274,9 @@ class ImageActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onLoadFailed(errorDrawable: Drawable?) {
|
override fun onLoadFailed(errorDrawable: Drawable?) {
|
||||||
super.onLoadFailed(errorDrawable)
|
super.onLoadFailed(errorDrawable)
|
||||||
binding.image.setImageDrawable(errorDrawable ?: resources.getDrawable(R.mipmap.placeholder,null))
|
binding.image.setImageDrawable(
|
||||||
|
errorDrawable ?: resources.getDrawable(R.mipmap.placeholder, null)
|
||||||
|
)
|
||||||
hideProgress()
|
hideProgress()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -249,10 +285,10 @@ class ImageActivity : AppCompatActivity() {
|
|||||||
private fun loadFavorite() {
|
private fun loadFavorite() {
|
||||||
viewModel
|
viewModel
|
||||||
.getWallpaperLike(imagePath)
|
.getWallpaperLike(imagePath)
|
||||||
.observe(this, Observer { isLike ->
|
.observe(this) { isLike ->
|
||||||
isFavorite = isLike;
|
isFavorite = isLike;
|
||||||
setFavoriteButton()
|
setFavoriteButton()
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setFavoriteButton() {
|
private fun setFavoriteButton() {
|
||||||
|
|||||||
@ -0,0 +1,76 @@
|
|||||||
|
package com.wallpaper.wallpaperdream.ui.activity
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.CountDownTimer
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ProgressBar
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
|
import com.wallpaper.wallpaperdream.R
|
||||||
|
import com.wallpaper.wallpaperdream.databinding.ActivitySplashBinding
|
||||||
|
|
||||||
|
class SplashActivity : AppCompatActivity() {
|
||||||
|
private lateinit var binding: ActivitySplashBinding
|
||||||
|
private lateinit var countDownTimer: CountDownTimer
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
this.enableEdgeToEdge()
|
||||||
|
|
||||||
|
binding = ActivitySplashBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.getRoot())
|
||||||
|
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(
|
||||||
|
findViewById(R.id.main)
|
||||||
|
) { v: View, insets: WindowInsetsCompat ->
|
||||||
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
|
||||||
|
val progressBar: ProgressBar = binding.progressBar
|
||||||
|
|
||||||
|
Glide.with(this)
|
||||||
|
.load(R.mipmap.placeholder)
|
||||||
|
.transform(RoundedCorners(16))
|
||||||
|
.into(binding.splashImage)
|
||||||
|
|
||||||
|
countDownTimer = object : CountDownTimer(TOTAL_TIME, 100) {
|
||||||
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
|
val percentage = (100 - millisUntilFinished.toFloat() / TOTAL_TIME * 100).toInt()
|
||||||
|
progressBar.progress = percentage
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFinish() {
|
||||||
|
startMain()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
countDownTimer.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startMain() {
|
||||||
|
binding.progressBar.progress = 100
|
||||||
|
|
||||||
|
val intent = Intent(
|
||||||
|
this@SplashActivity,
|
||||||
|
MainActivity::class.java
|
||||||
|
)
|
||||||
|
startActivity(intent)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
countDownTimer.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val TOTAL_TIME: Long = 3000
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -53,16 +53,16 @@ class CategoryAdapter(
|
|||||||
private var textView: TextView = itemView.findViewById(R.id.category_title)
|
private var textView: TextView = itemView.findViewById(R.id.category_title)
|
||||||
|
|
||||||
fun bind(imageEntry: WallpaperData) {
|
fun bind(imageEntry: WallpaperData) {
|
||||||
val imageEntryOriginal: String = imageEntry.original
|
val imagePath: String = imageEntry.original
|
||||||
|
|
||||||
textView.text = imageEntry.name
|
textView.text = imageEntry.name
|
||||||
loadImage(imageEntryOriginal)
|
loadImage(imagePath)
|
||||||
setClickListeners(imageEntry)
|
setClickListeners(imageEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadImage(imageEntryOriginal: String) {
|
private fun loadImage(imagePath: String) {
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.load(imageEntryOriginal)
|
.load(imagePath)
|
||||||
.transform(RoundedCorners(32))
|
.transform(RoundedCorners(32))
|
||||||
.error(R.mipmap.placeholder)
|
.error(R.mipmap.placeholder)
|
||||||
.placeholder(R.mipmap.placeholder)
|
.placeholder(R.mipmap.placeholder)
|
||||||
|
|||||||
@ -57,16 +57,16 @@ class ImageAdapter(
|
|||||||
private var favoriteButton: ImageView = itemView.findViewById(R.id.btn_favorite)
|
private var favoriteButton: ImageView = itemView.findViewById(R.id.btn_favorite)
|
||||||
|
|
||||||
fun bind(imageEntry: WallpaperData) {
|
fun bind(imageEntry: WallpaperData) {
|
||||||
val imageEntryOriginal: String = imageEntry.original
|
val imagePath: String = imageEntry.previewThumb
|
||||||
|
|
||||||
loadImage(imageEntryOriginal)
|
loadImage(imagePath)
|
||||||
setFavoriteButton(imageEntry)
|
setFavoriteButton(imageEntry)
|
||||||
setClickListeners(imageEntry)
|
setClickListeners(imageEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadImage(imageEntryOriginal: String) {
|
private fun loadImage(imagePath: String) {
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.load(imageEntryOriginal)
|
.load(imagePath)
|
||||||
.transform(RoundedCorners(16))
|
.transform(RoundedCorners(16))
|
||||||
.error(R.mipmap.placeholder)
|
.error(R.mipmap.placeholder)
|
||||||
.placeholder(R.mipmap.placeholder)
|
.placeholder(R.mipmap.placeholder)
|
||||||
@ -89,6 +89,7 @@ class ImageAdapter(
|
|||||||
ImageActivity::class.java
|
ImageActivity::class.java
|
||||||
)
|
)
|
||||||
intent.putExtra("imagePath", imageEntry.source)
|
intent.putExtra("imagePath", imageEntry.source)
|
||||||
|
intent.putExtra("name", imageEntry.name)
|
||||||
activity.startActivity(intent)
|
activity.startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,13 +50,13 @@ class FavoriteFragment : Fragment() {
|
|||||||
private fun loadFavoriteImages() {
|
private fun loadFavoriteImages() {
|
||||||
viewModel
|
viewModel
|
||||||
.getLike()
|
.getLike()
|
||||||
.observe(viewLifecycleOwner, Observer { wallpapers ->
|
.observe(viewLifecycleOwner) { wallpapers ->
|
||||||
if (wallpapers.isEmpty()) {
|
if (wallpapers.isEmpty()) {
|
||||||
binding.backgroundText.visibility = View.VISIBLE
|
binding.backgroundText.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
binding.backgroundText.visibility = View.GONE
|
binding.backgroundText.visibility = View.GONE
|
||||||
}
|
}
|
||||||
adapter.updateData(wallpapers)
|
adapter.updateData(wallpapers)
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,9 +59,9 @@ class HomeCategoryFragment : Fragment() {
|
|||||||
val randomOffset = (0..2000).random()
|
val randomOffset = (0..2000).random()
|
||||||
viewModel
|
viewModel
|
||||||
.getWallpapers(type,randomOffset)
|
.getWallpapers(type,randomOffset)
|
||||||
.observe(viewLifecycleOwner, Observer { wallpapers ->
|
.observe(viewLifecycleOwner) { wallpapers ->
|
||||||
adapter.updateData(wallpapers)
|
adapter.updateData(wallpapers)
|
||||||
})
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,13 +20,13 @@ class WallpaperViewModel(application: Application) : AndroidViewModel(applicatio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateIsLike(imagePath: String, isLike: Boolean) {
|
fun updateIsLike(imagePath: String, name: String, isLike: Boolean) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
repository.updateIsLike(imagePath, isLike)
|
repository.updateIsLike(imagePath, name, isLike)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getWallpapers(i: Int,random: Int): LiveData<List<WallpaperData>> {
|
fun getWallpapers(i: Int, random: Int): LiveData<List<WallpaperData>> {
|
||||||
return when (i) {
|
return when (i) {
|
||||||
1 -> repository.getWallpapers(20, 20)
|
1 -> repository.getWallpapers(20, 20)
|
||||||
2 -> repository.getWallpapers(20, 50)
|
2 -> repository.getWallpapers(20, 50)
|
||||||
|
|||||||
@ -8,13 +8,13 @@
|
|||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeColor="#000000"
|
android:strokeColor="#2196F3"
|
||||||
android:strokeLineCap="round"/>
|
android:strokeLineCap="round"/>
|
||||||
<path
|
<path
|
||||||
android:pathData="M36,36L24,24L36,12"
|
android:pathData="M36,36L24,24L36,12"
|
||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeColor="#000000"
|
android:strokeColor="#2196F3"
|
||||||
android:strokeLineCap="round"/>
|
android:strokeLineCap="round"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@ -8,23 +8,23 @@
|
|||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeColor="#FFEB3B"/>
|
android:strokeColor="#2196F3"/>
|
||||||
<path
|
<path
|
||||||
android:pathData="M18,28H8C6.895,28 6,28.895 6,30V40C6,41.105 6.895,42 8,42H18C19.105,42 20,41.105 20,40V30C20,28.895 19.105,28 18,28Z"
|
android:pathData="M18,28H8C6.895,28 6,28.895 6,30V40C6,41.105 6.895,42 8,42H18C19.105,42 20,41.105 20,40V30C20,28.895 19.105,28 18,28Z"
|
||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeColor="#FFEB3B"/>
|
android:strokeColor="#2196F3"/>
|
||||||
<path
|
<path
|
||||||
android:pathData="M40,6H30C28.895,6 28,6.895 28,8V18C28,19.105 28.895,20 30,20H40C41.105,20 42,19.105 42,18V8C42,6.895 41.105,6 40,6Z"
|
android:pathData="M40,6H30C28.895,6 28,6.895 28,8V18C28,19.105 28.895,20 30,20H40C41.105,20 42,19.105 42,18V8C42,6.895 41.105,6 40,6Z"
|
||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeColor="#FFEB3B"/>
|
android:strokeColor="#2196F3"/>
|
||||||
<path
|
<path
|
||||||
android:pathData="M40,28H30C28.895,28 28,28.895 28,30V40C28,41.105 28.895,42 30,42H40C41.105,42 42,41.105 42,40V30C42,28.895 41.105,28 40,28Z"
|
android:pathData="M40,28H30C28.895,28 28,28.895 28,30V40C28,41.105 28.895,42 30,42H40C41.105,42 42,41.105 42,40V30C42,28.895 41.105,28 40,28Z"
|
||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeColor="#FFEB3B"/>
|
android:strokeColor="#2196F3"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@ -8,13 +8,13 @@
|
|||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeColor="#FFEB3B"
|
android:strokeColor="#2196F3"
|
||||||
android:strokeLineCap="round"/>
|
android:strokeLineCap="round"/>
|
||||||
<path
|
<path
|
||||||
android:pathData="M35,27L37.243,31.913L42.609,32.528L38.629,36.179L39.702,41.472L35,38.816L30.298,41.472L31.371,36.179L27.392,32.528L32.757,31.913L35,27Z"
|
android:pathData="M35,27L37.243,31.913L42.609,32.528L38.629,36.179L39.702,41.472L35,38.816L30.298,41.472L31.371,36.179L27.392,32.528L32.757,31.913L35,27Z"
|
||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#FFEB3B"
|
android:fillColor="#2196F3"
|
||||||
android:strokeColor="#FFEB3B"
|
android:strokeColor="#2196F3"
|
||||||
android:strokeLineCap="round"/>
|
android:strokeLineCap="round"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
@ -7,13 +7,13 @@
|
|||||||
android:pathData="M44,44V20L24,4L4,20L4,44H16V26H32V44H44Z"
|
android:pathData="M44,44V20L24,4L4,20L4,44H16V26H32V44H44Z"
|
||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#FFEB3B"
|
android:fillColor="#2196F3"
|
||||||
android:strokeColor="#FFEB3B"/>
|
android:strokeColor="#2196F3"/>
|
||||||
<path
|
<path
|
||||||
android:pathData="M24,44V34"
|
android:pathData="M24,44V34"
|
||||||
android:strokeLineJoin="round"
|
android:strokeLineJoin="round"
|
||||||
android:strokeWidth="4"
|
android:strokeWidth="4"
|
||||||
android:fillColor="#00000000"
|
android:fillColor="#00000000"
|
||||||
android:strokeColor="#FFEB3B"
|
android:strokeColor="#2196F3"
|
||||||
android:strokeLineCap="round"/>
|
android:strokeLineCap="round"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
30
app/src/main/res/drawable/seek_bar_color.xml
Normal file
30
app/src/main/res/drawable/seek_bar_color.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<!-- res/drawable/seekbar_progress_drawable.xml -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@android:id/background">
|
||||||
|
<shape>
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<solid android:color="#D3D3D3" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item android:id="@android:id/secondaryProgress">
|
||||||
|
<clip>
|
||||||
|
<shape>
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<solid android:color="#FFD700" />
|
||||||
|
</shape>
|
||||||
|
</clip>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item android:id="@android:id/progress">
|
||||||
|
<clip>
|
||||||
|
<shape>
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<gradient
|
||||||
|
android:startColor="#4891FF"
|
||||||
|
android:endColor="#6CE89E"
|
||||||
|
android:angle="0" />
|
||||||
|
</shape>
|
||||||
|
</clip>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
@ -5,6 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@mipmap/background"
|
||||||
tools:context=".ui.activity.CategoryActivity">
|
tools:context=".ui.activity.CategoryActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/gray"
|
android:background="@mipmap/background"
|
||||||
tools:context=".ui.activity.ImageActivity">
|
tools:context=".ui.activity.ImageActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:background="@mipmap/background"
|
||||||
tools:context=".ui.activity.MainActivity">
|
tools:context=".ui.activity.MainActivity">
|
||||||
|
|
||||||
<androidx.viewpager2.widget.ViewPager2
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
|||||||
50
app/src/main/res/layout/activity_splash.xml
Normal file
50
app/src/main/res/layout/activity_splash.xml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?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:id="@+id/main"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@mipmap/background"
|
||||||
|
tools:activity=".ui.activity.SplashActivity">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/splash_image"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="150dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintVertical_bias="0.388" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/splash_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="32dp"
|
||||||
|
android:text="@string/app_name"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:gravity="center"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/splash_image" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="5dp"
|
||||||
|
android:layout_marginStart="53dp"
|
||||||
|
android:layout_marginEnd="53dp"
|
||||||
|
android:layout_marginBottom="80dp"
|
||||||
|
android:max="100"
|
||||||
|
android:progress="0"
|
||||||
|
android:progressDrawable="@drawable/seek_bar_color"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
BIN
app/src/main/res/mipmap-xxxhdpi/background.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 150 KiB |
6
keystore.properties
Normal file
6
keystore.properties
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
app_name=Wallpaper Dream
|
||||||
|
package_name=com.wallpaper.wallpaperdream
|
||||||
|
keystoreFile=app/WallpaperDream.jks
|
||||||
|
key_alias=WallpaperDreamkey0
|
||||||
|
key_store_password=WallpaperDream
|
||||||
|
key_password=WallpaperDream
|
||||||
Loading…
Reference in New Issue
Block a user