Compare commits
37 Commits
gallery-v1
...
gallery
| Author | SHA1 | Date | |
|---|---|---|---|
| 74ab06448f | |||
| 6cf5ac2034 | |||
| a2884122aa | |||
| 03ae37dc91 | |||
| aea9f1d745 | |||
| 0786d69ad6 | |||
| 1585ff7eed | |||
| 91b2b1b480 | |||
| bef3f3ce81 | |||
| c0da46e0fd | |||
| 72ca11a1af | |||
| 5decb2f8d9 | |||
| 29e7cfe985 | |||
| 6d521fefdb | |||
| f7932c134f | |||
| 93c59b0424 | |||
| fe248349df | |||
| 4790238343 | |||
| f144d91bb6 | |||
| 9c0e56462e | |||
| 4d977646e6 | |||
| 2d912abf92 | |||
| f764de4077 | |||
| 0788a52652 | |||
| ffea383a4e | |||
| 9c1e08a88b | |||
| abb28b766a | |||
| b6cd91c298 | |||
| 61c2bab83e | |||
| 5a700a0808 | |||
| dad179c15f | |||
| 1b62ff288f | |||
| 87ad6668a4 | |||
| 139083c22f | |||
| c49e68d7f1 | |||
| b035d461aa | |||
| 474ddcbb3b |
@@ -109,7 +109,7 @@ dependencies {
|
|||||||
*/
|
*/
|
||||||
// WinBoLL库 nexus.winboll.cc 地址
|
// WinBoLL库 nexus.winboll.cc 地址
|
||||||
api 'cc.winboll.studio:libaes:15.15.9'
|
api 'cc.winboll.studio:libaes:15.15.9'
|
||||||
api 'cc.winboll.studio:libappbase:15.15.20'
|
api 'cc.winboll.studio:libappbase:15.15.21'
|
||||||
|
|
||||||
// WinBoLL备用库 jitpack.io 地址
|
// WinBoLL备用库 jitpack.io 地址
|
||||||
//api 'com.github.ZhanGSKen:AES:aes-v15.15.7'
|
//api 'com.github.ZhanGSKen:AES:aes-v15.15.7'
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue Apr 28 10:57:44 HKT 2026
|
#Sat May 02 10:32:03 CST 2026
|
||||||
stageCount=8
|
stageCount=16
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.0
|
baseVersion=15.0
|
||||||
publishVersion=15.0.7
|
publishVersion=15.0.15
|
||||||
buildCount=0
|
buildCount=19
|
||||||
baseBetaVersion=15.0.8
|
baseBetaVersion=15.0.16
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class AlbumAdapter extends RecyclerView.Adapter<AlbumAdapter.ViewHolder>
|
|||||||
private void showContextMenu(View view, final Album album) {
|
private void showContextMenu(View view, final Album album) {
|
||||||
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(view.getContext());
|
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(view.getContext());
|
||||||
builder.setTitle(album.getName());
|
builder.setTitle(album.getName());
|
||||||
boolean isPinned = pinnedDbHelper != null && pinnedDbHelper.isPinned(album.getPath());
|
final boolean isPinned = pinnedDbHelper != null && pinnedDbHelper.isPinned(album.getPath());
|
||||||
String[] items = isPinned ? new String[]{"取消置顶"} : new String[]{"置顶"};
|
String[] items = isPinned ? new String[]{"取消置顶"} : new String[]{"置顶"};
|
||||||
builder.setItems(items, new android.content.DialogInterface.OnClickListener() {
|
builder.setItems(items, new android.content.DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -252,4 +252,4 @@ private void showContextMenu(View view, final Album album) {
|
|||||||
imageCount = itemView.findViewById(R.id.image_count);
|
imageCount = itemView.findViewById(R.id.image_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,18 +5,28 @@ import android.graphics.BitmapFactory;
|
|||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class CropActivity extends AppCompatActivity {
|
public class CropActivity extends AppCompatActivity {
|
||||||
public static final String TAG = "CropActivity";
|
public static final String TAG = "CropActivity";
|
||||||
@@ -34,6 +44,7 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
private int cropWidth = 240;
|
private int cropWidth = 240;
|
||||||
private int cropHeight = 120;
|
private int cropHeight = 120;
|
||||||
private float cropRatio = 2.0f;
|
private float cropRatio = 2.0f;
|
||||||
|
private Preferences prefs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -45,7 +56,8 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
cropWidth = getIntent().getIntExtra(EXTRA_CROP_WIDTH, 240);
|
cropWidth = getIntent().getIntExtra(EXTRA_CROP_WIDTH, 240);
|
||||||
cropHeight = getIntent().getIntExtra(EXTRA_CROP_HEIGHT, 120);
|
cropHeight = getIntent().getIntExtra(EXTRA_CROP_HEIGHT, 120);
|
||||||
|
|
||||||
Preferences prefs = new Preferences(this);
|
prefs = new Preferences(this);
|
||||||
|
int bgType = prefs.getBgType();
|
||||||
if (cropWidth > 0 && cropHeight > 0) {
|
if (cropWidth > 0 && cropHeight > 0) {
|
||||||
cropRatio = (float) cropWidth / cropHeight;
|
cropRatio = (float) cropWidth / cropHeight;
|
||||||
} else {
|
} else {
|
||||||
@@ -61,16 +73,6 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final ImageView btnColorPick = findViewById(R.id.btn_color_pick);
|
|
||||||
btnColorPick.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
boolean pickMode = !cropCanvasView.isColorPickMode();
|
|
||||||
cropCanvasView.setColorPickMode(pickMode);
|
|
||||||
btnColorPick.setAlpha(pickMode ? 0.5f : 1.0f);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
findViewById(R.id.btn_done).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.btn_done).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -78,6 +80,20 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.btn_info).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
showCropInfoDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
findViewById(R.id.btn_change_bg).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(CropActivity.this, "修改剪裁背景颜色", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
zoomContainer = findViewById(R.id.zoom_container);
|
zoomContainer = findViewById(R.id.zoom_container);
|
||||||
|
|
||||||
SeekBar seekBarZoom = findViewById(R.id.seekbar_zoom);
|
SeekBar seekBarZoom = findViewById(R.id.seekbar_zoom);
|
||||||
@@ -98,6 +114,15 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
cropCanvasView = findViewById(R.id.crop_canvas_view);
|
cropCanvasView = findViewById(R.id.crop_canvas_view);
|
||||||
|
|
||||||
|
cropCanvasView.setBackgroundType(bgType);
|
||||||
|
|
||||||
|
cropCanvasView.setOnBackgroundColorChangedListener(new CropCanvasView.OnBackgroundColorChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onBackgroundColorChanged(int color) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
loadImage();
|
loadImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +231,77 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showCropInfoDialog() {
|
||||||
|
StringBuilder info = new StringBuilder();
|
||||||
|
info.append("=== 画布信息 ===\n");
|
||||||
|
info.append("画布宽度: ").append(cropCanvasView.getCanvasWidth()).append("px\n");
|
||||||
|
info.append("画布高度: ").append(cropCanvasView.getCanvasHeight()).append("px\n");
|
||||||
|
|
||||||
|
info.append("\n=== 背景类型 ===\n");
|
||||||
|
String[] bgNames = {"灰白相间", "全白", "全黑"};
|
||||||
|
info.append("背景: ").append(bgNames[cropCanvasView.getBackgroundType()]).append("\n");
|
||||||
|
int bgColor = cropCanvasView.getBackgroundColor();
|
||||||
|
info.append("背景颜色: #").append(String.format("%06X", bgColor & 0xFFFFFF)).append("\n");
|
||||||
|
info.append("拾取坐标: ").append(cropCanvasView.getLastPickImageX()).append(",")
|
||||||
|
.append(cropCanvasView.getLastPickImageY()).append("\n");
|
||||||
|
|
||||||
|
info.append("\n=== 裁剪结果 ===\n");
|
||||||
|
RectF cropRect = cropCanvasView.getCropRect();
|
||||||
|
if (cropRect != null) {
|
||||||
|
info.append("裁剪区域: ").append((int)cropRect.left).append(",")
|
||||||
|
.append((int)cropRect.top).append(",")
|
||||||
|
.append((int)cropRect.right).append(",")
|
||||||
|
.append((int)cropRect.bottom).append("\n");
|
||||||
|
info.append("裁剪宽度: ").append((int)cropRect.width()).append("px\n");
|
||||||
|
info.append("裁剪高度: ").append((int)cropRect.height()).append("px\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
Bitmap canvasBitmap = cropCanvasView.getCanvasBitmap();
|
||||||
|
final Bitmap[] previewHolder = new Bitmap[1];
|
||||||
|
if (canvasBitmap != null && !canvasBitmap.isRecycled() && cropRect != null) {
|
||||||
|
int bmpX = Math.max(0, (int) cropRect.left);
|
||||||
|
int bmpY = Math.max(0, (int) cropRect.top);
|
||||||
|
int bmpW = Math.min((int) cropRect.width(), canvasBitmap.getWidth() - bmpX);
|
||||||
|
int bmpH = Math.min((int) cropRect.height(), canvasBitmap.getHeight() - bmpY);
|
||||||
|
if (bmpW > 0 && bmpH > 0) {
|
||||||
|
previewHolder[0] = Bitmap.createBitmap(canvasBitmap, bmpX, bmpY, bmpW, bmpH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Bitmap previewBitmap = previewHolder[0];
|
||||||
|
|
||||||
|
View dialogView = getLayoutInflater().inflate(R.layout.dialog_crop_info, null);
|
||||||
|
TextView infoText = dialogView.findViewById(R.id.info_text);
|
||||||
|
ImageView previewImage = dialogView.findViewById(R.id.preview_image);
|
||||||
|
final LinearLayout previewImageContainer = dialogView.findViewById(R.id.preview_image_container);
|
||||||
|
infoText.setText(info.toString());
|
||||||
|
if (previewBitmap != null) {
|
||||||
|
previewImage.setImageBitmap(previewBitmap);
|
||||||
|
}
|
||||||
|
previewImage.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
int randomColor = 0xFF000000 | new Random().nextInt(0x00FFFFFF);
|
||||||
|
previewImageContainer.setBackgroundColor(randomColor);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||||
|
.setTitle("裁剪信息")
|
||||||
|
.setView(dialogView)
|
||||||
|
.setPositiveButton("确定", null)
|
||||||
|
.create();
|
||||||
|
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
if (previewBitmap != null && !previewBitmap.isRecycled()) {
|
||||||
|
previewBitmap.recycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@@ -214,4 +310,4 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
originalBitmap = null;
|
originalBitmap = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,46 @@ package cc.winboll.studio.gallery;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapShader;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.Shader;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
public class CropCanvasView extends View {
|
public class CropCanvasView extends View {
|
||||||
|
public interface OnBackgroundColorChangedListener {
|
||||||
|
void onBackgroundColorChanged(int color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnColorPickedListener {
|
||||||
|
void onColorPicked(int color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnColorPickEndListener {
|
||||||
|
void onColorPickEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnBackgroundColorChangedListener backgroundColorChangedListener;
|
||||||
|
private OnColorPickedListener colorPickedListener;
|
||||||
|
private OnColorPickEndListener colorPickEndListener;
|
||||||
|
|
||||||
|
public void setOnBackgroundColorChangedListener(OnBackgroundColorChangedListener listener) {
|
||||||
|
this.backgroundColorChangedListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnColorPickedListener(OnColorPickedListener listener) {
|
||||||
|
this.colorPickedListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnColorPickEndListener(OnColorPickEndListener listener) {
|
||||||
|
this.colorPickEndListener = listener;
|
||||||
|
}
|
||||||
private Paint imagePaint;
|
private Paint imagePaint;
|
||||||
private Paint borderPaint;
|
private Paint borderPaint;
|
||||||
private Paint cornerPaint;
|
private Paint cornerPaint;
|
||||||
@@ -39,11 +69,20 @@ public class CropCanvasView extends View {
|
|||||||
private RectF imageBounds = new RectF();
|
private RectF imageBounds = new RectF();
|
||||||
private RectF canvasBounds = new RectF();
|
private RectF canvasBounds = new RectF();
|
||||||
private Bitmap originalBitmap;
|
private Bitmap originalBitmap;
|
||||||
|
private Bitmap canvasBitmap;
|
||||||
|
private float bitmapScale = 1.0f;
|
||||||
private Bitmap displayBitmap;
|
private Bitmap displayBitmap;
|
||||||
private RectF initialSpanRect;
|
private RectF initialSpanRect;
|
||||||
private float initialSpan;
|
private float initialSpan;
|
||||||
|
private int bgType = 2;
|
||||||
|
private Bitmap tileBitmap;
|
||||||
|
private BitmapShader tileShader;
|
||||||
|
private Paint bgPaint;
|
||||||
private int backgroundColor = Color.BLUE;
|
private int backgroundColor = Color.BLUE;
|
||||||
private boolean colorPickMode = false;
|
private boolean colorPickMode = false;
|
||||||
|
private int previewColor = 0;
|
||||||
|
private float lastPickX = 0;
|
||||||
|
private float lastPickY = 0;
|
||||||
private float pickX, pickY;
|
private float pickX, pickY;
|
||||||
|
|
||||||
private float displayScale = 1.0f;
|
private float displayScale = 1.0f;
|
||||||
@@ -79,6 +118,60 @@ public class CropCanvasView extends View {
|
|||||||
cornerPaint = new Paint();
|
cornerPaint = new Paint();
|
||||||
cornerPaint.setColor(Color.WHITE);
|
cornerPaint.setColor(Color.WHITE);
|
||||||
cornerPaint.setStyle(Paint.Style.FILL);
|
cornerPaint.setStyle(Paint.Style.FILL);
|
||||||
|
|
||||||
|
bgType = 2;
|
||||||
|
bgPaint = new Paint();
|
||||||
|
initTileBitmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initTileBitmap() {
|
||||||
|
if (tileBitmap != null && !tileBitmap.isRecycled()) {
|
||||||
|
tileBitmap.recycle();
|
||||||
|
tileBitmap = null;
|
||||||
|
}
|
||||||
|
tileShader = null;
|
||||||
|
|
||||||
|
if (bgType == 0) {
|
||||||
|
Drawable drawable = getContext().getDrawable(R.drawable.bg_checkerboard);
|
||||||
|
if (drawable != null) {
|
||||||
|
int w = drawable.getIntrinsicWidth();
|
||||||
|
int h = drawable.getIntrinsicHeight();
|
||||||
|
if (w <= 0) w = 10;
|
||||||
|
if (h <= 0) h = 10;
|
||||||
|
tileBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
||||||
|
Canvas c = new Canvas(tileBitmap);
|
||||||
|
drawable.setBounds(0, 0, w, h);
|
||||||
|
drawable.draw(c);
|
||||||
|
tileShader = new BitmapShader(tileBitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackgroundType(int type) {
|
||||||
|
if (bgType != type) {
|
||||||
|
bgType = type;
|
||||||
|
initTileBitmap();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBackgroundType() {
|
||||||
|
return bgType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawBackground(Canvas canvas) {
|
||||||
|
if (bgType == 0 && tileShader != null) {
|
||||||
|
bgPaint.setShader(tileShader);
|
||||||
|
canvas.drawRect(canvasBounds, bgPaint);
|
||||||
|
} else if (bgType == 1) {
|
||||||
|
bgPaint.setShader(null);
|
||||||
|
bgPaint.setColor(Color.WHITE);
|
||||||
|
canvas.drawRect(canvasBounds, bgPaint);
|
||||||
|
} else {
|
||||||
|
bgPaint.setShader(null);
|
||||||
|
bgPaint.setColor(Color.BLACK);
|
||||||
|
canvas.drawRect(canvasBounds, bgPaint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImageBitmap(Bitmap bitmap) {
|
public void setImageBitmap(Bitmap bitmap) {
|
||||||
@@ -143,7 +236,7 @@ public class CropCanvasView extends View {
|
|||||||
}
|
}
|
||||||
Bitmap canvasBmp = Bitmap.createBitmap(canvasWidth, canvasHeight, Bitmap.Config.ARGB_8888);
|
Bitmap canvasBmp = Bitmap.createBitmap(canvasWidth, canvasHeight, Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(canvasBmp);
|
Canvas canvas = new Canvas(canvasBmp);
|
||||||
canvas.drawColor(backgroundColor);
|
drawBackground(canvas);
|
||||||
if (displayBitmap != null && !displayBitmap.isRecycled()) {
|
if (displayBitmap != null && !displayBitmap.isRecycled()) {
|
||||||
if (displayBitmap == originalBitmap) {
|
if (displayBitmap == originalBitmap) {
|
||||||
canvas.drawBitmap(displayBitmap, imageBounds.left, imageBounds.top, imagePaint);
|
canvas.drawBitmap(displayBitmap, imageBounds.left, imageBounds.top, imagePaint);
|
||||||
@@ -239,6 +332,9 @@ public class CropCanvasView extends View {
|
|||||||
|
|
||||||
public void setBackgroundColor(int color) {
|
public void setBackgroundColor(int color) {
|
||||||
this.backgroundColor = color;
|
this.backgroundColor = color;
|
||||||
|
if (backgroundColorChangedListener != null) {
|
||||||
|
backgroundColorChangedListener.onBackgroundColorChanged(color);
|
||||||
|
}
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,6 +342,40 @@ public class CropCanvasView extends View {
|
|||||||
return backgroundColor;
|
return backgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPreviewColor() {
|
||||||
|
return previewColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getLastPickX() {
|
||||||
|
return lastPickX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getLastPickY() {
|
||||||
|
return lastPickY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastPickImageX() {
|
||||||
|
if (originalBitmap == null || originalBitmap.isRecycled()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
float imgX = screenToImageX(lastPickX);
|
||||||
|
float imgY = screenToImageY(lastPickY);
|
||||||
|
int bmpX = (int) ((imgX - imageBounds.left) * displayBitmapScale);
|
||||||
|
int bmpY = (int) ((imgY - imageBounds.top) * displayBitmapScale);
|
||||||
|
return Math.max(0, Math.min(bmpX, originalBitmap.getWidth() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLastPickImageY() {
|
||||||
|
if (originalBitmap == null || originalBitmap.isRecycled()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
float imgX = screenToImageX(lastPickX);
|
||||||
|
float imgY = screenToImageY(lastPickY);
|
||||||
|
int bmpX = (int) ((imgX - imageBounds.left) * displayBitmapScale);
|
||||||
|
int bmpY = (int) ((imgY - imageBounds.top) * displayBitmapScale);
|
||||||
|
return Math.max(0, Math.min(bmpY, originalBitmap.getHeight() - 1));
|
||||||
|
}
|
||||||
|
|
||||||
public void setColorPickMode(boolean enable) {
|
public void setColorPickMode(boolean enable) {
|
||||||
this.colorPickMode = enable;
|
this.colorPickMode = enable;
|
||||||
if (enable) {
|
if (enable) {
|
||||||
@@ -340,7 +470,7 @@ public class CropCanvasView extends View {
|
|||||||
getDisplayMatrix(matrix);
|
getDisplayMatrix(matrix);
|
||||||
canvas.concat(matrix);
|
canvas.concat(matrix);
|
||||||
|
|
||||||
canvas.drawColor(backgroundColor);
|
drawBackground(canvas);
|
||||||
|
|
||||||
if (displayBitmap == originalBitmap) {
|
if (displayBitmap == originalBitmap) {
|
||||||
canvas.drawBitmap(displayBitmap, imageBounds.left, imageBounds.top, imagePaint);
|
canvas.drawBitmap(displayBitmap, imageBounds.left, imageBounds.top, imagePaint);
|
||||||
@@ -447,11 +577,46 @@ public class CropCanvasView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (colorPickMode) {
|
if (colorPickMode) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
pickX = x;
|
if (originalBitmap != null && !originalBitmap.isRecycled()) {
|
||||||
pickY = y;
|
float imgX = screenToImageX(x);
|
||||||
int color = getColorAt(x, y);
|
float imgY = screenToImageY(y);
|
||||||
setBackgroundColor(color);
|
if (imageBounds.contains(imgX, imgY)) {
|
||||||
|
previewColor = getImageColorAt(x, y);
|
||||||
|
} else if (canvasBounds.contains(x, y)) {
|
||||||
|
previewColor = (bgType == 1) ? Color.WHITE : Color.BLACK;
|
||||||
|
} else {
|
||||||
|
previewColor = Color.TRANSPARENT;
|
||||||
|
}
|
||||||
|
lastPickX = x;
|
||||||
|
lastPickY = y;
|
||||||
|
if (backgroundColorChangedListener != null) {
|
||||||
|
backgroundColorChangedListener.onBackgroundColorChanged(previewColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
|
if (canvasBounds.contains(x, y)) {
|
||||||
|
int pickedColor;
|
||||||
|
float imgX = screenToImageX(x);
|
||||||
|
float imgY = screenToImageY(y);
|
||||||
|
if (imageBounds.contains(imgX, imgY)) {
|
||||||
|
int colorAtPoint = getImageColorAt(x, y);
|
||||||
|
pickedColor = colorAtPoint;
|
||||||
|
backgroundColor = colorAtPoint;
|
||||||
|
} else {
|
||||||
|
pickedColor = (bgType == 1) ? Color.WHITE : Color.BLACK;
|
||||||
|
}
|
||||||
|
if (colorPickedListener != null) {
|
||||||
|
colorPickedListener.onColorPicked(pickedColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (colorPickEndListener != null) {
|
||||||
|
colorPickEndListener.onColorPickEnd();
|
||||||
|
}
|
||||||
|
previewColor = 0;
|
||||||
|
invalidate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
|||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.ToastUtils;
|
import cc.winboll.studio.libappbase.ToastUtils;
|
||||||
|
import cc.winboll.studio.gallery.utils.BackgroundUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
* @Author 豆包&ZhanGSKen<zhangsken@qq.com>
|
||||||
@@ -23,6 +24,8 @@ public class GlobalWinBoLLApplication extends GlobalApplication {
|
|||||||
|
|
||||||
WinBoLLActivityManager.init(this);
|
WinBoLLActivityManager.init(this);
|
||||||
|
|
||||||
|
BackgroundUtils.initFromPreferences(this);
|
||||||
|
|
||||||
// 初始化 Toast 框架
|
// 初始化 Toast 框架
|
||||||
ToastUtils.init(this);
|
ToastUtils.init(this);
|
||||||
// 设置 Toast 布局样式
|
// 设置 Toast 布局样式
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder>
|
|||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showContextMenu(View view, final int position) {
|
private void showContextMenu(final View view, final int position) {
|
||||||
final String imagePath = imagePaths.get(position);
|
final String imagePath = imagePaths.get(position);
|
||||||
final Uri imageUri = imageUrls.get(position);
|
final Uri imageUri = imageUrls.get(position);
|
||||||
final boolean[] isPinned = {pinnedDbHelper != null && pinnedDbHelper.isPinned(imagePath)};
|
final boolean[] isPinned = {pinnedDbHelper != null && pinnedDbHelper.isPinned(imagePath)};
|
||||||
@@ -244,4 +244,4 @@ public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder>
|
|||||||
coverIcon = itemView.findViewById(R.id.cover_icon);
|
coverIcon = itemView.findViewById(R.id.cover_icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,25 +16,10 @@ import cc.winboll.studio.libappbase.LogUtils;
|
|||||||
public class ImagePagerAdapter extends PagerAdapter {
|
public class ImagePagerAdapter extends PagerAdapter {
|
||||||
public static final String TAG = "ImagePagerAdapter";
|
public static final String TAG = "ImagePagerAdapter";
|
||||||
private ArrayList<Uri> imageUrls;
|
private ArrayList<Uri> imageUrls;
|
||||||
private int bgType;
|
|
||||||
|
|
||||||
public ImagePagerAdapter(ArrayList<Uri> imageUrls, int bgType) {
|
public ImagePagerAdapter(ArrayList<Uri> imageUrls) {
|
||||||
this.imageUrls = imageUrls;
|
this.imageUrls = imageUrls;
|
||||||
this.bgType = bgType;
|
LogUtils.d(TAG, "ImagePagerAdapter created with " + imageUrls.size() + " images");
|
||||||
LogUtils.d(TAG, "ImagePagerAdapter created with " + imageUrls.size() + " images, bgType=" + bgType);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getBgRes() {
|
|
||||||
switch (bgType) {
|
|
||||||
case 0:
|
|
||||||
return R.drawable.bg_checkerboard;
|
|
||||||
case 1:
|
|
||||||
return R.drawable.bg_white;
|
|
||||||
case 2:
|
|
||||||
return R.drawable.bg_black;
|
|
||||||
default:
|
|
||||||
return R.drawable.bg_checkerboard;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,7 +32,7 @@ public class ImagePagerAdapter extends PagerAdapter {
|
|||||||
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
public Object instantiateItem(@NonNull ViewGroup container, int position) {
|
||||||
View view = LayoutInflater.from(container.getContext())
|
View view = LayoutInflater.from(container.getContext())
|
||||||
.inflate(R.layout.item_image_pager, container, false);
|
.inflate(R.layout.item_image_pager, container, false);
|
||||||
view.setBackgroundResource(getBgRes());
|
view.setBackgroundResource(R.color.black);
|
||||||
ImageView imageView = view.findViewById(R.id.image);
|
ImageView imageView = view.findViewById(R.id.image);
|
||||||
|
|
||||||
Glide.with(imageView.getContext())
|
Glide.with(imageView.getContext())
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import android.view.View;
|
|||||||
import android.view.View.OnTouchListener;
|
import android.view.View.OnTouchListener;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.Toast;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -33,8 +34,7 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
|
|||||||
private ImageButton btnDelete;
|
private ImageButton btnDelete;
|
||||||
private ImageButton btnShare;
|
private ImageButton btnShare;
|
||||||
private ImageButton btnInfo;
|
private ImageButton btnInfo;
|
||||||
private ImageButton btnBg;
|
private ImageButton btnGallery;
|
||||||
private int bgType = 0;
|
|
||||||
private GestureDetector gestureDetector;
|
private GestureDetector gestureDetector;
|
||||||
private TrashManager trashManager;
|
private TrashManager trashManager;
|
||||||
private Preferences prefs;
|
private Preferences prefs;
|
||||||
@@ -53,7 +53,6 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
|
|||||||
|
|
||||||
trashManager = new TrashManager(this);
|
trashManager = new TrashManager(this);
|
||||||
prefs = new Preferences(this);
|
prefs = new Preferences(this);
|
||||||
bgType = prefs.getBgType();
|
|
||||||
|
|
||||||
viewPager = findViewById(R.id.view_pager);
|
viewPager = findViewById(R.id.view_pager);
|
||||||
toolbar = findViewById(R.id.toolbar);
|
toolbar = findViewById(R.id.toolbar);
|
||||||
@@ -61,11 +60,10 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
|
|||||||
btnDelete = findViewById(R.id.btn_delete);
|
btnDelete = findViewById(R.id.btn_delete);
|
||||||
btnShare = findViewById(R.id.btn_share);
|
btnShare = findViewById(R.id.btn_share);
|
||||||
btnInfo = findViewById(R.id.btn_info);
|
btnInfo = findViewById(R.id.btn_info);
|
||||||
btnBg = findViewById(R.id.btn_bg);
|
|
||||||
|
|
||||||
applyBg();
|
btnGallery = findViewById(R.id.btn_gallery);
|
||||||
|
|
||||||
ImagePagerAdapter adapter = new ImagePagerAdapter(imageUrls, bgType);
|
ImagePagerAdapter adapter = new ImagePagerAdapter(imageUrls);
|
||||||
viewPager.setAdapter(adapter);
|
viewPager.setAdapter(adapter);
|
||||||
viewPager.setCurrentItem(currentPosition);
|
viewPager.setCurrentItem(currentPosition);
|
||||||
viewPager.addOnPageChangeListener(this);
|
viewPager.addOnPageChangeListener(this);
|
||||||
@@ -113,10 +111,17 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnBg.setOnClickListener(new View.OnClickListener() {
|
btnGallery.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switchBg();
|
Toast.makeText(ImageViewerActivity.this, "Gallery", Toast.LENGTH_SHORT).show();
|
||||||
|
if (imageUrls != null && currentPosition >= 0 && currentPosition < imageUrls.size()) {
|
||||||
|
Uri imageUri = imageUrls.get(currentPosition);
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(imageUri, "image/*");
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
startActivity(Intent.createChooser(intent, "打开相册"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -129,52 +134,6 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyBg() {
|
|
||||||
int bgRes;
|
|
||||||
switch (bgType) {
|
|
||||||
case 0:
|
|
||||||
bgRes = R.drawable.bg_checkerboard;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
bgRes = R.drawable.bg_white;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
bgRes = R.drawable.bg_black;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
bgRes = R.drawable.bg_checkerboard;
|
|
||||||
}
|
|
||||||
View container = findViewById(R.id.container);
|
|
||||||
if (container != null) {
|
|
||||||
container.setBackgroundResource(bgRes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void switchBg() {
|
|
||||||
final String[] bgNames = {"灰白相间", "全白", "全黑"};
|
|
||||||
final int[] bgResources = {R.drawable.bg_checkerboard, R.drawable.bg_white, R.drawable.bg_black};
|
|
||||||
|
|
||||||
new AlertDialog.Builder(this)
|
|
||||||
.setTitle("选择背景")
|
|
||||||
.setSingleChoiceItems(bgNames, bgType, new android.content.DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(android.content.DialogInterface dialog, int which) {
|
|
||||||
bgType = which;
|
|
||||||
prefs.setBgType(which);
|
|
||||||
int currentItem = viewPager.getCurrentItem();
|
|
||||||
View container = findViewById(R.id.container);
|
|
||||||
if (container != null) {
|
|
||||||
container.setBackgroundResource(bgResources[which]);
|
|
||||||
}
|
|
||||||
viewPager.setAdapter(new ImagePagerAdapter(imageUrls, bgType));
|
|
||||||
viewPager.setCurrentItem(currentItem);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton("取消", null)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showDeleteDialog() {
|
private void showDeleteDialog() {
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setMessage("Delete to trash?")
|
.setMessage("Delete to trash?")
|
||||||
@@ -239,7 +198,7 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
|
|||||||
if (currentPosition >= imageUrls.size()) {
|
if (currentPosition >= imageUrls.size()) {
|
||||||
currentPosition = imageUrls.size() - 1;
|
currentPosition = imageUrls.size() - 1;
|
||||||
}
|
}
|
||||||
viewPager.setAdapter(new ImagePagerAdapter(imageUrls, bgType));
|
viewPager.setAdapter(new ImagePagerAdapter(imageUrls));
|
||||||
viewPager.setCurrentItem(currentPosition);
|
viewPager.setCurrentItem(currentPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,12 @@ import androidx.core.app.ActivityCompat;
|
|||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
|
||||||
import cc.winboll.studio.gallery.AlbumAdapter.OnAlbumClickListener;
|
import cc.winboll.studio.gallery.AlbumAdapter.OnAlbumClickListener;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.gallery.utils.BackgroundUtils;
|
||||||
import cc.winboll.studio.libappbase.LogActivity;
|
import cc.winboll.studio.libappbase.LogActivity;
|
||||||
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
|
import com.a4455jkjh.colorpicker.ColorPickerDialog;
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
@@ -49,55 +51,60 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
LogUtils.d(TAG, "onCreate");
|
LogUtils.d(TAG, "onCreate");
|
||||||
|
|
||||||
|
View content = findViewById(android.R.id.content);
|
||||||
|
if (content != null) {
|
||||||
|
content.setBackground(BackgroundUtils.getInstance().getDrawable());
|
||||||
|
}
|
||||||
|
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
prefs = new Preferences(this);
|
prefs = new Preferences(this);
|
||||||
|
|
||||||
recyclerView = findViewById(R.id.recycler_view);
|
recyclerView = findViewById(R.id.recycler_view);
|
||||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||||
adapter = new AlbumAdapter();
|
adapter = new AlbumAdapter();
|
||||||
adapter.setContext(this);
|
adapter.setContext(this);
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
fabScrollTop = findViewById(R.id.fab_scroll_top);
|
fabScrollTop = findViewById(R.id.fab_scroll_top);
|
||||||
fabScrollTop.setOnClickListener(new View.OnClickListener() {
|
fabScrollTop.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
recyclerView.scrollToPosition(0);
|
recyclerView.scrollToPosition(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||||
super.onScrolled(recyclerView, dx, dy);
|
super.onScrolled(recyclerView, dx, dy);
|
||||||
GridLayoutManager layoutManager = (GridLayoutManager) recyclerView.getLayoutManager();
|
GridLayoutManager layoutManager = (GridLayoutManager) recyclerView.getLayoutManager();
|
||||||
if (layoutManager != null) {
|
if (layoutManager != null) {
|
||||||
int firstVisible = layoutManager.findFirstVisibleItemPosition();
|
int firstVisible = layoutManager.findFirstVisibleItemPosition();
|
||||||
if (firstVisible > 0) {
|
if (firstVisible > 0) {
|
||||||
fabScrollTop.setVisibility(View.VISIBLE);
|
fabScrollTop.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
fabScrollTop.setVisibility(View.GONE);
|
fabScrollTop.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
adapter.setOnAlbumClickListener(new OnAlbumClickListener() {
|
adapter.setOnAlbumClickListener(new OnAlbumClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onAlbumClick(Album album) {
|
public void onAlbumClick(Album album) {
|
||||||
Intent intent = new Intent(MainActivity.this, AlbumActivity.class);
|
Intent intent = new Intent(MainActivity.this, AlbumActivity.class);
|
||||||
intent.putExtra(AlbumActivity.EXTRA_ALBUM_PATH, album.getPath());
|
intent.putExtra(AlbumActivity.EXTRA_ALBUM_PATH, album.getPath());
|
||||||
intent.putExtra(AlbumActivity.EXTRA_ALBUM_NAME, album.getName());
|
intent.putExtra(AlbumActivity.EXTRA_ALBUM_NAME, album.getName());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
checkAndRequestPermissions();
|
checkAndRequestPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndRequestPermissions() {
|
private void checkAndRequestPermissions() {
|
||||||
LogUtils.i(TAG, "checkAndRequestPermissions");
|
LogUtils.i(TAG, "checkAndRequestPermissions");
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
@@ -113,14 +120,14 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkPermission()) {
|
if (checkPermission()) {
|
||||||
loadAlbums();
|
loadAlbums();
|
||||||
} else {
|
} else {
|
||||||
requestPermission();
|
requestPermission();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
@@ -134,7 +141,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkPermission() {
|
private boolean checkPermission() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
return Environment.isExternalStorageManager();
|
return Environment.isExternalStorageManager();
|
||||||
@@ -145,13 +152,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void requestPermission() {
|
private void requestPermission() {
|
||||||
ActivityCompat.requestPermissions(this,
|
ActivityCompat.requestPermissions(this,
|
||||||
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||||
PERMISSION_REQUEST_CODE);
|
PERMISSION_REQUEST_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||||
@NonNull int[] grantResults) {
|
@NonNull int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
if (requestCode == PERMISSION_REQUEST_CODE) {
|
if (requestCode == PERMISSION_REQUEST_CODE) {
|
||||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
@@ -162,12 +169,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadAlbums() {
|
private void loadAlbums() {
|
||||||
LogUtils.d(TAG, "loadAlbums");
|
LogUtils.d(TAG, "loadAlbums");
|
||||||
String folderPath = prefs.getFolderPath();
|
String folderPath = prefs.getFolderPath();
|
||||||
File baseFolder = new File(folderPath);
|
File baseFolder = new File(folderPath);
|
||||||
LogUtils.d(TAG, "baseFolder: " + baseFolder.getAbsolutePath() + ", exists=" + baseFolder.exists());
|
LogUtils.d(TAG, "baseFolder: " + baseFolder.getAbsolutePath() + ", exists=" + baseFolder.exists());
|
||||||
|
|
||||||
if (!baseFolder.exists() || !baseFolder.isDirectory()) {
|
if (!baseFolder.exists() || !baseFolder.isDirectory()) {
|
||||||
folderPath = Preferences.getDefaultPath();
|
folderPath = Preferences.getDefaultPath();
|
||||||
baseFolder = new File(folderPath);
|
baseFolder = new File(folderPath);
|
||||||
@@ -178,10 +185,10 @@ private void loadAlbums() {
|
|||||||
LogUtils.d(TAG, "try Pictures: " + baseFolder.getAbsolutePath() + ", exists=" + baseFolder.exists());
|
LogUtils.d(TAG, "try Pictures: " + baseFolder.getAbsolutePath() + ", exists=" + baseFolder.exists());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AlbumCoverDbHelper coverDbHelper = AlbumCoverDbHelper.getInstance(this);
|
AlbumCoverDbHelper coverDbHelper = AlbumCoverDbHelper.getInstance(this);
|
||||||
ArrayList<Album> albums = new ArrayList<>();
|
ArrayList<Album> albums = new ArrayList<>();
|
||||||
|
|
||||||
FileFilter directoryFilter = new FileFilter() {
|
FileFilter directoryFilter = new FileFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
@@ -224,7 +231,7 @@ private void loadAlbums() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (albums.isEmpty()) {
|
if (albums.isEmpty()) {
|
||||||
Toast.makeText(this, R.string.no_images_found, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.no_images_found, Toast.LENGTH_SHORT).show();
|
||||||
LogUtils.i(TAG, "No albums found");
|
LogUtils.i(TAG, "No albums found");
|
||||||
@@ -232,14 +239,14 @@ private void loadAlbums() {
|
|||||||
adapter.setData(albums);
|
adapter.setData(albums);
|
||||||
LogUtils.d(TAG, "Loaded " + albums.size() + " albums");
|
LogUtils.d(TAG, "Loaded " + albums.size() + " albums");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Uri getUriFromPath(String path) {
|
private Uri getUriFromPath(String path) {
|
||||||
String[] projection = { MediaStore.Images.Media._ID };
|
String[] projection = { MediaStore.Images.Media._ID };
|
||||||
String selection = MediaStore.Images.Media.DATA + " = ?";
|
String selection = MediaStore.Images.Media.DATA + " = ?";
|
||||||
String[] selectionArgs = { path };
|
String[] selectionArgs = { path };
|
||||||
try (Cursor cursor = getContentResolver().query(
|
try (Cursor cursor = getContentResolver().query(
|
||||||
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||||
projection, selection, selectionArgs, null)) {
|
projection, selection, selectionArgs, null)) {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
long id = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID));
|
long id = cursor.getLong(cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID));
|
||||||
@@ -249,18 +256,18 @@ private void loadAlbums() {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<Uri> getImagesInFolder(String folderPath) {
|
private ArrayList<Uri> getImagesInFolder(String folderPath) {
|
||||||
ArrayList<Uri> imageUrls = new ArrayList<>();
|
ArrayList<Uri> imageUrls = new ArrayList<>();
|
||||||
ContentResolver contentResolver = getContentResolver();
|
ContentResolver contentResolver = getContentResolver();
|
||||||
Uri collection = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
Uri collection = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||||
|
|
||||||
String selection = MediaStore.Images.Media.DATA + " LIKE ?";
|
String selection = MediaStore.Images.Media.DATA + " LIKE ?";
|
||||||
String[] selectionArgs = new String[]{folderPath + "/%"};
|
String[] selectionArgs = new String[]{folderPath + "/%"};
|
||||||
String sortOrder = MediaStore.Images.Media.DATE_ADDED + " DESC";
|
String sortOrder = MediaStore.Images.Media.DATE_ADDED + " DESC";
|
||||||
|
|
||||||
LogUtils.d(TAG, "getImagesInFolder: " + folderPath);
|
LogUtils.d(TAG, "getImagesInFolder: " + folderPath);
|
||||||
|
|
||||||
try (Cursor cursor = contentResolver.query(collection, null, selection, selectionArgs, sortOrder)) {
|
try (Cursor cursor = contentResolver.query(collection, null, selection, selectionArgs, sortOrder)) {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
LogUtils.d(TAG, "cursor count: " + cursor.getCount());
|
LogUtils.d(TAG, "cursor count: " + cursor.getCount());
|
||||||
@@ -289,7 +296,40 @@ private void loadAlbums() {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
if (id == R.id.action_settings) {
|
if (id == R.id.action_mi_gallery) {
|
||||||
|
Toast.makeText(this, "Gallery clicked", Toast.LENGTH_SHORT).show();
|
||||||
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
intent.addCategory(Intent.CATEGORY_APP_GALLERY);
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
} else if (id == R.id.action_change_bg_color) {
|
||||||
|
//Toast.makeText(this, "修改背景颜色", Toast.LENGTH_SHORT).show();
|
||||||
|
if (BackgroundUtils.DrawableType.COLOR == BackgroundUtils.getInstance().getDrawableType()) {
|
||||||
|
|
||||||
|
ColorPickerDialog dlg = new ColorPickerDialog(this, BackgroundUtils.getInstance().getColor());
|
||||||
|
dlg.setOnColorChangedListener(new com.a4455jkjh.colorpicker.view.OnColorChangedListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeColorChanged() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onColorChanged(int color) {
|
||||||
|
BackgroundUtils.getInstance().initFromColor(MainActivity.this, color);
|
||||||
|
View content = findViewById(android.R.id.content);
|
||||||
|
if (content != null) {
|
||||||
|
content.setBackground(BackgroundUtils.getInstance().getDrawable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterColorChanged() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dlg.show();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else if (id == R.id.action_settings) {
|
||||||
startActivity(new Intent(this, SettingsActivity.class));
|
startActivity(new Intent(this, SettingsActivity.class));
|
||||||
return true;
|
return true;
|
||||||
} else if (id == R.id.action_about) {
|
} else if (id == R.id.action_about) {
|
||||||
@@ -304,7 +344,7 @@ private void loadAlbums() {
|
|||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BroadcastReceiver coverUpdatedReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver coverUpdatedReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@@ -313,7 +353,7 @@ private void loadAlbums() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -328,35 +368,35 @@ private void loadAlbums() {
|
|||||||
adapter.refreshCover();
|
adapter.refreshCover();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
unregisterReceiver(coverUpdatedReceiver);
|
unregisterReceiver(coverUpdatedReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanMediaStore() {
|
private void scanMediaStore() {
|
||||||
String folderPath = prefs.getFolderPath();
|
String folderPath = prefs.getFolderPath();
|
||||||
File baseFolder = new File(folderPath);
|
File baseFolder = new File(folderPath);
|
||||||
if (baseFolder.exists() && baseFolder.isDirectory()) {
|
if (baseFolder.exists() && baseFolder.isDirectory()) {
|
||||||
File[] subfolders = baseFolder.listFiles(new FileFilter() {
|
File[] subfolders = baseFolder.listFiles(new FileFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File file) {
|
public boolean accept(File file) {
|
||||||
return file.isDirectory();
|
return file.isDirectory();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (subfolders != null) {
|
if (subfolders != null) {
|
||||||
ArrayList<String> paths = new ArrayList<>();
|
ArrayList<String> paths = new ArrayList<>();
|
||||||
for (File subfolder : subfolders) {
|
for (File subfolder : subfolders) {
|
||||||
File[] images = subfolder.listFiles(new FilenameFilter() {
|
File[] images = subfolder.listFiles(new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
String lower = name.toLowerCase();
|
String lower = name.toLowerCase();
|
||||||
return lower.endsWith(".jpg") || lower.endsWith(".jpeg")
|
return lower.endsWith(".jpg") || lower.endsWith(".jpeg")
|
||||||
|| lower.endsWith(".png") || lower.endsWith(".gif")
|
|| lower.endsWith(".png") || lower.endsWith(".gif")
|
||||||
|| lower.endsWith(".webp") || lower.endsWith(".bmp");
|
|| lower.endsWith(".webp") || lower.endsWith(".bmp");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (images != null) {
|
if (images != null) {
|
||||||
for (File img : images) {
|
for (File img : images) {
|
||||||
paths.add(img.getAbsolutePath());
|
paths.add(img.getAbsolutePath());
|
||||||
@@ -367,11 +407,11 @@ private void loadAlbums() {
|
|||||||
LogUtils.d(TAG, "scanning " + paths.size() + " files to MediaStore");
|
LogUtils.d(TAG, "scanning " + paths.size() + " files to MediaStore");
|
||||||
String[] pathArray = paths.toArray(new String[0]);
|
String[] pathArray = paths.toArray(new String[0]);
|
||||||
MediaScannerConnection.scanFile(this, pathArray, null, new MediaScannerConnection.OnScanCompletedListener() {
|
MediaScannerConnection.scanFile(this, pathArray, null, new MediaScannerConnection.OnScanCompletedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScanCompleted(String path, Uri uri) {
|
public void onScanCompleted(String path, Uri uri) {
|
||||||
LogUtils.d(TAG, "scanCompleted: " + path + " -> " + uri);
|
LogUtils.d(TAG, "scanCompleted: " + path + " -> " + uri);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package cc.winboll.studio.gallery.dialog;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import cc.winboll.studio.gallery.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 颜色表对话框
|
||||||
|
* 继承于普通对话框类,使用视图文件
|
||||||
|
*/
|
||||||
|
public class ColorPaletteDialog extends Dialog {
|
||||||
|
|
||||||
|
public ColorPaletteDialog(@NonNull Context context) {
|
||||||
|
super(context, R.style.ColorPaletteDialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorPaletteDialog(@NonNull Context context, int themeResId) {
|
||||||
|
super(context, themeResId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
// super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.dialog_color_palette);
|
||||||
|
|
||||||
|
TextView titleText = findViewById(R.id.title_text);
|
||||||
|
|
||||||
|
WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||||
|
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||||
|
getWindow().setAttributes(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnColorItemClick {
|
||||||
|
void onColorClick(int color);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package cc.winboll.studio.gallery.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import androidx.annotation.ColorInt;
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
public class BackgroundUtils {
|
||||||
|
|
||||||
|
public enum DrawableType {
|
||||||
|
RESOURCE_ID,
|
||||||
|
COLOR
|
||||||
|
}
|
||||||
|
|
||||||
|
private static volatile BackgroundUtils instance;
|
||||||
|
|
||||||
|
private static final String PREF_NAME = "background_prefs";
|
||||||
|
private static final String KEY_TYPE = "bg_type";
|
||||||
|
private static final String KEY_RES_ID = "bg_res_id";
|
||||||
|
private static final String KEY_COLOR = "bg_color";
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
private Drawable drawable;
|
||||||
|
private DrawableType drawableType;
|
||||||
|
private int resId;
|
||||||
|
private int color;
|
||||||
|
|
||||||
|
private BackgroundUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BackgroundUtils getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
synchronized (BackgroundUtils.class) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new BackgroundUtils();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BackgroundUtils initFromResource(Context context, @DrawableRes int resId) {
|
||||||
|
synchronized (BackgroundUtils.class) {
|
||||||
|
BackgroundUtils utils = getInstance();
|
||||||
|
utils.context = context.getApplicationContext();
|
||||||
|
utils.drawableType = DrawableType.RESOURCE_ID;
|
||||||
|
utils.resId = resId;
|
||||||
|
utils.drawable = ContextCompat.getDrawable(utils.context, resId);
|
||||||
|
utils.saveToPreferences();
|
||||||
|
return utils;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BackgroundUtils initFromColor(Context context, @ColorInt int color) {
|
||||||
|
synchronized (BackgroundUtils.class) {
|
||||||
|
BackgroundUtils utils = getInstance();
|
||||||
|
utils.context = context.getApplicationContext();
|
||||||
|
utils.drawableType = DrawableType.COLOR;
|
||||||
|
utils.color = color;
|
||||||
|
utils.drawable = new ColorDrawable(color);
|
||||||
|
utils.saveToPreferences();
|
||||||
|
return utils;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BackgroundUtils initFromPreferences(Context context) {
|
||||||
|
synchronized (BackgroundUtils.class) {
|
||||||
|
Context appContext = context.getApplicationContext();
|
||||||
|
SharedPreferences prefs = appContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||||
|
int type = prefs.getInt(KEY_TYPE, -1);
|
||||||
|
if (type == 0) {
|
||||||
|
int resId = prefs.getInt(KEY_RES_ID, 0);
|
||||||
|
if (resId != 0) {
|
||||||
|
return initFromResource(appContext, resId);
|
||||||
|
}
|
||||||
|
} else if (type == 1) {
|
||||||
|
int color = prefs.getInt(KEY_COLOR, Color.BLACK);
|
||||||
|
return initFromColor(appContext, color);
|
||||||
|
}
|
||||||
|
// 默认情况,initFromColor 内部已经调用了 saveToPreferences()
|
||||||
|
return initFromColor(appContext, 0xFF00FF00);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getDrawable() {
|
||||||
|
return drawable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DrawableType getDrawableType() {
|
||||||
|
return drawableType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DrawableType getAttributeValueType() {
|
||||||
|
return drawableType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getResId() {
|
||||||
|
return resId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveToPreferences() {
|
||||||
|
if (context == null) return;
|
||||||
|
SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
if (drawableType == DrawableType.RESOURCE_ID) {
|
||||||
|
editor.putInt(KEY_TYPE, 0);
|
||||||
|
editor.putInt(KEY_RES_ID, resId);
|
||||||
|
editor.remove(KEY_COLOR);
|
||||||
|
} else {
|
||||||
|
editor.putInt(KEY_TYPE, 1);
|
||||||
|
editor.putInt(KEY_COLOR, color);
|
||||||
|
editor.remove(KEY_RES_ID);
|
||||||
|
}
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearPreferences(Context context) {
|
||||||
|
SharedPreferences prefs = context.getApplicationContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||||
|
prefs.edit().clear().apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package cc.winboll.studio.gallery.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import androidx.annotation.ColorInt;
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
public class CropBackgroundUtils {
|
||||||
|
|
||||||
|
public enum DrawableType {
|
||||||
|
RESOURCE_ID,
|
||||||
|
COLOR
|
||||||
|
}
|
||||||
|
|
||||||
|
private static volatile CropBackgroundUtils instance;
|
||||||
|
|
||||||
|
private static final String PREF_NAME = "crop_background_prefs";
|
||||||
|
private static final String KEY_TYPE = "crop_bg_type";
|
||||||
|
private static final String KEY_RES_ID = "crop_bg_res_id";
|
||||||
|
private static final String KEY_COLOR = "crop_bg_color";
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
private Drawable drawable;
|
||||||
|
private DrawableType drawableType;
|
||||||
|
private int resId;
|
||||||
|
private int color;
|
||||||
|
|
||||||
|
private CropBackgroundUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CropBackgroundUtils getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
synchronized (CropBackgroundUtils.class) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new CropBackgroundUtils();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CropBackgroundUtils initFromResource(Context context, @DrawableRes int resId) {
|
||||||
|
synchronized (CropBackgroundUtils.class) {
|
||||||
|
CropBackgroundUtils utils = getInstance();
|
||||||
|
utils.context = context.getApplicationContext();
|
||||||
|
utils.drawableType = DrawableType.RESOURCE_ID;
|
||||||
|
utils.resId = resId;
|
||||||
|
utils.drawable = ContextCompat.getDrawable(utils.context, resId);
|
||||||
|
utils.saveToPreferences();
|
||||||
|
return utils;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CropBackgroundUtils initFromColor(Context context, @ColorInt int color) {
|
||||||
|
synchronized (CropBackgroundUtils.class) {
|
||||||
|
CropBackgroundUtils utils = getInstance();
|
||||||
|
utils.context = context.getApplicationContext();
|
||||||
|
utils.drawableType = DrawableType.COLOR;
|
||||||
|
utils.color = color;
|
||||||
|
utils.drawable = new ColorDrawable(color);
|
||||||
|
utils.saveToPreferences();
|
||||||
|
return utils;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CropBackgroundUtils initFromPreferences(Context context) {
|
||||||
|
synchronized (CropBackgroundUtils.class) {
|
||||||
|
Context appContext = context.getApplicationContext();
|
||||||
|
SharedPreferences prefs = appContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||||
|
int type = prefs.getInt(KEY_TYPE, -1);
|
||||||
|
if (type == 0) {
|
||||||
|
int resId = prefs.getInt(KEY_RES_ID, 0);
|
||||||
|
if (resId != 0) {
|
||||||
|
return initFromResource(appContext, resId);
|
||||||
|
}
|
||||||
|
} else if (type == 1) {
|
||||||
|
int color = prefs.getInt(KEY_COLOR, Color.BLACK);
|
||||||
|
return initFromColor(appContext, color);
|
||||||
|
}
|
||||||
|
return initFromColor(appContext, 0xFF00FF00);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getDrawable() {
|
||||||
|
return drawable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DrawableType getDrawableType() {
|
||||||
|
return drawableType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getResId() {
|
||||||
|
return resId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveToPreferences() {
|
||||||
|
if (context == null) return;
|
||||||
|
SharedPreferences prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
if (drawableType == DrawableType.RESOURCE_ID) {
|
||||||
|
editor.putInt(KEY_TYPE, 0);
|
||||||
|
editor.putInt(KEY_RES_ID, resId);
|
||||||
|
editor.remove(KEY_COLOR);
|
||||||
|
} else {
|
||||||
|
editor.putInt(KEY_TYPE, 1);
|
||||||
|
editor.putInt(KEY_COLOR, color);
|
||||||
|
editor.remove(KEY_RES_ID);
|
||||||
|
}
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearPreferences(Context context) {
|
||||||
|
SharedPreferences prefs = context.getApplicationContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
|
||||||
|
prefs.edit().clear().apply();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package cc.winboll.studio.gallery.views;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
|
public class BackgroundRadioButton extends RadioButton {
|
||||||
|
|
||||||
|
CustomApplicationBackground mCustomApplicationBackground;
|
||||||
|
|
||||||
|
public BackgroundRadioButton(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BackgroundRadioButton(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BackgroundRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupCustomApplicationBackground(Context context, int resId) {
|
||||||
|
mCustomApplicationBackground = new CustomApplicationBackground(context, resId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomApplicationBackground(CustomApplicationBackground customApplicationBackground) {
|
||||||
|
mCustomApplicationBackground = customApplicationBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomApplicationBackground getCustomApplicationBackground() {
|
||||||
|
return mCustomApplicationBackground;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package cc.winboll.studio.gallery.views;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
public class CustomApplicationBackground {
|
||||||
|
Drawable mDrawable;
|
||||||
|
|
||||||
|
public CustomApplicationBackground(Drawable drawable) {
|
||||||
|
mDrawable = drawable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomApplicationBackground(int color) {
|
||||||
|
mDrawable = new ColorDrawable(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CustomApplicationBackground(Context context, int resId) {
|
||||||
|
mDrawable = context.getDrawable(resId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getDrawable() {
|
||||||
|
return mDrawable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDrawable(Drawable drawable) {
|
||||||
|
mDrawable = drawable;
|
||||||
|
}
|
||||||
|
}
|
||||||
7
gallery/src/main/res/drawable/bg_color_circle.xml
Normal file
7
gallery/src/main/res/drawable/bg_color_circle.xml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<solid android:color="@android:color/transparent"/>
|
||||||
|
<stroke android:width="2dp" android:color="@android:color/white"/>
|
||||||
|
<size android:width="32dp" android:height="32dp"/>
|
||||||
|
</shape>
|
||||||
6
gallery/src/main/res/drawable/bg_color_circle_border.xml
Normal file
6
gallery/src/main/res/drawable/bg_color_circle_border.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<stroke android:width="2dp" android:color="@android:color/white"/>
|
||||||
|
<size android:width="36dp" android:height="36dp"/>
|
||||||
|
</shape>
|
||||||
6
gallery/src/main/res/drawable/bg_dialog.xml
Normal file
6
gallery/src/main/res/drawable/bg_dialog.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@android:color/black"/>
|
||||||
|
<stroke android:width="2dp" android:color="@android:color/white"/>
|
||||||
|
</shape>
|
||||||
@@ -5,9 +5,9 @@
|
|||||||
android:viewportWidth="24"
|
android:viewportWidth="24"
|
||||||
android:viewportHeight="24">
|
android:viewportHeight="24">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#000000"
|
android:fillColor="#FFFFFF"
|
||||||
android:pathData="M21,3H3C1.9,3 1,3.9 1,5v14c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2V5C23,3.9 22.1,3 21,3zM21,19H3V5h18V19z"/>
|
android:pathData="M21,3H3C1.9,3 1,3.9 1,5v14c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2V5C23,3.9 22.1,3 21,3zM21,19H3V5h18V19z"/>
|
||||||
<path
|
<path
|
||||||
android:fillColor="#000000"
|
android:fillColor="#FFFFFF"
|
||||||
android:pathData="M9,12l2,2l4,-4l1.5,1.5L11,17l-3,-3z"/>
|
android:pathData="M9,12l2,2l4,-4l1.5,1.5L11,17l-3,-3z"/>
|
||||||
</vector>
|
</vector>
|
||||||
16
gallery/src/main/res/drawable/ic_mi_gallery.xml
Normal file
16
gallery/src/main/res/drawable/ic_mi_gallery.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10s10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8s8,3.59 8,8s-3.59,8 -8,8z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5s5,-2.24 5,-5s-2.24,-5 -5,-5zM12,15c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3s3,1.34 3,3s-1.34,3 -3,3z"/>
|
||||||
|
<path
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:pathData="M8,12l1.5,-2l2,2.5l2.5,-3l2,2.5"/>
|
||||||
|
</vector>
|
||||||
11
gallery/src/main/res/drawable/ic_view_gallery_outline.xml
Normal file
11
gallery/src/main/res/drawable/ic_view_gallery_outline.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M1,3V21H23V3H1M21,5V14H3V5H21M11,16V19H8V16H11M3,16H6V19H3V16M13,19V16H16V19H13M18,19V16H21V19H18Z"/>
|
||||||
|
|
||||||
|
</vector>
|
||||||
@@ -15,30 +15,51 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/btn_close"
|
android:id="@+id/btn_close"
|
||||||
android:layout_width="48dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="40dp"
|
||||||
android:padding="12dp"
|
android:padding="5dp"
|
||||||
android:src="@drawable/ic_close"
|
android:src="@drawable/ic_close"
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"/>
|
android:background="?attr/selectableItemBackgroundBorderless"/>
|
||||||
|
|
||||||
<ImageView
|
<TextView
|
||||||
android:id="@+id/btn_color_pick"
|
android:id="@+id/textview_window_name"
|
||||||
android:layout_width="48dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:padding="12dp"
|
android:text="封面剪裁"
|
||||||
android:src="@drawable/ic_color_pick"
|
android:textColor="@android:color/white"
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"/>
|
android:textSize="18sp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginEnd="8dp"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btn_info"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:src="@drawable/ic_info"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/btn_change_bg"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:src="@drawable/ic_color_pick"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:contentDescription="修改剪裁背景颜色"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/btn_done"
|
android:id="@+id/btn_done"
|
||||||
android:layout_width="48dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="40dp"
|
||||||
android:padding="12dp"
|
android:padding="5dp"
|
||||||
android:src="@drawable/ic_done"
|
android:src="@drawable/ic_done"
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"/>
|
android:background="?attr/selectableItemBackgroundBorderless"/>
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,14 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/btn_gallery"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:src="@drawable/ic_view_gallery_outline"
|
||||||
|
android:contentDescription="Gallery"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/btn_share"
|
android:id="@+id/btn_share"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
@@ -52,14 +60,6 @@
|
|||||||
android:src="@drawable/ic_info"
|
android:src="@drawable/ic_info"
|
||||||
android:contentDescription="Info"/>
|
android:contentDescription="Info"/>
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/btn_bg"
|
|
||||||
android:layout_width="48dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:background="?attr/selectableItemBackgroundBorderless"
|
|
||||||
android:src="@drawable/ic_bg"
|
|
||||||
android:contentDescription="Background"/>
|
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/btn_delete"
|
android:id="@+id/btn_delete"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/black"/>
|
android:background="@android:color/transparent"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
16
gallery/src/main/res/layout/dialog_color_palette.xml
Normal file
16
gallery/src/main/res/layout/dialog_color_palette.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_dialog"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
36
gallery/src/main/res/layout/dialog_crop_info.xml
Normal file
36
gallery/src/main/res/layout/dialog_crop_info.xml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
android:background="@drawable/bg_dialog"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/info_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:fontFamily="monospace"
|
||||||
|
android:textColor="@android:color/white"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/preview_image_container"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="2dp"
|
||||||
|
android:background="#FFBBD505">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/preview_image"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scaleType="fitCenter"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
20
gallery/src/main/res/layout/item_color_icon.xml
Normal file
20
gallery/src/main/res/layout/item_color_icon.xml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="40dp"
|
||||||
|
android:layout_height="40dp">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/color_view"
|
||||||
|
android:layout_width="32dp"
|
||||||
|
android:layout_height="32dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@drawable/bg_color_circle"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@drawable/bg_color_circle_border"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
@@ -2,6 +2,17 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_mi_gallery"
|
||||||
|
android:title="@string/mi_gallery"
|
||||||
|
android:icon="@drawable/ic_mi_gallery"
|
||||||
|
app:showAsAction="ifRoom"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_change_bg_color"
|
||||||
|
android:title="修改背景颜色"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_trash"
|
android:id="@+id/action_trash"
|
||||||
android:title="@string/trash"
|
android:title="@string/trash"
|
||||||
|
|||||||
@@ -18,4 +18,7 @@
|
|||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
<string name="debug_log">Debug Log</string>
|
<string name="debug_log">Debug Log</string>
|
||||||
<string name="debug_message">Debug log message</string>
|
<string name="debug_message">Debug log message</string>
|
||||||
|
<string name="system_gallery">系统相册</string>
|
||||||
|
<string name="mi_gallery">小米相册</string>
|
||||||
|
<string name="reset_gallery">重置</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -8,4 +8,9 @@
|
|||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="ColorPaletteDialog" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
|
<item name="android:windowIsFloating">false</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user