diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-10-24 12:35:22 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-24 12:35:22 -0700 |
commit | 46106ca28e8a679ce2f0609d03ae6ba4b95d7f30 (patch) | |
tree | 515b481fc8e0459356591e3ea9a91b2b6694ae88 | |
parent | 1a529ddaa71a3dfa50586a145ebfa502bea85e1d (diff) | |
parent | 686fa2db5b8feeb9e378aeb8e5dbac2f79ef2153 (diff) | |
download | frameworks_base-46106ca28e8a679ce2f0609d03ae6ba4b95d7f30.zip frameworks_base-46106ca28e8a679ce2f0609d03ae6ba4b95d7f30.tar.gz frameworks_base-46106ca28e8a679ce2f0609d03ae6ba4b95d7f30.tar.bz2 |
am 686fa2db: am c832ef0d: Merge "Show spinner while waiting for mutations." into klp-dev
* commit '686fa2db5b8feeb9e378aeb8e5dbac2f79ef2153':
Show spinner while waiting for mutations.
5 files changed, 64 insertions, 10 deletions
diff --git a/packages/DocumentsUI/res/layout/fragment_save.xml b/packages/DocumentsUI/res/layout/fragment_save.xml index 891f0a0..d601194 100644 --- a/packages/DocumentsUI/res/layout/fragment_save.xml +++ b/packages/DocumentsUI/res/layout/fragment_save.xml @@ -51,15 +51,31 @@ android:singleLine="true" android:selectAllOnFocus="true" /> - <Button - android:id="@android:id/button1" + <FrameLayout android:layout_width="wrap_content" - android:layout_height="match_parent" - android:background="?android:attr/selectableItemBackground" - android:text="@string/menu_save" - android:textAllCaps="true" - android:textAppearance="?android:attr/textAppearanceSmall" - android:padding="8dp" /> + android:layout_height="match_parent"> + + <Button + android:id="@android:id/button1" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:background="?android:attr/selectableItemBackground" + android:text="@string/menu_save" + android:textAllCaps="true" + android:textAppearance="?android:attr/textAppearanceSmall" + android:padding="8dp" /> + + <ProgressBar + android:id="@android:id/progress" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:visibility="gone" + android:indeterminate="true" + android:padding="8dp" + style="?android:attr/progressBarStyle" /> + + </FrameLayout> </LinearLayout> diff --git a/packages/DocumentsUI/src/com/android/documentsui/CreateDirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/CreateDirectoryFragment.java index 90be197..ba8c35f 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/CreateDirectoryFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/CreateDirectoryFragment.java @@ -95,6 +95,11 @@ public class CreateDirectoryFragment extends DialogFragment { } @Override + protected void onPreExecute() { + mActivity.setPending(true); + } + + @Override protected DocumentInfo doInBackground(Void... params) { final ContentResolver resolver = mActivity.getContentResolver(); ContentProviderClient client = null; @@ -120,6 +125,8 @@ public class CreateDirectoryFragment extends DialogFragment { } else { Toast.makeText(mActivity, R.string.create_error, Toast.LENGTH_SHORT).show(); } + + mActivity.setPending(false); } } } diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index d675e8d..a9278d7 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -661,6 +661,13 @@ public class DocumentsActivity extends Activity { DirectoryFragment.get(getFragmentManager()).onUserModeChanged(); } + public void setPending(boolean pending) { + final SaveFragment save = SaveFragment.get(getFragmentManager()); + if (save != null) { + save.setPending(pending); + } + } + @Override public void onBackPressed() { if (!mState.stackTouched) { @@ -1051,6 +1058,11 @@ public class DocumentsActivity extends Activity { } @Override + protected void onPreExecute() { + setPending(true); + } + + @Override protected Uri doInBackground(Void... params) { final ContentResolver resolver = getContentResolver(); final DocumentInfo cwd = getCurrentDirectory(); @@ -1083,6 +1095,8 @@ public class DocumentsActivity extends Activity { Toast.makeText(DocumentsActivity.this, R.string.save_error, Toast.LENGTH_SHORT) .show(); } + + setPending(false); } } diff --git a/packages/DocumentsUI/src/com/android/documentsui/SaveFragment.java b/packages/DocumentsUI/src/com/android/documentsui/SaveFragment.java index 23e047c..9d70c51 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/SaveFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/SaveFragment.java @@ -30,6 +30,7 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; +import android.widget.ProgressBar; import com.android.documentsui.model.DocumentInfo; @@ -42,6 +43,7 @@ public class SaveFragment extends Fragment { private DocumentInfo mReplaceTarget; private EditText mDisplayName; private Button mSave; + private ProgressBar mProgress; private boolean mIgnoreNextEdit; private static final String EXTRA_MIME_TYPE = "mime_type"; @@ -83,6 +85,8 @@ public class SaveFragment extends Fragment { mSave.setOnClickListener(mSaveListener); mSave.setEnabled(false); + mProgress = (ProgressBar) view.findViewById(android.R.id.progress); + return view; } @@ -92,7 +96,6 @@ public class SaveFragment extends Fragment { if (mIgnoreNextEdit) { mIgnoreNextEdit = false; } else { - Log.d(TAG, "onTextChanged!"); mReplaceTarget = null; } } @@ -140,4 +143,9 @@ public class SaveFragment extends Fragment { public void setSaveEnabled(boolean enabled) { mSave.setEnabled(enabled); } + + public void setPending(boolean pending) { + mSave.setVisibility(pending ? View.INVISIBLE : View.VISIBLE); + mProgress.setVisibility(pending ? View.VISIBLE : View.GONE); + } } diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java index 71ce4dd..af6ff01 100644 --- a/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java +++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/TestDocumentsProvider.java @@ -127,7 +127,7 @@ public class TestDocumentsProvider extends DocumentsProvider { final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection)); final RowBuilder row = result.newRow(); row.add(Root.COLUMN_ROOT_ID, MY_ROOT_ID); - row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_RECENTS); + row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_CREATE); row.add(Root.COLUMN_TITLE, "_Test title which is really long"); row.add(Root.COLUMN_SUMMARY, SystemClock.elapsedRealtime() + " summary which is also super long text"); @@ -147,6 +147,14 @@ public class TestDocumentsProvider extends DocumentsProvider { return result; } + @Override + public String createDocument(String parentDocumentId, String mimeType, String displayName) + throws FileNotFoundException { + if (LAG) lagUntilCanceled(null); + + return super.createDocument(parentDocumentId, mimeType, displayName); + } + /** * Holds any outstanding or finished "network" fetching. */ @@ -386,6 +394,7 @@ public class TestDocumentsProvider extends DocumentsProvider { if (MY_DOC_ID.equals(docId)) { row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR); + row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_SUPPORTS_CREATE); } else if (MY_DOC_NULL.equals(docId)) { // No MIME type } else { |