mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
more androidish way for disabled icons; use selected path
This commit is contained in:
parent
5328375941
commit
cea22e0d6d
12 changed files with 44 additions and 20 deletions
|
@ -98,7 +98,7 @@ public class FixBooksDirectoryActivity extends Activity {
|
|||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == 1 && resultCode == RESULT_OK) {
|
||||
myDirectoryView.setText(FileChooserUtil.pathFromData(data));
|
||||
myDirectoryView.setText(FileChooserUtil.folderPathFromData(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.geometerplus.android.fbreader.preferences.background;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
@ -96,7 +98,13 @@ public class Chooser extends ListActivity implements AdapterView.OnItemClickList
|
|||
finish();
|
||||
break;
|
||||
case 2:
|
||||
System.err.println("FILE DATA: " + data);
|
||||
final List<String> paths = FileChooserUtil.filePathsFromData(data);
|
||||
if (paths.size() == 1) {
|
||||
setResult(RESULT_OK, new Intent().putExtra(
|
||||
BackgroundPreference.VALUE_KEY, paths.get(0)
|
||||
));
|
||||
finish();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class FileChooserSinglePreference extends FileChooserPreference {
|
|||
|
||||
@Override
|
||||
protected void setValueFromIntent(Intent data) {
|
||||
final String value = FileChooserUtil.pathFromData(data);
|
||||
final String value = FileChooserUtil.folderPathFromData(data);
|
||||
if (MiscUtil.isEmptyString(value)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,9 @@ import android.content.Intent;
|
|||
import android.os.Parcelable;
|
||||
|
||||
import group.pals.android.lib.ui.filechooser.FileChooserActivity;
|
||||
import group.pals.android.lib.ui.filechooser.services.IFileProvider;
|
||||
import group.pals.android.lib.ui.filechooser.io.IFile;
|
||||
import group.pals.android.lib.ui.filechooser.io.localfile.LocalFile;
|
||||
import group.pals.android.lib.ui.filechooser.services.IFileProvider;
|
||||
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
|
@ -95,10 +96,19 @@ public abstract class FileChooserUtil {
|
|||
activity.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
public static String pathFromData(Intent data) {
|
||||
public static String folderPathFromData(Intent data) {
|
||||
return data.getStringExtra(FileChooserActivity._FolderPath);
|
||||
}
|
||||
|
||||
public static List<String> filePathsFromData(Intent data) {
|
||||
final List<IFile> files = data.getParcelableArrayListExtra(FileChooserActivity._Results);
|
||||
final List<String> paths = new ArrayList<String>(files.size());
|
||||
for (IFile f : files) {
|
||||
paths.add(f.getAbsolutePath());
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
public static List<String> pathListFromData(Intent data) {
|
||||
return data.getStringArrayListExtra(FolderListDialogActivity.Key.FOLDER_LIST);
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class FolderListDialogActivity extends ListActivity {
|
|||
@Override
|
||||
protected void onActivityResult(int index, int resultCode, Intent data) {
|
||||
if (resultCode == RESULT_OK) {
|
||||
final String path = FileChooserUtil.pathFromData(data);
|
||||
final String path = FileChooserUtil.folderPathFromData(data);
|
||||
final int existing = myFolderList.indexOf(path);
|
||||
if (existing == -1) {
|
||||
if (index == 0) {
|
||||
|
|
BIN
third-party/android-filechooser/code/res/drawable-hdpi/afc_folder_disabled.png
vendored
Normal file
BIN
third-party/android-filechooser/code/res/drawable-hdpi/afc_folder_disabled.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
BIN
third-party/android-filechooser/code/res/drawable-ldpi/afc_folder_disabled.png
vendored
Normal file
BIN
third-party/android-filechooser/code/res/drawable-ldpi/afc_folder_disabled.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 507 B |
BIN
third-party/android-filechooser/code/res/drawable-mdpi/afc_folder_disabled.png
vendored
Normal file
BIN
third-party/android-filechooser/code/res/drawable-mdpi/afc_folder_disabled.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 683 B |
BIN
third-party/android-filechooser/code/res/drawable-xhdpi/afc_folder_disabled.png
vendored
Normal file
BIN
third-party/android-filechooser/code/res/drawable-xhdpi/afc_folder_disabled.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
14
third-party/android-filechooser/code/res/drawable/afc_item_folder.xml
vendored
Executable file
14
third-party/android-filechooser/code/res/drawable/afc_item_folder.xml
vendored
Executable file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (c) 2012 Hai Bison
|
||||
|
||||
See the file LICENSE at the root directory of this project for copying
|
||||
permission.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:drawable="@drawable/afc_folder_disabled" android:state_enabled="false"/> <!-- enabled -->
|
||||
<item android:drawable="@drawable/afc_folder"/> <!-- default -->
|
||||
|
||||
</selector>
|
|
@ -24,7 +24,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.*;
|
||||
import android.graphics.Paint;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -288,18 +288,8 @@ public class IFileAdapter extends BaseAdapter {
|
|||
*/
|
||||
bag.mTxtFileName.setSingleLine(parent instanceof GridView);
|
||||
|
||||
final boolean isAccessible = FileUtils.isAccessible(file, mFilenameRegexp);
|
||||
// file icon
|
||||
bag.mImageIcon.setImageResource(FileUtils.getResIcon(file, mFilterMode));
|
||||
final ColorMatrix matrix = new ColorMatrix();
|
||||
if (!isAccessible) {
|
||||
final ColorMatrix scaleMatrix = new ColorMatrix();
|
||||
scaleMatrix.setScale(.7f, .7f, .7f, 1f);
|
||||
final ColorMatrix saturationMatrix = new ColorMatrix();
|
||||
saturationMatrix.setSaturation(0f);
|
||||
matrix.setConcat(saturationMatrix, scaleMatrix);
|
||||
}
|
||||
bag.mImageIcon.setColorFilter(new ColorMatrixColorFilter(matrix));
|
||||
|
||||
// filename
|
||||
bag.mTxtFileName.setText(file.getSecondName());
|
||||
|
@ -316,6 +306,8 @@ public class IFileAdapter extends BaseAdapter {
|
|||
else
|
||||
bag.mTxtFileInfo.setText(String.format("%s, %s", Converter.sizeToStr(file.length()), time));
|
||||
|
||||
final boolean isAccessible = FileUtils.isAccessible(file, mFilenameRegexp);
|
||||
bag.mImageIcon.setEnabled(isAccessible);
|
||||
bag.mTxtFileName.setEnabled(isAccessible);
|
||||
bag.mTxtFileInfo.setEnabled(isAccessible);
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ public class FileUtils {
|
|||
if (filterMode == IFileProvider.FilterMode.DirectoriesOnly) {
|
||||
if (file instanceof File && !((File)file).canWrite()) {
|
||||
if (file instanceof ParentFile) {
|
||||
return R.drawable.afc_folder;
|
||||
return R.drawable.afc_item_folder;
|
||||
} else if (accessDenied(file)) {
|
||||
return R.drawable.afc_folder;
|
||||
return R.drawable.afc_item_folder;
|
||||
} else {
|
||||
return R.drawable.afc_folder_locked;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class FileUtils {
|
|||
return R.drawable.afc_folder;
|
||||
}
|
||||
} else {
|
||||
return R.drawable.afc_folder;
|
||||
return R.drawable.afc_item_folder;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue