Add daily rotation icon to the tool bar. (1/3)

Bug: 185308659
Test: manual
Change-Id: Ia988143c0b43055e9e3bb82315329bdb26c0cc48
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
index d2921a3..157fe86 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
@@ -38,6 +38,7 @@
 import android.service.wallpaper.WallpaperService;
 import android.util.Log;
 import android.view.LayoutInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.Toast;
@@ -415,6 +416,9 @@
                 && !mBottomActionBar.areActionsShown(ROTATION)) {
             mBottomActionBar.showActions(ROTATION);
         }
+        if (mToolbar != null && isRotationEnabled()) {
+            setUpToolbarMenu(R.menu.individual_picker_menu);
+        }
         fetchWallpapers(false);
 
         if (mCategory.supportsThirdParty()) {
@@ -495,6 +499,9 @@
             setUpArrowEnabled(/* upArrow= */ true);
         } else {
             setUpToolbar(view);
+            if (isRotationEnabled()) {
+                setUpToolbarMenu(R.menu.individual_picker_menu);
+            }
             if (mCategory != null) {
                 setTitle(mCategory.getTitle());
             }
@@ -939,6 +946,18 @@
         }
     }
 
+    @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);
+            return true;
+        }
+        return super.onMenuItemClick(item);
+    }
+
     /**
      * Shows a "set wallpaper" error dialog with a failure message and button to try again.
      */