Skip to content

A modern Android client for ActivityPub and Mastodon instances built with Jetpack Compose.

License

Notifications You must be signed in to change notification settings

manalejandro/MyActivityPub

Repository files navigation

My ActivityPub

A modern Android client for ActivityPub and Mastodon instances built with Jetpack Compose.

Overview

My ActivityPub is a beautiful, user-friendly Android application that allows you to interact with Mastodon and other ActivityPub-compatible social networks. The app features a clean, modern UI built entirely with Jetpack Compose and Material Design 3.

Features

Core Features

  • πŸ“± Modern Material Design 3 UI - Beautiful, responsive interface
  • 🌐 Multi-Instance Support - Connect to any Mastodon/ActivityPub instance
  • πŸ” OAuth Authentication - Secure login with OAuth 2.0
  • πŸ“° Public & Home Timelines - Browse federated and personal timelines
  • πŸ”„ Pull-to-Refresh - Swipe down to update your timeline
  • ⚑ Auto-Refresh - Timeline automatically updates every 30 seconds
  • πŸ”— Interactive Links & Hashtags - Click URLs and hashtags in posts
  • πŸ–ΌοΈ Media Attachments - View images and media in posts
  • πŸ’¬ Post Interactions - Reply, boost, and favorite posts
  • πŸ“Š Status Details - View full posts with reply threads
  • πŸ”” Notifications - Stay updated with mentions and interactions
  • ♾️ Infinite Scrolling - Load more posts as you scroll
  • 🎨 Dynamic Colors - Adapts to your system theme (Android 12+)
  • πŸŒ™ Dark Mode - Full dark theme support

Screenshots

(Coming soon)

Tech Stack

  • Language: Kotlin
  • UI Framework: Jetpack Compose
  • Architecture: MVVM (Model-View-ViewModel)
  • Networking: Retrofit 2 + OkHttp
  • Image Loading: Coil
  • Async Operations: Kotlin Coroutines + Flow
  • Material Design: Material 3

Project Structure

app/
β”œβ”€β”€ src/main/java/com/manalejandro/myactivitypub/
β”‚   β”œβ”€β”€ MainActivity.kt                      # Main entry point
β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── MastodonApiService.kt       # API service interface
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   β”œβ”€β”€ Account.kt                  # User account model
β”‚   β”‚   β”‚   β”œβ”€β”€ Status.kt                   # Post/status model
β”‚   β”‚   β”‚   β”œβ”€β”€ MediaAttachment.kt          # Media attachment model
β”‚   β”‚   β”‚   └── Instance.kt                 # Instance information model
β”‚   β”‚   └── repository/
β”‚   β”‚       └── MastodonRepository.kt       # Data repository
β”‚   └── ui/
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   └── StatusCard.kt               # Status card component
β”‚       β”œβ”€β”€ viewmodel/
β”‚       β”‚   └── TimelineViewModel.kt        # Timeline view model
β”‚       └── theme/
β”‚           β”œβ”€β”€ Color.kt                    # Color definitions
β”‚           β”œβ”€β”€ Theme.kt                    # Theme configuration
β”‚           └── Type.kt                     # Typography

Architecture

The app follows the MVVM (Model-View-ViewModel) architecture pattern:

  • Model: Data classes representing API responses (Status, Account, etc.)
  • View: Composable functions for UI (StatusCard, MyActivityPubApp)
  • ViewModel: TimelineViewModel manages UI state and business logic
  • Repository: MastodonRepository handles data operations and API calls

Data Flow

API Service β†’ Repository β†’ ViewModel β†’ UI State β†’ Composable UI

Getting Started

Prerequisites

  • Android Studio Hedgehog (2023.1.1) or newer
  • JDK 11 or higher
  • Android SDK with API level 24+ (Android 7.0+)

Building the Project

  1. Clone the repository:
git clone <repository-url>
cd MyActivityPub
  1. Open the project in Android Studio

  2. Sync Gradle files

  3. Build and run:

./gradlew assembleDebug

The APK will be generated at:

app/build/outputs/apk/debug/app-debug.apk

