Compare commits

...

4 Commits

6 changed files with 182 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle #Created by .winboll/winboll_app_build.gradle
#Sat Apr 25 05:49:42 HKT 2026 #Sat Apr 25 06:42:01 HKT 2026
stageCount=1 stageCount=3
libraryProject= libraryProject=
baseVersion=15.0 baseVersion=15.0
publishVersion=15.0.0 publishVersion=15.0.2
buildCount=0 buildCount=0
baseBetaVersion=15.0.1 baseBetaVersion=15.0.3

View File

@@ -32,6 +32,7 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
private ImageButton btnBack; private ImageButton btnBack;
private ImageButton btnDelete; private ImageButton btnDelete;
private ImageButton btnShare; private ImageButton btnShare;
private ImageButton btnInfo;
private GestureDetector gestureDetector; private GestureDetector gestureDetector;
private TrashManager trashManager; private TrashManager trashManager;
@@ -54,6 +55,7 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
btnBack = findViewById(R.id.btn_back); btnBack = findViewById(R.id.btn_back);
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);
ImagePagerAdapter adapter = new ImagePagerAdapter(imageUrls); ImagePagerAdapter adapter = new ImagePagerAdapter(imageUrls);
viewPager.setAdapter(adapter); viewPager.setAdapter(adapter);
@@ -95,6 +97,13 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
shareCurrentImage(); shareCurrentImage();
} }
}); });
btnInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showImageInfo();
}
});
} }
private void toggleToolbar() { private void toggleToolbar() {
@@ -201,6 +210,155 @@ public class ImageViewerActivity extends Activity implements ViewPager.OnPageCha
} }
} }
private void showImageInfo() {
if (currentPosition < 0 || currentPosition >= imageUrls.size()) {
return;
}
String imagePath = "";
if (imagePaths != null && currentPosition < imagePaths.size()) {
imagePath = imagePaths.get(currentPosition);
} else {
imagePath = getPathFromUri(imageUrls.get(currentPosition));
}
File imageFile = new File(imagePath);
if (!imageFile.exists()) {
imageFile = new File(imagePath);
}
android.widget.LinearLayout layout = new android.widget.LinearLayout(this);
layout.setOrientation(android.widget.LinearLayout.VERTICAL);
layout.setPadding(48, 32, 48, 32);
android.widget.TextView labelPath = new android.widget.TextView(this);
labelPath.setText("Path:");
labelPath.setTextColor(getColor(android.R.color.darker_gray));
labelPath.setTextSize(14);
labelPath.setTypeface(null, android.graphics.Typeface.BOLD);
layout.addView(labelPath);
android.widget.TextView valuePath = new android.widget.TextView(this);
valuePath.setText(imagePath);
valuePath.setTextColor(getColor(android.R.color.black));
valuePath.setTextSize(14);
valuePath.setTextIsSelectable(true);
layout.addView(valuePath);
if (imageFile.exists()) {
long sizeBytes = imageFile.length();
String size;
if (sizeBytes < 1024) {
size = sizeBytes + " B";
} else if (sizeBytes < 1024 * 1024) {
size = String.format("%.2f KB", sizeBytes / 1024.0);
} else {
size = String.format("%.2f MB", sizeBytes / (1024.0 * 1024.0));
}
android.widget.TextView labelSize = new android.widget.TextView(this);
labelSize.setText("Size:");
labelSize.setTextColor(getColor(android.R.color.darker_gray));
labelSize.setTextSize(14);
labelSize.setTypeface(null, android.graphics.Typeface.BOLD);
layout.addView(labelSize);
android.widget.TextView valueSize = new android.widget.TextView(this);
valueSize.setText(size);
valueSize.setTextColor(getColor(android.R.color.black));
valueSize.setTextSize(14);
valueSize.setTextIsSelectable(true);
layout.addView(valueSize);
}
try {
android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory.Options();
options.inJustDecodeBounds = true;
android.graphics.BitmapFactory.decodeFile(imagePath, options);
if (options.outWidth > 0 && options.outHeight > 0) {
android.widget.TextView labelPixels = new android.widget.TextView(this);
labelPixels.setText("Pixels:");
labelPixels.setTextColor(getColor(android.R.color.darker_gray));
labelPixels.setTextSize(14);
labelPixels.setTypeface(null, android.graphics.Typeface.BOLD);
layout.addView(labelPixels);
android.widget.TextView valuePixels = new android.widget.TextView(this);
valuePixels.setText(options.outWidth + " x " + options.outHeight);
valuePixels.setTextColor(getColor(android.R.color.black));
valuePixels.setTextSize(14);
valuePixels.setTextIsSelectable(true);
layout.addView(valuePixels);
}
} catch (Exception e) {
LogUtils.e(TAG, "get pixels error: " + e.getMessage());
}
try {
String[] projection = {
MediaStore.Images.Media.DATE_ADDED,
MediaStore.Images.Media.DATE_MODIFIED,
MediaStore.Images.Media.DATE_TAKEN
};
android.database.Cursor cursor = getContentResolver().query(
imageUrls.get(currentPosition), projection, null, null, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
int dateAddedCol = cursor.getColumnIndex(MediaStore.Images.Media.DATE_ADDED);
int dateTakenCol = cursor.getColumnIndex(MediaStore.Images.Media.DATE_TAKEN);
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (dateTakenCol >= 0) {
long dateTaken = cursor.getLong(dateTakenCol);
if (dateTaken > 0) {
android.widget.TextView labelTaken = new android.widget.TextView(this);
labelTaken.setText("Date Taken:");
labelTaken.setTextColor(getColor(android.R.color.darker_gray));
labelTaken.setTextSize(14);
labelTaken.setTypeface(null, android.graphics.Typeface.BOLD);
layout.addView(labelTaken);
android.widget.TextView valueTaken = new android.widget.TextView(this);
valueTaken.setText(sdf.format(new java.util.Date(dateTaken)));
valueTaken.setTextColor(getColor(android.R.color.black));
valueTaken.setTextSize(14);
valueTaken.setTextIsSelectable(true);
layout.addView(valueTaken);
}
}
if (dateAddedCol >= 0) {
long dateAdded = cursor.getLong(dateAddedCol);
if (dateAdded > 0) {
android.widget.TextView labelAdded = new android.widget.TextView(this);
labelAdded.setText("Date Added:");
labelAdded.setTextColor(getColor(android.R.color.darker_gray));
labelAdded.setTextSize(14);
labelAdded.setTypeface(null, android.graphics.Typeface.BOLD);
layout.addView(labelAdded);
android.widget.TextView valueAdded = new android.widget.TextView(this);
valueAdded.setText(sdf.format(new java.util.Date(dateAdded * 1000)));
valueAdded.setTextColor(getColor(android.R.color.black));
valueAdded.setTextSize(14);
valueAdded.setTextIsSelectable(true);
layout.addView(valueAdded);
}
}
}
cursor.close();
}
} catch (Exception e) {
LogUtils.e(TAG, "get date error: " + e.getMessage());
}
new AlertDialog.Builder(this)
.setTitle("Image Info")
.setView(layout)
.setPositiveButton("OK", null)
.show();
}
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
currentPosition = position; currentPosition = position;

