Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
0eca356
refactor(data): replace ScopeProvider with CoroutineScope and remove …
gdlbo Apr 6, 2026
5aca914
Rewritten mappings of chats/messages (#200)
gdlbo Apr 6, 2026
c2fa490
Better mappings + memory logger (#204)
gdlbo Apr 6, 2026
c3bd470
photo: better crop (#188)
aliveoutside Apr 6, 2026
be8d206
feat(photo-editor): add rotate to crop
aliveoutside Apr 6, 2026
aa9d1b8
feat(photo-editor): smoother rotate animation
aliveoutside Apr 6, 2026
18c39ac
better notifications info caching
gdlbo Apr 6, 2026
8cedbad
feat(chat): smoother mic/send button animation
aliveoutside Apr 6, 2026
926514b
fixed runtime update user info in chat
gdlbo Apr 6, 2026
dec286e
thread send message fix + caption message fix
gdlbo Apr 6, 2026
4a8842c
fix #174
gdlbo Apr 6, 2026
162928f
slow mode, mute etc. support
gdlbo Apr 6, 2026
7b42fa0
fix disable drag-to-back in chats
gdlbo Apr 6, 2026
c8469e7
fix chat settings ui
gdlbo Apr 7, 2026
6614dd0
pins redesign + fix #73
gdlbo Apr 7, 2026
8f1937a
rewritten pinned sheet
gdlbo Apr 7, 2026
803460e
remove password length limit (#210)
fimkov Apr 7, 2026
6db2fc1
phone number input screen improvements (#209)
fimkov Apr 7, 2026
a072091
better animations of pins
gdlbo Apr 7, 2026
f05cab9
chore: update project dependencies
gdlbo Apr 7, 2026
11eeca9
fix: rename release APK outputs
gdlbo Apr 7, 2026
ca9c306
fix media download event routing and message cache collisions
gdlbo Apr 7, 2026
7467cae
Remove non-existent `web_app_set_header_text` event and page reload o…
SecondThundeR Apr 8, 2026
eab7b5b
Update sensors handling and move evaluateJavascript to message queue …
SecondThundeR Apr 8, 2026
6178c23
feat: fast reply gesture (#168)
andr0d1v Apr 8, 2026
33c9da5
Add androidx-compose-ui version and update refs
gdlbo Apr 8, 2026
9f8c2b1
Optimize chat UI updates and typing dots
gdlbo Apr 8, 2026
028a12b
Enable configuration cache; simplify build tasks
gdlbo Apr 8, 2026
984e6bc
Preserve string/plurals with keep.xml
gdlbo Apr 8, 2026
37ee6b1
targeted media path updates
gdlbo Apr 8, 2026
714da74
Add video duration to gallery items and UI
gdlbo Apr 8, 2026
e579db9
feat(files): download progress (#215)
andr0d1v Apr 9, 2026
27f3a22
Pretty folding and unfolding, fullscreen media, no hang on startup an…
keimoger Apr 9, 2026
62540fb
fixed profile paddings
gdlbo Apr 9, 2026
2c17f68
optimize file update pipeline and wallpaper persistence
gdlbo Apr 9, 2026
5fa4aee
localize chat and notification UI strings across modules
gdlbo Apr 9, 2026
a45151d
localize sender label in notification quick replies
gdlbo Apr 9, 2026
3e7a874
fix profile top bar badge wrapping on narrow widths
gdlbo Apr 9, 2026
6e175d4
Update TDLib badge to 1.8.63
gdlbo Apr 9, 2026
8d4cfc3
feat: android workflow ci (#218)
andr0d1v Apr 9, 2026
d3862e4
implement Android 12+ SplashScreen API
gdlbo Apr 9, 2026
5c4472e
support saving media albums to downloads
gdlbo Apr 9, 2026
8dcb7c4
update message bubble components and album handling
gdlbo Apr 9, 2026
7219766
update ChatInputBarComposerSection vertical alignment to center
gdlbo Apr 9, 2026
7469151
fix #202
gdlbo Apr 9, 2026
8e20634
update splash screen to support monochrome icons and dynamic colors
gdlbo Apr 9, 2026
cfaf58f
support pasting images from clipboard
gdlbo Apr 9, 2026
ac27462
defer non-critical startup work for faster cold start
gdlbo Apr 9, 2026
6340b9d
optimize chat compose state and list rendering paths
gdlbo Apr 9, 2026
627bd9d
improve chat viewport restoration and scrolling precision
gdlbo Apr 9, 2026
d0fc90c
Start foreground notification before FCM stop
gdlbo Apr 10, 2026
b5fbb54
improve tablet layout, localization, and message rendering
gdlbo Apr 10, 2026
1e98ed5
refine message bubble grouping and sender block logic
gdlbo Apr 10, 2026
709c766
refine chat message options and translation/summary logic
gdlbo Apr 10, 2026
520eb8f
Refactor startup overlay state handling
gdlbo Apr 10, 2026
e9d5db2
replace gallery top bar puzzle icon with photo library
gdlbo Apr 10, 2026
334c3ef
guard scheduled messages fetch by chat rights
gdlbo Apr 10, 2026
998ad66
add copy cut paste actions to fullscreen editor
gdlbo Apr 10, 2026
75e09f1
armv7 crash and performance fix
gdlbo Apr 10, 2026
c687991
add toggle for tablet split-screen interface
gdlbo Apr 10, 2026
3ad52c3
Add 12h format support depending on locale (#219)
iWisp360 Apr 10, 2026
ebd9459
eagerly initialize OfflineWarmup and SponsorSyncManager
gdlbo Apr 10, 2026
755565c
fix message text rendering and prevent substring out-of-bounds crashes
gdlbo Apr 10, 2026
fca9fb2
remove telega proxy integration and settings flow
gdlbo Apr 11, 2026
9de8cae
advanced proxy management and network-specific routing rules
gdlbo Apr 11, 2026
9de90db
rename development build to Alpha across localized strings
gdlbo Apr 11, 2026
d823012
implement separate audio recording and improve transcoding in `Advanc…
gdlbo Apr 11, 2026
9950df7
refine video gesture controls and dismissal logic
gdlbo Apr 11, 2026
1ce5811
bump version to 0.0.7
gdlbo Apr 11, 2026
d5abbd1
Add fast +1 button (#182)
xtexx Apr 12, 2026
9c21d3b
Refactor chat list state decomposition into focused StateFlows (#242)
fakelog Apr 12, 2026
599a195
Keep member names for Monogram and TDLib packages in release builds
gdlbo Apr 12, 2026
f36ddff
fix #237 #241 #238 #236 #234
gdlbo Apr 12, 2026
6735e44
improve notification handling and background service reliability
gdlbo Apr 12, 2026
d0d8b4c
Implement UnifiedPush support (#244)
gdlbo Apr 13, 2026
0a85e18
prioritize push provider fallback order
gdlbo Apr 13, 2026
31a31af
harden notification building against NPEs
gdlbo Apr 13, 2026
7120f83
Feat: Add complete Turkish (tr) localization (#239)
bugycugy Apr 13, 2026
463a15e
complete Turkish locale wiring and missing translations
gdlbo Apr 13, 2026
7df1c21
Escape apostrophes and remove revenue_title
gdlbo Apr 13, 2026
0587350
Add collectors for scope notification prefs
gdlbo Apr 13, 2026
fe68044
Merge branch 'master' into develop
gdlbo Apr 13, 2026
2f93211
fixed compile issues
gdlbo Apr 13, 2026
7c87d22
bump app version to 0.0.8
gdlbo Apr 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</a>
</h1>

**Read this in other languages:** [Русский](README_RU.md), [한국어](README_KOR.md), [اُردو](README_UR.md), [Español](README_ES.md)
**Read this in other languages:** [Русский](README_RU.md), [Türkçe](README_TR.md), [한국어](README_KOR.md), [اُردو](README_UR.md), [Español](README_ES.md)


---
Expand Down
2 changes: 1 addition & 1 deletion README_ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</h1>

**Si deseas leer este documento en otro lenguaje:** [Русский](README_RU.md),
[한국어](README_KOR.md), [اُردو](README_UR.md), [English](README.md)
[Türkçe](README_TR.md), [한국어](README_KOR.md), [اُردو](README_UR.md), [English](README.md)

---

Expand Down
2 changes: 1 addition & 1 deletion README_KOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</a>
</h1>

**다른 언어로 읽기:** [English](README.md), [Русский](README_RU.md), [Español](README_ES.md)
**다른 언어로 읽기:** [English](README.md), [Русский](README_RU.md), [Türkçe](README_TR.md), [Español](README_ES.md)

---

Expand Down
2 changes: 1 addition & 1 deletion README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</a>
</h1>

**Читать на других языках:** [English](README.md), [한국어](README_KOR.md), [اُردو](README_UR.md),
**Читать на других языках:** [English](README.md), [Türkçe](README_TR.md), [한국어](README_KOR.md), [اُردو](README_UR.md),
[Español](README_ES.md)

---
Expand Down
215 changes: 215 additions & 0 deletions README_TR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
<h1 align="center">
<br>
<a href="https://github.com/monogram-android/monogram"><img width="130" height="130" alt="MonoGram" src="./documents/monogram.png" />
</a>
<br>
<b>MonoGram</b>
<br>
</h1>

<h1 align="center">
<a href="https://github.com/monogram-android/monogram/blob/develop/LICENSE">
<img src="https://img.shields.io/badge/Lisans-GPLv3-blue.svg" width="120">
</a>
<a href="https://github.com/monogram-android/monogram/stargazers">
<img src="https://img.shields.io/github/stars/monogram-android/monogram" width="120">
</a>
<img src="https://img.shields.io/badge/Kotlin-2.0+-blue.svg?logo=kotlin" width="130">
<img src="https://img.shields.io/badge/TDLib-1.8.63-blue" width="120">
<img src="https://img.shields.io/badge/Durum-Aktif_Geliştirme-orange" width="170">
<a href="https://boosty.to/monogram">
<img src="https://img.shields.io/badge/Boosty-Projeyi_Destekle-ff6f61?logo=boosty&logoColor=white" width="200">
</a>
</h1>

**Bu dokümanı diğer dillerde okuyun:** [English](README.md), [Русский](README_RU.md), [Türkçe](README_TR.md), [한국어](README_KOR.md), [اُردو](README_UR.md), [Español](README_ES.md)

---

**MonoGram**, Android için modern, yıldırım hızında ve zarif bir resmi olmayan Telegram istemcisidir. **Jetpack Compose** ve **Material Design 3** ile sıfırdan inşa edilen uygulama, resmi **TDLib** altyapısıyla desteklenen yerleşik (native) ve akıcı bir deneyim sunar.

> [!IMPORTANT]
> MonoGram şu an **aktif geliştirme** aşamasındadır. Sık güncellemeler, mimari değişiklikler ve nadiren de olsa hatalar (bug) bekleyebilirsiniz.

Projeyi [**Boosty**](https://boosty.to/monogram) üzerinden destekleyebilirsiniz.

---

## Ekran Görüntüleri

<div align="center">

| | | | |
|:---:|:---:|:---:|:---:|
| <img src="./documents/1.png" width="180" alt="Ekran Görüntüsü 1" /> | <img src="./documents/2.png" width="180" alt="Ekran Görüntüsü 2" /> | <img src="./documents/3.png" width="180" alt="Ekran Görüntüsü 3" /> | <img src="./documents/4.png" width="180" alt="Ekran Görüntüsü 4" /> |

</div>

---

## Öne Çıkan Özellikler

- **Bağımsız İstemci** — Android için Telegram'ın bir çatalı (fork) değildir. MonoGram, tamamen sıfırdan bağımsız bir proje olarak inşa edilmiştir.
- **Material Design 3** — Telefonlar, tabletler ve katlanabilir cihazlarda harika görünen, estetik ve uyarlanabilir kullanıcı arayüzü.
- **Güvenli** — Yerleşik biyometrik kilitleme ve şifrelenmiş yerel depolama.
- **Zengin Medya Deneyimi** — ExoPlayer ve Coil 3 ile yüksek performanslı medya oynatma.
- **Hızlı ve Verimli** — Kotlin Coroutines ile desteklenen, performans için optimize edilmiş yapı.
- **Temiz Mimari (Clean Architecture)** — Domain, Data ve Presentation katmanları ile sorumlulukların net bir şekilde ayrılması.
- **MVI Deseni** — MVIKotlin kullanılarak sağlanan öngörülebilir durum yönetimi.
- **NFT veya Kripto Yok** — MonoGram; Telegram tarafından dayatılan ve bir mesajlaşma uygulamasının kapsamı dışında gördüğümüz NFT tanıtımları, hediyeleri veya benzeri özellikleri asla içermeyecektir.

---

## Başlangıç

Projeyi yerel ortamınızda kurmak için bu adımları izleyin.

### Ön Koşullar

- **Android Studio**: Ladybug veya daha yeni bir sürüm (önerilir).
- **JDK**: Java 17 veya daha yeni bir sürüm.

### 1. Depoyu Klonlayın

```bash
git clone --recurse-submodules https://github.com/monogram-android/monogram.git
cd monogram
```
### 2. Telegram API Anahtarlarını Yapılandırın

Telegram sunucularına bağlanmak için kendi API kimlik bilgilerinize ihtiyacınız vardır.

1. [my.telegram.org](https://my.telegram.org/) adresinde oturum açın.
2. **API development tools (API geliştirme araçları)** bölümüne gidin.
3. `App api_id` ve `App api_hash` değerlerinizi almak için yeni bir uygulama oluşturun.
4. Projenin kök dizininde (eğer yoksa) `local.properties` adlı bir dosya oluşturun.
5. Aşağıdaki satırları dosyaya ekleyin:

```properties
API_ID=12345678
API_HASH=your_api_hash_here
```
### 3. Anlık Bildirimleri (Push Notifications) Yapılandırın

1. [Firebase konsolunda](https://console.firebase.google.com) oturum açın.
2. Yeni bir proje oluşturun.
3. İhtiyacınız olan `applicationId` değerine sahip yeni bir uygulama ekleyin. Farklı ID'lere sahip birden fazla uygulamanız varsa, birden fazla Firebase uygulaması oluşturun. **Varsayılan olarak, hata ayıklama (debug) ve yayınlama (release) sürümlerinin `applicationId` değerleri farklıdır.**
4. `google-services.json` dosyasını indirin ve **app** modülünün kök dizinine kopyalayın (`monogram/app/google-services.json`). Birden fazla uygulama oluşturduysanız, yalnızca en güncel yapılandırmayı kopyalayın.
5. **Cloud Messaging** bölümüne gidin.
6. **Manage service accounts** (Hizmet hesaplarını yönet) seçeneğine tıklayın.
7. Açılan pencerenin üst kısmındaki **Keys** (Anahtarlar) sekmesini seçin.
8. **Add key** (Anahtar ekle) seçeneğine tıklayın ve **JSON** opsiyonunu seçin. Dosyanın indirilmesini bekleyin.
9. Uygulama ID'nizi aldığınız Telegram API sayfasına geri dönün.
10. FCM kimlik bilgileri (FCM credentials) bölümünün yanındaki **Update** (Güncelle) butonuna tıklayın.
11. Açılan sayfada hizmet hesabı (service account) JSON dosyasını yükleyin.

### 4. İlk Kurulum: libvpx Derlemesi

Animasyonların çalışması için libvpx'in derlenmiş olması gerekir. Bu işlem, Gradle derlemesini başlatmadan önce yapılmalıdır; aksi takdirde derleme hatalarıyla karşılaşırsınız.

1. Çalışma dizininizi `presentation/src/main/cpp` olarak değiştirin.
2. `build.sh` dosyası içerisine kendi `ANDROID_NDK_HOME` yolunuzu ekleyin.
3. `build.sh` dosyasını çalıştırın ve işlemin tamamlanmasını bekleyin.

### 5. Derleyin ve Çalıştırın

1. Projeyi **Android Studio** ile açın.
2. `TdApi.java` (TDLib sarmalayıcısı) dosyasının doğru şekilde indekslenebilmesi için IDE indeksleme limitlerini artırın. **Android Studio** veya **IntelliJ IDEA** içerisinde, **Help (Yardım) → Edit Custom Properties...** (Özel Özellikleri Düzenle) yolunu izleyin, aşağıdaki satırları yapıştırın ve istenirse IDE'yi yeniden başlatın:

```properties
# Kb cinsinden boyut
idea.max.intellisense.filesize=20480
# Kb cinsinden boyut
idea.max.content.load.filesize=20480
```

3. Gradle senkronizasyonunu (Sync) yapın.
4. `app` çalıştırma yapılandırmasını (run configuration) seçin.
5. Bir cihaz bağlayın veya bir emülatör başlatın.
6. **Run** (Çalıştır) butonuna tıklayın.

---

## TDLib Derlemesi

Eğer TDLib'i kaynaktan derlemeniz gerekirse, öncelikle gerekli bağımlılıkları kurun. Debian/Ubuntu tabanlı dağıtımlar için:

```bash
sudo apt-get update
sudo apt-get install build-essential git curl wget php perl gperf unzip zip default-jdk cmake
```

Ardından projenin kök dizininden derleme betiğini (script) çalıştırın:

```bash
./build-tdlib.sh
```

---

## Katkıda Bulunma

Katkılarınızı memnuniyetle karşılıyoruz! İster hataları gidermek, ister dokümantasyonu iyileştirmek veya yeni özellikler önermek olsun, her türlü katkıya açığız.

1. **Sorunları (Issues) Kontrol Edin** — Açık sorunlara göz atın veya fikirlerinizi tartışmak için yeni bir sorun kaydı oluşturun.
2. **`develop` Dalında Çalışın** — Kendi dalınızı (branch) `develop` üzerinden oluşturun ve çalışmalarınızı bu dalı temel alarak sürdürün.
3. **Fork & Branch** — Depoyu (repo) çatallayın (fork) ve bir özellik dalı (feature branch) oluşturun.
4. **Kod Stili** — Mevcut Kotlin kod yazım stiline ve Temiz Mimari (Clean Architecture) yönergelerine uyun.
5. **PR Gönderin** — Değişikliklerinizin net bir açıklamasını içeren bir Çekme İsteğini (Pull Request) `develop` dalına açın.

> [!IMPORTANT]
> - [Telegram API Hizmet Şartlarına](https://core.telegram.org/api/terms) uyun.
> - Kodunuzun tüm kontrollerden ve testlerden geçtiğinden emin olun.

### Hata Bildirme ve Özellik Önerileri

- **Hatalar (Bugs)** — Bir sorun kaydı (issue) açın ve başlıkta `[Bug]` etiketini kullanın (Örn: `[Bug] Uygulama başlangıçta çöküyor`). Ayrıca, bilinen tüm hatalara [**Hata Takipçisi**](https://github.com/orgs/monogram-android/projects/3/views/1) üzerinden göz atabilirsiniz.
- **Özellik İstekleri** — `[Feature]` etiketini içeren bir sorun kaydı açın (Örn: `[Feature] Planlanmış mesaj desteği`). Mevcut özellik isteklerini [**Özellik Panosu**](https://github.com/orgs/monogram-android/projects/5/views/1) üzerinden inceleyebilirsiniz.

---

## Çeviriler

MonoGram topluluk tarafından yapılan çevirileri memnuniyetle karşılar! Kendi dilinizle katkıda bulunmak için metin kaynak (strings resource) dosyasını düzenleyebilirsiniz.

Kaynak metinler [`presentation/src/main/res/values/string.xml`](https://github.com/monogram-android/monogram/blob/develop/presentation/src/main/res/values/string.xml) adresinde yer almaktadır. Yeni bir dil eklemek için, ilgili dile ait bir `values-<yerel-kod>/string.xml` dosyası oluşturun (örneğin Almanca için `values-de/string.xml`) ve metinleri orada çevirin. Çevirinizi içeren bir Çekme İsteği (PR) açın, biz de onu projeye dahil edelim.

---

## Teknoloji Yığını

MonoGram, en güncel Android geliştirme araçlarından ve kütüphanelerinden yararlanır:

| Kategori | Kütüphaneler |
|:---|:---|
| **Dil** | [Kotlin](https://kotlinlang.org/) |
| **Kullanıcı Arayüzü (UI)** | [Jetpack Compose](https://developer.android.com/jetpack/compose) (Material 3) |
| **Mimari** | [Decompose](https://github.com/arkivanov/Decompose) (Navigasyon), [MVIKotlin](https://github.com/arkivanov/MVIKotlin) |
| **Bağımlılık Enjeksiyonu (DI)** | [Koin](https://insert-koin.io/) |
| **Asenkron İşlemler** | Coroutines & Flow |
| **Telegram Çekirdeği** | [TDLib](https://core.telegram.org/tdlib) (Telegram Database Library) |
| **Görsel Yükleme** | [Coil 3](https://coil-kt.github.io/coil/) |
| **Medya** | Media3 (ExoPlayer) |
| **Haritalar** | [MapLibre](https://maplibre.org/) |
| **Yerel Veritabanı** | Room |

---

## Proje Yapısı

Proje, sorumlulukların ayrılmasını ve ölçeklenebilirliği sağlamak amacıyla çok modüllü (multi-module) bir yapı izlemektedir:

| Modül | Açıklama |
|:---|:---|
| **:app** | Ana Android uygulama modülü. |
| **:domain** | İş mantığı (business logic), kullanım durumları (use cases) ve depo (repository) arayüzlerini içeren saf Kotlin modülü. |
| **:data** | Depo (repository) uygulamaları, veri kaynakları ve TDLib entegrasyonu. |
| **:presentation** | Kullanıcı arayüzü (UI) bileşenleri, ekranlar ve görünüm modelleri (MVI Store'ları). |
| **:core** | Modüller genelinde kullanılan ortak yardımcı sınıflar ve uzantılar (extensions). |
| **:baselineprofile** | Uygulama başlangıcı ve performans optimizasyonu için Baseline Profilleri. |

---

## Lisans

Bu proje [**GNU General Public License v3.0**](LICENSE) (GNU Genel Kamu Lisansı v3.0) kapsamında lisanslanmıştır.
2 changes: 1 addition & 1 deletion README_UR.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</a>
</h1>

**اسے دوسری زبانوں میں پڑھیں:** [English](README.md), [Русский](README_RU.md)، [한국어](README_KOR.md),
**اسے دوسری زبانوں میں پڑھیں:** [English](README.md), [Русский](README_RU.md)، [Türkçe](README_TR.md), [한국어](README_KOR.md),
[Español](README_ES.md)

---
Expand Down
15 changes: 13 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
applicationId = "org.monogram"
minSdk = 25
targetSdk = 36
versionCode = 7
versionName = "0.0.7"
versionCode = 8
versionName = "0.0.8"
}

splits {
Expand Down Expand Up @@ -110,6 +110,16 @@ androidComponents {
}
}

configurations.configureEach {
val tink = "com.google.crypto.tink:tink-android:1.21.0"
resolutionStrategy {
force(tink)
dependencySubstitution {
substitute(module("com.google.crypto.tink:tink")).using(module(tink))
}
}
}

dependencies {
implementation(platform(libs.androidx.compose.bom))
implementation(libs.bundles.androidx.compose)
Expand All @@ -126,6 +136,7 @@ dependencies {

implementation(platform(libs.firebase.bom))
implementation(libs.firebase.messaging)
implementation(libs.unifiedpush.connector)

implementation(libs.maplibre.compose)

Expand Down
2 changes: 2 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

-keepnames class org.monogram.**
-keepnames class org.drinkless.tdlib.**
-keepclassmembernames class org.monogram.** { *; }
-keepclassmembernames class org.drinkless.tdlib.** { *; }

-assumenosideeffects class android.util.Log {
public static *** v(...);
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />

<queries>
<intent>
<action android:name="org.unifiedpush.android.connector.REGISTER" />
</intent>
</queries>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand Down
28 changes: 22 additions & 6 deletions app/src/main/java/org/monogram/app/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.monogram.presentation.di.AppContainer
import org.monogram.presentation.di.KoinAppContainer
import java.io.PrintWriter
import java.io.StringWriter
import kotlin.jvm.java
import kotlin.system.exitProcess

class App : Application(), SingletonImageLoader.Factory {
Expand Down Expand Up @@ -84,12 +83,29 @@ class App : Application(), SingletonImageLoader.Factory {

private fun checkPushAvailability() {
val distrManager = get<DistrManager>()
val isGmsAvailable = distrManager.isGmsAvailable()
val isFcmAvailable = distrManager.isFcmAvailable()

val prefs = get<AppPreferencesProvider>()
if (!(isGmsAvailable && isFcmAvailable) && prefs.pushProvider.value == PushProvider.FCM) {
prefs.setPushProvider(PushProvider.GMS_LESS)
val currentProvider = prefs.pushProvider.value
val bestAvailable = resolveBestAvailablePushProvider(distrManager)

val shouldFallback = when (currentProvider) {
PushProvider.FCM -> bestAvailable != PushProvider.FCM
PushProvider.UNIFIED_PUSH -> !distrManager.isUnifiedPushDistributorAvailable()
PushProvider.GMS_LESS -> false
}

if (shouldFallback && currentProvider != bestAvailable) {
prefs.setPushProvider(bestAvailable)
}
}

private fun resolveBestAvailablePushProvider(distrManager: DistrManager): PushProvider {
val fcmAvailable = distrManager.isGmsAvailable() && distrManager.isFcmAvailable()
val unifiedPushAvailable = distrManager.isUnifiedPushDistributorAvailable()

return when {
fcmAvailable -> PushProvider.FCM
unifiedPushAvailable -> PushProvider.UNIFIED_PUSH
else -> PushProvider.GMS_LESS
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/monogram/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class MainActivity : FragmentActivity() {
}

private fun startNotificationService() {
if (appPreferences.pushProvider.value == PushProvider.FCM) return
if (appPreferences.pushProvider.value != PushProvider.GMS_LESS) return
val intent = Intent(this, TdNotificationService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent)
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/monogram/app/di/DistrManagerImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.google.android.gms.common.ConnectionResult
import com.google.android.gms.common.GoogleApiAvailability
import com.google.firebase.FirebaseApp
import org.monogram.domain.managers.DistrManager
import org.unifiedpush.android.connector.UnifiedPush

class DistrManagerImpl(private val context: Context) : DistrManager {
override fun isGmsAvailable(): Boolean {
Expand All @@ -16,6 +17,10 @@ class DistrManagerImpl(private val context: Context) : DistrManager {
return FirebaseApp.getApps(context).isNotEmpty()
}

override fun isUnifiedPushDistributorAvailable(): Boolean {
return UnifiedPush.getDistributors(context).isNotEmpty()
}

override fun isInstalledFromGooglePlay(): Boolean {
val installer = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
context.packageManager.getInstallSourceInfo(context.packageName).installingPackageName
Expand Down
Loading