【问题】从Gallery Widget 点击查看图片,再按back 键,返回AlbumPage;
【需求】直接返回launcher 界面;转自
[SOLUTION]请作如下修改:
1.在GalleryActivity.java中增加mFromWidget变量:
/// M: [TESTCASE.ADD] add for performance test case@{ public long mStopTime = 0;+ private boolean mFromWidget=false;/// @}
2. 在GalleryActivity.java的onCreate()方法中给mFromWidget 赋值:
(intent != null && (intent.getBooleanExtra(EXTRA_FROM_WIDGET, false) || (intent.getAction() != null && intent.getAction().equals(intent.ACTION_MAIN)))) { + mFromWidget=intent.getBooleanExtra(EXTRA_FROM_WIDGET, false);View view = findViewById(R.id.gl_root_cover);if (view != null) { view.setVisibility(View.VISIBLE);
3. 在GalleryActivity.java的startViewAction()中添加:
itemPath.clearObject();albumPath = dm.getDefaultSetOf(itemPath);/// @}+ data.putBoolean(EXTRA_FROM_WIDGET, mFromWidget);data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());data.putBoolean(PhotoPage.KEY_READONLY, true);
4. 在PhotoPage.java中添加EXTRA_FROM_WIDGET :
public static final String KEY_SHOW_WHEN_LOCKED = "show_when_locked";public static final String KEY_IN_CAMERA_ROLL = "in_camera_roll";public static final String KEY_READONLY = "read-only";+ public static final String EXTRA_FROM_WIDGET = "fromWidget";public static final String KEY_ALBUMPAGE_TRANSITION = "albumpage-transition";public static final int MSG_ALBUMPAGE_NONE = 0;public static final int MSG_ALBUMPAGE_STARTED = 1;
5. 在PhotoPage.java添加mIsFromWidget
private boolean mIsActive;private boolean mShowSpinner;private String mSetPathString;+ private boolean mIsFromWidget = false;// This is the original mSetPathString before adding the camera preview item.private boolean mReadOnlyView = false;private String mOriginalSetPathString;
6. 在PhotoPage.java中给mIsFromWidget赋值:
mSetPathString = data.getString(KEY_MEDIA_SET_PATH);mReadOnlyView = data.getBoolean(KEY_READONLY);+ mIsFromWidget=data.getBoolean(EXTRA_FROM_WIDGET);mOriginalSetPathString = mSetPathString;setupNfcBeamPush();String itemPathString = data.getString(KEY_MEDIA_ITEM_PATH);
7. 在PhotoPage.java的onBackPressed()中添加如下:
/*showBars();*/wantBars();/// @}+ if(mFromWidget){ + super.onBackPressed();+ return;+ }if (mShowDetails) { hideDetails();} else if (mAppBridge == null || !switchWithCaptureAnimation(-1)) {