Minor cleanups.

Address/remove unnecessary TODOs.
Rename demo apps.
Minor docs fixups.

Bug: 72230246
Test: Passing
Change-Id: I87b11c90275d4825c6236776f418245d95e5c476
diff --git a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/BandSelectionHelper.java b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/BandSelectionHelper.java
index 385eb72..16cab29 100644
--- a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/BandSelectionHelper.java
+++ b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/BandSelectionHelper.java
@@ -62,7 +62,6 @@
     private final BandHost mHost;
     private final ItemKeyProvider<K> mKeyProvider;
     private final SelectionTracker<K> mSelectionTracker;
-    private final SelectionPredicate<K> mSelectionPredicate;
     private final BandPredicate mBandPredicate;
     private final FocusDelegate<K> mFocusDelegate;
     private final OperationMonitor mLock;
@@ -81,7 +80,6 @@
             @NonNull AutoScroller scroller,
             @NonNull ItemKeyProvider<K> keyProvider,
             @NonNull SelectionTracker<K> selectionTracker,
-            @NonNull SelectionPredicate<K> selectionPredicate,
             @NonNull BandPredicate bandPredicate,
             @NonNull FocusDelegate<K> focusDelegate,
             @NonNull OperationMonitor lock) {
@@ -90,7 +88,6 @@
         checkArgument(scroller != null);
         checkArgument(keyProvider != null);
         checkArgument(selectionTracker != null);
-        checkArgument(selectionPredicate != null);
         checkArgument(bandPredicate != null);
         checkArgument(focusDelegate != null);
         checkArgument(lock != null);
@@ -98,7 +95,6 @@
         mHost = host;
         mKeyProvider = keyProvider;
         mSelectionTracker = selectionTracker;
-        mSelectionPredicate = selectionPredicate;
         mBandPredicate = bandPredicate;
         mFocusDelegate = focusDelegate;
         mLock = lock;
@@ -142,7 +138,6 @@
                 scroller,
                 keyProvider,
                 selectionTracker,
-                selectionPredicate,
                 bandPredicate,
                 focusDelegate,
                 lock);
diff --git a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/DefaultSelectionTracker.java b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/DefaultSelectionTracker.java
index c188507..d58f1c8 100644
--- a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/DefaultSelectionTracker.java
+++ b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/DefaultSelectionTracker.java
@@ -242,8 +242,10 @@
 
     @Override
     public void startRange(int position) {
-        select(mKeyProvider.getKey(position));
-        anchorRange(position);
+        if (mSelection.contains(mKeyProvider.getKey(position))
+                || select(mKeyProvider.getKey(position))) {
+            anchorRange(position);
+        }
     }
 
     @Override
diff --git a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/EventBridge.java b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/EventBridge.java
index 256e618..9b57de0 100644
--- a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/EventBridge.java
+++ b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/EventBridge.java
@@ -83,11 +83,8 @@
 
         @Override
         public void onItemRangeChanged(int startPosition, int itemCount, @Nullable Object payload) {
-            // No change in position. Ignore, since we assume
-            // selection is a user driven activity. So changes
-            // in properties of items shouldn't result in a
-            // change of selection.
-            // TODO: It is possible properties of items chould change to make them unselectable.
+            // No change in position. Ignore.
+            // TODO(b/72393576): Properties of items could change. Should reevaluate selected status
         }
 
         @Override
diff --git a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/ItemDetailsLookup.java b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/ItemDetailsLookup.java
index d6e6e8f..fa20c25 100644
--- a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/ItemDetailsLookup.java
+++ b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/ItemDetailsLookup.java
@@ -93,7 +93,6 @@
      *
      * @param <K> Selection key type. @see {@link StorageStrategy} for supported types.
      */
-    // TODO: Can this be merged with ViewHolder?
     public abstract static class ItemDetails<K> {
 
         /** @return the position of an item. */
diff --git a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/MotionEvents.java b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/MotionEvents.java
index 0de3704..0e50341 100644
--- a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/MotionEvents.java
+++ b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/MotionEvents.java
@@ -77,7 +77,7 @@
         return isButtonPressed(e, MotionEvent.BUTTON_TERTIARY);
     }
 
