mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +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 android.content.Context;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.*;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -235,7 +235,6 @@ public class IFileAdapter extends BaseAdapter {
|
|||
*
|
||||
*/
|
||||
private static final class Bag {
|
||||
|
||||
ImageView mImageIcon;
|
||||
TextView mTxtFileName;
|
||||
TextView mTxtFileInfo;
|
||||
|
@ -290,6 +289,17 @@ public class IFileAdapter extends BaseAdapter {
|
|||
|
||||
// file icon
|
||||
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
|
||||
bag.mTxtFileName.setText(file.getSecondName());
|
||||
|
|
|
@ -61,7 +61,7 @@ public class FileUtils {
|
|||
*/
|
||||
public static int getResIcon(IFile file, final IFileProvider.FilterMode filterMode) {
|
||||
if (file == null || !file.exists())
|
||||
return 0;//android.R.drawable.ic_delete;
|
||||
return R.drawable.afc_file;
|
||||
|
||||
if (file.isFile()) {
|
||||
String filename = file.getName();
|
||||
|
@ -76,7 +76,7 @@ public class FileUtils {
|
|||
if (file instanceof ParentFile) {
|
||||
return R.drawable.afc_folder;
|
||||
} else if (accessDenied(file)) {
|
||||
return R.drawable.afc_folder_no_access;
|
||||
return R.drawable.afc_folder;
|
||||
} else {
|
||||
return R.drawable.afc_folder_locked;
|
||||
}
|
||||
|
@ -84,17 +84,35 @@ public class FileUtils {
|
|||
return R.drawable.afc_folder;
|
||||
}
|
||||
} else {
|
||||
if (accessDenied(file)) {
|
||||
return R.drawable.afc_folder_no_access;
|
||||
} else {
|
||||
return R.drawable.afc_folder;
|
||||
}
|
||||
return R.drawable.afc_folder;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;//android.R.drawable.ic_delete;
|
||||
return R.drawable.afc_file;
|
||||
}// getResIcon()
|
||||
|
||||
public static boolean isAccessible(IFile file, final IFileProvider.FilterMode filterMode) {
|
||||
if (file == null || !file.exists()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.isFile()) {
|
||||
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>
|
||||
* See <a href="http://en.wikipedia.org/wiki/Filename">wiki</a> for more
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue