Loading res/layout/dialog_delete_confirmation.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="30dp" android:gravity="center" android:textAppearance="@android:style/TextAppearance.Material.Subhead" android:textColor="@*android:color/primary_text_default_material_light"> </TextView> res/values/strings.xml +2 −4 Original line number Diff line number Diff line Loading @@ -208,11 +208,9 @@ <string name="allow">Allow</string> <!-- Text in the button asking user to deny access to a given directory. --> <string name="deny">Deny</string> <!-- Dialog title shown to users when asking if they want to delete files (a confirmation). --> <string name="delete_confirmation_title">Delete files?</string> <!-- Dialog text shown to users when asking if they want to delete files (a confirmation). --> <plurals name="delete_confirmation_message"> <item quantity="one">Are you sure you want to delete <xliff:g id="count" example="1">%1$d</xliff:g> file?</item> <item quantity="other">Are you sure you want to delete <xliff:g id="count" example="3">%1$d</xliff:g> files?</item> <item quantity="one">Delete <xliff:g id="count" example="1">%1$d</xliff:g> file?</item> <item quantity="other">Delete <xliff:g id="count" example="3">%1$d</xliff:g> files?</item> </plurals> </resources> src/com/android/documentsui/dirlist/DirectoryFragment.java +22 −8 Original line number Diff line number Diff line Loading @@ -168,6 +168,7 @@ public class DirectoryFragment extends Fragment private GridLayoutManager mLayout; private int mColumnCount = 1; // This will get updated when layout changes. private LayoutInflater mInflater; private MessageBar mMessageBar; private View mProgressBar; Loading @@ -182,13 +183,12 @@ public class DirectoryFragment extends Fragment @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mInflater = inflater; final View view = inflater.inflate(R.layout.fragment_directory, container, false); mMessageBar = MessageBar.create(getChildFragmentManager()); mProgressBar = view.findViewById(R.id.progressbar); mEmptyView = view.findViewById(android.R.id.empty); mRecView = (RecyclerView) view.findViewById(R.id.dir_list); mRecView.setRecyclerListener( new RecyclerListener() { Loading Loading @@ -708,13 +708,27 @@ public class DirectoryFragment extends Fragment new GetDocumentsTask() { @Override void onDocumentsReady(final List<DocumentInfo> docs) { new AlertDialog.Builder(getActivity()) .setTitle(R.string.delete_confirmation_title) .setMessage( TextView message = (TextView) mInflater.inflate(R.layout.dialog_delete_confirmation, null); message.setText( Shared.getQuantityString( getActivity(), R.plurals.delete_confirmation_message, docs.size())) docs.size())); // This "insta-hides" files that are being deleted, because // the delete operation may be not execute immediately (it // may be queued up on the FileOperationService.) // To hide the files locally, we call the hide method on the adapter // ...which a live object...cannot be parceled. // For that reason, for now, we implement this dialog NOT // as a fragment (which can survive rotation and have its own state), // but as a simple runtime dialog. So rotating a device with an // active delete dialog...results in that dialog disappearing. // We can do better, but don't have cycles for it now. new AlertDialog.Builder(getActivity()) .setView(message) .setPositiveButton( android.R.string.yes, new DialogInterface.OnClickListener() { Loading src/com/android/documentsui/dirlist/DocumentsAdapter.java +0 −7 Original line number Diff line number Diff line Loading @@ -73,13 +73,6 @@ abstract class DocumentsAdapter */ abstract public SparseArray<String> hide(String... ids); /** * Unhides a set of previously hidden items. * * @param ids A sparse array of IDs from a previous call to {@link #hide}. */ abstract void unhide(SparseArray<String> ids); /** * Returns a class that yields the span size for a particular element. This is * primarily useful in {@link SectionBreakDocumentsAdapterWrapper} where Loading src/com/android/documentsui/dirlist/ModelBackedDocumentsAdapter.java +1 −24 Original line number Diff line number Diff line Loading @@ -24,12 +24,12 @@ import static com.android.documentsui.model.DocumentInfo.getCursorString; import android.database.Cursor; import android.provider.DocumentsContract.Document; import android.support.annotation.VisibleForTesting; import android.util.Log; import android.util.SparseArray; import android.view.ViewGroup; import com.android.documentsui.State; import com.google.common.collect.Sets; import java.util.ArrayList; Loading Loading @@ -181,29 +181,6 @@ final class ModelBackedDocumentsAdapter extends DocumentsAdapter { return hiddenItems; } @VisibleForTesting @Override public void unhide(SparseArray<String> ids) { if (DEBUG) Log.d(TAG, "Unhiding ids: " + ids); // An ArrayList can shrink at runtime...and in fact // it does when we clear it completely. // This means we can't call add(pos, id) without // first checking the list size. List<String> oldIds = mModelIds; mModelIds = new ArrayList<>(oldIds.size() + ids.size()); mModelIds.addAll(oldIds); // Finally insert the unhidden items. for (int i = 0; i < ids.size(); i++) { int pos = ids.keyAt(i); String id = ids.get(pos); mHiddenIds.remove(id); mModelIds.add(pos, id); notifyItemInserted(pos); } } @Override public List<String> getModelIds() { return mModelIds; Loading Loading
res/layout/dialog_delete_confirmation.xml 0 → 100644 +25 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="30dp" android:gravity="center" android:textAppearance="@android:style/TextAppearance.Material.Subhead" android:textColor="@*android:color/primary_text_default_material_light"> </TextView>
res/values/strings.xml +2 −4 Original line number Diff line number Diff line Loading @@ -208,11 +208,9 @@ <string name="allow">Allow</string> <!-- Text in the button asking user to deny access to a given directory. --> <string name="deny">Deny</string> <!-- Dialog title shown to users when asking if they want to delete files (a confirmation). --> <string name="delete_confirmation_title">Delete files?</string> <!-- Dialog text shown to users when asking if they want to delete files (a confirmation). --> <plurals name="delete_confirmation_message"> <item quantity="one">Are you sure you want to delete <xliff:g id="count" example="1">%1$d</xliff:g> file?</item> <item quantity="other">Are you sure you want to delete <xliff:g id="count" example="3">%1$d</xliff:g> files?</item> <item quantity="one">Delete <xliff:g id="count" example="1">%1$d</xliff:g> file?</item> <item quantity="other">Delete <xliff:g id="count" example="3">%1$d</xliff:g> files?</item> </plurals> </resources>
src/com/android/documentsui/dirlist/DirectoryFragment.java +22 −8 Original line number Diff line number Diff line Loading @@ -168,6 +168,7 @@ public class DirectoryFragment extends Fragment private GridLayoutManager mLayout; private int mColumnCount = 1; // This will get updated when layout changes. private LayoutInflater mInflater; private MessageBar mMessageBar; private View mProgressBar; Loading @@ -182,13 +183,12 @@ public class DirectoryFragment extends Fragment @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mInflater = inflater; final View view = inflater.inflate(R.layout.fragment_directory, container, false); mMessageBar = MessageBar.create(getChildFragmentManager()); mProgressBar = view.findViewById(R.id.progressbar); mEmptyView = view.findViewById(android.R.id.empty); mRecView = (RecyclerView) view.findViewById(R.id.dir_list); mRecView.setRecyclerListener( new RecyclerListener() { Loading Loading @@ -708,13 +708,27 @@ public class DirectoryFragment extends Fragment new GetDocumentsTask() { @Override void onDocumentsReady(final List<DocumentInfo> docs) { new AlertDialog.Builder(getActivity()) .setTitle(R.string.delete_confirmation_title) .setMessage( TextView message = (TextView) mInflater.inflate(R.layout.dialog_delete_confirmation, null); message.setText( Shared.getQuantityString( getActivity(), R.plurals.delete_confirmation_message, docs.size())) docs.size())); // This "insta-hides" files that are being deleted, because // the delete operation may be not execute immediately (it // may be queued up on the FileOperationService.) // To hide the files locally, we call the hide method on the adapter // ...which a live object...cannot be parceled. // For that reason, for now, we implement this dialog NOT // as a fragment (which can survive rotation and have its own state), // but as a simple runtime dialog. So rotating a device with an // active delete dialog...results in that dialog disappearing. // We can do better, but don't have cycles for it now. new AlertDialog.Builder(getActivity()) .setView(message) .setPositiveButton( android.R.string.yes, new DialogInterface.OnClickListener() { Loading
src/com/android/documentsui/dirlist/DocumentsAdapter.java +0 −7 Original line number Diff line number Diff line Loading @@ -73,13 +73,6 @@ abstract class DocumentsAdapter */ abstract public SparseArray<String> hide(String... ids); /** * Unhides a set of previously hidden items. * * @param ids A sparse array of IDs from a previous call to {@link #hide}. */ abstract void unhide(SparseArray<String> ids); /** * Returns a class that yields the span size for a particular element. This is * primarily useful in {@link SectionBreakDocumentsAdapterWrapper} where Loading
src/com/android/documentsui/dirlist/ModelBackedDocumentsAdapter.java +1 −24 Original line number Diff line number Diff line Loading @@ -24,12 +24,12 @@ import static com.android.documentsui.model.DocumentInfo.getCursorString; import android.database.Cursor; import android.provider.DocumentsContract.Document; import android.support.annotation.VisibleForTesting; import android.util.Log; import android.util.SparseArray; import android.view.ViewGroup; import com.android.documentsui.State; import com.google.common.collect.Sets; import java.util.ArrayList; Loading Loading @@ -181,29 +181,6 @@ final class ModelBackedDocumentsAdapter extends DocumentsAdapter { return hiddenItems; } @VisibleForTesting @Override public void unhide(SparseArray<String> ids) { if (DEBUG) Log.d(TAG, "Unhiding ids: " + ids); // An ArrayList can shrink at runtime...and in fact // it does when we clear it completely. // This means we can't call add(pos, id) without // first checking the list size. List<String> oldIds = mModelIds; mModelIds = new ArrayList<>(oldIds.size() + ids.size()); mModelIds.addAll(oldIds); // Finally insert the unhidden items. for (int i = 0; i < ids.size(); i++) { int pos = ids.keyAt(i); String id = ids.get(pos); mHiddenIds.remove(id); mModelIds.add(pos, id); notifyItemInserted(pos); } } @Override public List<String> getModelIds() { return mModelIds; Loading