Compare commits
5 Commits
gallery-v1
...
gallery-v1
| Author | SHA1 | Date | |
|---|---|---|---|
| bef3f3ce81 | |||
| c0da46e0fd | |||
| 72ca11a1af | |||
| 5decb2f8d9 | |||
| 29e7cfe985 |
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Fri May 01 09:21:07 HKT 2026
|
#Fri May 01 21:09:33 HKT 2026
|
||||||
stageCount=14
|
stageCount=16
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.0
|
baseVersion=15.0
|
||||||
publishVersion=15.0.13
|
publishVersion=15.0.15
|
||||||
buildCount=0
|
buildCount=0
|
||||||
baseBetaVersion=15.0.14
|
baseBetaVersion=15.0.16
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package cc.winboll.studio.gallery;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
|
public class BgSelectorDialog extends Dialog {
|
||||||
|
|
||||||
|
public interface OnBgSelectedListener {
|
||||||
|
void onBgSelected(int bgType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int currentBgType;
|
||||||
|
private OnBgSelectedListener listener;
|
||||||
|
|
||||||
|
public BgSelectorDialog(Context context, int currentBgType) {
|
||||||
|
super(context);
|
||||||
|
this.currentBgType = currentBgType;
|
||||||
|
setContentView(R.layout.dialog_bg_selector);
|
||||||
|
initViews();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initViews() {
|
||||||
|
RadioGroup radioGroup = findViewById(R.id.radio_group_bg);
|
||||||
|
RadioButton radioCheckerboard = findViewById(R.id.radio_checkerboard);
|
||||||
|
RadioButton radioWhite = findViewById(R.id.radio_white);
|
||||||
|
RadioButton radioBlack = findViewById(R.id.radio_black);
|
||||||
|
|
||||||
|
switch (currentBgType) {
|
||||||
|
case 0:
|
||||||
|
radioCheckerboard.setChecked(true);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
radioWhite.setChecked(true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
radioBlack.setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
|
int which = 0;
|
||||||
|
if (checkedId == R.id.radio_white) {
|
||||||
|
which = 1;
|
||||||
|
} else if (checkedId == R.id.radio_black) {
|
||||||
|
which = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onBgSelected(which);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnBgSelectedListener(OnBgSelectedListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,7 @@ 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.TextView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@@ -26,6 +27,7 @@ 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";
|
||||||
@@ -147,25 +149,20 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showBgDialog() {
|
private void showBgDialog() {
|
||||||
final String[] bgNames = {"灰白相间", "全白", "全黑"};
|
|
||||||
final int[] bgDrawables = {R.drawable.bg_checkerboard, R.drawable.bg_white, R.drawable.bg_black};
|
|
||||||
final View colorView = findViewById(R.id.color_view);
|
final View colorView = findViewById(R.id.color_view);
|
||||||
final GradientDrawable colorDrawable = (GradientDrawable) colorView.getBackground();
|
final GradientDrawable colorDrawable = (GradientDrawable) colorView.getBackground();
|
||||||
final int currentBgType = cropCanvasView.getBackgroundType();
|
final int currentBgType = cropCanvasView.getBackgroundType();
|
||||||
|
|
||||||
new AlertDialog.Builder(this)
|
BgSelectorDialog dialog = new BgSelectorDialog(this, currentBgType);
|
||||||
.setTitle("选择背景")
|
dialog.setOnBgSelectedListener(new BgSelectorDialog.OnBgSelectedListener() {
|
||||||
.setSingleChoiceItems(bgNames, currentBgType, new android.content.DialogInterface.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onBgSelected(int which) {
|
||||||
public void onClick(android.content.DialogInterface dialog, int which) {
|
cropCanvasView.setBackgroundType(which);
|
||||||
cropCanvasView.setBackgroundType(which);
|
prefs.setBgType(which);
|
||||||
prefs.setBgType(which);
|
updateColorView(colorDrawable, which);
|
||||||
updateColorView(colorDrawable, which);
|
}
|
||||||
dialog.dismiss();
|
});
|
||||||
}
|
dialog.show();
|
||||||
})
|
|
||||||
.setNegativeButton("取消", null)
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadImage() {
|
private void loadImage() {
|
||||||
@@ -315,10 +312,18 @@ public class CropActivity extends AppCompatActivity {
|
|||||||
View dialogView = getLayoutInflater().inflate(R.layout.dialog_crop_info, null);
|
View dialogView = getLayoutInflater().inflate(R.layout.dialog_crop_info, null);
|
||||||
TextView infoText = dialogView.findViewById(R.id.info_text);
|
TextView infoText = dialogView.findViewById(R.id.info_text);
|
||||||
ImageView previewImage = dialogView.findViewById(R.id.preview_image);
|
ImageView previewImage = dialogView.findViewById(R.id.preview_image);
|
||||||
|
LinearLayout previewImageContainer = dialogView.findViewById(R.id.preview_image_container);
|
||||||
infoText.setText(info.toString());
|
infoText.setText(info.toString());
|
||||||
if (previewBitmap != null) {
|
if (previewBitmap != null) {
|
||||||
previewImage.setImageBitmap(previewBitmap);
|
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)
|
AlertDialog dialog = new AlertDialog.Builder(this)
|
||||||
.setTitle("裁剪信息")
|
.setTitle("裁剪信息")
|
||||||
|
|||||||
@@ -169,28 +169,24 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void switchBg() {
|
private void switchBg() {
|
||||||
final String[] bgNames = {"灰白相间", "全白", "全黑"};
|
|
||||||
final int[] bgResources = {R.drawable.bg_checkerboard, R.drawable.bg_white, R.drawable.bg_black};
|
final int[] bgResources = {R.drawable.bg_checkerboard, R.drawable.bg_white, R.drawable.bg_black};
|
||||||
|
|
||||||
new AlertDialog.Builder(this)
|
BgSelectorDialog dialog = new BgSelectorDialog(this, bgType);
|
||||||
.setTitle("选择背景")
|
dialog.setOnBgSelectedListener(new BgSelectorDialog.OnBgSelectedListener() {
|
||||||
.setSingleChoiceItems(bgNames, bgType, new android.content.DialogInterface.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onBgSelected(int which) {
|
||||||
public void onClick(android.content.DialogInterface dialog, int which) {
|
bgType = which;
|
||||||
bgType = which;
|
prefs.setBgType(which);
|
||||||
prefs.setBgType(which);
|
int currentItem = viewPager.getCurrentItem();
|
||||||
int currentItem = viewPager.getCurrentItem();
|
View container = findViewById(R.id.container);
|
||||||
View container = findViewById(R.id.container);
|
if (container != null) {
|
||||||
if (container != null) {
|
container.setBackgroundResource(bgResources[which]);
|
||||||
container.setBackgroundResource(bgResources[which]);
|
|
||||||
}
|
|
||||||
viewPager.setAdapter(new ImagePagerAdapter(imageUrls, bgType));
|
|
||||||
viewPager.setCurrentItem(currentItem);
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
}
|
||||||
})
|
viewPager.setAdapter(new ImagePagerAdapter(imageUrls, bgType));
|
||||||
.setNegativeButton("取消", null)
|
viewPager.setCurrentItem(currentItem);
|
||||||
.show();
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showDeleteDialog() {
|
private void showDeleteDialog() {
|
||||||
|
|||||||
45
gallery/src/main/res/layout/dialog_bg_selector.xml
Normal file
45
gallery/src/main/res/layout/dialog_bg_selector.xml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="选择背景"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingBottom="16dp" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/radio_group_bg"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radio_checkerboard"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="灰白相间"
|
||||||
|
android:padding="12dp" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radio_white"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="全白"
|
||||||
|
android:padding="12dp" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/radio_black"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="全黑"
|
||||||
|
android:padding="12dp" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -1,26 +1,36 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:background="@drawable/bg_dialog">
|
android:background="@drawable/bg_dialog"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/info_text"
|
android:id="@+id/info_text"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:fontFamily="monospace"
|
android:fontFamily="monospace"
|
||||||
android:textColor="@android:color/white"/>
|
android:textColor="@android:color/white"/>
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:id="@+id/preview_image"
|
android:id="@+id/preview_image_container"
|
||||||
android:layout_width="match_parent"
|
android:orientation="horizontal"
|
||||||
android:layout_height="200dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_height="wrap_content"
|
||||||
android:scaleType="fitCenter"
|
android:padding="2dp"
|
||||||
android:background="@android:color/black"/>
|
android:background="#FFBBD505">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/preview_image"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scaleType="fitCenter"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
Reference in New Issue
Block a user