Loading src/com/android/documentsui/files/FilesActivity.java +37 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,10 @@ package com.android.documentsui.files; import static com.android.documentsui.OperationDialogFragment.DIALOG_TYPE_UNKNOWN; import android.app.ActivityManager.TaskDescription; import android.app.FragmentManager; import android.content.Intent; import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.support.annotation.CallSuper; Loading Loading @@ -144,9 +146,44 @@ public class FilesActivity extends BaseActivity implements ActionHandler.Addons final Intent intent = getIntent(); mInjector.actions.initLocation(intent); // Allow the activity to masquerade as another, so we can look both like // Downloads and Files, but with only a single underlying activity. if (intent.hasExtra(LauncherActivity.TASK_LABEL_RES) && intent.hasExtra(LauncherActivity.TASK_ICON_RES)) { updateTaskDescription(intent); } presentFileErrors(icicle, intent); } // This is called in the intent contains label and icon resources. // When that is true, the launcher activity has supplied them so we // can adapt our presentation to how we were launched. // Without this code, overlaying launcher_icon and launcher_label // resources won't create a complete illusion of the activity being renamed. // E.g. if we re-brand Files to Downloads by overlaying label and icon // when the user tapped recents they'd see not "Downloads", but the // underlying Activity description...Files. // Alternate if we rename this activity, when launching other ways // like when browsing files on a removable disk, the app would be // called Downloads, which is also not the desired behavior. private void updateTaskDescription(final Intent intent) { int labelRes = intent.getIntExtra(LauncherActivity.TASK_LABEL_RES, -1); assert(labelRes > -1); String label = getResources().getString(labelRes); int iconRes = intent.getIntExtra(LauncherActivity.TASK_ICON_RES, -1); assert(iconRes > -1); BitmapDrawable drawable = (BitmapDrawable) getResources().getDrawable( iconRes, null // we don't care about theme, since the supplier should have handled that. ); setTaskDescription(new TaskDescription(label, drawable.getBitmap())); } private void presentFileErrors(Bundle icicle, final Intent intent) { final @DialogType int dialogType = intent.getIntExtra( FileOperationService.EXTRA_DIALOG_TYPE, DIALOG_TYPE_UNKNOWN); Loading src/com/android/documentsui/files/LauncherActivity.java +8 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.provider.DocumentsContract; import android.support.annotation.Nullable; import android.util.Log; import com.android.documentsui.R; import java.util.List; /** Loading @@ -42,6 +44,9 @@ import java.util.List; */ public class LauncherActivity extends Activity { public static final String TASK_LABEL_RES = "com.android.documentsui.taskLabel"; public static final String TASK_ICON_RES = "com.android.documentsui.taskIcon"; private static final String LAUNCH_CONTROL_AUTHORITY = "com.android.documentsui.launchControl"; private static final String TAG = "LauncherActivity"; Loading Loading @@ -93,6 +98,9 @@ public class LauncherActivity extends Activity { private void startTask() { Intent intent = createLaunchIntent(this); intent.putExtra(TASK_LABEL_RES, R.string.launcher_label); intent.putExtra(TASK_ICON_RES, R.drawable.launcher_icon); // Forward any flags from the original intent. intent.setFlags(getIntent().getFlags()); if (DEBUG) Log.d(TAG, "Starting new task > " + intent.getData()); Loading Loading
src/com/android/documentsui/files/FilesActivity.java +37 −0 Original line number Diff line number Diff line Loading @@ -18,8 +18,10 @@ package com.android.documentsui.files; import static com.android.documentsui.OperationDialogFragment.DIALOG_TYPE_UNKNOWN; import android.app.ActivityManager.TaskDescription; import android.app.FragmentManager; import android.content.Intent; import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.support.annotation.CallSuper; Loading Loading @@ -144,9 +146,44 @@ public class FilesActivity extends BaseActivity implements ActionHandler.Addons final Intent intent = getIntent(); mInjector.actions.initLocation(intent); // Allow the activity to masquerade as another, so we can look both like // Downloads and Files, but with only a single underlying activity. if (intent.hasExtra(LauncherActivity.TASK_LABEL_RES) && intent.hasExtra(LauncherActivity.TASK_ICON_RES)) { updateTaskDescription(intent); } presentFileErrors(icicle, intent); } // This is called in the intent contains label and icon resources. // When that is true, the launcher activity has supplied them so we // can adapt our presentation to how we were launched. // Without this code, overlaying launcher_icon and launcher_label // resources won't create a complete illusion of the activity being renamed. // E.g. if we re-brand Files to Downloads by overlaying label and icon // when the user tapped recents they'd see not "Downloads", but the // underlying Activity description...Files. // Alternate if we rename this activity, when launching other ways // like when browsing files on a removable disk, the app would be // called Downloads, which is also not the desired behavior. private void updateTaskDescription(final Intent intent) { int labelRes = intent.getIntExtra(LauncherActivity.TASK_LABEL_RES, -1); assert(labelRes > -1); String label = getResources().getString(labelRes); int iconRes = intent.getIntExtra(LauncherActivity.TASK_ICON_RES, -1); assert(iconRes > -1); BitmapDrawable drawable = (BitmapDrawable) getResources().getDrawable( iconRes, null // we don't care about theme, since the supplier should have handled that. ); setTaskDescription(new TaskDescription(label, drawable.getBitmap())); } private void presentFileErrors(Bundle icicle, final Intent intent) { final @DialogType int dialogType = intent.getIntExtra( FileOperationService.EXTRA_DIALOG_TYPE, DIALOG_TYPE_UNKNOWN); Loading
src/com/android/documentsui/files/LauncherActivity.java +8 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.provider.DocumentsContract; import android.support.annotation.Nullable; import android.util.Log; import com.android.documentsui.R; import java.util.List; /** Loading @@ -42,6 +44,9 @@ import java.util.List; */ public class LauncherActivity extends Activity { public static final String TASK_LABEL_RES = "com.android.documentsui.taskLabel"; public static final String TASK_ICON_RES = "com.android.documentsui.taskIcon"; private static final String LAUNCH_CONTROL_AUTHORITY = "com.android.documentsui.launchControl"; private static final String TAG = "LauncherActivity"; Loading Loading @@ -93,6 +98,9 @@ public class LauncherActivity extends Activity { private void startTask() { Intent intent = createLaunchIntent(this); intent.putExtra(TASK_LABEL_RES, R.string.launcher_label); intent.putExtra(TASK_ICON_RES, R.drawable.launcher_icon); // Forward any flags from the original intent. intent.setFlags(getIntent().getFlags()); if (DEBUG) Log.d(TAG, "Starting new task > " + intent.getData()); Loading