View File

@@ -138,9 +138,9 @@ public class MainActivity extends AppCompatActivity {
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 = Environment.getExternalStorageDirectory() + "/DCIM"; folderPath = Preferences.getDefaultPath();
baseFolder = new File(folderPath); baseFolder = new File(folderPath);
LogUtils.d(TAG, "try DCIM: " + baseFolder.getAbsolutePath() + ", exists=" + baseFolder.exists()); LogUtils.d(TAG, "try default: " + baseFolder.getAbsolutePath() + ", exists=" + baseFolder.exists());
if (!baseFolder.exists()) { if (!baseFolder.exists()) {
folderPath = Environment.getExternalStorageDirectory() + "/Pictures"; folderPath = Environment.getExternalStorageDirectory() + "/Pictures";
baseFolder = new File(folderPath); baseFolder = new File(folderPath);

View File

@@ -8,7 +8,7 @@ public class Preferences {
public static final String TAG = "Preferences"; public static final String TAG = "Preferences";
private static final String PREF_NAME = "gallery_prefs"; private static final String PREF_NAME = "gallery_prefs";
private static final String KEY_FOLDER_PATH = "folder_path"; private static final String KEY_FOLDER_PATH = "folder_path";
private static final String DEFAULT_PATH = "/storage/emulated/0/DCIM"; private static final String DEFAULT_PATH = "/storage/emulated/0/Pictures/Gallery/owner";
public static String getDefaultPath() { public static String getDefaultPath() {
return DEFAULT_PATH; return DEFAULT_PATH;

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFF"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
</vector>

View File

@@ -44,6 +44,14 @@
android:src="@drawable/ic_share" android:src="@drawable/ic_share"
android:contentDescription="Share"/> android:contentDescription="Share"/>
<ImageButton
android:id="@+id/btn_info"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_info"
android:contentDescription="Info"/>
<ImageButton <ImageButton
android:id="@+id/btn_delete" android:id="@+id/btn_delete"
android:layout_width="48dp" android:layout_width="48dp"