Add daily rotation icon to the tool bar for WP2. (2/3)
Bug: 185308659
Test: manual
Change-Id: If6d2c24734dba40cf745604bea154500fe2bdd2a
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
index 157fe86..c1eb6c9 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
@@ -21,6 +21,7 @@
import static com.android.wallpaper.widget.BottomActionBar.BottomAction.INFORMATION;
import static com.android.wallpaper.widget.BottomActionBar.BottomAction.ROTATION;
+import android.annotation.MenuRes;
import android.app.Activity;
import android.app.ProgressDialog;
import android.app.WallpaperManager;
@@ -190,6 +191,18 @@
void setToolbarTitle(CharSequence title);
/**
+ * Configures the menu in the toolbar.
+ *
+ * @param menuResId the resource id of the menu
+ */
+ void setToolbarMenu(@MenuRes int menuResId);
+
+ /**
+ * Removes the menu in the toolbar.
+ */
+ void removeToolbarMenu();
+
+ /**
* Moves to the previous fragment.
*/
void moveToPreviousFragment();
@@ -497,6 +510,9 @@
if (getIndividualPickerFragmentHost().isHostToolbarShown()) {
view.findViewById(R.id.header_bar).setVisibility(View.GONE);
setUpArrowEnabled(/* upArrow= */ true);
+ if (isRotationEnabled()) {
+ getIndividualPickerFragmentHost().setToolbarMenu(R.menu.individual_picker_menu);
+ }
} else {
setUpToolbar(view);
if (isRotationEnabled()) {
@@ -695,6 +711,12 @@
}
@Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ getIndividualPickerFragmentHost().removeToolbarMenu();
+ }
+
+ @Override
public void onDestroy() {
super.onDestroy();
if (mProgressDialog != null) {
@@ -949,16 +971,23 @@
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.daily_rotation) {
- DialogFragment startRotationDialogFragment = new StartRotationDialogFragment();
- startRotationDialogFragment.setTargetFragment(
- IndividualPickerFragment.this, UNUSED_REQUEST_CODE);
- startRotationDialogFragment.show(getFragmentManager(), TAG_START_ROTATION_DIALOG);
+ showRotationDialog();
return true;
}
return super.onMenuItemClick(item);
}
/**
+ * Popups a daily rotation dialog for the uses to confirm.
+ */
+ public void showRotationDialog() {
+ DialogFragment startRotationDialogFragment = new StartRotationDialogFragment();
+ startRotationDialogFragment.setTargetFragment(
+ IndividualPickerFragment.this, UNUSED_REQUEST_CODE);
+ startRotationDialogFragment.show(getFragmentManager(), TAG_START_ROTATION_DIALOG);
+ }
+
+ /**
* Shows a "set wallpaper" error dialog with a failure message and button to try again.
*/
private void showSetWallpaperErrorDialog() {