diff options
author | Steve McKay <smckay@google.com> | 2015-05-07 14:08:20 -0700 |
---|---|---|
committer | Steve McKay <smckay@google.com> | 2015-05-11 16:19:00 +0000 |
commit | 6e02dc8cd69720043bd36ae29fe93e767e3b38a9 (patch) | |
tree | 62e134a63fdb894afaffb62bd7efe49784a45c33 /packages/DocumentsUI | |
parent | 7b753cf12e471e15a4b1c1b710393b40502a8bb7 (diff) | |
download | frameworks_base-6e02dc8cd69720043bd36ae29fe93e767e3b38a9.zip frameworks_base-6e02dc8cd69720043bd36ae29fe93e767e3b38a9.tar.gz frameworks_base-6e02dc8cd69720043bd36ae29fe93e767e3b38a9.tar.bz2 |
Delete StandaloneActivity from M (DO NOT MERGE)
The activity is already disabled by default.
Fix an issue where copy support error handling was attempting to invoke StandaloneActivity.
Change-Id: If15c312a183cae1b2a84517e7f7b3123c11bd619
Diffstat (limited to 'packages/DocumentsUI')
5 files changed, 14 insertions, 351 deletions
diff --git a/packages/DocumentsUI/AndroidManifest.xml b/packages/DocumentsUI/AndroidManifest.xml index bf50017..382b2d0 100644 --- a/packages/DocumentsUI/AndroidManifest.xml +++ b/packages/DocumentsUI/AndroidManifest.xml @@ -47,17 +47,6 @@ </intent-filter> </activity> - <activity - android:name=".StandaloneActivity" - android:theme="@style/StandaloneTheme" - android:icon="@drawable/ic_doc_text" - android:enabled="false"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - <provider android:name=".RecentsProvider" android:authorities="com.android.documentsui.recents" diff --git a/packages/DocumentsUI/res/values/styles.xml b/packages/DocumentsUI/res/values/styles.xml index 97509f7..6d741aa 100644 --- a/packages/DocumentsUI/res/values/styles.xml +++ b/packages/DocumentsUI/res/values/styles.xml @@ -36,20 +36,4 @@ <item name="android:windowSoftInputMode">stateUnspecified|adjustUnspecified</item> </style> - <style name="StandaloneTheme" parent="@android:style/Theme.Material.DayNight.DarkActionBar"> - <item name="android:actionBarWidgetTheme">@null</item> - - <item name="android:colorPrimaryDark">@*android:color/material_blue_grey_900</item> - <item name="android:colorPrimary">@*android:color/material_blue_grey_800</item> - <item name="android:colorAccent">@*android:color/material_deep_teal_500</item> - - <item name="android:listDivider">@*android:drawable/list_divider_material</item> - - <item name="android:windowActionBar">false</item> - <item name="android:windowActionModeOverlay">true</item> - <item name="android:windowNoTitle">true</item> - - <item name="android:windowSoftInputMode">stateUnspecified|adjustUnspecified</item> - </style> - </resources> diff --git a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java index 202402f..6e050c6 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java +++ b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java @@ -156,7 +156,7 @@ public class CopyService extends IntentService { if (mFailedFiles.size() > 0) { final Context context = getApplicationContext(); - final Intent navigateIntent = new Intent(context, StandaloneActivity.class); + final Intent navigateIntent = new Intent(context, DocumentsActivity.class); navigateIntent.putExtra(EXTRA_STACK, (Parcelable) stack); navigateIntent.putExtra(EXTRA_FAILURE, FAILURE_COPY); navigateIntent.putParcelableArrayListExtra(EXTRA_SRC_LIST, mFailedFiles); @@ -200,7 +200,7 @@ public class CopyService extends IntentService { mIsCancelled = false; final Context context = getApplicationContext(); - final Intent navigateIntent = new Intent(context, StandaloneActivity.class); + final Intent navigateIntent = new Intent(context, DocumentsActivity.class); navigateIntent.putExtra(EXTRA_STACK, (Parcelable) stack); mProgressBuilder = new Notification.Builder(this) diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java index e58c637..cded717 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java @@ -27,6 +27,7 @@ import static com.android.documentsui.DirectoryFragment.ANIM_DOWN; import static com.android.documentsui.DirectoryFragment.ANIM_NONE; import static com.android.documentsui.DirectoryFragment.ANIM_UP; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -66,6 +67,7 @@ import android.widget.Toolbar; import com.android.documentsui.RecentsProvider.RecentColumns; import com.android.documentsui.RecentsProvider.ResumeColumns; import com.android.documentsui.model.DocumentInfo; +import com.android.documentsui.model.DocumentStack; import com.android.documentsui.model.DurableUtils; import com.android.documentsui.model.RootInfo; @@ -189,6 +191,16 @@ public class DocumentsActivity extends BaseActivity { } else { new RestoreStackTask().execute(); } + + // Show a failure dialog if there was a failed operation. + final Intent intent = getIntent(); + final DocumentStack dstStack = intent.getParcelableExtra(CopyService.EXTRA_STACK); + final int failure = intent.getIntExtra(CopyService.EXTRA_FAILURE, 0); + if (failure != 0) { + final ArrayList<DocumentInfo> failedSrcList = + intent.getParcelableArrayListExtra(CopyService.EXTRA_SRC_LIST); + FailureDialogFragment.show(getFragmentManager(), failure, failedSrcList, dstStack); + } } else { onCurrentDirectoryChanged(ANIM_NONE); } diff --git a/packages/DocumentsUI/src/com/android/documentsui/StandaloneActivity.java b/packages/DocumentsUI/src/com/android/documentsui/StandaloneActivity.java deleted file mode 100644 index 1f62973..0000000 --- a/packages/DocumentsUI/src/com/android/documentsui/StandaloneActivity.java +++ /dev/null @@ -1,322 +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.DirectoryFragment.ANIM_DOWN; -import static com.android.documentsui.DirectoryFragment.ANIM_NONE; -import static com.android.documentsui.DirectoryFragment.ANIM_UP; -import android.app.Activity; -import android.app.FragmentManager; -import android.content.ActivityNotFoundException; -import android.content.ClipData; -import android.content.ContentResolver; -import android.content.ContentValues; -import android.content.Context; -import android.content.Intent; -import android.graphics.Point; -import android.net.Uri; -import android.os.Bundle; -import android.provider.DocumentsContract; -import android.provider.DocumentsContract.Root; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.WindowManager; -import android.widget.BaseAdapter; -import android.widget.Spinner; -import android.widget.Toast; -import android.widget.Toolbar; - -import com.android.documentsui.FailureDialogFragment; -import com.android.documentsui.RecentsProvider.ResumeColumns; -import com.android.documentsui.model.DocumentInfo; -import com.android.documentsui.model.DocumentStack; -import com.android.documentsui.model.DurableUtils; -import com.android.documentsui.model.RootInfo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Activity providing a directly launchable file management activity. - */ -public class StandaloneActivity extends BaseActivity { - public static final String TAG = "StandaloneFileManagement"; - - private Toolbar mToolbar; - private Spinner mToolbarStack; - private Toolbar mRootsToolbar; - private DirectoryContainerView mDirectoryContainer; - private State mState; - private ItemSelectedListener mStackListener; - private BaseAdapter mStackAdapter; - - public StandaloneActivity() { - super(TAG); - } - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - setResult(Activity.RESULT_CANCELED); - setContentView(R.layout.activity); - - final Context context = this; - - mDirectoryContainer = (DirectoryContainerView) findViewById(R.id.container_directory); - - mState = (icicle != null) - ? icicle.<State>getParcelable(EXTRA_STATE) - : buildDefaultState(); - - mToolbar = (Toolbar) findViewById(R.id.toolbar); - mToolbar.setTitleTextAppearance(context, - android.R.style.TextAppearance_DeviceDefault_Widget_ActionBar_Title); - - mStackAdapter = new StackAdapter(); - mStackListener = new ItemSelectedListener(); - mToolbarStack = (Spinner) findViewById(R.id.stack); - mToolbarStack.setOnItemSelectedListener(mStackListener); - - mRootsToolbar = (Toolbar) findViewById(R.id.roots_toolbar); - if (mRootsToolbar != null) { - mRootsToolbar.setTitleTextAppearance(context, - android.R.style.TextAppearance_DeviceDefault_Widget_ActionBar_Title); - } - - setActionBar(mToolbar); - - RootsFragment.show(getFragmentManager(), null); - if (!mState.restored) { - new RestoreStackTask().execute(); - - // Show a failure dialog if there was a failed operation. - final Intent intent = getIntent(); - final DocumentStack dstStack = intent.getParcelableExtra(CopyService.EXTRA_STACK); - final int failure = intent.getIntExtra(CopyService.EXTRA_FAILURE, 0); - if (failure != 0) { - final ArrayList<DocumentInfo> failedSrcList = - intent.getParcelableArrayListExtra(CopyService.EXTRA_SRC_LIST); - FailureDialogFragment.show(getFragmentManager(), failure, failedSrcList, dstStack); - } - } else { - onCurrentDirectoryChanged(ANIM_NONE); - } - } - - private State buildDefaultState() { - State state = new State(); - - final Intent intent = getIntent(); - state.action = State.ACTION_BROWSE_ALL; - state.acceptMimes = new String[] { "*/*" }; - state.allowMultiple = true; - state.acceptMimes = new String[] { intent.getType() }; - state.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false); - state.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); - state.showAdvanced = state.forceAdvanced - | LocalPreferences.getDisplayAdvancedDevices(this); - state.showSize = true; - final DocumentStack stack = intent.getParcelableExtra(CopyService.EXTRA_STACK); - if (stack != null) - state.stack = stack; - - return state; - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - updateActionBar(); - } - - @Override - public void updateActionBar() { - final RootInfo root = getCurrentRoot(); - mToolbar.setNavigationIcon( - root != null ? root.loadToolbarIcon(mToolbar.getContext()) : null); - mToolbar.setNavigationContentDescription(R.string.drawer_open); - mToolbar.setNavigationOnClickListener(null); - - if (mSearchManager.isExpanded()) { - mToolbar.setTitle(null); - mToolbarStack.setVisibility(View.GONE); - mToolbarStack.setAdapter(null); - } else { - if (mState.stack.size() <= 1) { - mToolbar.setTitle(root.title); - mToolbarStack.setVisibility(View.GONE); - mToolbarStack.setAdapter(null); - } else { - mToolbar.setTitle(null); - mToolbarStack.setVisibility(View.VISIBLE); - mToolbarStack.setAdapter(mStackAdapter); - - mStackListener.mIgnoreNextNavigation = true; - mToolbarStack.setSelection(mStackAdapter.getCount() - 1); - } - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - boolean showMenu = super.onCreateOptionsMenu(menu); - - expandMenus(menu); - return showMenu; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - boolean shown = super.onPrepareOptionsMenu(menu); - - final RootInfo root = getCurrentRoot(); - final DocumentInfo cwd = getCurrentDirectory(); - - final MenuItem createDir = menu.findItem(R.id.menu_create_dir); - final MenuItem advanced = menu.findItem(R.id.menu_advanced); - final MenuItem fileSize = menu.findItem(R.id.menu_file_size); - final MenuItem settings = menu.findItem(R.id.menu_settings); - - createDir.setVisible(cwd != null - && cwd.isCreateSupported() - && !mSearchManager.isSearching() - && !root.isDownloads()); - - fileSize.setVisible(cwd != null); - advanced.setVisible(cwd != null); - - settings.setVisible((root.flags & Root.FLAG_HAS_SETTINGS) != 0); - - return shown; - } - - @Override - public void onBackPressed() { - if (!mState.stackTouched) { - super.onBackPressed(); - return; - } - - final int size = mState.stack.size(); - if (size > 1) { - mState.stack.pop(); - onCurrentDirectoryChanged(ANIM_UP); - } else { - super.onBackPressed(); - } - } - - @Override - public State getDisplayState() { - return mState; - } - - @Override - void onDirectoryChanged(int anim) { - final FragmentManager fm = getFragmentManager(); - final RootInfo root = getCurrentRoot(); - final DocumentInfo cwd = getCurrentDirectory(); - - mDirectoryContainer.setDrawDisappearingFirst(anim == ANIM_DOWN); - - if (cwd == null) { - DirectoryFragment.showRecentsOpen(fm, anim); - - // Start recents in grid when requesting visual things - final boolean visualMimes = MimePredicate.mimeMatches( - MimePredicate.VISUAL_MIMES, mState.acceptMimes); - mState.userMode = visualMimes ? State.MODE_GRID : State.MODE_LIST; - mState.derivedMode = mState.userMode; - } else { - if (mState.currentSearch != null) { - // Ongoing search - DirectoryFragment.showSearch(fm, root, mState.currentSearch, anim); - } else { - // Normal boring directory - DirectoryFragment.showNormal(fm, root, cwd, anim); - } - } - } - - @Override - public void onDocumentPicked(DocumentInfo doc) { - if (doc.isDirectory()) { - mState.stack.push(doc); - mState.stackTouched = true; - onCurrentDirectoryChanged(ANIM_DOWN); - } else { - // 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) { - Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show(); - } - } - } - - public void onDocumentsPicked(List<DocumentInfo> docs) { - // TODO - } - - @Override - void saveStackBlocking() { - final ContentResolver resolver = getContentResolver(); - final ContentValues values = new ContentValues(); - - final byte[] rawStack = DurableUtils.writeToArrayOrNull( - getDisplayState().stack); - - // Remember location for next app launch - final String packageName = getCallingPackageMaybeExtra(); - values.clear(); - values.put(ResumeColumns.STACK, rawStack); - values.put(ResumeColumns.EXTERNAL, 0); - resolver.insert(RecentsProvider.buildResume(packageName), values); - } - - @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(); - } -} |