-    // TODO: Replace with MotionEvent.isButtonPressed once targeting 21 or higher.
+    // NOTE: Can replace this with MotionEvent.isButtonPressed once targeting 21 or higher.
     private static boolean isButtonPressed(MotionEvent e, int button) {
         if (button == 0) {
             return false;
diff --git a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/OperationMonitor.java b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/OperationMonitor.java
index 496c0db..46b97e3 100644
--- a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/OperationMonitor.java
+++ b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/OperationMonitor.java
@@ -36,10 +36,10 @@
  * <p>
  * The host {@link android.app.Activity} or {@link android.app.Fragment} should avoid changing
  * {@link android.support.v7.widget.RecyclerView.Adapter Adapter} data while there
- * are active selection operations as this can result in a poor user experience.
+ * are active selection operations, as this can result in a poor user experience.
  *
  * <p>
- * To known when an operation is active listen to changes using an {@link OnChangeListener}.
+ * To know when an operation is active listen to changes using an {@link OnChangeListener}.
  */
 public final class OperationMonitor {
 
diff --git a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/SelectionTracker.java b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/SelectionTracker.java
index df793a1..5465840 100644
--- a/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/SelectionTracker.java
+++ b/recyclerview-selection/src/main/java/androidx/widget/recyclerview/selection/SelectionTracker.java
@@ -189,9 +189,12 @@
     abstract void onDataSetChanged();
 
     /**
-     * Specifies the "anchor" item position denoting the beginning of a range.
+     * Attempts to establish a range selection at {@code position}, selecting the item
+     * at {@code position} if needed.
      *
-     * @param position The anchor position for the selection range.
+     * @param position The "anchor" position for the range. Subsequent range operations
+     *                 (primarily keyboard and mouse based operations like SHIFT + click)
+     *                 work with the established anchor point to define selection ranges.
      */
     abstract void startRange(int position);
 
@@ -245,7 +248,9 @@
      */
     abstract void setProvisionalSelection(@NonNull Set<K> newSelection);
 
-    /** Clears any existing provisional selection */
+    /**
+     * Clears any existing provisional selection
+     */
     abstract void clearProvisionalSelection();
 
     /**
@@ -780,8 +785,6 @@
 
             // Band selection not supported in single select mode, or when key access
             // is limited to anything less than the entire corpus.
-            // TODO: Since we cach grid info from laid out items, we could cache key too.
-            // Then we couldn't have to limit to CORPUS access.
             if (mKeyProvider.hasAccess(ItemKeyProvider.SCOPE_MAPPED)
                     && mSelectionPredicate.canSelectMultiple()) {
                 // BandSelectionHelper provides support for band selection on-top of a RecyclerView
diff --git a/recyclerview-selection/tests/java/androidx/widget/recyclerview/selection/BandSelectionHelperTest.java b/recyclerview-selection/tests/java/androidx/widget/recyclerview/selection/BandSelectionHelperTest.java
index 64c47ec..1c999c5 100644
--- a/recyclerview-selection/tests/java/androidx/widget/recyclerview/selection/BandSelectionHelperTest.java
+++ b/recyclerview-selection/tests/java/androidx/widget/recyclerview/selection/BandSelectionHelperTest.java
@@ -32,7 +32,6 @@
 import java.util.Collections;
 import java.util.List;
 
-import androidx.widget.recyclerview.selection.SelectionTracker.SelectionPredicate;
 import androidx.widget.recyclerview.selection.testing.TestAdapter;
 import androidx.widget.recyclerview.selection.testing.TestAutoScroller;
 import androidx.widget.recyclerview.selection.testing.TestBandPredicate;
@@ -66,12 +65,11 @@
         ItemKeyProvider<String> keyProvider =
                 new TestItemKeyProvider<>(ItemKeyProvider.SCOPE_MAPPED, mAdapter);
         OperationMonitor operationMonitor = new OperationMonitor();
-        SelectionPredicate<String> selectionTest = SelectionPredicates.createSelectAnything();
 
         SelectionTracker<String> helper = new DefaultSelectionTracker<String>(
                 "band-selection-test",
                 keyProvider,
-                selectionTest,
+                SelectionPredicates.createSelectAnything(),
                 StorageStrategy.createStringStorage());
 
         EventBridge.install(mAdapter, helper, keyProvider);
@@ -82,7 +80,6 @@
                 new TestAutoScroller(),
                 keyProvider,
                 helper,
-                selectionTest,
                 mBandPredicate,
                 focusDelegate,
                 operationMonitor) {
diff --git a/samples/Support7Demos/src/main/res/values/strings.xml b/samples/Support7Demos/src/main/res/values/strings.xml
index 2c4b0b6..8f6f37c 100644
--- a/samples/Support7Demos/src/main/res/values/strings.xml
+++ b/samples/Support7Demos/src/main/res/values/strings.xml
@@ -236,8 +236,8 @@
     <string name="appcompat_vector_disabled">AnimatedVectorDrawableCompat does not work on devices running API v10 or below</string>
     <string name="appcompat_vector_title">AppCompat/Integrations/AnimatedVectorDrawable</string>
 
-    <string name="simple_selection_demo_activity">RecyclerView Selection</string>
-    <string name="fancy_selection_demo_activity">RecyclerView: Gesture+Pointer Selection</string>
+    <string name="simple_selection_demo_activity">RecyclerView Selection: Gesture Only</string>
+    <string name="fancy_selection_demo_activity">RecyclerView Selection: Gesture and Pointer</string>
 
     <string name="night_mode">DAY</string>