V1.0.0(1)完成版
This commit is contained in:
parent
287a9f0439
commit
ce257f913d
BIN
app/PaletteWallpaper.jks
Normal file
BIN
app/PaletteWallpaper.jks
Normal file
Binary file not shown.
@ -53,6 +53,4 @@ dependencies {
|
||||
|
||||
implementation ("androidx.room:room-runtime:2.7.0")
|
||||
annotationProcessor ("androidx.room:room-compiler:2.7.0")
|
||||
|
||||
implementation ("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
}
|
||||
14
app/proguard-rules.pro
vendored
14
app/proguard-rules.pro
vendored
@ -19,3 +19,17 @@
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
-keepclassmembers class com.wallpaper.palettewallpaper.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.palettewallpaper.local.database.AppDatabase { *; }
|
||||
-keep class com.wallpaper.palettewallpaper.local.database.data.PaletteData { *; }
|
||||
-keep class com.wallpaper.palettewallpaper.local.database.data.SubList { *; }
|
||||
-keep class com.wallpaper.palettewallpaper.local.database.dao.PaletteDataDao { *; }
|
||||
@ -4,13 +4,9 @@ import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.wallpaper.palettewallpaper.data.database.AppDatabase;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.SubList;
|
||||
import com.wallpaper.palettewallpaper.util.InsertAll;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.SubList;
|
||||
import com.wallpaper.palettewallpaper.util.InsertAllUtil;
|
||||
import com.wallpaper.palettewallpaper.util.JsonParse;
|
||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -18,9 +14,9 @@ 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";
|
||||
public static final String DB_NAME = "palette_database";
|
||||
private static final String PREFERENCES_NAME = "app_preferences";
|
||||
private static final String KEY_INIT = "init";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@ -28,11 +24,10 @@ public class MyApplication extends Application {
|
||||
|
||||
application = this;
|
||||
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
|
||||
boolean isDatabaseInitialized = sharedPreferences.getBoolean(KEY_INIT, false);
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_NAME, MODE_PRIVATE);
|
||||
|
||||
if (!isDatabaseInitialized) {
|
||||
initializeDatabase();
|
||||
if (!sharedPreferences.getBoolean(KEY_INIT, false)) {
|
||||
init();
|
||||
sharedPreferences.edit().putBoolean(KEY_INIT, true).apply();
|
||||
}
|
||||
|
||||
@ -42,15 +37,15 @@ public class MyApplication extends Application {
|
||||
return application.getApplicationContext();
|
||||
}
|
||||
|
||||
private void initializeDatabase() {
|
||||
private void init() {
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
List<SubList> subList = getCategoryList();
|
||||
InsertAll insertAll = new InsertAll(getContext());
|
||||
insertAll.insertAllImages(subList);
|
||||
List<SubList> subList = getSubList();
|
||||
InsertAllUtil insertAllUtil = new InsertAllUtil(getContext());
|
||||
insertAllUtil.insertAllImages(subList);
|
||||
});
|
||||
}
|
||||
|
||||
public static List<SubList> getCategoryList() {
|
||||
public static List<SubList> getSubList() {
|
||||
return JsonParse.parseJson("wallpapers.json");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
package com.wallpaper.palettewallpaper.data.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface PaletteDataDao {
|
||||
@Insert
|
||||
void insertAll(List<PaletteData> paletteData);
|
||||
|
||||
@Update
|
||||
void update(PaletteData paletteData);
|
||||
|
||||
@Query("SELECT * FROM PaletteData WHERE isLike = 1 ")
|
||||
LiveData<List<PaletteData>> getAllFavoriteLive();
|
||||
|
||||
@Query("SELECT * FROM PaletteData WHERE id IN (SELECT MIN(id) FROM PaletteData GROUP BY name)")
|
||||
LiveData<List<PaletteData>> getFirstRecordOfEachName();
|
||||
|
||||
@Query("SELECT * FROM PaletteData WHERE name = :name")
|
||||
LiveData<List<PaletteData>> getAllCategoryLive(String name);
|
||||
|
||||
@Query("SELECT isLIKE FROM PaletteData WHERE source = :source AND name = :name")
|
||||
LiveData<Boolean> getWallpaperLike(String source, String name);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.wallpaper.palettewallpaper.data.database;
|
||||
package com.wallpaper.palettewallpaper.local.database;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@ -7,8 +7,8 @@ import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.wallpaper.palettewallpaper.MyApplication;
|
||||
import com.wallpaper.palettewallpaper.data.database.dao.PaletteDataDao;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.local.database.dao.PaletteDataDao;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
|
||||
@Database(entities = {PaletteData.class}, version = MyApplication.DB_VERSION, exportSchema = false)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
@ -0,0 +1,32 @@
|
||||
package com.wallpaper.palettewallpaper.local.database.dao;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface PaletteDataDao {
|
||||
@Insert
|
||||
void insertAll(List<PaletteData> paletteData);
|
||||
|
||||
@Update
|
||||
void update(PaletteData paletteData);
|
||||
|
||||
@Query("SELECT * FROM PaletteData WHERE isLike = 1 ")
|
||||
LiveData<List<PaletteData>> getAllFavorite();
|
||||
|
||||
@Query("SELECT * FROM PaletteData WHERE id IN (SELECT MAX(id) FROM PaletteData GROUP BY name) ORDER BY id ASC")
|
||||
LiveData<List<PaletteData>> getFirstByName();
|
||||
|
||||
@Query("SELECT * FROM PaletteData WHERE name = :name ORDER BY id DESC")
|
||||
LiveData<List<PaletteData>> getAllCategory(String name);
|
||||
|
||||
@Query("SELECT isLIKE FROM PaletteData WHERE source = :source AND name = :name")
|
||||
LiveData<Boolean> getLike(String source, String name);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.wallpaper.palettewallpaper.data.database.entiey;
|
||||
package com.wallpaper.palettewallpaper.local.database.data;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
@ -1,4 +1,4 @@
|
||||
package com.wallpaper.palettewallpaper.data.database.entiey;
|
||||
package com.wallpaper.palettewallpaper.local.database.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -2,6 +2,7 @@ package com.wallpaper.palettewallpaper.ui.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@ -14,101 +15,83 @@ import com.google.android.material.tabs.TabLayout;
|
||||
import com.google.android.material.tabs.TabLayoutMediator;
|
||||
import com.wallpaper.palettewallpaper.R;
|
||||
import com.wallpaper.palettewallpaper.databinding.ActivityMainBinding;
|
||||
import com.wallpaper.palettewallpaper.databinding.TabLayoutBinding;
|
||||
import com.wallpaper.palettewallpaper.databinding.CustomTabBinding;
|
||||
import com.wallpaper.palettewallpaper.ui.adapter.MainViewpager2Adapter;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
private ActivityMainBinding binding;
|
||||
private ActivityMainBinding ui;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
ui = ActivityMainBinding.inflate(getLayoutInflater());
|
||||
setContentView(ui.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);
|
||||
handleInsets();
|
||||
setupViewPagerAndTabs();
|
||||
}
|
||||
|
||||
private void handleInsets() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (view, insets) -> {
|
||||
Insets bars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
view.setPadding(bars.left, bars.top, bars.right, bars.bottom);
|
||||
return insets;
|
||||
});
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
MainViewpager2Adapter adapter = new MainViewpager2Adapter(this);
|
||||
binding.mainViewpager2.setAdapter(adapter);
|
||||
}
|
||||
private void setupViewPagerAndTabs() {
|
||||
ui.viewPager.setAdapter(new MainViewpager2Adapter(this));
|
||||
|
||||
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);
|
||||
new TabLayoutMediator(ui.tabLayout, ui.viewPager, (tab, index) -> {
|
||||
CustomTabBinding customTabBinding = CustomTabBinding.inflate(LayoutInflater.from(this));
|
||||
tab.setCustomView(customTabBinding.getRoot());
|
||||
initializeTab(customTabBinding, index);
|
||||
}).attach();
|
||||
|
||||
binding.mainTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
ui.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
updateTab(tab, true);
|
||||
applyTabStyle(tab, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
updateTab(tab, false);
|
||||
applyTabStyle(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.black;
|
||||
|
||||
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 void initializeTab(CustomTabBinding binding, int pos) {
|
||||
binding.text.setText(pos == 0 ? "Home" : "Favorite");
|
||||
binding.image.setImageResource(getIconFor(pos, false, 1));
|
||||
binding.text.setTextColor(ContextCompat.getColor(this, pos == 0 ? R.color.black : R.color.gray));
|
||||
}
|
||||
|
||||
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;
|
||||
private void applyTabStyle(TabLayout.Tab tab, boolean selected) {
|
||||
View view = tab.getCustomView();
|
||||
if (view == null) return;
|
||||
|
||||
CustomTabBinding binding = CustomTabBinding.bind(view);
|
||||
int pos = tab.getPosition();
|
||||
|
||||
binding.image.setImageResource(getIconFor(pos, selected, 0));
|
||||
binding.text.setTextColor(ContextCompat.getColor(this, selected ? R.color.black : R.color.gray));
|
||||
}
|
||||
|
||||
private int getIconFor(int pos, boolean selected, int i) {
|
||||
if (pos == 0 && i == 1) return R.drawable.main;
|
||||
if (pos == 1) return selected ? R.drawable.favorite : R.drawable.un_favorite;
|
||||
return selected ? R.drawable.main : R.drawable.un_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
binding = null;
|
||||
ui = null;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
package com.wallpaper.palettewallpaper.ui.activity;
|
||||
|
||||
import static com.wallpaper.palettewallpaper.util.SetAndDownloadUtils.REQUEST_CODE_WRITE_EXTERNAL_STORAGE;
|
||||
import static com.wallpaper.palettewallpaper.util.WallpaperHelper.PERMISSION_CODE_WRITE;
|
||||
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.pm.PackageManager;
|
||||
@ -19,8 +19,6 @@ import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
@ -28,251 +26,244 @@ import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.wallpaper.palettewallpaper.R;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.databinding.ActivityPaletteBinding;
|
||||
import com.wallpaper.palettewallpaper.util.DownloadCallback;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
||||
import com.wallpaper.palettewallpaper.util.SetAndDownloadUtils;
|
||||
import com.wallpaper.palettewallpaper.util.WallpaperDownloadListener;
|
||||
import com.wallpaper.palettewallpaper.util.WallpaperHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class PaletteActivity extends AppCompatActivity implements DownloadCallback {
|
||||
private ActivityPaletteBinding binding;
|
||||
private String original;
|
||||
private String source;
|
||||
public class PaletteActivity extends AppCompatActivity implements WallpaperDownloadListener {
|
||||
private ActivityPaletteBinding viewBinding;
|
||||
private String baseImageUrl;
|
||||
private String imageSource;
|
||||
private PaletteData paletteData;
|
||||
private PaletteViewModel paletteViewModel;
|
||||
private String name;
|
||||
private Bitmap bitmap;
|
||||
private SetAndDownloadUtils setAndDownloadUtils;
|
||||
private ExecutorService executorService;
|
||||
private Handler handler;
|
||||
private PaletteViewModel viewModel;
|
||||
private String title;
|
||||
private Bitmap imageBitmap;
|
||||
private WallpaperHelper wallpaperUtility;
|
||||
private ExecutorService backgroundExecutor;
|
||||
private Handler uiHandler;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
EdgeToEdge.enable(this);
|
||||
binding = ActivityPaletteBinding.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;
|
||||
});
|
||||
viewBinding = ActivityPaletteBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
setupInitialData();
|
||||
configureInteractions();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
paletteData = (PaletteData) getIntent().getSerializableExtra("cool");
|
||||
if (paletteData != null) {
|
||||
original = paletteData.getOriginal();
|
||||
source = paletteData.getSource();
|
||||
name = paletteData.getName();
|
||||
} else {
|
||||
Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
|
||||
private void setupInitialData() {
|
||||
paletteData = (PaletteData) getIntent().getSerializableExtra("palette");
|
||||
if (paletteData == null) {
|
||||
Toast.makeText(this, "Data error", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
setAndDownloadUtils = new SetAndDownloadUtils();
|
||||
baseImageUrl = paletteData.getOriginal();
|
||||
imageSource = paletteData.getSource();
|
||||
title = paletteData.getName();
|
||||
|
||||
paletteViewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||
|
||||
handler = new Handler(Looper.getMainLooper());
|
||||
executorService = Executors.newSingleThreadExecutor();
|
||||
wallpaperUtility = new WallpaperHelper();
|
||||
viewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||
|
||||
uiHandler = new Handler(Looper.getMainLooper());
|
||||
backgroundExecutor = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
showProgress();
|
||||
private void configureInteractions() {
|
||||
displayLoadingIndicator();
|
||||
|
||||
binding.back.setOnClickListener(v -> finish());
|
||||
viewBinding.back.setOnClickListener(v -> finish());
|
||||
|
||||
binding.like.setOnClickListener(v -> {
|
||||
boolean newStatus = !paletteData.getLike();
|
||||
paletteData.setLike(newStatus);
|
||||
executorService.submit(() -> paletteViewModel.update(paletteData));
|
||||
viewBinding.like.setOnClickListener(v -> {
|
||||
boolean updatedStatus = !paletteData.getLike();
|
||||
paletteData.setLike(updatedStatus);
|
||||
backgroundExecutor.submit(() -> viewModel.update(paletteData));
|
||||
});
|
||||
|
||||
binding.set.setOnClickListener(v -> showCustomBottomSheet());
|
||||
viewBinding.set.setOnClickListener(v -> showOptionDialog());
|
||||
|
||||
binding.down.setOnClickListener(v -> {
|
||||
showProgress();
|
||||
setAndDownloadUtils.setAsWallpaper(PaletteActivity.this, source, PaletteActivity.this);
|
||||
viewBinding.down.setOnClickListener(v -> {
|
||||
displayLoadingIndicator();
|
||||
wallpaperUtility.applyWallpaper(this, imageSource, this);
|
||||
});
|
||||
|
||||
loadImage();
|
||||
loadFavorite();
|
||||
fetchImage();
|
||||
monitorFavoriteStatus();
|
||||
}
|
||||
|
||||
@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 (requestCode == PERMISSION_CODE_WRITE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
setAndDownloadUtils.setAsWallpaper(this, source, this);
|
||||
wallpaperUtility.applyWallpaper(this, imageSource, this);
|
||||
} else {
|
||||
Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, "Access denied", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showCustomBottomSheet() {
|
||||
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
|
||||
View bottomSheetView = LayoutInflater.from(this).inflate(R.layout.detail_dialog, null);
|
||||
private void showOptionDialog() {
|
||||
BottomSheetDialog dialog = new BottomSheetDialog(this);
|
||||
View dialogView = LayoutInflater.from(this).inflate(R.layout.detail_dialog, null);
|
||||
|
||||
bottomSheetView.findViewById(R.id.both).setOnClickListener(v -> {
|
||||
disableButtons(bottomSheetView);
|
||||
applyWallpaper(bitmap, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK, bottomSheetDialog);
|
||||
bottomSheetDialog.dismiss();
|
||||
dialogView.findViewById(R.id.both).setOnClickListener(v -> {
|
||||
disableOptions(dialogView);
|
||||
setWallpaper(imageBitmap, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK, dialog);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
bottomSheetView.findViewById(R.id.lock).setOnClickListener(v -> {
|
||||
disableButtons(bottomSheetView);
|
||||
applyWallpaper(bitmap, WallpaperManager.FLAG_LOCK, bottomSheetDialog);
|
||||
bottomSheetDialog.dismiss();
|
||||
dialogView.findViewById(R.id.lock).setOnClickListener(v -> {
|
||||
disableOptions(dialogView);
|
||||
setWallpaper(imageBitmap, WallpaperManager.FLAG_LOCK, dialog);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
bottomSheetView.findViewById(R.id.desktop).setOnClickListener(v -> {
|
||||
disableButtons(bottomSheetView);
|
||||
applyWallpaper(bitmap, WallpaperManager.FLAG_SYSTEM, bottomSheetDialog);
|
||||
bottomSheetDialog.dismiss();
|
||||
dialogView.findViewById(R.id.desktop).setOnClickListener(v -> {
|
||||
disableOptions(dialogView);
|
||||
setWallpaper(imageBitmap, WallpaperManager.FLAG_SYSTEM, dialog);
|
||||
dialog.dismiss();
|
||||
});
|
||||
|
||||
bottomSheetDialog.setContentView(bottomSheetView);
|
||||
bottomSheetDialog.show();
|
||||
dialog.setContentView(dialogView);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void disableButtons(View bottomSheetView) {
|
||||
bottomSheetView.findViewById(R.id.both).setEnabled(false);
|
||||
bottomSheetView.findViewById(R.id.lock).setEnabled(false);
|
||||
bottomSheetView.findViewById(R.id.desktop).setEnabled(false);
|
||||
private void disableOptions(View dialogView) {
|
||||
dialogView.findViewById(R.id.both).setEnabled(false);
|
||||
dialogView.findViewById(R.id.lock).setEnabled(false);
|
||||
dialogView.findViewById(R.id.desktop).setEnabled(false);
|
||||
}
|
||||
|
||||
private void applyWallpaper(Bitmap bitmap, int flag, BottomSheetDialog bottomSheetDialog) {
|
||||
showProgress();
|
||||
private void setWallpaper(Bitmap bitmap, int flags, BottomSheetDialog dialog) {
|
||||
displayLoadingIndicator();
|
||||
|
||||
executorService.submit(() -> {
|
||||
boolean success = false;
|
||||
backgroundExecutor.submit(() -> {
|
||||
boolean result = false;
|
||||
try {
|
||||
success = setWallpaperImage(bitmap, flag);
|
||||
result = applyWallpaper(bitmap, flags);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
boolean finalSuccess = success;
|
||||
handler.post(() -> {
|
||||
hideProgress();
|
||||
bottomSheetDialog.findViewById(R.id.both).setEnabled(true);
|
||||
bottomSheetDialog.findViewById(R.id.lock).setEnabled(true);
|
||||
bottomSheetDialog.findViewById(R.id.desktop).setEnabled(true);
|
||||
boolean finalResult = result;
|
||||
uiHandler.post(() -> {
|
||||
hideLoadingIndicator();
|
||||
dialog.findViewById(R.id.both).setEnabled(true);
|
||||
dialog.findViewById(R.id.lock).setEnabled(true);
|
||||
dialog.findViewById(R.id.desktop).setEnabled(true);
|
||||
|
||||
String message = finalSuccess ? "Wallpaper set successfully" : "Failed to set wallpaper";
|
||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
||||
String message = finalResult ? "Success" : "Failed";
|
||||
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean setWallpaperImage(Bitmap bitmap, int flag) {
|
||||
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
|
||||
private boolean applyWallpaper(Bitmap bitmap, int flags) {
|
||||
WallpaperManager wallpaperMgr = WallpaperManager.getInstance(this);
|
||||
try {
|
||||
binding.imageView.setDrawingCacheEnabled(true);
|
||||
viewBinding.imageView.setDrawingCacheEnabled(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
wallpaperManager.setBitmap(bitmap, null, true, flag);
|
||||
wallpaperMgr.setBitmap(bitmap, null, true, flags);
|
||||
} else {
|
||||
wallpaperManager.setBitmap(bitmap);
|
||||
wallpaperMgr.setBitmap(bitmap);
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
binding.imageView.setDrawingCacheEnabled(false);
|
||||
viewBinding.imageView.setDrawingCacheEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void loadImage() {
|
||||
private void fetchImage() {
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(original)
|
||||
.load(baseImageUrl)
|
||||
.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();
|
||||
viewBinding.imageView.setImageBitmap(resource);
|
||||
imageBitmap = resource;
|
||||
hideLoadingIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(Drawable placeholder) {
|
||||
binding.imageView.setImageDrawable(placeholder != null ? placeholder : getDefaultPlaceholder());
|
||||
viewBinding.imageView.setImageDrawable(placeholder != null ? placeholder : getDefaultImage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(Drawable errorDrawable) {
|
||||
binding.imageView.setImageDrawable(errorDrawable != null ? errorDrawable : getDefaultPlaceholder());
|
||||
hideProgress();
|
||||
viewBinding.imageView.setImageDrawable(errorDrawable != null ? errorDrawable : getDefaultImage());
|
||||
hideLoadingIndicator();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Drawable getDefaultPlaceholder() {
|
||||
private Drawable getDefaultImage() {
|
||||
return ContextCompat.getDrawable(this, R.mipmap.placeholder);
|
||||
}
|
||||
|
||||
private void loadFavorite() {
|
||||
paletteViewModel.getWallpaperLike(source, name).observe(this, wallpaper -> setFavoriteButton());
|
||||
private void monitorFavoriteStatus() {
|
||||
viewModel.getLike(imageSource, title).observe(this, wallpaper -> updateFavoriteIcon());
|
||||
}
|
||||
|
||||
private void setFavoriteButton() {
|
||||
binding.like.setImageResource(
|
||||
private void updateFavoriteIcon() {
|
||||
viewBinding.like.setImageResource(
|
||||
paletteData.getLike() ? R.drawable.like : R.drawable.un_like
|
||||
);
|
||||
}
|
||||
|
||||
private void hideProgress() {
|
||||
if (binding != null) {
|
||||
binding.progressBar.setVisibility(View.GONE);
|
||||
binding.view.setVisibility(View.GONE);
|
||||
private void hideLoadingIndicator() {
|
||||
if (viewBinding != null) {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
viewBinding.view.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void showProgress() {
|
||||
binding.progressBar.setVisibility(View.VISIBLE);
|
||||
binding.view.setVisibility(View.VISIBLE);
|
||||
private void displayLoadingIndicator() {
|
||||
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||
viewBinding.view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadStart() {
|
||||
showProgress();
|
||||
public void onPrepare() {
|
||||
displayLoadingIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadComplete(Uri uri) {
|
||||
hideProgress();
|
||||
public void onSuccess(Uri uri) {
|
||||
hideLoadingIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadFailed() {
|
||||
hideProgress();
|
||||
public void onError() {
|
||||
hideLoadingIndicator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
if (uiHandler != null) {
|
||||
uiHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (executorService != null) {
|
||||
executorService.shutdown();
|
||||
if (backgroundExecutor != null) {
|
||||
backgroundExecutor.shutdown();
|
||||
}
|
||||
binding = null;
|
||||
viewBinding = null;
|
||||
}
|
||||
}
|
||||
@ -8,80 +8,79 @@ 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.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.wallpaper.palettewallpaper.R;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.databinding.ActivitySecondBinding;
|
||||
import com.wallpaper.palettewallpaper.ui.adapter.SecondAdapter;
|
||||
import com.wallpaper.palettewallpaper.ui.adapter.ArtAdapter;
|
||||
import com.wallpaper.palettewallpaper.ui.adapter.GalleryAdapter;
|
||||
import com.wallpaper.palettewallpaper.util.ItemDecoration;
|
||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SecondActivity extends AppCompatActivity {
|
||||
private ActivitySecondBinding binding;
|
||||
private SecondAdapter secondAdapter;
|
||||
private PaletteViewModel paletteViewModel;
|
||||
private String name;
|
||||
private ActivitySecondBinding ui;
|
||||
private ArtAdapter adapter;
|
||||
private PaletteViewModel viewModel;
|
||||
private String categoryName;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
EdgeToEdge.enable(this);
|
||||
binding = ActivitySecondBinding.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;
|
||||
});
|
||||
ui = ActivitySecondBinding.inflate(getLayoutInflater());
|
||||
setContentView(ui.getRoot());
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
applyInsets();
|
||||
initialize();
|
||||
setupListeners();
|
||||
observeCategoryData();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
name = getIntent().getStringExtra("name");
|
||||
if (name == null) {
|
||||
Toast.makeText(this, "The picture does not exist", Toast.LENGTH_SHORT).show();
|
||||
private void applyInsets() {
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (view, insets) -> {
|
||||
Insets sysBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||
view.setPadding(sysBars.left, sysBars.top, sysBars.right, sysBars.bottom);
|
||||
return insets;
|
||||
});
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
categoryName = getIntent().getStringExtra("name");
|
||||
if (categoryName == null) {
|
||||
Toast.makeText(this, "No data available", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
paletteViewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||
viewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||
|
||||
binding.recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
secondAdapter = new SecondAdapter(this, new ArrayList<>());
|
||||
binding.recyclerView.setAdapter(secondAdapter);
|
||||
|
||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
||||
binding.recyclerView.addItemDecoration(itemDecoration);
|
||||
adapter = new ArtAdapter(this, new ArrayList<>());
|
||||
ui.recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
ui.recyclerView.setAdapter(adapter);
|
||||
ui.recyclerView.addItemDecoration(new ItemDecoration(25, 15, 10));
|
||||
|
||||
ui.title.setText(categoryName);
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
|
||||
binding.back.setOnClickListener(v -> finish());
|
||||
binding.text.setText(name);
|
||||
|
||||
loadImage();
|
||||
private void setupListeners() {
|
||||
ui.back.setOnClickListener(view -> finish());
|
||||
}
|
||||
|
||||
private void loadImage() {
|
||||
paletteViewModel
|
||||
.getAllCategory(name)
|
||||
.observe(this, new Observer<List<PaletteData>>() {
|
||||
@Override
|
||||
public void onChanged(List<PaletteData> coolEntities) {
|
||||
secondAdapter.updateData(coolEntities);
|
||||
}
|
||||
});
|
||||
private void observeCategoryData() {
|
||||
viewModel.getAllCategory(categoryName).observe(this, paletteList -> {
|
||||
if (paletteList != null) {
|
||||
adapter.replaceData(paletteList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
ui = null;
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.wallpaper.palettewallpaper.R;
|
||||
import com.wallpaper.palettewallpaper.databinding.ActivitySplashBinding;
|
||||
@ -36,10 +37,10 @@ public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
Glide.with(this)
|
||||
.load(R.mipmap.placeholder)
|
||||
.transform(new RoundedCorners(16))
|
||||
.transform(new CenterCrop(), new RoundedCorners(32))
|
||||
.into(binding.image);
|
||||
|
||||
countDownTimer = new CountDownTimer(TOTAL_TIME,100) {
|
||||
countDownTimer = new CountDownTimer(TOTAL_TIME, 100) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
int percentage = (int) (100 - (float) millisUntilFinished / TOTAL_TIME * 100);
|
||||
|
||||
@ -0,0 +1,115 @@
|
||||
package com.wallpaper.palettewallpaper.ui.adapter;
|
||||
|
||||
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.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.wallpaper.palettewallpaper.R;
|
||||
import com.wallpaper.palettewallpaper.local.database.AppDatabase;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.ui.activity.PaletteActivity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class ArtAdapter extends RecyclerView.Adapter<ArtAdapter.ArtHolder> {
|
||||
private final List<PaletteData> artList;
|
||||
private final Context context;
|
||||
private final Executor dbExecutor = Executors.newSingleThreadExecutor();
|
||||
|
||||
public ArtAdapter(Context context, List<PaletteData> initialList) {
|
||||
this.context = context;
|
||||
this.artList = initialList;
|
||||
}
|
||||
|
||||
public void replaceData(List<PaletteData> newList) {
|
||||
artList.clear();
|
||||
artList.addAll(newList);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ArtHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View itemView = LayoutInflater.from(context).inflate(R.layout.item_palette, parent, false);
|
||||
return new ArtHolder(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ArtHolder holder, int position) {
|
||||
holder.loadContent(artList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return artList.size();
|
||||
}
|
||||
|
||||
class ArtHolder extends RecyclerView.ViewHolder {
|
||||
private final ImageView imageDisplay;
|
||||
private final ImageView likeToggle;
|
||||
|
||||
ArtHolder(View itemView) {
|
||||
super(itemView);
|
||||
imageDisplay = itemView.findViewById(R.id.image_view);
|
||||
likeToggle = itemView.findViewById(R.id.favorite);
|
||||
}
|
||||
|
||||
void loadContent(PaletteData item) {
|
||||
displayArtwork(item.getOriginal());
|
||||
setLikeStatus(item);
|
||||
setInteractionListeners(item);
|
||||
}
|
||||
|
||||
private void displayArtwork(String imageUrl) {
|
||||
Glide.with(imageDisplay.getContext())
|
||||
.load(imageUrl)
|
||||
.dontAnimate()
|
||||
.transform(new CenterCrop(), new RoundedCorners(30))
|
||||
.placeholder(R.mipmap.placeholder)
|
||||
.error(R.mipmap.placeholder)
|
||||
.into(imageDisplay);
|
||||
}
|
||||
|
||||
private void setLikeStatus(PaletteData item) {
|
||||
int icon = item.getLike() ? R.drawable.like : R.drawable.un_like;
|
||||
likeToggle.setImageResource(icon);
|
||||
}
|
||||
|
||||
private void setInteractionListeners(PaletteData item) {
|
||||
imageDisplay.setOnClickListener(view -> {
|
||||
Intent openDetail = new Intent(view.getContext(), PaletteActivity.class);
|
||||
openDetail.putExtra("palette", item);
|
||||
view.getContext().startActivity(openDetail);
|
||||
});
|
||||
|
||||
likeToggle.setOnClickListener(v -> toggleFavorite(item));
|
||||
}
|
||||
|
||||
private void toggleFavorite(PaletteData item) {
|
||||
item.setLike(!item.getLike());
|
||||
likeToggle.setImageResource(item.getLike() ? R.drawable.like : R.drawable.un_like);
|
||||
notifyItemChanged(getAdapterPosition());
|
||||
saveToDatabase(item);
|
||||
}
|
||||
|
||||
private void saveToDatabase(PaletteData item) {
|
||||
dbExecutor.execute(() -> {
|
||||
AppDatabase
|
||||
.getInstance(context.getApplicationContext())
|
||||
.paletteDataDao()
|
||||
.update(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
package com.wallpaper.palettewallpaper.ui.adapter;
|
||||
|
||||
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.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.wallpaper.palettewallpaper.R;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.ui.activity.SecondActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.GalleryViewHolder> {
|
||||
private List<PaletteData> dataList;
|
||||
private final Context context;
|
||||
|
||||
public GalleryAdapter(Context context, List<PaletteData> initialList) {
|
||||
this.context = context;
|
||||
this.dataList = initialList;
|
||||
}
|
||||
|
||||
public void refreshData(List<PaletteData> updatedList) {
|
||||
this.dataList = updatedList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public GalleryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View itemView = LayoutInflater.from(context).inflate(R.layout.item_second, parent, false);
|
||||
return new GalleryViewHolder(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull GalleryViewHolder holder, int position) {
|
||||
holder.populateWith(dataList.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return dataList.size();
|
||||
}
|
||||
|
||||
static class GalleryViewHolder extends RecyclerView.ViewHolder {
|
||||
private final ImageView thumbnail;
|
||||
private final TextView label;
|
||||
|
||||
GalleryViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
thumbnail = itemView.findViewById(R.id.imageview);
|
||||
label = itemView.findViewById(R.id.category_title);
|
||||
}
|
||||
|
||||
void populateWith(PaletteData entry) {
|
||||
label.setText(entry.getName());
|
||||
loadImage(entry.getOriginal());
|
||||
attachClickListener(entry.getName());
|
||||
}
|
||||
|
||||
private void loadImage(String url) {
|
||||
Glide.with(thumbnail.getContext())
|
||||
.load(url)
|
||||
.thumbnail(0.1f)
|
||||
.transform(new CenterCrop(), new RoundedCorners(28))
|
||||
.placeholder(R.mipmap.placeholder)
|
||||
.error(R.mipmap.placeholder)
|
||||
.into(thumbnail);
|
||||
}
|
||||
|
||||
private void attachClickListener(String categoryName) {
|
||||
thumbnail.setOnClickListener(view -> {
|
||||
Intent jumpIntent = new Intent(view.getContext(), SecondActivity.class);
|
||||
jumpIntent.putExtra("name", categoryName);
|
||||
view.getContext().startActivity(jumpIntent);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||
|
||||
import com.wallpaper.palettewallpaper.ui.fragment.CollectionFragment;
|
||||
import com.wallpaper.palettewallpaper.ui.fragment.FavoriteFragment;
|
||||
import com.wallpaper.palettewallpaper.ui.fragment.HomeFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -18,7 +18,7 @@ public class MainViewpager2Adapter extends FragmentStateAdapter {
|
||||
public MainViewpager2Adapter(@NonNull FragmentActivity fragmentActivity) {
|
||||
super(fragmentActivity);
|
||||
fragmentList.add(new HomeFragment());
|
||||
fragmentList.add(new CollectionFragment());
|
||||
fragmentList.add(new FavoriteFragment());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@ -1,90 +0,0 @@
|
||||
package com.wallpaper.palettewallpaper.ui.adapter;
|
||||
|
||||
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.palettewallpaper.R;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.ui.activity.SecondActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PaletteAdapter extends RecyclerView.Adapter<PaletteAdapter.ViewHolder> {
|
||||
private List<PaletteData> categoryList;
|
||||
private final Context context;
|
||||
|
||||
public PaletteAdapter(Context context, List<PaletteData> categoryList) {
|
||||
this.context = context;
|
||||
this.categoryList = categoryList;
|
||||
}
|
||||
|
||||
public void updateData(List<PaletteData> 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) {
|
||||
PaletteData paletteData = categoryList.get(position);
|
||||
holder.bindItemData(paletteData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return categoryList.size();
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private final ImageView itemImage;
|
||||
private final TextView itemTitle;
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
itemImage = view.findViewById(R.id.imageview);
|
||||
itemTitle = view.findViewById(R.id.category_title);
|
||||
}
|
||||
|
||||
void bindItemData(PaletteData paletteData) {
|
||||
String imageUrl = paletteData.getOriginal();
|
||||
|
||||
itemTitle.setText(paletteData.getName());
|
||||
loadImageFromUrl(imageUrl);
|
||||
setItemClickListener(paletteData);
|
||||
}
|
||||
|
||||
private void loadImageFromUrl(String imageUrl) {
|
||||
Glide.with(itemImage.getContext())
|
||||
.load(imageUrl)
|
||||
.transform(new RoundedCorners(32))
|
||||
.error(R.mipmap.placeholder)
|
||||
.placeholder(R.mipmap.placeholder)
|
||||
.into(itemImage);
|
||||
}
|
||||
|
||||
private void setItemClickListener(final PaletteData paletteData) {
|
||||
itemImage.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(v.getContext(), SecondActivity.class);
|
||||
intent.putExtra("name", paletteData.getName());
|
||||
v.getContext().startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,117 +0,0 @@
|
||||
package com.wallpaper.palettewallpaper.ui.adapter;
|
||||
|
||||
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.palettewallpaper.R;
|
||||
import com.wallpaper.palettewallpaper.data.database.AppDatabase;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.ui.activity.PaletteActivity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class SecondAdapter extends RecyclerView.Adapter<SecondAdapter.ViewHolder> {
|
||||
private List<PaletteData> coolEntities;
|
||||
private final Context context;
|
||||
private final Executor executor = Executors.newSingleThreadExecutor();
|
||||
|
||||
public SecondAdapter(Context context, List<PaletteData> coolEntities) {
|
||||
this.context = context;
|
||||
this.coolEntities = coolEntities;
|
||||
}
|
||||
|
||||
public void updateData(List<PaletteData> 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) {
|
||||
PaletteData paletteData = coolEntities.get(position);
|
||||
holder.bindData(paletteData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return coolEntities.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private final ImageView itemImageView;
|
||||
private final ImageView likeButton;
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
itemImageView = view.findViewById(R.id.image_view);
|
||||
likeButton = view.findViewById(R.id.favorite);
|
||||
}
|
||||
|
||||
void bindData(PaletteData paletteData) {
|
||||
String imageUrl = paletteData.getOriginal();
|
||||
|
||||
displayImage(imageUrl);
|
||||
updateFavoriteButton(paletteData);
|
||||
setupItemClickListeners(paletteData);
|
||||
}
|
||||
|
||||
private void displayImage(String imageUrl) {
|
||||
Glide.with(itemImageView.getContext())
|
||||
.load(imageUrl)
|
||||
.transform(new RoundedCorners(32))
|
||||
.error(R.mipmap.placeholder)
|
||||
.placeholder(R.mipmap.placeholder)
|
||||
.into(itemImageView);
|
||||
}
|
||||
|
||||
private void updateFavoriteButton(PaletteData paletteData) {
|
||||
likeButton.setImageResource(paletteData.getLike()
|
||||
? R.drawable.like
|
||||
: R.drawable.un_like);
|
||||
}
|
||||
|
||||
private void setupItemClickListeners(PaletteData paletteData) {
|
||||
itemImageView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(v.getContext(), PaletteActivity.class);
|
||||
intent.putExtra("cool", paletteData);
|
||||
v.getContext().startActivity(intent);
|
||||
});
|
||||
|
||||
likeButton.setOnClickListener(v -> handleFavoriteToggle(paletteData));
|
||||
}
|
||||
|
||||
private void handleFavoriteToggle(PaletteData paletteData) {
|
||||
boolean updatedStatus = !paletteData.getLike();
|
||||
paletteData.setLike(updatedStatus);
|
||||
|
||||
saveImageDataToDatabase(paletteData);
|
||||
notifyItemChanged(getAdapterPosition());
|
||||
}
|
||||
|
||||
private void saveImageDataToDatabase(PaletteData paletteData) {
|
||||
executor.execute(() -> {
|
||||
AppDatabase.getInstance(itemImageView.getContext())
|
||||
.paletteDataDao()
|
||||
.update(paletteData);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,72 +0,0 @@
|
||||
package com.wallpaper.palettewallpaper.ui.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.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.databinding.FragmentCollectionBinding;
|
||||
import com.wallpaper.palettewallpaper.ui.adapter.SecondAdapter;
|
||||
import com.wallpaper.palettewallpaper.util.ItemDecoration;
|
||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CollectionFragment extends Fragment {
|
||||
|
||||
private FragmentCollectionBinding fragmentCollectionBinding;
|
||||
private SecondAdapter secondAdapter;
|
||||
private PaletteViewModel paletteViewModel;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
fragmentCollectionBinding = FragmentCollectionBinding.inflate(inflater, container, false);
|
||||
|
||||
initData();
|
||||
initEvent();
|
||||
return fragmentCollectionBinding.getRoot();
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
paletteViewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||
|
||||
fragmentCollectionBinding.recyclerView.setLayoutManager(new GridLayoutManager(getContext(),2));
|
||||
|
||||
secondAdapter = new SecondAdapter(requireContext(), new ArrayList<>());
|
||||
fragmentCollectionBinding.recyclerView.setAdapter(secondAdapter);
|
||||
|
||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
||||
fragmentCollectionBinding.recyclerView.addItemDecoration(itemDecoration);
|
||||
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
loadAllList();
|
||||
}
|
||||
|
||||
private void loadAllList() {
|
||||
paletteViewModel
|
||||
.getAllFavoriteList()
|
||||
.observe(getViewLifecycleOwner(), new Observer<List<PaletteData>>() {
|
||||
@Override
|
||||
public void onChanged(List<PaletteData> coolEntities) {
|
||||
secondAdapter.updateData(coolEntities);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
fragmentCollectionBinding = null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package com.wallpaper.palettewallpaper.ui.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.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.wallpaper.palettewallpaper.databinding.FragmentFavoriteBinding;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.ui.adapter.ArtAdapter;
|
||||
import com.wallpaper.palettewallpaper.util.ItemDecoration;
|
||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FavoriteFragment extends Fragment {
|
||||
private FragmentFavoriteBinding binding;
|
||||
private ArtAdapter artAdapter;
|
||||
private PaletteViewModel paletteViewModel;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
binding = FragmentFavoriteBinding.inflate(inflater, container, false);
|
||||
|
||||
initializeData();
|
||||
setupListeners();
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
private void initializeData() {
|
||||
paletteViewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||
|
||||
binding.recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
|
||||
|
||||
artAdapter = new ArtAdapter(requireContext(), new ArrayList<>());
|
||||
binding.recyclerView.setAdapter(artAdapter);
|
||||
|
||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
||||
binding.recyclerView.addItemDecoration(itemDecoration);
|
||||
}
|
||||
|
||||
private void setupListeners() {
|
||||
fetchFavoriteItems();
|
||||
}
|
||||
|
||||
private void fetchFavoriteItems() {
|
||||
paletteViewModel.getAllFavorite()
|
||||
.observe(getViewLifecycleOwner(), new Observer<List<PaletteData>>() {
|
||||
@Override
|
||||
public void onChanged(List<PaletteData> updatedList) {
|
||||
artAdapter.replaceData(updatedList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
binding = null;
|
||||
}
|
||||
}
|
||||
@ -8,11 +8,11 @@ import android.view.ViewGroup;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.databinding.FragmentHomeBinding;
|
||||
import com.wallpaper.palettewallpaper.ui.adapter.PaletteAdapter;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.ui.adapter.GalleryAdapter;
|
||||
import com.wallpaper.palettewallpaper.util.ItemDecoration;
|
||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
||||
|
||||
@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
private FragmentHomeBinding fragmentHomeBinding;
|
||||
private PaletteAdapter paletteAdapter;
|
||||
private GalleryAdapter paletteAdapter;
|
||||
private PaletteViewModel paletteViewModel;
|
||||
|
||||
@Override
|
||||
@ -38,34 +38,33 @@ public class HomeFragment extends Fragment {
|
||||
|
||||
paletteViewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||
|
||||
fragmentHomeBinding.recyclerView.setLayoutManager(new GridLayoutManager(getContext(),2));
|
||||
fragmentHomeBinding.recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
||||
|
||||
paletteAdapter = new PaletteAdapter(requireContext(), new ArrayList<>());
|
||||
paletteAdapter = new GalleryAdapter(requireContext(), new ArrayList<>());
|
||||
fragmentHomeBinding.recyclerView.setAdapter(paletteAdapter);
|
||||
|
||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
||||
fragmentHomeBinding.recyclerView.addItemDecoration(itemDecoration);
|
||||
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
loadCategoryImage();
|
||||
getFirstByName();
|
||||
}
|
||||
|
||||
private void loadCategoryImage() {
|
||||
private void getFirstByName() {
|
||||
paletteViewModel
|
||||
.getCategoryFirst()
|
||||
.getFirstByName()
|
||||
.observe(getViewLifecycleOwner(), new Observer<List<PaletteData>>() {
|
||||
@Override
|
||||
public void onChanged(List<PaletteData> coolEntities) {
|
||||
paletteAdapter.updateData(coolEntities);
|
||||
paletteAdapter.refreshData(coolEntities);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
fragmentHomeBinding = null;
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
package com.wallpaper.palettewallpaper.util;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
public interface DownloadCallback {
|
||||
void onDownloadStart();
|
||||
void onDownloadComplete(Uri uri);
|
||||
void onDownloadFailed();
|
||||
}
|
||||
@ -2,18 +2,18 @@ package com.wallpaper.palettewallpaper.util;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.wallpaper.palettewallpaper.data.database.AppDatabase;
|
||||
import com.wallpaper.palettewallpaper.data.database.dao.PaletteDataDao;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.SubList;
|
||||
import com.wallpaper.palettewallpaper.local.database.AppDatabase;
|
||||
import com.wallpaper.palettewallpaper.local.database.dao.PaletteDataDao;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.SubList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InsertAll {
|
||||
public class InsertAllUtil {
|
||||
private final PaletteDataDao paletteDataDao;
|
||||
|
||||
public InsertAll(Context context) {
|
||||
public InsertAllUtil(Context context) {
|
||||
AppDatabase db = AppDatabase.getInstance(context);
|
||||
paletteDataDao = db.paletteDataDao();
|
||||
}
|
||||
@ -3,8 +3,8 @@ package com.wallpaper.palettewallpaper.util;
|
||||
import android.util.Log;
|
||||
|
||||
import com.wallpaper.palettewallpaper.MyApplication;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.SubList;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.SubList;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@ -5,9 +5,9 @@ import android.app.Application;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.wallpaper.palettewallpaper.data.database.AppDatabase;
|
||||
import com.wallpaper.palettewallpaper.data.database.dao.PaletteDataDao;
|
||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
||||
import com.wallpaper.palettewallpaper.local.database.AppDatabase;
|
||||
import com.wallpaper.palettewallpaper.local.database.dao.PaletteDataDao;
|
||||
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -21,23 +21,23 @@ public class PaletteViewModel extends AndroidViewModel {
|
||||
paletteDataDao = db.paletteDataDao();
|
||||
}
|
||||
|
||||
public LiveData<List<PaletteData>> getAllFavoriteList() {
|
||||
return paletteDataDao.getAllFavoriteLive();
|
||||
public LiveData<List<PaletteData>> getAllFavorite() {
|
||||
return paletteDataDao.getAllFavorite();
|
||||
}
|
||||
|
||||
public LiveData<List<PaletteData>> getCategoryFirst() {
|
||||
return paletteDataDao.getFirstRecordOfEachName();
|
||||
public LiveData<List<PaletteData>> getFirstByName() {
|
||||
return paletteDataDao.getFirstByName();
|
||||
}
|
||||
|
||||
public LiveData<List<PaletteData>> getAllCategory(String name) {
|
||||
return paletteDataDao.getAllCategoryLive(name);
|
||||
return paletteDataDao.getAllCategory(name);
|
||||
}
|
||||
|
||||
public LiveData<Boolean> getWallpaperLike(String source, String name) {
|
||||
return paletteDataDao.getWallpaperLike(source, name);
|
||||
public LiveData<Boolean> getLike(String source, String name) {
|
||||
return paletteDataDao.getLike(source, name);
|
||||
}
|
||||
|
||||
public void update(PaletteData imageEntry) {
|
||||
paletteDataDao.update(imageEntry);
|
||||
public void update(PaletteData paletteData) {
|
||||
paletteDataDao.update(paletteData);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,108 +0,0 @@
|
||||
package com.wallpaper.palettewallpaper.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 androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.UUID;
|
||||
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 ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
|
||||
public void setAsWallpaper(Activity activity, String imageUrl,DownloadCallback callback) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
startDownload(activity, imageUrl,callback);
|
||||
} 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,callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startDownload(Activity activity, String imageUrl, DownloadCallback callback) {
|
||||
callback.onDownloadStart();
|
||||
|
||||
executorService.submit(() -> {
|
||||
Uri uri = downloadImage(activity, imageUrl);
|
||||
|
||||
activity.runOnUiThread(() -> {
|
||||
if (uri != null) {
|
||||
callback.onDownloadComplete(uri);
|
||||
} else {
|
||||
callback.onDownloadFailed();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private Uri downloadImage(Activity activity, String imageUrl) {
|
||||
String displayName = UUID.randomUUID().toString() + ".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;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.wallpaper.palettewallpaper.util;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
public interface WallpaperDownloadListener {
|
||||
void onPrepare();
|
||||
void onSuccess(Uri uri);
|
||||
void onError();
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package com.wallpaper.palettewallpaper.util;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentValues;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class WallpaperHelper {
|
||||
public static final int PERMISSION_CODE_WRITE = 201;
|
||||
private final ExecutorService backgroundWorker = Executors.newSingleThreadExecutor();
|
||||
|
||||
public void applyWallpaper(Activity context, String imageLink, WallpaperDownloadListener listener) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
proceedDownload(context, imageLink, listener);
|
||||
} else {
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(
|
||||
context,
|
||||
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
PERMISSION_CODE_WRITE
|
||||
);
|
||||
} else {
|
||||
proceedDownload(context, imageLink, listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void proceedDownload(Activity context, String url, WallpaperDownloadListener listener) {
|
||||
listener.onPrepare();
|
||||
|
||||
backgroundWorker.execute(() -> {
|
||||
Uri resultUri = storeImageToMedia(context, url);
|
||||
|
||||
new Handler(Looper.getMainLooper()).post(() -> {
|
||||
if (resultUri != null) {
|
||||
listener.onSuccess(resultUri);
|
||||
} else {
|
||||
listener.onError();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private Uri storeImageToMedia(Activity context, String url) {
|
||||
String fileName = "img_" + System.currentTimeMillis() + ".jpg";
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MediaStore.Images.Media.DISPLAY_NAME, fileName);
|
||||
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 1);
|
||||
}
|
||||
|
||||
Uri storageUri = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
? MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
|
||||
: MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
|
||||
Uri targetUri = context.getContentResolver().insert(storageUri, values);
|
||||
if (targetUri == null) return null;
|
||||
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.connect();
|
||||
try (InputStream input = connection.getInputStream();
|
||||
OutputStream output = context.getContentResolver().openOutputStream(targetUri)) {
|
||||
if (output == null) return null;
|
||||
|
||||
byte[] buffer = new byte[4096];
|
||||
int length;
|
||||
while ((length = input.read(buffer)) != -1) {
|
||||
output.write(buffer, 0, length);
|
||||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
values.clear();
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 0);
|
||||
context.getContentResolver().update(targetUri, values, null, null);
|
||||
}
|
||||
|
||||
return targetUri;
|
||||
} catch (IOException e) {
|
||||
context.getContentResolver().delete(targetUri, null, null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:angle="45"
|
||||
android:endColor="#006B8C"
|
||||
android:startColor="#8EE5EE"
|
||||
android:endColor="#BBDEFB"
|
||||
android:startColor="#F5F5F5"
|
||||
android:type="linear"
|
||||
android:useLevel="false" />
|
||||
<corners android:radius="16sp" />
|
||||
@ -5,8 +5,8 @@
|
||||
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/white"/>
|
||||
android:fillColor="@color/black"/>
|
||||
<path
|
||||
android:pathData="M640,292.3a32,32 0,1 0,32 32,32 32,0 0,0 -32,-32z"
|
||||
android:fillColor="@color/white"/>
|
||||
android:fillColor="@color/black"/>
|
||||
</vector>
|
||||
|
||||
@ -5,22 +5,21 @@
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/blue_black"
|
||||
tools:context=".ui.activity.MainActivity">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/main_viewpager2"
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/main_tab_layout"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tab_layout"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/main_tab_layout"
|
||||
android:id="@+id/tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="125dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@android:color/transparent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:tabIndicatorHeight="0dp"
|
||||
|
||||
@ -15,61 +15,64 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="64dp"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="48dp"
|
||||
android:src="@drawable/back"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/like"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
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"
|
||||
<LinearLayout
|
||||
android:id="@+id/action_bar"
|
||||
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" />
|
||||
android:background="@drawable/rounded_rectangle_gradient_blue"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingEnd="4dp"
|
||||
android:paddingBottom="2dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:src="@drawable/download" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
android:id="@+id/like"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginHorizontal="32dp"
|
||||
android:src="@drawable/un_like" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/set"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginBottom="32dp"
|
||||
android:src="@drawable/apply"
|
||||
android:padding="5dp"
|
||||
android:background="@drawable/rounded_rectangle_gradient"
|
||||
app:layout_constraintBottom_toTopOf="@+id/like"
|
||||
app:layout_constraintEnd_toEndOf="@+id/like" />
|
||||
<FrameLayout
|
||||
android:id="@+id/down"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/download" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/down_progress"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminateTint="@color/black"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/set"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginHorizontal="32dp"
|
||||
android:padding="6dp"
|
||||
android:src="@drawable/apply" />
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/view"
|
||||
|
||||
@ -5,26 +5,25 @@
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/blue_black"
|
||||
tools:context=".ui.activity.SecondActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="25dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:src="@drawable/back"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/text"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/text" />
|
||||
app:layout_constraintTop_toTopOf="@+id/title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24sp"
|
||||
android:text="@string/app_name"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -37,6 +36,6 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -5,7 +5,6 @@
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/blue_black"
|
||||
tools:context=".ui.activity.SplashActivity">
|
||||
|
||||
<ImageView
|
||||
@ -27,7 +26,7 @@
|
||||
android:textSize="25sp"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textColor="@color/black"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/image" />
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/rounded_rectangle_gradient">
|
||||
android:background="@drawable/rounded_rectangle_gradient_blue">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
<?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"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:context=".ui.fragment.CollectionFragment">
|
||||
tools:context=".ui.fragment.FavoriteFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:gravity="center"
|
||||
android:text="COLLECTION"
|
||||
android:textColor="@color/white"
|
||||
android:text="FAVORITE"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -26,6 +26,6 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -7,13 +7,13 @@
|
||||
tools:context=".ui.fragment.HomeFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:gravity="center"
|
||||
android:text="HOME"
|
||||
android:textColor="@color/white"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -26,6 +26,6 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/title" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -6,8 +6,7 @@
|
||||
<ImageView
|
||||
android:id="@+id/image_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"/>
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favorite"
|
||||
@ -7,8 +7,7 @@
|
||||
<ImageView
|
||||
android:id="@+id/imageview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY" />
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category_title"
|
||||
@ -16,9 +15,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:maxLines="2"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
android:maxLines="2"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@ -3,5 +3,4 @@
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="gray">#9C979D</color>
|
||||
<color name="blue_black">#0D1B2A</color>
|
||||
</resources>
|
||||
6
keystore.properties
Normal file
6
keystore.properties
Normal file
@ -0,0 +1,6 @@
|
||||
app_name=Palette Wallpaper
|
||||
package_name=com.wallpaper.palettewallpaper
|
||||
keystoreFile=app/PaletteWallpaper.jks
|
||||
key_alias=PaletteWallpaperkey0
|
||||
key_store_password=PaletteWallpaper
|
||||
key_password=PaletteWallpaper
|
||||
Loading…
Reference in New Issue
Block a user