mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
gray icon & texy for inaccessible folders
This commit is contained in:
parent
4bfd0bb29f
commit
7a18393e5a
6 changed files with 38 additions and 10 deletions
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 6.1 KiB |
|
@ -24,7 +24,7 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Paint;
|
import android.graphics.*;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -235,7 +235,6 @@ public class IFileAdapter extends BaseAdapter {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final class Bag {
|
private static final class Bag {
|
||||||
|
|
||||||
ImageView mImageIcon;
|
ImageView mImageIcon;
|
||||||
TextView mTxtFileName;
|
TextView mTxtFileName;
|
||||||
TextView mTxtFileInfo;
|
TextView mTxtFileInfo;
|
||||||
|
@ -290,6 +289,17 @@ public class IFileAdapter extends BaseAdapter {
|
||||||
|
|
||||||
// file icon
|
// file icon
|
||||||
bag.mImageIcon.setImageResource(FileUtils.getResIcon(file, mFilterMode));
|
bag.mImageIcon.setImageResource(FileUtils.getResIcon(file, mFilterMode));
|
||||||
|
final ColorMatrix matrix = new ColorMatrix();
|
||||||
|
if (!FileUtils.isAccessible(file, mFilterMode)) {
|
||||||
|
final ColorMatrix scaleMatrix = new ColorMatrix();
|
||||||
|
scaleMatrix.setScale(.7f, .7f, .7f, 1f);
|
||||||
|
final ColorMatrix saturationMatrix = new ColorMatrix();
|
||||||
|
saturationMatrix.setSaturation(0f);
|
||||||
|
matrix.setConcat(saturationMatrix, scaleMatrix);
|
||||||
|
bag.mTxtFileName.setEnabled(false);
|
||||||
|
bag.mTxtFileInfo.setEnabled(false);
|
||||||
|
}
|
||||||
|
bag.mImageIcon.setColorFilter(new ColorMatrixColorFilter(matrix));
|
||||||
|
|
||||||
// filename
|
// filename
|
||||||
bag.mTxtFileName.setText(file.getSecondName());
|
bag.mTxtFileName.setText(file.getSecondName());
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class FileUtils {
|
||||||
*/
|
*/
|
||||||
public static int getResIcon(IFile file, final IFileProvider.FilterMode filterMode) {
|
public static int getResIcon(IFile file, final IFileProvider.FilterMode filterMode) {
|
||||||
if (file == null || !file.exists())
|
if (file == null || !file.exists())
|
||||||
return 0;//android.R.drawable.ic_delete;
|
return R.drawable.afc_file;
|
||||||
|
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
String filename = file.getName();
|
String filename = file.getName();
|
||||||
|
@ -76,24 +76,42 @@ public class FileUtils {
|
||||||
if (file instanceof ParentFile) {
|
if (file instanceof ParentFile) {
|
||||||
return R.drawable.afc_folder;
|
return R.drawable.afc_folder;
|
||||||
} else if (accessDenied(file)) {
|
} else if (accessDenied(file)) {
|
||||||
return R.drawable.afc_folder_no_access;
|
return R.drawable.afc_folder;
|
||||||
} else {
|
} else {
|
||||||
return R.drawable.afc_folder_locked;
|
return R.drawable.afc_folder_locked;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return R.drawable.afc_folder;
|
return R.drawable.afc_folder;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (accessDenied(file)) {
|
|
||||||
return R.drawable.afc_folder_no_access;
|
|
||||||
} else {
|
} else {
|
||||||
return R.drawable.afc_folder;
|
return R.drawable.afc_folder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return R.drawable.afc_file;
|
||||||
|
}// getResIcon()
|
||||||
|
|
||||||
|
public static boolean isAccessible(IFile file, final IFileProvider.FilterMode filterMode) {
|
||||||
|
if (file == null || !file.exists()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;//android.R.drawable.ic_delete;
|
if (file.isFile()) {
|
||||||
}// getResIcon()
|
return true;
|
||||||
|
} else if (file.isDirectory()) {
|
||||||
|
if (filterMode != IFileProvider.FilterMode.AnyDirectories) {
|
||||||
|
if (file instanceof File && !((File)file).canWrite()) {
|
||||||
|
return (file instanceof ParentFile || !accessDenied(file));
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return !accessDenied(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}// isAccessible()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the filename given is valid or not.<br>
|
* Checks whether the filename given is valid or not.<br>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue