init
@@ -0,0 +1,57 @@
|
|||||||
|
# Android Studio / IntelliJ
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
build/
|
||||||
|
!*/build/filtered-manifest/
|
||||||
|
!*/build/generated/
|
||||||
|
!*/build/intermediates/
|
||||||
|
local.properties
|
||||||
|
.gradle/
|
||||||
|
captures/
|
||||||
|
.externalNativeBuild/
|
||||||
|
debug_keystore/
|
||||||
|
*.keystore
|
||||||
|
debug.keystore
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
/build/
|
||||||
|
/.gradle/
|
||||||
|
/captures/
|
||||||
|
*.apk
|
||||||
|
*.aab
|
||||||
|
*.ap_
|
||||||
|
*.dex
|
||||||
|
|
||||||
|
# Mac
|
||||||
|
.DS_Store
|
||||||
|
*.swp
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Maven
|
||||||
|
target/
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
|
||||||
|
# Linters
|
||||||
|
.lint/
|
||||||
|
|
||||||
|
# Other
|
||||||
|
*.log
|
||||||
|
.cxx/
|
||||||
|
*build/
|
||||||
|
out/
|
||||||
|
gen/
|
||||||
|
*~
|
||||||
|
*.swp
|
||||||
|
*.lock
|
||||||
|
|
||||||
|
# Google services
|
||||||
|
google-services.json
|
||||||
|
|
||||||
|
# Keystore files
|
||||||
|
*.jks
|
||||||
|
*.keystore
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
# bitchat Privacy Policy
|
||||||
|
|
||||||
|
*Last updated: January 2025*
|
||||||
|
|
||||||
|
## Our Commitment
|
||||||
|
|
||||||
|
bitchat is designed with privacy as its foundation. We believe private communication is a fundamental human right. This policy explains how bitchat protects your privacy.
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
- **No personal data collection** - We don't collect names, emails, or phone numbers
|
||||||
|
- **No servers** - Everything happens on your device and through peer-to-peer connections
|
||||||
|
- **No tracking** - We have no analytics, telemetry, or user tracking
|
||||||
|
- **Open source** - You can verify these claims by reading our code
|
||||||
|
|
||||||
|
## What Information bitchat Stores
|
||||||
|
|
||||||
|
### On Your Device Only
|
||||||
|
|
||||||
|
1. **Identity Key**
|
||||||
|
- A cryptographic key generated on first launch
|
||||||
|
- Stored locally in your device's secure storage
|
||||||
|
- Allows you to maintain "favorite" relationships across app restarts
|
||||||
|
- Never leaves your device
|
||||||
|
|
||||||
|
2. **Nickname**
|
||||||
|
- The display name you choose (or auto-generated)
|
||||||
|
- Stored only on your device
|
||||||
|
- Shared with peers you communicate with
|
||||||
|
|
||||||
|
3. **Message History** (if enabled)
|
||||||
|
- When room owners enable retention, messages are saved locally
|
||||||
|
- Stored encrypted on your device
|
||||||
|
- You can delete this at any time
|
||||||
|
|
||||||
|
4. **Favorite Peers**
|
||||||
|
- Public keys of peers you mark as favorites
|
||||||
|
- Stored only on your device
|
||||||
|
- Allows you to recognize these peers in future sessions
|
||||||
|
|
||||||
|
### Temporary Session Data
|
||||||
|
|
||||||
|
During each session, bitchat temporarily maintains:
|
||||||
|
- Active peer connections (forgotten when app closes)
|
||||||
|
- Routing information for message delivery
|
||||||
|
- Cached messages for offline peers (12 hours max)
|
||||||
|
|
||||||
|
## What Information is Shared
|
||||||
|
|
||||||
|
### With Other bitchat Users
|
||||||
|
|
||||||
|
When you use bitchat, nearby peers can see:
|
||||||
|
- Your chosen nickname
|
||||||
|
- Your ephemeral public key (changes each session)
|
||||||
|
- Messages you send to public rooms or directly to them
|
||||||
|
- Your approximate Bluetooth signal strength (for connection quality)
|
||||||
|
|
||||||
|
### With Room Members
|
||||||
|
|
||||||
|
When you join a password-protected room:
|
||||||
|
- Your messages are visible to others with the password
|
||||||
|
- Your nickname appears in the member list
|
||||||
|
- Room owners can see you've joined
|
||||||
|
|
||||||
|
## What We DON'T Do
|
||||||
|
|
||||||
|
bitchat **never**:
|
||||||
|
- Collects personal information
|
||||||
|
- Tracks your location
|
||||||
|
- Stores data on servers
|
||||||
|
- Shares data with third parties
|
||||||
|
- Uses analytics or telemetry
|
||||||
|
- Creates user profiles
|
||||||
|
- Requires registration
|
||||||
|
|
||||||
|
## Encryption
|
||||||
|
|
||||||
|
All private messages use end-to-end encryption:
|
||||||
|
- **X25519** for key exchange
|
||||||
|
- **AES-256-GCM** for message encryption
|
||||||
|
- **Ed25519** for digital signatures
|
||||||
|
- **Argon2id** for password-protected rooms
|
||||||
|
|
||||||
|
## Your Rights
|
||||||
|
|
||||||
|
You have complete control:
|
||||||
|
- **Delete Everything**: Triple-tap the logo to instantly wipe all data
|
||||||
|
- **Leave Anytime**: Close the app and your presence disappears
|
||||||
|
- **No Account**: Nothing to delete from servers because there are none
|
||||||
|
- **Portability**: Your data never leaves your device unless you export it
|
||||||
|
|
||||||
|
## Bluetooth & Permissions
|
||||||
|
|
||||||
|
bitchat requires Bluetooth permission to function:
|
||||||
|
- Used only for peer-to-peer communication
|
||||||
|
- No location data is accessed or stored
|
||||||
|
- Bluetooth is not used for tracking
|
||||||
|
- You can revoke this permission at any time in system settings
|
||||||
|
|
||||||
|
## Children's Privacy
|
||||||
|
|
||||||
|
bitchat does not knowingly collect information from children. The app has no age verification because it collects no personal information from anyone.
|
||||||
|
|
||||||
|
## Data Retention
|
||||||
|
|
||||||
|
- **Messages**: Deleted from memory when app closes (unless room retention is enabled)
|
||||||
|
- **Identity Key**: Persists until you delete the app
|
||||||
|
- **Favorites**: Persist until you remove them or delete the app
|
||||||
|
- **Everything Else**: Exists only during active sessions
|
||||||
|
|
||||||
|
## Security Measures
|
||||||
|
|
||||||
|
- All communication is encrypted
|
||||||
|
- No data transmitted to servers (there are none)
|
||||||
|
- Open source code for public audit
|
||||||
|
- Regular security updates
|
||||||
|
- Cryptographic signatures prevent tampering
|
||||||
|
|
||||||
|
## Changes to This Policy
|
||||||
|
|
||||||
|
If we update this policy:
|
||||||
|
- The "Last updated" date will change
|
||||||
|
- The updated policy will be included in the app
|
||||||
|
- No retroactive changes can affect data (since we don't collect any)
|
||||||
|
|
||||||
|
## Contact
|
||||||
|
|
||||||
|
bitchat is an open source project. For privacy questions:
|
||||||
|
- Review our code: https://github.com/yourusername/bitchat
|
||||||
|
- Open an issue on GitHub
|
||||||
|
- Join the discussion in public rooms
|
||||||
|
|
||||||
|
## Philosophy
|
||||||
|
|
||||||
|
Privacy isn't just a feature—it's the entire point. bitchat proves that modern communication doesn't require surrendering your privacy. No accounts, no servers, no surveillance. Just people talking freely.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*This policy is released into the public domain under The Unlicense, just like bitchat itself.*
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|

|
||||||
|
# bitchat
|
||||||
|
|
||||||
|
A secure, decentralized, peer-to-peer messaging app that works over Bluetooth mesh networks. No internet required, no servers, no phone numbers - just pure encrypted communication.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is released into the public domain. See the [LICENSE](LICENSE) file for details.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Decentralized Mesh Network**: Automatic peer discovery and multi-hop message relay over Bluetooth LE
|
||||||
|
- **End-to-End Encryption**: X25519 key exchange + AES-256-GCM for private messages
|
||||||
|
- **Channel-Based Chats**: Topic-based group messaging with optional password protection
|
||||||
|
- **Store & Forward**: Messages cached for offline peers and delivered when they reconnect
|
||||||
|
- **Privacy First**: No accounts, no phone numbers, no persistent identifiers
|
||||||
|
- **IRC-Style Commands**: Familiar `/join`, `/msg`, `/who` style interface
|
||||||
|
- **Message Retention**: Optional channel-wide message saving controlled by channel owners
|
||||||
|
- **Universal App**: Native support for iOS and macOS
|
||||||
|
- **Cover Traffic**: Timing obfuscation and dummy messages for enhanced privacy
|
||||||
|
- **Emergency Wipe**: Triple-tap to instantly clear all data
|
||||||
|
- **Performance Optimizations**: LZ4 message compression, adaptive battery modes, and optimized networking
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
### Option 1: Using XcodeGen (Recommended)
|
||||||
|
|
||||||
|
1. Install XcodeGen if you haven't already:
|
||||||
|
```bash
|
||||||
|
brew install xcodegen
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Generate the Xcode project:
|
||||||
|
```bash
|
||||||
|
cd bitchat
|
||||||
|
xcodegen generate
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Open the generated project:
|
||||||
|
```bash
|
||||||
|
open bitchat.xcodeproj
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: Using Swift Package Manager
|
||||||
|
|
||||||
|
1. Open the project in Xcode:
|
||||||
|
```bash
|
||||||
|
cd bitchat
|
||||||
|
open Package.swift
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Select your target device and run
|
||||||
|
|
||||||
|
### Option 3: Manual Xcode Project
|
||||||
|
|
||||||
|
1. Open Xcode and create a new iOS/macOS App
|
||||||
|
2. Copy all Swift files from the `bitchat` directory into your project
|
||||||
|
3. Update Info.plist with Bluetooth permissions
|
||||||
|
4. Set deployment target to iOS 16.0 / macOS 13.0
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Basic Commands
|
||||||
|
|
||||||
|
- `/j #channel` - Join or create a channel
|
||||||
|
- `/m @name message` - Send a private message
|
||||||
|
- `/w` - List online users
|
||||||
|
- `/channels` - Show all discovered channels
|
||||||
|
- `/block @name` - Block a peer from messaging you
|
||||||
|
- `/block` - List all blocked peers
|
||||||
|
- `/unblock @name` - Unblock a peer
|
||||||
|
- `/clear` - Clear chat messages
|
||||||
|
- `/pass [password]` - Set/change channel password (owner only)
|
||||||
|
- `/transfer @name` - Transfer channel ownership
|
||||||
|
- `/save` - Toggle message retention for channel (owner only)
|
||||||
|
|
||||||
|
### Getting Started
|
||||||
|
|
||||||
|
1. Launch bitchat on your device
|
||||||
|
2. Set your nickname (or use the auto-generated one)
|
||||||
|
3. You'll automatically connect to nearby peers
|
||||||
|
4. Join a channel with `/j #general` or start chatting in public
|
||||||
|
5. Messages relay through the mesh network to reach distant peers
|
||||||
|
|
||||||
|
### Channel Features
|
||||||
|
|
||||||
|
- **Password Protection**: Channel owners can set passwords with `/pass`
|
||||||
|
- **Message Retention**: Owners can enable mandatory message saving with `/save`
|
||||||
|
- **@ Mentions**: Use `@nickname` to mention users (with autocomplete)
|
||||||
|
- **Ownership Transfer**: Pass control to trusted users with `/transfer`
|
||||||
|
|
||||||
|
## Security & Privacy
|
||||||
|
|
||||||
|
### Encryption
|
||||||
|
- **Private Messages**: X25519 key exchange + AES-256-GCM encryption
|
||||||
|
- **Channel Messages**: Argon2id password derivation + AES-256-GCM
|
||||||
|
- **Digital Signatures**: Ed25519 for message authenticity
|
||||||
|
- **Forward Secrecy**: New key pairs generated each session
|
||||||
|
|
||||||
|
### Privacy Features
|
||||||
|
- **No Registration**: No accounts, emails, or phone numbers required
|
||||||
|
- **Ephemeral by Default**: Messages exist only in device memory
|
||||||
|
- **Cover Traffic**: Random delays and dummy messages prevent traffic analysis
|
||||||
|
- **Emergency Wipe**: Triple-tap logo to instantly clear all data
|
||||||
|
- **Local-First**: Works completely offline, no servers involved
|
||||||
|
|
||||||
|
## Performance & Efficiency
|
||||||
|
|
||||||
|
### Message Compression
|
||||||
|
- **LZ4 Compression**: Automatic compression for messages >100 bytes
|
||||||
|
- **30-70% bandwidth savings** on typical text messages
|
||||||
|
- **Smart compression**: Skips already-compressed data
|
||||||
|
|
||||||
|
### Battery Optimization
|
||||||
|
- **Adaptive Power Modes**: Automatically adjusts based on battery level
|
||||||
|
- Performance mode: Full features when charging or >60% battery
|
||||||
|
- Balanced mode: Default operation (30-60% battery)
|
||||||
|
- Power saver: Reduced scanning when <30% battery
|
||||||
|
- Ultra-low power: Emergency mode when <10% battery
|
||||||
|
- **Background efficiency**: Automatic power saving when app backgrounded
|
||||||
|
- **Configurable scanning**: Duty cycle adapts to battery state
|
||||||
|
|
||||||
|
### Network Efficiency
|
||||||
|
- **Optimized Bloom filters**: Faster duplicate detection with less memory
|
||||||
|
- **Message aggregation**: Batches small messages to reduce transmissions
|
||||||
|
- **Adaptive connection limits**: Adjusts peer connections based on power mode
|
||||||
|
|
||||||
|
## Technical Architecture
|
||||||
|
|
||||||
|
### Binary Protocol
|
||||||
|
bitchat uses an efficient binary protocol optimized for Bluetooth LE:
|
||||||
|
- Compact packet format with 1-byte type field
|
||||||
|
- TTL-based message routing (max 7 hops)
|
||||||
|
- Automatic fragmentation for large messages
|
||||||
|
- Message deduplication via unique IDs
|
||||||
|
|
||||||
|
### Mesh Networking
|
||||||
|
- Each device acts as both client and peripheral
|
||||||
|
- Automatic peer discovery and connection management
|
||||||
|
- Store-and-forward for offline message delivery
|
||||||
|
- Adaptive duty cycling for battery optimization
|
||||||
|
|
||||||
|
For detailed protocol documentation, see the [Technical Whitepaper](WHITEPAPER.md).
|
||||||
|
|
||||||
|
## Building for Production
|
||||||
|
|
||||||
|
1. Set your development team in project settings
|
||||||
|
2. Configure code signing
|
||||||
|
3. Archive and distribute through App Store or TestFlight
|
||||||
|
|
||||||
|
## Android Compatibility
|
||||||
|
|
||||||
|
The protocol is designed to be platform-agnostic. An Android client can be built using:
|
||||||
|
- Bluetooth LE APIs
|
||||||
|
- Same packet structure and encryption
|
||||||
|
- Compatible service/characteristic UUIDs
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
plugins {
|
||||||
|
id("com.android.application")
|
||||||
|
id("org.jetbrains.kotlin.android")
|
||||||
|
id("kotlin-parcelize")
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "com.bitchat.android"
|
||||||
|
compileSdk = 34
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "com.bitchat.android"
|
||||||
|
minSdk = 26 // API 26 for proper BLE support
|
||||||
|
targetSdk = 34
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
vectorDrawables {
|
||||||
|
useSupportLibrary = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
|
}
|
||||||
|
composeOptions {
|
||||||
|
kotlinCompilerExtensionVersion = "1.5.5"
|
||||||
|
}
|
||||||
|
packaging {
|
||||||
|
resources {
|
||||||
|
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lint {
|
||||||
|
baseline = file("lint-baseline.xml")
|
||||||
|
abortOnError = false
|
||||||
|
checkReleaseBuilds = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("androidx.core:core-ktx:1.12.0")
|
||||||
|
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
|
||||||
|
implementation("androidx.activity:activity-compose:1.8.2")
|
||||||
|
implementation(platform("androidx.compose:compose-bom:2023.10.01"))
|
||||||
|
implementation("androidx.compose.ui:ui")
|
||||||
|
implementation("androidx.compose.ui:ui-graphics")
|
||||||
|
implementation("androidx.compose.ui:ui-tooling-preview")
|
||||||
|
implementation("androidx.compose.material3:material3")
|
||||||
|
|
||||||
|
// AppCompat for theme support
|
||||||
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
||||||
|
|
||||||
|
// ViewModel and LiveData
|
||||||
|
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
|
||||||
|
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
|
||||||
|
implementation("androidx.compose.runtime:runtime-livedata")
|
||||||
|
|
||||||
|
// Navigation
|
||||||
|
implementation("androidx.navigation:navigation-compose:2.7.6")
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
implementation("com.google.accompanist:accompanist-permissions:0.32.0")
|
||||||
|
|
||||||
|
// Cryptography
|
||||||
|
implementation("org.bouncycastle:bcprov-jdk15on:1.70")
|
||||||
|
implementation("com.google.crypto.tink:tink-android:1.10.0")
|
||||||
|
|
||||||
|
// JSON
|
||||||
|
implementation("com.google.code.gson:gson:2.10.1")
|
||||||
|
|
||||||
|
// Coroutines
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
|
||||||
|
|
||||||
|
// Bluetooth
|
||||||
|
implementation("no.nordicsemi.android:ble:2.6.1")
|
||||||
|
|
||||||
|
// Compression
|
||||||
|
implementation("org.lz4:lz4-java:1.8.0")
|
||||||
|
|
||||||
|
// Security preferences
|
||||||
|
implementation("androidx.security:security-crypto:1.1.0-alpha06")
|
||||||
|
|
||||||
|
// Testing
|
||||||
|
testImplementation("junit:junit:4.13.2")
|
||||||
|
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
||||||
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
||||||
|
androidTestImplementation(platform("androidx.compose:compose-bom:2023.10.01"))
|
||||||
|
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
|
||||||
|
debugImplementation("androidx.compose.ui:ui-tooling")
|
||||||
|
debugImplementation("androidx.compose.ui:ui-test-manifest")
|
||||||
|
}
|
||||||
@@ -0,0 +1,598 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<issues format="6" by="lint 8.2.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.2.0)" variant="all" version="8.2.0">
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gatt.disconnect()"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="175"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gatt.close()"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="176"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gattServer?.close()"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="187"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gattServer?.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, null)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="268"
|
||||||
|
column="25"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gattServer?.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, null)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="296"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gattServer = bluetoothManager.openGattServer(context, serverCallback)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="301"
|
||||||
|
column="22"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gattServer?.addService(service)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="325"
|
||||||
|
column="9"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" bleAdvertiser?.startAdvertising(settings, data, advertiseCallback)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="384"
|
||||||
|
column="9"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" bleAdvertiser.startAdvertising(settings, data, scanResponse, advertiseCallback)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="429"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" bleAdvertiser.startAdvertising(settings, data, advertiseCallback)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="466"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" bleAdvertiser.stopAdvertising(object : AdvertiseCallback() {})"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="478"
|
||||||
|
column="9"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" bleScanner.startScan(listOf(scanFilter), scanSettings, scanCallback)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="526"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" bleScanner.stopScan(object : ScanCallback() {})"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="539"
|
||||||
|
column="9"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gatt.discoverServices()"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="626"
|
||||||
|
column="25"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gatt.close()"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="633"
|
||||||
|
column="25"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gatt.setCharacteristicNotification(characteristic, true)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="645"
|
||||||
|
column="25"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gatt.writeDescriptor(descriptor)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="652"
|
||||||
|
column="25"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" device.connectGatt(context, false, gattCallback)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="683"
|
||||||
|
column="9"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gattServer?.notifyCharacteristicChanged(device, characteristic, false)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="700"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" gatt.writeCharacteristic(characteristic)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="721"
|
||||||
|
column="17"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" val success = gattServer?.notifyCharacteristicChanged(device, char, false) ?: false"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="1135"
|
||||||
|
column="35"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingPermission"
|
||||||
|
message="Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with `checkPermission`) or explicitly handle a potential `SecurityException`"
|
||||||
|
errorLine1=" val success = gatt.writeCharacteristic(characteristic)"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt"
|
||||||
|
line="1153"
|
||||||
|
column="35"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="OldTargetApi"
|
||||||
|
message="Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details."
|
||||||
|
errorLine1=" targetSdk = 34"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="14"
|
||||||
|
column="9"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="RedundantLabel"
|
||||||
|
message="Redundant label can be removed"
|
||||||
|
errorLine1=" android:label="@string/app_name""
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/AndroidManifest.xml"
|
||||||
|
line="35"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.core:core-ktx than 1.12.0 is available: 1.16.0"
|
||||||
|
errorLine1=" implementation("androidx.core:core-ktx:1.12.0")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="59"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.lifecycle:lifecycle-runtime-ktx than 2.7.0 is available: 2.9.1"
|
||||||
|
errorLine1=" implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="60"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.activity:activity-compose than 1.8.2 is available: 1.10.1"
|
||||||
|
errorLine1=" implementation("androidx.activity:activity-compose:1.8.2")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="61"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.appcompat:appcompat than 1.6.1 is available: 1.7.1"
|
||||||
|
errorLine1=" implementation("androidx.appcompat:appcompat:1.6.1")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="69"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.lifecycle:lifecycle-viewmodel-compose than 2.7.0 is available: 2.9.1"
|
||||||
|
errorLine1=" implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="72"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.lifecycle:lifecycle-livedata-ktx than 2.7.0 is available: 2.9.1"
|
||||||
|
errorLine1=" implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="73"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.navigation:navigation-compose than 2.7.6 is available: 2.9.1"
|
||||||
|
errorLine1=" implementation("androidx.navigation:navigation-compose:2.7.6")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="77"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.security:security-crypto than 1.1.0-alpha06 is available: 1.1.0-beta01"
|
||||||
|
errorLine1=" implementation("androidx.security:security-crypto:1.1.0-alpha06")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="99"
|
||||||
|
column="21"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.test.ext:junit than 1.1.5 is available: 1.2.1"
|
||||||
|
errorLine1=" androidTestImplementation("androidx.test.ext:junit:1.1.5")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="103"
|
||||||
|
column="32"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="GradleDependency"
|
||||||
|
message="A newer version of androidx.test.espresso:espresso-core than 3.5.1 is available: 3.6.1"
|
||||||
|
errorLine1=" androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="build.gradle.kts"
|
||||||
|
line="104"
|
||||||
|
column="32"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="LockedOrientationActivity"
|
||||||
|
message="Expecting `android:screenOrientation="unspecified"` or `"fullSensor"` for this activity so the user can use the application in any orientation and provide a great experience on Chrome OS devices"
|
||||||
|
errorLine1=" android:screenOrientation="portrait""
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/AndroidManifest.xml"
|
||||||
|
line="37"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="StaticFieldLeak"
|
||||||
|
message="This field leaks a context object"
|
||||||
|
errorLine1=" private val context: Context = application.applicationContext"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/ui/ChatViewModel.kt"
|
||||||
|
line="30"
|
||||||
|
column="5"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="AutoboxingStateCreation"
|
||||||
|
message="Prefer `mutableIntStateOf` instead of `mutableStateOf`"
|
||||||
|
errorLine1=" var tripleClickCount by remember { mutableStateOf(0) }"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/ui/ChatScreen.kt"
|
||||||
|
line="62"
|
||||||
|
column="40"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.permission_bluetooth_rationale` appears to be unused"
|
||||||
|
errorLine1=" <string name="permission_bluetooth_rationale">Bluetooth permission is required for peer-to-peer messaging without internet.</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="4"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.permission_location_rationale` appears to be unused"
|
||||||
|
errorLine1=" <string name="permission_location_rationale">Location permission is required to discover nearby devices via Bluetooth.</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="5"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.permission_notification_rationale` appears to be unused"
|
||||||
|
errorLine1=" <string name="permission_notification_rationale">Notification permission is required to alert you of new messages.</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="6"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.nickname_hint` appears to be unused"
|
||||||
|
errorLine1=" <string name="nickname_hint">nickname</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="7"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.message_hint` appears to be unused"
|
||||||
|
errorLine1=" <string name="message_hint">type a message…</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="8"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.channel_password_hint` appears to be unused"
|
||||||
|
errorLine1=" <string name="channel_password_hint">Password</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="9"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.join_channel` appears to be unused"
|
||||||
|
errorLine1=" <string name="join_channel">Join Channel</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="10"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.leave_channel` appears to be unused"
|
||||||
|
errorLine1=" <string name="leave_channel">Leave</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="11"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.send_message` appears to be unused"
|
||||||
|
errorLine1=" <string name="send_message">Send</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="12"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.back` appears to be unused"
|
||||||
|
errorLine1=" <string name="back">Back</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="13"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.people` appears to be unused"
|
||||||
|
errorLine1=" <string name="people">People</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="14"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.channels` appears to be unused"
|
||||||
|
errorLine1=" <string name="channels">Channels</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="15"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.online_users` appears to be unused"
|
||||||
|
errorLine1=" <string name="online_users">Online Users</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="16"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.no_one_connected` appears to be unused"
|
||||||
|
errorLine1=" <string name="no_one_connected">No one connected</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="17"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="UnusedResources"
|
||||||
|
message="The resource `R.string.emergency_clear_hint` appears to be unused"
|
||||||
|
errorLine1=" <string name="emergency_clear_hint">Triple tap to clear all data</string>"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/res/values/strings.xml"
|
||||||
|
line="18"
|
||||||
|
column="13"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="MissingApplicationIcon"
|
||||||
|
message="Should explicitly set `android:icon`, there is no default"
|
||||||
|
errorLine1=" <application"
|
||||||
|
errorLine2=" ~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/AndroidManifest.xml"
|
||||||
|
line="23"
|
||||||
|
column="6"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
<issue
|
||||||
|
id="NullSafeMutableLiveData"
|
||||||
|
message="Expected non-nullable value"
|
||||||
|
errorLine1=" _nickname.value = savedNickname"
|
||||||
|
errorLine2=" ~~~~~~~~~~~~~">
|
||||||
|
<location
|
||||||
|
file="src/main/java/com/bitchat/android/ui/ChatViewModel.kt"
|
||||||
|
line="125"
|
||||||
|
column="31"/>
|
||||||
|
</issue>
|
||||||
|
|
||||||
|
</issues>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
-keep class com.bitchat.android.protocol.** { *; }
|
||||||
|
-keep class com.bitchat.android.crypto.** { *; }
|
||||||
|
-dontwarn org.bouncycastle.**
|
||||||
|
-keep class org.bouncycastle.** { *; }
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<!-- Bluetooth permissions -->
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||||
|
|
||||||
|
<!-- Location permission required for BLE scanning -->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
|
||||||
|
<!-- Notification permissions -->
|
||||||
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
|
||||||
|
<!-- Haptic feedback permission -->
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
|
||||||
|
<!-- Hardware features -->
|
||||||
|
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
|
||||||
|
<uses-feature android:name="android.hardware.bluetooth" android:required="true" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".BitchatApplication"
|
||||||
|
android:allowBackup="false"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.BitchatAndroid"
|
||||||
|
tools:targetApi="31">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:theme="@style/Theme.BitchatAndroid"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:launchMode="singleTop">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.bitchat.android
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main application class for bitchat Android
|
||||||
|
*/
|
||||||
|
class BitchatApplication : Application() {
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
|
||||||
|
// Initialize any global services or configurations
|
||||||
|
// For now, keep it simple
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package com.bitchat.android
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import com.bitchat.android.ui.ChatScreen
|
||||||
|
import com.bitchat.android.ui.ChatViewModel
|
||||||
|
import com.bitchat.android.ui.theme.BitchatTheme
|
||||||
|
|
||||||
|
class MainActivity : ComponentActivity() {
|
||||||
|
|
||||||
|
private val chatViewModel: ChatViewModel by viewModels()
|
||||||
|
|
||||||
|
private val permissionLauncher = registerForActivityResult(
|
||||||
|
ActivityResultContracts.RequestMultiplePermissions()
|
||||||
|
) { permissions ->
|
||||||
|
val allPermissionsGranted = permissions.values.all { it }
|
||||||
|
if (allPermissionsGranted) {
|
||||||
|
// Permissions granted, the mesh service should start automatically
|
||||||
|
} else {
|
||||||
|
// Handle permission denial
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
// Request necessary permissions
|
||||||
|
requestPermissions()
|
||||||
|
|
||||||
|
setContent {
|
||||||
|
BitchatTheme {
|
||||||
|
Surface(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
color = MaterialTheme.colorScheme.background
|
||||||
|
) {
|
||||||
|
ChatScreen(viewModel = chatViewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun requestPermissions() {
|
||||||
|
val permissions = mutableListOf<String>()
|
||||||
|
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
|
permissions.addAll(listOf(
|
||||||
|
Manifest.permission.BLUETOOTH_ADVERTISE,
|
||||||
|
Manifest.permission.BLUETOOTH_CONNECT,
|
||||||
|
Manifest.permission.BLUETOOTH_SCAN
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
permissions.addAll(listOf(
|
||||||
|
Manifest.permission.BLUETOOTH,
|
||||||
|
Manifest.permission.BLUETOOTH_ADMIN
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
permissions.addAll(listOf(
|
||||||
|
Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||||
|
Manifest.permission.ACCESS_FINE_LOCATION
|
||||||
|
))
|
||||||
|
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
permissions.add(Manifest.permission.POST_NOTIFICATIONS)
|
||||||
|
}
|
||||||
|
|
||||||
|
permissionLauncher.launch(permissions.toTypedArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
// FIXED: Ensure Bluetooth resources are cleaned up when the activity is destroyed
|
||||||
|
// This addresses the issue where stale Bluetooth advertisements interfere with
|
||||||
|
// restart discovery times. This is more reliable than relying solely on
|
||||||
|
// ChatViewModel.onCleared() which may not be called when the app is swiped away.
|
||||||
|
try {
|
||||||
|
chatViewModel.meshService.stopServices()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Log error, but don't crash the app on exit
|
||||||
|
android.util.Log.w("MainActivity", "Error stopping mesh services in onDestroy: ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,321 @@
|
|||||||
|
package com.bitchat.android.crypto
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.security.keystore.KeyGenParameterSpec
|
||||||
|
import android.security.keystore.KeyProperties
|
||||||
|
import org.bouncycastle.crypto.agreement.X25519Agreement
|
||||||
|
import org.bouncycastle.crypto.generators.Ed25519KeyPairGenerator
|
||||||
|
import org.bouncycastle.crypto.generators.X25519KeyPairGenerator
|
||||||
|
import org.bouncycastle.crypto.params.*
|
||||||
|
import org.bouncycastle.crypto.signers.Ed25519Signer
|
||||||
|
import org.bouncycastle.crypto.util.PrivateKeyFactory
|
||||||
|
import org.bouncycastle.crypto.util.PublicKeyFactory
|
||||||
|
import org.bouncycastle.jcajce.provider.digest.SHA256
|
||||||
|
import java.security.SecureRandom
|
||||||
|
import javax.crypto.Cipher
|
||||||
|
import javax.crypto.KeyGenerator
|
||||||
|
import javax.crypto.spec.GCMParameterSpec
|
||||||
|
import javax.crypto.spec.SecretKeySpec
|
||||||
|
import kotlin.experimental.and
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encryption service that's 100% compatible with iOS version
|
||||||
|
* Uses the same cryptographic algorithms and key derivation
|
||||||
|
*/
|
||||||
|
class EncryptionService(private val context: Context) {
|
||||||
|
|
||||||
|
// Key agreement keys for encryption
|
||||||
|
private val privateKey: X25519PrivateKeyParameters
|
||||||
|
private val publicKey: X25519PublicKeyParameters
|
||||||
|
|
||||||
|
// Signing keys for authentication
|
||||||
|
private val signingPrivateKey: Ed25519PrivateKeyParameters
|
||||||
|
private val signingPublicKey: Ed25519PublicKeyParameters
|
||||||
|
|
||||||
|
// Persistent identity for favorites (separate from ephemeral keys)
|
||||||
|
private lateinit var identityKey: Ed25519PrivateKeyParameters
|
||||||
|
private lateinit var identityPublicKey: Ed25519PublicKeyParameters
|
||||||
|
|
||||||
|
// Storage for peer keys
|
||||||
|
private val peerPublicKeys = mutableMapOf<String, X25519PublicKeyParameters>()
|
||||||
|
private val peerSigningKeys = mutableMapOf<String, Ed25519PublicKeyParameters>()
|
||||||
|
private val peerIdentityKeys = mutableMapOf<String, Ed25519PublicKeyParameters>()
|
||||||
|
private val sharedSecrets = mutableMapOf<String, ByteArray>()
|
||||||
|
|
||||||
|
private val prefs: SharedPreferences = context.getSharedPreferences("bitchat_crypto", Context.MODE_PRIVATE)
|
||||||
|
private val secureRandom = SecureRandom()
|
||||||
|
|
||||||
|
init {
|
||||||
|
// Generate ephemeral key pairs for this session
|
||||||
|
val x25519Generator = X25519KeyPairGenerator()
|
||||||
|
x25519Generator.init(X25519KeyGenerationParameters(secureRandom))
|
||||||
|
val x25519KeyPair = x25519Generator.generateKeyPair()
|
||||||
|
privateKey = x25519KeyPair.private as X25519PrivateKeyParameters
|
||||||
|
publicKey = x25519KeyPair.public as X25519PublicKeyParameters
|
||||||
|
|
||||||
|
val ed25519Generator = Ed25519KeyPairGenerator()
|
||||||
|
ed25519Generator.init(Ed25519KeyGenerationParameters(secureRandom))
|
||||||
|
val ed25519KeyPair = ed25519Generator.generateKeyPair()
|
||||||
|
signingPrivateKey = ed25519KeyPair.private as Ed25519PrivateKeyParameters
|
||||||
|
signingPublicKey = ed25519KeyPair.public as Ed25519PublicKeyParameters
|
||||||
|
|
||||||
|
// Load or create persistent identity key
|
||||||
|
val identityKeyBytes = prefs.getString("identity_key", null)
|
||||||
|
if (identityKeyBytes != null) {
|
||||||
|
try {
|
||||||
|
val keyBytes = android.util.Base64.decode(identityKeyBytes, android.util.Base64.DEFAULT)
|
||||||
|
identityKey = Ed25519PrivateKeyParameters(keyBytes, 0)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// Create new identity key if loading fails
|
||||||
|
val newIdentityKeyPair = ed25519Generator.generateKeyPair()
|
||||||
|
identityKey = newIdentityKeyPair.private as Ed25519PrivateKeyParameters
|
||||||
|
saveIdentityKey()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// First run - create and save identity key
|
||||||
|
val newIdentityKeyPair = ed25519Generator.generateKeyPair()
|
||||||
|
identityKey = newIdentityKeyPair.private as Ed25519PrivateKeyParameters
|
||||||
|
saveIdentityKey()
|
||||||
|
}
|
||||||
|
identityPublicKey = Ed25519PublicKeyParameters(identityKey.encoded, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun saveIdentityKey() {
|
||||||
|
val keyBytes = android.util.Base64.encodeToString(identityKey.encoded, android.util.Base64.DEFAULT)
|
||||||
|
prefs.edit().putString("identity_key", keyBytes).apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create combined public key data for exchange - exactly same format as iOS
|
||||||
|
* 96 bytes total: 32 (X25519) + 32 (Ed25519 signing) + 32 (Ed25519 identity)
|
||||||
|
*/
|
||||||
|
fun getCombinedPublicKeyData(): ByteArray {
|
||||||
|
val combined = ByteArray(96)
|
||||||
|
System.arraycopy(publicKey.encoded, 0, combined, 0, 32) // X25519 key
|
||||||
|
System.arraycopy(signingPublicKey.encoded, 0, combined, 32, 32) // Ed25519 signing key
|
||||||
|
System.arraycopy(identityPublicKey.encoded, 0, combined, 64, 32) // Ed25519 identity key
|
||||||
|
return combined
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add peer's combined public keys - exactly same logic as iOS
|
||||||
|
*/
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun addPeerPublicKey(peerID: String, publicKeyData: ByteArray) {
|
||||||
|
if (publicKeyData.size != 96) {
|
||||||
|
throw Exception("Invalid public key data size: ${publicKeyData.size}, expected 96")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract all three keys: 32 for key agreement + 32 for signing + 32 for identity
|
||||||
|
val keyAgreementData = publicKeyData.sliceArray(0..31)
|
||||||
|
val signingKeyData = publicKeyData.sliceArray(32..63)
|
||||||
|
val identityKeyData = publicKeyData.sliceArray(64..95)
|
||||||
|
|
||||||
|
val peerPublicKey = X25519PublicKeyParameters(keyAgreementData, 0)
|
||||||
|
peerPublicKeys[peerID] = peerPublicKey
|
||||||
|
|
||||||
|
val peerSigningKey = Ed25519PublicKeyParameters(signingKeyData, 0)
|
||||||
|
peerSigningKeys[peerID] = peerSigningKey
|
||||||
|
|
||||||
|
val peerIdentityKey = Ed25519PublicKeyParameters(identityKeyData, 0)
|
||||||
|
peerIdentityKeys[peerID] = peerIdentityKey
|
||||||
|
|
||||||
|
// Generate shared secret for encryption using X25519
|
||||||
|
val agreement = X25519Agreement()
|
||||||
|
agreement.init(privateKey)
|
||||||
|
val sharedSecret = ByteArray(32)
|
||||||
|
agreement.calculateAgreement(peerPublicKey, sharedSecret, 0)
|
||||||
|
|
||||||
|
// Derive symmetric key using HKDF with same salt as iOS
|
||||||
|
val salt = "bitchat-v1".toByteArray()
|
||||||
|
val derivedKey = hkdf(sharedSecret, salt, byteArrayOf(), 32)
|
||||||
|
sharedSecrets[peerID] = derivedKey
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get peer's persistent identity key for favorites
|
||||||
|
*/
|
||||||
|
fun getPeerIdentityKey(peerID: String): ByteArray? {
|
||||||
|
return peerIdentityKeys[peerID]?.encoded
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear persistent identity (for panic mode)
|
||||||
|
*/
|
||||||
|
fun clearPersistentIdentity() {
|
||||||
|
prefs.edit().remove("identity_key").apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encrypt data for a specific peer using AES-256-GCM
|
||||||
|
*/
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun encrypt(data: ByteArray, peerID: String): ByteArray {
|
||||||
|
val symmetricKey = sharedSecrets[peerID]
|
||||||
|
?: throw Exception("No shared secret for peer $peerID")
|
||||||
|
|
||||||
|
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
|
||||||
|
val keySpec = SecretKeySpec(symmetricKey, "AES")
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, keySpec)
|
||||||
|
|
||||||
|
val iv = cipher.iv
|
||||||
|
val ciphertext = cipher.doFinal(data)
|
||||||
|
|
||||||
|
// Combine IV and ciphertext (same format as iOS AES.GCM.SealedBox.combined)
|
||||||
|
val combined = ByteArray(iv.size + ciphertext.size)
|
||||||
|
System.arraycopy(iv, 0, combined, 0, iv.size)
|
||||||
|
System.arraycopy(ciphertext, 0, combined, iv.size, ciphertext.size)
|
||||||
|
|
||||||
|
return combined
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypt data from a specific peer
|
||||||
|
*/
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun decrypt(data: ByteArray, peerID: String): ByteArray {
|
||||||
|
val symmetricKey = sharedSecrets[peerID]
|
||||||
|
?: throw Exception("No shared secret for peer $peerID")
|
||||||
|
|
||||||
|
if (data.size < 16) { // 12 bytes IV + 16 bytes tag minimum for GCM
|
||||||
|
throw Exception("Invalid encrypted data size")
|
||||||
|
}
|
||||||
|
|
||||||
|
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
|
||||||
|
val keySpec = SecretKeySpec(symmetricKey, "AES")
|
||||||
|
|
||||||
|
// Extract IV and ciphertext
|
||||||
|
val iv = data.sliceArray(0..11) // GCM IV is 12 bytes
|
||||||
|
val ciphertext = data.sliceArray(12 until data.size)
|
||||||
|
|
||||||
|
val gcmSpec = GCMParameterSpec(128, iv) // 128-bit authentication tag
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE, keySpec, gcmSpec)
|
||||||
|
|
||||||
|
return cipher.doFinal(ciphertext)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sign data using Ed25519
|
||||||
|
*/
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun sign(data: ByteArray): ByteArray {
|
||||||
|
val signer = Ed25519Signer()
|
||||||
|
signer.init(true, signingPrivateKey)
|
||||||
|
signer.update(data, 0, data.size)
|
||||||
|
return signer.generateSignature()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify signature using Ed25519
|
||||||
|
*/
|
||||||
|
@Throws(Exception::class)
|
||||||
|
fun verify(signature: ByteArray, data: ByteArray, peerID: String): Boolean {
|
||||||
|
val verifyingKey = peerSigningKeys[peerID]
|
||||||
|
?: throw Exception("No signing key for peer $peerID")
|
||||||
|
|
||||||
|
val signer = Ed25519Signer()
|
||||||
|
signer.init(false, verifyingKey)
|
||||||
|
signer.update(data, 0, data.size)
|
||||||
|
return signer.verifySignature(signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HKDF implementation using SHA256 - same as iOS HKDF
|
||||||
|
*/
|
||||||
|
private fun hkdf(ikm: ByteArray, salt: ByteArray, info: ByteArray, length: Int): ByteArray {
|
||||||
|
// Extract
|
||||||
|
val hmac = javax.crypto.Mac.getInstance("HmacSHA256")
|
||||||
|
val saltKey = SecretKeySpec(if (salt.isEmpty()) ByteArray(32) else salt, "HmacSHA256")
|
||||||
|
hmac.init(saltKey)
|
||||||
|
val prk = hmac.doFinal(ikm)
|
||||||
|
|
||||||
|
// Expand
|
||||||
|
hmac.init(SecretKeySpec(prk, "HmacSHA256"))
|
||||||
|
val result = ByteArray(length)
|
||||||
|
var offset = 0
|
||||||
|
var counter = 1
|
||||||
|
|
||||||
|
while (offset < length) {
|
||||||
|
hmac.reset()
|
||||||
|
if (counter > 1) {
|
||||||
|
hmac.update(result, offset - 32, 32)
|
||||||
|
}
|
||||||
|
hmac.update(info)
|
||||||
|
hmac.update(counter.toByte())
|
||||||
|
|
||||||
|
val t = hmac.doFinal()
|
||||||
|
val remaining = length - offset
|
||||||
|
val toCopy = minOf(t.size, remaining)
|
||||||
|
System.arraycopy(t, 0, result, offset, toCopy)
|
||||||
|
|
||||||
|
offset += toCopy
|
||||||
|
counter++
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message padding utilities - exact same as iOS version
|
||||||
|
*/
|
||||||
|
object MessagePadding {
|
||||||
|
// Standard block sizes for padding
|
||||||
|
private val blockSizes = listOf(256, 512, 1024, 2048)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add PKCS#7-style padding to reach target size
|
||||||
|
*/
|
||||||
|
fun pad(data: ByteArray, targetSize: Int): ByteArray {
|
||||||
|
if (data.size >= targetSize) return data
|
||||||
|
|
||||||
|
val paddingNeeded = targetSize - data.size
|
||||||
|
|
||||||
|
// PKCS#7 only supports padding up to 255 bytes
|
||||||
|
if (paddingNeeded > 255) return data
|
||||||
|
|
||||||
|
val padded = ByteArray(targetSize)
|
||||||
|
System.arraycopy(data, 0, padded, 0, data.size)
|
||||||
|
|
||||||
|
// Fill with random bytes except the last byte
|
||||||
|
val random = SecureRandom()
|
||||||
|
random.nextBytes(padded.sliceArray(data.size until targetSize - 1))
|
||||||
|
|
||||||
|
// Last byte indicates padding length (PKCS#7)
|
||||||
|
padded[targetSize - 1] = paddingNeeded.toByte()
|
||||||
|
|
||||||
|
return padded
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove padding from data
|
||||||
|
*/
|
||||||
|
fun unpad(data: ByteArray): ByteArray {
|
||||||
|
if (data.isEmpty()) return data
|
||||||
|
|
||||||
|
// Last byte tells us how much padding to remove
|
||||||
|
val paddingLength = (data.last() and 0xFF.toByte()).toInt()
|
||||||
|
if (paddingLength <= 0 || paddingLength > data.size) return data
|
||||||
|
|
||||||
|
return data.sliceArray(0 until (data.size - paddingLength))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find optimal block size for data
|
||||||
|
*/
|
||||||
|
fun optimalBlockSize(dataSize: Int): Int {
|
||||||
|
// Account for encryption overhead (~16 bytes for AES-GCM tag)
|
||||||
|
val totalSize = dataSize + 16
|
||||||
|
|
||||||
|
// Find smallest block that fits
|
||||||
|
for (blockSize in blockSizes) {
|
||||||
|
if (totalSize <= blockSize) {
|
||||||
|
return blockSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// For very large messages, just use the original size
|
||||||
|
return dataSize
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,407 @@
|
|||||||
|
package com.bitchat.android.model
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import java.nio.ByteBuffer
|
||||||
|
import java.nio.ByteOrder
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delivery status for messages - exact same as iOS version
|
||||||
|
*/
|
||||||
|
sealed class DeliveryStatus : Parcelable {
|
||||||
|
@Parcelize
|
||||||
|
object Sending : DeliveryStatus()
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
object Sent : DeliveryStatus()
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class Delivered(val to: String, val at: Date) : DeliveryStatus()
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class Read(val by: String, val at: Date) : DeliveryStatus()
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class Failed(val reason: String) : DeliveryStatus()
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data class PartiallyDelivered(val reached: Int, val total: Int) : DeliveryStatus()
|
||||||
|
|
||||||
|
fun getDisplayText(): String {
|
||||||
|
return when (this) {
|
||||||
|
is Sending -> "Sending..."
|
||||||
|
is Sent -> "Sent"
|
||||||
|
is Delivered -> "Delivered to ${this.to}"
|
||||||
|
is Read -> "Read by ${this.by}"
|
||||||
|
is Failed -> "Failed: ${this.reason}"
|
||||||
|
is PartiallyDelivered -> "Delivered to ${this.reached}/${this.total}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BitchatMessage - 100% compatible with iOS version
|
||||||
|
*/
|
||||||
|
@Parcelize
|
||||||
|
data class BitchatMessage(
|
||||||
|
val id: String = UUID.randomUUID().toString(),
|
||||||
|
val sender: String,
|
||||||
|
val content: String,
|
||||||
|
val timestamp: Date,
|
||||||
|
val isRelay: Boolean = false,
|
||||||
|
val originalSender: String? = null,
|
||||||
|
val isPrivate: Boolean = false,
|
||||||
|
val recipientNickname: String? = null,
|
||||||
|
val senderPeerID: String? = null,
|
||||||
|
val mentions: List<String>? = null,
|
||||||
|
val channel: String? = null,
|
||||||
|
val encryptedContent: ByteArray? = null,
|
||||||
|
val isEncrypted: Boolean = false,
|
||||||
|
val deliveryStatus: DeliveryStatus? = null
|
||||||
|
) : Parcelable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert message to binary payload format - exactly same as iOS version
|
||||||
|
*/
|
||||||
|
fun toBinaryPayload(): ByteArray? {
|
||||||
|
try {
|
||||||
|
val buffer = ByteBuffer.allocate(4096).apply { order(ByteOrder.BIG_ENDIAN) }
|
||||||
|
|
||||||
|
// Message format:
|
||||||
|
// - Flags: 1 byte (bit flags for optional fields)
|
||||||
|
// - Timestamp: 8 bytes (milliseconds since epoch, big-endian)
|
||||||
|
// - ID length: 1 byte + ID data
|
||||||
|
// - Sender length: 1 byte + sender data
|
||||||
|
// - Content length: 2 bytes + content data (or encrypted content)
|
||||||
|
// Optional fields based on flags...
|
||||||
|
|
||||||
|
var flags: UByte = 0u
|
||||||
|
if (isRelay) flags = flags or 0x01u
|
||||||
|
if (isPrivate) flags = flags or 0x02u
|
||||||
|
if (originalSender != null) flags = flags or 0x04u
|
||||||
|
if (recipientNickname != null) flags = flags or 0x08u
|
||||||
|
if (senderPeerID != null) flags = flags or 0x10u
|
||||||
|
if (mentions != null && mentions.isNotEmpty()) flags = flags or 0x20u
|
||||||
|
if (channel != null) flags = flags or 0x40u
|
||||||
|
if (isEncrypted) flags = flags or 0x80u
|
||||||
|
|
||||||
|
buffer.put(flags.toByte())
|
||||||
|
|
||||||
|
// Timestamp (in milliseconds, 8 bytes big-endian)
|
||||||
|
val timestampMillis = timestamp.time
|
||||||
|
buffer.putLong(timestampMillis)
|
||||||
|
|
||||||
|
// ID
|
||||||
|
val idBytes = id.toByteArray(Charsets.UTF_8)
|
||||||
|
buffer.put(minOf(idBytes.size, 255).toByte())
|
||||||
|
buffer.put(idBytes.take(255).toByteArray())
|
||||||
|
|
||||||
|
// Sender
|
||||||
|
val senderBytes = sender.toByteArray(Charsets.UTF_8)
|
||||||
|
buffer.put(minOf(senderBytes.size, 255).toByte())
|
||||||
|
buffer.put(senderBytes.take(255).toByteArray())
|
||||||
|
|
||||||
|
// Content or encrypted content
|
||||||
|
if (isEncrypted && encryptedContent != null) {
|
||||||
|
val length = minOf(encryptedContent.size, 65535)
|
||||||
|
buffer.putShort(length.toShort())
|
||||||
|
buffer.put(encryptedContent.take(length).toByteArray())
|
||||||
|
} else {
|
||||||
|
val contentBytes = content.toByteArray(Charsets.UTF_8)
|
||||||
|
val length = minOf(contentBytes.size, 65535)
|
||||||
|
buffer.putShort(length.toShort())
|
||||||
|
buffer.put(contentBytes.take(length).toByteArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional fields
|
||||||
|
originalSender?.let { origSender ->
|
||||||
|
val origBytes = origSender.toByteArray(Charsets.UTF_8)
|
||||||
|
buffer.put(minOf(origBytes.size, 255).toByte())
|
||||||
|
buffer.put(origBytes.take(255).toByteArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
recipientNickname?.let { recipient ->
|
||||||
|
val recipBytes = recipient.toByteArray(Charsets.UTF_8)
|
||||||
|
buffer.put(minOf(recipBytes.size, 255).toByte())
|
||||||
|
buffer.put(recipBytes.take(255).toByteArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
senderPeerID?.let { peerID ->
|
||||||
|
val peerBytes = peerID.toByteArray(Charsets.UTF_8)
|
||||||
|
buffer.put(minOf(peerBytes.size, 255).toByte())
|
||||||
|
buffer.put(peerBytes.take(255).toByteArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mentions array
|
||||||
|
mentions?.let { mentionList ->
|
||||||
|
buffer.put(minOf(mentionList.size, 255).toByte())
|
||||||
|
mentionList.take(255).forEach { mention ->
|
||||||
|
val mentionBytes = mention.toByteArray(Charsets.UTF_8)
|
||||||
|
buffer.put(minOf(mentionBytes.size, 255).toByte())
|
||||||
|
buffer.put(mentionBytes.take(255).toByteArray())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Channel hashtag
|
||||||
|
channel?.let { channelName ->
|
||||||
|
val channelBytes = channelName.toByteArray(Charsets.UTF_8)
|
||||||
|
buffer.put(minOf(channelBytes.size, 255).toByte())
|
||||||
|
buffer.put(channelBytes.take(255).toByteArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
val result = ByteArray(buffer.position())
|
||||||
|
buffer.rewind()
|
||||||
|
buffer.get(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/**
|
||||||
|
* Parse message from binary payload - exactly same logic as iOS version
|
||||||
|
*/
|
||||||
|
fun fromBinaryPayload(data: ByteArray): BitchatMessage? {
|
||||||
|
try {
|
||||||
|
if (data.size < 13) return null
|
||||||
|
|
||||||
|
val buffer = ByteBuffer.wrap(data).apply { order(ByteOrder.BIG_ENDIAN) }
|
||||||
|
|
||||||
|
// Flags
|
||||||
|
val flags = buffer.get().toUByte()
|
||||||
|
val isRelay = (flags and 0x01u) != 0u.toUByte()
|
||||||
|
val isPrivate = (flags and 0x02u) != 0u.toUByte()
|
||||||
|
val hasOriginalSender = (flags and 0x04u) != 0u.toUByte()
|
||||||
|
val hasRecipientNickname = (flags and 0x08u) != 0u.toUByte()
|
||||||
|
val hasSenderPeerID = (flags and 0x10u) != 0u.toUByte()
|
||||||
|
val hasMentions = (flags and 0x20u) != 0u.toUByte()
|
||||||
|
val hasChannel = (flags and 0x40u) != 0u.toUByte()
|
||||||
|
val isEncrypted = (flags and 0x80u) != 0u.toUByte()
|
||||||
|
|
||||||
|
// Timestamp
|
||||||
|
val timestampMillis = buffer.getLong()
|
||||||
|
val timestamp = Date(timestampMillis)
|
||||||
|
|
||||||
|
// ID
|
||||||
|
val idLength = buffer.get().toInt() and 0xFF
|
||||||
|
if (buffer.remaining() < idLength) return null
|
||||||
|
val idBytes = ByteArray(idLength)
|
||||||
|
buffer.get(idBytes)
|
||||||
|
val id = String(idBytes, Charsets.UTF_8)
|
||||||
|
|
||||||
|
// Sender
|
||||||
|
val senderLength = buffer.get().toInt() and 0xFF
|
||||||
|
if (buffer.remaining() < senderLength) return null
|
||||||
|
val senderBytes = ByteArray(senderLength)
|
||||||
|
buffer.get(senderBytes)
|
||||||
|
val sender = String(senderBytes, Charsets.UTF_8)
|
||||||
|
|
||||||
|
// Content
|
||||||
|
val contentLength = buffer.getShort().toInt() and 0xFFFF
|
||||||
|
if (buffer.remaining() < contentLength) return null
|
||||||
|
|
||||||
|
val content: String
|
||||||
|
val encryptedContent: ByteArray?
|
||||||
|
|
||||||
|
if (isEncrypted) {
|
||||||
|
val encryptedBytes = ByteArray(contentLength)
|
||||||
|
buffer.get(encryptedBytes)
|
||||||
|
encryptedContent = encryptedBytes
|
||||||
|
content = "" // Empty placeholder
|
||||||
|
} else {
|
||||||
|
val contentBytes = ByteArray(contentLength)
|
||||||
|
buffer.get(contentBytes)
|
||||||
|
content = String(contentBytes, Charsets.UTF_8)
|
||||||
|
encryptedContent = null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional fields
|
||||||
|
val originalSender = if (hasOriginalSender && buffer.hasRemaining()) {
|
||||||
|
val length = buffer.get().toInt() and 0xFF
|
||||||
|
if (buffer.remaining() >= length) {
|
||||||
|
val bytes = ByteArray(length)
|
||||||
|
buffer.get(bytes)
|
||||||
|
String(bytes, Charsets.UTF_8)
|
||||||
|
} else null
|
||||||
|
} else null
|
||||||
|
|
||||||
|
val recipientNickname = if (hasRecipientNickname && buffer.hasRemaining()) {
|
||||||
|
val length = buffer.get().toInt() and 0xFF
|
||||||
|
if (buffer.remaining() >= length) {
|
||||||
|
val bytes = ByteArray(length)
|
||||||
|
buffer.get(bytes)
|
||||||
|
String(bytes, Charsets.UTF_8)
|
||||||
|
} else null
|
||||||
|
} else null
|
||||||
|
|
||||||
|
val senderPeerID = if (hasSenderPeerID && buffer.hasRemaining()) {
|
||||||
|
val length = buffer.get().toInt() and 0xFF
|
||||||
|
if (buffer.remaining() >= length) {
|
||||||
|
val bytes = ByteArray(length)
|
||||||
|
buffer.get(bytes)
|
||||||
|
String(bytes, Charsets.UTF_8)
|
||||||
|
} else null
|
||||||
|
} else null
|
||||||
|
|
||||||
|
// Mentions array
|
||||||
|
val mentions = if (hasMentions && buffer.hasRemaining()) {
|
||||||
|
val mentionCount = buffer.get().toInt() and 0xFF
|
||||||
|
val mentionList = mutableListOf<String>()
|
||||||
|
repeat(mentionCount) {
|
||||||
|
if (buffer.hasRemaining()) {
|
||||||
|
val length = buffer.get().toInt() and 0xFF
|
||||||
|
if (buffer.remaining() >= length) {
|
||||||
|
val bytes = ByteArray(length)
|
||||||
|
buffer.get(bytes)
|
||||||
|
mentionList.add(String(bytes, Charsets.UTF_8))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mentionList.isNotEmpty()) mentionList else null
|
||||||
|
} else null
|
||||||
|
|
||||||
|
// Channel
|
||||||
|
val channel = if (hasChannel && buffer.hasRemaining()) {
|
||||||
|
val length = buffer.get().toInt() and 0xFF
|
||||||
|
if (buffer.remaining() >= length) {
|
||||||
|
val bytes = ByteArray(length)
|
||||||
|
buffer.get(bytes)
|
||||||
|
String(bytes, Charsets.UTF_8)
|
||||||
|
} else null
|
||||||
|
} else null
|
||||||
|
|
||||||
|
return BitchatMessage(
|
||||||
|
id = id,
|
||||||
|
sender = sender,
|
||||||
|
content = content,
|
||||||
|
timestamp = timestamp,
|
||||||
|
isRelay = isRelay,
|
||||||
|
originalSender = originalSender,
|
||||||
|
isPrivate = isPrivate,
|
||||||
|
recipientNickname = recipientNickname,
|
||||||
|
senderPeerID = senderPeerID,
|
||||||
|
mentions = mentions,
|
||||||
|
channel = channel,
|
||||||
|
encryptedContent = encryptedContent,
|
||||||
|
isEncrypted = isEncrypted
|
||||||
|
)
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as BitchatMessage
|
||||||
|
|
||||||
|
if (id != other.id) return false
|
||||||
|
if (sender != other.sender) return false
|
||||||
|
if (content != other.content) return false
|
||||||
|
if (timestamp != other.timestamp) return false
|
||||||
|
if (isRelay != other.isRelay) return false
|
||||||
|
if (originalSender != other.originalSender) return false
|
||||||
|
if (isPrivate != other.isPrivate) return false
|
||||||
|
if (recipientNickname != other.recipientNickname) return false
|
||||||
|
if (senderPeerID != other.senderPeerID) return false
|
||||||
|
if (mentions != other.mentions) return false
|
||||||
|
if (channel != other.channel) return false
|
||||||
|
if (encryptedContent != null) {
|
||||||
|
if (other.encryptedContent == null) return false
|
||||||
|
if (!encryptedContent.contentEquals(other.encryptedContent)) return false
|
||||||
|
} else if (other.encryptedContent != null) return false
|
||||||
|
if (isEncrypted != other.isEncrypted) return false
|
||||||
|
if (deliveryStatus != other.deliveryStatus) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = id.hashCode()
|
||||||
|
result = 31 * result + sender.hashCode()
|
||||||
|
result = 31 * result + content.hashCode()
|
||||||
|
result = 31 * result + timestamp.hashCode()
|
||||||
|
result = 31 * result + isRelay.hashCode()
|
||||||
|
result = 31 * result + (originalSender?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + isPrivate.hashCode()
|
||||||
|
result = 31 * result + (recipientNickname?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (senderPeerID?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (mentions?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (channel?.hashCode() ?: 0)
|
||||||
|
result = 31 * result + (encryptedContent?.contentHashCode() ?: 0)
|
||||||
|
result = 31 * result + isEncrypted.hashCode()
|
||||||
|
result = 31 * result + (deliveryStatus?.hashCode() ?: 0)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delivery acknowledgment structure - exact same as iOS version
|
||||||
|
*/
|
||||||
|
@Parcelize
|
||||||
|
data class DeliveryAck(
|
||||||
|
val originalMessageID: String,
|
||||||
|
val ackID: String = UUID.randomUUID().toString(),
|
||||||
|
val recipientID: String,
|
||||||
|
val recipientNickname: String,
|
||||||
|
val timestamp: Date = Date(),
|
||||||
|
val hopCount: UByte
|
||||||
|
) : Parcelable {
|
||||||
|
|
||||||
|
fun encode(): ByteArray? {
|
||||||
|
return try {
|
||||||
|
com.google.gson.Gson().toJson(this).toByteArray(Charsets.UTF_8)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun decode(data: ByteArray): DeliveryAck? {
|
||||||
|
return try {
|
||||||
|
val json = String(data, Charsets.UTF_8)
|
||||||
|
com.google.gson.Gson().fromJson(json, DeliveryAck::class.java)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read receipt structure - exact same as iOS version
|
||||||
|
*/
|
||||||
|
@Parcelize
|
||||||
|
data class ReadReceipt(
|
||||||
|
val originalMessageID: String,
|
||||||
|
val receiptID: String = UUID.randomUUID().toString(),
|
||||||
|
val readerID: String,
|
||||||
|
val readerNickname: String,
|
||||||
|
val timestamp: Date = Date()
|
||||||
|
) : Parcelable {
|
||||||
|
|
||||||
|
fun encode(): ByteArray? {
|
||||||
|
return try {
|
||||||
|
com.google.gson.Gson().toJson(this).toByteArray(Charsets.UTF_8)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun decode(data: ByteArray): ReadReceipt? {
|
||||||
|
return try {
|
||||||
|
val json = String(data, Charsets.UTF_8)
|
||||||
|
com.google.gson.Gson().fromJson(json, ReadReceipt::class.java)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,334 @@
|
|||||||
|
package com.bitchat.android.protocol
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import java.nio.ByteBuffer
|
||||||
|
import java.nio.ByteOrder
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message types - exact same as iOS version
|
||||||
|
*/
|
||||||
|
enum class MessageType(val value: UByte) {
|
||||||
|
ANNOUNCE(0x01u),
|
||||||
|
KEY_EXCHANGE(0x02u),
|
||||||
|
LEAVE(0x03u),
|
||||||
|
MESSAGE(0x04u),
|
||||||
|
FRAGMENT_START(0x05u),
|
||||||
|
FRAGMENT_CONTINUE(0x06u),
|
||||||
|
FRAGMENT_END(0x07u),
|
||||||
|
CHANNEL_ANNOUNCE(0x08u),
|
||||||
|
CHANNEL_RETENTION(0x09u),
|
||||||
|
DELIVERY_ACK(0x0Au),
|
||||||
|
DELIVERY_STATUS_REQUEST(0x0Bu),
|
||||||
|
READ_RECEIPT(0x0Cu);
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun fromValue(value: UByte): MessageType? {
|
||||||
|
return values().find { it.value == value }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special recipient IDs - exact same as iOS version
|
||||||
|
*/
|
||||||
|
object SpecialRecipients {
|
||||||
|
val BROADCAST = ByteArray(8) { 0xFF.toByte() } // All 0xFF = broadcast
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binary packet format - 100% compatible with iOS version
|
||||||
|
*
|
||||||
|
* Header (Fixed 13 bytes):
|
||||||
|
* - Version: 1 byte
|
||||||
|
* - Type: 1 byte
|
||||||
|
* - TTL: 1 byte
|
||||||
|
* - Timestamp: 8 bytes (UInt64, big-endian)
|
||||||
|
* - Flags: 1 byte (bit 0: hasRecipient, bit 1: hasSignature, bit 2: isCompressed)
|
||||||
|
* - PayloadLength: 2 bytes (UInt16, big-endian)
|
||||||
|
*
|
||||||
|
* Variable sections:
|
||||||
|
* - SenderID: 8 bytes (fixed)
|
||||||
|
* - RecipientID: 8 bytes (if hasRecipient flag set)
|
||||||
|
* - Payload: Variable length (includes original size if compressed)
|
||||||
|
* - Signature: 64 bytes (if hasSignature flag set)
|
||||||
|
*/
|
||||||
|
@Parcelize
|
||||||
|
data class BitchatPacket(
|
||||||
|
val version: UByte = 1u,
|
||||||
|
val type: UByte,
|
||||||
|
val senderID: ByteArray,
|
||||||
|
val recipientID: ByteArray? = null,
|
||||||
|
val timestamp: ULong,
|
||||||
|
val payload: ByteArray,
|
||||||
|
val signature: ByteArray? = null,
|
||||||
|
var ttl: UByte
|
||||||
|
) : Parcelable {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
type: UByte,
|
||||||
|
ttl: UByte,
|
||||||
|
senderID: String,
|
||||||
|
payload: ByteArray
|
||||||
|
) : this(
|
||||||
|
version = 1u,
|
||||||
|
type = type,
|
||||||
|
senderID = senderID.toByteArray(),
|
||||||
|
recipientID = null,
|
||||||
|
timestamp = (System.currentTimeMillis()).toULong(),
|
||||||
|
payload = payload,
|
||||||
|
signature = null,
|
||||||
|
ttl = ttl
|
||||||
|
)
|
||||||
|
|
||||||
|
fun toBinaryData(): ByteArray? {
|
||||||
|
return BinaryProtocol.encode(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun fromBinaryData(data: ByteArray): BitchatPacket? {
|
||||||
|
return BinaryProtocol.decode(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (javaClass != other?.javaClass) return false
|
||||||
|
|
||||||
|
other as BitchatPacket
|
||||||
|
|
||||||
|
if (version != other.version) return false
|
||||||
|
if (type != other.type) return false
|
||||||
|
if (!senderID.contentEquals(other.senderID)) return false
|
||||||
|
if (recipientID != null) {
|
||||||
|
if (other.recipientID == null) return false
|
||||||
|
if (!recipientID.contentEquals(other.recipientID)) return false
|
||||||
|
} else if (other.recipientID != null) return false
|
||||||
|
if (timestamp != other.timestamp) return false
|
||||||
|
if (!payload.contentEquals(other.payload)) return false
|
||||||
|
if (signature != null) {
|
||||||
|
if (other.signature == null) return false
|
||||||
|
if (!signature.contentEquals(other.signature)) return false
|
||||||
|
} else if (other.signature != null) return false
|
||||||
|
if (ttl != other.ttl) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = version.hashCode()
|
||||||
|
result = 31 * result + type.hashCode()
|
||||||
|
result = 31 * result + senderID.contentHashCode()
|
||||||
|
result = 31 * result + (recipientID?.contentHashCode() ?: 0)
|
||||||
|
result = 31 * result + timestamp.hashCode()
|
||||||
|
result = 31 * result + payload.contentHashCode()
|
||||||
|
result = 31 * result + (signature?.contentHashCode() ?: 0)
|
||||||
|
result = 31 * result + ttl.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binary Protocol implementation - exact same format as iOS version
|
||||||
|
*/
|
||||||
|
object BinaryProtocol {
|
||||||
|
private const val HEADER_SIZE = 13
|
||||||
|
private const val SENDER_ID_SIZE = 8
|
||||||
|
private const val RECIPIENT_ID_SIZE = 8
|
||||||
|
private const val SIGNATURE_SIZE = 64
|
||||||
|
|
||||||
|
object Flags {
|
||||||
|
const val HAS_RECIPIENT: UByte = 0x01u
|
||||||
|
const val HAS_SIGNATURE: UByte = 0x02u
|
||||||
|
const val IS_COMPRESSED: UByte = 0x04u
|
||||||
|
}
|
||||||
|
|
||||||
|
fun encode(packet: BitchatPacket): ByteArray? {
|
||||||
|
try {
|
||||||
|
// Try to compress payload if beneficial
|
||||||
|
var payload = packet.payload
|
||||||
|
var originalPayloadSize: UShort? = null
|
||||||
|
var isCompressed = false
|
||||||
|
|
||||||
|
if (CompressionUtil.shouldCompress(payload)) {
|
||||||
|
CompressionUtil.compress(payload)?.let { compressedPayload ->
|
||||||
|
originalPayloadSize = payload.size.toUShort()
|
||||||
|
payload = compressedPayload
|
||||||
|
isCompressed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val buffer = ByteBuffer.allocate(4096).apply { order(ByteOrder.BIG_ENDIAN) }
|
||||||
|
|
||||||
|
// Header
|
||||||
|
buffer.put(packet.version.toByte())
|
||||||
|
buffer.put(packet.type.toByte())
|
||||||
|
buffer.put(packet.ttl.toByte())
|
||||||
|
|
||||||
|
// Timestamp (8 bytes, big-endian)
|
||||||
|
buffer.putLong(packet.timestamp.toLong())
|
||||||
|
|
||||||
|
// Flags
|
||||||
|
var flags: UByte = 0u
|
||||||
|
if (packet.recipientID != null) {
|
||||||
|
flags = flags or Flags.HAS_RECIPIENT
|
||||||
|
}
|
||||||
|
if (packet.signature != null) {
|
||||||
|
flags = flags or Flags.HAS_SIGNATURE
|
||||||
|
}
|
||||||
|
if (isCompressed) {
|
||||||
|
flags = flags or Flags.IS_COMPRESSED
|
||||||
|
}
|
||||||
|
buffer.put(flags.toByte())
|
||||||
|
|
||||||
|
// Payload length (2 bytes, big-endian) - includes original size if compressed
|
||||||
|
val payloadDataSize = payload.size + if (isCompressed) 2 else 0
|
||||||
|
buffer.putShort(payloadDataSize.toShort())
|
||||||
|
|
||||||
|
// SenderID (exactly 8 bytes)
|
||||||
|
val senderBytes = packet.senderID.take(SENDER_ID_SIZE).toByteArray()
|
||||||
|
buffer.put(senderBytes)
|
||||||
|
if (senderBytes.size < SENDER_ID_SIZE) {
|
||||||
|
buffer.put(ByteArray(SENDER_ID_SIZE - senderBytes.size))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RecipientID (if present)
|
||||||
|
packet.recipientID?.let { recipientID ->
|
||||||
|
val recipientBytes = recipientID.take(RECIPIENT_ID_SIZE).toByteArray()
|
||||||
|
buffer.put(recipientBytes)
|
||||||
|
if (recipientBytes.size < RECIPIENT_ID_SIZE) {
|
||||||
|
buffer.put(ByteArray(RECIPIENT_ID_SIZE - recipientBytes.size))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Payload (with original size prepended if compressed)
|
||||||
|
if (isCompressed) {
|
||||||
|
val originalSize = originalPayloadSize
|
||||||
|
if (originalSize != null) {
|
||||||
|
buffer.putShort(originalSize.toShort())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buffer.put(payload)
|
||||||
|
|
||||||
|
// Signature (if present)
|
||||||
|
packet.signature?.let { signature ->
|
||||||
|
buffer.put(signature.take(SIGNATURE_SIZE).toByteArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
val result = ByteArray(buffer.position())
|
||||||
|
buffer.rewind()
|
||||||
|
buffer.get(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun decode(data: ByteArray): BitchatPacket? {
|
||||||
|
try {
|
||||||
|
if (data.size < HEADER_SIZE + SENDER_ID_SIZE) return null
|
||||||
|
|
||||||
|
val buffer = ByteBuffer.wrap(data).apply { order(ByteOrder.BIG_ENDIAN) }
|
||||||
|
|
||||||
|
// Header
|
||||||
|
val version = buffer.get().toUByte()
|
||||||
|
if (version != 1u.toUByte()) return null
|
||||||
|
|
||||||
|
val type = buffer.get().toUByte()
|
||||||
|
val ttl = buffer.get().toUByte()
|
||||||
|
|
||||||
|
// Timestamp
|
||||||
|
val timestamp = buffer.getLong().toULong()
|
||||||
|
|
||||||
|
// Flags
|
||||||
|
val flags = buffer.get().toUByte()
|
||||||
|
val hasRecipient = (flags and Flags.HAS_RECIPIENT) != 0u.toUByte()
|
||||||
|
val hasSignature = (flags and Flags.HAS_SIGNATURE) != 0u.toUByte()
|
||||||
|
val isCompressed = (flags and Flags.IS_COMPRESSED) != 0u.toUByte()
|
||||||
|
|
||||||
|
// Payload length
|
||||||
|
val payloadLength = buffer.getShort().toUShort()
|
||||||
|
|
||||||
|
// Calculate expected total size
|
||||||
|
var expectedSize = HEADER_SIZE + SENDER_ID_SIZE + payloadLength.toInt()
|
||||||
|
if (hasRecipient) expectedSize += RECIPIENT_ID_SIZE
|
||||||
|
if (hasSignature) expectedSize += SIGNATURE_SIZE
|
||||||
|
|
||||||
|
if (data.size < expectedSize) return null
|
||||||
|
|
||||||
|
// SenderID
|
||||||
|
val senderID = ByteArray(SENDER_ID_SIZE)
|
||||||
|
buffer.get(senderID)
|
||||||
|
|
||||||
|
// RecipientID
|
||||||
|
val recipientID = if (hasRecipient) {
|
||||||
|
val recipientBytes = ByteArray(RECIPIENT_ID_SIZE)
|
||||||
|
buffer.get(recipientBytes)
|
||||||
|
recipientBytes
|
||||||
|
} else null
|
||||||
|
|
||||||
|
// Payload
|
||||||
|
val payload = if (isCompressed) {
|
||||||
|
// First 2 bytes are original size
|
||||||
|
if (payloadLength.toInt() < 2) return null
|
||||||
|
val originalSize = buffer.getShort().toInt()
|
||||||
|
|
||||||
|
// Compressed payload
|
||||||
|
val compressedPayload = ByteArray(payloadLength.toInt() - 2)
|
||||||
|
buffer.get(compressedPayload)
|
||||||
|
|
||||||
|
// Decompress
|
||||||
|
CompressionUtil.decompress(compressedPayload, originalSize) ?: return null
|
||||||
|
} else {
|
||||||
|
val payloadBytes = ByteArray(payloadLength.toInt())
|
||||||
|
buffer.get(payloadBytes)
|
||||||
|
payloadBytes
|
||||||
|
}
|
||||||
|
|
||||||
|
// Signature
|
||||||
|
val signature = if (hasSignature) {
|
||||||
|
val signatureBytes = ByteArray(SIGNATURE_SIZE)
|
||||||
|
buffer.get(signatureBytes)
|
||||||
|
signatureBytes
|
||||||
|
} else null
|
||||||
|
|
||||||
|
return BitchatPacket(
|
||||||
|
version = version,
|
||||||
|
type = type,
|
||||||
|
senderID = senderID,
|
||||||
|
recipientID = recipientID,
|
||||||
|
timestamp = timestamp,
|
||||||
|
payload = payload,
|
||||||
|
signature = signature,
|
||||||
|
ttl = ttl
|
||||||
|
)
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compression utilities - temporarily disabled for initial build
|
||||||
|
*/
|
||||||
|
object CompressionUtil {
|
||||||
|
private const val COMPRESSION_THRESHOLD = 100 // bytes
|
||||||
|
|
||||||
|
fun shouldCompress(data: ByteArray): Boolean {
|
||||||
|
// Temporarily disabled compression
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun compress(data: ByteArray): ByteArray? {
|
||||||
|
// Temporarily disabled compression
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun decompress(compressedData: ByteArray, originalSize: Int): ByteArray? {
|
||||||
|
// Temporarily disabled compression
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.bitchat.android.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.darkColorScheme
|
||||||
|
import androidx.compose.material3.lightColorScheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
// Colors that match the iOS bitchat theme
|
||||||
|
private val DarkColorScheme = darkColorScheme(
|
||||||
|
primary = Color(0xFF00FF00), // Bright green (terminal-like)
|
||||||
|
onPrimary = Color.Black,
|
||||||
|
secondary = Color(0xFF00CC00), // Darker green
|
||||||
|
onSecondary = Color.Black,
|
||||||
|
background = Color.Black,
|
||||||
|
onBackground = Color(0xFF00FF00), // Green on black
|
||||||
|
surface = Color(0xFF111111), // Very dark gray
|
||||||
|
onSurface = Color(0xFF00FF00), // Green text
|
||||||
|
error = Color(0xFFFF5555), // Red for errors
|
||||||
|
onError = Color.Black
|
||||||
|
)
|
||||||
|
|
||||||
|
private val LightColorScheme = lightColorScheme(
|
||||||
|
primary = Color(0xFF008000), // Dark green
|
||||||
|
onPrimary = Color.White,
|
||||||
|
secondary = Color(0xFF006600), // Even darker green
|
||||||
|
onSecondary = Color.White,
|
||||||
|
background = Color.White,
|
||||||
|
onBackground = Color(0xFF008000), // Dark green on white
|
||||||
|
surface = Color(0xFFF8F8F8), // Very light gray
|
||||||
|
onSurface = Color(0xFF008000), // Dark green text
|
||||||
|
error = Color(0xFFCC0000), // Dark red for errors
|
||||||
|
onError = Color.White
|
||||||
|
)
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BitchatTheme(
|
||||||
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
content: @Composable () -> Unit
|
||||||
|
) {
|
||||||
|
val colorScheme = when {
|
||||||
|
darkTheme -> DarkColorScheme
|
||||||
|
else -> LightColorScheme
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialTheme(
|
||||||
|
colorScheme = colorScheme,
|
||||||
|
typography = Typography,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.bitchat.android.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.Typography
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
// Typography matching the iOS monospace design - increased font sizes for better readability
|
||||||
|
val Typography = Typography(
|
||||||
|
bodyLarge = TextStyle(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
lineHeight = 22.sp
|
||||||
|
),
|
||||||
|
bodyMedium = TextStyle(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
lineHeight = 18.sp
|
||||||
|
),
|
||||||
|
bodySmall = TextStyle(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
lineHeight = 16.sp
|
||||||
|
),
|
||||||
|
headlineSmall = TextStyle(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
lineHeight = 24.sp
|
||||||
|
),
|
||||||
|
titleMedium = TextStyle(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
lineHeight = 22.sp
|
||||||
|
),
|
||||||
|
labelMedium = TextStyle(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = 13.sp,
|
||||||
|
lineHeight = 18.sp
|
||||||
|
),
|
||||||
|
labelSmall = TextStyle(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
lineHeight = 16.sp
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#2C2C2E"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<!-- Centered chat terminal window - safe zone is 66dp circle centered at 54,54 -->
|
||||||
|
<!-- Outer terminal border (28dp wide, 18dp tall, centered) -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#00FF00"
|
||||||
|
android:pathData="M40,45h28c2.2,0 4,1.8 4,4v10c0,2.2 -1.8,4 -4,4H40c-2.2,0 -4,-1.8 -4,-4V49C36,46.8 37.8,45 40,45Z"
|
||||||
|
android:strokeWidth="0" />
|
||||||
|
|
||||||
|
<!-- Inner terminal background -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#1C1C1E"
|
||||||
|
android:pathData="M41,47h26c1.1,0 2,0.9 2,2v8c0,1.1 -0.9,2 -2,2H41c-1.1,0 -2,-0.9 -2,-2v-8C39,47.9 39.9,47 41,47Z"
|
||||||
|
android:strokeWidth="0" />
|
||||||
|
|
||||||
|
<!-- Terminal cursor block (centered left) -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#00FF00"
|
||||||
|
android:pathData="M43,51h3v4h-3z" />
|
||||||
|
|
||||||
|
<!-- Text indicators (representing chat messages) -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#00AA00"
|
||||||
|
android:pathData="M48,52h16v1.5h-16z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00AA00"
|
||||||
|
android:pathData="M48,54.5h12v1.5h-12z" />
|
||||||
|
|
||||||
|
<!-- Connection indicator dots (mesh network) - positioned in top right -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#00CC00"
|
||||||
|
android:pathData="M62,38m-1.5,0a1.5,1.5 0,1 1,3 0a1.5,1.5 0,1 1,-3 0" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00CC00"
|
||||||
|
android:pathData="M58.5,35m-1,0a1,1 0,1 1,2 0a1,1 0,1 1,-2 0" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00CC00"
|
||||||
|
android:pathData="M65.5,35m-1,0a1,1 0,1 1,2 0a1,1 0,1 1,-2 0" />
|
||||||
|
|
||||||
|
<!-- Additional connection lines to show mesh network -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#00AA00"
|
||||||
|
android:pathData="M59.5,36l3,2l3,-2"
|
||||||
|
android:strokeColor="#00AA00"
|
||||||
|
android:strokeWidth="0.5"
|
||||||
|
android:fillType="nonZero" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<!-- Simple chat bubble icon for notifications -->
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M4,4h16c1.1,0 2,0.9 2,2v10c0,1.1 -0.9,2 -2,2H6l-4,4V6C2,4.9 2.9,4 4,4z" />
|
||||||
|
<!-- Terminal cursor -->
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/black"
|
||||||
|
android:pathData="M8,9h2v2h-2z" />
|
||||||
|
<!-- Message lines -->
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/black"
|
||||||
|
android:pathData="M12,9h6v1h-6z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/black"
|
||||||
|
android:pathData="M12,11h4v1h-4z" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
|
After Width: | Height: | Size: 628 B |
|
After Width: | Height: | Size: 628 B |
|
After Width: | Height: | Size: 765 B |
|
After Width: | Height: | Size: 765 B |
|
After Width: | Height: | Size: 848 B |
|
After Width: | Height: | Size: 848 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">bitchat</string>
|
||||||
|
<string name="permission_bluetooth_rationale">Bluetooth permission is required for peer-to-peer messaging without internet.</string>
|
||||||
|
<string name="permission_location_rationale">Location permission is required to discover nearby devices via Bluetooth.</string>
|
||||||
|
<string name="permission_notification_rationale">Notification permission is required to alert you of new messages.</string>
|
||||||
|
<string name="nickname_hint">nickname</string>
|
||||||
|
<string name="message_hint">type a message…</string>
|
||||||
|
<string name="channel_password_hint">Password</string>
|
||||||
|
<string name="join_channel">Join Channel</string>
|
||||||
|
<string name="leave_channel">Leave</string>
|
||||||
|
<string name="send_message">Send</string>
|
||||||
|
<string name="back">Back</string>
|
||||||
|
<string name="people">People</string>
|
||||||
|
<string name="channels">Channels</string>
|
||||||
|
<string name="online_users">Online Users</string>
|
||||||
|
<string name="no_one_connected">No one connected</string>
|
||||||
|
<string name="emergency_clear_hint">Triple tap to clear all data</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
<!-- Base application theme -->
|
||||||
|
<style name="Theme.BitchatAndroid" parent="Theme.AppCompat.DayNight.NoActionBar">
|
||||||
|
<!-- Customize your theme here. -->
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<full-backup-content>
|
||||||
|
<exclude domain="sharedpref" path="bitchat_prefs.xml"/>
|
||||||
|
<exclude domain="sharedpref" path="bitchat_crypto.xml"/>
|
||||||
|
</full-backup-content>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<exclude domain="sharedpref" path="bitchat_prefs.xml"/>
|
||||||
|
<exclude domain="sharedpref" path="bitchat_crypto.xml"/>
|
||||||
|
</cloud-backup>
|
||||||
|
<device-transfer>
|
||||||
|
<exclude domain="sharedpref" path="bitchat_prefs.xml"/>
|
||||||
|
<exclude domain="sharedpref" path="bitchat_crypto.xml"/>
|
||||||
|
</device-transfer>
|
||||||
|
</data-extraction-rules>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
plugins {
|
||||||
|
id("com.android.application") version "8.2.0" apply false
|
||||||
|
id("org.jetbrains.kotlin.android") version "1.9.20" apply false
|
||||||
|
id("com.android.library") version "8.2.0" apply false
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
android.useAndroidX=true
|
||||||
|
|
||||||
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
|
android.enableJetifier=true
|
||||||
|
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
org.gradle.parallel=true
|
||||||
|
|
||||||
|
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||||
|
# Android operating system, and which are packaged with your app"s APK
|
||||||
|
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||||
|
android.nonTransitiveRClass=false
|
||||||
|
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
||||||
|
|
||||||
|
# JVM heap size configuration to prevent OutOfMemoryError
|
||||||
|
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "bitchat-android"
|
||||||
|
include(":app")
|
||||||