diff --git a/app/src/main/java/com/keepassdroid/fileselect/DeleteFileHistoryAsyncTask.java b/app/src/main/java/com/keepassdroid/fileselect/DeleteFileHistoryAsyncTask.java index 782f0880c..73e05db0a 100644 --- a/app/src/main/java/com/keepassdroid/fileselect/DeleteFileHistoryAsyncTask.java +++ b/app/src/main/java/com/keepassdroid/fileselect/DeleteFileHistoryAsyncTask.java @@ -19,10 +19,9 @@ */ package com.keepassdroid.fileselect; -import android.net.Uri; import android.os.AsyncTask; -class DeleteFileHistoryAsyncTask extends AsyncTask { +class DeleteFileHistoryAsyncTask extends AsyncTask { private AfterDeleteFileHistoryListener afterDeleteFileHistoryListener; private RecentFileHistory fileHistory; @@ -34,8 +33,8 @@ class DeleteFileHistoryAsyncTask extends AsyncTask { this.adapter = adapter; } - protected Void doInBackground(String... args) { - fileHistory.deleteFile(Uri.parse(args[0])); + protected Void doInBackground(FileSelectBean... args) { + fileHistory.deleteFile(args[0].getFileUri()); return null; } diff --git a/app/src/main/java/com/keepassdroid/fileselect/FileInformationDialogFragment.java b/app/src/main/java/com/keepassdroid/fileselect/FileInformationDialogFragment.java index 11c2e2549..7c1e19dbd 100644 --- a/app/src/main/java/com/keepassdroid/fileselect/FileInformationDialogFragment.java +++ b/app/src/main/java/com/keepassdroid/fileselect/FileInformationDialogFragment.java @@ -30,15 +30,17 @@ import android.widget.TextView; import com.kunzisoft.keepass.R; +import java.text.DateFormat; + public class FileInformationDialogFragment extends DialogFragment { private static final String FILE_SELECT_BEEN_ARG = "FILE_SELECT_BEEN_ARG"; - public static FileInformationDialogFragment newInstance(FileSelectBeen fileSelectBeen) { + public static FileInformationDialogFragment newInstance(FileSelectBean fileSelectBean) { FileInformationDialogFragment fileInformationDialogFragment = new FileInformationDialogFragment(); Bundle args = new Bundle(); - args.putSerializable(FILE_SELECT_BEEN_ARG, fileSelectBeen); + args.putSerializable(FILE_SELECT_BEEN_ARG, fileSelectBean); fileInformationDialogFragment.setArguments(args); return fileInformationDialogFragment; } @@ -50,17 +52,23 @@ public class FileInformationDialogFragment extends DialogFragment { View root = inflater.inflate(R.layout.file_selection_information, null); if (getArguments() != null && getArguments().containsKey(FILE_SELECT_BEEN_ARG)) { - FileSelectBeen fileSelectBeen = (FileSelectBeen) getArguments().getSerializable(FILE_SELECT_BEEN_ARG); - if(fileSelectBeen != null) { + FileSelectBean fileSelectBean = (FileSelectBean) getArguments().getSerializable(FILE_SELECT_BEEN_ARG); + TextView fileWarningView = (TextView) root.findViewById(R.id.file_warning); + if(fileSelectBean != null) { TextView fileNameView = (TextView) root.findViewById(R.id.file_filename); TextView filePathView = (TextView) root.findViewById(R.id.file_path); TextView fileSizeView = (TextView) root.findViewById(R.id.file_size); TextView fileModificationView = (TextView) root.findViewById(R.id.file_modification); - fileNameView.setText(fileSelectBeen.getFileName()); - filePathView.setText(fileSelectBeen.getFileUri().toString()); - fileSizeView.setText(String.valueOf(fileSelectBeen.getSize())); - fileModificationView.setText(fileSelectBeen.getLastModification().toString()); - } + fileWarningView.setVisibility(View.GONE); + fileNameView.setText(fileSelectBean.getFileName()); + filePathView.setText(fileSelectBean.getFileUri().toString()); + fileSizeView.setText(String.valueOf(fileSelectBean.getSize())); + fileModificationView.setText(DateFormat.getDateTimeInstance() + .format(fileSelectBean.getLastModification())); + if(fileSelectBean.notFound()) + showFileNotFound(fileWarningView); + } else + showFileNotFound(fileWarningView); } builder.setView(root); @@ -71,4 +79,9 @@ public class FileInformationDialogFragment extends DialogFragment { }); return builder.create(); } + + private void showFileNotFound(TextView fileWarningView) { + fileWarningView.setVisibility(View.VISIBLE); + fileWarningView.setText(R.string.file_not_found); + } } diff --git a/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java b/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java index 5f1bf8a2d..498d8dfec 100644 --- a/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java +++ b/app/src/main/java/com/keepassdroid/fileselect/FileSelectActivity.java @@ -71,7 +71,7 @@ import java.net.URLDecoder; public class FileSelectActivity extends StylishActivity implements CreateFileDialog.DefinePathDialogListener , AssignMasterKeyDialog.AssignPasswordDialogListener, - FileSelectViewHolder.FileSelectClearListener, + FileSelectAdapter.FileSelectClearListener, FileSelectAdapter.FileInformationShowListener { private static final String TAG = "FileSelectActivity"; @@ -351,13 +351,6 @@ public class FileSelectActivity extends StylishActivity implements } - @Override - public void onClickFileInformation(FileSelectBeen fileSelectBeen) { - FileInformationDialogFragment fileInformationDialogFragment = - FileInformationDialogFragment.newInstance(fileSelectBeen); - fileInformationDialogFragment.show(getSupportFragmentManager(), "fileInformation"); - } - private class AssignPasswordOnFinish extends FileOnFinish { AssignPasswordOnFinish(FileOnFinish fileOnFinish) { @@ -425,13 +418,24 @@ public class FileSelectActivity extends StylishActivity implements } @Override - public boolean onFileSelectClearListener(String fileName) { + public void onClickFileInformation(FileSelectBean fileSelectBean) { + if (fileSelectBean != null) { + FileInformationDialogFragment fileInformationDialogFragment = + FileInformationDialogFragment.newInstance(fileSelectBean); + fileInformationDialogFragment.show(getSupportFragmentManager(), "fileInformation"); + } + } + + @Override + public boolean onFileSelectClearListener(final FileSelectBean fileSelectBean) { new DeleteFileHistoryAsyncTask(new DeleteFileHistoryAsyncTask.AfterDeleteFileHistoryListener() { @Override public void afterDeleteFile() { + fileHistory.deleteFile(fileSelectBean.getFileUri()); + mAdapter.notifyDataSetChanged(); updateTitleFileListView(); } - }, fileHistory, mAdapter).execute(fileName); + }, fileHistory, mAdapter).execute(fileSelectBean); return true; } @@ -497,6 +501,8 @@ public class FileSelectActivity extends StylishActivity implements FileNameView fnv = (FileNameView) findViewById(R.id.file_select); fnv.updateExternalStorageWarning(); + + updateTitleFileListView(); } private void checkStoragePermission() { diff --git a/app/src/main/java/com/keepassdroid/fileselect/FileSelectAdapter.java b/app/src/main/java/com/keepassdroid/fileselect/FileSelectAdapter.java index ea6eec7d0..9342ef724 100644 --- a/app/src/main/java/com/keepassdroid/fileselect/FileSelectAdapter.java +++ b/app/src/main/java/com/keepassdroid/fileselect/FileSelectAdapter.java @@ -20,8 +20,14 @@ package com.keepassdroid.fileselect; import android.content.Context; +import android.content.res.Resources; +import android.support.annotation.ColorInt; import android.support.v7.widget.RecyclerView; +import android.util.TypedValue; +import android.view.ContextMenu; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; @@ -31,15 +37,25 @@ import java.util.List; public class FileSelectAdapter extends RecyclerView.Adapter { + private static final int MENU_CLEAR = 1; + private LayoutInflater inflater; private List listFiles; private View.OnClickListener mOnClickListener; - private FileSelectViewHolder.FileSelectClearListener fileSelectClearListener; + private FileSelectClearListener fileSelectClearListener; private FileInformationShowListener fileInformationShowListener; + private @ColorInt + int warningColor; + FileSelectAdapter(Context context, List listFiles) { inflater = LayoutInflater.from(context); this.listFiles=listFiles; + + TypedValue typedValue = new TypedValue(); + Resources.Theme theme = context.getTheme(); + theme.resolveAttribute(R.attr.colorAccentCompat, typedValue, true); + warningColor = typedValue.data; } @Override @@ -51,12 +67,16 @@ public class FileSelectAdapter extends RecyclerView.Adapter. --> - + + - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/file_selection_information.xml b/app/src/main/res/layout/file_selection_information.xml index 1ac225f44..1d819e3f1 100644 --- a/app/src/main/res/layout/file_selection_information.xml +++ b/app/src/main/res/layout/file_selection_information.xml @@ -29,8 +29,7 @@ android:layout_margin="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/entry_modified" - style="@style/KeepassDXStyle.TextAppearance.Title"/> + android:text="@string/entry_modified"/> + + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index ef35156cf..cfaf5ac23 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -230,6 +230,7 @@ Chemin Assigner une clé maître Créer un fichier keepass + Octets 30 secondes