Deprecate getTabLayout()

We don't want to expose a view subclass to prevent
apps from changing it's appearance. It will also
be helpful when switching to shared libraries.

Test: Manually
Bug: 170496778
Change-Id: I6170d1f58f71a47938d908cee6c29f3211b410b9
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
index b069fb0..ba51cd3 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/Toolbar.java
@@ -268,13 +268,32 @@
 
     /**
      * Gets the {@link TabLayout} for this toolbar.
+     * @deprecated Use other tab-related functions in the ToolbarController interface.
      */
+    @Deprecated
     @Override
     public TabLayout getTabLayout() {
         return mController.getTabLayout();
     }
 
     /**
+     * Gets the number of tabs in the toolbar. The tabs can be retrieved using
+     * {@link #getTab(int)}.
+     */
+    @Override
+    public int getTabCount() {
+        return mController.getTabCount();
+    }
+
+    /**
+     * Gets the index of the tab.
+     */
+    @Override
+    public int getTabPosition(TabLayout.Tab tab) {
+        return mController.getTabPosition(tab);
+    }
+
+    /**
      * Adds a tab to this toolbar. You can listen for when it is selected via
      * {@link #registerOnTabSelectedListener(OnTabSelectedListener)}.
      */
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
index 4eb009d..d3e3910 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarController.java
@@ -77,10 +77,23 @@
 
     /**
      * Gets the {@link TabLayout} for this toolbar.
+     * @deprecated Use other tab-related functions in this interface.
      */
+    @Deprecated
     TabLayout getTabLayout();
 
     /**
+     * Gets the number of tabs in the toolbar. The tabs can be retrieved using
+     * {@link #getTab(int)}.
+     */
+    int getTabCount();
+
+    /**
+     * Gets the index of the tab.
+     */
+    int getTabPosition(TabLayout.Tab tab);
+
+    /**
      * Adds a tab to this toolbar. You can listen for when it is selected via
      * {@link #registerOnTabSelectedListener(Toolbar.OnTabSelectedListener)}.
      */
diff --git a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
index 413beaa..24c94a5 100644
--- a/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
+++ b/car-ui-lib/car-ui-lib/src/main/java/com/android/car/ui/toolbar/ToolbarControllerImpl.java
@@ -266,13 +266,32 @@
 
     /**
      * Gets the {@link TabLayout} for this toolbar.
+     * @deprecated Use other tab-related functions in the ToolbarController interface.
      */
+    @Deprecated
     @Override
     public TabLayout getTabLayout() {
         return mTabLayout;
     }
 
     /**
+     * Gets the number of tabs in the toolbar. The tabs can be retrieved using
+     * {@link #getTab(int)}.
+     */
+    @Override
+    public int getTabCount() {
+        return mTabLayout.getTabCount();
+    }
+
+    /**
+     * Gets the index of the tab.
+     */
+    @Override
+    public int getTabPosition(TabLayout.Tab tab) {
+        return mTabLayout.getTabPosition(tab);
+    }
+
+    /**
      * Adds a tab to this toolbar. You can listen for when it is selected via
      * {@link #registerOnTabSelectedListener(Toolbar.OnTabSelectedListener)}.
      */