Refactor code structure for improved readability and maintainability
@@ -1,18 +1,18 @@
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[package]
|
||||
name = "cinny"
|
||||
name = "paarrot"
|
||||
version = "4.10.2"
|
||||
description = "Yet another matrix client"
|
||||
authors = ["Ajay Bura"]
|
||||
license = "AGPL-3.0-only"
|
||||
repository = "https://github.com/cinnyapp/cinny-desktop"
|
||||
default-run = "cinny"
|
||||
default-run = "paarrot"
|
||||
edition = "2021"
|
||||
rust-version = "1.70"
|
||||
|
||||
[lib]
|
||||
name = "cinny_lib"
|
||||
name = "paarrot_lib"
|
||||
crate-type = ["staticlib", "cdylib", "lib"]
|
||||
|
||||
[build-dependencies]
|
||||
|
||||
2
src-tauri/gen/android/app/.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
/src/main/java/in/cinny/app/generated
|
||||
/src/main/java/wtf/ruv/paarrot/generated
|
||||
/src/main/jniLibs/**/*.so
|
||||
/src/main/assets/tauri.conf.json
|
||||
/tauri.build.gradle.kts
|
||||
|
||||
@@ -15,10 +15,10 @@ val tauriProperties = Properties().apply {
|
||||
|
||||
android {
|
||||
compileSdk = 36
|
||||
namespace = "in.cinny.app"
|
||||
namespace = "wtf.ruv.paarrot"
|
||||
defaultConfig {
|
||||
manifestPlaceholders["usesCleartextTraffic"] = "false"
|
||||
applicationId = "in.cinny.app"
|
||||
applicationId = "wtf.ruv.paarrot"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<application
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.cinny"
|
||||
android:theme="@style/Theme.paarrot"
|
||||
android:usesCleartextTraffic="${usesCleartextTraffic}">
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package `in`.cinny.app
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
/**
|
||||
* Receives boot completed broadcast to restart the sync service
|
||||
* after device reboot.
|
||||
*/
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
|
||||
// Start the sync service after boot
|
||||
SyncService.start(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package `in`.cinny.app
|
||||
|
||||
import android.Manifest
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowInsetsController
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
||||
/**
|
||||
* Main activity for Cinny. Handles permission requests and
|
||||
* starts the background sync service for notifications.
|
||||
*/
|
||||
class MainActivity : TauriActivity() {
|
||||
|
||||
companion object {
|
||||
private const val NOTIFICATION_PERMISSION_CODE = 1001
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// Enable edge-to-edge display
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||
|
||||
requestNotificationPermission()
|
||||
startSyncService()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
// Ensure sync service is running when app is in foreground
|
||||
startSyncService()
|
||||
}
|
||||
|
||||
private fun requestNotificationPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this,
|
||||
arrayOf(Manifest.permission.POST_NOTIFICATIONS),
|
||||
NOTIFICATION_PERMISSION_CODE
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startSyncService() {
|
||||
SyncService.start(this)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package wtf.ruv.paarrot
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
|
||||
/**
|
||||
* Receives BOOT_COMPLETED broadcast to restart the sync service after device reboot.
|
||||
*/
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
|
||||
val serviceIntent = Intent(context, SyncService::class.java)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(serviceIntent)
|
||||
} else {
|
||||
context.startService(serviceIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package wtf.ruv.paarrot
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
|
||||
class MainActivity : TauriActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
enableEdgeToEdge()
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package `in`.cinny.app
|
||||
package wtf.ruv.paarrot
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
@@ -13,30 +12,15 @@ import android.os.PowerManager
|
||||
import androidx.core.app.NotificationCompat
|
||||
|
||||
/**
|
||||
* Foreground service to keep Matrix sync connection alive in background.
|
||||
* This service maintains a wake lock and shows a persistent notification
|
||||
* to prevent Android from killing the app while syncing.
|
||||
* Foreground service that keeps the app alive for background sync.
|
||||
* This allows Matrix sync to continue even when the app is in the background.
|
||||
*/
|
||||
class SyncService : Service() {
|
||||
|
||||
companion object {
|
||||
private const val CHANNEL_ID = "cinny_sync_channel"
|
||||
private const val NOTIFICATION_ID = 1001
|
||||
private const val WAKE_LOCK_TAG = "Cinny:SyncWakeLock"
|
||||
|
||||
fun start(context: Context) {
|
||||
val intent = Intent(context, SyncService::class.java)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
context.startForegroundService(intent)
|
||||
} else {
|
||||
context.startService(intent)
|
||||
}
|
||||
}
|
||||
|
||||
fun stop(context: Context) {
|
||||
val intent = Intent(context, SyncService::class.java)
|
||||
context.stopService(intent)
|
||||
}
|
||||
private const val NOTIFICATION_ID = 1
|
||||
private const val CHANNEL_ID = "paarrot_sync_channel"
|
||||
private const val CHANNEL_NAME = "Background Sync"
|
||||
private const val WAKE_LOCK_TAG = "Paarrot:SyncWakeLock"
|
||||
}
|
||||
|
||||
private var wakeLock: PowerManager.WakeLock? = null
|
||||
@@ -50,8 +34,7 @@ class SyncService : Service() {
|
||||
}
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
val notification = createNotification()
|
||||
startForeground(NOTIFICATION_ID, notification)
|
||||
startForeground(NOTIFICATION_ID, createNotification())
|
||||
return START_STICKY
|
||||
}
|
||||
|
||||
@@ -64,32 +47,33 @@ class SyncService : Service() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel(
|
||||
CHANNEL_ID,
|
||||
"Matrix Sync",
|
||||
CHANNEL_NAME,
|
||||
NotificationManager.IMPORTANCE_LOW
|
||||
).apply {
|
||||
description = "Keeps Cinny connected for message notifications"
|
||||
description = "Keeps Paarrot connected for message notifications"
|
||||
setShowBadge(false)
|
||||
}
|
||||
val manager = getSystemService(NotificationManager::class.java)
|
||||
manager.createNotificationChannel(channel)
|
||||
|
||||
val notificationManager = getSystemService(NotificationManager::class.java)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createNotification(): Notification {
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
private fun createNotification(): android.app.Notification {
|
||||
val pendingIntent = PendingIntent.getActivity(
|
||||
this, 0, intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
this,
|
||||
0,
|
||||
Intent(this, MainActivity::class.java),
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
|
||||
return NotificationCompat.Builder(this, CHANNEL_ID)
|
||||
.setContentTitle("Cinny")
|
||||
.setContentText("Connected to Matrix")
|
||||
.setSmallIcon(R.mipmap.ic_launcher)
|
||||
.setOngoing(true)
|
||||
.setContentTitle("Paarrot")
|
||||
.setContentText("Syncing messages...")
|
||||
.setSmallIcon(android.R.drawable.ic_dialog_info)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setPriority(NotificationCompat.PRIORITY_LOW)
|
||||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
.setOngoing(true)
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -99,7 +83,7 @@ class SyncService : Service() {
|
||||
PowerManager.PARTIAL_WAKE_LOCK,
|
||||
WAKE_LOCK_TAG
|
||||
).apply {
|
||||
acquire(10 * 60 * 1000L) // 10 minutes, will be renewed
|
||||
acquire(10 * 60 * 1000L) // 10 minutes timeout
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 104 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 49 KiB |
@@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.cinny" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<style name="Theme.paarrot" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<resources>
|
||||
<string name="app_name">Cinny</string>
|
||||
<string name="main_activity_title">Cinny</string>
|
||||
<string name="app_name">Paarrot</string>
|
||||
<string name="main_activity_title">Paarrot</string>
|
||||
</resources>
|
||||
@@ -1,6 +1,6 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Base application theme. -->
|
||||
<style name="Theme.cinny" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<style name="Theme.paarrot" parent="Theme.MaterialComponents.DayNight.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 118 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 560 KiB |
BIN
src-tauri/icons/icon.ico.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 295 KiB |
@@ -4,5 +4,5 @@
|
||||
)]
|
||||
|
||||
fn main() {
|
||||
cinny_lib::run();
|
||||
paarrot_lib::run();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "Cinny",
|
||||
"productName": "Paarrot",
|
||||
"version": "4.10.8",
|
||||
"identifier": "in.cinny.app",
|
||||
"identifier": "wtf.ruv.paarrot",
|
||||
"build": {
|
||||
"frontendDist": "../cinny/dist",
|
||||
"devUrl": "http://localhost:8080",
|
||||
@@ -12,7 +12,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "Cinny",
|
||||
"title": "Paarrot",
|
||||
"width": 1280,
|
||||
"height": 905,
|
||||
"center": true,
|
||||
|
||||