Make the RecyclerView in fragments rotary scrollable

Bug: 174703040
Test: manual
Change-Id: I03adf08f2ad27ce9bc5b1024ac69581e52fdad77
Merged-In: I03adf08f2ad27ce9bc5b1024ac69581e52fdad77
diff --git a/src/com/android/car/settings/common/SettingsFragment.java b/src/com/android/car/settings/common/SettingsFragment.java
index 949c042..a945e95 100644
--- a/src/com/android/car/settings/common/SettingsFragment.java
+++ b/src/com/android/car/settings/common/SettingsFragment.java
@@ -42,9 +42,11 @@
 
 import com.android.car.settings.R;
 import com.android.car.ui.preference.PreferenceFragment;
+import com.android.car.ui.recyclerview.CarUiRecyclerView;
 import com.android.car.ui.toolbar.MenuItem;
 import com.android.car.ui.toolbar.Toolbar;
 import com.android.car.ui.toolbar.ToolbarController;
+import com.android.car.ui.utils.CarUiUtils;
 import com.android.settingslib.search.Indexable;
 
 import java.util.ArrayList;
@@ -130,6 +132,20 @@
         return null;
     }
 
+    /**
+     * Enables rotary scrolling for the {@link CarUiRecyclerView} in this fragment.
+     * <p>
+     * Rotary scrolling should be enabled for scrolling views which contain content which the user
+     * may want to see but can't interact with, either alone or along with interactive (focusable)
+     * content.
+     */
+    protected void enableRotaryScroll() {
+        CarUiRecyclerView recyclerView = getView().findViewById(R.id.recycler_view);
+        if (recyclerView != null) {
+            CarUiUtils.setRotaryScrollEnabled(recyclerView, /* isVertical= */ true);
+        }
+    }
+
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
diff --git a/src/com/android/car/settings/location/LocationSettingsFragment.java b/src/com/android/car/settings/location/LocationSettingsFragment.java
index 0b30138..891fe33 100644
--- a/src/com/android/car/settings/location/LocationSettingsFragment.java
+++ b/src/com/android/car/settings/location/LocationSettingsFragment.java
@@ -25,7 +25,10 @@
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.provider.Settings;
+import android.view.View;
 
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 import androidx.annotation.XmlRes;
 
 import com.android.car.settings.R;
@@ -76,6 +79,12 @@
     }
 
     @Override
+    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        enableRotaryScroll();
+    }
+
+    @Override
     @XmlRes
     protected int getPreferenceScreenResId() {
         return R.xml.location_settings_fragment;
diff --git a/src/com/android/car/settings/storage/AppStorageSettingsDetailsFragment.java b/src/com/android/car/settings/storage/AppStorageSettingsDetailsFragment.java
index 6dac603..34c3f16 100644
--- a/src/com/android/car/settings/storage/AppStorageSettingsDetailsFragment.java
+++ b/src/com/android/car/settings/storage/AppStorageSettingsDetailsFragment.java
@@ -27,7 +27,10 @@
 import android.os.Message;
 import android.os.UserHandle;
 import android.os.UserManager;
+import android.view.View;
 
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 import androidx.annotation.VisibleForTesting;
 import androidx.annotation.XmlRes;
 import androidx.loader.app.LoaderManager;
@@ -216,6 +219,12 @@
     }
 
     @Override
+    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        enableRotaryScroll();
+    }
+
+    @Override
     public void onResume() {
         super.onResume();
         mAppsControlDisallowedAdmin = RestrictedLockUtilsInternal.checkIfRestrictionEnforced(
diff --git a/src/com/android/car/settings/wifi/details/WifiDetailsFragment.java b/src/com/android/car/settings/wifi/details/WifiDetailsFragment.java
index 3317109..c048818 100644
--- a/src/com/android/car/settings/wifi/details/WifiDetailsFragment.java
+++ b/src/com/android/car/settings/wifi/details/WifiDetailsFragment.java
@@ -25,8 +25,11 @@
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 import android.os.Bundle;
+import android.view.View;
 import android.widget.Toast;
 
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 import androidx.annotation.StringRes;
 import androidx.annotation.XmlRes;
 
@@ -165,6 +168,12 @@
     }
 
     @Override
+    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+        enableRotaryScroll();
+    }
+
+    @Override
     public void onStart() {
         super.onStart();
         mWifiInfoProvider.addListener(this);