Loading packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java +11 −32 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; Loading Loading @@ -66,9 +65,6 @@ import java.util.concurrent.Executor; public abstract class BaseActivity extends Activity implements SearchManagerListener, NavigationView.Environment { // See comments where this const is referenced for details. private static final int DRAWER_NO_FIDDLE_DELAY = 1500; State mState; RootsCache mRoots; SearchViewManager mSearchManager; Loading @@ -80,10 +76,6 @@ public abstract class BaseActivity extends Activity @LayoutRes private int mLayoutId; // Track the time we opened the drawer in response to back being pressed. // We use the time gap to figure out whether to close app or reopen the drawer. private long mDrawerLastFiddled; private boolean mNavDrawerHasFocus; public abstract void onDocumentPicked(DocumentInfo doc, Model model); Loading Loading @@ -368,6 +360,11 @@ public abstract class BaseActivity extends Activity invalidateOptionsMenu(); } final void loadRoot(final Uri uri) { new LoadRootTask(this, uri).executeOnExecutor( ProviderExecutor.forAuthority(uri.getAuthority())); } /** * Called when search results changed. * Refreshes the content of the directory. It doesn't refresh elements on the action bar. Loading Loading @@ -543,34 +540,16 @@ public abstract class BaseActivity extends Activity return; } int size = mState.stack.size(); // Do some "do what a I want" drawer fiddling, but don't // do it if user already hit back recently and we recently // did some fiddling. if (mDrawer.isPresent() && (System.currentTimeMillis() - mDrawerLastFiddled) > DRAWER_NO_FIDDLE_DELAY) { // Close drawer if it is open. if (mDrawer.isOpen()) { mDrawer.setOpen(false); mDrawerLastFiddled = System.currentTimeMillis(); if (onBeforePopDir() || popDir()) { return; } // Open the Close drawer if it is closed and we're at the top of a root. if (size == 1) { mDrawer.setOpen(true); // Remember so we don't just close it again if back is pressed again. mDrawerLastFiddled = System.currentTimeMillis(); return; } } if (popDir()) { return; super.onBackPressed(); } super.onBackPressed(); boolean onBeforePopDir() { // Files app overrides this with some fancy logic. return false; } public void onStackPicked(DocumentStack stack) { Loading packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +26 −9 Original line number Diff line number Diff line Loading @@ -95,13 +95,27 @@ public class DocumentsActivity extends BaseActivity { RootsFragment.show(getFragmentManager(), null); } 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. if (mState.restored) { refreshCurrentRootAndDirectory(ANIM_NONE); } else { // We set the activity title in AsyncTask.onPostExecute(). // To prevent talkback from reading aloud the default title, we clear it here. setTitle(""); new RestoreStackTask(this).execute(); // As a matter of policy we don't load the last used stack for the copy // destination picker (user is already in Files app). // Concensus was that the experice was too confusing. // In all other cases, where the user is visiting us from another app // we restore the stack as last used from that app. if (mState.action == ACTION_PICK_COPY_DESTINATION) { if (DEBUG) Log.d(TAG, "Launching directly into Home directory."); Uri homeUri = DocumentsContract.buildHomeUri(); new LoadRootTask(this, homeUri).executeOnExecutor( ProviderExecutor.forAuthority(homeUri.getAuthority())); } else { refreshCurrentRootAndDirectory(ANIM_NONE); if (DEBUG) Log.d(TAG, "Attempting to load last used stack for calling package."); new LoadLastUsedStackTask(this).execute(); } } } Loading Loading @@ -443,16 +457,19 @@ public class DocumentsActivity extends BaseActivity { } /** * Restores the stack from Recents for the specified package. * Loads the last used path (stack) from Recents (history). * The path selected is based on the calling package name. So the last * path for an app like Gmail can be different than the last path * for an app like DropBox. */ private static final class RestoreStackTask private static final class LoadLastUsedStackTask extends PairedTask<DocumentsActivity, Void, Void> { private volatile boolean mRestoredStack; private volatile boolean mExternal; private State mState; public RestoreStackTask(DocumentsActivity activity) { public LoadLastUsedStackTask(DocumentsActivity activity) { super(activity); mState = activity.mState; } Loading packages/DocumentsUI/src/com/android/documentsui/DownloadsActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class DownloadsActivity extends BaseActivity { // talkback from reading aloud the default title, we clear it here. setTitle(""); final Uri rootUri = getIntent().getData(); new RestoreRootTask(this, rootUri).executeOnExecutor(getExecutorForCurrentDirectory()); new LoadRootTask(this, rootUri).executeOnExecutor(getExecutorForCurrentDirectory()); } else { refreshCurrentRootAndDirectory(ANIM_NONE); } Loading packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java +36 −4 Original line number Diff line number Diff line Loading @@ -62,6 +62,12 @@ public class FilesActivity extends BaseActivity { public static final String TAG = "FilesActivity"; // See comments where this const is referenced for details. private static final int DRAWER_NO_FIDDLE_DELAY = 1500; // Track the time we opened the drawer in response to back being pressed. // We use the time gap to figure out whether to close app or reopen the drawer. private long mDrawerLastFiddled; private DocumentClipper mClipper; public FilesActivity() { Loading Loading @@ -102,14 +108,12 @@ public class FilesActivity extends BaseActivity { if (DEBUG) Log.d(TAG, "Launching with root URI."); // If we've got a specific root to display, restore that root using a dedicated // authority. That way a misbehaving provider won't result in an ANR. new RestoreRootTask(this, uri).executeOnExecutor( ProviderExecutor.forAuthority(uri.getAuthority())); 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(); new RestoreRootTask(this, homeUri).executeOnExecutor( ProviderExecutor.forAuthority(homeUri.getAuthority())); loadRoot(homeUri); } final @DialogType int dialogType = intent.getIntExtra( Loading Loading @@ -340,6 +344,34 @@ public class FilesActivity extends BaseActivity { } } // Do some "do what a I want" drawer fiddling, but don't // do it if user already hit back recently and we recently // did some fiddling. @Override boolean onBeforePopDir() { int size = mState.stack.size(); if (mDrawer.isPresent() && (System.currentTimeMillis() - mDrawerLastFiddled) > DRAWER_NO_FIDDLE_DELAY) { // Close drawer if it is open. if (mDrawer.isOpen()) { mDrawer.setOpen(false); mDrawerLastFiddled = System.currentTimeMillis(); return true; } // Open the Close drawer if it is closed and we're at the top of a root. if (size == 1) { mDrawer.setOpen(true); // Remember so we don't just close it again if back is pressed again. mDrawerLastFiddled = System.currentTimeMillis(); return true; } } return false; } // Turns out only DocumentsActivity was ever calling saveStackBlocking. // There may be a case where we want to contribute entries from // Behavior here in FilesActivity, but it isn't yet obvious. Loading packages/DocumentsUI/src/com/android/documentsui/RestoreRootTask.java→packages/DocumentsUI/src/com/android/documentsui/LoadRootTask.java +2 −2 Original line number Diff line number Diff line Loading @@ -22,12 +22,12 @@ import android.util.Log; import com.android.documentsui.model.RootInfo; final class RestoreRootTask extends PairedTask<BaseActivity, Void, RootInfo> { final class LoadRootTask extends PairedTask<BaseActivity, Void, RootInfo> { private static final String TAG = "RestoreRootTask"; private final Uri mRootUri; public RestoreRootTask(BaseActivity activity, Uri rootUri) { public LoadRootTask(BaseActivity activity, Uri rootUri) { super(activity); mRootUri = rootUri; } Loading Loading
packages/DocumentsUI/src/com/android/documentsui/BaseActivity.java +11 −32 Original line number Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.database.Cursor; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; Loading Loading @@ -66,9 +65,6 @@ import java.util.concurrent.Executor; public abstract class BaseActivity extends Activity implements SearchManagerListener, NavigationView.Environment { // See comments where this const is referenced for details. private static final int DRAWER_NO_FIDDLE_DELAY = 1500; State mState; RootsCache mRoots; SearchViewManager mSearchManager; Loading @@ -80,10 +76,6 @@ public abstract class BaseActivity extends Activity @LayoutRes private int mLayoutId; // Track the time we opened the drawer in response to back being pressed. // We use the time gap to figure out whether to close app or reopen the drawer. private long mDrawerLastFiddled; private boolean mNavDrawerHasFocus; public abstract void onDocumentPicked(DocumentInfo doc, Model model); Loading Loading @@ -368,6 +360,11 @@ public abstract class BaseActivity extends Activity invalidateOptionsMenu(); } final void loadRoot(final Uri uri) { new LoadRootTask(this, uri).executeOnExecutor( ProviderExecutor.forAuthority(uri.getAuthority())); } /** * Called when search results changed. * Refreshes the content of the directory. It doesn't refresh elements on the action bar. Loading Loading @@ -543,34 +540,16 @@ public abstract class BaseActivity extends Activity return; } int size = mState.stack.size(); // Do some "do what a I want" drawer fiddling, but don't // do it if user already hit back recently and we recently // did some fiddling. if (mDrawer.isPresent() && (System.currentTimeMillis() - mDrawerLastFiddled) > DRAWER_NO_FIDDLE_DELAY) { // Close drawer if it is open. if (mDrawer.isOpen()) { mDrawer.setOpen(false); mDrawerLastFiddled = System.currentTimeMillis(); if (onBeforePopDir() || popDir()) { return; } // Open the Close drawer if it is closed and we're at the top of a root. if (size == 1) { mDrawer.setOpen(true); // Remember so we don't just close it again if back is pressed again. mDrawerLastFiddled = System.currentTimeMillis(); return; } } if (popDir()) { return; super.onBackPressed(); } super.onBackPressed(); boolean onBeforePopDir() { // Files app overrides this with some fancy logic. return false; } public void onStackPicked(DocumentStack stack) { Loading
packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java +26 −9 Original line number Diff line number Diff line Loading @@ -95,13 +95,27 @@ public class DocumentsActivity extends BaseActivity { RootsFragment.show(getFragmentManager(), null); } 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. if (mState.restored) { refreshCurrentRootAndDirectory(ANIM_NONE); } else { // We set the activity title in AsyncTask.onPostExecute(). // To prevent talkback from reading aloud the default title, we clear it here. setTitle(""); new RestoreStackTask(this).execute(); // As a matter of policy we don't load the last used stack for the copy // destination picker (user is already in Files app). // Concensus was that the experice was too confusing. // In all other cases, where the user is visiting us from another app // we restore the stack as last used from that app. if (mState.action == ACTION_PICK_COPY_DESTINATION) { if (DEBUG) Log.d(TAG, "Launching directly into Home directory."); Uri homeUri = DocumentsContract.buildHomeUri(); new LoadRootTask(this, homeUri).executeOnExecutor( ProviderExecutor.forAuthority(homeUri.getAuthority())); } else { refreshCurrentRootAndDirectory(ANIM_NONE); if (DEBUG) Log.d(TAG, "Attempting to load last used stack for calling package."); new LoadLastUsedStackTask(this).execute(); } } } Loading Loading @@ -443,16 +457,19 @@ public class DocumentsActivity extends BaseActivity { } /** * Restores the stack from Recents for the specified package. * Loads the last used path (stack) from Recents (history). * The path selected is based on the calling package name. So the last * path for an app like Gmail can be different than the last path * for an app like DropBox. */ private static final class RestoreStackTask private static final class LoadLastUsedStackTask extends PairedTask<DocumentsActivity, Void, Void> { private volatile boolean mRestoredStack; private volatile boolean mExternal; private State mState; public RestoreStackTask(DocumentsActivity activity) { public LoadLastUsedStackTask(DocumentsActivity activity) { super(activity); mState = activity.mState; } Loading
packages/DocumentsUI/src/com/android/documentsui/DownloadsActivity.java +1 −1 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class DownloadsActivity extends BaseActivity { // talkback from reading aloud the default title, we clear it here. setTitle(""); final Uri rootUri = getIntent().getData(); new RestoreRootTask(this, rootUri).executeOnExecutor(getExecutorForCurrentDirectory()); new LoadRootTask(this, rootUri).executeOnExecutor(getExecutorForCurrentDirectory()); } else { refreshCurrentRootAndDirectory(ANIM_NONE); } Loading
packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java +36 −4 Original line number Diff line number Diff line Loading @@ -62,6 +62,12 @@ public class FilesActivity extends BaseActivity { public static final String TAG = "FilesActivity"; // See comments where this const is referenced for details. private static final int DRAWER_NO_FIDDLE_DELAY = 1500; // Track the time we opened the drawer in response to back being pressed. // We use the time gap to figure out whether to close app or reopen the drawer. private long mDrawerLastFiddled; private DocumentClipper mClipper; public FilesActivity() { Loading Loading @@ -102,14 +108,12 @@ public class FilesActivity extends BaseActivity { if (DEBUG) Log.d(TAG, "Launching with root URI."); // If we've got a specific root to display, restore that root using a dedicated // authority. That way a misbehaving provider won't result in an ANR. new RestoreRootTask(this, uri).executeOnExecutor( ProviderExecutor.forAuthority(uri.getAuthority())); 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(); new RestoreRootTask(this, homeUri).executeOnExecutor( ProviderExecutor.forAuthority(homeUri.getAuthority())); loadRoot(homeUri); } final @DialogType int dialogType = intent.getIntExtra( Loading Loading @@ -340,6 +344,34 @@ public class FilesActivity extends BaseActivity { } } // Do some "do what a I want" drawer fiddling, but don't // do it if user already hit back recently and we recently // did some fiddling. @Override boolean onBeforePopDir() { int size = mState.stack.size(); if (mDrawer.isPresent() && (System.currentTimeMillis() - mDrawerLastFiddled) > DRAWER_NO_FIDDLE_DELAY) { // Close drawer if it is open. if (mDrawer.isOpen()) { mDrawer.setOpen(false); mDrawerLastFiddled = System.currentTimeMillis(); return true; } // Open the Close drawer if it is closed and we're at the top of a root. if (size == 1) { mDrawer.setOpen(true); // Remember so we don't just close it again if back is pressed again. mDrawerLastFiddled = System.currentTimeMillis(); return true; } } return false; } // Turns out only DocumentsActivity was ever calling saveStackBlocking. // There may be a case where we want to contribute entries from // Behavior here in FilesActivity, but it isn't yet obvious. Loading
packages/DocumentsUI/src/com/android/documentsui/RestoreRootTask.java→packages/DocumentsUI/src/com/android/documentsui/LoadRootTask.java +2 −2 Original line number Diff line number Diff line Loading @@ -22,12 +22,12 @@ import android.util.Log; import com.android.documentsui.model.RootInfo; final class RestoreRootTask extends PairedTask<BaseActivity, Void, RootInfo> { final class LoadRootTask extends PairedTask<BaseActivity, Void, RootInfo> { private static final String TAG = "RestoreRootTask"; private final Uri mRootUri; public RestoreRootTask(BaseActivity activity, Uri rootUri) { public LoadRootTask(BaseActivity activity, Uri rootUri) { super(activity); mRootUri = rootUri; } Loading