request WRITE_EXTERNAL_STORAGE + cleanup

This commit is contained in:
tibbi 2016-10-30 17:35:32 +01:00
parent 22b3c3f5cc
commit b1c9822179
4 changed files with 3 additions and 21 deletions

View File

@ -23,7 +23,7 @@ public class Utils {
}
public static boolean hasStoragePermission(Context cxt) {
return ContextCompat.checkSelfPermission(cxt, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
return ContextCompat.checkSelfPermission(cxt, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
}
public static boolean isNameValid(String name) {

View File

@ -12,7 +12,6 @@ import android.support.annotation.Nullable;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import android.util.SparseBooleanArray;
import android.view.ActionMode;
import android.view.LayoutInflater;
@ -24,7 +23,6 @@ import android.view.ViewGroup;
import android.webkit.MimeTypeMap;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import com.simplemobiletools.filemanager.Config;
import com.simplemobiletools.filemanager.Constants;
@ -63,10 +61,7 @@ public class ItemsFragment extends android.support.v4.app.Fragment
private ItemInteractionListener mListener;
private List<String> mToBeDeleted;
private String mPath;
private String mCopyDestinationPath;
private Snackbar mSnackbar;
private AlertDialog mCopyDialog;
private TextView mDestinationView;
private Config mConfig;
private boolean mShowHidden;
@ -112,7 +107,6 @@ public class ItemsFragment extends android.support.v4.app.Fragment
private void fillItems() {
mPath = getArguments().getString(Constants.PATH);
mCopyDestinationPath = mPath;
final List<FileDirItem> newItems = getItems(mPath);
Collections.sort(newItems);
if (mItems != null && newItems.toString().equals(mItems.toString())) {
@ -378,11 +372,6 @@ public class ItemsFragment extends android.support.v4.app.Fragment
public void onSuccess() {
fillItems();
}
@Override
public void onCancel() {
mCopyDestinationPath = mPath;
}
});
}

View File

@ -51,7 +51,7 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
if (Utils.hasStoragePermission(applicationContext)) {
initRootFileManager()
} else {
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE), STORAGE_PERMISSION)
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE), STORAGE_PERMISSION)
}
}

View File

@ -38,8 +38,7 @@ class CopyDialog(val activity: Activity, val files: List<File>, val path: String
.setTitle(mContext.resources.getString(R.string.create_new))
.setView(view)
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, { dialog, which -> dialogDismissed() })
.setOnCancelListener { dialogDismissed() }
.setNegativeButton(R.string.cancel, null)
.create().apply {
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
show()
@ -75,13 +74,7 @@ class CopyDialog(val activity: Activity, val files: List<File>, val path: String
}
}
private fun dialogDismissed() {
listener.onCancel()
}
interface OnCopyListener {
fun onSuccess()
fun onCancel()
}
}