Skip to content

Predictive Back Refactor #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samples/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Available Samples

- [](user-interface/predictiveback/src/main/java/com/example/platform/ui/predictiveback/PBHostingActivity.kt):

- [App Widgets](user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/AppWidgets.kt):
Showcases how to pin widget within the app. Check the launcher widget menu for all the app widgets samples
- [Call Notification Sample](connectivity/callnotification/src/main/java/com/example/platform/connectivity/callnotification/CallNotificationSample.kt):
Expand Down Expand Up @@ -82,6 +80,8 @@ Select images/videos in a privacy-friendly way using the photo picker
Basic usage of Picture-in-Picture mode showcasing a stopwatch
- [Picture in Picture (PiP) - Video playback](user-interface/picture-in-picture/src/main/java/com/example/android/pip/PiPMovieActivity.kt):
Basic usage of Picture-in-Picture mode showcasing video playback
- [Predictive Back](user-interface/predictiveback/src/main/java/com/example/platform/ui/predictiveback/PBHostingActivity.kt):
See Predictive Back animations.
- [Quick Settings](user-interface/quicksettings/src/main/java/com/example/platform/ui/quicksettings/QuickSettings.kt):
Add your custom tile to the Quick Settings.
- [Receive data shared by other apps](user-interface/share/src/main/java/com/example/platform/ui/share/receiver/ShareReceiverActivity.kt):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@

package com.example.platform.ui.predictiveback

data class PBAnimation(val title: String, val description: String)
enum class PBAnimation {
SYS_UI, BACK_TO_HOME, CROSS_ACTIVITY, CROSS_FRAGMENT
}
data class PBAnimationText(val title: String, val description: String)

val animations = listOf(
PBAnimation(
val animations = mapOf<PBAnimation, PBAnimationText>(
PBAnimation.SYS_UI to PBAnimationText(
"Enable System Animations",
"The system animations are back-to-home and default cross-activity. To see them: (1) Enable gesture navigation. (2) In Android 14, enable the Predictive Back Developer Option."
),
PBAnimation(
PBAnimation.BACK_TO_HOME to PBAnimationText(
"Back-to-Home",
"To see the back-to-home animation, go to the root activity and swipe back from either the left or right edge to exit the app."
),
PBAnimation(
PBAnimation.CROSS_ACTIVITY to PBAnimationText(
"Default Cross-Activity",
"To see the default cross-activity animation, on this screen swipe back from either the left or right edge."
),
PBAnimation(
PBAnimation.CROSS_FRAGMENT to PBAnimationText(
"Cross-Fragment",
"Animation example coming soon."
)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.platform.ui.predictiveback.databinding.FragmentAnimationListBinding

class PBListFragment : Fragment() {
Expand All @@ -36,10 +35,8 @@ class PBListFragment : Fragment() {
savedInstanceState: Bundle?,
): View {
_binding = FragmentAnimationListBinding.inflate(inflater, container, false)
binding.pbRecyclerView.layoutManager = LinearLayoutManager(context)

val adapter = PBListAdapter(animations)
binding.pbRecyclerView.adapter = adapter
setAnimationText()

return binding.root
}
Expand All @@ -48,4 +45,15 @@ class PBListFragment : Fragment() {
super.onDestroyView()
_binding = null
}

private fun setAnimationText() {
binding.sysUiTitle.text = animations[PBAnimation.SYS_UI]?.title ?: ""
binding.sysUiDescription.text = animations[PBAnimation.SYS_UI]?.description ?: ""
binding.backToHomeTitle.text = animations[PBAnimation.BACK_TO_HOME]?.title ?: ""
binding.backToHomeDescription.text = animations[PBAnimation.BACK_TO_HOME]?.description ?: ""
binding.crossActivityTitle.text = animations[PBAnimation.CROSS_ACTIVITY]?.title ?: ""
binding.crossActivityDescription.text = animations[PBAnimation.CROSS_ACTIVITY]?.description ?: ""
binding.crossFragmentTitle.text = animations[PBAnimation.CROSS_FRAGMENT]?.title ?: ""
binding.crossFragmentDescription.text = animations[PBAnimation.CROSS_FRAGMENT]?.description ?: ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,159 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<LinearLayout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">

<TextView
android:id="@+id/textView"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_margin="16dp"
android:gravity="center"
android:text="@string/predictive_back_sample_first_activity_header"
android:textSize="24sp"
android:textAppearance="?attr/textAppearanceTitleMedium" />

<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/pb_recycler_view" />
android:orientation="vertical">

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_margin="16dp"
android:gravity="center"
android:text="@string/predictive_back_sample_first_activity_header"
android:textSize="24sp"
android:textAppearance="?attr/textAppearanceTitleMedium" />

<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/sys_ui_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textSize="16sp"/>

<TextView
android:id="@+id/sys_ui_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" />

</LinearLayout>

</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/back_to_home_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textSize="16sp"/>

<TextView
android:id="@+id/back_to_home_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" />

</LinearLayout>

</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/cross_activity_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textSize="16sp"/>

<TextView
android:id="@+id/cross_activity_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" />

</LinearLayout>

</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:id="@+id/cross_fragment_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textSize="16sp"/>

<TextView
android:id="@+id/cross_fragment_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?android:attr/textColorSecondary"
android:textSize="12sp" />

</LinearLayout>

</com.google.android.material.card.MaterialCardView>

</LinearLayout>

</LinearLayout>
</ScrollView>