Skip to content

Conversation

@atorch
Copy link
Owner

@atorch atorch commented Aug 26, 2025

This commit introduces a new feature that allows users to get hints for puzzles by launching the Gemini app.

  • A "Talk to Gemini" button has been added to the puzzle screen.
  • When clicked, the puzzle text is copied to the clipboard, and an Intent is fired to open the Gemini app.
  • If the Gemini app is not installed, the user is redirected to the Play Store.
  • The minimum SDK version has been increased to 19 to support the new testing libraries.
  • An end-to-end test has been added to verify the new functionality.

This is a simple option for #34

This commit introduces a new feature that allows users to get hints for puzzles by launching the Gemini app.

- A "Talk to Gemini" button has been added to the puzzle screen.
- When clicked, the puzzle text is copied to the clipboard, and an Intent is fired to open the Gemini app.
- If the Gemini app is not installed, the user is redirected to the Play Store.
- The minimum SDK version has been increased to 19 to support the new testing libraries.
- An end-to-end test has been added to verify the new functionality.
@atorch atorch requested a review from Copilot August 26, 2025 05:22

This comment was marked as outdated.

@atorch atorch requested a review from Copilot August 27, 2025 04:40

This comment was marked as outdated.

<string name="button_hint">تحتاج تلميحاً؟</string>
<string name="button_gemini_hint">التحدث إلى Gemini</string>
<string name="puzzle_copied_to_clipboard">تم نسخ اللغز إلى الحافظة.</string>
<string name="gemini_not_installed">تطبيق Gemini غير مثبت. جارٍ فتح متجر Play.</string>
Copy link
Collaborator

Choose a reason for hiding this comment

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

@aalhour What's the proper translation for this string? I think either "Play Store" needs to be spelled out both in English, or the word "Play" needs to be in Arabic as well.

atorch added 2 commits August 28, 2025 21:37
This commit resolves an AmbiguousViewMatcherException in the SolvePuzzleTest by ensuring the Gemini hint button is only visible on the currently displayed puzzle fragment.

The visibility of the button is now managed in the onResume() and onPause() lifecycle methods of the SolvePuzzle fragment. This prevents Espresso from finding multiple matching views in the hierarchy when running tests on devices with larger screens or in specific orientations.

Additionally, this commit:
- Refactors the Gemini prompt creation to use a translatable string resource.
- Adds translations for Arabic, German, and Spanish.
@atorch atorch requested a review from Copilot August 29, 2025 05:18

This comment was marked as outdated.

Add detailed instructions to README.md for setting up an Android emulator and running the connectedAndroidTest Gradle task locally.
// For example:
// String hint = res.getHint(level, puzzleIndex);
// String prompt = getString(R.string.gemini_prompt_template) + puzzleText +
// "\n\nHere's the current hint, please expand on it: " + hint;
Copy link
Owner Author

Choose a reason for hiding this comment

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

Note to self: I could try this with and without, and see whether Gemini's response is better with or without the added context

Another note: look at what this does for the "intro" levels that are already giving away the answer, simply to teach the user how to type in the input field, and how the math parser works. That intro level probably doesn't need a "Talk to Gemini" button, I could hide it for that level

Copy link
Owner Author

Choose a reason for hiding this comment

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

I could also ask the bot to review all of my hardcoded hints, and add another sentence or two to the ones that are too short

atorch added 3 commits August 28, 2025 23:22
This commit resolves a race condition in the `SolvePuzzleTest` that caused failures on the CI. The `onResume` and `onPause` methods in `SolvePuzzleFragment` were hiding and showing the Gemini hint button, which created a race condition with the test that was trying to click it.

This commit fixes the issue by removing the visibility changes from the fragment and relying on the `isDisplayed()` matcher in the test to select the correct button.

Additionally, this commit updates the `README.md` file with detailed instructions on how to run the instrumented tests with a specific locale, which will help with debugging and testing in the future.
…est reliability\n\n- Configured CI to use Pixel 6 emulator for consistent testing environment.\n- Updated README.md to document CI emulator configuration.\n- Improved instrumented test reliability by adding scrollTo() action and clarifying comments in SolvePuzzleTest.java.
- Address potential NullPointerException by using requireActivity() in SolvePuzzleFragment.
- Add test cases to AnswerChecker for factorial expressions and invalid user input.
- Improve Arabic translation for the "Gemini not installed" message.
@atorch atorch requested a review from Copilot September 1, 2025 00:27

This comment was marked as outdated.

This commit enhances the "Get a hint from Gemini" feature by providing the existing hint to Gemini as context, allowing for more relevant and helpful hints.

Key changes:
- Modified the Gemini prompt to include the current hint for expansion.
- Updated the Gemini app package name to `com.google.android.apps.bard`.
- Added necessary `<queries>` to `AndroidManifest.xml` for package visibility.
- Updated the `SolvePuzzleTest` to reflect the package name change.
- Added extensive documentation to `README.md` for running the app on a physical device (both USB and wireless).
- Added translations for the new string resources.
@atorch atorch requested a review from Copilot September 6, 2025 07:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a "Talk to Gemini" feature that allows users to get hints for puzzles by launching the Google Gemini app with the puzzle text pre-populated on the clipboard.

  • Added a new "Talk to Gemini" button that copies puzzle text to clipboard and launches the Gemini app
  • Enhanced test coverage with new unit tests and an end-to-end test for the Gemini functionality
  • Updated build configuration to support newer testing libraries and improved CI setup

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
SolvePuzzle.java Added onGeminiHint() method and button handler for Gemini integration
fragment_solve_puzzle.xml Added new "Talk to Gemini" button to the puzzle UI
strings.xml (all locales) Added localized strings for Gemini feature messages and prompts
AndroidManifest.xml Added queries declaration to check for Gemini app installation
SolvePuzzleTest.java New end-to-end test verifying Gemini button launches Play Store when app not installed
AnswerCheckerTest.java Added additional test cases for answer validation
build.gradle Updated Espresso testing library versions
README.md Added comprehensive documentation for running instrumented tests
actions.yml Added device specification for CI emulator
Comments suppressed due to low confidence (1)

app/src/main/java/atorch/statspuzzles/SolvePuzzle.java:1

  • The toast message is shown regardless of whether the Gemini app is installed or not. It should only be displayed when the app is not installed and the user is being redirected to the Play Store.
package atorch.statspuzzles;

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +350 to +351
// The package name for the Google Gemini app is com.google.android.apps.bard.
String geminiPackageName = "com.google.android.apps.bard";
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The hardcoded package name should be extracted to a constant or configuration value to improve maintainability and make it easier to update if the package name changes.

Copilot uses AI. Check for mistakes.
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + geminiPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + geminiPackageName)));
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The ActivityNotFoundException is caught but no user feedback is provided if the web fallback also fails. Consider adding a Toast message to inform the user if both the Play Store app and web browser fail to open.

Suggested change
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + geminiPackageName)));
try {
activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + geminiPackageName)));
} catch (android.content.ActivityNotFoundException anfe2) {
Toast.makeText(activity, R.string.cannot_open_play_store, Toast.LENGTH_LONG).show();
}

Copilot uses AI. Check for mistakes.
@atorch atorch merged commit c62bc5f into master Sep 6, 2025
5 checks passed
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