Merge branch 'android-filechooser-orig'

Conflicts:
	src/java/android-filechooser/code/src/group/pals/android/lib/ui/filechooser/FragmentFiles.java
	src/java/android-filechooser/code/src/group/pals/android/lib/ui/filechooser/providers/localfile/LocalFileProvider.java
	src/java/android-filechooser/code/src/group/pals/android/lib/ui/filechooser/utils/ui/bookmark/BookmarkFragment.java
This commit is contained in:
Philipp Crocoll 2013-10-27 20:31:14 +01:00
commit f8e17a8144
7 changed files with 190 additions and 83 deletions

View File

@ -10,10 +10,12 @@ package group.pals.android.lib.ui.filechooser;
import group.pals.android.lib.ui.filechooser.prefs.DisplayPrefs; import group.pals.android.lib.ui.filechooser.prefs.DisplayPrefs;
import group.pals.android.lib.ui.filechooser.providers.basefile.BaseFileContract.BaseFile; import group.pals.android.lib.ui.filechooser.providers.basefile.BaseFileContract.BaseFile;
import group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileContract; import group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileContract;
import group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileProvider;
import group.pals.android.lib.ui.filechooser.utils.Utils; import group.pals.android.lib.ui.filechooser.utils.Utils;
import group.pals.android.lib.ui.filechooser.utils.ui.Dlg; import group.pals.android.lib.ui.filechooser.utils.ui.Dlg;
import group.pals.android.lib.ui.filechooser.utils.ui.Ui; import group.pals.android.lib.ui.filechooser.utils.ui.Ui;
import java.util.ArrayList;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.net.Uri; import android.net.Uri;
@ -112,8 +114,9 @@ public class FileChooserActivity extends FragmentActivity {
* Key to hold filter mode, can be one of * Key to hold filter mode, can be one of
* {@link BaseFile#FILTER_DIRECTORIES_ONLY}, * {@link BaseFile#FILTER_DIRECTORIES_ONLY},
* {@link BaseFile#FILTER_FILES_AND_DIRECTORIES}, * {@link BaseFile#FILTER_FILES_AND_DIRECTORIES},
* {@link BaseFile#FILTER_FILES_ONLY}. Default is
* {@link BaseFile#FILTER_FILES_ONLY}. * {@link BaseFile#FILTER_FILES_ONLY}.
* <p/>
* Default is {@link BaseFile#FILTER_FILES_ONLY}.
*/ */
public static final String EXTRA_FILTER_MODE = CLASSNAME + ".filter_mode"; public static final String EXTRA_FILTER_MODE = CLASSNAME + ".filter_mode";
@ -128,7 +131,7 @@ public class FileChooserActivity extends FragmentActivity {
public static final String EXTRA_MAX_FILE_COUNT = CLASSNAME public static final String EXTRA_MAX_FILE_COUNT = CLASSNAME
+ ".max_file_count"; + ".max_file_count";
/** /**
* Key to hold multi-selection mode, default = {@code false} * Key to hold multi-selection mode, default = {@code false}.
*/ */
public static final String EXTRA_MULTI_SELECTION = CLASSNAME public static final String EXTRA_MULTI_SELECTION = CLASSNAME
+ ".multi_selection"; + ".multi_selection";
@ -149,7 +152,7 @@ public class FileChooserActivity extends FragmentActivity {
public static final String EXTRA_NEGATIVE_REGEX_FILTER = CLASSNAME public static final String EXTRA_NEGATIVE_REGEX_FILTER = CLASSNAME
+ ".negative_regex_filter"; + ".negative_regex_filter";
/** /**
* Key to hold display-hidden-files, default = {@code false} * Key to hold display-hidden-files, default = {@code false}.
*/ */
public static final String EXTRA_DISPLAY_HIDDEN_FILES = CLASSNAME public static final String EXTRA_DISPLAY_HIDDEN_FILES = CLASSNAME
+ ".display_hidden_files"; + ".display_hidden_files";
@ -191,19 +194,35 @@ public class FileChooserActivity extends FragmentActivity {
// --------------------------------------------------------- // ---------------------------------------------------------
/** /**
* Key to hold property save-dialog, default = {@code false} * Key to hold property save-dialog, default = {@code false}.
*/ */
public static final String EXTRA_SAVE_DIALOG = CLASSNAME + ".save_dialog"; public static final String EXTRA_SAVE_DIALOG = CLASSNAME + ".save_dialog";
/** /**
* Key to hold default filename, default = {@code null} * Key to hold default filename, default = {@code null}.
*/ */
public static final String EXTRA_DEFAULT_FILENAME = CLASSNAME public static final String EXTRA_DEFAULT_FILENAME = CLASSNAME
+ ".default_filename"; + ".default_filename";
/** /**
* Key to hold results (can be one or multiple files) * Key to hold default file extension (<b>without</b> the period prefix),
* default = {@code null}.
* <p/>
* Note that this will be compared to the user's input value as
* case-insensitive. For example if you provide "csv" and the user types
* "CSV" then it is OK to use "CSV".
*/
public static final String EXTRA_DEFAULT_FILE_EXT = CLASSNAME
+ ".default_file_ext";
/**
* Key to hold results, which is an {@link ArrayList} of {@link Uri}. It can
* be one or multiple files.
*/ */
public static final String EXTRA_RESULTS = CLASSNAME + ".results"; public static final String EXTRA_RESULTS = CLASSNAME + ".results";
public static final String EXTRA_RESULT_FILE_EXISTS = CLASSNAME + ".result_file_exists";
/* /*
* CONTROLS * CONTROLS
*/ */

View File

@ -19,6 +19,7 @@ import group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileContra
import group.pals.android.lib.ui.filechooser.utils.E; import group.pals.android.lib.ui.filechooser.utils.E;
import group.pals.android.lib.ui.filechooser.utils.EnvUtils; import group.pals.android.lib.ui.filechooser.utils.EnvUtils;
import group.pals.android.lib.ui.filechooser.utils.FileUtils; import group.pals.android.lib.ui.filechooser.utils.FileUtils;
import group.pals.android.lib.ui.filechooser.utils.Texts;
import group.pals.android.lib.ui.filechooser.utils.Utils; import group.pals.android.lib.ui.filechooser.utils.Utils;
import group.pals.android.lib.ui.filechooser.utils.history.History; import group.pals.android.lib.ui.filechooser.utils.history.History;
import group.pals.android.lib.ui.filechooser.utils.history.HistoryFilter; import group.pals.android.lib.ui.filechooser.utils.history.HistoryFilter;
@ -33,6 +34,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
@ -114,6 +116,7 @@ public class FragmentFiles extends Fragment implements
*/ */
private static final String[] EXTRAS_STRING = { private static final String[] EXTRAS_STRING = {
FileChooserActivity.EXTRA_DEFAULT_FILENAME, FileChooserActivity.EXTRA_DEFAULT_FILENAME,
FileChooserActivity.EXTRA_DEFAULT_FILE_EXT,
FileChooserActivity.EXTRA_FILE_PROVIDER_AUTHORITY, FileChooserActivity.EXTRA_FILE_PROVIDER_AUTHORITY,
FileChooserActivity.EXTRA_NEGATIVE_REGEX_FILTER, FileChooserActivity.EXTRA_NEGATIVE_REGEX_FILTER,
FileChooserActivity.EXTRA_POSITIVE_REGEX_FILTER }; FileChooserActivity.EXTRA_POSITIVE_REGEX_FILTER };
@ -222,12 +225,12 @@ public class FragmentFiles extends Fragment implements
private ViewGroup mViewAddressBar; private ViewGroup mViewAddressBar;
private View mViewGroupFiles; private View mViewGroupFiles;
private ViewGroup mViewFilesContainer; private ViewGroup mViewFilesContainer;
private TextView mTxtFullDirName; private TextView mTextFullDirName;
private AbsListView mViewFiles; private AbsListView mViewFiles;
private TextView mFooterView; private TextView mFooterView;
private View mViewLoading; private View mViewLoading;
private Button mBtnOk; private Button mBtnOk;
private EditText mTxtSaveas; private EditText mTextSaveas;
private ImageView mViewGoBack; private ImageView mViewGoBack;
private ImageView mViewGoForward; private ImageView mViewGoForward;
private GestureDetector mListviewFilesGestureDetector; private GestureDetector mListviewFilesGestureDetector;
@ -308,7 +311,7 @@ public class FragmentFiles extends Fragment implements
.findViewById(R.id.afc_view_locations); .findViewById(R.id.afc_view_locations);
mViewLocationsContainer = (HorizontalScrollView) rootView mViewLocationsContainer = (HorizontalScrollView) rootView
.findViewById(R.id.afc_view_locations_container); .findViewById(R.id.afc_view_locations_container);
mTxtFullDirName = (TextView) rootView mTextFullDirName = (TextView) rootView
.findViewById(R.id.afc_textview_full_dir_name); .findViewById(R.id.afc_textview_full_dir_name);
mViewGroupFiles = rootView.findViewById(R.id.afc_viewgroup_files); mViewGroupFiles = rootView.findViewById(R.id.afc_viewgroup_files);
mViewFilesContainer = (ViewGroup) rootView mViewFilesContainer = (ViewGroup) rootView
@ -316,7 +319,7 @@ public class FragmentFiles extends Fragment implements
mFooterView = (TextView) rootView mFooterView = (TextView) rootView
.findViewById(R.id.afc_view_files_footer_view); .findViewById(R.id.afc_view_files_footer_view);
mViewLoading = rootView.findViewById(R.id.afc_view_loading); mViewLoading = rootView.findViewById(R.id.afc_view_loading);
mTxtSaveas = (EditText) rootView mTextSaveas = (EditText) rootView
.findViewById(R.id.afc_textview_saveas_filename); .findViewById(R.id.afc_textview_saveas_filename);
mBtnOk = (Button) rootView.findViewById(R.id.afc_button_ok); mBtnOk = (Button) rootView.findViewById(R.id.afc_button_ok);
@ -560,7 +563,7 @@ public class FragmentFiles extends Fragment implements
super.onPostExecute(result); super.onPostExecute(result);
if (!TextUtils.isEmpty(result)) if (!TextUtils.isEmpty(result))
mTxtSaveas.setText(result); mTextSaveas.setText(result);
}// onPostExecute() }// onPostExecute()
}.execute(); }.execute();
@ -736,11 +739,51 @@ public class FragmentFiles extends Fragment implements
viewGroupFooterContainer.setVisibility(View.VISIBLE); viewGroupFooterContainer.setVisibility(View.VISIBLE);
viewGroupFooter.setVisibility(View.VISIBLE); viewGroupFooter.setVisibility(View.VISIBLE);
mTxtSaveas.setVisibility(View.VISIBLE); mTextSaveas.setVisibility(View.VISIBLE);
mTxtSaveas.setText(getArguments().getString( mTextSaveas.setText(getArguments().getString(
FileChooserActivity.EXTRA_DEFAULT_FILENAME)); FileChooserActivity.EXTRA_DEFAULT_FILENAME));
mTxtSaveas mTextSaveas
.setOnEditorActionListener(mTxtFilenameOnEditorActionListener); .setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
Ui.showSoftKeyboard(v, false);
mBtnOk.performClick();
return true;
}
return false;
}// onEditorAction()
});
mTextSaveas.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
/*
* Do nothing.
*/
}// onTextChanged()
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
/*
* Do nothing.
*/
}// beforeTextChanged()
@Override
public void afterTextChanged(Editable s) {
/*
* If the user taps a file, the tag is set to that file's
* URI. But if the user types the file name, we remove the
* tag.
*/
mTextSaveas.setTag(null);
}// afterTextChanged()
});
mBtnOk.setVisibility(View.VISIBLE); mBtnOk.setVisibility(View.VISIBLE);
mBtnOk.setOnClickListener(mBtnOk_SaveDialog_OnClickListener); mBtnOk.setOnClickListener(mBtnOk_SaveDialog_OnClickListener);
@ -847,12 +890,16 @@ public class FragmentFiles extends Fragment implements
@Override @Override
public void onLongPress(MotionEvent e) { public void onLongPress(MotionEvent e) {
// do nothing /*
* Do nothing.
*/
}// onLongPress() }// onLongPress()
@Override @Override
public boolean onSingleTapConfirmed(MotionEvent e) { public boolean onSingleTapConfirmed(MotionEvent e) {
// do nothing /*
* Do nothing.
*/
return false; return false;
}// onSingleTapConfirmed() }// onSingleTapConfirmed()
@ -862,11 +909,11 @@ public class FragmentFiles extends Fragment implements
if (mIsMultiSelection) if (mIsMultiSelection)
return false; return false;
Cursor data = getData(e); Cursor cursor = getData(e);
if (data == null) if (cursor == null)
return false; return false;
if (BaseFileProviderUtils.isDirectory(data) if (BaseFileProviderUtils.isDirectory(cursor)
&& BaseFile.FILTER_FILES_ONLY == mFilterMode) && BaseFile.FILTER_FILES_ONLY == mFilterMode)
return false; return false;
@ -876,18 +923,25 @@ public class FragmentFiles extends Fragment implements
*/ */
if (mIsSaveDialog) { if (mIsSaveDialog) {
if (BaseFileProviderUtils.isFile(data)) { if (BaseFileProviderUtils.isFile(cursor)) {
mTxtSaveas.setText(BaseFileProviderUtils mTextSaveas.setText(BaseFileProviderUtils
.getFileName(data)); .getFileName(cursor));
checkSaveasFilenameAndFinish(BaseFileProviderUtils /*
.getFileName(data)); * Always set tag after setting text, or tag
* will be reset to null.
*/
mTextSaveas.setTag(BaseFileProviderUtils
.getUri(cursor));
checkSaveasFilenameAndFinish();
} else } else
return false; return false;
} else } else
finish(BaseFileProviderUtils.getUri(data)); finish(BaseFileProviderUtils.getUri(cursor));
}// double tap to choose files }// double tap to choose files
else { else {
// do nothing /*
* Do nothing.
*/
return false; return false;
}// single tap to choose files }// single tap to choose files
@ -1577,15 +1631,43 @@ public class FragmentFiles extends Fragment implements
/** /**
* As the name means. * As the name means.
*
* @param filename
* the file name.
*/ */
private void checkSaveasFilenameAndFinish(final String filename) { private void checkSaveasFilenameAndFinish() {
new LoadingDialog<Void, String, Uri>(getActivity(), false) { new LoadingDialog<Void, String, Uri>(getActivity(), false) {
String filename;
Uri fileUri;
int fileType; int fileType;
@Override
protected void onPreExecute() {
super.onPreExecute();
/*
* If the user tapped a file, its URI was stored here. If not,
* this is null.
*/
fileUri = (Uri) mTextSaveas.getTag();
/*
* File name and extension.
*/
filename = mTextSaveas.getText().toString().trim();
if (fileUri == null
&& getArguments().containsKey(
FileChooserActivity.EXTRA_DEFAULT_FILE_EXT)) {
if (!TextUtils.isEmpty(filename)) {
String ext = getArguments().getString(
FileChooserActivity.EXTRA_DEFAULT_FILE_EXT);
if (!filename.matches("(?si)^.+"
+ Pattern.quote(Texts.C_PERIOD + ext) + "$")) {
filename += Texts.C_PERIOD + ext;
mTextSaveas.setText(filename);
}
}
}
}// onPreExecute()
@Override @Override
protected Uri doInBackground(Void... params) { protected Uri doInBackground(Void... params) {
if (!BaseFileProviderUtils.fileCanWrite(getActivity(), if (!BaseFileProviderUtils.fileCanWrite(getActivity(),
@ -1593,19 +1675,20 @@ public class FragmentFiles extends Fragment implements
publishProgress(getString(R.string.afc_msg_cannot_save_a_file_here)); publishProgress(getString(R.string.afc_msg_cannot_save_a_file_here));
return null; return null;
} }
if (TextUtils.isEmpty(filename)
|| !FileUtils.isFilenameValid(filename)) { if (fileUri == null && !FileUtils.isFilenameValid(filename)) {
publishProgress(getString( publishProgress(getString(
R.string.afc_pmsg_filename_is_invalid, filename)); R.string.afc_pmsg_filename_is_invalid, filename));
return null; return null;
} }
final Cursor cursor = getActivity().getContentResolver().query( if (fileUri == null)
getCurrentLocation() fileUri = getCurrentLocation()
.buildUpon() .buildUpon()
.appendQueryParameter( .appendQueryParameter(BaseFile.PARAM_APPEND_NAME,
BaseFile.PARAM_APPEND_NAME, filename) filename).build();
.build(), null, null, null, null); final Cursor cursor = getActivity().getContentResolver().query(
fileUri, null, null, null, null);
try { try {
if (cursor == null || !cursor.moveToFirst()) if (cursor == null || !cursor.moveToFirst())
return null; return null;
@ -1898,12 +1981,12 @@ public class FragmentFiles extends Fragment implements
R.dimen.afc_button_location_max_width) R.dimen.afc_button_location_max_width)
- btnLoc.getPaddingLeft() - btnLoc.getPaddingLeft()
- btnLoc.getPaddingRight()) { - btnLoc.getPaddingRight()) {
mTxtFullDirName.setText(progress[0] mTextFullDirName.setText(progress[0]
.getString(progress[0] .getString(progress[0]
.getColumnIndex(BaseFile.COLUMN_NAME))); .getColumnIndex(BaseFile.COLUMN_NAME)));
mTxtFullDirName.setVisibility(View.VISIBLE); mTextFullDirName.setVisibility(View.VISIBLE);
} else } else
mTxtFullDirName.setVisibility(View.GONE); mTextFullDirName.setVisibility(View.GONE);
}// if }// if
}// onProgressUpdate() }// onProgressUpdate()
@ -2050,26 +2133,12 @@ public class FragmentFiles extends Fragment implements
};// mBtnGoForwardOnClickListener };// mBtnGoForwardOnClickListener
private final TextView.OnEditorActionListener mTxtFilenameOnEditorActionListener = new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
Ui.showSoftKeyboard(v, false);
mBtnOk.performClick();
return true;
}
return false;
}// onEditorAction()
};// mTxtFilenameOnEditorActionListener
private final View.OnClickListener mBtnOk_SaveDialog_OnClickListener = new View.OnClickListener() { private final View.OnClickListener mBtnOk_SaveDialog_OnClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Ui.showSoftKeyboard(v, false); Ui.showSoftKeyboard(v, false);
String filename = mTxtSaveas.getText().toString().trim(); checkSaveasFilenameAndFinish();
checkSaveasFilenameAndFinish(filename);
}// onClick() }// onClick()
};// mBtnOk_SaveDialog_OnClickListener };// mBtnOk_SaveDialog_OnClickListener
@ -2102,11 +2171,19 @@ public class FragmentFiles extends Fragment implements
return; return;
} }
if (mIsSaveDialog) if (mIsSaveDialog) {
mTxtSaveas.setText(BaseFileProviderUtils.getFileName(cursor)); mTextSaveas.setText(BaseFileProviderUtils.getFileName(cursor));
/*
* Always set tag after setting text, or tag will be reset to
* null.
*/
mTextSaveas.setTag(BaseFileProviderUtils.getUri(cursor));
}
if (mDoubleTapToChooseFiles) { if (mDoubleTapToChooseFiles) {
// do nothing /*
* Do nothing.
*/
return; return;
}// double tap to choose files }// double tap to choose files
else { else {
@ -2114,8 +2191,7 @@ public class FragmentFiles extends Fragment implements
return; return;
if (mIsSaveDialog) if (mIsSaveDialog)
checkSaveasFilenameAndFinish(BaseFileProviderUtils checkSaveasFilenameAndFinish();
.getFileName(cursor));
else else
finish(BaseFileProviderUtils.getUri(cursor)); finish(BaseFileProviderUtils.getUri(cursor));
}// single tap to choose files }// single tap to choose files

View File

@ -18,18 +18,18 @@ public interface BaseColumns extends android.provider.BaseColumns {
/** /**
* Column name for the creation timestamp. * Column name for the creation timestamp.
* <p/> * <p/>
* Type: {@code String} ({@code long} from {@link java.util.Date#getTime()} * Type: {@code String} representing {@code long} from
* ). * {@link java.util.Date#getTime()}. This is because SQLite doesn't handle
* </P> * Java's {@code long} well.
*/ */
public static final String COLUMN_CREATE_TIME = "create_time"; public static final String COLUMN_CREATE_TIME = "create_time";
/** /**
* Column name for the modification timestamp. * Column name for the modification timestamp.
* <p/> * <p/>
* Type: {@code String} ({@code long} from {@link java.util.Date#getTime()} * Type: {@code String} representing {@code long} from
* ). * {@link java.util.Date#getTime()}. This is because SQLite doesn't handle
* </P> * Java's {@code long} well.
*/ */
public static final String COLUMN_MODIFICATION_TIME = "modification_time"; public static final String COLUMN_MODIFICATION_TIME = "modification_time";

View File

@ -217,7 +217,7 @@ public class BaseFileProviderUtils {
BaseFile.COLUMN_ICON_ID }; BaseFile.COLUMN_ICON_ID };
/** /**
* Creates new cursor which hold default properties of a base file for * Creates new cursor which holds default properties of a base file for
* client to access. * client to access.
* *
* @return the new empty cursor. The columns are * @return the new empty cursor. The columns are
@ -495,9 +495,15 @@ public class BaseFileProviderUtils {
* @return {@code true} or {@code false}. * @return {@code true} or {@code false}.
*/ */
public static boolean fileCanRead(Cursor cursor) { public static boolean fileCanRead(Cursor cursor) {
return cursor.getInt(cursor.getColumnIndex(BaseFile.COLUMN_CAN_READ)) != 0 if (cursor.getInt(cursor.getColumnIndex(BaseFile.COLUMN_CAN_READ)) != 0) {
&& (cursor.getInt(cursor.getColumnIndex(BaseFile.COLUMN_TYPE)) == BaseFile.FILE_TYPE_DIRECTORY || cursor switch (cursor.getInt(cursor.getColumnIndex(BaseFile.COLUMN_TYPE))) {
.getInt(cursor.getColumnIndex(BaseFile.COLUMN_TYPE)) == BaseFile.FILE_TYPE_FILE); case BaseFile.FILE_TYPE_DIRECTORY:
case BaseFile.FILE_TYPE_FILE:
return true;
}
}
return false;
}// fileCanRead() }// fileCanRead()
/** /**
@ -532,9 +538,15 @@ public class BaseFileProviderUtils {
* @return {@code true} or {@code false}. * @return {@code true} or {@code false}.
*/ */
public static boolean fileCanWrite(Cursor cursor) { public static boolean fileCanWrite(Cursor cursor) {
return cursor.getInt(cursor.getColumnIndex(BaseFile.COLUMN_CAN_WRITE)) != 0 if (cursor.getInt(cursor.getColumnIndex(BaseFile.COLUMN_CAN_WRITE)) != 0) {
&& (cursor.getInt(cursor.getColumnIndex(BaseFile.COLUMN_TYPE)) == BaseFile.FILE_TYPE_DIRECTORY || cursor switch (cursor.getInt(cursor.getColumnIndex(BaseFile.COLUMN_TYPE))) {
.getInt(cursor.getColumnIndex(BaseFile.COLUMN_TYPE)) == BaseFile.FILE_TYPE_FILE); case BaseFile.FILE_TYPE_DIRECTORY:
case BaseFile.FILE_TYPE_FILE:
return true;
}
}
return false;
}// fileCanWrite() }// fileCanWrite()
/** /**

View File

@ -73,8 +73,8 @@ public class ProviderUtils {
*/ */
public static boolean getBooleanQueryParam(Uri uri, String key) { public static boolean getBooleanQueryParam(Uri uri, String key) {
String param = uri.getQueryParameter(key); String param = uri.getQueryParameter(key);
if (param == null || "false".equalsIgnoreCase(param) if (param == null || Boolean.FALSE.toString().equalsIgnoreCase(param)
|| "0".equalsIgnoreCase(param)) || Integer.toString(0).equalsIgnoreCase(param))
return false; return false;
return true; return true;
}// getBooleanQueryParam() }// getBooleanQueryParam()

View File

@ -15,8 +15,8 @@ import group.pals.android.lib.ui.filechooser.providers.basefile.BaseFileContract
import group.pals.android.lib.ui.filechooser.providers.basefile.BaseFileProvider; import group.pals.android.lib.ui.filechooser.providers.basefile.BaseFileProvider;
import group.pals.android.lib.ui.filechooser.utils.FileUtils; import group.pals.android.lib.ui.filechooser.utils.FileUtils;
import group.pals.android.lib.ui.filechooser.utils.TextUtils; import group.pals.android.lib.ui.filechooser.utils.TextUtils;
import group.pals.android.lib.ui.filechooser.utils.Texts;
import group.pals.android.lib.ui.filechooser.utils.Utils; import group.pals.android.lib.ui.filechooser.utils.Utils;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.IOException; import java.io.IOException;
@ -508,8 +508,8 @@ public class LocalFileProvider extends BaseFileProvider {
final boolean showHiddenFiles, final int filterMode, final boolean showHiddenFiles, final int filterMode,
final int limit, String positiveRegex, String negativeRegex, final int limit, String positiveRegex, String negativeRegex,
final List<File> results, final boolean hasMoreFiles[]) { final List<File> results, final boolean hasMoreFiles[]) {
final Pattern positivePattern = TextUtils.compileRegex(positiveRegex); final Pattern positivePattern = Texts.compileRegex(positiveRegex);
final Pattern negativePattern = TextUtils.compileRegex(negativeRegex); final Pattern negativePattern = Texts.compileRegex(negativeRegex);
hasMoreFiles[0] = false; hasMoreFiles[0] = false;
try { try {

View File

@ -95,7 +95,7 @@ public abstract class LoadingDialog<Params, Progress, Result> extends
/** /**
* If you override this method, you must call {@code super.onPreExecute()} * If you override this method, you must call {@code super.onPreExecute()}
* at very first of the method. * at beginning of the method.
*/ */
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
@ -121,7 +121,7 @@ public abstract class LoadingDialog<Params, Progress, Result> extends
/** /**
* If you override this method, you must call * If you override this method, you must call
* {@code super.onPostExecute(result)} at the entry point of the method. * {@code super.onPostExecute(result)} at beginning of the method.
*/ */
@Override @Override
protected void onPostExecute(Result result) { protected void onPostExecute(Result result) {
@ -130,7 +130,7 @@ public abstract class LoadingDialog<Params, Progress, Result> extends
/** /**
* If you override this method, you must call {@code super.onCancelled()} at * If you override this method, you must call {@code super.onCancelled()} at
* the entry point of the method. * beginning of the method.
*/ */
@Override @Override
protected void onCancelled() { protected void onCancelled() {