[ThemePicker 2/N] Add an initial Theme fragment

Initial (mostly empty) implementation of ThemeFragment.
More content to come in follow-up CLs.

Bug: 120559294
Change-Id: Ic763f12cb86945b5af40e14349498660478921a4
diff --git a/res/color/bottom_nav_item_color.xml b/res/color/bottom_nav_item_color.xml
index d1c118b..17d8fce 100644
--- a/res/color/bottom_nav_item_color.xml
+++ b/res/color/bottom_nav_item_color.xml
@@ -17,7 +17,7 @@
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item
         android:state_checked="true"
-        android:color="@color/accent_color" />
+        android:color="?android:colorAccent" />
     <item
         android:state_checked="false"
         android:color="@color/material_grey500" />
diff --git a/res/layout/activity_customization_picker_main.xml b/res/layout/activity_customization_picker_main.xml
index 40fcabb..5910ab6 100755
--- a/res/layout/activity_customization_picker_main.xml
+++ b/res/layout/activity_customization_picker_main.xml
@@ -14,7 +14,7 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<androidx.coordinatorlayout.widget.CoordinatorLayout
+<FrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
@@ -24,14 +24,16 @@
     <FrameLayout
         android:id="@+id/fragment_container"
         android:layout_width="match_parent"
-        android:layout_height="match_parent" />
+        android:layout_height="match_parent"
+        android:layout_marginBottom="@dimen/bottom_navbar_height"/>
 
     <com.google.android.material.bottomnavigation.BottomNavigationView
-        style="@style/BottomNavStyle"
         android:id="@+id/main_bottom_nav"
+        style="@style/BottomNavStyle"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="@dimen/bottom_navbar_height"
         android:layout_gravity="bottom"
         app:labelVisibilityMode="labeled"
         app:menu="@menu/bottom_navigation_menu"/>
-</androidx.coordinatorlayout.widget.CoordinatorLayout>
+
+</FrameLayout>
diff --git a/res/layout/fragment_theme_picker.xml b/res/layout/fragment_theme_picker.xml
new file mode 100644
index 0000000..d88e1f7
--- /dev/null
+++ b/res/layout/fragment_theme_picker.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:background="@color/category_picker_background_color">
+    <include layout="@layout/section_header"/>
+
+    <!-- TODO(santie): Preview pager goes here... -->
+
+    <LinearLayout
+        android:id="@+id/options_section"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/options_container"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"/>
+
+        <RelativeLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content">
+            <Button
+                style="@style/ActionPrimaryButton"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentEnd="true"
+                android:text="@string/apply_theme_btn"/>
+        </RelativeLayout>
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 0000000..e96bfa7
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+     Copyright (C) 2018 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<resources>
+    <dimen name="bottom_navbar_height">56dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f04ee7e..8c1fc6d 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -33,4 +33,8 @@
     <!-- Title of a section of the customization picker where the user can select a Wallpaper.
         [CHAR LIMIT=15] -->
     <string name="wallpaper_title">Wallpaper</string>
+
+    <!-- Label for a button that allows the user to apply the currently selected Theme.
+        [CHAR LIMIT=20] -->
+    <string name="apply_theme_btn">Apply Theme</string>
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index dcc76e5..dfd7a4b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -31,6 +31,7 @@
         <item name="android:windowActionBar">false</item>
         <item name="android:windowNoTitle">true</item>
     </style>
+
     <style name="BottomNavStyle" parent="@style/Widget.MaterialComponents.BottomNavigationView">
         <item name="itemIconTint">@color/bottom_nav_item_color</item>
         <item name="itemTextColor">@color/bottom_nav_item_color</item>
@@ -41,4 +42,12 @@
     <style name="BottomNavTextAppearance" parent="@android:style/TextAppearance.Small">
         <item name="android:textStyle">bold</item>
     </style>
+    <style name="RegularToolbarStyle" parent="@android:style/Widget.DeviceDefault.Light.ActionBar.Solid">
+        <item name="android:background">@color/primary_color</item>
+        <item name="android:elevation">0dp</item>
+    </style>
+
+    <style name="HeaderTextAppearance" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title"/>
+
+    <style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
 </resources>
\ No newline at end of file
diff --git a/src/com/android/customization/picker/CustomizationPickerActivity.java b/src/com/android/customization/picker/CustomizationPickerActivity.java
index 2eb0c93..5b19a7d 100644
--- a/src/com/android/customization/picker/CustomizationPickerActivity.java
+++ b/src/com/android/customization/picker/CustomizationPickerActivity.java
@@ -28,6 +28,7 @@
 import androidx.fragment.app.FragmentManager;
 import androidx.fragment.app.FragmentTransaction;
 
