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")
|
implementation ("androidx.room:room-runtime:2.7.0")
|
||||||
annotationProcessor ("androidx.room:room-compiler:2.7.0")
|
annotationProcessor ("androidx.room:room-compiler:2.7.0")
|
||||||
|
|
||||||
implementation ("com.squareup.okhttp3:okhttp:4.12.0")
|
|
||||||
}
|
}
|
||||||
16
app/proguard-rules.pro
vendored
16
app/proguard-rules.pro
vendored
@ -18,4 +18,18 @@
|
|||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
# If you keep the line number information, uncomment this to
|
||||||
# hide the original source file name.
|
# hide the original source file name.
|
||||||
#-renamesourcefileattribute SourceFile
|
#-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
|
-keepclassmembers class com.wallpaper.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.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import com.wallpaper.palettewallpaper.local.database.data.SubList;
|
||||||
|
import com.wallpaper.palettewallpaper.util.InsertAllUtil;
|
||||||
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.util.JsonParse;
|
import com.wallpaper.palettewallpaper.util.JsonParse;
|
||||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@ -18,9 +14,9 @@ import java.util.concurrent.Executors;
|
|||||||
public class MyApplication extends Application {
|
public class MyApplication extends Application {
|
||||||
public static MyApplication application;
|
public static MyApplication application;
|
||||||
public static final int DB_VERSION = 1;
|
public static final int DB_VERSION = 1;
|
||||||
public static final String DB_NAME = "cool_database";
|
public static final String DB_NAME = "palette_database";
|
||||||
private static final String PREF_NAME = "app_preferences";
|
private static final String PREFERENCES_NAME = "app_preferences";
|
||||||
private static final String KEY_INIT = "isInit";
|
private static final String KEY_INIT = "init";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@ -28,11 +24,10 @@ public class MyApplication extends Application {
|
|||||||
|
|
||||||
application = this;
|
application = this;
|
||||||
|
|
||||||
SharedPreferences sharedPreferences = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
|
SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_NAME, MODE_PRIVATE);
|
||||||
boolean isDatabaseInitialized = sharedPreferences.getBoolean(KEY_INIT, false);
|
|
||||||
|
|
||||||
if (!isDatabaseInitialized) {
|
if (!sharedPreferences.getBoolean(KEY_INIT, false)) {
|
||||||
initializeDatabase();
|
init();
|
||||||
sharedPreferences.edit().putBoolean(KEY_INIT, true).apply();
|
sharedPreferences.edit().putBoolean(KEY_INIT, true).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,15 +37,15 @@ public class MyApplication extends Application {
|
|||||||
return application.getApplicationContext();
|
return application.getApplicationContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeDatabase() {
|
private void init() {
|
||||||
Executors.newSingleThreadExecutor().execute(() -> {
|
Executors.newSingleThreadExecutor().execute(() -> {
|
||||||
List<SubList> subList = getCategoryList();
|
List<SubList> subList = getSubList();
|
||||||
InsertAll insertAll = new InsertAll(getContext());
|
InsertAllUtil insertAllUtil = new InsertAllUtil(getContext());
|
||||||
insertAll.insertAllImages(subList);
|
insertAllUtil.insertAllImages(subList);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SubList> getCategoryList() {
|
public static List<SubList> getSubList() {
|
||||||
return JsonParse.parseJson("wallpapers.json");
|
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;
|
import android.content.Context;
|
||||||
|
|
||||||
@ -7,8 +7,8 @@ import androidx.room.Room;
|
|||||||
import androidx.room.RoomDatabase;
|
import androidx.room.RoomDatabase;
|
||||||
|
|
||||||
import com.wallpaper.palettewallpaper.MyApplication;
|
import com.wallpaper.palettewallpaper.MyApplication;
|
||||||
import com.wallpaper.palettewallpaper.data.database.dao.PaletteDataDao;
|
import com.wallpaper.palettewallpaper.local.database.dao.PaletteDataDao;
|
||||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||||
|
|
||||||
@Database(entities = {PaletteData.class}, version = MyApplication.DB_VERSION, exportSchema = false)
|
@Database(entities = {PaletteData.class}, version = MyApplication.DB_VERSION, exportSchema = false)
|
||||||
public abstract class AppDatabase extends RoomDatabase {
|
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.Entity;
|
||||||
import androidx.room.PrimaryKey;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
@ -2,6 +2,7 @@ package com.wallpaper.palettewallpaper.ui.activity;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.activity.EdgeToEdge;
|
import androidx.activity.EdgeToEdge;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
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.google.android.material.tabs.TabLayoutMediator;
|
||||||
import com.wallpaper.palettewallpaper.R;
|
import com.wallpaper.palettewallpaper.R;
|
||||||
import com.wallpaper.palettewallpaper.databinding.ActivityMainBinding;
|
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;
|
import com.wallpaper.palettewallpaper.ui.adapter.MainViewpager2Adapter;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
private ActivityMainBinding binding;
|
private ActivityMainBinding ui;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
EdgeToEdge.enable(this);
|
EdgeToEdge.enable(this);
|
||||||
binding = ActivityMainBinding.inflate(getLayoutInflater());
|
ui = ActivityMainBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(ui.getRoot());
|
||||||
|
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
handleInsets();
|
||||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
setupViewPagerAndTabs();
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
}
|
||||||
|
|
||||||
|
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;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
initData();
|
|
||||||
initEvent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void setupViewPagerAndTabs() {
|
||||||
MainViewpager2Adapter adapter = new MainViewpager2Adapter(this);
|
ui.viewPager.setAdapter(new MainViewpager2Adapter(this));
|
||||||
binding.mainViewpager2.setAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initEvent() {
|
new TabLayoutMediator(ui.tabLayout, ui.viewPager, (tab, index) -> {
|
||||||
binding.mainViewpager2.setUserInputEnabled(false);
|
CustomTabBinding customTabBinding = CustomTabBinding.inflate(LayoutInflater.from(this));
|
||||||
|
tab.setCustomView(customTabBinding.getRoot());
|
||||||
new TabLayoutMediator(binding.mainTabLayout, binding.mainViewpager2, (tab, position) -> {
|
initializeTab(customTabBinding, index);
|
||||||
TabLayoutBinding tabLayoutBinding = TabLayoutBinding.inflate(LayoutInflater.from(this));
|
|
||||||
tab.setCustomView(tabLayoutBinding.getRoot());
|
|
||||||
setTab(tabLayoutBinding, position);
|
|
||||||
}).attach();
|
}).attach();
|
||||||
|
|
||||||
binding.mainTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
ui.tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
updateTab(tab, true);
|
applyTabStyle(tab, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabUnselected(TabLayout.Tab tab) {
|
public void onTabUnselected(TabLayout.Tab tab) {
|
||||||
updateTab(tab, false);
|
applyTabStyle(tab, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabReselected(TabLayout.Tab tab) {
|
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) {
|
private void initializeTab(CustomTabBinding binding, int pos) {
|
||||||
int iconResId = getIconResource(position, false);
|
binding.text.setText(pos == 0 ? "Home" : "Favorite");
|
||||||
int textColorResId = R.color.black;
|
binding.image.setImageResource(getIconFor(pos, false, 1));
|
||||||
|
binding.text.setTextColor(ContextCompat.getColor(this, pos == 0 ? R.color.black : 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) {
|
private void applyTabStyle(TabLayout.Tab tab, boolean selected) {
|
||||||
if (position == 1) {
|
View view = tab.getCustomView();
|
||||||
return isSelected ? R.drawable.favorite : R.drawable.un_favorite;
|
if (view == null) return;
|
||||||
}
|
|
||||||
return isSelected ? R.drawable.main : R.drawable.un_main;
|
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
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
binding = null;
|
ui = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package com.wallpaper.palettewallpaper.ui.activity;
|
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.app.WallpaperManager;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
@ -19,8 +19,6 @@ import androidx.activity.EdgeToEdge;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.view.ViewCompat;
|
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
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.bumptech.glide.request.transition.Transition;
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||||
import com.wallpaper.palettewallpaper.R;
|
import com.wallpaper.palettewallpaper.R;
|
||||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
|
||||||
import com.wallpaper.palettewallpaper.databinding.ActivityPaletteBinding;
|
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.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.io.IOException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
public class PaletteActivity extends AppCompatActivity implements DownloadCallback {
|
public class PaletteActivity extends AppCompatActivity implements WallpaperDownloadListener {
|
||||||
private ActivityPaletteBinding binding;
|
private ActivityPaletteBinding viewBinding;
|
||||||
private String original;
|
private String baseImageUrl;
|
||||||
private String source;
|
private String imageSource;
|
||||||
private PaletteData paletteData;
|
private PaletteData paletteData;
|
||||||
private PaletteViewModel paletteViewModel;
|
private PaletteViewModel viewModel;
|
||||||
private String name;
|
private String title;
|
||||||
private Bitmap bitmap;
|
private Bitmap imageBitmap;
|
||||||
private SetAndDownloadUtils setAndDownloadUtils;
|
private WallpaperHelper wallpaperUtility;
|
||||||
private ExecutorService executorService;
|
private ExecutorService backgroundExecutor;
|
||||||
private Handler handler;
|
private Handler uiHandler;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
EdgeToEdge.enable(this);
|
EdgeToEdge.enable(this);
|
||||||
binding = ActivityPaletteBinding.inflate(getLayoutInflater());
|
viewBinding = ActivityPaletteBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(viewBinding.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();
|
setupInitialData();
|
||||||
initEvent();
|
configureInteractions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void setupInitialData() {
|
||||||
paletteData = (PaletteData) getIntent().getSerializableExtra("cool");
|
paletteData = (PaletteData) getIntent().getSerializableExtra("palette");
|
||||||
if (paletteData != null) {
|
if (paletteData == null) {
|
||||||
original = paletteData.getOriginal();
|
Toast.makeText(this, "Data error", Toast.LENGTH_SHORT).show();
|
||||||
source = paletteData.getSource();
|
|
||||||
name = paletteData.getName();
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
|
|
||||||
finish();
|
finish();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAndDownloadUtils = new SetAndDownloadUtils();
|
baseImageUrl = paletteData.getOriginal();
|
||||||
|
imageSource = paletteData.getSource();
|
||||||
|
title = paletteData.getName();
|
||||||
|
|
||||||
paletteViewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
wallpaperUtility = new WallpaperHelper();
|
||||||
|
viewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||||
handler = new Handler(Looper.getMainLooper());
|
|
||||||
executorService = Executors.newSingleThreadExecutor();
|
|
||||||
|
|
||||||
|
uiHandler = new Handler(Looper.getMainLooper());
|
||||||
|
backgroundExecutor = Executors.newSingleThreadExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initEvent() {
|
private void configureInteractions() {
|
||||||
showProgress();
|
displayLoadingIndicator();
|
||||||
|
|
||||||
binding.back.setOnClickListener(v -> finish());
|
viewBinding.back.setOnClickListener(v -> finish());
|
||||||
|
|
||||||
binding.like.setOnClickListener(v -> {
|
viewBinding.like.setOnClickListener(v -> {
|
||||||
boolean newStatus = !paletteData.getLike();
|
boolean updatedStatus = !paletteData.getLike();
|
||||||
paletteData.setLike(newStatus);
|
paletteData.setLike(updatedStatus);
|
||||||
executorService.submit(() -> paletteViewModel.update(paletteData));
|
backgroundExecutor.submit(() -> viewModel.update(paletteData));
|
||||||
});
|
});
|
||||||
|
|
||||||
binding.set.setOnClickListener(v -> showCustomBottomSheet());
|
viewBinding.set.setOnClickListener(v -> showOptionDialog());
|
||||||
|
|
||||||
binding.down.setOnClickListener(v -> {
|
viewBinding.down.setOnClickListener(v -> {
|
||||||
showProgress();
|
displayLoadingIndicator();
|
||||||
setAndDownloadUtils.setAsWallpaper(PaletteActivity.this, source, PaletteActivity.this);
|
wallpaperUtility.applyWallpaper(this, imageSource, this);
|
||||||
});
|
});
|
||||||
|
|
||||||
loadImage();
|
fetchImage();
|
||||||
loadFavorite();
|
monitorFavoriteStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, 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) {
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
setAndDownloadUtils.setAsWallpaper(this, source, this);
|
wallpaperUtility.applyWallpaper(this, imageSource, this);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Access denied", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showCustomBottomSheet() {
|
private void showOptionDialog() {
|
||||||
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
|
BottomSheetDialog dialog = new BottomSheetDialog(this);
|
||||||
View bottomSheetView = LayoutInflater.from(this).inflate(R.layout.detail_dialog, null);
|
View dialogView = LayoutInflater.from(this).inflate(R.layout.detail_dialog, null);
|
||||||
|
|
||||||
bottomSheetView.findViewById(R.id.both).setOnClickListener(v -> {
|
dialogView.findViewById(R.id.both).setOnClickListener(v -> {
|
||||||
disableButtons(bottomSheetView);
|
disableOptions(dialogView);
|
||||||
applyWallpaper(bitmap, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK, bottomSheetDialog);
|
setWallpaper(imageBitmap, WallpaperManager.FLAG_SYSTEM | WallpaperManager.FLAG_LOCK, dialog);
|
||||||
bottomSheetDialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
bottomSheetView.findViewById(R.id.lock).setOnClickListener(v -> {
|
dialogView.findViewById(R.id.lock).setOnClickListener(v -> {
|
||||||
disableButtons(bottomSheetView);
|
disableOptions(dialogView);
|
||||||
applyWallpaper(bitmap, WallpaperManager.FLAG_LOCK, bottomSheetDialog);
|
setWallpaper(imageBitmap, WallpaperManager.FLAG_LOCK, dialog);
|
||||||
bottomSheetDialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
bottomSheetView.findViewById(R.id.desktop).setOnClickListener(v -> {
|
dialogView.findViewById(R.id.desktop).setOnClickListener(v -> {
|
||||||
disableButtons(bottomSheetView);
|
disableOptions(dialogView);
|
||||||
applyWallpaper(bitmap, WallpaperManager.FLAG_SYSTEM, bottomSheetDialog);
|
setWallpaper(imageBitmap, WallpaperManager.FLAG_SYSTEM, dialog);
|
||||||
bottomSheetDialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
bottomSheetDialog.setContentView(bottomSheetView);
|
dialog.setContentView(dialogView);
|
||||||
bottomSheetDialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableButtons(View bottomSheetView) {
|
private void disableOptions(View dialogView) {
|
||||||
bottomSheetView.findViewById(R.id.both).setEnabled(false);
|
dialogView.findViewById(R.id.both).setEnabled(false);
|
||||||
bottomSheetView.findViewById(R.id.lock).setEnabled(false);
|
dialogView.findViewById(R.id.lock).setEnabled(false);
|
||||||
bottomSheetView.findViewById(R.id.desktop).setEnabled(false);
|
dialogView.findViewById(R.id.desktop).setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyWallpaper(Bitmap bitmap, int flag, BottomSheetDialog bottomSheetDialog) {
|
private void setWallpaper(Bitmap bitmap, int flags, BottomSheetDialog dialog) {
|
||||||
showProgress();
|
displayLoadingIndicator();
|
||||||
|
|
||||||
executorService.submit(() -> {
|
backgroundExecutor.submit(() -> {
|
||||||
boolean success = false;
|
boolean result = false;
|
||||||
try {
|
try {
|
||||||
success = setWallpaperImage(bitmap, flag);
|
result = applyWallpaper(bitmap, flags);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
boolean finalSuccess = success;
|
boolean finalResult = result;
|
||||||
handler.post(() -> {
|
uiHandler.post(() -> {
|
||||||
hideProgress();
|
hideLoadingIndicator();
|
||||||
bottomSheetDialog.findViewById(R.id.both).setEnabled(true);
|
dialog.findViewById(R.id.both).setEnabled(true);
|
||||||
bottomSheetDialog.findViewById(R.id.lock).setEnabled(true);
|
dialog.findViewById(R.id.lock).setEnabled(true);
|
||||||
bottomSheetDialog.findViewById(R.id.desktop).setEnabled(true);
|
dialog.findViewById(R.id.desktop).setEnabled(true);
|
||||||
|
|
||||||
String message = finalSuccess ? "Wallpaper set successfully" : "Failed to set wallpaper";
|
String message = finalResult ? "Success" : "Failed";
|
||||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setWallpaperImage(Bitmap bitmap, int flag) {
|
private boolean applyWallpaper(Bitmap bitmap, int flags) {
|
||||||
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext());
|
WallpaperManager wallpaperMgr = WallpaperManager.getInstance(this);
|
||||||
try {
|
try {
|
||||||
binding.imageView.setDrawingCacheEnabled(true);
|
viewBinding.imageView.setDrawingCacheEnabled(true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
wallpaperManager.setBitmap(bitmap, null, true, flag);
|
wallpaperMgr.setBitmap(bitmap, null, true, flags);
|
||||||
} else {
|
} else {
|
||||||
wallpaperManager.setBitmap(bitmap);
|
wallpaperMgr.setBitmap(bitmap);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
binding.imageView.setDrawingCacheEnabled(false);
|
viewBinding.imageView.setDrawingCacheEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fetchImage() {
|
||||||
private void loadImage() {
|
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
.load(original)
|
.load(baseImageUrl)
|
||||||
.error(ContextCompat.getDrawable(this, R.mipmap.placeholder))
|
.error(ContextCompat.getDrawable(this, R.mipmap.placeholder))
|
||||||
.override(1080, 1920)
|
.override(1080, 1920)
|
||||||
.centerInside()
|
.centerInside()
|
||||||
.into(new CustomTarget<Bitmap>() {
|
.into(new CustomTarget<Bitmap>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) {
|
||||||
binding.imageView.setImageBitmap(resource);
|
viewBinding.imageView.setImageBitmap(resource);
|
||||||
bitmap = resource;
|
imageBitmap = resource;
|
||||||
hideProgress();
|
hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadCleared(Drawable placeholder) {
|
public void onLoadCleared(Drawable placeholder) {
|
||||||
binding.imageView.setImageDrawable(placeholder != null ? placeholder : getDefaultPlaceholder());
|
viewBinding.imageView.setImageDrawable(placeholder != null ? placeholder : getDefaultImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadFailed(Drawable errorDrawable) {
|
public void onLoadFailed(Drawable errorDrawable) {
|
||||||
binding.imageView.setImageDrawable(errorDrawable != null ? errorDrawable : getDefaultPlaceholder());
|
viewBinding.imageView.setImageDrawable(errorDrawable != null ? errorDrawable : getDefaultImage());
|
||||||
hideProgress();
|
hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getDefaultPlaceholder() {
|
private Drawable getDefaultImage() {
|
||||||
return ContextCompat.getDrawable(this, R.mipmap.placeholder);
|
return ContextCompat.getDrawable(this, R.mipmap.placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadFavorite() {
|
private void monitorFavoriteStatus() {
|
||||||
paletteViewModel.getWallpaperLike(source, name).observe(this, wallpaper -> setFavoriteButton());
|
viewModel.getLike(imageSource, title).observe(this, wallpaper -> updateFavoriteIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFavoriteButton() {
|
private void updateFavoriteIcon() {
|
||||||
binding.like.setImageResource(
|
viewBinding.like.setImageResource(
|
||||||
paletteData.getLike() ? R.drawable.like : R.drawable.un_like
|
paletteData.getLike() ? R.drawable.like : R.drawable.un_like
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hideProgress() {
|
private void hideLoadingIndicator() {
|
||||||
if (binding != null) {
|
if (viewBinding != null) {
|
||||||
binding.progressBar.setVisibility(View.GONE);
|
viewBinding.progressBar.setVisibility(View.GONE);
|
||||||
binding.view.setVisibility(View.GONE);
|
viewBinding.view.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showProgress() {
|
private void displayLoadingIndicator() {
|
||||||
binding.progressBar.setVisibility(View.VISIBLE);
|
viewBinding.progressBar.setVisibility(View.VISIBLE);
|
||||||
binding.view.setVisibility(View.VISIBLE);
|
viewBinding.view.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadStart() {
|
public void onPrepare() {
|
||||||
showProgress();
|
displayLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadComplete(Uri uri) {
|
public void onSuccess(Uri uri) {
|
||||||
hideProgress();
|
hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadFailed() {
|
public void onError() {
|
||||||
hideProgress();
|
hideLoadingIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (handler != null) {
|
if (uiHandler != null) {
|
||||||
handler.removeCallbacksAndMessages(null);
|
uiHandler.removeCallbacksAndMessages(null);
|
||||||
}
|
}
|
||||||
if (executorService != null) {
|
if (backgroundExecutor != null) {
|
||||||
executorService.shutdown();
|
backgroundExecutor.shutdown();
|
||||||
}
|
}
|
||||||
binding = null;
|
viewBinding = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,80 +8,79 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
import androidx.lifecycle.Observer;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
|
||||||
import com.wallpaper.palettewallpaper.R;
|
import com.wallpaper.palettewallpaper.R;
|
||||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
|
||||||
import com.wallpaper.palettewallpaper.databinding.ActivitySecondBinding;
|
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.ItemDecoration;
|
||||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SecondActivity extends AppCompatActivity {
|
public class SecondActivity extends AppCompatActivity {
|
||||||
private ActivitySecondBinding binding;
|
private ActivitySecondBinding ui;
|
||||||
private SecondAdapter secondAdapter;
|
private ArtAdapter adapter;
|
||||||
private PaletteViewModel paletteViewModel;
|
private PaletteViewModel viewModel;
|
||||||
private String name;
|
private String categoryName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
EdgeToEdge.enable(this);
|
EdgeToEdge.enable(this);
|
||||||
binding = ActivitySecondBinding.inflate(getLayoutInflater());
|
|
||||||
setContentView(binding.getRoot());
|
|
||||||
|
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
|
ui = ActivitySecondBinding.inflate(getLayoutInflater());
|
||||||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
setContentView(ui.getRoot());
|
||||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
|
|
||||||
return insets;
|
|
||||||
});
|
|
||||||
|
|
||||||
initData();
|
applyInsets();
|
||||||
initEvent();
|
initialize();
|
||||||
|
setupListeners();
|
||||||
|
observeCategoryData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void applyInsets() {
|
||||||
name = getIntent().getStringExtra("name");
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (view, insets) -> {
|
||||||
if (name == null) {
|
Insets sysBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
Toast.makeText(this, "The picture does not exist", Toast.LENGTH_SHORT).show();
|
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();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
paletteViewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
viewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
||||||
|
|
||||||
binding.recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
adapter = new ArtAdapter(this, new ArrayList<>());
|
||||||
secondAdapter = new SecondAdapter(this, new ArrayList<>());
|
ui.recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||||
binding.recyclerView.setAdapter(secondAdapter);
|
ui.recyclerView.setAdapter(adapter);
|
||||||
|
ui.recyclerView.addItemDecoration(new ItemDecoration(25, 15, 10));
|
||||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
|
||||||
binding.recyclerView.addItemDecoration(itemDecoration);
|
|
||||||
|
|
||||||
|
ui.title.setText(categoryName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initEvent() {
|
private void setupListeners() {
|
||||||
|
ui.back.setOnClickListener(view -> finish());
|
||||||
binding.back.setOnClickListener(v -> finish());
|
|
||||||
binding.text.setText(name);
|
|
||||||
|
|
||||||
loadImage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadImage() {
|
private void observeCategoryData() {
|
||||||
paletteViewModel
|
viewModel.getAllCategory(categoryName).observe(this, paletteList -> {
|
||||||
.getAllCategory(name)
|
if (paletteList != null) {
|
||||||
.observe(this, new Observer<List<PaletteData>>() {
|
adapter.replaceData(paletteList);
|
||||||
@Override
|
}
|
||||||
public void onChanged(List<PaletteData> coolEntities) {
|
});
|
||||||
secondAdapter.updateData(coolEntities);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
ui = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -11,6 +11,7 @@ import androidx.core.view.ViewCompat;
|
|||||||
import androidx.core.view.WindowInsetsCompat;
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||||
import com.wallpaper.palettewallpaper.R;
|
import com.wallpaper.palettewallpaper.R;
|
||||||
import com.wallpaper.palettewallpaper.databinding.ActivitySplashBinding;
|
import com.wallpaper.palettewallpaper.databinding.ActivitySplashBinding;
|
||||||
@ -36,10 +37,10 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
Glide.with(this)
|
Glide.with(this)
|
||||||
.load(R.mipmap.placeholder)
|
.load(R.mipmap.placeholder)
|
||||||
.transform(new RoundedCorners(16))
|
.transform(new CenterCrop(), new RoundedCorners(32))
|
||||||
.into(binding.image);
|
.into(binding.image);
|
||||||
|
|
||||||
countDownTimer = new CountDownTimer(TOTAL_TIME,100) {
|
countDownTimer = new CountDownTimer(TOTAL_TIME, 100) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
int percentage = (int) (100 - (float) millisUntilFinished / TOTAL_TIME * 100);
|
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.fragment.app.FragmentActivity;
|
||||||
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
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 com.wallpaper.palettewallpaper.ui.fragment.HomeFragment;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -18,7 +18,7 @@ public class MainViewpager2Adapter extends FragmentStateAdapter {
|
|||||||
public MainViewpager2Adapter(@NonNull FragmentActivity fragmentActivity) {
|
public MainViewpager2Adapter(@NonNull FragmentActivity fragmentActivity) {
|
||||||
super(fragmentActivity);
|
super(fragmentActivity);
|
||||||
fragmentList.add(new HomeFragment());
|
fragmentList.add(new HomeFragment());
|
||||||
fragmentList.add(new CollectionFragment());
|
fragmentList.add(new FavoriteFragment());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@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.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.Observer;
|
import androidx.lifecycle.Observer;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
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.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.ItemDecoration;
|
||||||
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
import com.wallpaper.palettewallpaper.util.PaletteViewModel;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class HomeFragment extends Fragment {
|
public class HomeFragment extends Fragment {
|
||||||
private FragmentHomeBinding fragmentHomeBinding;
|
private FragmentHomeBinding fragmentHomeBinding;
|
||||||
private PaletteAdapter paletteAdapter;
|
private GalleryAdapter paletteAdapter;
|
||||||
private PaletteViewModel paletteViewModel;
|
private PaletteViewModel paletteViewModel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,34 +38,33 @@ public class HomeFragment extends Fragment {
|
|||||||
|
|
||||||
paletteViewModel = new ViewModelProvider(this).get(PaletteViewModel.class);
|
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);
|
fragmentHomeBinding.recyclerView.setAdapter(paletteAdapter);
|
||||||
|
|
||||||
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
ItemDecoration itemDecoration = new ItemDecoration(25, 15, 10);
|
||||||
fragmentHomeBinding.recyclerView.addItemDecoration(itemDecoration);
|
fragmentHomeBinding.recyclerView.addItemDecoration(itemDecoration);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initEvent() {
|
private void initEvent() {
|
||||||
loadCategoryImage();
|
getFirstByName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCategoryImage() {
|
private void getFirstByName() {
|
||||||
paletteViewModel
|
paletteViewModel
|
||||||
.getCategoryFirst()
|
.getFirstByName()
|
||||||
.observe(getViewLifecycleOwner(), new Observer<List<PaletteData>>() {
|
.observe(getViewLifecycleOwner(), new Observer<List<PaletteData>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(List<PaletteData> coolEntities) {
|
public void onChanged(List<PaletteData> coolEntities) {
|
||||||
paletteAdapter.updateData(coolEntities);
|
paletteAdapter.refreshData(coolEntities);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroyView() {
|
||||||
super.onDestroy();
|
super.onDestroyView();
|
||||||
fragmentHomeBinding = null;
|
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 android.content.Context;
|
||||||
|
|
||||||
import com.wallpaper.palettewallpaper.data.database.AppDatabase;
|
import com.wallpaper.palettewallpaper.local.database.AppDatabase;
|
||||||
import com.wallpaper.palettewallpaper.data.database.dao.PaletteDataDao;
|
import com.wallpaper.palettewallpaper.local.database.dao.PaletteDataDao;
|
||||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||||
import com.wallpaper.palettewallpaper.data.database.entiey.SubList;
|
import com.wallpaper.palettewallpaper.local.database.data.SubList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class InsertAll {
|
public class InsertAllUtil {
|
||||||
private final PaletteDataDao paletteDataDao;
|
private final PaletteDataDao paletteDataDao;
|
||||||
|
|
||||||
public InsertAll(Context context) {
|
public InsertAllUtil(Context context) {
|
||||||
AppDatabase db = AppDatabase.getInstance(context);
|
AppDatabase db = AppDatabase.getInstance(context);
|
||||||
paletteDataDao = db.paletteDataDao();
|
paletteDataDao = db.paletteDataDao();
|
||||||
}
|
}
|
||||||
@ -3,8 +3,8 @@ package com.wallpaper.palettewallpaper.util;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.wallpaper.palettewallpaper.MyApplication;
|
import com.wallpaper.palettewallpaper.MyApplication;
|
||||||
import com.wallpaper.palettewallpaper.data.database.entiey.SubList;
|
import com.wallpaper.palettewallpaper.local.database.data.SubList;
|
||||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import android.app.Application;
|
|||||||
import androidx.lifecycle.AndroidViewModel;
|
import androidx.lifecycle.AndroidViewModel;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
|
|
||||||
import com.wallpaper.palettewallpaper.data.database.AppDatabase;
|
import com.wallpaper.palettewallpaper.local.database.AppDatabase;
|
||||||
import com.wallpaper.palettewallpaper.data.database.dao.PaletteDataDao;
|
import com.wallpaper.palettewallpaper.local.database.dao.PaletteDataDao;
|
||||||
import com.wallpaper.palettewallpaper.data.database.entiey.PaletteData;
|
import com.wallpaper.palettewallpaper.local.database.data.PaletteData;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -21,23 +21,23 @@ public class PaletteViewModel extends AndroidViewModel {
|
|||||||
paletteDataDao = db.paletteDataDao();
|
paletteDataDao = db.paletteDataDao();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<PaletteData>> getAllFavoriteList() {
|
public LiveData<List<PaletteData>> getAllFavorite() {
|
||||||
return paletteDataDao.getAllFavoriteLive();
|
return paletteDataDao.getAllFavorite();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<PaletteData>> getCategoryFirst() {
|
public LiveData<List<PaletteData>> getFirstByName() {
|
||||||
return paletteDataDao.getFirstRecordOfEachName();
|
return paletteDataDao.getFirstByName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<PaletteData>> getAllCategory(String name) {
|
public LiveData<List<PaletteData>> getAllCategory(String name) {
|
||||||
return paletteDataDao.getAllCategoryLive(name);
|
return paletteDataDao.getAllCategory(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<Boolean> getWallpaperLike(String source, String name) {
|
public LiveData<Boolean> getLike(String source, String name) {
|
||||||
return paletteDataDao.getWallpaperLike(source, name);
|
return paletteDataDao.getLike(source, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(PaletteData imageEntry) {
|
public void update(PaletteData paletteData) {
|
||||||
paletteDataDao.update(imageEntry);
|
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,9 +1,9 @@
|
|||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<gradient
|
<gradient
|
||||||
android:angle="45"
|
android:angle="45"
|
||||||
android:endColor="#006B8C"
|
android:endColor="#BBDEFB"
|
||||||
android:startColor="#8EE5EE"
|
android:startColor="#F5F5F5"
|
||||||
android:type="linear"
|
android:type="linear"
|
||||||
android:useLevel="false" />
|
android:useLevel="false" />
|
||||||
<corners android:radius="16sp" />
|
<corners android:radius="16sp" />
|
||||||
</shape>
|
</shape>
|
||||||
@ -5,8 +5,8 @@
|
|||||||
android:viewportHeight="1024">
|
android:viewportHeight="1024">
|
||||||
<path
|
<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: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
|
<path
|
||||||
android:pathData="M640,292.3a32,32 0,1 0,32 32,32 32,0 0,0 -32,-32z"
|
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>
|
</vector>
|
||||||
|
|||||||
@ -5,22 +5,21 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/blue_black"
|
|
||||||
tools:context=".ui.activity.MainActivity">
|
tools:context=".ui.activity.MainActivity">
|
||||||
|
|
||||||
<androidx.viewpager2.widget.ViewPager2
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
android:id="@+id/main_viewpager2"
|
android:id="@+id/view_pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="8dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/main_tab_layout"
|
app:layout_constraintBottom_toTopOf="@+id/tab_layout"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<com.google.android.material.tabs.TabLayout
|
||||||
android:id="@+id/main_tab_layout"
|
android:id="@+id/tab_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="125dp"
|
android:layout_height="125dp"
|
||||||
android:layout_marginBottom="25dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:tabIndicatorHeight="0dp"
|
app:tabIndicatorHeight="0dp"
|
||||||
|
|||||||
@ -15,61 +15,64 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/back"
|
android:id="@+id/back"
|
||||||
android:layout_width="30dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="32dp"
|
||||||
android:layout_marginStart="32dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="64dp"
|
android:layout_marginTop="48dp"
|
||||||
android:src="@drawable/back"
|
android:src="@drawable/back"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/like"
|
android:id="@+id/action_bar"
|
||||||
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"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="32dp"
|
android:layout_marginBottom="32dp"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/set"
|
android:background="@drawable/rounded_rectangle_gradient_blue"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/set">
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
<ProgressBar
|
android:paddingStart="4dp"
|
||||||
android:id="@+id/down_progress"
|
android:paddingTop="2dp"
|
||||||
android:layout_width="24dp"
|
android:paddingEnd="4dp"
|
||||||
android:layout_height="24dp"
|
android:paddingBottom="2dp"
|
||||||
android:indeterminateTint="@color/black"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
android:visibility="gone"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="60dp"
|
android:id="@+id/like"
|
||||||
android:layout_height="60dp"
|
android:layout_width="56dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
android:layout_height="56dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:layout_marginHorizontal="32dp"
|
||||||
android:src="@drawable/download" />
|
android:src="@drawable/un_like" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
<ImageView
|
<FrameLayout
|
||||||
android:id="@+id/set"
|
android:id="@+id/down"
|
||||||
android:layout_width="60dp"
|
android:layout_width="56dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="56dp">
|
||||||
android:layout_marginBottom="32dp"
|
|
||||||
android:src="@drawable/apply"
|
<ImageView
|
||||||
android:padding="5dp"
|
android:layout_width="match_parent"
|
||||||
android:background="@drawable/rounded_rectangle_gradient"
|
android:layout_height="match_parent"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/like"
|
android:src="@drawable/download" />
|
||||||
app:layout_constraintEnd_toEndOf="@+id/like" />
|
|
||||||
|
<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
|
<ImageView
|
||||||
android:id="@+id/view"
|
android:id="@+id/view"
|
||||||
@ -89,4 +92,4 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@ -5,26 +5,25 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/blue_black"
|
|
||||||
tools:context=".ui.activity.SecondActivity">
|
tools:context=".ui.activity.SecondActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/back"
|
android:id="@+id/back"
|
||||||
android:layout_width="30dp"
|
android:layout_width="30dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:layout_marginStart="25dp"
|
android:layout_marginStart="24dp"
|
||||||
android:src="@drawable/back"
|
android:src="@drawable/back"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/text"
|
app:layout_constraintBottom_toBottomOf="@+id/title"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/text" />
|
app:layout_constraintTop_toTopOf="@+id/title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="24dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/black"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:text="@string/app_name"
|
android:text="@string/app_name"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@ -37,6 +36,6 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
app:layout_constraintTop_toBottomOf="@+id/title" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -5,7 +5,6 @@
|
|||||||
android:id="@+id/main"
|
android:id="@+id/main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/blue_black"
|
|
||||||
tools:context=".ui.activity.SplashActivity">
|
tools:context=".ui.activity.SplashActivity">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -27,7 +26,7 @@
|
|||||||
android:textSize="25sp"
|
android:textSize="25sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/black"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/image" />
|
app:layout_constraintTop_toBottomOf="@+id/image" />
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
android:layout_width="250dp"
|
android:layout_width="250dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@drawable/rounded_rectangle_gradient">
|
android:background="@drawable/rounded_rectangle_gradient_blue">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
tools:context=".ui.fragment.FavoriteFragment">
|
||||||
tools:context=".ui.fragment.CollectionFragment">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="24dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="COLLECTION"
|
android:text="FAVORITE"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/black"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@ -26,6 +26,6 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
app:layout_constraintTop_toBottomOf="@+id/title" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -7,13 +7,13 @@
|
|||||||
tools:context=".ui.fragment.HomeFragment">
|
tools:context=".ui.fragment.HomeFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="24dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="HOME"
|
android:text="HOME"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/black"
|
||||||
android:textSize="24sp"
|
android:textSize="24sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@ -26,6 +26,6 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="25dp"
|
android:layout_marginTop="25dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/text" />
|
app:layout_constraintTop_toBottomOf="@+id/title" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -6,8 +6,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image_view"
|
android:id="@+id/image_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
android:scaleType="fitXY"/>
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/favorite"
|
android:id="@+id/favorite"
|
||||||
@ -7,8 +7,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageview"
|
android:id="@+id/imageview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
android:scaleType="fitXY" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/category_title"
|
android:id="@+id/category_title"
|
||||||
@ -16,9 +15,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="20dp"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
|
android:maxLines="2"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:maxLines="2"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
@ -3,5 +3,4 @@
|
|||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
<color name="gray">#9C979D</color>
|
<color name="gray">#9C979D</color>
|
||||||
<color name="blue_black">#0D1B2A</color>
|
|
||||||
</resources>
|
</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