Skip to content

teja2495/rewritely

Repository files navigation

Rewritely - Android App for Text Rewriting

Rewritely is an Android app that helps users quickly rewrite their written text to improve grammar and sentence structure in any app.

Screenshots

Home Screen Text Input with Floating Icon
Home Screen Text Input with Floating Icon

Features

  • Text Rewriting: Rewrites text in any input field using the OpenAI API.
  • Floating Icon: Provides a non-intrusive floating icon for easy access to the rewrite functionality. Type at least 3 words in the input field for the icon to show up.
  • Shortcut Triggers: Create custom shortcut texts (2-5 characters) that automatically trigger text rewriting when typed at the end of your text followed by a space. Each shortcut can be configured with its own custom prompt or use existing custom options.
  • Trigger Modes: Choose how to trigger rewrites - shortcuts only, floating icon only, or both modes together.
  • API Key Management: Securely stores and manages the OpenAI API key with the ability to reset it.
  • App Selection: Choose which specific apps should show the floating icon, or enable it for all apps.
  • Custom Options: Create and manage custom rewrite prompts with up to 4 custom options plus default and ChatGPT options. Users can also update default prompts along with adding new custom options.
  • ChatGPT Integration: Special ChatGPT option that copy-pastes text directly into ChatGPT with the configured prompt for seamless workflow.
  • Permissions Handling: Manages necessary permissions, including Accessibility Service and Draw Over Other Apps.

Prerequisites

  • Android device with API level 23 or higher.
  • OpenAI API Key.

Setup

  1. Clone the repository:
    git clone <repository_url>
  2. Open the project in Android Studio.
  3. Obtain an OpenAI API Key from the OpenAI platform.
  4. Build and run the app on an Android device or emulator.
  5. Enter your OpenAI API key in the app's settings.
  6. Grant the necessary permissions, specifically:
    • Accessibility Service: Enable the Rewritely Accessibility Service to allow the app to monitor and interact with text fields.
    • Draw Over Other Apps: Allow the app to display the floating icon.

Usage

Basic Text Rewriting

  1. Open any app with text input fields
  2. Type at least 3 words in a text field
  3. A floating icon will appear next to the text field
  4. Tap the floating icon to rewrite your text using AI

App Selection

  1. Go to the app's settings screen
  2. Tap "Choose Apps" in the App Selection section
  3. Select which apps should show the floating icon
  4. You can choose specific apps or enable it for all apps

Custom Options

  1. In the settings screen, tap "Customize Now" in the Customization section
  2. Create custom rewrite prompts with descriptive names
  3. Edit the default and ChatGPT options as needed
  4. Up to 4 custom options can be created in addition to the built-in options

Shortcut Triggers

  1. In the settings screen, tap "Add shortcut" in the Shortcuts section
  2. Create shortcut texts (2-5 characters) that will automatically trigger rewriting
  3. Configure each shortcut with a custom prompt or select an existing custom option
  4. Enable or disable shortcuts individually as needed
  5. Up to 10 shortcuts can be created
  6. When typing in any text field, type your shortcut followed by a space to automatically trigger rewriting
  7. The shortcut text is automatically removed before the rewrite is performed

Trigger Modes

  1. In the settings screen, tap "Configure Mode" in the Trigger Mode section
  2. Choose from three modes:
    • Shortcuts Only: Only shortcut triggers work; no floating icon appears
    • Floating Icon Only: Only the floating icon appears; shortcut triggers are disabled
    • Both: Both shortcuts and floating icon are active

Architecture

The app follows a simple architecture with the following key components:

  • MainActivity: The main activity handles the UI for API key input, permission requests, and settings management.
  • RewritelyService: An Accessibility Service that monitors text fields, displays the floating icon, detects shortcut triggers, and handles the text rewriting.
  • OpenAiApiService: A Retrofit interface for making API calls to the OpenAI API.
  • ApiClient: A singleton object that provides a Retrofit client for the OpenAI API.
  • SecurePrefs: A utility class for securely storing the OpenAI API key, custom options, and shortcut triggers using EncryptedSharedPreferences.
  • AppSelectionSettings: Manages which apps should show the floating icon.
  • CustomOption: Data class for managing custom rewrite prompts.
  • ShortcutTrigger: Data class for managing shortcut trigger configurations.
  • TriggerMode: Enum for managing trigger mode settings (shortcuts only, floating icon only, or both).
  • AppCache: Handles caching of installed apps for better performance.

Dependencies

  • Kotlin
  • AndroidX libraries
  • Retrofit
  • OkHttp
  • AndroidX Security Crypto
  • Jetpack Compose

Permissions

The app requires the following permissions:

  • android.permission.SYSTEM_ALERT_WINDOW: To draw the floating icon over other apps.
  • android.permission.INTERNET: To communicate with the OpenAI API.
  • android.permission.FOREGROUND_SERVICE: To keep the service running in the background.
  • android.permission.FOREGROUND_SERVICE_SPECIAL_USE: (Android 14+) Specific foreground service permission.
  • android.permission.BIND_ACCESSIBILITY_SERVICE: Granted by the system when the user enables the Accessibility Service.

Important Notes

  • The OpenAI API key is stored securely using EncryptedSharedPreferences.
  • The Accessibility Service is crucial for the app's functionality. The app will not function correctly without it enabled.
  • The app uses foregroundServiceType="specialUse" and the corresponding permission for Android 14 to provide a clear justification for its background operation, emphasizing its assistance features.
  • Custom options are limited to 4 additional options plus the default and ChatGPT options.
  • Shortcut triggers are limited to 10 shortcuts, each with 2-5 characters.
  • Shortcut triggers automatically detect when you type a shortcut followed by a space and trigger rewriting without requiring the floating icon.
  • App selection settings are saved automatically and persist across app restarts.

License

MIT License

About

A handy Android app which enables a floating icon to quickly rephrase your text within any app.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages