V1.0.2(4) 添加选择本地图片功能,优化
This commit is contained in:
parent
de061ce66e
commit
65323628ff
@ -15,8 +15,8 @@ android {
|
||||
minSdk = 23
|
||||
//noinspection OldTargetApi
|
||||
targetSdk = 34
|
||||
versionCode = 3
|
||||
versionName = "1.0.1"
|
||||
versionCode = 4
|
||||
versionName = "1.0.2"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
setProperty("archivesBaseName", "WallpapersHaven_V" + versionName + "(${versionCode})_$timestamp")
|
||||
}
|
||||
|
||||
4
app/proguard-rules.pro
vendored
4
app/proguard-rules.pro
vendored
@ -27,10 +27,10 @@
|
||||
-keepclassmembers class * {
|
||||
@androidx.room.Query <methods>;
|
||||
}
|
||||
-keep class com.lh.wallpaper2.entity.AppDatabase { *; }
|
||||
-keep class com.lh.wallpaper2.room.AppDatabase { *; }
|
||||
-keep class com.lh.wallpaper2.json.Info { *; }
|
||||
-keepclassmembers class com.lh.wallpaper2.json.Url { *; }
|
||||
-keep class com.lh.wallpaper2.db.Favorite { *; }
|
||||
-keep class com.lh.wallpaper2.room.Favorite { *; }
|
||||
|
||||
-keep class com.google.gson.** { *; }
|
||||
-keepattributes Signature
|
||||
|
||||
@ -4,9 +4,11 @@
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.SET_WALLPAPER" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32"
|
||||
@ -23,6 +25,9 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Wallpaper2"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".SettingActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".PrivacyActivity"
|
||||
android:exported="false" />
|
||||
|
||||
@ -40,7 +40,14 @@ public class DetailsActivity extends AppCompatActivity implements UrlWallpaperLi
|
||||
info = (Info) getIntent().getSerializableExtra(StaticValue.key_info);
|
||||
Log.d("99999999999", "onCreate: " + info.getList().size());
|
||||
if (info != null) {
|
||||
textView.setText(info.getName());
|
||||
String name = info.getName();
|
||||
if (name != null && !name.isEmpty()) {
|
||||
// 将首字母转换为大写,其他字母保持不变
|
||||
String capitalized = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
textView.setText(capitalized);
|
||||
} else {
|
||||
textView.setText(name); // 如果 name 为 null 或空,直接设置
|
||||
}
|
||||
Log.d("99999999999", "onCreate: " + info.getName());
|
||||
}
|
||||
setRecyclerView();
|
||||
|
||||
@ -23,7 +23,6 @@ import java.lang.annotation.Annotation;
|
||||
public class InitialActivity extends AppCompatActivity {
|
||||
private ProgressBar progressBar;
|
||||
// private int progressStatus = 0;
|
||||
private CountDownTimer countDownTimer;
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
private int progressStatus = 0;
|
||||
|
||||
@ -53,6 +52,7 @@ public class InitialActivity extends AppCompatActivity {
|
||||
}
|
||||
Intent intent = new Intent(InitialActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.google.android.material.navigation.NavigationBarView;
|
||||
import com.lh.wallpaper2.fragment.FavoriteFragment;
|
||||
import com.lh.wallpaper2.fragment.HomeFragment;
|
||||
import com.lh.wallpaper2.fragment.ImportFragment;
|
||||
import com.lh.wallpaper2.fragment.SettingFragment;
|
||||
import com.lh.wallpaper2.adapter.MyFragmentStateAdapter;
|
||||
|
||||
@ -40,8 +41,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
viewPager = findViewById(R.id.viewPager);
|
||||
List<Fragment> fragments = new ArrayList<>();
|
||||
fragments.add(new HomeFragment());
|
||||
fragments.add(new ImportFragment());
|
||||
fragments.add(new FavoriteFragment());
|
||||
fragments.add(new SettingFragment());
|
||||
//若跳转多个界面添加多个fragment
|
||||
MyFragmentStateAdapter adapter = new MyFragmentStateAdapter(getSupportFragmentManager(), fragments);
|
||||
viewPager.setAdapter(adapter);
|
||||
@ -52,9 +53,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.navigation_home) {
|
||||
viewPager.setCurrentItem(0);
|
||||
} if (item.getItemId() == R.id.navigation_favorite){
|
||||
} if (item.getItemId() == R.id.navigation_import){
|
||||
viewPager.setCurrentItem(1);
|
||||
} if (item.getItemId() == R.id.navigation_setting) {
|
||||
} if (item.getItemId() == R.id.navigation_favorite) {
|
||||
viewPager.setCurrentItem(2);
|
||||
}
|
||||
return true;
|
||||
@ -72,10 +73,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
navigationView.setSelectedItemId(R.id.navigation_home);
|
||||
break;
|
||||
case 1:
|
||||
navigationView.setSelectedItemId(R.id.navigation_favorite);
|
||||
navigationView.setSelectedItemId(R.id.navigation_import);
|
||||
break;
|
||||
case 2:
|
||||
navigationView.setSelectedItemId(R.id.navigation_setting);
|
||||
navigationView.setSelectedItemId(R.id.navigation_favorite);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
92
app/src/main/java/com/lh/wallpaper2/SettingActivity.java
Normal file
92
app/src/main/java/com/lh/wallpaper2/SettingActivity.java
Normal file
@ -0,0 +1,92 @@
|
||||
package com.lh.wallpaper2;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class SettingActivity extends AppCompatActivity {
|
||||
private RelativeLayout about;
|
||||
private RelativeLayout feedBack;
|
||||
private RelativeLayout privacy;
|
||||
private ImageView back;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_setting); // 新布局文件
|
||||
|
||||
about = findViewById(R.id.about);
|
||||
feedBack = findViewById(R.id.feedback);
|
||||
privacy = findViewById(R.id.Privacy);
|
||||
back = findViewById(R.id.setting_back);
|
||||
|
||||
back.setOnClickListener(v -> {finish();});
|
||||
|
||||
privacy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(SettingActivity.this, PrivacyActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
about.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
about();
|
||||
}
|
||||
});
|
||||
|
||||
feedBack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@SuppressLint("IntentWithNullActionLaunch")
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName()));
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void about() {
|
||||
final AlertDialog dialog;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("About");
|
||||
|
||||
builder.setMessage("The current version is " + getVersion());
|
||||
builder.setPositiveButton("CONFIRM", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss(); //关闭对话框
|
||||
}
|
||||
});
|
||||
dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
try {
|
||||
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
return packageInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
package com.lh.wallpaper2;
|
||||
import android.Manifest;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Intent;
|
||||
@ -13,6 +13,7 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -21,19 +22,22 @@ import androidx.cardview.widget.CardView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.lh.wallpaper2.dao.TaskDao;
|
||||
import com.lh.wallpaper2.db.Favorite;
|
||||
import com.lh.wallpaper2.room.TaskDao;
|
||||
import com.lh.wallpaper2.room.Favorite;
|
||||
import com.lh.wallpaper2.download.ImageDownloadTask;
|
||||
import com.lh.wallpaper2.entity.AppDatabase;
|
||||
import com.lh.wallpaper2.room.AppDatabase;
|
||||
import com.lh.wallpaper2.fragment.PreviewFragment;
|
||||
import com.lh.wallpaper2.json.Url;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ViewActivity extends AppCompatActivity {
|
||||
private ArrayList<Url> url;
|
||||
private int position;
|
||||
@ -51,8 +55,10 @@ public class ViewActivity extends AppCompatActivity {
|
||||
private Favorite info;
|
||||
private Url homeInfo;
|
||||
private String topInfo;
|
||||
private String importurl;
|
||||
private ImageDownloadTask downloadTask;
|
||||
private ProgressBar process;
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -67,10 +73,11 @@ public class ViewActivity extends AppCompatActivity {
|
||||
download = findViewById(R.id.download);
|
||||
collect = findViewById(R.id.collection);
|
||||
textViewLoading = findViewById(R.id.textview_loading);
|
||||
process=findViewById(R.id.progressbar);
|
||||
process = findViewById(R.id.progressbar);
|
||||
//初始化db
|
||||
initDb();
|
||||
topInfo=(String) getIntent().getSerializableExtra("top_info");
|
||||
topInfo = (String) getIntent().getSerializableExtra("top_info");
|
||||
importurl = (String) getIntent().getSerializableExtra("import");
|
||||
info = (Favorite) getIntent().getSerializableExtra("info");
|
||||
url = (ArrayList<Url>) getIntent().getSerializableExtra(StaticValue.key_picture);
|
||||
homeInfo = (Url) getIntent().getSerializableExtra("home_info");
|
||||
@ -79,14 +86,18 @@ public class ViewActivity extends AppCompatActivity {
|
||||
if (info != null) {
|
||||
selectPreImg = info.getPicture();
|
||||
judge();
|
||||
} else if (homeInfo != null) {
|
||||
}else if (importurl != null){
|
||||
download.setVisibility(View.GONE);
|
||||
selectPreImg = importurl;
|
||||
judge();
|
||||
}
|
||||
else if (homeInfo != null) {
|
||||
selectPreImg = homeInfo.getSourceUrl();
|
||||
judge();
|
||||
} else if (topInfo != null) {
|
||||
selectPreImg = topInfo;
|
||||
judge();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
selectPreImg = url.get(position).getSourceUrl();
|
||||
judge();
|
||||
}
|
||||
@ -172,9 +183,10 @@ public class ViewActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initDb() {
|
||||
//初始化db
|
||||
AppDatabase db = AppDatabase.getDatabase(this);
|
||||
AppDatabase db = AppDatabase.getInstance(this);
|
||||
dao = db.taskDao();
|
||||
}
|
||||
|
||||
@ -184,7 +196,7 @@ public class ViewActivity extends AppCompatActivity {
|
||||
public void run() {
|
||||
Log.d("2323232", "run: " + selectPreImg);
|
||||
if (dao.getTaskByUrl(selectPreImg) != null) {
|
||||
Log.d("2323232", "run: "+dao.getTaskByUrl(selectPreImg));
|
||||
Log.d("2323232", "run: " + dao.getTaskByUrl(selectPreImg));
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -201,6 +213,7 @@ public class ViewActivity extends AppCompatActivity {
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.load(selectPreImg)
|
||||
.centerInside()
|
||||
.into(new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package com.lh.wallpaper2.action;
|
||||
|
||||
|
||||
import com.lh.wallpaper2.db.Favorite;
|
||||
import com.lh.wallpaper2.room.Favorite;
|
||||
|
||||
public interface FavoriteWallpaperListener {
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ public class DetailsAdapter extends RecyclerView.Adapter<DetailsWallpaperVH> {
|
||||
Glide.with(myContext)
|
||||
.load(info.getPreUrl())
|
||||
.transform(new RoundedCorners(ReadFile.dp2Px(7)))
|
||||
.placeholder(R.drawable.preview)
|
||||
.into(imageView);
|
||||
holder.getItemRoot().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@ -13,7 +13,7 @@ import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.lh.wallpaper2.R;
|
||||
import com.lh.wallpaper2.action.FavoriteWallpaperListener;
|
||||
import com.lh.wallpaper2.db.Favorite;
|
||||
import com.lh.wallpaper2.room.Favorite;
|
||||
import com.lh.wallpaper2.file.ReadFile;
|
||||
import com.lh.wallpaper2.recycleView.DetailsWallpaperVH;
|
||||
|
||||
@ -45,6 +45,7 @@ public class FavoriteWallpaperAdapter extends RecyclerView.Adapter<DetailsWallpa
|
||||
Glide.with(myContext)
|
||||
.load(info.getPicture())
|
||||
.transform(new RoundedCorners(ReadFile.dp2Px(7)))
|
||||
.placeholder(R.drawable.preview)
|
||||
.into(imageView);
|
||||
holder.getItemRoot().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,109 @@
|
||||
package com.lh.wallpaper2.adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
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.engine.DiskCacheStrategy;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.lh.wallpaper2.R;
|
||||
import com.lh.wallpaper2.ViewActivity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ImageRecyclerViewAdapter extends RecyclerView.Adapter<ImageRecyclerViewAdapter.ViewHolder> {
|
||||
private List<String> imagePaths;
|
||||
private final Activity context;
|
||||
private OnImageDeleteListener onImageDeleteListener; // 删除监听器
|
||||
|
||||
public ImageRecyclerViewAdapter(List<String> imagePaths, Activity context) {
|
||||
this.imagePaths = imagePaths;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_import, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
String imagePath = imagePaths.get(position);
|
||||
|
||||
RequestOptions requestOptions = new RequestOptions()
|
||||
.transform(new CenterCrop(), new RoundedCorners(20)); // 20 是圆角半径
|
||||
|
||||
if (imagePath.startsWith("/data/user/")) {
|
||||
Glide.with(context)
|
||||
.load(imagePath)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.apply(requestOptions)
|
||||
.placeholder(R.drawable.preview)
|
||||
.into(holder.imageView);
|
||||
} else {
|
||||
Glide.with(context)
|
||||
.load("file:///android_asset/" + imagePath)
|
||||
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||
.apply(requestOptions)
|
||||
.placeholder(R.drawable.preview)
|
||||
.into(holder.imageView);
|
||||
}
|
||||
|
||||
holder.imageView.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ViewActivity.class);
|
||||
intent.putExtra("import", imagePath);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
|
||||
// 设置删除按钮的点击事件
|
||||
holder.delete.setOnClickListener(v -> {
|
||||
int adapterPosition = holder.getAdapterPosition(); // 动态获取当前位置
|
||||
if (adapterPosition != RecyclerView.NO_POSITION && onImageDeleteListener != null) {
|
||||
onImageDeleteListener.onImageDelete(imagePaths.get(adapterPosition)); // 调用删除回调
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return imagePaths.size();
|
||||
}
|
||||
|
||||
// 更新数据并通知数据集更改
|
||||
public void updateImagePaths(List<String> newImagePaths) {
|
||||
this.imagePaths = newImagePaths;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
// 设置删除监听器
|
||||
public void setOnImageDeleteListener(OnImageDeleteListener listener) {
|
||||
this.onImageDeleteListener = listener;
|
||||
}
|
||||
|
||||
public interface OnImageDeleteListener {
|
||||
void onImageDelete(String imagePath);
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView imageView;
|
||||
ImageView delete;
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
imageView = view.findViewById(R.id.imageView_wallpaper);
|
||||
delete = view.findViewById(R.id.delete);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,6 +38,7 @@ public class InfoWallpaperAdapter extends RecyclerView.Adapter<InfoWallpaperVH>
|
||||
public void setInfoWallpaperListener(InfoWallpaperListener infoWallpaperListener) {
|
||||
this.infoWallpaperListener = infoWallpaperListener;
|
||||
}
|
||||
|
||||
public InfoWallpaperAdapter(List<Info> infoList, Context myCon) {
|
||||
dataInfo = infoList;
|
||||
myContext = myCon;
|
||||
@ -53,7 +54,16 @@ public class InfoWallpaperAdapter extends RecyclerView.Adapter<InfoWallpaperVH>
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull InfoWallpaperVH holder, int position) {
|
||||
Info info = dataInfo.get(position);
|
||||
holder.getText().setText(info.getName());
|
||||
String name = info.getName();
|
||||
|
||||
if (name != null && !name.isEmpty()) {
|
||||
// 将首字母转换为大写,其他字母保持不变
|
||||
String capitalized = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
holder.getText().setText(capitalized);
|
||||
} else {
|
||||
holder.getText().setText(name); // 如果 name 为 null 或空,直接设置
|
||||
}
|
||||
|
||||
ImageView leftImage = holder.getLeftImage();
|
||||
ImageView rightImage = holder.getRightImage();
|
||||
Url homeLeftUrl = info.getList().get(0);
|
||||
|
||||
@ -19,9 +19,9 @@ import com.lh.wallpaper2.R;
|
||||
import com.lh.wallpaper2.ViewActivity;
|
||||
import com.lh.wallpaper2.action.FavoriteWallpaperListener;
|
||||
import com.lh.wallpaper2.adapter.FavoriteWallpaperAdapter;
|
||||
import com.lh.wallpaper2.dao.TaskDao;
|
||||
import com.lh.wallpaper2.db.Favorite;
|
||||
import com.lh.wallpaper2.entity.AppDatabase;
|
||||
import com.lh.wallpaper2.room.TaskDao;
|
||||
import com.lh.wallpaper2.room.Favorite;
|
||||
import com.lh.wallpaper2.room.AppDatabase;
|
||||
import com.lh.wallpaper2.file.MyItemSpace;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -47,7 +47,7 @@ public class FavoriteFragment extends Fragment implements FavoriteWallpaperListe
|
||||
likeBackground = view.findViewById(R.id.like_background);
|
||||
likeText = view.findViewById(R.id.like_text);
|
||||
|
||||
db = AppDatabase.getDatabase(requireContext());
|
||||
db = AppDatabase.getInstance(requireContext());
|
||||
dao = db.taskDao();
|
||||
setRecyclerviewWallpaper();
|
||||
loadFavoriteImages();
|
||||
|
||||
@ -17,6 +17,7 @@ import android.widget.RelativeLayout;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.lh.wallpaper2.DetailsActivity;
|
||||
import com.lh.wallpaper2.R;
|
||||
import com.lh.wallpaper2.SettingActivity;
|
||||
import com.lh.wallpaper2.StaticValue;
|
||||
import com.lh.wallpaper2.ViewActivity;
|
||||
import com.lh.wallpaper2.Wallpaper;
|
||||
@ -30,10 +31,13 @@ public class HomeFragment extends Fragment implements InfoWallpaperListener {
|
||||
private Info info;
|
||||
private RelativeLayout relativeLayout;
|
||||
private ImageView imageView;
|
||||
private ImageView setting;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@SuppressLint("MissingInflatedId")
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
@ -41,19 +45,28 @@ public class HomeFragment extends Fragment implements InfoWallpaperListener {
|
||||
View view = inflater.inflate(R.layout.fragment_home, container, false);
|
||||
recyclerView = view.findViewById(R.id.home_recyclerView);
|
||||
relativeLayout = view.findViewById(R.id.top_info);
|
||||
info=Wallpaper.getUserList().get(14);
|
||||
setting = view.findViewById(R.id.setting);
|
||||
info = Wallpaper.getUserList().get(14);
|
||||
String topInfo = info.getList().get(0).getSourceUrl();
|
||||
setRecyclerView();
|
||||
imageView=view.findViewById(R.id.top_image);
|
||||
imageView = view.findViewById(R.id.top_image);
|
||||
Glide.with(requireContext()).load(topInfo).into(imageView);
|
||||
relativeLayout.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(requireContext(), ViewActivity.class);
|
||||
intent.putExtra("top_info",topInfo);
|
||||
intent.putExtra("top_info", topInfo);
|
||||
startActivity(intent);
|
||||
});
|
||||
setting.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(requireContext(), SettingActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
private void setRecyclerView(){
|
||||
|
||||
private void setRecyclerView() {
|
||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(requireContext(), 1);
|
||||
InfoWallpaperAdapter infoWallpaperAdapter = new InfoWallpaperAdapter(Wallpaper.getUserList(), requireContext());
|
||||
infoWallpaperAdapter.setInfoWallpaperListener(this);
|
||||
@ -64,14 +77,14 @@ public class HomeFragment extends Fragment implements InfoWallpaperListener {
|
||||
@Override
|
||||
public void onItemClickAction(Info info) {
|
||||
Intent intent = new Intent(requireContext(), DetailsActivity.class);
|
||||
intent.putExtra(StaticValue.key_info,info);
|
||||
intent.putExtra(StaticValue.key_info, info);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHomeInfoClickAction(Url info) {
|
||||
Intent intent = new Intent(requireContext(), ViewActivity.class);
|
||||
intent.putExtra("home_info",info);
|
||||
intent.putExtra("home_info", info);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
231
app/src/main/java/com/lh/wallpaper2/fragment/ImportFragment.java
Normal file
231
app/src/main/java/com/lh/wallpaper2/fragment/ImportFragment.java
Normal file
@ -0,0 +1,231 @@
|
||||
package com.lh.wallpaper2.fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lh.wallpaper2.R;
|
||||
import com.lh.wallpaper2.adapter.ImageRecyclerViewAdapter;
|
||||
import com.lh.wallpaper2.file.MyItemSpace;
|
||||
import com.lh.wallpaper2.room.AppDatabase;
|
||||
import com.lh.wallpaper2.room.ImageEntry;
|
||||
import com.lh.wallpaper2.room.ImageEntryDao;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImportFragment extends Fragment {
|
||||
|
||||
private static final int PICK_IMAGE_REQUEST_CODE = 202; // 请求码,用于标识图片选择
|
||||
private ImageView btnSelectImage; // 选择图片按钮
|
||||
private RecyclerView recyclerView; // 显示图片的 RecyclerView
|
||||
private ImageRecyclerViewAdapter adapter; // 图片适配器
|
||||
private List<String> imagePaths = new ArrayList<>(); // 图片路径列表
|
||||
private AppDatabase appDatabase; // 数据库实例
|
||||
private ImageEntryDao imageEntryDao; // 图片条目 DAO
|
||||
private LinearLayout linearLayout; // 空视图
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
// 加载 Fragment 的布局
|
||||
View view = inflater.inflate(R.layout.fragment_import, container, false);
|
||||
|
||||
// 初始化控件
|
||||
btnSelectImage = view.findViewById(R.id.btn_select_image);
|
||||
recyclerView = view.findViewById(R.id.recycler_view);
|
||||
linearLayout = view.findViewById(R.id.empty);
|
||||
|
||||
// 设置 RecyclerView 的布局管理器和适配器
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2)); // 网格布局,每行显示两个图片
|
||||
MyItemSpace itemDecoration = new MyItemSpace(30, 50, 40);
|
||||
recyclerView.addItemDecoration(itemDecoration);
|
||||
|
||||
adapter = new ImageRecyclerViewAdapter(imagePaths, requireActivity());
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
// 设置选择图片按钮的点击事件
|
||||
btnSelectImage.setOnClickListener(v -> openImagePicker());
|
||||
|
||||
// 初始化数据库和 DAO
|
||||
appDatabase = AppDatabase.getInstance(requireContext());
|
||||
imageEntryDao = appDatabase.imageEntryDao();
|
||||
|
||||
// 加载图片路径
|
||||
loadImagePaths();
|
||||
|
||||
// 设置图片删除监听器
|
||||
adapter.setOnImageDeleteListener(imagePath -> {
|
||||
// 从数据库中删除图片记录
|
||||
new Thread(() -> {
|
||||
// 删除本地存储中的图片文件
|
||||
File imageFile = new File(imagePath);
|
||||
if (imageFile.exists() && imageFile.delete()) { // 删除文件,成功返回 true
|
||||
// 文件删除成功后,再删除数据库中的图片记录和更新列表
|
||||
imageEntryDao.deleteByPath(imagePath); // 删除数据库中的图片记录
|
||||
imagePaths.remove(imagePath); // 从列表中删除图片路径
|
||||
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
adapter.updateImagePaths(imagePaths); // 更新 RecyclerView
|
||||
setView(!imagePaths.isEmpty()); // 更新视图
|
||||
Toast.makeText(getContext(), "Image deleted", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
} else {
|
||||
// 文件删除失败时的处理
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
Toast.makeText(getContext(), "Failed to delete image file", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
adapter.notifyDataSetChanged(); // 重新加载适配器内容
|
||||
}
|
||||
|
||||
// 打开图片选择器
|
||||
private void openImagePicker() {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
||||
startActivityForResult(intent, PICK_IMAGE_REQUEST_CODE); // 启动选择图片的活动
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_IMAGE_REQUEST_CODE && resultCode == getActivity().RESULT_OK && data != null) {
|
||||
Uri selectedImageUri = data.getData(); // 获取选中的图片 URI
|
||||
if (selectedImageUri != null) {
|
||||
try {
|
||||
if (isImageSizeAcceptable(selectedImageUri)) {
|
||||
saveImageToInternalStorage(selectedImageUri); // 保存图片到内部存储
|
||||
} else {
|
||||
Toast.makeText(getContext(), "图片大小超过限制", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(getContext(), "无法获取图片大小: " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查图片大小是否在允许范围内
|
||||
private boolean isImageSizeAcceptable(Uri uri) throws IOException {
|
||||
InputStream inputStream = requireContext().getContentResolver().openInputStream(uri);
|
||||
if (inputStream == null) {
|
||||
return false;
|
||||
}
|
||||
long fileSize = inputStream.available();
|
||||
inputStream.close();
|
||||
long maxFileSize = 10 * 1024 * 1024; // 最大 10MB
|
||||
return fileSize <= maxFileSize;
|
||||
}
|
||||
|
||||
// 将选中的图片保存到内部存储
|
||||
private void saveImageToInternalStorage(Uri uri) {
|
||||
try {
|
||||
InputStream inputStream = requireContext().getContentResolver().openInputStream(uri);
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
if (bitmap == null) {
|
||||
Toast.makeText(getContext(), "无法加载图片", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
File internalStorageDir = requireContext().getFilesDir();
|
||||
File imageFile = new File(internalStorageDir, System.currentTimeMillis() + ".jpg");
|
||||
FileOutputStream outputStream = new FileOutputStream(imageFile);
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
|
||||
String imagePath = imageFile.getAbsolutePath();
|
||||
new Thread(() -> {
|
||||
if (isImageAlreadyExists(imagePath)) {
|
||||
requireActivity().runOnUiThread(() -> Toast.makeText(getContext(), "该图片已经存在", Toast.LENGTH_SHORT).show());
|
||||
imageFile.delete();
|
||||
return;
|
||||
}
|
||||
imagePaths.add(imagePath);
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
adapter.updateImagePaths(imagePaths);
|
||||
setView(!imagePaths.isEmpty());
|
||||
});
|
||||
imageEntryDao.insert(new ImageEntry(imagePath));
|
||||
}).start();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(getContext(), "保存图片失败: " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
// 检查图片是否已经存在
|
||||
private boolean isImageAlreadyExists(String imagePath) {
|
||||
File newImageFile = new File(imagePath);
|
||||
for (String path : imagePaths) {
|
||||
File existingFile = new File(path);
|
||||
if (filesAreIdentical(existingFile, newImageFile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
List<ImageEntry> imageEntries = imageEntryDao.getAllImages();
|
||||
for (ImageEntry imageEntry : imageEntries) {
|
||||
File existingFile = new File(imageEntry.getImagePath());
|
||||
if (filesAreIdentical(existingFile, newImageFile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 比较两个文件是否相同
|
||||
private boolean filesAreIdentical(File file1, File file2) {
|
||||
return file1.length() == file2.length(); // 比较文件长度
|
||||
}
|
||||
|
||||
// 加载图片路径列表
|
||||
private void loadImagePaths() {
|
||||
new Thread(() -> {
|
||||
imagePaths.clear(); // 清空列表,防止重复添加
|
||||
List<ImageEntry> imageEntries = imageEntryDao.getAllImages();
|
||||
for (ImageEntry imageEntry : imageEntries) {
|
||||
imagePaths.add(imageEntry.getImagePath()); // 添加路径到列表
|
||||
}
|
||||
requireActivity().runOnUiThread(() -> {
|
||||
adapter.updateImagePaths(imagePaths);
|
||||
setView(!imagePaths.isEmpty());
|
||||
});
|
||||
}).start();
|
||||
}
|
||||
|
||||
// 更新视图,切换空视图与图片视图
|
||||
private void setView(Boolean hasData) {
|
||||
if (hasData) {
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
linearLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
linearLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.lh.wallpaper2.entity;
|
||||
package com.lh.wallpaper2.room;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@ -6,16 +6,14 @@ import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.lh.wallpaper2.dao.TaskDao;
|
||||
import com.lh.wallpaper2.db.Favorite;
|
||||
|
||||
@Database(entities = {Favorite.class}, version = 1)
|
||||
@Database(entities = {Favorite.class, ImageEntry.class}, version = 1)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
public abstract TaskDao taskDao();
|
||||
public abstract ImageEntryDao imageEntryDao();
|
||||
|
||||
private static volatile AppDatabase INSTANCE;
|
||||
|
||||
public static AppDatabase getDatabase(final Context context) {
|
||||
public static AppDatabase getInstance(final Context context) {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (AppDatabase.class) {
|
||||
if (INSTANCE == null) {
|
||||
@ -1,4 +1,4 @@
|
||||
package com.lh.wallpaper2.db;
|
||||
package com.lh.wallpaper2.room;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
31
app/src/main/java/com/lh/wallpaper2/room/ImageEntry.java
Normal file
31
app/src/main/java/com/lh/wallpaper2/room/ImageEntry.java
Normal file
@ -0,0 +1,31 @@
|
||||
package com.lh.wallpaper2.room;
|
||||
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
@Entity(tableName = "image_entry")
|
||||
public class ImageEntry {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
private int id;
|
||||
private String imagePath;
|
||||
|
||||
public ImageEntry(String imagePath) {
|
||||
this.imagePath = imagePath;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getImagePath() {
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
public void setImagePath(String imagePath) {
|
||||
this.imagePath = imagePath;
|
||||
}
|
||||
}
|
||||
26
app/src/main/java/com/lh/wallpaper2/room/ImageEntryDao.java
Normal file
26
app/src/main/java/com/lh/wallpaper2/room/ImageEntryDao.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.lh.wallpaper2.room;
|
||||
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Delete;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public interface ImageEntryDao {
|
||||
@Insert
|
||||
void insert(ImageEntry imageEntry);
|
||||
|
||||
@Delete
|
||||
void delete(ImageEntry imageEntry);
|
||||
|
||||
@Query("SELECT * FROM image_entry")
|
||||
List<ImageEntry> getAllImages();
|
||||
|
||||
@Query("SELECT * FROM image_entry WHERE imagePath = :imagePath LIMIT 1")
|
||||
ImageEntry findByPath(String imagePath);
|
||||
|
||||
@Query("DELETE FROM image_entry WHERE imagePath = :imagePath")
|
||||
void deleteByPath(String imagePath);
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
package com.lh.wallpaper2.dao;
|
||||
package com.lh.wallpaper2.room;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Update;
|
||||
import com.lh.wallpaper2.db.Favorite;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
9
app/src/main/res/drawable/_delete.xml
Normal file
9
app/src/main/res/drawable/_delete.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M630.1,151.9L630.1,62.2L361.8,62.2v89.7L93.6,151.9v134.6h89.4v673.1h625.9v-673.1h89.4L898.4,151.9L630.1,151.9zM361.8,869.9h-89.4L272.4,286.5h89.4v583.4zM540.7,869.9h-89.4L451.3,286.5h89.4v583.4zM719.5,869.9h-89.4L630.1,286.5h89.4v583.4z"
|
||||
android:fillColor="#FA596F"/>
|
||||
</vector>
|
||||
37
app/src/main/res/drawable/frame.xml
Normal file
37
app/src/main/res/drawable/frame.xml
Normal file
File diff suppressed because one or more lines are too long
19
app/src/main/res/drawable/import_icon.xml
Normal file
19
app/src/main/res/drawable/import_icon.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
|
||||
<path
|
||||
android:pathData="M517.1,460.3v-116.4a23.3,23.3 0,0 0,-46.5 0v116.4a93.1,93.1 0,0 0,93.1 93.1h116.4a23.3,23.3 0,0 0,0 -46.5h-116.4a39.6,39.6 0,0 1,-11.9 -1.9l247.9,-247.9A23.3,23.3 0,0 0,768 224.3L519,472.2a39.6,39.6 0,0 1,-1.9 -11.9z"
|
||||
android:fillColor="#E22F60"
|
||||
android:strokeColor="#E22F60"
|
||||
android:strokeWidth="10"/>
|
||||
|
||||
<path
|
||||
android:pathData="M861.1,395.6a23.3,23.3 0,0 0,-23.3 23.3v372.4a46.5,46.5 0,0 1,-46.5 46.5H232.7a46.5,46.5 0,0 1,-46.5 -46.5V232.7a46.5,46.5 0,0 1,46.5 -46.5h372.4a23.3,23.3 0,0 0,0 -46.5H232.7a93.1,93.1 0,0 0,-93.1 93.1v558.5a93.1,93.1 0,0 0,93.1 93.1h558.5a93.1,93.1 0,0 0,93.1 -93.1V418.9a23.3,23.3 0,0 0,-23.3 -23.3z"
|
||||
android:fillColor="#E22F60"
|
||||
android:strokeColor="#E22F60"
|
||||
android:strokeWidth="10"/>
|
||||
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/setting.xml
Normal file
9
app/src/main/res/drawable/setting.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M4,11H20C20.265,11 20.52,11.105 20.707,11.293C20.895,11.48 21,11.735 21,12C21,12.265 20.895,12.52 20.707,12.707C20.52,12.895 20.265,13 20,13H4C3.735,13 3.48,12.895 3.293,12.707C3.105,12.52 3,12.265 3,12C3,11.735 3.105,11.48 3.293,11.293C3.48,11.105 3.735,11 4,11ZM4,4H18C18.265,4 18.52,4.105 18.707,4.293C18.895,4.48 19,4.735 19,5C19,5.265 18.895,5.52 18.707,5.707C18.52,5.895 18.265,6 18,6H4C3.869,6 3.739,5.974 3.617,5.924C3.496,5.874 3.386,5.8 3.293,5.707C3.2,5.614 3.126,5.504 3.076,5.383C3.026,5.261 3,5.131 3,5C3,4.869 3.026,4.739 3.076,4.617C3.126,4.496 3.2,4.386 3.293,4.293C3.386,4.2 3.496,4.126 3.617,4.076C3.739,4.026 3.869,4 4,4ZM4,18H16C16.265,18 16.52,18.105 16.707,18.293C16.895,18.48 17,18.735 17,19C17,19.265 16.895,19.52 16.707,19.707C16.52,19.895 16.265,20 16,20H4C3.735,20 3.48,19.895 3.293,19.707C3.105,19.52 3,19.265 3,19C3,18.735 3.105,18.48 3.293,18.293C3.48,18.105 3.735,18 4,18Z"
|
||||
android:fillColor="#242F39"/>
|
||||
</vector>
|
||||
@ -3,13 +3,16 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@id/bottomNavigation" />
|
||||
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottomNavigation"
|
||||
|
||||
124
app/src/main/res/layout/activity_setting.xml
Normal file
124
app/src/main/res/layout/activity_setting.xml
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/blue"
|
||||
android:orientation="vertical"
|
||||
tools:context=".SettingActivity">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/setting_back"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignBottom="@+id/setting"
|
||||
android:layout_alignStart="@+id/about"
|
||||
android:layout_marginTop="50dp"
|
||||
android:src="@drawable/svg_back"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/setting"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:text="@string/setting"
|
||||
android:textSize="24dp"
|
||||
android:textStyle="bold"
|
||||
tools:ignore="SpUsage" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/about"
|
||||
android:layout_width="350dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignTop="@+id/setting"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:background="#4DFFFFFF">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="20dp"
|
||||
android:gravity="center"
|
||||
android:text="About"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="320dp"
|
||||
android:src="@drawable/setting_enter"
|
||||
tools:ignore="ContentDescription,RtlHardcoded"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/feedback"
|
||||
android:layout_width="350dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignTop="@+id/about"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:background="#4DFFFFFF">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="20dp"
|
||||
android:gravity="center"
|
||||
android:text="Feedback"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="320dp"
|
||||
android:src="@drawable/setting_enter"
|
||||
tools:ignore="ContentDescription,RtlHardcoded" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/Privacy"
|
||||
android:layout_width="350dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignTop="@+id/feedback"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="50dp"
|
||||
android:background="#4DFFFFFF"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="20dp"
|
||||
android:gravity="center"
|
||||
android:text="Privacy Policy"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="12dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="320dp"
|
||||
android:src="@drawable/setting_enter"
|
||||
tools:ignore="ContentDescription,RtlHardcoded" />
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
@ -38,6 +38,7 @@
|
||||
android:layout_marginTop="45dp"
|
||||
android:background="@drawable/round_button"
|
||||
android:padding="5dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageview_back"
|
||||
android:layout_width="wrap_content"
|
||||
@ -78,66 +79,66 @@
|
||||
</TextView>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<RelativeLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_above="@+id/cardView"
|
||||
android:layout_marginBottom="22dp">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/download"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@drawable/round_button"
|
||||
tools:ignore="ContentDescription" >
|
||||
<ImageView
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_gravity="center"
|
||||
android:foreground="@drawable/down_load"
|
||||
tools:ignore="ContentDescription" />
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/share"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="80dp"
|
||||
android:layout_toLeftOf="@id/download"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/round_button"
|
||||
tools:ignore="RtlHardcoded">
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/download"
|
||||
app:layout_constraintHorizontal_bias="0.5">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_gravity="center"
|
||||
android:foreground="@drawable/share_icon"
|
||||
tools:ignore="ContentDescription" />
|
||||
android:foreground="@drawable/share_icon" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/download"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="80dp"
|
||||
android:layout_toRightOf="@id/download"
|
||||
android:background="@drawable/round_button"
|
||||
tools:ignore="RtlHardcoded">
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/share"
|
||||
app:layout_constraintEnd_toStartOf="@+id/collection_layout"
|
||||
app:layout_constraintHorizontal_bias="0.5">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_gravity="center"
|
||||
android:foreground="@drawable/down_load" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/collection_layout"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@drawable/round_button"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/download"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/collection"
|
||||
android:layout_width="26dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_gravity="center"
|
||||
android:foreground="@drawable/dislike"
|
||||
tools:ignore="ContentDescription" />
|
||||
android:foreground="@drawable/dislike" />
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/item_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/item_root"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView_wallpaper"
|
||||
android:layout_width="match_parent"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_height="320dp" />
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"/>
|
||||
<!--<ImageView
|
||||
android:id="@+id/collection"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/favorite_text"
|
||||
android:textColor="#AAAAAA"
|
||||
|
||||
@ -10,15 +10,15 @@
|
||||
<RelativeLayout
|
||||
android:id="@+id/top_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="240dp"
|
||||
>
|
||||
android:layout_height="240dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/top_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:id="@+id/top_image"
|
||||
tools:ignore="ContentDescription">
|
||||
</ImageView>
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="298.8dp"
|
||||
android:layout_height="wrap_content"
|
||||
@ -30,7 +30,19 @@
|
||||
android:textColor="@color/white"
|
||||
android:textSize="17sp"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/setting"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:src="@drawable/setting" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/home_recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
55
app/src/main/res/layout/fragment_import.xml
Normal file
55
app/src/main/res/layout/fragment_import.xml
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btn_select_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="30dp"
|
||||
android:src="@drawable/frame"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/empty"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="137dp"
|
||||
android:layout_height="142dp"
|
||||
android:src="@mipmap/import_back" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="292dp"
|
||||
android:layout_height="34dp"
|
||||
android:layout_marginTop="15dp"
|
||||
android:src="@mipmap/import_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/import_back" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="10dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btn_select_image"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -9,7 +9,7 @@
|
||||
android:id="@+id/imageview_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:scaleType="fitXY"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
|
||||
|
||||
@ -4,10 +4,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="27dp"
|
||||
android:layout_height="30dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/vh_see_all"
|
||||
android:layout_width="75dp"
|
||||
@ -15,6 +17,7 @@
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="24dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@ -34,38 +37,40 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/setting_enter" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_marginStart="24dp"
|
||||
android:id="@+id/vh_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="24dp"
|
||||
android:gravity="center_horizontal|top"
|
||||
android:text="@string/nature"
|
||||
android:textStyle="bold"
|
||||
android:textColor="#2A2E33"
|
||||
android:textSize="20sp"/>
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/vh_left_image"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_width="163dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="280dp">
|
||||
</ImageView>
|
||||
<ImageView
|
||||
android:id="@+id/vh_right_image"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_width="163dp"
|
||||
android:layout_height="280dp"
|
||||
android:layout_weight="1">
|
||||
</ImageView>
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_weight="1"></ImageView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/vh_right_image"
|
||||
android:layout_width="163dp"
|
||||
android:layout_height="280dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_weight="1"></ImageView>
|
||||
|
||||
<View
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="match_parent">
|
||||
</View>
|
||||
android:layout_height="match_parent"></View>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
25
app/src/main/res/layout/item_import.xml
Normal file
25
app/src/main/res/layout/item_import.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/item_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView_wallpaper"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="320dp"
|
||||
android:scaleType="fitXY" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:background="@drawable/_delete"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/imageView_wallpaper"
|
||||
app:layout_constraintEnd_toEndOf="@+id/imageView_wallpaper" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -4,12 +4,12 @@
|
||||
android:id="@+id/navigation_home"
|
||||
android:icon="@drawable/home_icon"
|
||||
android:title="Home" />
|
||||
<item
|
||||
android:id="@+id/navigation_import"
|
||||
android:icon="@drawable/import_icon"
|
||||
android:title="Import" />
|
||||
<item
|
||||
android:id="@+id/navigation_favorite"
|
||||
android:icon="@drawable/dislike_icon"
|
||||
android:title="Like"/>
|
||||
<item
|
||||
android:id="@+id/navigation_setting"
|
||||
android:icon="@drawable/setting_icon"
|
||||
android:title="Setting" />
|
||||
</menu>
|
||||
BIN
app/src/main/res/mipmap-hdpi/import_back.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/import_back.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 174 KiB |
BIN
app/src/main/res/mipmap-hdpi/import_title.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/import_title.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue
Block a user