diff --git a/.gitignore b/.gitignore index aa724b7..a593cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,28 @@ -*.iml -.gradle -/local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml +# macOS .DS_Store -/build -/captures -.externalNativeBuild -.cxx + +# Gradle and Android build output +.gradle/ +build/ +*/build/ +.externalNativeBuild/ +.cxx/ +captures/ + +# Local SDK, signing, and machine-specific files local.properties +*.iml +*.jks +*.keystore +keystore.properties + +# Android Studio local state +.idea/caches/ +.idea/libraries/ +.idea/modules.xml +.idea/workspace.xml +.idea/navEditor.xml +.idea/assetWizardSettings.xml +.idea/deploymentTargetSelector.xml +.idea/deviceManager.xml +.idea/shelf/ diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml deleted file mode 100644 index ca16a99..0000000 --- a/.idea/deploymentTargetSelector.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/deviceManager.xml b/.idea/deviceManager.xml deleted file mode 100644 index 91f9558..0000000 --- a/.idea/deviceManager.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6a6641e --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +# Remaining + +Remaining is an Android quota tracker for Iranian mobile and internet services. It stores account credentials locally, refreshes usage data in the background, and presents quota, expiry, refresh, and risk signals in the app and home-screen widgets. + +## Features + +- Tracks MCI, Jahan Nama / Webotel, and TCI Internet accounts. +- Shows remaining traffic, package details, expiry risk, stale refreshes, captcha needs, and authentication errors. +- Supports manual refresh, configurable background refresh intervals, low-data alerts, and app-wide theme settings. +- Includes multiple home-screen widgets for account spotlight, provider mix, watchlist, refresh timeline, compact signal, and account matrix views. +- Encrypts saved passwords, tokens, cookies, and session payloads with Android Keystore-backed AES-GCM. + +This project is not affiliated with MCI, TCI, Jahan Nama, Webotel, or their parent companies. + +## Requirements + +- Android Studio or the Android SDK command line tools. +- JDK 17 or newer. +- Android SDK platform for compile SDK 37. + +## Build + +From the repository root: + +```sh +./gradlew :app:assembleDebug +``` + +Run local unit tests: + +```sh +./gradlew :app:testDebugUnitTest +``` + +Run Android lint: + +```sh +./gradlew :app:lintDebug +``` + +The first build may download Gradle, Android Gradle Plugin, Kotlin, Compose, Room, WorkManager, OkHttp, jsoup, and test dependencies. + +## Project Structure + +- `app/src/main/java/net/rodakot/remaining/connectors`: provider-specific network clients and parsers. +- `app/src/main/java/net/rodakot/remaining/data`: Room entities, DAO, settings, and account repository. +- `app/src/main/java/net/rodakot/remaining/refresh`: WorkManager scheduling and notifications. +- `app/src/main/java/net/rodakot/remaining/security`: local credential encryption. +- `app/src/main/java/net/rodakot/remaining/ui`: Compose app, screens, theme, and UI helpers. +- `app/src/main/java/net/rodakot/remaining/widget`: AppWidget providers, renderers, and widget configuration. +- `docs`: observed provider API notes used by the connectors. + +## Privacy And Security + +- Credentials and session artifacts are stored only on the device and encrypted through Android Keystore. +- App backup is disabled in the manifest, and backup/data-extraction rules exclude app data. +- Do not commit `local.properties`, keystores, signing configs, real account credentials, API tokens, or generated build output. +- The provider API documentation contains placeholders only. Replace examples with sanitized values if you update those docs. + +## Publishing Checklist + +Before pushing this repository publicly: + +- Choose a license and add a `LICENSE` file if you want others to reuse or contribute to the code. +- Review package name, app name, icon, and screenshots for your intended public identity. +- Keep release signing material outside Git and document release signing separately if needed. +- Run `./gradlew :app:testDebugUnitTest :app:lintDebug :app:assembleDebug`. diff --git a/app/src/androidTest/java/net/rodakot/remaining/ExampleInstrumentedTest.kt b/app/src/androidTest/java/net/rodakot/remaining/ExampleInstrumentedTest.kt deleted file mode 100644 index 619057e..0000000 --- a/app/src/androidTest/java/net/rodakot/remaining/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package net.rodakot.remaining - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("net.rodakot.remaining", appContext.packageName) - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8d43156..b24b85c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -123,7 +123,6 @@ diff --git a/app/src/main/java/net/rodakot/remaining/refresh/NotificationHelper.kt b/app/src/main/java/net/rodakot/remaining/refresh/NotificationHelper.kt index e87e821..2d22e0e 100644 --- a/app/src/main/java/net/rodakot/remaining/refresh/NotificationHelper.kt +++ b/app/src/main/java/net/rodakot/remaining/refresh/NotificationHelper.kt @@ -14,7 +14,6 @@ import kotlin.math.absoluteValue class NotificationHelper(private val context: Context) { fun ensureChannel() { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return val channel = NotificationChannel( CHANNEL_ID, "Account alerts", @@ -37,8 +36,12 @@ class NotificationHelper(private val context: Context) { .setPriority(NotificationCompat.PRIORITY_DEFAULT) .build() - NotificationManagerCompat.from(context) - .notify(accountId.hashCode().absoluteValue, notification) + try { + NotificationManagerCompat.from(context) + .notify(accountId.hashCode().absoluteValue, notification) + } catch (exception: SecurityException) { + // Notification permission may be revoked between the check and notify(). + } } private fun canPostNotifications(): Boolean { diff --git a/app/src/main/java/net/rodakot/remaining/ui/components/UiHelpers.kt b/app/src/main/java/net/rodakot/remaining/ui/components/UiHelpers.kt index 96d6280..3ba3f47 100644 --- a/app/src/main/java/net/rodakot/remaining/ui/components/UiHelpers.kt +++ b/app/src/main/java/net/rodakot/remaining/ui/components/UiHelpers.kt @@ -259,7 +259,7 @@ fun QuotaRing( progress: Float?, label: String, value: String, - modifier: Modifier = Modifier.size(156.dp), + modifier: Modifier = Modifier, accent: Color = MaterialTheme.colorScheme.primary ) { val trackColor = MaterialTheme.colorScheme.surfaceContainerHighest diff --git a/app/src/main/java/net/rodakot/remaining/ui/screens/DashboardScreen.kt b/app/src/main/java/net/rodakot/remaining/ui/screens/DashboardScreen.kt index 5ff77e9..4608fc7 100644 --- a/app/src/main/java/net/rodakot/remaining/ui/screens/DashboardScreen.kt +++ b/app/src/main/java/net/rodakot/remaining/ui/screens/DashboardScreen.kt @@ -180,7 +180,12 @@ private fun EmptyDashboard(modifier: Modifier = Modifier, onAddAccount: () -> Un verticalArrangement = Arrangement.spacedBy(18.dp), modifier = Modifier.fillMaxWidth() ) { - QuotaRing(progress = null, label = "dashboard", value = "Ready") + QuotaRing( + progress = null, + label = "dashboard", + value = "Ready", + modifier = Modifier.size(156.dp) + ) Column(horizontalAlignment = Alignment.CenterHorizontally) { Text( "Your usage command center", diff --git a/app/src/main/java/net/rodakot/remaining/ui/screens/WidgetGalleryScreen.kt b/app/src/main/java/net/rodakot/remaining/ui/screens/WidgetGalleryScreen.kt index 163c6cf..9977d67 100644 --- a/app/src/main/java/net/rodakot/remaining/ui/screens/WidgetGalleryScreen.kt +++ b/app/src/main/java/net/rodakot/remaining/ui/screens/WidgetGalleryScreen.kt @@ -60,8 +60,7 @@ fun WidgetGalleryScreen( ) { val context = LocalContext.current val canPin = remember { - Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && - AppWidgetManager.getInstance(context).isRequestPinAppWidgetSupported + AppWidgetManager.getInstance(context).isRequestPinAppWidgetSupported } RemainingBackground { @@ -118,17 +117,15 @@ fun WidgetGalleryScreen( accounts = accounts, canPin = canPin, onPin = { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - AppWidgetManager.getInstance(context).requestPinAppWidget( - ComponentName(context, AccountChartTileWidgetProvider::class.java), - null, - accountWidgetConfigureCallback( - context, - AccountChartTileWidgetProvider::class.java.name, - ACCOUNT_CHART_TILE_CONFIGURE_REQUEST - ) + AppWidgetManager.getInstance(context).requestPinAppWidget( + ComponentName(context, AccountChartTileWidgetProvider::class.java), + null, + accountWidgetConfigureCallback( + context, + AccountChartTileWidgetProvider::class.java.name, + ACCOUNT_CHART_TILE_CONFIGURE_REQUEST ) - } + ) } ) } @@ -137,17 +134,15 @@ fun WidgetGalleryScreen( accounts = accounts, canPin = canPin, onPin = { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - AppWidgetManager.getInstance(context).requestPinAppWidget( - ComponentName(context, AccountSpotlightWidgetProvider::class.java), - null, - accountWidgetConfigureCallback( - context, - AccountSpotlightWidgetProvider::class.java.name, - ACCOUNT_SPOTLIGHT_CONFIGURE_REQUEST - ) + AppWidgetManager.getInstance(context).requestPinAppWidget( + ComponentName(context, AccountSpotlightWidgetProvider::class.java), + null, + accountWidgetConfigureCallback( + context, + AccountSpotlightWidgetProvider::class.java.name, + ACCOUNT_SPOTLIGHT_CONFIGURE_REQUEST ) - } + ) } ) } @@ -157,13 +152,11 @@ fun WidgetGalleryScreen( accounts = accounts, canPin = canPin, onPin = { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - AppWidgetManager.getInstance(context).requestPinAppWidget( - type.componentName(context), - null, - null - ) - } + AppWidgetManager.getInstance(context).requestPinAppWidget( + type.componentName(context), + null, + null + ) } ) } diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 0c96770..df195a4 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -2,8 +2,4 @@ #0D1117 #151B23 - #8FD8FF - #3DDC84 - #FF000000 - #FFFFFFFF diff --git a/app/src/main/res/xml/backup_rules.xml b/app/src/main/res/xml/backup_rules.xml index 4df9255..24bad93 100644 --- a/app/src/main/res/xml/backup_rules.xml +++ b/app/src/main/res/xml/backup_rules.xml @@ -1,13 +1,4 @@ - + - - \ No newline at end of file + + diff --git a/app/src/main/res/xml/data_extraction_rules.xml b/app/src/main/res/xml/data_extraction_rules.xml index 9ee9997..2130cfd 100644 --- a/app/src/main/res/xml/data_extraction_rules.xml +++ b/app/src/main/res/xml/data_extraction_rules.xml @@ -1,19 +1,9 @@ - + - + - - \ No newline at end of file + diff --git a/app/src/test/java/net/rodakot/remaining/ExampleUnitTest.kt b/app/src/test/java/net/rodakot/remaining/ExampleUnitTest.kt deleted file mode 100644 index 2d5142a..0000000 --- a/app/src/test/java/net/rodakot/remaining/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package net.rodakot.remaining - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file diff --git a/docs/mci-api.md b/docs/mci-api.md index d840a8a..be175ca 100644 --- a/docs/mci-api.md +++ b/docs/mci-api.md @@ -14,7 +14,7 @@ curl 'https://my.mci.ir/api/idm/v1/auth' \ -H 'Referer: https://my.mci.ir' \ -H 'platform: WEB' \ -H 'version: 1.29.0' \ - --data-raw '{"username":"9123456789","credential":"xxxx","credential_type":"PASSWORD"}' + --data-raw '{"username":"YOUR_MCI_USERNAME","credential":"YOUR_PASSWORD","credential_type":"PASSWORD"}' ``` ### response @@ -46,7 +46,7 @@ curl 'https://my.mci.ir/api/idm/v1/auth' \ -H 'Referer: https://my.mci.ir' \ -H 'platform: WEB' \ -H 'version: 1.29.0' \ - --data-raw '{"username":"9123456789","credential_type":"REFRESH_TOKEN","credential":"eyJhbG..."}' + --data-raw '{"username":"YOUR_MCI_USERNAME","credential_type":"REFRESH_TOKEN","credential":"eyJhbG..."}' ``` ### response