创建仓库
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
|
||||
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
||||
58
app/build.gradle.kts
Normal file
@ -0,0 +1,58 @@
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
}
|
||||
val timestamp: String = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
android {
|
||||
namespace = "com.wallpaper.coolwallpaper"
|
||||
compileSdk = 35
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.wallpaper.coolwallpaper"
|
||||
minSdk = 23
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
setProperty("archivesBaseName", "Cool Wallpaper_V" + versionName + "(${versionCode})_$timestamp")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
}
|
||||
|
||||
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")
|
||||
|
||||
implementation ("androidx.room:room-runtime:2.6.1")
|
||||
annotationProcessor ("androidx.room:room-compiler:2.6.1")
|
||||
|
||||
implementation ("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
}
|
||||
35
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
# 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
|
||||
|
||||
-keepclassmembers class com.wallpaper.coolwallpaper.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.coolwallpaper.database.AppDatabase { *; }
|
||||
-keep class com.wallpaper.coolwallpaper.database.CoolEntity { *; }
|
||||
-keep class com.wallpaper.coolwallpaper.database.CoolEntityDao { *; }
|
||||
-keep class com.wallpaper.coolwallpaper.database.CategoryList { *; }
|
||||
@ -0,0 +1,26 @@
|
||||
package com.wallpaper.coolwallpaper;
|
||||
|
||||
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.wallpaper.coolwallpaper", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
42
app/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"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<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:name=".MyApplication"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.CoolWallpaper"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".activity.DetailActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.WelcomeActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.SubListActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
12208
app/src/main/assets/wallpapers.json
Normal file
@ -0,0 +1,52 @@
|
||||
package com.wallpaper.coolwallpaper;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.wallpaper.coolwallpaper.database.CategoryList;
|
||||
import com.wallpaper.coolwallpaper.util.JsonParse;
|
||||
import com.wallpaper.coolwallpaper.util.RoomUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class MyApplication extends Application {
|
||||
public static MyApplication application;
|
||||
public static final int DB_VERSION = 1;
|
||||
public static final String DB_NAME = "cool_database";
|
||||
private static final String PREF_NAME = "app_preferences";
|
||||
private static final String KEY_INIT = "isInit";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
application = this;
|
||||
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
|
||||
boolean isDatabaseInitialized = sharedPreferences.getBoolean(KEY_INIT, false);
|
||||
|
||||
if (!isDatabaseInitialized) {
|
||||
initializeDatabase();
|
||||
sharedPreferences.edit().putBoolean(KEY_INIT, true).apply();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
return application.getApplicationContext();
|
||||
}
|
||||
|
||||
private void initializeDatabase() {
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
List<CategoryList> categoryList = getCategoryList();
|
||||
RoomUtils roomUtils = new RoomUtils(getContext());
|
||||
roomUtils.insertAllImages(categoryList);
|
||||
});
|
||||
}
|
||||
|
||||
public static List<CategoryList> getCategoryList() {
|
||||
return JsonParse.parseJson("wallpapers.json");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,246 @@
|
||||
package com.wallpaper.coolwallpaper.activity;
|
||||
|
||||
import static com.wallpaper.coolwallpaper.util.SetAndDownloadUtils.REQUEST_CODE_WRITE_EXTERNAL_STORAGE;
|
||||
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.wallpaper.coolwallpaper.R;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntity;
|
||||
import com.wallpaper.coolwallpaper.databinding.ActivityDetailBinding;
|
||||
import com.wallpaper.coolwallpaper.util.SetAndDownloadUtils;
|
||||
import com.wallpaper.coolwallpaper.util.RoomUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class DetailActivity extends AppCompatActivity {
|
||||
private ActivityDetailBinding binding;
|
||||
private String original;
|
||||
private String source;
|
||||
private CoolEntity coolEntity;
|
||||
private RoomUtils roomUtils;
|
||||
private String name;
|
||||
private Bitmap bitmap;
|
||||
private SetAndDownloadUtils setAndDownloadUtils;
|
||||
private ExecutorService executorService;
|
||||
private Handler handler;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
binding = ActivityDetailBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
||||
int navigationBars = insets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom;
|
||||
v.setPadding(0, 0, 0, navigationBars);
|
||||
return insets;
|
||||
});
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
coolEntity = (CoolEntity) getIntent().getSerializableExtra("cool");
|
||||
if (coolEntity != null) {
|
||||
original = coolEntity.getOriginal();
|
||||
source = coolEntity.getSource();
|
||||
name = coolEntity.getName();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
roomUtils = new RoomUtils(this);
|
||||
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
executorService = Executors.newSingleThreadExecutor();
|
||||
|
||||
setAndDownloadUtils = new SetAndDownloadUtils( binding.progressBar, binding.view);
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
showProgress();
|
||||
|
||||
binding.back.setOnClickListener(v -> finish());
|
||||
|
||||
binding.like.setOnClickListener(v -> {
|
||||
boolean newStatus = !coolEntity.getLike();
|
||||
coolEntity.setLike(newStatus);
|
||||
executorService.submit(() -> roomUtils.update(coolEntity));
|
||||
});
|
||||
|
||||
binding.set.setOnClickListener(v -> showCustomBottomSheetDialog());
|
||||
|
||||
binding.downPicture.setOnClickListener(v -> {
|
||||
showProgress();
|
||||
setAndDownloadUtils.setAsWallpaper(DetailActivity.this, source);
|
||||
});
|
||||
|
||||
loadImage();
|
||||
loadFavorite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_CODE_WRITE_EXTERNAL_STORAGE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
setAndDownloadUtils.setAsWallpaper(this, source);
|
||||
} else {
|
||||
Toast.makeText(this, "Write permission to external storage is denied", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showCustomBottomSheetDialog() {
|
||||
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
|
||||
View dialogView = LayoutInflater.from(this).inflate(R.layout.detail_dialog, null);
|
||||
|
||||
dialogView.findViewById(R.id.both).setOnClickListener(v -> {
|
||||
handleWallpaperAction(bitmap, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK);
|
||||
bottomSheetDialog.dismiss();
|
||||
});
|
||||
|
||||
dialogView.findViewById(R.id.lock).setOnClickListener(v -> {
|
||||
handleWallpaperAction(bitmap, WallpaperManager.FLAG_LOCK);
|
||||
bottomSheetDialog.dismiss();
|
||||
});
|
||||
|
||||
dialogView.findViewById(R.id.desktop).setOnClickListener(v -> {
|
||||
handleWallpaperAction(bitmap, WallpaperManager.FLAG_SYSTEM);
|
||||
bottomSheetDialog.dismiss();
|
||||
});
|
||||
|
||||
bottomSheetDialog.setContentView(dialogView);
|
||||
bottomSheetDialog.show();
|
||||
}
|
||||
|
||||
private void handleWallpaperAction(Bitmap bitmap, int flag) {
|
||||
showProgress();
|
||||
executorService.submit(() -> {
|
||||
boolean isSuccess = false;
|
||||
try {
|
||||
isSuccess = setWallpaper(bitmap, flag);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
boolean finalIsSuccess = isSuccess;
|
||||
handler.post(() -> {
|
||||
hideProgress();
|
||||
binding.set.setEnabled(true);
|
||||
if (finalIsSuccess) {
|
||||
Toast.makeText(getApplicationContext(), "Wallpaper setting is successful", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "Wallpaper setting failed", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean setWallpaper(Bitmap bitmap, int flag) {
|
||||
WallpaperManager wm = WallpaperManager.getInstance(getApplicationContext());
|
||||
try {
|
||||
binding.imageView.setDrawingCacheEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
wm.setBitmap(bitmap, null, true, flag);
|
||||
} else {
|
||||
wm.setBitmap(bitmap);
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
binding.imageView.setDrawingCacheEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadImage() {
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(original)
|
||||
.error(ContextCompat.getDrawable(this, R.mipmap.placeholder))
|
||||
.override(1080, 1920)
|
||||
.centerInside()
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
binding.imageView.setImageBitmap(resource);
|
||||
bitmap = resource;
|
||||
hideProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(Drawable placeholder) {
|
||||
binding.imageView.setImageDrawable(placeholder != null ? placeholder : getDefaultPlaceholder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(Drawable errorDrawable) {
|
||||
binding.imageView.setImageDrawable(errorDrawable != null ? errorDrawable : getDefaultPlaceholder());
|
||||
hideProgress();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Drawable getDefaultPlaceholder() {
|
||||
return ContextCompat.getDrawable(this, R.mipmap.placeholder);
|
||||
}
|
||||
|
||||
private void loadFavorite() {
|
||||
roomUtils.getWallpaperLike(source, name).observe(this, wallpaper -> setFavoriteButton());
|
||||
}
|
||||
|
||||
private void setFavoriteButton() {
|
||||
binding.like.setImageResource(
|
||||
coolEntity.getLike() ? R.drawable.like : R.drawable.un_like
|
||||
);
|
||||
}
|
||||
|
||||
private void hideProgress() {
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
binding.view.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void showProgress() {
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
binding.view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (executorService != null) {
|
||||
executorService.shutdown();
|
||||
}
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,114 @@
|
||||
package com.wallpaper.coolwallpaper.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.wallpaper.coolwallpaper.R;
|
||||
import com.wallpaper.coolwallpaper.adapter.MainAdapter;
|
||||
import com.wallpaper.coolwallpaper.databinding.ActivityMainBinding;
|
||||
import com.wallpaper.coolwallpaper.databinding.TabLayoutBinding;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private ActivityMainBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
MainAdapter adapter = new MainAdapter(this);
|
||||
binding.mainViewpager2.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
binding.mainViewpager2.setUserInputEnabled(false);
|
||||
|
||||
new TabLayoutMediator(binding.mainTabLayout, binding.mainViewpager2, (tab, position) -> {
|
||||
TabLayoutBinding tabLayoutBinding = TabLayoutBinding.inflate(LayoutInflater.from(this));
|
||||
tab.setCustomView(tabLayoutBinding.getRoot());
|
||||
setTab(tabLayoutBinding, position);
|
||||
}).attach();
|
||||
|
||||
binding.mainTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
updateTab(tab, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
updateTab(tab, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
}
|
||||
|
||||
private void updateTab(TabLayout.Tab tab, boolean isSelected) {
|
||||
if (tab.getCustomView() != null) {
|
||||
TabLayoutBinding mainCustomBinding = TabLayoutBinding.bind(tab.getCustomView());
|
||||
|
||||
int iconResId = getIconResource(tab.getPosition(), isSelected);
|
||||
mainCustomBinding.image.setImageResource(iconResId);
|
||||
|
||||
int textColor = isSelected ? R.color.gray : R.color.black;
|
||||
mainCustomBinding.text.setTextColor(ContextCompat.getColor(MainActivity.this, textColor));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setTab(TabLayoutBinding tabLayoutBinding, int position) {
|
||||
int iconResId = getIconResource(position, false);
|
||||
int textColorResId = R.color.gray;
|
||||
|
||||
switch (position) {
|
||||
case 0:
|
||||
tabLayoutBinding.text.setText("Home");
|
||||
iconResId = R.drawable.main;
|
||||
textColorResId = R.color.gray;
|
||||
break;
|
||||
case 1:
|
||||
tabLayoutBinding.text.setText("Collection");
|
||||
break;
|
||||
}
|
||||
|
||||
tabLayoutBinding.image.setImageResource(iconResId);
|
||||
tabLayoutBinding.text.setTextColor(ContextCompat.getColor(this, textColorResId));
|
||||
}
|
||||
|
||||
private int getIconResource(int position, boolean isSelected) {
|
||||
if (position == 1) {
|
||||
return isSelected ? R.drawable.favorite : R.drawable.un_favorite;
|
||||
}
|
||||
return isSelected ? R.drawable.main : R.drawable.un_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.wallpaper.coolwallpaper.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.wallpaper.coolwallpaper.R;
|
||||
import com.wallpaper.coolwallpaper.adapter.WallpaperAdapter;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntity;
|
||||
import com.wallpaper.coolwallpaper.databinding.ActivitySubListBinding;
|
||||
import com.wallpaper.coolwallpaper.util.ItemDecoration;
|
||||
import com.wallpaper.coolwallpaper.util.RoomUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SubListActivity extends AppCompatActivity {
|
||||
private ActivitySubListBinding binding;
|
||||
private WallpaperAdapter wallpaperAdapter;
|
||||
private RoomUtils roomUtils;
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
EdgeToEdge.enable(this);
|
||||
binding = ActivitySubListBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
name = getIntent().getStringExtra("name");
|
||||
if (name == null) {
|
||||
Toast.makeText(this, "The picture does not exist", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
roomUtils = new RoomUtils(this);
|
||||
|
||||
binding.recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
wallpaperAdapter = new WallpaperAdapter(this, new ArrayList<>(), this);
|
||||
binding.recyclerView.setAdapter(wallpaperAdapter);
|
||||
|
||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
||||
binding.recyclerView.addItemDecoration(itemDecoration);
|
||||
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
|
||||
binding.back.setOnClickListener(v -> finish());
|
||||
binding.text.setText(name);
|
||||
|
||||
loadImage();
|
||||
}
|
||||
|
||||
private void loadImage() {
|
||||
roomUtils
|
||||
.getAllCategory(name)
|
||||
.observe(this, new Observer<List<CoolEntity>>() {
|
||||
@Override
|
||||
public void onChanged(List<CoolEntity> coolEntities) {
|
||||
wallpaperAdapter.updateData(coolEntities);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
package com.wallpaper.coolwallpaper.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
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;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.wallpaper.coolwallpaper.R;
|
||||
import com.wallpaper.coolwallpaper.databinding.ActivityWelcomeBinding;
|
||||
|
||||
public class WelcomeActivity extends AppCompatActivity {
|
||||
|
||||
private ActivityWelcomeBinding binding;
|
||||
private static final long TOTAL_TIME = 1000;
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
|
||||
binding = ActivityWelcomeBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
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;
|
||||
});
|
||||
|
||||
ProgressBar progressBar = binding.progressBar;
|
||||
|
||||
Glide.with(this)
|
||||
.load(R.mipmap.placeholder)
|
||||
.transform(new RoundedCorners(16))
|
||||
.into(binding.image);
|
||||
|
||||
countDownTimer = new CountDownTimer(TOTAL_TIME, 100) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
int percentage = (int) (100 - (float) millisUntilFinished / TOTAL_TIME * 100);
|
||||
progressBar.setProgress(percentage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
startMain();
|
||||
}
|
||||
};
|
||||
|
||||
countDownTimer.start();
|
||||
}
|
||||
|
||||
private void startMain() {
|
||||
binding.progressBar.setProgress(100);
|
||||
|
||||
Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel();
|
||||
}
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.wallpaper.coolwallpaper.adapter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import com.wallpaper.coolwallpaper.fragment.HomeFragment;
|
||||
import com.wallpaper.coolwallpaper.fragment.CollectionFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MainAdapter extends FragmentStateAdapter {
|
||||
|
||||
private final List<Fragment> fragmentList = new ArrayList<>();
|
||||
|
||||
public MainAdapter(@NonNull FragmentActivity fragmentActivity) {
|
||||
super(fragmentActivity);
|
||||
fragmentList.add(new HomeFragment());
|
||||
fragmentList.add(new CollectionFragment());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment createFragment(int position) {
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return fragmentList.size();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,94 @@
|
||||
package com.wallpaper.coolwallpaper.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.wallpaper.coolwallpaper.R;
|
||||
import com.wallpaper.coolwallpaper.activity.SubListActivity;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SubListAdapter extends RecyclerView.Adapter<SubListAdapter.ViewHolder> {
|
||||
private List<CoolEntity> categoryList;
|
||||
private final Context context;
|
||||
private final Activity activity;
|
||||
|
||||
public SubListAdapter(Context context, List<CoolEntity> categoryList, Activity activity) {
|
||||
this.context = context;
|
||||
this.categoryList = categoryList;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public void updateData(List<CoolEntity> newFavoriteImages) {
|
||||
this.categoryList = newFavoriteImages;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.item_sublist, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
CoolEntity coolEntity = categoryList.get(position);
|
||||
holder.bind(coolEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return categoryList.size();
|
||||
}
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView imageView;
|
||||
TextView textView;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
imageView = itemView.findViewById(R.id.imageview);
|
||||
textView = itemView.findViewById(R.id.category_title);
|
||||
}
|
||||
|
||||
void bind(CoolEntity coolEntity) {
|
||||
String imageEntryOriginal = coolEntity.getOriginal();
|
||||
|
||||
textView.setText(coolEntity.getName());
|
||||
loadImage(imageEntryOriginal);
|
||||
setClickListeners(coolEntity);
|
||||
}
|
||||
|
||||
private void loadImage(String imageEntryOriginal) {
|
||||
|
||||
Glide.with(context)
|
||||
.load(imageEntryOriginal)
|
||||
.transform(new RoundedCorners(32))
|
||||
.error(R.mipmap.placeholder)
|
||||
.placeholder(R.mipmap.placeholder)
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
private void setClickListeners(final CoolEntity coolEntity) {
|
||||
imageView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(activity, SubListActivity.class);
|
||||
intent.putExtra("name", coolEntity.getName());
|
||||
activity.startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
package com.wallpaper.coolwallpaper.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
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.load.resource.bitmap.RoundedCorners;
|
||||
import com.wallpaper.coolwallpaper.R;
|
||||
import com.wallpaper.coolwallpaper.activity.DetailActivity;
|
||||
import com.wallpaper.coolwallpaper.activity.SubListActivity;
|
||||
import com.wallpaper.coolwallpaper.database.AppDatabase;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class WallpaperAdapter extends RecyclerView.Adapter<WallpaperAdapter.ViewHolder> {
|
||||
private List<CoolEntity> coolEntities;
|
||||
private final Context context;
|
||||
private final Activity activity;
|
||||
private final Executor executor = Executors.newSingleThreadExecutor();
|
||||
|
||||
public WallpaperAdapter(Context context, List<CoolEntity> coolEntities, Activity activity) {
|
||||
this.context = context;
|
||||
this.coolEntities = coolEntities;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public void updateData(List<CoolEntity> newFavoriteImages) {
|
||||
this.coolEntities = newFavoriteImages;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.item_cool, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
CoolEntity coolEntity = coolEntities.get(position);
|
||||
holder.bind(coolEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return coolEntities.size();
|
||||
}
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView imageView;
|
||||
ImageView favoriteButton;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
imageView = itemView.findViewById(R.id.image_view);
|
||||
favoriteButton = itemView.findViewById(R.id.favorite);
|
||||
}
|
||||
|
||||
void bind(CoolEntity coolEntity) {
|
||||
String imageEntryOriginal = coolEntity.getOriginal();
|
||||
|
||||
loadImage(imageEntryOriginal);
|
||||
setFavoriteButton(coolEntity);
|
||||
setClickListeners(coolEntity);
|
||||
}
|
||||
|
||||
private void loadImage(String imageEntryOriginal) {
|
||||
|
||||
Glide.with(context)
|
||||
.load(imageEntryOriginal)
|
||||
.transform(new RoundedCorners(32))
|
||||
.error(R.mipmap.placeholder)
|
||||
.placeholder(R.mipmap.placeholder)
|
||||
.into(imageView);
|
||||
}
|
||||
|
||||
private void setFavoriteButton(CoolEntity coolEntity) {
|
||||
favoriteButton.setImageResource(coolEntity.getLike()
|
||||
? R.drawable.like
|
||||
: R.drawable.un_like);
|
||||
}
|
||||
|
||||
private void setClickListeners(CoolEntity coolEntity) {
|
||||
imageView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(activity, DetailActivity.class);
|
||||
intent.putExtra("cool", coolEntity);
|
||||
activity.startActivity(intent);
|
||||
});
|
||||
|
||||
favoriteButton.setOnClickListener(v -> toggleFavorite(coolEntity));
|
||||
}
|
||||
|
||||
private void toggleFavorite(CoolEntity coolEntity) {
|
||||
boolean newStatus = !coolEntity.getLike();
|
||||
coolEntity.setLike(newStatus);
|
||||
|
||||
updateImageInDatabase(coolEntity);
|
||||
notifyItemChanged(getAdapterPosition());
|
||||
}
|
||||
|
||||
private void updateImageInDatabase(CoolEntity coolEntity) {
|
||||
executor.execute(() -> {
|
||||
AppDatabase.getInstance(context)
|
||||
.imageEntryDao()
|
||||
.update(coolEntity);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.wallpaper.coolwallpaper.database;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.wallpaper.coolwallpaper.MyApplication;
|
||||
|
||||
@Database(entities = {CoolEntity.class}, version = MyApplication.DB_VERSION, exportSchema = false)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
|
||||
public abstract CoolEntityDao imageEntryDao();
|
||||
private static volatile AppDatabase INSTANCE;
|
||||
|
||||
public static AppDatabase getInstance(Context context) {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (AppDatabase.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
|
||||
AppDatabase.class, MyApplication.DB_NAME)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package com.wallpaper.coolwallpaper.database;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CategoryList {
|
||||
private String name;
|
||||
private List<CoolEntity> list;
|
||||
|
||||
public CategoryList(String name, List<CoolEntity> list) {
|
||||
this.name = name;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<CoolEntity> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<CoolEntity> list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.wallpaper.coolwallpaper.database;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity
|
||||
public class CoolEntity implements Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int id;
|
||||
private String original;
|
||||
private String previewThumb;
|
||||
private String source;
|
||||
private String name;
|
||||
private Boolean isLike;
|
||||
|
||||
public CoolEntity(String original, String previewThumb, String source, String name, Boolean isLike) {
|
||||
this.original = original;
|
||||
this.previewThumb = previewThumb;
|
||||
this.source = source;
|
||||
this.name = name;
|
||||
this.isLike = isLike;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getOriginal() {
|
||||
return original;
|
||||
}
|
||||
|
||||
public void setOriginal(String original) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
public String getPreviewThumb() {
|
||||
return previewThumb;
|
||||
}
|
||||
|
||||
public void setPreviewThumb(String previewThumb) {
|
||||
this.previewThumb = previewThumb;
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Boolean getLike() {
|
||||
return isLike;
|
||||
}
|
||||
|
||||
public void setLike(Boolean like) {
|
||||
isLike = like;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.wallpaper.coolwallpaper.database;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface CoolEntityDao {
|
||||
@Insert
|
||||
void insertAll(List<CoolEntity> coolEntity);
|
||||
|
||||
@Update
|
||||
void update(CoolEntity coolEntity);
|
||||
|
||||
@Query("SELECT * FROM CoolEntity WHERE isLike = 1 ")
|
||||
LiveData<List<CoolEntity>> getAllFavoriteLive();
|
||||
|
||||
@Query("SELECT * FROM CoolEntity WHERE id IN (SELECT MIN(id) FROM CoolEntity GROUP BY name)")
|
||||
LiveData<List<CoolEntity>> getFirstRecordOfEachName();
|
||||
|
||||
@Query("SELECT * FROM CoolEntity WHERE name = :name")
|
||||
LiveData<List<CoolEntity>> getAllCategoryLive(String name);
|
||||
|
||||
@Query("SELECT isLIKE FROM CoolEntity WHERE source = :source AND name = :name")
|
||||
LiveData<Boolean> getWallpaperLike(String source, String name);
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package com.wallpaper.coolwallpaper.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.wallpaper.coolwallpaper.adapter.SubListAdapter;
|
||||
import com.wallpaper.coolwallpaper.adapter.WallpaperAdapter;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntity;
|
||||
import com.wallpaper.coolwallpaper.databinding.FragmentCollectionBinding;
|
||||
import com.wallpaper.coolwallpaper.util.ItemDecoration;
|
||||
import com.wallpaper.coolwallpaper.util.RoomUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CollectionFragment extends Fragment {
|
||||
|
||||
private FragmentCollectionBinding fragmentCollectionBinding;
|
||||
private WallpaperAdapter wallpaperAdapter;
|
||||
private RoomUtils roomUtils;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
fragmentCollectionBinding = FragmentCollectionBinding.inflate(inflater, container, false);
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
return fragmentCollectionBinding.getRoot();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
roomUtils = new RoomUtils(requireContext());
|
||||
|
||||
fragmentCollectionBinding.recyclerView.setLayoutManager(new GridLayoutManager(getContext(),2));
|
||||
|
||||
wallpaperAdapter = new WallpaperAdapter(requireContext(), new ArrayList<>(), requireActivity());
|
||||
fragmentCollectionBinding.recyclerView.setAdapter(wallpaperAdapter);
|
||||
|
||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
||||
fragmentCollectionBinding.recyclerView.addItemDecoration(itemDecoration);
|
||||
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
loadAllList();
|
||||
}
|
||||
|
||||
private void loadAllList() {
|
||||
roomUtils
|
||||
.getAllFavoriteList()
|
||||
.observe(getViewLifecycleOwner(), new Observer<List<CoolEntity>>() {
|
||||
@Override
|
||||
public void onChanged(List<CoolEntity> coolEntities) {
|
||||
wallpaperAdapter.updateData(coolEntities);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
fragmentCollectionBinding = null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.wallpaper.coolwallpaper.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.wallpaper.coolwallpaper.adapter.SubListAdapter;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntity;
|
||||
import com.wallpaper.coolwallpaper.databinding.FragmentHomeBinding;
|
||||
import com.wallpaper.coolwallpaper.util.ItemDecoration;
|
||||
import com.wallpaper.coolwallpaper.util.RoomUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
private FragmentHomeBinding fragmentHomeBinding;
|
||||
private SubListAdapter subListAdapter;
|
||||
private RoomUtils roomUtils;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
fragmentHomeBinding = FragmentHomeBinding.inflate(inflater, container, false);
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
return fragmentHomeBinding.getRoot();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
roomUtils = new RoomUtils(requireContext());
|
||||
|
||||
fragmentHomeBinding.recyclerView.setLayoutManager(new GridLayoutManager(getContext(),2));
|
||||
|
||||
subListAdapter = new SubListAdapter(requireContext(), new ArrayList<>(), requireActivity());
|
||||
fragmentHomeBinding.recyclerView.setAdapter(subListAdapter);
|
||||
|
||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
||||
fragmentHomeBinding.recyclerView.addItemDecoration(itemDecoration);
|
||||
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
loadCategoryImage();
|
||||
}
|
||||
|
||||
private void loadCategoryImage() {
|
||||
roomUtils
|
||||
.getCategoryFirst()
|
||||
.observe(getViewLifecycleOwner(), new Observer<List<CoolEntity>>() {
|
||||
@Override
|
||||
public void onChanged(List<CoolEntity> coolEntities) {
|
||||
subListAdapter.updateData(coolEntities);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
fragmentHomeBinding = null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
package com.wallpaper.coolwallpaper.util;
|
||||
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
|
||||
import com.wallpaper.coolwallpaper.MyApplication;
|
||||
|
||||
public class ItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private final int v;
|
||||
private final int h;
|
||||
private final int ex;
|
||||
|
||||
public ItemDecoration(int v, int h, int ex) {
|
||||
this.v = Math.round(dpToPx(v));
|
||||
this.h = Math.round(dpToPx(h));
|
||||
this.ex = Math.round(dpToPx(ex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
int spanCount = 1;
|
||||
int spanSize = 1;
|
||||
int spanIndex = 0;
|
||||
|
||||
int childAdapterPosition = parent.getChildAdapterPosition(view);
|
||||
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
|
||||
if (layoutManager instanceof StaggeredGridLayoutManager) {
|
||||
StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
|
||||
StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) view.getLayoutParams();
|
||||
spanCount = staggeredGridLayoutManager.getSpanCount();
|
||||
if (layoutParams.isFullSpan()) {
|
||||
spanSize = spanCount;
|
||||
}
|
||||
spanIndex = layoutParams.getSpanIndex();
|
||||
} else if (layoutManager instanceof GridLayoutManager) {
|
||||
GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
|
||||
GridLayoutManager.LayoutParams layoutParams = (GridLayoutManager.LayoutParams) view.getLayoutParams();
|
||||
spanCount = gridLayoutManager.getSpanCount();
|
||||
spanSize = gridLayoutManager.getSpanSizeLookup().getSpanSize(childAdapterPosition);
|
||||
spanIndex = layoutParams.getSpanIndex();
|
||||
} else if (layoutManager instanceof LinearLayoutManager) {
|
||||
outRect.left = v;
|
||||
outRect.right = v;
|
||||
outRect.bottom = h;
|
||||
}
|
||||
|
||||
if (spanSize == spanCount) {
|
||||
outRect.left = v + ex;
|
||||
outRect.right = v + ex;
|
||||
|
||||
} else {
|
||||
int itemAllSpacing = (v * (spanCount + 1) + ex * 2) / spanCount;
|
||||
int left = v * (spanIndex + 1) - itemAllSpacing * spanIndex + ex;
|
||||
int right = itemAllSpacing - left;
|
||||
outRect.left = left;
|
||||
outRect.right = right;
|
||||
|
||||
}
|
||||
outRect.bottom = h;
|
||||
|
||||
}
|
||||
|
||||
public static float dpToPx(float dpValue) {
|
||||
float density = MyApplication.getContext().getResources().getDisplayMetrics().density;
|
||||
return density * dpValue + 0.5f;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
package com.wallpaper.coolwallpaper.util;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.wallpaper.coolwallpaper.MyApplication;
|
||||
import com.wallpaper.coolwallpaper.database.CategoryList;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntity;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JsonParse {
|
||||
|
||||
private static String loadJSONFromAsset(String fileName) {
|
||||
StringBuilder jsonString = new StringBuilder();
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(MyApplication.getContext().getAssets().open(fileName)))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
jsonString.append(line);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.d("JsonParse", "Loaded JSON: " + jsonString.toString());
|
||||
return jsonString.toString();
|
||||
}
|
||||
|
||||
public static List<CategoryList> parseJson(String fileName) {
|
||||
List<CategoryList> categoryList = new ArrayList<>();
|
||||
try {
|
||||
String jsonString = loadJSONFromAsset(fileName);
|
||||
if (jsonString.isEmpty()) {
|
||||
throw new IllegalArgumentException("JSON file is empty or invalid.");
|
||||
}
|
||||
|
||||
JSONArray jsonArray = new JSONArray(jsonString);
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject categoryObject = jsonArray.getJSONObject(i);
|
||||
String name = categoryObject.getString("name");
|
||||
|
||||
JSONArray listArray = categoryObject.getJSONArray("data");
|
||||
List<CoolEntity> coolEntities = new ArrayList<>();
|
||||
|
||||
for (int j = 0; j < listArray.length(); j++) {
|
||||
JSONObject imageObject = listArray.getJSONObject(j);
|
||||
String original = imageObject.getString("original");
|
||||
String previewThumb = imageObject.getString("previewThumb");
|
||||
String source = imageObject.getString("source");
|
||||
|
||||
coolEntities.add(new CoolEntity(original, previewThumb, source, name, false));
|
||||
}
|
||||
|
||||
categoryList.add(new CategoryList(name, coolEntities));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return categoryList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.wallpaper.coolwallpaper.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.wallpaper.coolwallpaper.database.AppDatabase;
|
||||
import com.wallpaper.coolwallpaper.database.CategoryList;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntity;
|
||||
import com.wallpaper.coolwallpaper.database.CoolEntityDao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RoomUtils {
|
||||
|
||||
private final CoolEntityDao coolEntityDao;
|
||||
|
||||
public RoomUtils(Context context) {
|
||||
AppDatabase db = AppDatabase.getInstance(context);
|
||||
coolEntityDao = db.imageEntryDao();
|
||||
}
|
||||
|
||||
public void insertAllImages(List<CategoryList> categoryList) {
|
||||
List<CoolEntity> coolEntities = new ArrayList<>();
|
||||
|
||||
for (CategoryList category : categoryList) {
|
||||
coolEntities.addAll(category.getList());
|
||||
}
|
||||
|
||||
coolEntityDao.insertAll(coolEntities);
|
||||
}
|
||||
|
||||
public LiveData<List<CoolEntity>> getAllFavoriteList() {
|
||||
return coolEntityDao.getAllFavoriteLive();
|
||||
}
|
||||
|
||||
public LiveData<List<CoolEntity>> getCategoryFirst() {
|
||||
return coolEntityDao.getFirstRecordOfEachName();
|
||||
}
|
||||
|
||||
public LiveData<List<CoolEntity>> getAllCategory(String name) {
|
||||
return coolEntityDao.getAllCategoryLive(name);
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getWallpaperLike(String source, String name) {
|
||||
return coolEntityDao.getWallpaperLike(source, name);
|
||||
}
|
||||
|
||||
public void update(CoolEntity imageEntry) {
|
||||
coolEntityDao.update(imageEntry);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,121 @@
|
||||
package com.wallpaper.coolwallpaper.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentValues;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class SetAndDownloadUtils {
|
||||
public static final int REQUEST_CODE_WRITE_EXTERNAL_STORAGE = 111;
|
||||
private final ProgressBar progressBar;
|
||||
private final ImageView overlayView;
|
||||
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
|
||||
public SetAndDownloadUtils(ProgressBar progressBar, ImageView overlayView) {
|
||||
this.progressBar = progressBar;
|
||||
this.overlayView = overlayView;
|
||||
}
|
||||
|
||||
public void setAsWallpaper(Activity activity, String imageUrl) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
startDownload(activity, imageUrl);
|
||||
} else {
|
||||
if (ContextCompat.checkSelfPermission(activity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(activity,
|
||||
new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
REQUEST_CODE_WRITE_EXTERNAL_STORAGE);
|
||||
} else {
|
||||
startDownload(activity, imageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startDownload(Activity activity, String imageUrl) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
overlayView.setVisibility(View.VISIBLE);
|
||||
|
||||
executorService.submit(() -> {
|
||||
Uri uri = downloadImage(activity, imageUrl);
|
||||
activity.runOnUiThread(() -> {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
overlayView.setVisibility(View.GONE);
|
||||
|
||||
if (uri != null) {
|
||||
Toast.makeText(activity, "Wallpaper downloaded", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(activity, "Wallpaper download failure", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private Uri downloadImage(Activity activity, String imageUrl) {
|
||||
String displayName = System.currentTimeMillis() + ".jpg";
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(MediaStore.Images.Media.DISPLAY_NAME, displayName);
|
||||
contentValues.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
contentValues.put(MediaStore.Images.Media.IS_PENDING, 1);
|
||||
}
|
||||
|
||||
Uri collectionUri;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
collectionUri = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
|
||||
} else {
|
||||
collectionUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
|
||||
Uri imageUri = activity.getContentResolver().insert(collectionUri, contentValues);
|
||||
|
||||
if (imageUri != null) {
|
||||
try {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder().url(imageUrl).build();
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.isSuccessful()) {
|
||||
InputStream inputStream = response.body().byteStream();
|
||||
try (OutputStream outputStream = activity.getContentResolver().openOutputStream(imageUri)) {
|
||||
if (outputStream != null) {
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
contentValues.clear();
|
||||
contentValues.put(MediaStore.Images.Media.IS_PENDING, 0);
|
||||
activity.getContentResolver().update(imageUri, contentValues, null, null);
|
||||
}
|
||||
|
||||
return imageUri;
|
||||
} catch (IOException e) {
|
||||
activity.getContentResolver().delete(imageUri, null, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
30
app/src/main/res/drawable-v24/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>
|
||||
12
app/src/main/res/drawable/apply.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="32dp"
|
||||
android:height="32dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M408.3,928H97.2C43.6,928 0,885 0,832.2V223.8C0,171 43.6,128 97.2,128h797.7C948.4,128 992,171 992,223.8v144.1h-43.4V223.8a53.4,53.4 0,0 0,-53.8 -53H97.1a53.4,53.4 0,0 0,-53.8 53v608.3a53.4,53.4 0,0 0,53.8 53h311.1V928z"
|
||||
android:fillColor="#231F20"/>
|
||||
<path
|
||||
android:pathData="M160,416h512V352H160zM160,672h320v-64H160zM491.8,843.6l8.4,8.6a0.3,0.3 0,0 1,0.1 0.1l169,-65 4,-3.7 275.4,-275.4a14.3,14.3 0,0 0,-3.8 -6.1l-102.9,-102.9a14.8,14.8 0,0 0,-6.1 -3.8l-278.9,278.9 -65.1,169.3zM500.1,896c-10.8,0 -21.9,-4.7 -30.5,-13.3l-8.4,-8.3c-12.1,-12.1 -16.4,-29 -10.9,-43.1l67.5,-175.8c2.1,-5.3 5.8,-9.1 9,-12.2l280.1,-280.1c8.8,-8.8 21.6,-12.6 34.9,-10.5 11,1.8 21.9,7.5 30.5,16.1l102.9,102.9c19.9,19.9 22.3,48.7 5.6,65.5l-288.5,287.6 -179.6,69.1c-4.1,1.5 -8.3,2.3 -12.7,2.3z"
|
||||
android:fillColor="#231F20"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/back.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M396.9,780.4a42.5,42.5 0,0 0,0 -60.2L231.4,554.7h647.3c23.5,0 42.7,-19.2 42.7,-42.7s-19.2,-42.7 -42.7,-42.7H231l165.5,-165.5a42.5,42.5 0,1 0,-60.2 -60.2l-238.5,238.5a42.5,42.5 0,0 0,0 60.2l238.9,238.1c16.2,16.6 43.5,16.6 60.2,0z"
|
||||
android:fillColor="#858EBD"/>
|
||||
</vector>
|
||||
12
app/src/main/res/drawable/download.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="32dp"
|
||||
android:height="32dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M511.3,63.1c-247.3,0 -448.4,201.1 -448.4,448.4s201.2,448.4 448.4,448.4 448.4,-201.1 448.4,-448.4S758.5,63.1 511.3,63.1zM511.3,891c-209.2,0 -379.4,-170.2 -379.4,-379.4s170.2,-379.4 379.4,-379.4 379.4,170.2 379.4,379.4S720.5,891 511.3,891z"
|
||||
android:fillColor="#85D5F8"/>
|
||||
<path
|
||||
android:pathData="M680.2,508.5l-134.1,134.1v-380c0,-19 -15.4,-34.5 -34.5,-34.5 -19,0 -34.5,15.4 -34.5,34.5v380L337.5,503.1c-13.5,-13.5 -35.3,-13.5 -48.8,0 -13.5,13.5 -13.5,35.3 0,48.8l198.5,198.5a34.5,34.5 0,0 0,5.3 4.3c0.9,0.6 1.8,1 2.7,1.5 1.1,0.6 2.1,1.2 3.3,1.7 1.1,0.5 2.3,0.7 3.5,1.1 1,0.3 1.9,0.7 2.9,0.9 2.2,0.4 4.5,0.7 6.8,0.7s4.5,-0.2 6.8,-0.7c1,-0.2 2,-0.6 2.9,-0.9 1.2,-0.3 2.4,-0.6 3.5,-1.1 1.1,-0.5 2.2,-1.1 3.3,-1.7 0.9,-0.5 1.8,-0.9 2.7,-1.5a34.5,34.5 0,0 0,5.3 -4.3l193,-193c13.5,-13.5 13.5,-35.3 0,-48.8 -13.5,-13.5 -35.3,-13.5 -48.8,0z"
|
||||
android:fillColor="#85D5F8"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/favorite.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="@color/gray"
|
||||
android:pathData="M780.2,97.5a73.1,73.1 0,0 1,73.1 73.1v755.8l-341.3,-152.4L170.7,926.5L170.7,170.7a73.1,73.1 0,0 1,73.1 -73.1h536.4zM780.2,170.7L243.8,170.7v643l268.2,-119.7 268.2,119.7L780.2,170.7z"/>
|
||||
</vector>
|
||||
170
app/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>
|
||||
9
app/src/main/res/drawable/like.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="32dp"
|
||||
android:height="32dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M913.9,208.4c-98.8,-98.8 -258.6,-98.8 -357.4,0l-42,42 -42,-42c-98.8,-98.8 -258.6,-98.8 -357.4,0 -98.3,98.8 -98.3,258.6 0.5,357.4l52.2,52.2 337.4,337.4c5.6,5.6 14.3,5.6 20,0l337.4,-337.4 52.2,-52.2c97.8,-98.8 97.8,-258.6 -1,-357.4z"
|
||||
android:fillColor="#FC053B"/>
|
||||
</vector>
|
||||
24
app/src/main/res/drawable/main.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M134.1,256C147.6,256 158.5,246.4 158.5,234.7 158.5,222.9 147.6,213.3 134.1,213.3L36.6,213.3C23.1,213.3 12.2,222.9 12.2,234.7 12.2,246.4 23.1,256 36.6,256L134.1,256Z"
|
||||
android:fillColor="@color/gray"/>
|
||||
<path
|
||||
android:pathData="M134.1,533.3C147.6,533.3 158.5,523.8 158.5,512 158.5,500.2 147.6,490.7 134.1,490.7L36.6,490.7C23.1,490.7 12.2,500.2 12.2,512 12.2,523.8 23.1,533.3 36.6,533.3L134.1,533.3Z"
|
||||
android:fillColor="@color/gray"/>
|
||||
<path
|
||||
android:pathData="M134.1,810.7C147.6,810.7 158.5,801.1 158.5,789.3 158.5,777.6 147.6,768 134.1,768L36.6,768C23.1,768 12.2,777.6 12.2,789.3 12.2,801.1 23.1,810.7 36.6,810.7L134.1,810.7Z"
|
||||
android:fillColor="@color/gray"/>
|
||||
<path
|
||||
android:pathData="M987.4,256C1000.9,256 1011.8,246.4 1011.8,234.7 1011.8,222.9 1000.9,213.3 987.4,213.3L280.4,213.3C266.9,213.3 256,222.9 256,234.7 256,246.4 266.9,256 280.4,256L987.4,256Z"
|
||||
android:fillColor="@color/gray"/>
|
||||
<path
|
||||
android:pathData="M993.5,533.3C1007,533.3 1017.9,523.8 1017.9,512 1017.9,500.2 1007,490.7 993.5,490.7L286.5,490.7C273,490.7 262.1,500.2 262.1,512 262.1,523.8 273,533.3 286.5,533.3L993.5,533.3Z"
|
||||
android:fillColor="@color/gray"/>
|
||||
<path
|
||||
android:pathData="M996.6,810.7C1010,810.7 1021,801.1 1021,789.3 1021,777.6 1010,768 996.6,768L289.5,768C276.1,768 265.1,777.6 265.1,789.3 265.1,801.1 276.1,810.7 289.5,810.7L996.6,810.7Z"
|
||||
android:fillColor="@color/gray"/>
|
||||
</vector>
|
||||
30
app/src/main/res/drawable/progress_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>
|
||||
9
app/src/main/res/drawable/rounded_rectangle_gradient.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="45"
|
||||
android:endColor="#006B8C"
|
||||
android:startColor="#8EE5EE"
|
||||
android:type="linear"
|
||||
android:useLevel="false" />
|
||||
<corners android:radius="16sp" />
|
||||
</shape>
|
||||
8
app/src/main/res/drawable/set_dialog_background.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/gray" />
|
||||
<corners android:radius="6dp" />
|
||||
</shape>
|
||||
9
app/src/main/res/drawable/un_favorite.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="@color/black"
|
||||
android:pathData="M780.2,97.5a73.1,73.1 0,0 1,73.1 73.1v755.8l-341.3,-152.4L170.7,926.5L170.7,170.7a73.1,73.1 0,0 1,73.1 -73.1h536.4zM780.2,170.7L243.8,170.7v643l268.2,-119.7 268.2,119.7L780.2,170.7z"/>
|
||||
</vector>
|
||||
12
app/src/main/res/drawable/un_like.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M512,923.8a96,96 0,0 1,-67.8 -27.8L144,595.7C32.9,484.4 28.6,302.6 134.8,190.4a288,288 0,0 1,413 -5.8L584,221a32,32 0,1 1,-45.3 45.3l-36.3,-36.3a222.2,222.2 0,0 0,-158.4 -65.6h-3.2a222.4,222.4 0,0 0,-160 70.2c-82.6,87.2 -78.9,229 8,316l300,300a32,32 0,0 0,45.3 0l300.2,-300.2a232.9,232.9 0,0 0,67.3 -164.8,219.4 219.4,0 0,0 -65.1,-157 223.4,223.4 0,0 0,-205.9 -58.8,32 32,0 1,1 -13.9,-62.5 287.1,287.1 0,0 1,264.7 75.7,283 283,0 0,1 84.2,202.4A297.3,297.3 0,0 1,880 595.6L579.9,896a96,96 0,0 1,-67.9 27.8z"
|
||||
android:fillColor="@color/gray"/>
|
||||
<path
|
||||
android:pathData="M640,292.3a32,32 0,1 0,32 32,32 32,0 0,0 -32,-32z"
|
||||
android:fillColor="@color/gray"/>
|
||||
</vector>
|
||||
24
app/src/main/res/drawable/un_main.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M134.1,256C147.6,256 158.5,246.4 158.5,234.7 158.5,222.9 147.6,213.3 134.1,213.3L36.6,213.3C23.1,213.3 12.2,222.9 12.2,234.7 12.2,246.4 23.1,256 36.6,256L134.1,256Z"
|
||||
android:fillColor="@color/black"/>
|
||||
<path
|
||||
android:pathData="M134.1,533.3C147.6,533.3 158.5,523.8 158.5,512 158.5,500.2 147.6,490.7 134.1,490.7L36.6,490.7C23.1,490.7 12.2,500.2 12.2,512 12.2,523.8 23.1,533.3 36.6,533.3L134.1,533.3Z"
|
||||
android:fillColor="@color/black"/>
|
||||
<path
|
||||
android:pathData="M134.1,810.7C147.6,810.7 158.5,801.1 158.5,789.3 158.5,777.6 147.6,768 134.1,768L36.6,768C23.1,768 12.2,777.6 12.2,789.3 12.2,801.1 23.1,810.7 36.6,810.7L134.1,810.7Z"
|
||||
android:fillColor="@color/black"/>
|
||||
<path
|
||||
android:pathData="M987.4,256C1000.9,256 1011.8,246.4 1011.8,234.7 1011.8,222.9 1000.9,213.3 987.4,213.3L280.4,213.3C266.9,213.3 256,222.9 256,234.7 256,246.4 266.9,256 280.4,256L987.4,256Z"
|
||||
android:fillColor="@color/black"/>
|
||||
<path
|
||||
android:pathData="M993.5,533.3C1007,533.3 1017.9,523.8 1017.9,512 1017.9,500.2 1007,490.7 993.5,490.7L286.5,490.7C273,490.7 262.1,500.2 262.1,512 262.1,523.8 273,533.3 286.5,533.3L993.5,533.3Z"
|
||||
android:fillColor="@color/black"/>
|
||||
<path
|
||||
android:pathData="M996.6,810.7C1010,810.7 1021,801.1 1021,789.3 1021,777.6 1010,768 996.6,768L289.5,768C276.1,768 265.1,777.6 265.1,789.3 265.1,801.1 276.1,810.7 289.5,810.7L996.6,810.7Z"
|
||||
android:fillColor="@color/black"/>
|
||||
</vector>
|
||||
89
app/src/main/res/layout/activity_detail.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<?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"
|
||||
tools:context=".activity.DetailActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:src="@drawable/back"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/like"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:src="@drawable/un_like"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/down_picture"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="32dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/set"
|
||||
app:layout_constraintEnd_toEndOf="@+id/set">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/down_progress"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:indeterminateTint="@color/black"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/download" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/set"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:src="@drawable/apply"
|
||||
app:layout_constraintBottom_toTopOf="@+id/like"
|
||||
app:layout_constraintEnd_toEndOf="@+id/like" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/gray"
|
||||
android:focusable="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
29
app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?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="@color/blue_black"
|
||||
tools:context=".activity.MainActivity">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/main_viewpager2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/main_tab_layout"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/main_tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="125dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:background="@android:color/transparent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:tabIndicatorHeight="0dp"
|
||||
app:tabRippleColor="@android:color/transparent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
42
app/src/main/res/layout/activity_sub_list.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?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="@color/blue_black"
|
||||
tools:context=".activity.SubListActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:src="@drawable/back"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/text" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp"
|
||||
android:text="@string/app_name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
48
app/src/main/res/layout/activity_welcome.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<?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"
|
||||
tools:context=".activity.WelcomeActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/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/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="25sp"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/image" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_marginStart="53dp"
|
||||
android:layout_marginEnd="53dp"
|
||||
android:layout_marginBottom="80dp"
|
||||
android:max="100"
|
||||
android:progress="0"
|
||||
android:progressDrawable="@drawable/progress_bar_color"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
98
app/src/main/res/layout/detail_dialog.xml
Normal file
@ -0,0 +1,98 @@
|
||||
<?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="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/rounded_rectangle_gradient">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/set_as_wallpaper"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/both"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="24dp"
|
||||
android:background="@drawable/set_dialog_background"
|
||||
android:padding="12dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="BOTH"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/lock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="24dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@drawable/set_dialog_background"
|
||||
android:padding="12dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/both">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lock_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="LOCK"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/desktop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="24dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@drawable/set_dialog_background"
|
||||
android:padding="12dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/lock">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="DESKTOP"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
31
app/src/main/res/layout/fragment_collection.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:context=".fragment.CollectionFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center"
|
||||
android:text="COLLECTION"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
31
app/src/main/res/layout/fragment_home.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?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"
|
||||
tools:context=".fragment.HomeFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:gravity="center"
|
||||
android:text="HOME"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
21
app/src/main/res/layout/item_cool.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="144dp"
|
||||
android:layout_height="256dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favorite"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:src="@drawable/un_like"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
25
app/src/main/res/layout/item_sublist.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
android:maxLines="2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
31
app/src/main/res/layout/tab_layout.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?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"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/text"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/image" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 982 B |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/placeholder.png
Normal file
|
After Width: | Height: | Size: 168 KiB |
7
app/src/main/res/values-night/themes.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.CoolWallpaper" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
</resources>
|
||||
7
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="gray">#9C979D</color>
|
||||
<color name="blue_black">#0D1B2A</color>
|
||||
</resources>
|
||||
2
app/src/main/res/values/refs.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources></resources>
|
||||
6
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<string name="app_name">Cool Wallpaper</string>
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
<string name="set_as_wallpaper">Set as Wallpaper</string>
|
||||
</resources>
|
||||
9
app/src/main/res/values/themes.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.CoolWallpaper" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.CoolWallpaper" parent="Base.Theme.CoolWallpaper" />
|
||||
</resources>
|
||||
13
app/src/main/res/xml/backup_rules.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample backup rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/guide/topics/data/autobackup
|
||||
for details.
|
||||
Note: This file is ignored for devices older that API 31
|
||||
See https://developer.android.com/about/versions/12/backup-restore
|
||||
-->
|
||||
<full-backup-content>
|
||||
<!--
|
||||
<include domain="sharedpref" path="."/>
|
||||
<exclude domain="sharedpref" path="device.xml"/>
|
||||
-->
|
||||
</full-backup-content>
|
||||
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Sample data extraction rules file; uncomment and customize as necessary.
|
||||
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||
for details.
|
||||
-->
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
-->
|
||||
</cloud-backup>
|
||||
<!--
|
||||
<device-transfer>
|
||||
<include .../>
|
||||
<exclude .../>
|
||||
</device-transfer>
|
||||
-->
|
||||
</data-extraction-rules>
|
||||
@ -0,0 +1,17 @@
|
||||
package com.wallpaper.coolwallpaper;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
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.8.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.2.1"
|
||||
espressoCore = "3.6.1"
|
||||
appcompat = "1.7.0"
|
||||
material = "1.12.0"
|
||||
activity = "1.10.0"
|
||||
constraintlayout = "2.2.0"
|
||||
|
||||
[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
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Fri Feb 21 18:22:41 CST 2025
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
185
gradlew
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or 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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# 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"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 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
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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"
|
||||
which java >/dev/null 2>&1 || 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
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
89
gradlew.bat
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
@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
|
||||
|
||||
@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=.
|
||||
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%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="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!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
24
settings.gradle.kts
Normal file
@ -0,0 +1,24 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "Cool Wallpaper"
|
||||
include(":app")
|
||||
|
||||