Running on Device/Emulator

  1. Connect your Android device or start an emulator
  2. Click "Run" in Android Studio or use:
./gradlew installDebug

API Reference

The app uses the Mastodon API v1 specification. By default, it connects to mastodon.social, but you can modify the base URL in MainActivity.kt.

Supported Endpoints

  • GET /api/v1/timelines/public - Fetch public timeline
  • GET /api/v1/instance - Get instance information
  • GET /api/v1/accounts/:id - Get account details
  • GET /api/v1/accounts/:id/statuses - Get account statuses

For more information, see the Mastodon API documentation.

Configuration

Changing the Instance

To connect to a different Mastodon instance, modify the base URL in MainActivity.kt:

val retrofit = Retrofit.Builder()
    .baseUrl("https://your-instance.social/")
    // ...

Gradle Configuration

Key configuration files:

  • build.gradle.kts - App dependencies and build configuration
  • gradle.properties - Gradle properties (JVM memory, etc.)
  • libs.versions.toml - Version catalog for dependencies

Dependencies

Library Version Purpose
Retrofit 2.9.0 REST API client
OkHttp 4.12.0 HTTP client
Gson 2.9.0 JSON serialization
Coil 2.5.0 Image loading
Coroutines 1.7.3 Async programming
Compose BOM 2024.09.00 Jetpack Compose libraries
Material 3 Latest Material Design 3 components

Development

Code Style

This project follows the official Kotlin coding conventions. Key guidelines:

  • Use 4 spaces for indentation
  • Use camelCase for variables and functions
  • Use PascalCase for classes
  • Add KDoc comments for public APIs
  • Keep functions small and focused

Adding New Features

  1. Create data models in data/models/
  2. Add API endpoints in MastodonApiService.kt
  3. Implement repository methods in MastodonRepository.kt
  4. Create ViewModel with UI state in ui/viewmodel/
  5. Build UI components in ui/components/
  6. Wire everything together in composable screens

Troubleshooting

Build Issues

Gradle daemon crashes:

  • Increase JVM memory in gradle.properties: org.gradle.jvmargs=-Xmx4096m

Dependency resolution fails:

  • Clear Gradle cache: ./gradlew clean --no-daemon
  • Invalidate caches in Android Studio

Compose compiler issues:

  • Ensure Kotlin and Compose versions are compatible
  • Check libs.versions.toml for version alignment

Runtime Issues

Network errors:

  • Verify INTERNET permission in AndroidManifest.xml
  • Check device/emulator internet connection
  • Ensure HTTPS URLs are used (clear text traffic is disabled)

Image loading failures:

  • Coil requires valid URLs
  • Check LogCat for detailed error messages

Recent Updates

Latest Features (v1.0)

πŸ”„ Pull-to-Refresh

The app now supports pull-to-refresh functionality on all timelines. Simply swipe down from the top of the timeline to fetch the latest posts from your instance.

⚑ Automatic Timeline Updates

Timelines now automatically check for new posts every 30 seconds. New posts appear seamlessly at the top of your timeline without interrupting your reading experience.

How it works:

  • Background coroutine checks for new posts using since_id parameter
  • Updates are silent and don't interfere with scrolling
  • Auto-refresh restarts when switching between timelines
  • Minimal network usage - only fetches posts newer than the current top post

πŸ”— Interactive Content

Post content is now fully interactive with support for:

  • Clickable URLs: Tap any link to open in your default browser
  • Hashtags: Styled and clickable hashtags
  • Rich HTML content: Proper rendering of formatted text

All links and hashtags are displayed in your theme's primary color with underlines for easy identification.

For detailed information about all features, see FEATURES.md.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Mastodon for the API specification
  • Takahe for API reference
  • Material Design 3 for the beautiful design system
  • The Android and Kotlin communities

Contact

For questions or feedback, please open an issue on GitHub.


Note: This is a demonstration project showcasing modern Android development with Jetpack Compose. For production use, consider adding authentication, error handling improvements, and additional features like posting, following, and notifications.

About

A modern Android client for ActivityPub and Mastodon instances built with Jetpack Compose.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages