Commit Graph
348 Commits
Author SHA1 Message Date
callebtcandGitHub 3f8c236a72 Background persistence (#505)
* persistence step 1

* fix build

* messages in the background work, notifications not yet

* app state store

* DM icon shows up

* notification launches when app is closed!

* keep ui updated

* lifecycle fixes

* extensive logging, maybe revert later

* send nickname in announcement

* quit in notification

* setting in about sheet

* fix quit bitchat

* lifecycle fixes

* power mode based on background state

* stats for both direciotns

* fix graph persistence

* better counting

* count per device

* only compute when debug sheet is open? untested

* fix read receipts

* fix read receipts fully

* fix unread badge if messages have been read in focus

* foreground promotion fix

* fix app kill in notification

* adjust to new tor

* nice

* about sheet design
2025-12-13 16:43:39 +07:00
e96330e50b Migrate from LiveData to Kotlin Flow (#518)
* Automated update of relay data - Sun Sep 21 06:21:05 UTC 2025

* Automated update of relay data - Sun Sep 28 06:20:40 UTC 2025

* refactor: new close button like ios(but not liquid glass)

* Automated update of relay data - Sun Oct  5 06:20:09 UTC 2025

* Automated update of relay data - Sun Oct 12 06:20:12 UTC 2025

* Automated update of relay data - Sun Oct 19 06:21:51 UTC 2025

* Automated update of relay data - Sun Oct 26 06:21:31 UTC 2025

* Automated update of relay data - Sun Nov  2 06:22:16 UTC 2025

* Automated update of relay data - Sun Nov  9 06:21:43 UTC 2025

* Automated update of relay data - Sun Nov 16 06:22:37 UTC 2025

* Automated update of relay data - Sun Nov 23 06:22:51 UTC 2025

* Automated update of relay data - Sun Nov 30 06:24:08 UTC 2025

* Chore: Remove unused `lifecycle-livedata-ktx` dependency

This commit removes the `androidx.lifecycle:lifecycle-livedata-ktx` library from the project's dependencies.

The `[libraries]` and `[bundles]` sections in `gradle/libs.versions.toml` have been updated to reflect this removal, as the dependency is no longer in use.

* Refactor: Remove unused `runtime-livedata` dependency

* Refactor: Migrate `LocationChannelManager` and `GeohashBookmarksStore` to StateFlow

This commit refactors `LocationChannelManager` and `GeohashBookmarksStore` to use `StateFlow` instead of `LiveData` for managing and exposing their state. This change aligns with modern Android development practices and improves testability.

**Key Changes:**

- **`LocationChannelManager`**:
    - All `MutableLiveData` properties (`permissionState`, `availableChannels`, `selectedChannel`, etc.) have been replaced with `MutableStateFlow`.
    - Consumers now access these properties as `StateFlow`.
    - State updates have been changed from `postValue()` to direct `.value` assignments, simplifying thread management within the manager which already uses a dedicated coroutine scope.

- **`GeohashBookmarksStore`**:
    - `bookmarks` and `bookmarkNames` are now exposed as `StateFlow` instead of `LiveData`.
    - State updates similarly use `.value` assignment.

- **Nullability**:
    - The non-nullable nature of `StateFlow`'s value reduces the need for null-checks in both the manager classes and their consumers, leading to safer code.

* Refactor: Migrate from LiveData to StateFlow for Nostr components

This commit replaces `LiveData` with `StateFlow` across core Nostr-related classes to align with modern Android architecture and improve state management. This change affects `NostrClient`, `NostrRelayManager`, `LocationNotesManager`, and `GeohashRepository`.

**Key Changes:**

-   **`NostrClient`**:
    -   `isInitialized` and `currentNpub` are now `StateFlow` instead of `LiveData`.
    -   `relayConnectionStatus` and `relayInfo` now return `StateFlow` from `NostrRelayManager`.

-   **`NostrRelayManager`**:
    -   Public properties `relays` and `isConnected` are migrated from `MutableLiveData` to `MutableStateFlow`.
    -   Updates are now pushed using `.value` instead of `.postValue()`.

-   **`LocationNotesManager`**:
    -   All public `LiveData` properties (`notes`, `geohash`, `initialLoadComplete`, `state`, `errorMessage`) are converted to `StateFlow`.
    -   The class documentation is updated to reflect the use of `StateFlow`.

-   **`GeohashRepository`**:
    -   Methods `updateGeohashPeople` and `updateReactiveParticipantCounts` now call `set...` methods on the `state` object instead of `post...`, reflecting the removal of `LiveData` from the underlying state management.

* Refactor: Migrate ChatState from LiveData to StateFlow

This commit refactors the `ChatState`, `ChatViewModel`, and `GeohashViewModel` to use `StateFlow` instead of `LiveData` for managing and exposing UI state. This migration improves state management by leveraging modern coroutine-based flows.

**Key Changes:**

- **`ChatState.kt`**:
    - Replaced all `MutableLiveData` instances with `MutableStateFlow`.
    - Exposed state properties as `StateFlow` instead of `LiveData`.
    - Removed `MediatorLiveData` for computed properties (`hasUnreadChannels`, `hasUnreadPrivateMessages`) and replaced them with `Flow.combine` to create derivative `StateFlows`.
    - Simplified non-nullable `getters` to directly return the `.value` of the `StateFlows`.
    - Removed `postValue` helpers that are no longer necessary.

- **`ChatViewModel.kt`**:
    - Updated all state properties to be `StateFlow`, reflecting the changes in `ChatState`.

- **`GeohashViewModel.kt`**:
    - Changed state properties (`geohashPeople`, `geohashParticipantCounts`, etc.) from `LiveData` to `StateFlow`.
    - Replaced `observeForever` on `LiveData` from `LocationChannelManager` with `viewModelScope.launch` blocks that `.collect()` from the underlying flows.

* Refactor: Migrate UI from LiveData to StateFlow

This commit replaces `LiveData.observeAsState()` with `StateFlow.collectAsState()` across various UI components. This change aligns the codebase with modern Android development practices, using Kotlin Flows for reactive UI state management.

No functional changes are intended. The primary goal is to remove the dependency on `androidx.lifecycle.livedata` from the composable functions.

**Affected Components:**
- `ChatScreen`
- `SidebarComponents`
- `ChatHeader`
- `LocationChannelsSheet`
- `LocationNotesSheet`
- `LocationNotesButton`
- `GeohashPeopleList`
- `LocationNotesSheetPresenter`

* Refactor: Use `collectAsStateWithLifecycle` for UI state collection

* Refactor: move CloseButton to core/ui/component

* Refactor: remove AI generated comments

* Refactor: fix combine to map and use WhileSubscribed

* Refactor: Pass CoroutineScope to ChatState

This commit refactors the `ChatState` class to accept a `CoroutineScope` in its constructor instead of creating its own.

**Key Changes:**

- **`ChatState.kt`**: The constructor now requires a `CoroutineScope`. This scope is used for the `stateIn` operators that convert `Flows` into `StateFlows` (`hasUnreadChannels`, `hasUnreadPrivateMessages`), ensuring they operate within the lifecycle of the provided scope.
- **`ChatViewModel.kt`**: The `viewModelScope` is now passed to the `ChatState` constructor during its instantiation. This ties the lifecycle of the state's coroutines directly to the `ViewModel`'s lifecycle.

* Test: Use `TestScope` for coroutines in `CommandProcessorTest`

This commit refactors `CommandProcessorTest` to use a `TestScope` and `UnconfinedTestDispatcher` for managing coroutines.

This ensures that coroutine-based operations within the test are executed in a controlled and predictable manner, improving test reliability. The `coroutineScope` for `CommandProcessor` and the `scope` for `ChatState` are now both configured to use this test-specific scope.

---------

Co-authored-by: GitHub Action <action@github.com>
2025-12-13 15:58:48 +07:00
b2febcee88 feat: add product flavors and TorProvider abstraction (#508)
* feat: add product flavors and TorProvider abstraction

Introduces build flavors to separate Tor functionality from the standard build, reducing APK size for users who don't need Tor.

- Creates `standard` and `tor` product flavors.
- The `standard` flavor is the default, lightweight build.
- The `tor` flavor includes the Arti (Tor) dependency and is identified by the `.tor` application ID suffix.
- Adds a `TorProvider` interface and a `TorProviderFactory` to abstract Tor implementation details between flavors.

Prepares architecture for optional Tor support to reduce APK size
from 142MB to ~4-5MB for standard builds

Related to #454

* Refactor: implement StandardTorProvider and RealTorProvider

This commit refactors the Tor integration by introducing a `TorProvider` interface and creating separate implementations for 'tor' and 'standard' product flavors.

- The original `TorManager` singleton has been moved into `RealTorProvider` for the 'tor' flavor.
- A no-op `StandardTorProvider` is introduced for the 'standard' flavor, which reports Tor as unavailable.
- A `TorProviderFactory` is used to create the appropriate provider at runtime based on the build variant.

* refactor: migrate to TorProvider abstraction

Replaced direct calls to the static `TorManager` with an instance obtained from `TorProviderFactory`.

This change allows for different Tor implementations based on build flavors, improving modularity and abstracting the Tor provider logic.

Updated `BitchatApplication`, `ChatHeader`, `OkHttpProvider`, and `AboutSheet` to use the new factory pattern for accessing Tor functionalities.

* build: add flavor-specific ProGuard rules and CI/CD

 - Split ProGuard rules: base, standard-specific, tor-specific
  - Move Arti/Guardian Project rules to proguard-tor.pro
  - Update CI/CD workflow to build both flavors
  - Add separate artifact uploads for each flavor
  - Add descriptive release notes template

  CI now builds both standard (~4-5MB) and tor (~140MB) APKs."

  resolves #454

* refactor: centralize network reset logic

Extracts the repeated network connection reset logic into a new private function `resetNetworkConnections()`.

This change also replaces direct `_statusFlow.value = ...` assignments with the safer `_statusFlow.update { ... }` function to prevent race conditions.

* ci: run separate build steps for flavors

* feat: disable Tor toggle if not available in build

* ci: parallelize builds and add conditional tor lint

Optimizes CI workflow:
- Parallel matrix builds (4 runners instead of sequential)
- Conditional tor lint only when app/src/tor/ changes in PRs
- Merged test+lint jobs to reduce setup overhead

Reduces CI time by ~50% (8-11 min vs 18-26 min)

* refactor: Unify Tor implementation and remove build flavors

This commit refactors the Tor integration by removing the `standard` and `tor` product flavors in favor of a single, unified build that always includes a custom-built Arti (Tor) library.

Key changes include:
*   **Removed Build Flavors:** Deleted the `standard` and `tor` product flavors from `build.gradle.kts`, simplifying the build process and CI configuration.
*   **Unified Tor Manager:** Replaced the `TorProvider` interface and flavor-specific implementations (`StandardTorProvider`, `RealTorProvider`) with a new singleton, `ArtiTorManager`. This class now manages the Arti lifecycle for all builds.
*   **Custom Arti Wrapper:** Introduced a new `ArtiProxy` class to provide a compatible API wrapper around the custom-built native Arti library (`libarti_android.so`). This replaces the dependency on the external `arti-mobile-ex` library.
*   **Updated Proguard:** Consolidated and updated Proguard rules into the main `proguard-rules.pro` file to keep the necessary `ArtiTorManager` and native library classes.
*   **CI/CD Simplification:** Updated GitHub Actions workflows (`release.yml`, `android-build.yml`) to build and release a single APK instead of separate ones for each flavor.

* build: Configure ABI filters for debug and release builds

For debug builds, include `x86_64` to support emulators.

For release builds, only include `arm64-v8a` to minimize the final APK size.

* feat: Ignore jniLibs directory

This change adds the `app/src/main/jniLibs/` directory to the `.gitignore` file to prevent native libraries from being committed to the repository.

* feat: Refine .gitignore for Arti build artifacts

Improves the `.gitignore` file by:
- Ignoring all `build/` directories except for `tools/arti-build/`.
- Adding specific ignores for Arti build artifacts, including the cloned source repository and the Rust build cache directory.

* feat: Update arti android native library

* feat: add build script and JNI wrapper for Arti

Adds a comprehensive build system for creating custom Arti (Tor in Rust) shared libraries for Android. This replaces the dependency on external, outdated AARs with a fully transparent and reproducible build process.

Key changes:
- Introduces `build-arti.sh`, a script to clone the official Arti repository, apply a JNI wrapper, and build `.so` files for Android.
- Adds `ARTI_VERSION` to pin the build to a specific Arti release (v1.7.0).
- Implements a new Rust JNI wrapper (`src/lib.rs`) that exposes core functions like `initialize`, `startSocksProxy`, and `stop` to the Android app.
- Includes a `Cargo.toml` with release profile optimizations for size (`lto`, `strip`, `opt-level = "z"`).
- Provides detailed documentation in `README.md` explaining the build process, prerequisites, and architecture.

* build script for mac

* consolidate both scripts

* improve script

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
2025-12-12 23:27:52 +07:00
Mafiadöner36andGitHub a174ac5185 Add Network permission requirement to README (#522)
It forces Network permission prompt right down your throat, so please explain in readme, I was super irritated as its counter intuitive in regards to apps main selling point!
2025-12-12 19:20:09 +07:00
GitHub Action 4511cef619 Automated update of relay data - Sun Dec 7 06:06:39 UTC 2025 2025-12-07 06:06:39 +00:00
GitHub Action 7a628f2fec Automated update of relay data - Sun Nov 30 06:06:53 UTC 2025 2025-11-30 06:06:53 +00:00
GitHub Action b4142c7f1f Automated update of relay data - Sun Nov 23 06:06:51 UTC 2025 2025-11-23 06:06:51 +00:00
callebtcandGitHub 04ea2a3162 refactor app constants: service UUID for BLE (#500) 2025-11-18 21:26:20 +01:00
GitHub Action 466c8176a1 Automated update of relay data - Sun Nov 16 06:06:45 UTC 2025 2025-11-16 06:06:45 +00:00
GitHub Action 02cc6301e0 Automated update of relay data - Sun Nov 9 06:06:33 UTC 2025 2025-11-09 06:06:33 +00:00
callebtcandGitHub 282ac0fe5a Fix: do not reject empty packets that arent message type (#510)
* do not reject empty packets that arent message type

* leave message with empty byte array

* clean up comments
2025-11-03 20:37:31 +01:00
GitHub Action cf53c65cfe Automated update of relay data - Sun Nov 2 06:06:38 UTC 2025 2025-11-02 06:06:38 +00:00
callebtcandGitHub 292ca4532b fix connection attempt counter tracker (#503) 2025-10-30 13:50:47 +01:00
callebtcandGitHub a4ce8cc979 better tracking of first announce seen (#502) 2025-10-30 00:39:24 +01:00
GitHub Action 80d897a022 Automated update of relay data - Sun Oct 26 06:06:36 UTC 2025 2025-10-26 06:06:36 +00:00
callebtcandGitHub c3f5739fea refactor app constants: service UUID for BLE (#494) 2025-10-22 13:48:35 +02:00
callebtcandGitHub da7fdd0f23 suppress relay of reassambled packet by setting TTL=0 (#492) 2025-10-21 12:52:14 +02:00
Developer ChunkandGitHub 9535ca8940 feat: Add tablet landscape orientation support (#490)
- Tablets now support landscape mode, phones remain portrait-only
- Add OrientationAwareActivity base class for orientation management
- Add DeviceUtils.isTablet() for runtime device detection
- Update MainActivity and GeohashPickerActivity to extend OrientationAwareActivity
- Uses multiple detection criteria (screen size, density, configuration)
Fixes #480
2025-10-20 20:14:50 +02:00
callebtcandGitHub f633509848 bump to 1.5.1 (#488) 1.5.1 2025-10-19 12:43:55 +02:00
callebtcandGitHub 59ee530d54 show media buttons only in mesh (#487) 2025-10-19 12:32:56 +02:00
GitHub Action 7881210785 Automated update of relay data - Sun Oct 19 06:06:46 UTC 2025 2025-10-19 06:06:46 +00:00
callebtcandGitHub 2869a2b192 actually 1.5.0 (#485) 1.5.0 2025-10-18 15:03:45 +02:00
callebtcandGitHub 20342351a5 Camera take picture (#484)
* camera capture

* icon change

* image preview great

* remove string
2025-10-18 15:03:32 +02:00
callebtcandGitHub af4dd175c4 lower voice quality, smaller file size (#483) 2025-10-18 14:20:35 +02:00
callebtcandGitHub f99cb46b26 Location notes (#482)
* try 1

* works

* equalize UI with ios

* ui cleanup

* geohash chats: no building

* load notes in background

* insta

* simplify and tor icon change

* icons nice

* refactor

* unify location enabled / disabled

* cooler

* simplify, doesnt subscribe right away

* load when clicked

* plus minus location notes

* load when tor is available

* translations

* fix transalations

* implement review comments
2025-10-18 14:19:53 +02:00
callebtcandGitHub e8862d5128 versioncode 24 (#479) 2025-10-16 14:26:13 +02:00
callebtcandGitHub c4966b9a28 remove from all languages (#478) 2025-10-16 14:20:35 +02:00
Developer ChunkandGitHub fc3a00b4b9 fix: Resolve debug settings bottom sheet crash on some devices (#474)
Fixes #472 - App crashing in debug settings
The issue was in ui/debug/DebugSettingsSheet.kt:
- Line 304: Code was pre-formatting double value with String.format() then passing
  to string resource that expected raw double parameter
- Line 307: Numeric values weren't properly converted to strings for string resource
  that expected string parameters
Changes made:
- Changed stringResource(R.string.debug_target_fpr_fmt, String.format("%.2f", gcsFpr))
  to stringResource(R.string.debug_target_fpr_fmt, gcsFpr) - passes raw double value
- Changed stringResource(R.string.debug_derived_p_fmt, p, nmax)
  to stringResource(R.string.debug_derived_p_fmt, p.toString(), nmax.toString()) -
  properly converts numeric values to strings
This resolves the IllegalFormatConversionException: f != java.lang.String crash
when scrolling through the debug settings bottom sheet.
2025-10-16 13:21:44 +02:00
callebtcandGitHub 4a6fe922f3 bump version 1.4.0 (#470) 1.4.0 2025-10-14 13:02:12 +02:00
callebtcandGitHub 1486121b77 Extract constants (#469)
* extract constants

* refactor constants
2025-10-12 20:59:37 +02:00
callebtcandGitHub c61347defe Remove ghost sync (#468)
* delete stale peers and messages from sync manager

* ignore old announcenements
2025-10-12 19:41:44 +02:00
callebtcandGitHub ad28cc710c Translations (#467)
* english done

* de

* more extraction

* wip strings en

* translations work

* remove unneeded translations

* remove notification message

* add languages

* new languages
2025-10-12 18:54:20 +02:00
GitHub Action 3b2241e891 Automated update of relay data - Sun Oct 12 06:06:18 UTC 2025 2025-10-12 06:06:18 +00:00
4030396203 fix: clear channel messages on reset (#446)
When `clearMessages` is called, it now also clears the `channelMessages` in the state, ensuring that messages from specific channels are also removed.

Co-authored-by: elian.kumaraku <elian.kumaraku@creactives.com>
2025-10-11 21:31:35 +02:00
GitHub Action 7e65450eac Automated update of relay data - Sun Oct 5 06:06:17 UTC 2025 2025-10-05 06:06:17 +00:00
GitHub Action 6546943cf7 Automated update of relay data - Sun Sep 28 06:06:42 UTC 2025 2025-09-28 06:06:42 +00:00
GitHub Action 2e4b0b04ed Automated update of relay data - Sun Sep 21 06:06:38 UTC 2025 2025-09-21 06:06:38 +00:00
callebtcandGitHub 2b0bb5af74 fix unit tests (#442) 2025-09-20 00:05:46 +02:00
callebtcandGitHub 633a506753 Media transfers (#440)
* tor voice wip

* worky BLE a bit

* can send sound

* remove tor

* ui cleanup

* recording time

* progress bar color

* nicknames for audio

* onboarding permissions no microphone

* may work

* fix destionation

* extend

* refactor voice input component

* fix keyboard collapse issue

* send images

* wip image open

* image sending works

* wip waveforms

* better

* better animation

* fix cursor for sending audio

* image sending animation

* image sending animation

* full screen image viewer

* gossip sync for fragments too

* reduce delays

* fix keyboard focus

* use v2 for file transfers

* do not sync fragments

* scrollable image viewer

* ui

* ui adjustments

* nicer animation

* seek through audio

* add spec

* add more details to documentation

* File sharing E2E:
- Add TLV BitchatFilePacket, FileSharingManager
- Implement sendFileNote in ChatViewModel
- File receive path: save to files/incoming and render [file] messages with FileMessageItem or FileSendingAnimation during transfer
- SAF FilePickerButton and dispatcher wiring; image/file choice to follow in MediaPickerOptions
- Add FileViewerDialog with system open/save, FileProvider and file_paths
- Hook transfer progress to file sending UI
- Manifest: READ_MEDIA_* and FileProvider
- Fix MessageHandler saving and prefix for non-image payloads
- Add helper utils (FileUtils)

* kinda wip

* fix buttons

* files half working

* wip file transfer

* file packet has 2-byte TLV and chunks. it wokrs but it sucks

* clean

* remove gossip sync for fragments

* fix audio and image rendering

* adjust FILE_SIZE TLV size too

* cleanup

* haptic

* private messages media

* read receipts for media

* use enum for message type not string

* delivery ack checks dont push content

* check

* animation fix

* refactor

* ui adjustments

* comments

* refactor

* fix crash on send and receive of the same file

* refactor notifications

* tests
2025-09-19 22:46:14 +02:00
callebtcandGitHub 1178fc254a remove the noise handshake if peer goes offline (#435) 2025-09-15 15:33:39 +02:00
callebtcandGitHub 7061a96cce bump to 1.3.1 (#432) 1.3.1 2025-09-15 12:43:58 +02:00
callebtcandGitHub 4eda850110 better verbose logging (#431) 2025-09-15 01:31:32 +02:00
c2609643da add github tests (#233)
* add github tests

* fix github tests (#409)

---------

Co-authored-by: Tobiloba Oyelekan <miketobi73@gmail.com>
2025-09-14 17:31:19 +02:00
callebtcandGitHub 277dbdf4e1 nostr: fix block feature (#427)
* fix block feature

* fix nostr nickname in sidebar
2025-09-14 17:30:47 +02:00
lollerfirstandGitHub a4ef2ef29c fix: bookmark removal persistence (#424) 2025-09-14 16:38:39 +02:00
callebtcandGitHub 9c7567e62e lock to tor (#426)
* lock to tor

* bootstrap state
2025-09-14 16:36:02 +02:00
GitHub Action df4aa4b25d Automated update of relay data - Sun Sep 14 06:06:21 UTC 2025 2025-09-14 06:06:21 +00:00
callebtcandGitHub 382d29e03f bump versioncode (#419) 2025-09-14 05:12:42 +02:00
callebtcandGitHub 4786b1f250 default pow to 12 (#418) 1.3.0 2025-09-14 05:04:04 +02:00
callebtcandGitHub b96bf180f9 Fix pow (#417)
* fix pow

* only pow with nonse
2025-09-14 05:01:34 +02:00