Merge "Delete downloads activity." into nyc-dev
am: 4064f60831
* commit '4064f60831faf30a1ceced3b08c61ee945f79bfb':
Delete downloads activity.
This commit is contained in:
@@ -118,8 +118,6 @@ public final class DocumentsContract {
|
||||
*/
|
||||
public static final String EXTRA_PROMPT = "android.provider.extra.PROMPT";
|
||||
|
||||
/** {@hide} */
|
||||
public static final String ACTION_MANAGE_ROOT = "android.provider.action.MANAGE_ROOT";
|
||||
/** {@hide} */
|
||||
public static final String ACTION_MANAGE_DOCUMENT = "android.provider.action.MANAGE_DOCUMENT";
|
||||
|
||||
|
||||
@@ -39,18 +39,6 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".DownloadsActivity"
|
||||
android:theme="@style/DocumentsTheme"
|
||||
android:label="@string/downloads_label"
|
||||
android:icon="@drawable/ic_doc_text">
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.action.MANAGE_ROOT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="vnd.android.document/root" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".LauncherActivity"
|
||||
android:theme="@android:style/Theme.NoDisplay"
|
||||
@@ -71,6 +59,10 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW_DOWNLOADS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.action.BROWSE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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.
|
||||
*/
|
||||
|
||||
package com.android.documentsui;
|
||||
|
||||
import static com.android.documentsui.State.ACTION_MANAGE;
|
||||
import static com.android.documentsui.dirlist.DirectoryFragment.ANIM_NONE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
import com.android.documentsui.dirlist.DirectoryFragment;
|
||||
import com.android.documentsui.dirlist.Model;
|
||||
import com.android.documentsui.model.DocumentInfo;
|
||||
import com.android.documentsui.model.RootInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
// Let's face it. MANAGE_ROOT is used almost exclusively
|
||||
// for downloads, and is specialized for this purpose.
|
||||
// So it is now thusly christened.
|
||||
public class DownloadsActivity extends BaseActivity {
|
||||
private static final String TAG = "DownloadsActivity";
|
||||
|
||||
public DownloadsActivity() {
|
||||
super(R.layout.downloads_activity, TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
final Context context = this;
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setTitleTextAppearance(context,
|
||||
android.R.style.TextAppearance_DeviceDefault_Widget_ActionBar_Title);
|
||||
|
||||
if (!mState.restored) {
|
||||
// In this case, we set the activity title in AsyncTask.onPostExecute(). To prevent
|
||||
// talkback from reading aloud the default title, we clear it here.
|
||||
setTitle("");
|
||||
final Uri rootUri = getIntent().getData();
|
||||
new LoadRootTask(this, rootUri).executeOnExecutor(getExecutorForCurrentDirectory());
|
||||
} else {
|
||||
refreshCurrentRootAndDirectory(ANIM_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void includeState(State state) {
|
||||
state.action = ACTION_MANAGE;
|
||||
state.acceptMimes = new String[] { "*/*" };
|
||||
state.allowMultiple = true;
|
||||
state.showSize = true;
|
||||
state.excludedAuthorities = getExcludedAuthorities();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
mNavigator.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDrawerTitle() {
|
||||
return null; // being and nothingness
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
|
||||
final MenuItem createDir = menu.findItem(R.id.menu_create_dir);
|
||||
final MenuItem pasteFromCb = menu.findItem(R.id.menu_paste_from_clipboard);
|
||||
final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
|
||||
|
||||
createDir.setVisible(false);
|
||||
pasteFromCb.setEnabled(false);
|
||||
fileSize.setVisible(false);
|
||||
|
||||
Menus.disableHiddenItems(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void refreshDirectory(int anim) {
|
||||
final FragmentManager fm = getFragmentManager();
|
||||
final RootInfo root = getCurrentRoot();
|
||||
final DocumentInfo cwd = getCurrentDirectory();
|
||||
|
||||
assert(!mSearchManager.isSearching());
|
||||
|
||||
// If started in manage roots mode, there has to be a cwd (i.e. the root dir of the managed
|
||||
// root).
|
||||
assert(cwd != null);
|
||||
|
||||
// Normal boring directory
|
||||
DirectoryFragment.showDirectory(fm, root, cwd, anim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDocumentPicked(DocumentInfo doc, Model model) {
|
||||
assert(!doc.isDirectory());
|
||||
|
||||
// First try managing the document; we expect manager to filter
|
||||
// based on authority, so we don't grant.
|
||||
final Intent manage = new Intent(DocumentsContract.ACTION_MANAGE_DOCUMENT);
|
||||
manage.setData(doc.derivedUri);
|
||||
|
||||
try {
|
||||
startActivity(manage);
|
||||
} catch (ActivityNotFoundException ex) {
|
||||
// Fall back to viewing.
|
||||
final Intent view = new Intent(Intent.ACTION_VIEW);
|
||||
view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
view.setData(doc.derivedUri);
|
||||
|
||||
try {
|
||||
startActivity(view);
|
||||
} catch (ActivityNotFoundException ex2) {
|
||||
Snackbars.makeSnackbar(this, R.string.toast_no_application, Snackbar.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDocumentsPicked(List<DocumentInfo> docs) {}
|
||||
|
||||
@Override
|
||||
void onTaskFinished(Uri... uris) {
|
||||
Log.d(TAG, "onFinished() " + Arrays.toString(uris));
|
||||
|
||||
final Intent intent = new Intent();
|
||||
if (uris.length == 1) {
|
||||
intent.setData(uris[0]);
|
||||
} else if (uris.length > 1) {
|
||||
final ClipData clipData = new ClipData(
|
||||
null, mState.acceptMimes, new ClipData.Item(uris[0]));
|
||||
for (int i = 1; i < uris.length; i++) {
|
||||
clipData.addItem(new ClipData.Item(uris[i]));
|
||||
}
|
||||
intent.setClipData(clipData);
|
||||
}
|
||||
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
|
||||
|
||||
setResult(Activity.RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
public static DownloadsActivity get(Fragment fragment) {
|
||||
return (DownloadsActivity) fragment.getActivity();
|
||||
}
|
||||
}
|
||||
@@ -108,10 +108,10 @@ public class FilesActivity extends BaseActivity {
|
||||
// authority. That way a misbehaving provider won't result in an ANR.
|
||||
loadRoot(uri);
|
||||
} else {
|
||||
if (DEBUG) Log.d(TAG, "Launching into Home directory.");
|
||||
// If all else fails, try to load "Home" directory.
|
||||
final Uri homeUri = DocumentsContract.buildHomeUri();
|
||||
loadRoot(homeUri);
|
||||
if (DEBUG) Log.d(TAG, "All other means skipped. Launching into default directory.");
|
||||
Uri defaultUri = DocumentsContract.buildRootUri(
|
||||
"com.android.providers.downloads.documents", "downloads");
|
||||
loadRoot(defaultUri);
|
||||
}
|
||||
|
||||
final @DialogType int dialogType = intent.getIntExtra(
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.documentsui;
|
||||
|
||||
import static android.os.Environment.STANDARD_DIRECTORIES;
|
||||
import static com.android.documentsui.Shared.DEBUG;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.StringDef;
|
||||
@@ -58,7 +59,7 @@ public final class Metrics {
|
||||
private static final String COUNT_CREATE_MIME = "docsui_create_mime";
|
||||
private static final String COUNT_GET_CONTENT_MIME = "docsui_get_content_mime";
|
||||
private static final String COUNT_BROWSE_ROOT = "docsui_browse_root";
|
||||
private static final String COUNT_MANAGE_ROOT = "docsui_manage_root";
|
||||
@Deprecated private static final String COUNT_MANAGE_ROOT = "docsui_manage_root";
|
||||
private static final String COUNT_MULTI_WINDOW = "docsui_multi_window";
|
||||
private static final String COUNT_FILEOP_SYSTEM = "docsui_fileop_system";
|
||||
private static final String COUNT_FILEOP_EXTERNAL = "docsui_fileop_external";
|
||||
@@ -194,7 +195,7 @@ public final class Metrics {
|
||||
private static final int ACTION_CREATE = 3;
|
||||
private static final int ACTION_GET_CONTENT = 4;
|
||||
private static final int ACTION_OPEN_TREE = 5;
|
||||
private static final int ACTION_MANAGE = 6;
|
||||
@Deprecated private static final int ACTION_MANAGE = 6;
|
||||
private static final int ACTION_BROWSE = 7;
|
||||
private static final int ACTION_PICK_COPY_DESTINATION = 8;
|
||||
|
||||
@@ -246,9 +247,6 @@ public final class Metrics {
|
||||
case State.ACTION_GET_CONTENT:
|
||||
logHistogram(context, COUNT_GET_CONTENT_MIME, sanitizeMime(intent.getType()));
|
||||
break;
|
||||
case State.ACTION_MANAGE:
|
||||
logHistogram(context, COUNT_MANAGE_ROOT, sanitizeRoot(uri));
|
||||
break;
|
||||
case State.ACTION_BROWSE:
|
||||
logHistogram(context, COUNT_BROWSE_ROOT, sanitizeRoot(uri));
|
||||
break;
|
||||
@@ -641,8 +639,6 @@ public final class Metrics {
|
||||
return ACTION_GET_CONTENT;
|
||||
case State.ACTION_OPEN_TREE:
|
||||
return ACTION_OPEN_TREE;
|
||||
case State.ACTION_MANAGE:
|
||||
return ACTION_MANAGE;
|
||||
case State.ACTION_BROWSE:
|
||||
return ACTION_BROWSE;
|
||||
case State.ACTION_PICK_COPY_DESTINATION:
|
||||
|
||||
@@ -43,13 +43,15 @@ public class State implements android.os.Parcelable {
|
||||
|
||||
private static final String TAG = "State";
|
||||
|
||||
public static final int ACTION_OPEN = 1;
|
||||
public static final int ACTION_CREATE = 2;
|
||||
public static final int ACTION_GET_CONTENT = 3;
|
||||
public static final int ACTION_OPEN_TREE = 4;
|
||||
public static final int ACTION_MANAGE = 5;
|
||||
public static final int ACTION_BROWSE = 6;
|
||||
public static final int ACTION_PICK_COPY_DESTINATION = 8;
|
||||
// File manager and related private picking activity.
|
||||
public static final int ACTION_BROWSE = 1;
|
||||
public static final int ACTION_PICK_COPY_DESTINATION = 2;
|
||||
|
||||
// All public picking activities
|
||||
public static final int ACTION_OPEN = 3;
|
||||
public static final int ACTION_CREATE = 4;
|
||||
public static final int ACTION_GET_CONTENT = 5;
|
||||
public static final int ACTION_OPEN_TREE = 6;
|
||||
|
||||
@IntDef(flag = true, value = {
|
||||
MODE_UNKNOWN,
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.documentsui.dirlist;
|
||||
import static com.android.documentsui.State.ACTION_BROWSE;
|
||||
import static com.android.documentsui.State.ACTION_CREATE;
|
||||
import static com.android.documentsui.State.ACTION_GET_CONTENT;
|
||||
import static com.android.documentsui.State.ACTION_MANAGE;
|
||||
import static com.android.documentsui.State.ACTION_OPEN;
|
||||
import static com.android.documentsui.State.ACTION_OPEN_TREE;
|
||||
|
||||
@@ -53,8 +52,6 @@ public abstract class FragmentTuner {
|
||||
switch (state.action) {
|
||||
case ACTION_BROWSE:
|
||||
return new FilesTuner(context, state);
|
||||
case ACTION_MANAGE:
|
||||
return new DownloadsTuner(context, state);
|
||||
default:
|
||||
return new DocumentsTuner(context, state);
|
||||
}
|
||||
@@ -170,47 +167,6 @@ public abstract class FragmentTuner {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides support for Platform specific specializations of DirectoryFragment.
|
||||
*/
|
||||
private static final class DownloadsTuner extends FragmentTuner {
|
||||
|
||||
public DownloadsTuner(Context context, State state) {
|
||||
super(context, state);
|
||||
assert(state.action == ACTION_MANAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActionMenu(
|
||||
Menu menu, @ResultType int resultType, boolean canDelete, boolean canRename) {
|
||||
assert(resultType != DirectoryFragment.TYPE_RECENT_OPEN);
|
||||
|
||||
MenuItem open = menu.findItem(R.id.menu_open);
|
||||
MenuItem delete = menu.findItem(R.id.menu_delete);
|
||||
MenuItem copyTo = menu.findItem(R.id.menu_copy_to);
|
||||
MenuItem moveTo = menu.findItem(R.id.menu_move_to);
|
||||
MenuItem rename = menu.findItem(R.id.menu_rename);
|
||||
MenuItem copy = menu.findItem(R.id.menu_copy_to_clipboard);
|
||||
|
||||
open.setVisible(false);
|
||||
delete.setVisible(canDelete);
|
||||
copy.setEnabled(true); // to clipboard
|
||||
copyTo.setVisible(true);
|
||||
copyTo.setEnabled(true);
|
||||
moveTo.setVisible(true);
|
||||
moveTo.setEnabled(true);
|
||||
rename.setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
void onModelLoaded(Model model, @ResultType int resultType, boolean isSearch) {}
|
||||
|
||||
@Override
|
||||
public boolean enableManagedMode() {
|
||||
return mState.stack.root != null && mState.stack.root.isDownloads();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides support for Files activity specific specializations of DirectoryFragment.
|
||||
*/
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.
|
||||
*/
|
||||
|
||||
package com.android.documentsui;
|
||||
|
||||
import static com.android.documentsui.StubProvider.ROOT_0_ID;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.support.test.uiautomator.By;
|
||||
import android.support.test.uiautomator.Until;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
||||
@LargeTest
|
||||
public class DownloadsActivityUiTest extends ActivityTest<DownloadsActivity> {
|
||||
|
||||
public DownloadsActivityUiTest() {
|
||||
super(DownloadsActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
void launchActivity() {
|
||||
final Intent intent = new Intent(DocumentsContract.ACTION_MANAGE_ROOT);
|
||||
intent.setDataAndType(rootDir0.getUri(), DocumentsContract.Root.MIME_TYPE_ITEM);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
setActivityIntent(intent);
|
||||
getActivity(); // Launch the activity.
|
||||
}
|
||||
|
||||
@Override
|
||||
void initTestFiles() throws RemoteException {
|
||||
mDocsHelper.createDocument(rootDir0, "text/plain", "file0.log");
|
||||
mDocsHelper.createDocument(rootDir0, "image/png", "file1.png");
|
||||
mDocsHelper.createDocument(rootDir0, "text/csv", "file2.csv");
|
||||
}
|
||||
|
||||
public void testWindowTitle() throws Exception {
|
||||
initTestFiles();
|
||||
|
||||
bots.main.assertWindowTitle(ROOT_0_ID);
|
||||
}
|
||||
|
||||
public void testFilesListed() throws Exception {
|
||||
initTestFiles();
|
||||
|
||||
bots.directory.assertDocumentsPresent("file0.log", "file1.png", "file2.csv");
|
||||
}
|
||||
|
||||
public void testFilesList_LiveUpdate() throws Exception {
|
||||
initTestFiles();
|
||||
|
||||
mDocsHelper.createDocument(rootDir0, "yummers/sandwich", "Ham & Cheese.sandwich");
|
||||
|
||||
bots.directory.waitForDocument("Ham & Cheese.sandwich");
|
||||
bots.directory.assertDocumentsPresent(
|
||||
"file0.log", "file1.png", "file2.csv", "Ham & Cheese.sandwich");
|
||||
}
|
||||
|
||||
public void testDeleteDocument() throws Exception {
|
||||
initTestFiles();
|
||||
|
||||
bots.directory.clickDocument("file1.png");
|
||||
device.waitForIdle();
|
||||
bots.main.menuDelete().click();
|
||||
|
||||
bots.directory.waitForDeleteSnackbar();
|
||||
bots.directory.assertDocumentsAbsent("file1.png");
|
||||
|
||||
bots.directory.waitForDeleteSnackbarGone();
|
||||
bots.directory.assertDocumentsAbsent("file1.png");
|
||||
}
|
||||
|
||||
public void testSupportsShare() throws Exception {
|
||||
initTestFiles();
|
||||
|
||||
bots.directory.clickDocument("file1.png");
|
||||
device.waitForIdle();
|
||||
assertNotNull(bots.main.menuShare());
|
||||
}
|
||||
|
||||
public void testClosesOnBack() throws Exception {
|
||||
DownloadsActivity activity = getActivity();
|
||||
device.pressBack();
|
||||
device.wait(Until.gone(By.text(ROOT_0_ID)), TIMEOUT); // wait for the window to go away
|
||||
assertTrue(activity.isDestroyed());
|
||||
}
|
||||
}
|
||||
@@ -72,11 +72,11 @@ public class FilesActivityUiTest extends ActivityTest<FilesActivity> {
|
||||
bots.directory.assertDocumentsPresent("file0.log", "file1.png", "file2.csv");
|
||||
}
|
||||
|
||||
public void testLoadsHomeDirectoryByDefault() throws Exception {
|
||||
public void testLoadsDownloadsDirectoryByDefault() throws Exception {
|
||||
initTestFiles();
|
||||
|
||||
device.waitForIdle();
|
||||
bots.main.assertWindowTitle("Documents");
|
||||
bots.main.assertWindowTitle("Downloads");
|
||||
}
|
||||
|
||||
public void testRootClickSetsWindowTitle() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user