+import com.android.customization.picker.theme.ThemeFragment;
 import com.android.wallpaper.R;
 import com.android.wallpaper.model.WallpaperInfo;
 import com.android.wallpaper.module.DailyLoggingAlarmScheduler;
@@ -85,27 +86,23 @@
         FragmentManager fm = getSupportFragmentManager();
         Fragment fragment = fm.findFragmentById(R.id.fragment_container);
 
-        boolean forceCategoryRefresh = false;
         if (fragment == null) {
             // App launch specific logic: log the "app launched" event and set up daily logging.
             mUserEventLogger.logAppLaunched();
             DailyLoggingAlarmScheduler.setAlarm(getApplicationContext());
-            navigateToSection(R.id.nav_wallpaper);
-            forceCategoryRefresh = true;
+            navigateToSection(R.id.nav_theme);
         }
 
-        mDelegate.initialize(forceCategoryRefresh);
 
     }
 
     private boolean supportsCustomization() {
-        //TODO (santie): the check for sections.size() should be > 1: if we only have wallpaper we
-        // should default to the Wallpaper only UI
         return mDelegate.getFormFactor() == FormFactorChecker.FORM_FACTOR_MOBILE
-                && mSections.size() > 0;
+                && mSections.size() > 1;
     }
 
     private void initSections() {
+        mSections.put(R.id.nav_theme, new ThemeSection(R.id.nav_theme));
         mSections.put(R.id.nav_wallpaper, new WallpaperSection(R.id.nav_wallpaper));
         //TODO (santie): add other sections if supported by the device
     }
@@ -121,7 +118,9 @@
         }
 
         mBottomNav.setOnNavigationItemSelectedListener(item -> {
-            switchFragment(item.getItemId());
+            CustomizationSection section = mSections.get(item.getItemId());
+            switchFragment(section);
+            section.onVisible();
             return true;
         });
     }
@@ -130,10 +129,10 @@
         mBottomNav.setSelectedItemId(id);
     }
 
-    private void switchFragment(int id) {
+    private void switchFragment(CustomizationSection section) {
         final FragmentManager fragmentManager = getSupportFragmentManager();
 
-        Fragment fragment = mSections.get(id).getFragment();
+        Fragment fragment = section.getFragment();
 
         final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
         fragmentTransaction.replace(R.id.fragment_container, fragment);
@@ -201,12 +200,14 @@
          */
         abstract Fragment getFragment();
 
+        void onVisible() {}
     }
 
     /**
      * {@link CustomizationSection} corresponding to the "Wallpaper" section of the Picker.
      */
     private class WallpaperSection extends CustomizationSection {
+        private boolean mForceCategoryRefresh;
 
         private WallpaperSection(int id) {
             super(id);
@@ -215,9 +216,28 @@
         @Override
         Fragment getFragment() {
             if (mWallpaperCategoryFragment == null) {
-                mWallpaperCategoryFragment = new CategoryFragment();
+                mWallpaperCategoryFragment = CategoryFragment.newInstance(
+                        getString(R.string.wallpaper_title));
+                mForceCategoryRefresh = true;
             }
             return mWallpaperCategoryFragment;
         }
+
+        @Override
+        void onVisible() {
+            mDelegate.initialize(mForceCategoryRefresh);
+        }
+    }
+
+    private class ThemeSection extends CustomizationSection {
+
+        private ThemeSection(int id) {
+            super(id);
+        }
+
+        @Override
+        Fragment getFragment() {
+            return ThemeFragment.newInstance(getString(R.string.theme_title));
+        }
     }
 }
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
new file mode 100644
index 0000000..ec04b17
--- /dev/null
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.customization.picker.theme;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.wallpaper.R;
+import com.android.wallpaper.picker.ToolbarFragment;
+
+/**
+ * Fragment that contains the main UI for selecting and applying a Theme.
+ */
+public class ThemeFragment extends ToolbarFragment {
+
+    public static ThemeFragment newInstance(CharSequence title) {
+        ThemeFragment fragment = new ThemeFragment();
+        fragment.setArguments(ToolbarFragment.createArguments(title));
+        return fragment;
+    }
+
+
+    @Nullable
+    @Override
+    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
+            @Nullable Bundle savedInstanceState) {
+        View view = inflater.inflate(
+                R.layout.fragment_theme_picker, container, /* attachToRoot */ false);
+        setUpToolbar(view);
+
+        return view;
+    }
+}