### Initialize and Start TapTargetSequence Source: https://github.com/keepsafe/taptargetview/blob/master/README.md How to instantiate a TapTargetSequence, add multiple targets, and attach a listener to handle sequence lifecycle events. ```APIDOC ## TapTargetSequence.start() ### Description Initializes and executes a sequence of tap targets to guide the user through the UI. ### Method Java Method Call ### Parameters #### Path Parameters - **activity** (Context) - Required - The current activity context. #### Request Body - **targets** (List) - Required - A list of TapTarget objects to display in order. - **listener** (TapTargetSequence.Listener) - Optional - Callback interface for sequence events (onSequenceFinish, onSequenceStep, onSequenceCanceled). ### Request Example new TapTargetSequence(this) .targets( TapTarget.forView(findViewById(R.id.view1), "Title"), TapTarget.forView(findViewById(R.id.view2), "Title", "Description") ) .listener(new TapTargetSequence.Listener() { @Override public void onSequenceFinish() {} @Override public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) {} @Override public void onSequenceCanceled(TapTarget lastTarget) {} }) .start(); ### Response #### Success Response - **void** - The sequence starts displaying the first target. ``` -------------------------------- ### TapTargetSequence Source: https://context7.com/keepsafe/taptargetview/llms.txt Manages a sequence of multiple tap targets to create a guided tutorial flow. ```APIDOC ## CLASS TapTargetSequence ### Description Creates a sequence of tap targets displayed one after another. ### Methods - **targets(TapTarget...)**: Sets the list of targets to display. - **listener(Listener)**: Sets the callback listener for sequence events. - **start()**: Begins the sequence. ### Parameters #### Listener Callbacks - **onSequenceFinish()**: Called when all targets are completed. - **onSequenceStep(TapTarget, boolean)**: Called after each individual step. - **onSequenceCanceled(TapTarget)**: Called if the user cancels the sequence. ### Request Example new TapTargetSequence(context).targets(target1, target2).listener(listener).start(); ``` -------------------------------- ### Display Multiple Tap Targets in Order with TapTargetSequence Source: https://context7.com/keepsafe/taptargetview/llms.txt Creates a sequence of tap targets displayed one after another for a complete onboarding or tutorial flow. This example demonstrates building a sequence with various target types (toolbar navigation, menu item, overflow, custom bounds) and handling sequence completion, step callbacks, and cancellation. ```java Toolbar toolbar = findViewById(R.id.toolbar); toolbar.inflateMenu(R.menu.menu_main); toolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.ic_arrow_back_white_24dp)); // Create custom bounds for a drawable target Drawable droid = ContextCompat.getDrawable(this, R.drawable.ic_android_black_24dp); Rect droidTarget = new Rect(0, 0, droid.getIntrinsicWidth() * 2, droid.getIntrinsicHeight() * 2); Display display = getWindowManager().getDefaultDisplay(); droidTarget.offset(display.getWidth() / 2, display.getHeight() / 2); // Build the sequence TapTargetSequence sequence = new TapTargetSequence(this) .targets( // Step 1: Navigation icon TapTarget.forToolbarNavigationIcon(toolbar, "Back Button", "Navigate to previous screen") .id(1), // Step 2: Search menu item with custom styling TapTarget.forToolbarMenuItem(toolbar, R.id.search, "Search", "Find what you're looking for") .dimColor(android.R.color.black) .outerCircleColor(R.color.colorAccent) .targetCircleColor(android.R.color.black) .transparentTarget(true) .textColor(android.R.color.black) .id(2), // Step 3: Overflow menu TapTarget.forToolbarOverflow(toolbar, "More Options", "Additional actions here") .id(3), // Step 4: Custom bounds target TapTarget.forBounds(droidTarget, "Custom Target", "You can target any screen area!") .cancelable(false) .icon(droid) .id(4) ) .listener(new TapTargetSequence.Listener() { @Override public void onSequenceFinish() { // All targets completed Toast.makeText(MainActivity.this, "Tutorial complete!", Toast.LENGTH_SHORT).show(); ((TextView) findViewById(R.id.status)).setText("You're educated now!"); } @Override public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) { // Called after each step Log.d("TapTargetSequence", "Completed step: " + lastTarget.id() + ", clicked: " + targetClicked); } @Override public void onSequenceCanceled(TapTarget lastTarget) { // User canceled the sequence new AlertDialog.Builder(MainActivity.this) .setTitle("Tutorial Canceled") .setMessage("You canceled at step " + lastTarget.id()) .setPositiveButton("OK", null) .show(); } }); // Start the sequence sequence.start(); // Alternative: Start from a specific target ID // sequence.startWith(2); // Start from target with id(2) // Alternative: Start from a specific index // sequence.startAt(1); // Start from second target (0-indexed) ``` -------------------------------- ### Install TapTargetView via Gradle Source: https://github.com/keepsafe/taptargetview/blob/master/README.md Add the TapTargetView dependency to your Android project's build.gradle file to enable the library. ```groovy repositories { mavenCentral() } dependencies { implementation 'com.getkeepsafe.taptargetview:taptargetview:x.x.x' } ``` -------------------------------- ### Create TapTargetSequence in Java Source: https://github.com/keepsafe/taptargetview/blob/master/README.md This snippet demonstrates how to create and configure a sequence of tap targets using the TapTargetSequence class in Java. It shows how to add targets, customize their appearance, set them as non-cancelable, and attach a listener to handle sequence events like completion, step changes, and cancellation. The sequence is initiated by calling the start() method. ```java new TapTargetSequence(this) .targets( TapTarget.forView(findViewById(R.id.never), "Gonna"), TapTarget.forView(findViewById(R.id.give), "You", "Up") .dimColor(android.R.color.never) .outerCircleColor(R.color.gonna) .targetCircleColor(R.color.let) .textColor(android.R.color.you), TapTarget.forBounds(rickTarget, "Down", ":^") .cancelable(false) .icon(rick)) .listener(new TapTargetSequence.Listener() { // This listener will tell us when interesting(tm) events happen in regards // to the sequence @Override public void onSequenceFinish() { // Yay } @Override public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) { // Perform action for the current target } @Override public void onSequenceCanceled(TapTarget lastTarget) { // Boo } }); ``` -------------------------------- ### Display Single Tap Target with TapTargetView Source: https://context7.com/keepsafe/taptargetview/llms.txt Demonstrates how to use TapTargetView.showFor to display a single tap target overlay on an Activity or Dialog. It includes basic usage targeting a view and an example with an AlertDialog, along with listener implementations for handling user interactions like clicks and dismissals. ```java // Basic usage - targeting a view TapTargetView.showFor(this, // Activity context TapTarget.forView(findViewById(R.id.fab), "Hello, world!", "This is the sample app for TapTargetView") .cancelable(false) .drawShadow(true) .titleTextDimen(R.dimen.title_text_size) .tintTarget(false), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); // Dismisses the view // Handle target click - proceed to next action doSomething(); } @Override public void onOuterCircleClick(TapTargetView view) { // User clicked on the outer circle but not the target Toast.makeText(view.getContext(), "You clicked the outer circle!", Toast.LENGTH_SHORT).show(); } @Override public void onTargetDismissed(TapTargetView view, boolean userInitiated) { // Called when the tap target is dismissed Log.d("TapTarget", "Dismissed, user initiated: " + userInitiated); } @Override public void onTargetCancel(TapTargetView view) { // Called when user cancels (if cancelable is true) view.dismiss(false); } }); // Usage with a Dialog AlertDialog dialog = new AlertDialog.Builder(this) .setTitle("Dialog Title") .setMessage("Dialog message") .setPositiveButton("OK", null) .show(); TapTargetView.showFor(dialog, TapTarget.forView(dialog.getButton(DialogInterface.BUTTON_POSITIVE), "Click here!", "This button does something important") .cancelable(false) .tintTarget(false), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); dialog.dismiss(); } }); ``` -------------------------------- ### Target Toolbar Navigation Icon with TapTargetView Source: https://context7.com/keepsafe/taptargetview/llms.txt Creates a tap target for the navigation icon (back button, hamburger menu, etc.) in a Toolbar. This example demonstrates how to initialize and display a TapTarget for the toolbar's navigation icon, including custom descriptions and styling. ```java Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.ic_arrow_back_white_24dp)); SpannableString sassyDesc = new SpannableString("It allows you to go back, sometimes"); sassyDesc.setSpan(new StyleSpan(Typeface.ITALIC), sassyDesc.length() - "sometimes".length(), sassyDesc.length(), 0); TapTargetView.showFor(this, TapTarget.forToolbarNavigationIcon(toolbar, "This is the back button", sassyDesc) .outerCircleColor(R.color.colorPrimary) .targetCircleColor(R.color.white) .id(1), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); // Navigate back or open drawer } }); ``` -------------------------------- ### Configure System UI Interaction for Tap Targets Source: https://context7.com/keepsafe/taptargetview/llms.txt Controls how tap targets interact with system UI elements like the status bar and navigation bar. It allows drawing behind these bars and forcing the target to be centered. Includes an example for enabling edge-to-edge display mode. ```java TapTargetView.showFor(this, TapTarget.forView(findViewById(R.id.target), "Near Edge", "This target is near the screen edge") // Allow drawing behind status bar (default: true) .setDrawBehindStatusBar(true) // Allow drawing behind navigation bar (default: true) .setDrawBehindNavigationBar(true) // Force the target to be centered regardless of text position .setForceCenteredTarget(false), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); } }); // For edge-to-edge display mode WindowCompat.setDecorFitsSystemWindows(getWindow(), false); ``` -------------------------------- ### Target Toolbar Overflow Menu with TapTargetView Source: https://context7.com/keepsafe/taptargetview/llms.txt Creates a tap target for the overflow (three dots) button in a Toolbar. This example shows how to target the overflow menu, noting that it's experimental and might require Proguard configuration. It includes styling and a click listener to show the overflow menu. ```java Toolbar toolbar = findViewById(R.id.toolbar); toolbar.inflateMenu(R.menu.menu_main); TapTargetView.showFor(this, TapTarget.forToolbarOverflow(toolbar, "More Options", "But they're not useful :(") .outerCircleColor(R.color.colorPrimary) .targetCircleColor(R.color.white) .drawShadow(true) .id(3), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); // Show overflow menu toolbar.showOverflowMenu(); } }); ``` -------------------------------- ### Configure Gradle for Signing and Publishing Source: https://github.com/keepsafe/taptargetview/blob/master/RELEASING.md Sets up the necessary GPG signing keys and Sonatype credentials in the local gradle.properties file to enable secure artifact publishing. ```gradle signing.keyId= signing.password= signing.secretKeyRingFile=/path/to/your/secring.gpg mavenCentralUsername= mavenCentralPassword= SONATYPE_STAGING_PROFILE=com.getkeepsafe ``` -------------------------------- ### Execute Release Commands Source: https://github.com/keepsafe/taptargetview/blob/master/RELEASING.md Commands to verify the build, create signed commits and tags, and publish the library to Maven Central. ```bash ./gradlew clean check git commit -S -m "Release version X.Y.Z" git tag -s -a X.Y.Z ./gradlew :taptargetview:publishAndReleaseToMavenCentral --no-configuration-cache git push --tags origin master ``` -------------------------------- ### Create Tap Target for Standard Android Views (Java) Source: https://context7.com/keepsafe/taptargetview/llms.txt Demonstrates how to create a tap target for any standard Android View using TapTarget.forView. It covers extensive customization options for the target's appearance, text styling, behavior, and custom icons. Dependencies include Android View references and resource IDs for colors and drawables. ```java TapTarget.forView(findViewById(R.id.fab), "This is a target", "We have the best targets, believe me") // Circle appearance .outerCircleColor(R.color.colorPrimary) // Outer circle color (resource) .outerCircleAlpha(0.96f) // Outer circle transparency [0.0-1.0] .targetCircleColor(R.color.white) // Inner target circle color // Text styling .titleTextSize(20) // Title text size in SP .titleTextColor(R.color.white) // Title text color .descriptionTextSize(14) // Description text size in SP .descriptionTextColor(R.color.lightGray) // Description text color .textColor(R.color.white) // Set both title and description color .textTypeface(Typeface.SANS_SERIF) // Typeface for all text .titleTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL)) .descriptionTypeface(Typeface.SANS_SERIF) .descriptionTextAlpha(0.54f) // Description text transparency // Target behavior .dimColor(R.color.black) // Dim background with 30% opacity .drawShadow(true) // Draw drop shadow around circle .cancelable(false) // Disable tap-outside-to-dismiss .tintTarget(true) // Tint target view with outer circle color .transparentTarget(false) // Make target circle transparent .targetRadius(60) // Target radius in DP // Custom icon .icon(ContextCompat.getDrawable(this, R.drawable.ic_custom)); // Using SpannableString for styled text SpannableString styledDesc = new SpannableString("It allows you to go back, sometimes"); styledDesc.setSpan(new StyleSpan(Typeface.ITALIC), styledDesc.length() - "sometimes".length(), styledDesc.length(), 0); TapTargetView.showFor(this, TapTarget.forView(findViewById(R.id.button), "Styled Description", styledDesc) .cancelable(true)); ``` -------------------------------- ### Create Tap Target for Custom Screen Areas (Java) Source: https://context7.com/keepsafe/taptargetview/llms.txt Illustrates how to define a tap target for a custom rectangular area on the screen using TapTarget.forBounds. This is useful for highlighting arbitrary positions or areas without associated Views. It requires defining Rect bounds, optionally loading a Drawable for the icon, and setting customization properties. ```java // Load a drawable to use as the target icon Drawable droid = ContextCompat.getDrawable(this, R.drawable.ic_android_black_24dp); // Define custom bounds for the tap target Rect customTarget = new Rect(0, 0, droid.getIntrinsicWidth() * 2, droid.getIntrinsicHeight() * 2); // Position the target at center of screen Display display = getWindowManager().getDefaultDisplay(); customTarget.offset(display.getWidth() / 2, display.getHeight() / 2); TapTargetView.showFor(this, TapTarget.forBounds(customTarget, "Oh look!", "You can point to any part of the screen") .cancelable(false) .icon(droid) .targetRadius(50) .outerCircleColor(R.color.colorAccent) .drawShadow(true), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); // Proceed after user acknowledges } }); ``` -------------------------------- ### Control TapTargetView Dismissal and Visibility Source: https://context7.com/keepsafe/taptargetview/llms.txt Demonstrates programmatic control over TapTargetView visibility and dismissal. It shows how to store a reference to the view, handle click events without automatic dismissal, and manually dismiss the target with different animations. Also includes enabling debug drawing. ```java // Store reference to control later TapTargetView tapTargetView = TapTargetView.showFor(this, TapTarget.forView(findViewById(R.id.target), "Title", "Description") .cancelable(true), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { // Don't call super to prevent automatic dismissal // Handle click without dismissing processClick(); } @Override public void onTargetDismissed(TapTargetView view, boolean userInitiated) { // Cleanup after dismissal if (userInitiated) { Log.d("TapTarget", "User dismissed the target"); } else { Log.d("TapTarget", "Programmatically dismissed"); } } }); // Check visibility if (tapTargetView.isVisible()) { // Dismiss with "target tapped" animation tapTargetView.dismiss(true); // Or dismiss with "canceled" animation // tapTargetView.dismiss(false); } // Enable debug wireframe drawing tapTargetView.setDrawDebug(true); ``` -------------------------------- ### TapTargetSequence Configuration Source: https://context7.com/keepsafe/taptargetview/llms.txt Configures and manages multi-step feature discovery sequences with custom listener callbacks. ```APIDOC ## TapTargetSequence Configuration ### Description Defines a sequence of multiple TapTargets to guide users through a workflow. Supports cancellation handling and step tracking. ### Method N/A (Builder Pattern) ### Parameters #### Request Body - **targets** (List) - Required - List of targets to display in order. - **continueOnCancel** (boolean) - Optional - If true, proceeds to next target even if user cancels current one. - **considerOuterCircleCanceled** (boolean) - Optional - If true, treats outer circle clicks as cancellation. ### Response - **onSequenceFinish** - Triggered when all steps are completed. - **onSequenceStep** - Triggered on each step transition. - **onSequenceCanceled** - Triggered if the sequence is aborted. ``` -------------------------------- ### Display a TapTargetView Source: https://github.com/keepsafe/taptargetview/blob/master/README.md Initialize and show a TapTargetView for a specific UI element in an Activity. This snippet demonstrates how to configure visual properties and attach a listener for user interactions. ```java TapTargetView.showFor(this, TapTarget.forView(findViewById(R.id.target), "This is a target", "We have the best targets, believe me") .outerCircleColor(R.color.red) .outerCircleAlpha(0.96f) .targetCircleColor(R.color.white) .titleTextSize(20) .titleTextColor(R.color.white) .descriptionTextSize(10) .descriptionTextColor(R.color.red) .textColor(R.color.blue) .textTypeface(Typeface.SANS_SERIF) .dimColor(R.color.black) .drawShadow(true) .cancelable(false) .tintTarget(true) .transparentTarget(false) .targetRadius(60), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); doSomething(); } }); ``` -------------------------------- ### System UI Configuration Source: https://context7.com/keepsafe/taptargetview/llms.txt Configures how tap targets interact with system UI elements like status bars and navigation bars. ```APIDOC ## System UI Configuration ### Description Adjusts drawing behavior for targets near screen edges and system bars. ### Parameters #### Request Body - **setDrawBehindStatusBar** (boolean) - Optional - Allow drawing behind the status bar. - **setDrawBehindNavigationBar** (boolean) - Optional - Allow drawing behind the navigation bar. - **setForceCenteredTarget** (boolean) - Optional - Forces the target to be centered regardless of text position. ``` -------------------------------- ### Configure Git for Signed Commits Source: https://github.com/keepsafe/taptargetview/blob/master/RELEASING.md Configures the local repository to use a specific GPG key for signing commits and tags, ensuring authenticity of the release. ```bash git config user.email "your@email.com" git config user.signingKey "your-key-id" ``` -------------------------------- ### Displaying a TapTarget Source: https://github.com/keepsafe/taptargetview/blob/master/README.md Shows how to initialize and display a feature discovery target on an Android Activity. ```APIDOC ## TapTargetView.showFor ### Description Displays a material design feature discovery target on a specific view within an Activity. ### Method Static Method ### Parameters #### Arguments - **activity** (Activity) - Required - The current activity context. - **tapTarget** (TapTarget) - Required - The configuration object defining the target view, title, and description. - **listener** (TapTargetView.Listener) - Optional - Callback for handling clicks, long clicks, or dismissals. ### Request Example TapTargetView.showFor(this, TapTarget.forView(findViewById(R.id.target), "Title", "Description"), listener); ### Response #### Success Response - **view** (TapTargetView) - Returns the instance of the displayed view. ``` -------------------------------- ### Create Tap Target for Toolbar Menu Items (Java) Source: https://context7.com/keepsafe/taptargetview/llms.txt Shows how to create a tap target specifically for a menu item within an Android Toolbar using TapTarget.forToolbarMenuItem. This method automatically finds the menu item by its resource ID and allows for customization of its appearance and behavior. It requires a Toolbar reference, menu item ID, and text content. ```java Toolbar toolbar = findViewById(R.id.toolbar); toolbar.inflateMenu(R.menu.menu_main); TapTargetView.showFor(this, TapTarget.forToolbarMenuItem(toolbar, R.id.search, "Search Feature", "As you can see, it has gotten pretty dark around here...") .dimColor(android.R.color.black) .outerCircleColor(R.color.colorAccent) .targetCircleColor(android.R.color.black) .transparentTarget(true) .textColor(android.R.color.black) .id(2), new TapTargetView.Listener() { @Override public void onTargetClick(TapTargetView view) { super.onTargetClick(view); // Open search functionality toolbar.getMenu().performIdentifierAction(R.id.search, 0); } }); ``` -------------------------------- ### Configure TapTargetSequence Behavior Source: https://context7.com/keepsafe/taptargetview/llms.txt Configures a TapTargetSequence to control cancellation behavior and outer circle taps. It allows continuing to the next target even if the current one is canceled and treats outer circle clicks as cancellation. Includes listeners for sequence completion, step progression, and cancellation. ```java TapTargetSequence sequence = new TapTargetSequence(this) .targets( TapTarget.forView(findViewById(R.id.button1), "First", "Step one").id(1), TapTarget.forView(findViewById(R.id.button2), "Second", "Step two").id(2), TapTarget.forView(findViewById(R.id.button3), "Third", "Step three").id(3) ) // Continue to next target even if user cancels current one .continueOnCancel(true) // Treat outer circle clicks as cancellation .considerOuterCircleCanceled(true) .listener(new TapTargetSequence.Listener() { @Override public void onSequenceFinish() { Log.d("Sequence", "Completed!"); } @Override public void onSequenceStep(TapTarget lastTarget, boolean targetClicked) { // targetClicked will be false if user canceled but continueOnCancel is true if (!targetClicked) { Log.d("Sequence", "User skipped step " + lastTarget.id()); } } @Override public void onSequenceCanceled(TapTarget lastTarget) { // Only called if continueOnCancel is false Log.d("Sequence", "Canceled at step " + lastTarget.id()); } }); // Programmatically cancel the sequence // boolean wasCanceled = sequence.cancel(); sequence.start(); ``` -------------------------------- ### TapTarget.forToolbarOverflow Source: https://context7.com/keepsafe/taptargetview/llms.txt Creates a tap target for the overflow menu (three dots) button in a Toolbar. ```APIDOC ## METHOD TapTarget.forToolbarOverflow ### Description Creates a tap target for the overflow menu button. Note: This is an experimental feature. ### Method Static Factory Method ### Parameters #### Arguments - **toolbar** (Toolbar) - Required - The Toolbar instance. - **title** (String) - Required - The main title text. - **description** (String) - Optional - The descriptive text. ### Request Example TapTarget.forToolbarOverflow(toolbar, "More Options", "Additional actions") ### Response - **TapTarget** (Object) - Returns a configured TapTarget instance. ``` -------------------------------- ### TapTarget.forToolbarNavigationIcon Source: https://context7.com/keepsafe/taptargetview/llms.txt Creates a tap target specifically for the navigation icon (back button or hamburger menu) within a Toolbar. ```APIDOC ## METHOD TapTarget.forToolbarNavigationIcon ### Description Creates a tap target for the navigation icon in a Toolbar. ### Method Static Factory Method ### Parameters #### Arguments - **toolbar** (Toolbar) - Required - The Toolbar instance containing the icon. - **title** (String) - Required - The main title text for the target. - **description** (CharSequence) - Optional - The descriptive text for the target. ### Request Example TapTarget.forToolbarNavigationIcon(toolbar, "Title", "Description") ### Response - **TapTarget** (Object) - Returns a configured TapTarget instance. ``` -------------------------------- ### TapTargetView Visibility and Dismissal Source: https://context7.com/keepsafe/taptargetview/llms.txt Controls the lifecycle of a single TapTargetView, including programmatic dismissal and visibility checks. ```APIDOC ## TapTargetView Dismissal ### Description Allows programmatic control over the visibility and dismissal of a displayed tap target. ### Method N/A ### Parameters #### Request Body - **cancelable** (boolean) - Optional - Whether the target can be dismissed by the user. ### Response - **onTargetDismissed** - Callback providing the view instance and a boolean indicating if the dismissal was user-initiated. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.