Skip to content
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

chore(deps): content-provider 1.2.30 #150

Merged
merged 3 commits into from
Mar 11, 2025
Merged

Conversation

jo-elimu
Copy link
Member

@jo-elimu jo-elimu commented Mar 10, 2025

Summary by CodeRabbit

  • Chores

    • Upgraded the content provider dependency to its latest version.
  • New Features

    • Introduced a new Kotlin-based storybook activity that enhances chapter viewing with refined transitions.
    • Added functionality to prevent double-click events on views with a new abstract listener.
  • Refactor

    • Improved click event handling for better responsiveness and null safety by updating listener implementations.
    • Updated method calls to access the content provider using an instance context instead of static calls.

@jo-elimu jo-elimu self-assigned this Mar 10, 2025
@jo-elimu jo-elimu requested a review from a team as a code owner March 10, 2025 12:23
Copy link

coderabbitai bot commented Mar 10, 2025

Walkthrough

This pull request updates the dependency version for the content-provider library, modifies the click listener’s method signature to accept a nullable view, removes the legacy Java implementation of the StoryBookActivity, and introduces a new Kotlin version. Additionally, it replaces the Java SingleClickListener with a new Kotlin abstract class that implements double-click prevention. These changes involve dependency management, type safety, and code migration from Java to Kotlin for both activity and click handling components.

Changes

File(s) Change Summary
app/build.gradle Updated the dependency for content-provider from version 1.2.28 to 1.2.30.
.../ui/StoryBooksActivity.kt Modified onSingleClick method signature: parameter type changed from View to View?.
.../ui/storybook/StoryBookActivity.{java, kt} Removed the Java version of StoryBookActivity and added a Kotlin implementation featuring intent data extraction, chapter retrieval, and a view pager setup.
.../util/SingleClickListener.{java, kt} Removed the Java SingleClickListener and introduced a new Kotlin abstract class that implements double-click prevention using a defined interval.
.../ui/storybook/WordDialogFragment.java Updated method calls to ContentProviderUtil from static to instance context using INSTANCE.
.../ui/storybook/WordViewAdapter.java Modified method call to getAllEmojiGsons from static to instance context using INSTANCE.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant A as StoryBookActivity
    participant CP as ContentProviderUtil
    participant VP as ViewPager/ChapterPagerAdapter

    U->>A: Launch activity with intent data
    A->>CP: Request storybook chapter data
    CP-->>A: Return chapter list
    A->>VP: Initialize chapter adapter with data and settings
    VP-->>A: Adapter setup complete
    A->>A: Apply ZoomOutPageTransformer for visual effects
Loading
sequenceDiagram
    participant V as View
    participant L as SingleClickListener
    participant SC as SystemClock

    V->>L: onClick event received
    L->>SC: Get elapsedRealtime()
    SC-->>L: Return current time
    L-->>L: Check if click is within DOUBLE_CLICK_INTERVAL
    alt Valid click interval
        L->>L: Invoke onSingleClick()
    else
        L->>L: Ignore click event
    end
Loading

Possibly related PRs

Suggested reviewers

  • jo-elimu: Suggested reviewer for the changes made in this pull request.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 988438d and 0d717d3.

📒 Files selected for processing (2)
  • app/src/main/java/ai/elimu/vitabu/ui/storybook/WordDialogFragment.java (1 hunks)
  • app/src/main/java/ai/elimu/vitabu/ui/storybook/WordViewAdapter.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: build (windows-latest, 17)
🔇 Additional comments (3)
app/src/main/java/ai/elimu/vitabu/ui/storybook/WordViewAdapter.java (1)

143-144: Properly updated method call to match new ContentProviderUtil API requirements

The change from a static method call to using ContentProviderUtil.INSTANCE aligns with the content-provider library upgrade to version 1.2.30. This is the correct approach when methods have been changed from static to instance methods in the dependency.

app/src/main/java/ai/elimu/vitabu/ui/storybook/WordDialogFragment.java (2)

55-55: Updated getWordGson call correctly to use ContentProviderUtil.INSTANCE

This change properly addresses the build error mentioned in the PR comments about "non-static method cannot be referenced from a static context". The method now uses the singleton instance pattern required by the updated content-provider library.


62-62: Properly updated getAllEmojiGsons method call to use instance

This change is consistent with the other modifications in the codebase, ensuring that the getAllEmojiGsons method is now called on the ContentProviderUtil.INSTANCE object rather than statically.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jo-elimu
Copy link
Member Author

jo-elimu commented Mar 10, 2025

@tuancoltech I'm getting build errors with the latest version of the Content Provider library. Do you have any ideas how we should solve this?

non-static method getAllEmojiGsons(long,Context,String) cannot be referenced from a static context

@tuancoltech
Copy link
Member

@tuancoltech I'm getting build errors with the latest version of the Content Provider library. Do you have any ideas how we should solve this?

non-static method getAllEmojiGsons(long,Context,String) cannot be referenced from a static context

@jo-elimu I've fixed that.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/src/main/java/ai/elimu/vitabu/util/SingleClickListener.kt (1)

21-25: Potential issue with shared lastClickTime variable.

The mLastClickTime variable is static (stored in the companion object), meaning it's shared across all instances of SingleClickListener. This might cause unexpected behavior if multiple views with different SingleClickListeners are clicked in rapid succession.

Consider moving mLastClickTime outside the companion object to make it instance-specific:

-    companion object {
-        private const val DOUBLE_CLICK_INTERVAL: Long = 2000
-
-        private var mLastClickTime: Long = 0
-    }
+    companion object {
+        private const val DOUBLE_CLICK_INTERVAL: Long = 2000
+    }
+    
+    private var mLastClickTime: Long = 0
🛑 Comments failed to post (1)
app/src/main/java/ai/elimu/vitabu/ui/storybook/StoryBookActivity.kt (1)

25-25: ⚠️ Potential issue

Fix deprecated getSerializableExtra method.

The pipeline has flagged this method as deprecated in Java.

Replace it with the newer API that requires specifying the expected class type:

-        val readingLevel = intent.getSerializableExtra(EXTRA_KEY_STORYBOOK_LEVEL) as ReadingLevel?
+        val readingLevel = intent.getSerializableExtra(EXTRA_KEY_STORYBOOK_LEVEL, ReadingLevel::class.java)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

        val readingLevel = intent.getSerializableExtra(EXTRA_KEY_STORYBOOK_LEVEL, ReadingLevel::class.java)
🧰 Tools
🪛 GitHub Actions: Gradle Build

[warning] 25-25: 'fun getSerializableExtra(p0: String!): Serializable?' is deprecated. Deprecated in Java.

@jo-elimu jo-elimu merged commit 58fe7dc into main Mar 11, 2025
6 checks passed
@jo-elimu jo-elimu deleted the content-provider-1.2.30 branch March 11, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants