Compare commits
2 Commits
dev
...
WIP-PhoneC
Author | SHA1 | Date | |
---|---|---|---|
1867c025fd | |||
90cea674d4 |
@ -1,31 +0,0 @@
|
|||||||
on:
|
|
||||||
push:
|
|
||||||
paths:
|
|
||||||
- dialer/**
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: debian
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
with:
|
|
||||||
subpath: dialer/
|
|
||||||
- uses: docker://git.gmoker.com/icing/flutter:main
|
|
||||||
- uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: icing-dialer-${{ gitea.ref_name }}-${{ gitea.run_id }}.apk
|
|
||||||
path: build/app/outputs/flutter-apk/app-release.apk
|
|
||||||
|
|
||||||
build-stealth:
|
|
||||||
runs-on: debian
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
with:
|
|
||||||
subpath: dialer/
|
|
||||||
- uses: docker://git.gmoker.com/icing/flutter:main
|
|
||||||
with:
|
|
||||||
args: "build apk --dart-define=STEALTH=true"
|
|
||||||
- uses: actions/upload-artifact@v1
|
|
||||||
with:
|
|
||||||
name: icing-dialer-stealth-${{ gitea.ref_name }}-${{ gitea.run_id }}.apk
|
|
||||||
path: build/app/outputs/flutter-apk/app-release.apk
|
|
@ -6,10 +6,11 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: debian
|
runs-on: debian
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: website
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
with:
|
|
||||||
subpath: website/
|
|
||||||
- name: setup env
|
- name: setup env
|
||||||
run: |
|
run: |
|
||||||
. ./.env || true
|
. ./.env || true
|
||||||
@ -28,8 +29,10 @@ jobs:
|
|||||||
- uses: actions/kaniko@v1
|
- uses: actions/kaniko@v1
|
||||||
with:
|
with:
|
||||||
password: "${{ secrets.PKGRW }}"
|
password: "${{ secrets.PKGRW }}"
|
||||||
|
dockerfile: website/Dockerfile
|
||||||
|
|
||||||
- uses: actions/k8sdeploy@v1
|
- uses: actions/k8sdeploy@v1
|
||||||
with:
|
with:
|
||||||
kubeconfig: "${{ secrets.K8S }}"
|
kubeconfig: "${{ secrets.K8S }}"
|
||||||
registry_password: "${{ secrets.PKGRW }}"
|
registry_password: "${{ secrets.PKGRW }}"
|
||||||
|
workdir: website
|
||||||
|
2
.gitignore
vendored
@ -182,5 +182,3 @@ app.*.symbols
|
|||||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
||||||
!/dev/ci/**/Gemfile.lock
|
!/dev/ci/**/Gemfile.lock
|
||||||
!.vscode/settings.json
|
!.vscode/settings.json
|
||||||
dialer/android/gradle.properties
|
|
||||||
.gitignore
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
# Icing
|
# Icing
|
||||||
|
|
||||||
## Encrypting phone calls on an analog audio level
|
|
||||||
|
|
||||||
An Epitech Innovation Project
|
An Epitech Innovation Project
|
||||||
|
|
||||||
*By*
|
*By*
|
||||||
@ -10,12 +8,6 @@ An Epitech Innovation Project
|
|||||||
---
|
---
|
||||||
|
|
||||||
The **docs** folder contains documentation about:
|
The **docs** folder contains documentation about:
|
||||||
|
|
||||||
#### Epitech
|
|
||||||
- The Beta Test Plan
|
|
||||||
- The Delivrables
|
|
||||||
|
|
||||||
#### Icing
|
|
||||||
- The project
|
- The project
|
||||||
- A user manual
|
- A user manual
|
||||||
- Our automations
|
- Our automations
|
||||||
|
2
dialer/android/.gitignore
vendored
@ -4,10 +4,8 @@ gradle-wrapper.jar
|
|||||||
/gradlew
|
/gradlew
|
||||||
/gradlew.bat
|
/gradlew.bat
|
||||||
/local.properties
|
/local.properties
|
||||||
/gradle.properties
|
|
||||||
GeneratedPluginRegistrant.java
|
GeneratedPluginRegistrant.java
|
||||||
gradle.properties
|
gradle.properties
|
||||||
.cxx
|
|
||||||
|
|
||||||
# Remember to never publicly share your keystore.
|
# Remember to never publicly share your keystore.
|
||||||
# See https://flutter.dev/to/reference-keystore
|
# See https://flutter.dev/to/reference-keystore
|
||||||
|
@ -6,22 +6,22 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.icing.dialer"
|
namespace = "com.example.dialer"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = flutter.ndkVersion
|
ndkVersion = flutter.ndkVersion
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = JavaVersion.VERSION_17
|
jvmTarget = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId = "com.icing.dialer"
|
applicationId = "com.example.dialer"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||||
minSdk = flutter.minSdkVersion
|
minSdk = flutter.minSdkVersion
|
||||||
|
@ -1,93 +1,39 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.icing.dialer">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-feature android:name="android.hardware.telephony" android:required="true" />
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
|
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||||
<uses-permission android:name="android.permission.CALL_PHONE"/>
|
<uses-permission android:name="android.permission.CALL_PHONE"/>
|
||||||
|
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS"/>
|
||||||
<uses-permission android:name="android.permission.SEND_SMS"/>
|
<uses-permission android:name="android.permission.SEND_SMS"/>
|
||||||
<uses-permission android:name="android.permission.READ_BLOCKED_NUMBERS"/>
|
<uses-permission android:name="android.permission.READ_BLOCKED_NUMBERS"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_BLOCKED_NUMBERS"/>
|
<uses-permission android:name="android.permission.WRITE_BLOCKED_NUMBERS"/>
|
||||||
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
|
||||||
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>
|
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>
|
||||||
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
|
<uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<application android:label="Icing Dialer" android:name="${applicationName}" android:icon="@mipmap/ic_launcher" android:enableOnBackInvokedCallback="true">
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:taskAffinity="" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
|
||||||
|
|
||||||
<application
|
|
||||||
android:label="Icing Dialer"
|
|
||||||
android:name="${applicationName}"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
|
||||||
android:enableOnBackInvokedCallback="true">
|
|
||||||
<activity
|
|
||||||
android:name=".activities.MainActivity"
|
|
||||||
android:exported="true"
|
|
||||||
android:launchMode="singleTop"
|
|
||||||
android:taskAffinity=""
|
|
||||||
android:theme="@style/LaunchTheme"
|
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
|
||||||
android:hardwareAccelerated="true"
|
|
||||||
android:windowSoftInputMode="adjustResize">
|
|
||||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||||
the Android process has started. This theme is visible to the user
|
the Android process has started. This theme is visible to the user
|
||||||
while the Flutter UI initializes. After that, this theme continues
|
while the Flutter UI initializes. After that, this theme continues
|
||||||
to determine the Window background behind the Flutter UI. -->
|
to determine the Window background behind the Flutter UI. -->
|
||||||
<meta-data
|
<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme"/>
|
||||||
android:name="io.flutter.embedding.android.NormalTheme"
|
|
||||||
android:resource="@style/NormalTheme"
|
|
||||||
/>
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!-- Dialer intent filters (required for default dialer eligibility) -->
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.DIAL" />
|
<action android:name="android.intent.action.DIAL" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.DIAL" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:scheme="tel" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.CALL" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
|
||||||
<data android:scheme="tel" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
</activity>
|
||||||
<service
|
<service android:name=".MyConnectionService" android:label="My Connection Service" android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" android:exported="true">
|
||||||
android:name=".services.MyInCallService"
|
|
||||||
android:permission="android.permission.BIND_INCALL_SERVICE"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.telecom.InCallService" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data
|
|
||||||
android:name="android.telecom.IN_CALL_SERVICE_UI"
|
|
||||||
android:value="true" />
|
|
||||||
</service>
|
|
||||||
<!-- Custom ConnextionService, will be needed at some point when we implement our own protocol -->
|
|
||||||
<!-- <service
|
|
||||||
android:name=".services.CallConnectionService"
|
|
||||||
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
|
|
||||||
android:exported="true">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.telecom.ConnectionService"/>
|
<action android:name="android.telecom.ConnectionService"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service> -->
|
</service>
|
||||||
|
|
||||||
<!-- Don't delete the meta-data below.
|
<!-- Don't delete the meta-data below.
|
||||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||||
<meta-data
|
<meta-data android:name="flutterEmbedding" android:value="2"/>
|
||||||
android:name="flutterEmbedding"
|
|
||||||
android:value="2" />
|
|
||||||
</application>
|
</application>
|
||||||
<!-- Required to query activities that can process text, see:
|
<!-- Required to query activities that can process text, see:
|
||||||
https://developer.android.com/training/package-visibility and
|
https://developer.android.com/training/package-visibility and
|
||||||
|
@ -0,0 +1,218 @@
|
|||||||
|
package com.example.dialer
|
||||||
|
|
||||||
|
import android.app.role.RoleManager
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.Build
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.telecom.PhoneAccount
|
||||||
|
import android.telecom.PhoneAccountHandle
|
||||||
|
import android.telecom.TelecomManager
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.core.app.ActivityCompat
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
|
import io.flutter.plugin.common.MethodChannel
|
||||||
|
|
||||||
|
class MainActivity : FlutterActivity() {
|
||||||
|
private val CHANNEL = "com.example.dialer/call_events"
|
||||||
|
private lateinit var methodChannel: MethodChannel
|
||||||
|
|
||||||
|
// Request code for the default-dialer request.
|
||||||
|
private val DEFAULT_DIALER_REQUEST_CODE = 1001
|
||||||
|
|
||||||
|
// Request code for runtime permissions.
|
||||||
|
private val PERMISSION_REQUEST_CODE = 1002
|
||||||
|
|
||||||
|
// BroadcastReceiver to catch incoming call events from our ConnectionService.
|
||||||
|
private val incomingCallReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
val phoneNumber = intent?.getStringExtra("phoneNumber") ?: "Unknown"
|
||||||
|
notifyIncomingCall(phoneNumber)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
|
super.configureFlutterEngine(flutterEngine)
|
||||||
|
methodChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
|
||||||
|
methodChannel.setMethodCallHandler { call, result ->
|
||||||
|
when (call.method) {
|
||||||
|
"requestDefaultDialer" -> {
|
||||||
|
requestDefaultDialer()
|
||||||
|
result.success(null)
|
||||||
|
}
|
||||||
|
else -> result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
// Request runtime permissions.
|
||||||
|
checkAndRequestPermissions()
|
||||||
|
|
||||||
|
// Create the intent filter for incoming calls.
|
||||||
|
val filter = IntentFilter("com.example.dialer.INCOMING_CALL")
|
||||||
|
// Register the receiver. (For Android 13+ we must specify not exported.)
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
registerReceiver(incomingCallReceiver, filter, Context.RECEIVER_NOT_EXPORTED)
|
||||||
|
} else {
|
||||||
|
registerReceiver(incomingCallReceiver, filter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
unregisterReceiver(incomingCallReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
// Check if we are now the default dialer and update the UI accordingly.
|
||||||
|
if (isDefaultDialer()) {
|
||||||
|
registerManagedPhoneAccount()
|
||||||
|
notifyDefaultDialerSet()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isDefaultDialer(): Boolean {
|
||||||
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
val roleManager = getSystemService(RoleManager::class.java)
|
||||||
|
roleManager.isRoleHeld(RoleManager.ROLE_DIALER)
|
||||||
|
} else {
|
||||||
|
val telecomManager = getSystemService(TELECOM_SERVICE) as TelecomManager
|
||||||
|
telecomManager.defaultDialerPackage == packageName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request to become the default dialer.
|
||||||
|
private fun requestDefaultDialer() {
|
||||||
|
try {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
// Use the RoleManager API for Android Q and above.
|
||||||
|
val roleManager = getSystemService(RoleManager::class.java)
|
||||||
|
if (!roleManager.isRoleHeld(RoleManager.ROLE_DIALER)) {
|
||||||
|
val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_DIALER)
|
||||||
|
startActivityForResult(intent, DEFAULT_DIALER_REQUEST_CODE)
|
||||||
|
Log.d("MainActivity", "Requested ROLE_DIALER via RoleManager")
|
||||||
|
} else {
|
||||||
|
Log.d("MainActivity", "Already default dialer (ROLE_DIALER held)")
|
||||||
|
registerManagedPhoneAccount()
|
||||||
|
notifyDefaultDialerSet()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Fallback for older versions.
|
||||||
|
val telecomManager = getSystemService(TELECOM_SERVICE) as TelecomManager
|
||||||
|
if (telecomManager.defaultDialerPackage != packageName) {
|
||||||
|
val intent = Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER)
|
||||||
|
intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, packageName)
|
||||||
|
startActivityForResult(intent, DEFAULT_DIALER_REQUEST_CODE)
|
||||||
|
Log.d("MainActivity", "Requested default dialer via TelecomManager")
|
||||||
|
} else {
|
||||||
|
registerManagedPhoneAccount()
|
||||||
|
notifyDefaultDialerSet()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
Log.e("MainActivity", "Error requesting default dialer", ex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle the result from the default-dialer role request.
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
if (requestCode == DEFAULT_DIALER_REQUEST_CODE) {
|
||||||
|
Log.d("MainActivity", "onActivityResult received: resultCode=$resultCode")
|
||||||
|
when (resultCode) {
|
||||||
|
RESULT_OK -> {
|
||||||
|
Log.d("MainActivity", "User granted default dialer role")
|
||||||
|
Handler(mainLooper).postDelayed({
|
||||||
|
if (isDefaultDialer()) {
|
||||||
|
Log.d("MainActivity", "Default dialer successfully set")
|
||||||
|
registerManagedPhoneAccount()
|
||||||
|
notifyDefaultDialerSet()
|
||||||
|
} else {
|
||||||
|
Log.d("MainActivity", "Default dialer not set")
|
||||||
|
// Notify Flutter that the default dialer role was not set
|
||||||
|
methodChannel.invokeMethod("onDefaultDialerNotSet", null)
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
RESULT_CANCELED -> {
|
||||||
|
Log.d("MainActivity", "User denied default dialer role")
|
||||||
|
// Notify Flutter that the user denied the request
|
||||||
|
methodChannel.invokeMethod("onDefaultDialerDenied", null)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
Log.d("MainActivity", "Unknown resultCode: $resultCode")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register a managed PhoneAccount with the TelecomManager.
|
||||||
|
private fun registerManagedPhoneAccount() {
|
||||||
|
val telecomManager = getSystemService(TELECOM_SERVICE) as TelecomManager
|
||||||
|
val phoneAccountHandle = PhoneAccountHandle(
|
||||||
|
ComponentName(this, MyConnectionService::class.java),
|
||||||
|
"MyPhoneAccountID"
|
||||||
|
)
|
||||||
|
val phoneAccount = PhoneAccount.builder(phoneAccountHandle, "Icing Dialer")
|
||||||
|
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
|
||||||
|
.setShortDescription("Icing Custom Dialer")
|
||||||
|
.build()
|
||||||
|
telecomManager.registerPhoneAccount(phoneAccount)
|
||||||
|
Log.d("MainActivity", "PhoneAccount registered")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify Flutter that we are now the default dialer.
|
||||||
|
private fun notifyDefaultDialerSet() {
|
||||||
|
methodChannel.invokeMethod("onDefaultDialerSet", null)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify Flutter of an incoming call.
|
||||||
|
private fun notifyIncomingCall(phoneNumber: String) {
|
||||||
|
methodChannel.invokeMethod("onIncomingCall", phoneNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check and request runtime permissions.
|
||||||
|
private fun checkAndRequestPermissions() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
val permissionsNeeded = mutableListOf<String>()
|
||||||
|
val permissionsToRequest = mutableListOf<String>()
|
||||||
|
|
||||||
|
// Check if permissions are granted
|
||||||
|
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
permissionsToRequest.add(android.Manifest.permission.READ_PHONE_STATE)
|
||||||
|
}
|
||||||
|
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
permissionsToRequest.add(android.Manifest.permission.CALL_PHONE)
|
||||||
|
}
|
||||||
|
if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.ANSWER_PHONE_CALLS) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
permissionsToRequest.add(android.Manifest.permission.ANSWER_PHONE_CALLS)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request permissions if needed
|
||||||
|
if (permissionsToRequest.isNotEmpty()) {
|
||||||
|
ActivityCompat.requestPermissions(this, permissionsToRequest.toTypedArray(), PERMISSION_REQUEST_CODE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
|
if (requestCode == PERMISSION_REQUEST_CODE) {
|
||||||
|
if (grantResults.all { it == PackageManager.PERMISSION_GRANTED }) {
|
||||||
|
Log.d("MainActivity", "All permissions granted")
|
||||||
|
} else {
|
||||||
|
Log.d("MainActivity", "Some permissions denied")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
// File: android/app/src/main/kotlin/com/example/dialer/MyConnection.kt
|
||||||
|
package com.example.dialer
|
||||||
|
|
||||||
|
import android.telecom.Connection
|
||||||
|
import android.telecom.DisconnectCause
|
||||||
|
import android.util.Log
|
||||||
|
|
||||||
|
class MyConnection : Connection() {
|
||||||
|
|
||||||
|
override fun onAnswer(videoState: Int) {
|
||||||
|
super.onAnswer(videoState)
|
||||||
|
Log.d("MyConnection", "onAnswer called")
|
||||||
|
setActive()
|
||||||
|
// (You can later add notifications back to Flutter here if needed.)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReject() {
|
||||||
|
super.onReject()
|
||||||
|
Log.d("MyConnection", "onReject called")
|
||||||
|
setDisconnected(DisconnectCause(DisconnectCause.REJECTED))
|
||||||
|
destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDisconnect() {
|
||||||
|
super.onDisconnect()
|
||||||
|
Log.d("MyConnection", "onDisconnect called")
|
||||||
|
setDisconnected(DisconnectCause(DisconnectCause.LOCAL))
|
||||||
|
destroy()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
// File: android/app/src/main/kotlin/com/example/dialer/MyConnectionService.kt
|
||||||
|
package com.example.dialer
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
|
import android.telecom.Connection
|
||||||
|
import android.telecom.ConnectionRequest
|
||||||
|
import android.telecom.ConnectionService
|
||||||
|
import android.telecom.PhoneAccountHandle
|
||||||
|
import android.util.Log
|
||||||
|
|
||||||
|
class MyConnectionService : ConnectionService() {
|
||||||
|
|
||||||
|
override fun onCreateIncomingConnection(
|
||||||
|
connectionManagerPhoneAccount: PhoneAccountHandle,
|
||||||
|
request: ConnectionRequest
|
||||||
|
): Connection? {
|
||||||
|
Log.d("MyConnectionService", "onCreateIncomingConnection")
|
||||||
|
val myConnection = MyConnection()
|
||||||
|
|
||||||
|
// Try to extract the incoming phone number from the request.
|
||||||
|
val phoneUri: Uri? = request.address
|
||||||
|
val phoneNumber = phoneUri?.schemeSpecificPart ?: "Unknown"
|
||||||
|
|
||||||
|
// Broadcast an intent so MainActivity can notify Flutter.
|
||||||
|
val intent = Intent("com.example.dialer.INCOMING_CALL")
|
||||||
|
intent.putExtra("phoneNumber", phoneNumber)
|
||||||
|
applicationContext.sendBroadcast(intent)
|
||||||
|
|
||||||
|
// Mark the connection as ringing.
|
||||||
|
myConnection.setRinging()
|
||||||
|
return myConnection
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOutgoingConnection(
|
||||||
|
connectionManagerPhoneAccount: PhoneAccountHandle,
|
||||||
|
request: ConnectionRequest
|
||||||
|
): Connection? {
|
||||||
|
Log.d("MyConnectionService", "onCreateOutgoingConnection")
|
||||||
|
val myConnection = MyConnection()
|
||||||
|
myConnection.setDialing()
|
||||||
|
return myConnection
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +0,0 @@
|
|||||||
package com.icing.dialer
|
|
||||||
|
|
||||||
import java.security.KeyStore
|
|
||||||
|
|
||||||
object KeyDeleterHelper {
|
|
||||||
|
|
||||||
private const val ANDROID_KEYSTORE = "AndroidKeyStore"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the key pair associated with the given alias from the Android Keystore.
|
|
||||||
*
|
|
||||||
* @param alias The alias of the key pair to delete.
|
|
||||||
* @throws Exception if deletion fails.
|
|
||||||
*/
|
|
||||||
fun deleteKeyPair(alias: String) {
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
|
|
||||||
if (!keyStore.containsAlias(alias)) {
|
|
||||||
throw Exception("No key found with alias \"$alias\" to delete.")
|
|
||||||
}
|
|
||||||
|
|
||||||
keyStore.deleteEntry(alias)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
throw Exception("Failed to delete key pair: ${e.message}", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
package com.icing.dialer
|
|
||||||
|
|
||||||
import android.security.keystore.KeyGenParameterSpec
|
|
||||||
import android.security.keystore.KeyProperties
|
|
||||||
import java.security.KeyPairGenerator
|
|
||||||
import java.security.KeyStore
|
|
||||||
|
|
||||||
object KeyGeneratorHelper {
|
|
||||||
|
|
||||||
private const val ANDROID_KEYSTORE = "AndroidKeyStore"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates an ECDSA P-256 key pair and stores it in the Android Keystore.
|
|
||||||
*
|
|
||||||
* @param alias Unique identifier for the key pair.
|
|
||||||
* @throws Exception if key generation fails.
|
|
||||||
*/
|
|
||||||
fun generateECKeyPair(alias: String) {
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
|
|
||||||
// Check if the key already exists
|
|
||||||
if (keyStore.containsAlias(alias)) {
|
|
||||||
throw Exception("Key with alias \"$alias\" already exists.")
|
|
||||||
}
|
|
||||||
|
|
||||||
val keyPairGenerator = KeyPairGenerator.getInstance(
|
|
||||||
KeyProperties.KEY_ALGORITHM_EC,
|
|
||||||
ANDROID_KEYSTORE
|
|
||||||
)
|
|
||||||
|
|
||||||
val parameterSpec = KeyGenParameterSpec.Builder(
|
|
||||||
alias,
|
|
||||||
KeyProperties.PURPOSE_SIGN or KeyProperties.PURPOSE_VERIFY
|
|
||||||
)
|
|
||||||
.setAlgorithmParameterSpec(java.security.spec.ECGenParameterSpec("secp256r1"))
|
|
||||||
.setDigests(KeyProperties.DIGEST_SHA256, KeyProperties.DIGEST_SHA384, KeyProperties.DIGEST_SHA512)
|
|
||||||
.setUserAuthenticationRequired(false) // Set to true if you require user authentication
|
|
||||||
.build()
|
|
||||||
|
|
||||||
keyPairGenerator.initialize(parameterSpec)
|
|
||||||
keyPairGenerator.generateKeyPair()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
throw Exception("Failed to generate EC key pair: ${e.message}", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,154 +0,0 @@
|
|||||||
package com.icing.dialer
|
|
||||||
|
|
||||||
import java.security.PrivateKey
|
|
||||||
import android.security.keystore.KeyGenParameterSpec
|
|
||||||
import android.security.keystore.KeyProperties
|
|
||||||
import android.util.Base64
|
|
||||||
import io.flutter.plugin.common.MethodCall
|
|
||||||
import io.flutter.plugin.common.MethodChannel
|
|
||||||
import java.security.KeyPairGenerator
|
|
||||||
import java.security.KeyStore
|
|
||||||
import java.security.Signature
|
|
||||||
|
|
||||||
class KeystoreHelper(private val call: MethodCall, private val result: MethodChannel.Result) {
|
|
||||||
|
|
||||||
private val ANDROID_KEYSTORE = "AndroidKeyStore"
|
|
||||||
|
|
||||||
fun handleMethodCall() {
|
|
||||||
when (call.method) {
|
|
||||||
"generateKeyPair" -> generateECKeyPair()
|
|
||||||
"signData" -> signData()
|
|
||||||
"getPublicKey" -> getPublicKey()
|
|
||||||
"deleteKeyPair" -> deleteKeyPair()
|
|
||||||
"keyPairExists" -> keyPairExists()
|
|
||||||
else -> result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun generateECKeyPair() {
|
|
||||||
val alias = call.argument<String>("alias")
|
|
||||||
if (alias == null) {
|
|
||||||
result.error("INVALID_ARGUMENT", "Alias is required", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
|
|
||||||
if (keyStore.containsAlias(alias)) {
|
|
||||||
result.error("KEY_EXISTS", "Key with alias \"$alias\" already exists.", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val keyPairGenerator = KeyPairGenerator.getInstance(
|
|
||||||
KeyProperties.KEY_ALGORITHM_EC,
|
|
||||||
ANDROID_KEYSTORE
|
|
||||||
)
|
|
||||||
|
|
||||||
val parameterSpec = KeyGenParameterSpec.Builder(
|
|
||||||
alias,
|
|
||||||
KeyProperties.PURPOSE_SIGN or KeyProperties.PURPOSE_VERIFY
|
|
||||||
)
|
|
||||||
.setAlgorithmParameterSpec(java.security.spec.ECGenParameterSpec("secp256r1"))
|
|
||||||
.setDigests(KeyProperties.DIGEST_SHA256, KeyProperties.DIGEST_SHA384, KeyProperties.DIGEST_SHA512)
|
|
||||||
.setUserAuthenticationRequired(false)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
keyPairGenerator.initialize(parameterSpec)
|
|
||||||
keyPairGenerator.generateKeyPair()
|
|
||||||
|
|
||||||
result.success(null)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
result.error("KEY_GENERATION_FAILED", e.message, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun signData() {
|
|
||||||
val alias = call.argument<String>("alias")
|
|
||||||
val data = call.argument<String>("data")
|
|
||||||
if (alias == null || data == null) {
|
|
||||||
result.error("INVALID_ARGUMENT", "Alias and data are required", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
|
|
||||||
val privateKey = keyStore.getKey(alias, null) as? PrivateKey ?: run {
|
|
||||||
result.error("KEY_NOT_FOUND", "Private key not found for alias \"$alias\".", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val signature = Signature.getInstance("SHA256withECDSA")
|
|
||||||
signature.initSign(privateKey)
|
|
||||||
signature.update(data.toByteArray())
|
|
||||||
val signedBytes = signature.sign()
|
|
||||||
|
|
||||||
val signatureBase64 = Base64.encodeToString(signedBytes, Base64.DEFAULT)
|
|
||||||
result.success(signatureBase64)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
result.error("SIGNING_FAILED", e.message, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getPublicKey() {
|
|
||||||
val alias = call.argument<String>("alias")
|
|
||||||
if (alias == null) {
|
|
||||||
result.error("INVALID_ARGUMENT", "Alias is required", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
|
|
||||||
val certificate = keyStore.getCertificate(alias) ?: run {
|
|
||||||
result.error("CERTIFICATE_NOT_FOUND", "Certificate not found for alias \"$alias\".", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val publicKey = certificate.publicKey
|
|
||||||
val publicKeyBase64 = Base64.encodeToString(publicKey.encoded, Base64.DEFAULT)
|
|
||||||
result.success(publicKeyBase64)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
result.error("PUBLIC_KEY_RETRIEVAL_FAILED", e.message, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun deleteKeyPair() {
|
|
||||||
val alias = call.argument<String>("alias")
|
|
||||||
if (alias == null) {
|
|
||||||
result.error("INVALID_ARGUMENT", "Alias is required", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
|
|
||||||
if (!keyStore.containsAlias(alias)) {
|
|
||||||
result.error("KEY_NOT_FOUND", "No key found with alias \"$alias\" to delete.", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
keyStore.deleteEntry(alias)
|
|
||||||
result.success(null)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
result.error("KEY_DELETION_FAILED", e.message, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun keyPairExists() {
|
|
||||||
val alias = call.argument<String>("alias")
|
|
||||||
if (alias == null) {
|
|
||||||
result.error("INVALID_ARGUMENT", "Alias is required", null)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
val exists = keyStore.containsAlias(alias)
|
|
||||||
result.success(exists)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
result.error("KEY_CHECK_FAILED", e.message, null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package com.icing.dialer
|
|
||||||
|
|
||||||
import java.security.KeyStore
|
|
||||||
import java.security.PublicKey
|
|
||||||
import android.util.Base64
|
|
||||||
|
|
||||||
object PublicKeyHelper {
|
|
||||||
|
|
||||||
private const val ANDROID_KEYSTORE = "AndroidKeyStore"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the public key associated with the given alias.
|
|
||||||
*
|
|
||||||
* @param alias The alias of the key pair.
|
|
||||||
* @return The public key as a Base64-encoded string.
|
|
||||||
* @throws Exception if retrieval fails.
|
|
||||||
*/
|
|
||||||
fun getPublicKey(alias: String): String {
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
|
|
||||||
val certificate = keyStore.getCertificate(alias) ?: throw Exception("Certificate not found for alias \"$alias\".")
|
|
||||||
val publicKey: PublicKey = certificate.publicKey
|
|
||||||
|
|
||||||
return Base64.encodeToString(publicKey.encoded, Base64.DEFAULT)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
throw Exception("Failed to retrieve public key: ${e.message}", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
package com.icing.dialer
|
|
||||||
|
|
||||||
import android.security.keystore.KeyProperties
|
|
||||||
import java.security.KeyStore
|
|
||||||
import java.security.Signature
|
|
||||||
import android.util.Base64
|
|
||||||
import java.security.PrivateKey
|
|
||||||
|
|
||||||
object SignerHelper {
|
|
||||||
|
|
||||||
private const val ANDROID_KEYSTORE = "AndroidKeyStore"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signs the provided data using the private key associated with the given alias.
|
|
||||||
*
|
|
||||||
* @param alias The alias of the key pair.
|
|
||||||
* @param data The data to sign.
|
|
||||||
* @return The signature as a Base64-encoded string.
|
|
||||||
* @throws Exception if signing fails.
|
|
||||||
*/
|
|
||||||
fun signData(alias: String, data: ByteArray): String {
|
|
||||||
try {
|
|
||||||
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
|
|
||||||
|
|
||||||
val privateKey = keyStore.getKey(alias, null) as? PrivateKey?: throw Exception("Private key not found for alias \"$alias\".")
|
|
||||||
|
|
||||||
val signature = Signature.getInstance("SHA256withECDSA")
|
|
||||||
signature.initSign(privateKey)
|
|
||||||
signature.update(data)
|
|
||||||
val signedBytes = signature.sign()
|
|
||||||
|
|
||||||
return Base64.encodeToString(signedBytes, Base64.DEFAULT)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
throw Exception("Failed to sign data: ${e.message}", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,286 +0,0 @@
|
|||||||
package com.icing.dialer.activities
|
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.app.role.RoleManager
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.database.Cursor
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.provider.CallLog
|
|
||||||
import android.telecom.TelecomManager
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import com.icing.dialer.KeystoreHelper
|
|
||||||
import com.icing.dialer.services.CallService
|
|
||||||
import com.icing.dialer.services.MyInCallService
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
|
||||||
import io.flutter.embedding.engine.FlutterEngine
|
|
||||||
import io.flutter.plugin.common.MethodChannel
|
|
||||||
|
|
||||||
class MainActivity : FlutterActivity() {
|
|
||||||
private val KEYSTORE_CHANNEL = "com.example.keystore"
|
|
||||||
private val CALLLOG_CHANNEL = "com.example.calllog"
|
|
||||||
private val CALL_CHANNEL = "call_service"
|
|
||||||
private val TAG = "MainActivity"
|
|
||||||
private val REQUEST_CODE_SET_DEFAULT_DIALER = 1001
|
|
||||||
private val REQUEST_CODE_CALL_LOG_PERMISSION = 1002
|
|
||||||
private var pendingIncomingCall: Pair<String?, Boolean>? = null
|
|
||||||
private var wasPhoneLocked: Boolean = false
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
Log.d(TAG, "onCreate started")
|
|
||||||
wasPhoneLocked = intent.getBooleanExtra("wasPhoneLocked", false)
|
|
||||||
Log.d(TAG, "Was phone locked at start: $wasPhoneLocked")
|
|
||||||
updateLockScreenFlags(intent)
|
|
||||||
handleIncomingCallIntent(intent)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent) {
|
|
||||||
super.onNewIntent(intent)
|
|
||||||
setIntent(intent)
|
|
||||||
wasPhoneLocked = intent.getBooleanExtra("wasPhoneLocked", false)
|
|
||||||
Log.d(TAG, "onNewIntent, wasPhoneLocked: $wasPhoneLocked")
|
|
||||||
updateLockScreenFlags(intent)
|
|
||||||
handleIncomingCallIntent(intent)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateLockScreenFlags(intent: Intent?) {
|
|
||||||
val isIncomingCall = intent?.getBooleanExtra("isIncomingCall", false) ?: false
|
|
||||||
if (isIncomingCall && wasPhoneLocked) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
|
||||||
setShowWhenLocked(true)
|
|
||||||
setTurnScreenOn(true)
|
|
||||||
} else {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
window.addFlags(
|
|
||||||
android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
|
||||||
android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Enabled showWhenLocked and turnScreenOn for incoming call")
|
|
||||||
} else {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
|
||||||
setShowWhenLocked(false)
|
|
||||||
setTurnScreenOn(false)
|
|
||||||
} else {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
window.clearFlags(
|
|
||||||
android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
|
|
||||||
android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Disabled showWhenLocked and turnScreenOn for normal usage")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
|
||||||
super.configureFlutterEngine(flutterEngine)
|
|
||||||
Log.d(TAG, "Configuring Flutter engine")
|
|
||||||
MyInCallService.channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CALL_CHANNEL)
|
|
||||||
|
|
||||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CALL_CHANNEL)
|
|
||||||
.setMethodCallHandler { call, result ->
|
|
||||||
when (call.method) {
|
|
||||||
"permissionsGranted" -> {
|
|
||||||
Log.d(TAG, "Received permissionsGranted from Flutter")
|
|
||||||
pendingIncomingCall?.let { (phoneNumber, showScreen) ->
|
|
||||||
if (showScreen) {
|
|
||||||
MyInCallService.channel?.invokeMethod("incomingCallFromNotification", mapOf(
|
|
||||||
"phoneNumber" to phoneNumber,
|
|
||||||
"wasPhoneLocked" to wasPhoneLocked
|
|
||||||
))
|
|
||||||
pendingIncomingCall = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checkAndRequestDefaultDialer()
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
"makeGsmCall" -> {
|
|
||||||
val phoneNumber = call.argument<String>("phoneNumber")
|
|
||||||
if (phoneNumber != null) {
|
|
||||||
val success = CallService.makeGsmCall(this, phoneNumber)
|
|
||||||
if (success) {
|
|
||||||
result.success(mapOf("status" to "calling", "phoneNumber" to phoneNumber))
|
|
||||||
} else {
|
|
||||||
result.error("CALL_FAILED", "Failed to initiate call", null)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.error("INVALID_PHONE_NUMBER", "Phone number is required", null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"hangUpCall" -> {
|
|
||||||
val success = MyInCallService.currentCall?.let {
|
|
||||||
it.disconnect()
|
|
||||||
Log.d(TAG, "Call disconnected")
|
|
||||||
MyInCallService.channel?.invokeMethod("callEnded", mapOf(
|
|
||||||
"callId" to it.details.handle.toString(),
|
|
||||||
"wasPhoneLocked" to wasPhoneLocked
|
|
||||||
))
|
|
||||||
true
|
|
||||||
} ?: false
|
|
||||||
if (success) {
|
|
||||||
result.success(mapOf("status" to "ended"))
|
|
||||||
if (wasPhoneLocked) {
|
|
||||||
Log.d(TAG, "Finishing and removing task after hangup, phone was locked")
|
|
||||||
finishAndRemoveTask()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "No active call to hang up")
|
|
||||||
result.error("HANGUP_FAILED", "No active call to hang up", null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"answerCall" -> {
|
|
||||||
val success = MyInCallService.currentCall?.let {
|
|
||||||
it.answer(0)
|
|
||||||
Log.d(TAG, "Answered call")
|
|
||||||
true
|
|
||||||
} ?: false
|
|
||||||
if (success) {
|
|
||||||
result.success(mapOf("status" to "answered"))
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "No active call to answer")
|
|
||||||
result.error("ANSWER_FAILED", "No active call to answer", null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"callEndedFromFlutter" -> {
|
|
||||||
Log.d(TAG, "Call ended from Flutter, wasPhoneLocked: $wasPhoneLocked")
|
|
||||||
if (wasPhoneLocked) {
|
|
||||||
finishAndRemoveTask()
|
|
||||||
Log.d(TAG, "Finishing and removing task after call ended, phone was locked")
|
|
||||||
}
|
|
||||||
result.success(true)
|
|
||||||
}
|
|
||||||
else -> result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, KEYSTORE_CHANNEL)
|
|
||||||
.setMethodCallHandler { call, result ->
|
|
||||||
KeystoreHelper(call, result).handleMethodCall()
|
|
||||||
}
|
|
||||||
|
|
||||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CALLLOG_CHANNEL)
|
|
||||||
.setMethodCallHandler { call, result ->
|
|
||||||
if (call.method == "getCallLogs") {
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CALL_LOG) == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
val callLogs = getCallLogs()
|
|
||||||
result.success(callLogs)
|
|
||||||
} else {
|
|
||||||
requestPermissions(arrayOf(Manifest.permission.READ_CALL_LOG), REQUEST_CODE_CALL_LOG_PERMISSION)
|
|
||||||
result.error("PERMISSION_DENIED", "Call log permission not granted", null)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.notImplemented()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkAndRequestDefaultDialer() {
|
|
||||||
val telecomManager = getSystemService(TELECOM_SERVICE) as TelecomManager
|
|
||||||
val currentDefault = telecomManager.defaultDialerPackage
|
|
||||||
Log.d(TAG, "Current default dialer: $currentDefault, My package: $packageName")
|
|
||||||
|
|
||||||
if (currentDefault != packageName) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
||||||
val roleManager = getSystemService(Context.ROLE_SERVICE) as RoleManager
|
|
||||||
if (roleManager.isRoleAvailable(RoleManager.ROLE_DIALER) && !roleManager.isRoleHeld(RoleManager.ROLE_DIALER)) {
|
|
||||||
val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_DIALER)
|
|
||||||
startActivityForResult(intent, REQUEST_CODE_SET_DEFAULT_DIALER)
|
|
||||||
Log.d(TAG, "Launched RoleManager intent for default dialer on API 29+")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val intent = Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER)
|
|
||||||
.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, packageName)
|
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
try {
|
|
||||||
startActivityForResult(intent, REQUEST_CODE_SET_DEFAULT_DIALER)
|
|
||||||
Log.d(TAG, "Launched TelecomManager intent for default dialer")
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Failed to launch default dialer prompt: ${e.message}", e)
|
|
||||||
launchDefaultAppsSettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "Already the default dialer")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun launchDefaultAppsSettings() {
|
|
||||||
val settingsIntent = Intent(android.provider.Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
|
|
||||||
startActivity(settingsIntent)
|
|
||||||
Log.d(TAG, "Opened default apps settings as fallback")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
|
||||||
Log.d(TAG, "onActivityResult: requestCode=$requestCode, resultCode=$resultCode, data=$data")
|
|
||||||
if (requestCode == REQUEST_CODE_SET_DEFAULT_DIALER) {
|
|
||||||
if (resultCode == RESULT_OK) {
|
|
||||||
Log.d(TAG, "User accepted default dialer change")
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "Default dialer prompt canceled or failed (resultCode=$resultCode)")
|
|
||||||
launchDefaultAppsSettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
|
||||||
if (requestCode == REQUEST_CODE_CALL_LOG_PERMISSION) {
|
|
||||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
Log.d(TAG, "Call log permission granted")
|
|
||||||
MyInCallService.channel?.invokeMethod("callLogPermissionGranted", null)
|
|
||||||
} else {
|
|
||||||
Log.w(TAG, "Call log permission denied")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getCallLogs(): List<Map<String, Any?>> {
|
|
||||||
val logsList = mutableListOf<Map<String, Any?>>()
|
|
||||||
val cursor: Cursor? = contentResolver.query(
|
|
||||||
CallLog.Calls.CONTENT_URI, null, null, null, CallLog.Calls.DATE + " DESC"
|
|
||||||
)
|
|
||||||
cursor?.use {
|
|
||||||
while (it.moveToNext()) {
|
|
||||||
val number = it.getString(it.getColumnIndexOrThrow(CallLog.Calls.NUMBER))
|
|
||||||
val type = it.getInt(it.getColumnIndexOrThrow(CallLog.Calls.TYPE))
|
|
||||||
val date = it.getLong(it.getColumnIndexOrThrow(CallLog.Calls.DATE))
|
|
||||||
val duration = it.getLong(it.getColumnIndexOrThrow(CallLog.Calls.DURATION))
|
|
||||||
|
|
||||||
val map = mutableMapOf<String, Any?>(
|
|
||||||
"number" to number,
|
|
||||||
"type" to type,
|
|
||||||
"date" to date,
|
|
||||||
"duration" to duration
|
|
||||||
)
|
|
||||||
logsList.add(map)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return logsList
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleIncomingCallIntent(intent: Intent?) {
|
|
||||||
intent?.let {
|
|
||||||
if (it.getBooleanExtra("isIncomingCall", false)) {
|
|
||||||
val phoneNumber = it.getStringExtra("phoneNumber")
|
|
||||||
val showScreen = it.getBooleanExtra("showIncomingCallScreen", false)
|
|
||||||
Log.d(TAG, "Received incoming call intent for $phoneNumber, showScreen=$showScreen, wasPhoneLocked=$wasPhoneLocked")
|
|
||||||
if (showScreen) {
|
|
||||||
if (MyInCallService.channel != null) {
|
|
||||||
MyInCallService.channel?.invokeMethod("incomingCallFromNotification", mapOf(
|
|
||||||
"phoneNumber" to phoneNumber,
|
|
||||||
"wasPhoneLocked" to wasPhoneLocked
|
|
||||||
))
|
|
||||||
} else {
|
|
||||||
pendingIncomingCall = Pair(phoneNumber, true)
|
|
||||||
Log.d(TAG, "Flutter channel not ready, storing pending call: $phoneNumber")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,82 +0,0 @@
|
|||||||
// package com.icing.dialer.services
|
|
||||||
|
|
||||||
// import android.telecom.Connection
|
|
||||||
// import android.telecom.ConnectionService
|
|
||||||
// import android.telecom.PhoneAccountHandle
|
|
||||||
// import android.telecom.TelecomManager
|
|
||||||
// import android.telecom.DisconnectCause
|
|
||||||
// import android.util.Log
|
|
||||||
// import io.flutter.plugin.common.MethodChannel
|
|
||||||
|
|
||||||
// class CallConnectionService : ConnectionService() {
|
|
||||||
// companion object {
|
|
||||||
// var channel: MethodChannel? = null
|
|
||||||
// private const val TAG = "CallConnectionService"
|
|
||||||
// }
|
|
||||||
|
|
||||||
// init {
|
|
||||||
// Log.d(TAG, "CallConnectionService initialized")
|
|
||||||
// }
|
|
||||||
|
|
||||||
// override fun onCreate() {
|
|
||||||
// super.onCreate()
|
|
||||||
// Log.d(TAG, "Service created")
|
|
||||||
// }
|
|
||||||
|
|
||||||
// override fun onDestroy() {
|
|
||||||
// super.onDestroy()
|
|
||||||
// Log.d(TAG, "Service destroyed")
|
|
||||||
// }
|
|
||||||
|
|
||||||
// override fun onCreateOutgoingConnection(
|
|
||||||
// connectionManagerPhoneAccount: PhoneAccountHandle?,
|
|
||||||
// request: android.telecom.ConnectionRequest
|
|
||||||
// ): Connection {
|
|
||||||
// Log.d(TAG, "Creating outgoing connection for ${request.address}, account: $connectionManagerPhoneAccount")
|
|
||||||
// val connection = object : Connection() {
|
|
||||||
// override fun onStateChanged(state: Int) {
|
|
||||||
// super.onStateChanged(state)
|
|
||||||
// Log.d(TAG, "Connection state changed: $state")
|
|
||||||
// val stateStr = when (state) {
|
|
||||||
// STATE_DIALING -> "dialing"
|
|
||||||
// STATE_ACTIVE -> "active"
|
|
||||||
// STATE_DISCONNECTED -> "disconnected"
|
|
||||||
// else -> "unknown"
|
|
||||||
// }
|
|
||||||
// channel?.invokeMethod("callStateChanged", mapOf("state" to stateStr, "phoneNumber" to request.address.toString()))
|
|
||||||
// }
|
|
||||||
|
|
||||||
// override fun onDisconnect() {
|
|
||||||
// Log.d(TAG, "Connection disconnected")
|
|
||||||
// setDisconnected(DisconnectCause(DisconnectCause.LOCAL))
|
|
||||||
// destroy()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// connection.setAddress(request.address, TelecomManager.PRESENTATION_ALLOWED)
|
|
||||||
// connection.setInitialized()
|
|
||||||
// connection.setDialing()
|
|
||||||
// return connection
|
|
||||||
// }
|
|
||||||
|
|
||||||
// override fun onCreateIncomingConnection(
|
|
||||||
// connectionManagerPhoneAccount: PhoneAccountHandle?,
|
|
||||||
// request: android.telecom.ConnectionRequest
|
|
||||||
// ): Connection {
|
|
||||||
// Log.d(TAG, "Creating incoming connection for ${request.address}, account: $connectionManagerPhoneAccount")
|
|
||||||
// val connection = object : Connection() {
|
|
||||||
// override fun onAnswer() {
|
|
||||||
// Log.d(TAG, "Connection answered")
|
|
||||||
// setActive()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// override fun onDisconnect() {
|
|
||||||
// Log.d(TAG, "Connection disconnected")
|
|
||||||
// setDisconnected(DisconnectCause(DisconnectCause.LOCAL))
|
|
||||||
// destroy()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// connection.setAddress(request.address, TelecomManager.PRESENTATION_ALLOWED)
|
|
||||||
// connection.setRinging()
|
|
||||||
// return connection
|
|
||||||
// }
|
|
||||||
// }
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.icing.dialer.services
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.telecom.TelecomManager
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.Manifest
|
|
||||||
|
|
||||||
object CallService {
|
|
||||||
private val TAG = "CallService"
|
|
||||||
|
|
||||||
fun makeGsmCall(context: Context, phoneNumber: String): Boolean {
|
|
||||||
return try {
|
|
||||||
val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
|
||||||
val uri = Uri.parse("tel:$phoneNumber")
|
|
||||||
|
|
||||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
telecomManager.placeCall(uri, Bundle())
|
|
||||||
Log.d(TAG, "Initiated call to $phoneNumber")
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "CALL_PHONE permission not granted")
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Error making GSM call: ${e.message}", e)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hangUpCall(context: Context): Boolean {
|
|
||||||
return try {
|
|
||||||
if (MyInCallService.currentCall != null) {
|
|
||||||
MyInCallService.currentCall?.disconnect()
|
|
||||||
Log.d(TAG, "Disconnected active call via MyInCallService")
|
|
||||||
true
|
|
||||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
||||||
val telecomManager = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
|
|
||||||
telecomManager.endCall()
|
|
||||||
Log.d(TAG, "Ended call via TelecomManager (no active call in MyInCallService)")
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "No active call and hangup not supported below Android P")
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Error hanging up call: ${e.message}", e)
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,156 +0,0 @@
|
|||||||
package com.icing.dialer.services
|
|
||||||
|
|
||||||
import android.app.KeyguardManager
|
|
||||||
import android.app.NotificationChannel
|
|
||||||
import android.app.NotificationManager
|
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Build
|
|
||||||
import android.telecom.Call
|
|
||||||
import android.telecom.InCallService
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.app.NotificationCompat
|
|
||||||
import com.icing.dialer.activities.MainActivity
|
|
||||||
import io.flutter.plugin.common.MethodChannel
|
|
||||||
|
|
||||||
class MyInCallService : InCallService() {
|
|
||||||
companion object {
|
|
||||||
var channel: MethodChannel? = null
|
|
||||||
var currentCall: Call? = null
|
|
||||||
private const val TAG = "MyInCallService"
|
|
||||||
private const val NOTIFICATION_CHANNEL_ID = "incoming_call_channel"
|
|
||||||
private const val NOTIFICATION_ID = 1
|
|
||||||
var wasPhoneLocked: Boolean = false
|
|
||||||
}
|
|
||||||
|
|
||||||
private val callCallback = object : Call.Callback() {
|
|
||||||
override fun onStateChanged(call: Call, state: Int) {
|
|
||||||
super.onStateChanged(call, state)
|
|
||||||
val stateStr = when (state) {
|
|
||||||
Call.STATE_DIALING -> "dialing"
|
|
||||||
Call.STATE_ACTIVE -> "active"
|
|
||||||
Call.STATE_DISCONNECTED -> "disconnected"
|
|
||||||
Call.STATE_DISCONNECTING -> "disconnecting"
|
|
||||||
Call.STATE_RINGING -> "ringing"
|
|
||||||
else -> "unknown"
|
|
||||||
}
|
|
||||||
Log.d(TAG, "State changed: $stateStr for call ${call.details.handle}")
|
|
||||||
channel?.invokeMethod("callStateChanged", mapOf(
|
|
||||||
"callId" to call.details.handle.toString(),
|
|
||||||
"state" to stateStr,
|
|
||||||
"wasPhoneLocked" to wasPhoneLocked
|
|
||||||
))
|
|
||||||
if (state == Call.STATE_RINGING) {
|
|
||||||
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
|
||||||
wasPhoneLocked = keyguardManager.isKeyguardLocked
|
|
||||||
Log.d(TAG, "Phone locked at ringing: $wasPhoneLocked")
|
|
||||||
showIncomingCallScreen(call.details.handle.toString().replace("tel:", ""))
|
|
||||||
} else if (state == Call.STATE_DISCONNECTED || state == Call.STATE_DISCONNECTING) {
|
|
||||||
Log.d(TAG, "Call ended: ${call.details.handle}, wasPhoneLocked: $wasPhoneLocked")
|
|
||||||
channel?.invokeMethod("callEnded", mapOf(
|
|
||||||
"callId" to call.details.handle.toString(),
|
|
||||||
"wasPhoneLocked" to wasPhoneLocked
|
|
||||||
))
|
|
||||||
currentCall = null
|
|
||||||
cancelNotification()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCallAdded(call: Call) {
|
|
||||||
super.onCallAdded(call)
|
|
||||||
currentCall = call
|
|
||||||
val stateStr = when (call.state) {
|
|
||||||
Call.STATE_DIALING -> "dialing"
|
|
||||||
Call.STATE_ACTIVE -> "active"
|
|
||||||
Call.STATE_RINGING -> "ringing"
|
|
||||||
else -> "dialing"
|
|
||||||
}
|
|
||||||
Log.d(TAG, "Call added: ${call.details.handle}, state: $stateStr")
|
|
||||||
channel?.invokeMethod("callAdded", mapOf(
|
|
||||||
"callId" to call.details.handle.toString(),
|
|
||||||
"state" to stateStr
|
|
||||||
))
|
|
||||||
if (stateStr == "ringing") {
|
|
||||||
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
|
||||||
wasPhoneLocked = keyguardManager.isKeyguardLocked
|
|
||||||
Log.d(TAG, "Phone locked at call added: $wasPhoneLocked")
|
|
||||||
showIncomingCallScreen(call.details.handle.toString().replace("tel:", ""))
|
|
||||||
}
|
|
||||||
call.registerCallback(callCallback)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCallRemoved(call: Call) {
|
|
||||||
super.onCallRemoved(call)
|
|
||||||
Log.d(TAG, "Call removed: ${call.details.handle}, wasPhoneLocked: $wasPhoneLocked")
|
|
||||||
call.unregisterCallback(callCallback)
|
|
||||||
channel?.invokeMethod("callRemoved", mapOf(
|
|
||||||
"callId" to call.details.handle.toString(),
|
|
||||||
"wasPhoneLocked" to wasPhoneLocked
|
|
||||||
))
|
|
||||||
currentCall = null
|
|
||||||
cancelNotification()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCallAudioStateChanged(state: android.telecom.CallAudioState) {
|
|
||||||
super.onCallAudioStateChanged(state)
|
|
||||||
Log.d(TAG, "Audio state changed: route=${state.route}")
|
|
||||||
channel?.invokeMethod("audioStateChanged", mapOf("route" to state.route))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showIncomingCallScreen(phoneNumber: String) {
|
|
||||||
val intent = Intent(this, MainActivity::class.java).apply {
|
|
||||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
|
|
||||||
putExtra("phoneNumber", phoneNumber)
|
|
||||||
putExtra("isIncomingCall", true)
|
|
||||||
putExtra("showIncomingCallScreen", true)
|
|
||||||
putExtra("wasPhoneLocked", wasPhoneLocked)
|
|
||||||
}
|
|
||||||
|
|
||||||
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
|
|
||||||
if (keyguardManager.isKeyguardLocked) {
|
|
||||||
startActivity(intent)
|
|
||||||
Log.d(TAG, "Launched MainActivity directly for locked screen, phoneNumber: $phoneNumber")
|
|
||||||
} else {
|
|
||||||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
val channel = NotificationChannel(
|
|
||||||
NOTIFICATION_CHANNEL_ID,
|
|
||||||
"Incoming Calls",
|
|
||||||
NotificationManager.IMPORTANCE_HIGH
|
|
||||||
).apply {
|
|
||||||
description = "Notifications for incoming calls"
|
|
||||||
enableVibration(true)
|
|
||||||
setShowBadge(true)
|
|
||||||
}
|
|
||||||
notificationManager.createNotificationChannel(channel)
|
|
||||||
}
|
|
||||||
|
|
||||||
val pendingIntent = PendingIntent.getActivity(
|
|
||||||
this, 0, intent,
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_IMMUTABLE else 0)
|
|
||||||
)
|
|
||||||
|
|
||||||
val notification = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
|
|
||||||
.setSmallIcon(android.R.drawable.ic_dialog_alert)
|
|
||||||
.setContentTitle("Incoming Call")
|
|
||||||
.setContentText("Call from $phoneNumber")
|
|
||||||
.setPriority(NotificationCompat.PRIORITY_HIGH)
|
|
||||||
.setFullScreenIntent(pendingIntent, true)
|
|
||||||
.setAutoCancel(true)
|
|
||||||
.setOngoing(true)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
startActivity(intent)
|
|
||||||
notificationManager.notify(NOTIFICATION_ID, notification)
|
|
||||||
Log.d(TAG, "Launched MainActivity with notification for unlocked screen, phoneNumber: $phoneNumber")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun cancelNotification() {
|
|
||||||
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
||||||
notificationManager.cancel(NOTIFICATION_ID)
|
|
||||||
Log.d(TAG, "Notification canceled")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +1,21 @@
|
|||||||
|
// android/build.gradle (Project-level Gradle file)
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = "1.8.10"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Here is where the 'classpath' declarations go
|
||||||
|
classpath 'com.android.tools.build:gradle:8.1.2'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then your allprojects block can be minimal in newer Gradle versions:
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
@ -5,15 +23,18 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If you want to customize build directory paths:
|
||||||
rootProject.buildDir = "../build"
|
rootProject.buildDir = "../build"
|
||||||
subprojects {
|
subprojects {
|
||||||
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is optional, depends on your workflow:
|
||||||
subprojects {
|
subprojects {
|
||||||
project.evaluationDependsOn(":app")
|
project.evaluationDependsOn(":app")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A custom clean task:
|
||||||
tasks.register("clean", Delete) {
|
tasks.register("clean", Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryErro
|
|||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
dev.steenbakker.mobile_scanner.useUnbundled=true
|
dev.steenbakker.mobile_scanner.useUnbundled=true
|
||||||
org.gradle.java.home=/usr/lib/jvm/java-17-openjdk-amd64
|
org.gradle.java.home=/usr/lib/jvm/java-17-openjdk-17.0.13.0.11-3.fc41.x86_64
|
||||||
|
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
|
||||||
|
@ -18,8 +18,8 @@ pluginManagement {
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
|
||||||
id "com.android.application" version "8.3.2" apply false
|
id "com.android.application" version "8.1.0" apply false
|
||||||
id "org.jetbrains.kotlin.android" version "2.0.20" apply false
|
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
include ":app"
|
include ":app"
|
||||||
|
@ -2,9 +2,4 @@
|
|||||||
|
|
||||||
IMG=git.gmoker.com/icing/flutter:main
|
IMG=git.gmoker.com/icing/flutter:main
|
||||||
|
|
||||||
if [ "$1" == '-s' ]; then
|
docker run --rm -v "$PWD:/app/" "$IMG" build apk
|
||||||
OPT+=(--dart-define=STEALTH=true)
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -x
|
|
||||||
docker run --rm -v "$PWD:/app/" "$IMG" build apk "${OPT[@]}"
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
description: This file stores settings for Dart & Flutter DevTools.
|
|
||||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
|
||||||
extensions:
|
|
@ -1,348 +0,0 @@
|
|||||||
import 'dart:typed_data';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:dialer/services/call_service.dart';
|
|
||||||
import 'package:dialer/services/obfuscate_service.dart';
|
|
||||||
import 'package:dialer/widgets/username_color_generator.dart';
|
|
||||||
|
|
||||||
class CallPage extends StatefulWidget {
|
|
||||||
final String displayName;
|
|
||||||
final String phoneNumber;
|
|
||||||
final Uint8List? thumbnail;
|
|
||||||
|
|
||||||
const CallPage({
|
|
||||||
super.key,
|
|
||||||
required this.displayName,
|
|
||||||
required this.phoneNumber,
|
|
||||||
this.thumbnail,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_CallPageState createState() => _CallPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CallPageState extends State<CallPage> {
|
|
||||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
|
||||||
final CallService _callService = CallService();
|
|
||||||
bool isMuted = false;
|
|
||||||
bool isSpeakerOn = false;
|
|
||||||
bool isKeypadVisible = false;
|
|
||||||
bool icingProtocolOk = true;
|
|
||||||
String _typedDigits = "";
|
|
||||||
|
|
||||||
void _addDigit(String digit) {
|
|
||||||
setState(() {
|
|
||||||
_typedDigits += digit;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _toggleMute() {
|
|
||||||
setState(() {
|
|
||||||
isMuted = !isMuted;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _toggleSpeaker() {
|
|
||||||
setState(() {
|
|
||||||
isSpeakerOn = !isSpeakerOn;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _toggleKeypad() {
|
|
||||||
setState(() {
|
|
||||||
isKeypadVisible = !isKeypadVisible;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _toggleIcingProtocol() {
|
|
||||||
setState(() {
|
|
||||||
icingProtocolOk = !icingProtocolOk;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _hangUp() async {
|
|
||||||
try {
|
|
||||||
final result = await _callService.hangUpCall(context);
|
|
||||||
print('CallPage: Hang up result: $result');
|
|
||||||
if (result["status"] == "ended" && mounted && Navigator.canPop(context)) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("CallPage: Error hanging up: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text("Error hanging up: $e")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final double avatarRadius = isKeypadVisible ? 45.0 : 45.0;
|
|
||||||
final double nameFontSize = isKeypadVisible ? 24.0 : 24.0;
|
|
||||||
final double statusFontSize = isKeypadVisible ? 16.0 : 16.0;
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
body: Container(
|
|
||||||
color: Colors.black,
|
|
||||||
child: SafeArea(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
SizedBox(height: 35),
|
|
||||||
ObfuscatedAvatar(
|
|
||||||
imageBytes: widget.thumbnail,
|
|
||||||
radius: avatarRadius,
|
|
||||||
backgroundColor:
|
|
||||||
generateColorFromName(widget.displayName),
|
|
||||||
fallbackInitial: widget.displayName,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
icingProtocolOk ? Icons.lock : Icons.lock_open,
|
|
||||||
color: icingProtocolOk ? Colors.green : Colors.red,
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
Text(
|
|
||||||
'Icing protocol: ${icingProtocolOk ? "ok" : "ko"}',
|
|
||||||
style: TextStyle(
|
|
||||||
color: icingProtocolOk ? Colors.green : Colors.red,
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
_obfuscateService.obfuscateData(widget.displayName),
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: nameFontSize,
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
widget.phoneNumber,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: statusFontSize, color: Colors.white70),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Calling...',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: statusFontSize, color: Colors.white70),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
if (isKeypadVisible) ...[
|
|
||||||
const Spacer(flex: 2),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
_typedDigits,
|
|
||||||
maxLines: 1,
|
|
||||||
textAlign: TextAlign.right,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: _toggleKeypad,
|
|
||||||
icon:
|
|
||||||
const Icon(Icons.close, color: Colors.white),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
height: MediaQuery.of(context).size.height * 0.35,
|
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
child: GridView.count(
|
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
crossAxisCount: 3,
|
|
||||||
childAspectRatio: 1.3,
|
|
||||||
mainAxisSpacing: 8,
|
|
||||||
crossAxisSpacing: 8,
|
|
||||||
children: List.generate(12, (index) {
|
|
||||||
String label;
|
|
||||||
if (index < 9) {
|
|
||||||
label = '${index + 1}';
|
|
||||||
} else if (index == 9) {
|
|
||||||
label = '*';
|
|
||||||
} else if (index == 10) {
|
|
||||||
label = '0';
|
|
||||||
} else {
|
|
||||||
label = '#';
|
|
||||||
}
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () => _addDigit(label),
|
|
||||||
child: Container(
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
color: Colors.transparent,
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
label,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 32, color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(flex: 1),
|
|
||||||
] else ...[
|
|
||||||
const Spacer(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 32.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: _toggleMute,
|
|
||||||
icon: Icon(
|
|
||||||
isMuted ? Icons.mic_off : Icons.mic,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 32,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
isMuted ? 'Unmute' : 'Mute',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white, fontSize: 14),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: _toggleKeypad,
|
|
||||||
icon: const Icon(Icons.dialpad,
|
|
||||||
color: Colors.white, size: 32),
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
'Keypad',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white, fontSize: 14),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: _toggleSpeaker,
|
|
||||||
icon: Icon(
|
|
||||||
isSpeakerOn
|
|
||||||
? Icons.volume_up
|
|
||||||
: Icons.volume_off,
|
|
||||||
color: isSpeakerOn
|
|
||||||
? Colors.amber
|
|
||||||
: Colors.white,
|
|
||||||
size: 32,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
'Speaker',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white, fontSize: 14),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {},
|
|
||||||
icon: const Icon(Icons.person_add,
|
|
||||||
color: Colors.white, size: 32),
|
|
||||||
),
|
|
||||||
const Text('Add Contact',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white, fontSize: 14)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {},
|
|
||||||
icon: const Icon(Icons.sim_card,
|
|
||||||
color: Colors.white, size: 32),
|
|
||||||
),
|
|
||||||
const Text('Change SIM',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white, fontSize: 14)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(flex: 3),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 16.0),
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: _hangUp,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.red,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.call_end,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 32,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,181 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:dialer/services/call_service.dart';
|
|
||||||
import 'package:dialer/services/obfuscate_service.dart';
|
|
||||||
import 'package:dialer/widgets/username_color_generator.dart';
|
|
||||||
import 'package:dialer/features/call/call_page.dart';
|
|
||||||
|
|
||||||
class IncomingCallPage extends StatefulWidget {
|
|
||||||
final String displayName;
|
|
||||||
final String phoneNumber;
|
|
||||||
final Uint8List? thumbnail;
|
|
||||||
|
|
||||||
const IncomingCallPage({
|
|
||||||
super.key,
|
|
||||||
required this.displayName,
|
|
||||||
required this.phoneNumber,
|
|
||||||
this.thumbnail,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_IncomingCallPageState createState() => _IncomingCallPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _IncomingCallPageState extends State<IncomingCallPage> {
|
|
||||||
static const MethodChannel _channel = MethodChannel('call_service');
|
|
||||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
|
||||||
final CallService _callService = CallService();
|
|
||||||
bool icingProtocolOk = true;
|
|
||||||
|
|
||||||
void _toggleIcingProtocol() {
|
|
||||||
setState(() {
|
|
||||||
icingProtocolOk = !icingProtocolOk;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _answerCall() async {
|
|
||||||
try {
|
|
||||||
final result = await _channel.invokeMethod('answerCall');
|
|
||||||
print('IncomingCallPage: Answer call result: $result');
|
|
||||||
if (result["status"] == "answered") {
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => CallPage(
|
|
||||||
displayName: widget.displayName,
|
|
||||||
phoneNumber: widget.phoneNumber,
|
|
||||||
thumbnail: widget.thumbnail,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("IncomingCallPage: Error answering call: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text("Error answering call: $e")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _declineCall() async {
|
|
||||||
try {
|
|
||||||
await _callService.hangUpCall(context);
|
|
||||||
} catch (e) {
|
|
||||||
print("IncomingCallPage: Error declining call: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text("Error declining call: $e")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
const double avatarRadius = 45.0;
|
|
||||||
const double nameFontSize = 24.0;
|
|
||||||
const double statusFontSize = 16.0;
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
body: Container(
|
|
||||||
color: Colors.black,
|
|
||||||
child: SafeArea(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 35),
|
|
||||||
ObfuscatedAvatar(
|
|
||||||
imageBytes: widget.thumbnail,
|
|
||||||
radius: avatarRadius,
|
|
||||||
backgroundColor: generateColorFromName(widget.displayName),
|
|
||||||
fallbackInitial: widget.displayName,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
icingProtocolOk ? Icons.lock : Icons.lock_open,
|
|
||||||
color: icingProtocolOk ? Colors.green : Colors.red,
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
Text(
|
|
||||||
'Icing protocol: ${icingProtocolOk ? "ok" : "ko"}',
|
|
||||||
style: TextStyle(
|
|
||||||
color: icingProtocolOk ? Colors.green : Colors.red,
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
_obfuscateService.obfuscateData(widget.displayName),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: nameFontSize,
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
widget.phoneNumber,
|
|
||||||
style: const TextStyle(fontSize: statusFontSize, color: Colors.white70),
|
|
||||||
),
|
|
||||||
const Text(
|
|
||||||
'Incoming Call...',
|
|
||||||
style: TextStyle(fontSize: statusFontSize, color: Colors.white70),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 32.0, vertical: 16.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
onTap: _declineCall,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.red,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.call_end,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 32,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
GestureDetector(
|
|
||||||
onTap: _answerCall,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.green,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.call,
|
|
||||||
color: Colors.white,
|
|
||||||
size: 32,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import '../../services/contact_service.dart';
|
import '../../widgets/contact_service.dart';
|
||||||
import '../../services/obfuscate_service.dart';
|
import '../contacts/widgets/add_contact_button.dart';
|
||||||
import '../../services/call_service.dart';
|
|
||||||
|
|
||||||
class CompositionPage extends StatefulWidget {
|
class CompositionPage extends StatefulWidget {
|
||||||
const CompositionPage({super.key});
|
const CompositionPage({super.key});
|
||||||
@ -17,8 +16,6 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
List<Contact> _allContacts = [];
|
List<Contact> _allContacts = [];
|
||||||
List<Contact> _filteredContacts = [];
|
List<Contact> _filteredContacts = [];
|
||||||
final ContactService _contactService = ContactService();
|
final ContactService _contactService = ContactService();
|
||||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
|
||||||
final CallService _callService = CallService();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -35,13 +32,8 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
void _filterContacts() {
|
void _filterContacts() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_filteredContacts = _allContacts.where((contact) {
|
_filteredContacts = _allContacts.where((contact) {
|
||||||
bool phoneMatch = contact.phones.any((phone) {
|
final phoneMatch = contact.phones.any((phone) =>
|
||||||
final rawPhoneNumber = phone.number;
|
phone.number.replaceAll(RegExp(r'\D'), '').contains(dialedNumber));
|
||||||
final strippedPhoneNumber = rawPhoneNumber.replaceAll(RegExp(r'\D'), '');
|
|
||||||
final strippedDialedNumber = dialedNumber.replaceAll(RegExp(r'\D'), '');
|
|
||||||
return rawPhoneNumber.contains(dialedNumber) ||
|
|
||||||
strippedPhoneNumber.contains(strippedDialedNumber);
|
|
||||||
});
|
|
||||||
final nameMatch = contact.displayName
|
final nameMatch = contact.displayName
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(dialedNumber.toLowerCase());
|
.contains(dialedNumber.toLowerCase());
|
||||||
@ -57,13 +49,6 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onPlusPress() {
|
|
||||||
setState(() {
|
|
||||||
dialedNumber += '+';
|
|
||||||
_filterContacts();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onDeletePress() {
|
void _onDeletePress() {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (dialedNumber.isNotEmpty) {
|
if (dialedNumber.isNotEmpty) {
|
||||||
@ -80,20 +65,17 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _makeCall(String phoneNumber) async {
|
// Function to call a contact's number
|
||||||
try {
|
void _launchPhoneDialer(String phoneNumber) async {
|
||||||
await _callService.makeGsmCall(context, phoneNumber: phoneNumber);
|
final uri = Uri(scheme: 'tel', path: phoneNumber);
|
||||||
setState(() {
|
if (await canLaunchUrl(uri)) {
|
||||||
dialedNumber = phoneNumber;
|
await launchUrl(uri);
|
||||||
});
|
} else {
|
||||||
} catch (e) {
|
debugPrint('Could not launch $phoneNumber');
|
||||||
debugPrint("Error making call: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Failed to make call: $e')),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function to send an SMS to a contact's number
|
||||||
void _launchSms(String phoneNumber) async {
|
void _launchSms(String phoneNumber) async {
|
||||||
final uri = Uri(scheme: 'sms', path: phoneNumber);
|
final uri = Uri(scheme: 'sms', path: phoneNumber);
|
||||||
if (await canLaunchUrl(uri)) {
|
if (await canLaunchUrl(uri)) {
|
||||||
@ -103,20 +85,6 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _addContact() async {
|
|
||||||
if (await FlutterContacts.requestPermission()) {
|
|
||||||
final newContact = Contact()
|
|
||||||
..phones = [Phone(dialedNumber.isNotEmpty ? dialedNumber : '')];
|
|
||||||
final updatedContact = await FlutterContacts.openExternalInsert(newContact);
|
|
||||||
if (updatedContact != null) {
|
|
||||||
_fetchContacts();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Contact added successfully!')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -125,6 +93,7 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
|
// Top half: Display contacts matching dialed number
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -136,51 +105,61 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: [
|
children: _filteredContacts.isNotEmpty
|
||||||
..._filteredContacts.map((contact) {
|
? _filteredContacts.map((contact) {
|
||||||
final phoneNumber = contact.phones.isNotEmpty
|
final phoneNumber = contact.phones.isNotEmpty
|
||||||
? contact.phones.first.number
|
? contact.phones.first.number
|
||||||
: 'No phone number';
|
: 'No phone number';
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
_obfuscateService.obfuscateData(contact.displayName),
|
'${contact.displayName.isNotEmpty ? contact.displayName[0] : ''}...${contact.displayName.isNotEmpty ? contact.displayName[contact.displayName.length - 1] : ''}',
|
||||||
style: const TextStyle(color: Colors.white),
|
// contact.displayName
|
||||||
|
style:
|
||||||
|
const TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
_obfuscateService.obfuscateData(phoneNumber),
|
'${phoneNumber.isNotEmpty ? phoneNumber[0] : ''}...${phoneNumber.isNotEmpty ? phoneNumber[phoneNumber.length - 1] : ''}',
|
||||||
style: const TextStyle(color: Colors.grey),
|
// phoneNumber,
|
||||||
|
style:
|
||||||
|
const TextStyle(color: Colors.grey),
|
||||||
),
|
),
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
|
// Call button
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.phone, color: Colors.green[300], size: 20),
|
icon: Icon(Icons.phone,
|
||||||
onPressed: () => _makeCall(phoneNumber),
|
color: Colors.green[300],
|
||||||
|
size: 20),
|
||||||
|
onPressed: () {
|
||||||
|
_launchPhoneDialer(phoneNumber);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
|
// Message button
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.message, color: Colors.blue[300], size: 20),
|
icon: Icon(Icons.message,
|
||||||
onPressed: () => _launchSms(phoneNumber),
|
color: Colors.blue[300],
|
||||||
|
size: 20),
|
||||||
|
onPressed: () {
|
||||||
|
_launchSms(phoneNumber);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () {},
|
onTap: () {
|
||||||
|
// Handle contact selection if needed
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList()
|
||||||
ListTile(
|
: [],
|
||||||
title: const Text(
|
|
||||||
'Add a contact',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
trailing: Icon(Icons.add, color: Colors.grey[600]),
|
|
||||||
onTap: _addContact,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Bottom half: Dialpad and Dialed number display with erase button
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -188,6 +167,7 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
// Display dialed number with erase button
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -196,57 +176,61 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
dialedNumber,
|
dialedNumber,
|
||||||
style: const TextStyle(fontSize: 24, color: Colors.white),
|
style: const TextStyle(
|
||||||
|
fontSize: 24, color: Colors.white),
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
GestureDetector(
|
IconButton(
|
||||||
onTap: _onDeletePress,
|
onPressed: _onClearPress,
|
||||||
onLongPress: _onClearPress,
|
icon: const Icon(Icons.backspace,
|
||||||
child: const Padding(
|
color: Colors.white),
|
||||||
padding: EdgeInsets.all(8.0),
|
|
||||||
child: Icon(Icons.backspace, color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
|
||||||
|
// Dialpad
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildDialButton('1', Colors.white),
|
_buildDialButton('1'),
|
||||||
_buildDialButton('2', Colors.white),
|
_buildDialButton('2'),
|
||||||
_buildDialButton('3', Colors.white),
|
_buildDialButton('3'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildDialButton('4', Colors.white),
|
_buildDialButton('4'),
|
||||||
_buildDialButton('5', Colors.white),
|
_buildDialButton('5'),
|
||||||
_buildDialButton('6', Colors.white),
|
_buildDialButton('6'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildDialButton('7', Colors.white),
|
_buildDialButton('7'),
|
||||||
_buildDialButton('8', Colors.white),
|
_buildDialButton('8'),
|
||||||
_buildDialButton('9', Colors.white),
|
_buildDialButton('9'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildDialButton('*', const Color.fromRGBO(117, 117, 117, 1)),
|
_buildDialButton('*'),
|
||||||
_buildDialButtonWithPlus('0'),
|
_buildDialButton('0'),
|
||||||
_buildDialButton('#', const Color.fromRGBO(117, 117, 117, 1)),
|
_buildDialButton('#'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -259,28 +243,26 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Add Contact Button
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 20.0,
|
bottom: 20.0,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: ElevatedButton(
|
child: AddContactButton(),
|
||||||
onPressed: dialedNumber.isNotEmpty ? () => _makeCall(dialedNumber) : null,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.green[700],
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
padding: const EdgeInsets.all(20),
|
|
||||||
),
|
|
||||||
child: const Icon(Icons.phone, color: Colors.white, size: 30),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Top Row with Back Arrow
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 40.0,
|
top: 40.0,
|
||||||
left: 16.0,
|
left: 16.0,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -288,7 +270,7 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDialButton(String number, Color textColor) {
|
Widget _buildDialButton(String number) {
|
||||||
return ElevatedButton(
|
return ElevatedButton(
|
||||||
onPressed: () => _onNumberPress(number),
|
onPressed: () => _onNumberPress(number),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
@ -298,38 +280,11 @@ class _CompositionPageState extends State<CompositionPage> {
|
|||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
number,
|
number,
|
||||||
style: TextStyle(fontSize: 24, color: textColor),
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDialButtonWithPlus(String number) {
|
|
||||||
return Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
onLongPress: _onPlusPress,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: () => _onNumberPress(number),
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
shape: const CircleBorder(),
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
number,
|
|
||||||
style: const TextStyle(fontSize: 24, color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
bottom: 8,
|
|
||||||
child: Text(
|
|
||||||
'+',
|
|
||||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
import '../../services/contact_service.dart';
|
import '../../widgets/contact_service.dart';
|
||||||
|
|
||||||
class ContactState extends StatefulWidget {
|
class ContactState extends StatefulWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:dialer/services/obfuscate_service.dart';
|
|
||||||
import 'package:dialer/widgets/username_color_generator.dart';
|
import 'package:dialer/widgets/username_color_generator.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
import '../contact_state.dart';
|
import '../contact_state.dart';
|
||||||
|
import '../../../widgets/color_darkener.dart';
|
||||||
import 'add_contact_button.dart';
|
import 'add_contact_button.dart';
|
||||||
import 'contact_modal.dart';
|
import 'contact_modal.dart';
|
||||||
import 'share_own_qr.dart';
|
import 'share_own_qr.dart';
|
||||||
@ -24,8 +24,6 @@ class AlphabetScrollPage extends StatefulWidget {
|
|||||||
class _AlphabetScrollPageState extends State<AlphabetScrollPage> {
|
class _AlphabetScrollPageState extends State<AlphabetScrollPage> {
|
||||||
late ScrollController _scrollController;
|
late ScrollController _scrollController;
|
||||||
|
|
||||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -126,7 +124,7 @@ class _AlphabetScrollPageState extends State<AlphabetScrollPage> {
|
|||||||
vertical: 8.0, horizontal: 16.0),
|
vertical: 8.0, horizontal: 16.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
letter,
|
letter,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 28,
|
fontSize: 28,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -136,25 +134,31 @@ class _AlphabetScrollPageState extends State<AlphabetScrollPage> {
|
|||||||
// Contact Entries
|
// Contact Entries
|
||||||
...contactsForLetter.map((contact) {
|
...contactsForLetter.map((contact) {
|
||||||
String phoneNumber = contact.phones.isNotEmpty
|
String phoneNumber = contact.phones.isNotEmpty
|
||||||
? _obfuscateService.obfuscateData(contact.phones.first.number)
|
? contact.phones.first.number
|
||||||
: 'No phone number';
|
: 'No phone number';
|
||||||
Color avatarColor =
|
Color avatarColor =
|
||||||
generateColorFromName(contact.displayName);
|
generateColorFromName(contact.displayName);
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: ObfuscatedAvatar(
|
leading: (contact.thumbnail != null &&
|
||||||
imageBytes: contact.thumbnail,
|
contact.thumbnail!.isNotEmpty)
|
||||||
radius: 25,
|
? CircleAvatar(
|
||||||
|
backgroundImage:
|
||||||
|
MemoryImage(contact.thumbnail!),
|
||||||
|
)
|
||||||
|
: CircleAvatar(
|
||||||
backgroundColor: avatarColor,
|
backgroundColor: avatarColor,
|
||||||
fallbackInitial: contact.displayName,
|
child: Text(
|
||||||
|
contact.displayName.isNotEmpty
|
||||||
|
? contact.displayName[0].toUpperCase()
|
||||||
|
: '?',
|
||||||
|
style: TextStyle(
|
||||||
|
color: darken(avatarColor, 0.4)),
|
||||||
),
|
),
|
||||||
title: Text(
|
|
||||||
_obfuscateService.obfuscateData(contact.displayName),
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
phoneNumber,
|
|
||||||
style: const TextStyle(color: Colors.white70),
|
|
||||||
),
|
),
|
||||||
|
title: Text(contact.displayName,
|
||||||
|
style: TextStyle(color: Colors.white)),
|
||||||
|
subtitle: Text(phoneNumber,
|
||||||
|
style: TextStyle(color: Colors.white70)),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import 'package:dialer/services/obfuscate_service.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'package:dialer/widgets/username_color_generator.dart';
|
import 'package:dialer/widgets/username_color_generator.dart';
|
||||||
import '../../../services/block_service.dart';
|
import '../../../widgets/block_service.dart';
|
||||||
import '../../../services/contact_service.dart';
|
|
||||||
import '../../../services/call_service.dart';
|
|
||||||
|
|
||||||
class ContactModal extends StatefulWidget {
|
class ContactModal extends StatefulWidget {
|
||||||
final Contact contact;
|
final Contact contact;
|
||||||
@ -28,8 +25,6 @@ class ContactModal extends StatefulWidget {
|
|||||||
class _ContactModalState extends State<ContactModal> {
|
class _ContactModalState extends State<ContactModal> {
|
||||||
late String phoneNumber;
|
late String phoneNumber;
|
||||||
bool isBlocked = false;
|
bool isBlocked = false;
|
||||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
|
||||||
final CallService _callService = CallService();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -104,8 +99,7 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
title: const Text('Delete Contact'),
|
title: const Text('Delete Contact'),
|
||||||
content: Text(
|
content: Text('Are you sure you want to delete ${widget.contact.displayName}?'),
|
||||||
'Are you sure you want to delete ${_obfuscateService.obfuscateData(widget.contact.displayName)}?'),
|
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(false),
|
onPressed: () => Navigator.of(context).pop(false),
|
||||||
@ -126,9 +120,7 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
|
|
||||||
// Show success message
|
// Show success message
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(content: Text('${widget.contact.displayName} deleted')),
|
||||||
content: Text(
|
|
||||||
'${_obfuscateService.obfuscateData(widget.contact.displayName)} deleted')),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Close the modal
|
// Close the modal
|
||||||
@ -136,23 +128,16 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle errors and show a failure message
|
// Handle errors and show a failure message
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(content: Text('Failed to delete ${widget.contact.displayName}: $e')),
|
||||||
content:
|
|
||||||
Text('Failed to delete ${widget.contact.displayName}: $e')),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _shareContactAsQRCode() {
|
|
||||||
// Use the ContactService to show the QR code for the contact's vCard
|
|
||||||
ContactService().showContactQRCodeDialog(context, widget.contact);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String email = widget.contact.emails.isNotEmpty
|
String email = widget.contact.emails.isNotEmpty
|
||||||
? _obfuscateService.obfuscateData(widget.contact.emails.first.address)
|
? widget.contact.emails.first.address
|
||||||
: 'No email';
|
: 'No email';
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
@ -198,10 +183,7 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
onSelected: (String choice) {
|
onSelected: (String choice) {
|
||||||
if (choice == 'delete') {
|
if (choice == 'delete') {
|
||||||
_deleteContact();
|
_deleteContact();
|
||||||
} else if (choice == 'share') {
|
|
||||||
_shareContactAsQRCode();
|
|
||||||
}
|
}
|
||||||
// Handle other choices if needed
|
|
||||||
},
|
},
|
||||||
itemBuilder: (BuildContext context) {
|
itemBuilder: (BuildContext context) {
|
||||||
return [
|
return [
|
||||||
@ -238,46 +220,49 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ObfuscatedAvatar(
|
CircleAvatar(
|
||||||
imageBytes: widget.contact.thumbnail,
|
|
||||||
radius: 50,
|
radius: 50,
|
||||||
|
backgroundImage: (widget.contact.thumbnail != null &&
|
||||||
|
widget.contact.thumbnail!.isNotEmpty)
|
||||||
|
? MemoryImage(widget.contact.thumbnail!)
|
||||||
|
: null,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
generateColorFromName(widget.contact.displayName),
|
generateColorFromName(widget.contact.displayName),
|
||||||
fallbackInitial: widget.contact.displayName,
|
child: (widget.contact.thumbnail == null ||
|
||||||
|
widget.contact.thumbnail!.isEmpty)
|
||||||
|
? Text(
|
||||||
|
widget.contact.displayName.isNotEmpty
|
||||||
|
? widget.contact.displayName[0]
|
||||||
|
.toUpperCase()
|
||||||
|
: '?',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 40, color: Colors.white),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Text(
|
Text(
|
||||||
_obfuscateService
|
widget.contact.displayName,
|
||||||
.obfuscateData(widget.contact.displayName),
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24, fontWeight: FontWeight.bold),
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.white),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(color: Colors.grey),
|
const Divider(),
|
||||||
// Contact Actions
|
// Contact Actions
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.phone, color: Colors.green),
|
leading: const Icon(Icons.phone, color: Colors.green),
|
||||||
title: Text(
|
title: Text(phoneNumber),
|
||||||
_obfuscateService.obfuscateData(phoneNumber),
|
onTap: () {
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
if (widget.contact.phones.isNotEmpty) {
|
if (widget.contact.phones.isNotEmpty) {
|
||||||
await _callService.makeGsmCall(context,
|
_launchPhoneDialer(phoneNumber);
|
||||||
phoneNumber: phoneNumber);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.message, color: Colors.blue),
|
leading: const Icon(Icons.message, color: Colors.blue),
|
||||||
title: Text(
|
title: Text(phoneNumber),
|
||||||
_obfuscateService.obfuscateData(phoneNumber),
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.contact.phones.isNotEmpty) {
|
if (widget.contact.phones.isNotEmpty) {
|
||||||
_launchSms(phoneNumber);
|
_launchSms(phoneNumber);
|
||||||
@ -286,17 +271,14 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.email, color: Colors.orange),
|
leading: const Icon(Icons.email, color: Colors.orange),
|
||||||
title: Text(
|
title: Text(email),
|
||||||
email,
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.contact.emails.isNotEmpty) {
|
if (widget.contact.emails.isNotEmpty) {
|
||||||
_launchEmail(email);
|
_launchEmail(email);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Divider(color: Colors.grey),
|
const Divider(),
|
||||||
// Favorite, Edit, and Block/Unblock Buttons
|
// Favorite, Edit, and Block/Unblock Buttons
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
@ -304,7 +286,8 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
children: [
|
children: [
|
||||||
// Favorite button
|
// Favorite button
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double
|
||||||
|
.infinity, // This makes the button take full width
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
@ -317,20 +300,24 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
widget.isFavorite ? 'Unfavorite' : 'Favorite'),
|
widget.isFavorite ? 'Unfavorite' : 'Favorite'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10), // Space between buttons
|
||||||
|
|
||||||
// Edit button
|
// Edit button
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double
|
||||||
|
.infinity, // This makes the button take full width
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () => widget.onEdit(),
|
onPressed: () => widget.onEdit(),
|
||||||
icon: const Icon(Icons.edit),
|
icon: const Icon(Icons.edit),
|
||||||
label: const Text('Edit Contact'),
|
label: const Text('Edit Contact'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10), // Space between buttons
|
||||||
|
|
||||||
// Block/Unblock button
|
// Block/Unblock button
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double
|
||||||
|
.infinity, // This makes the button take full width
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: _toggleBlockState,
|
onPressed: _toggleBlockState,
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
@ -341,6 +328,7 @@ class _ContactModalState extends State<ContactModal> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_contacts/contact.dart';
|
import 'package:flutter_contacts/contact.dart';
|
||||||
import 'package:dialer/services/contact_service.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
|
||||||
class QRCodeButton extends StatelessWidget {
|
class QRCodeButton extends StatelessWidget {
|
||||||
final List<Contact> contacts;
|
final List<Contact> contacts;
|
||||||
@ -23,12 +23,31 @@ class QRCodeButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: Icon(Icons.qr_code, color: selfContact != null ? Colors.blue : Colors.grey),
|
icon: Icon(Icons.qr_code, color: selfContact != null ? Colors.blue : Colors.grey),
|
||||||
onPressed: selfContact != null
|
onPressed: selfContact != null
|
||||||
? () {
|
? () {
|
||||||
// Use the ContactService to show the QR code
|
showDialog(
|
||||||
ContactService().showContactQRCodeDialog(context, selfContact!);
|
barrierColor: Colors.white24,
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: true,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
content: SizedBox(
|
||||||
|
width: 200,
|
||||||
|
height: 220,
|
||||||
|
child: QrImageView(
|
||||||
|
data: selfContact!.toVCard(),
|
||||||
|
version: QrVersions.auto,
|
||||||
|
backgroundColor: Colors.white, // Ensure QR code is visible on black background
|
||||||
|
size: 200.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'package:dialer/services/obfuscate_service.dart';
|
|
||||||
import 'package:dialer/widgets/color_darkener.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import 'package:dialer/features/contacts/contact_state.dart';
|
import 'package:dialer/features/contacts/contact_state.dart';
|
||||||
import 'package:dialer/widgets/username_color_generator.dart';
|
import 'package:dialer/widgets/username_color_generator.dart';
|
||||||
import '../../services/block_service.dart';
|
import 'package:dialer/widgets/color_darkener.dart';
|
||||||
import '../contacts/widgets/contact_modal.dart';
|
|
||||||
import '../../services/call_service.dart';
|
|
||||||
|
|
||||||
class History {
|
class History {
|
||||||
final Contact contact;
|
final Contact contact;
|
||||||
@ -36,114 +29,23 @@ class HistoryPage extends StatefulWidget {
|
|||||||
_HistoryPageState createState() => _HistoryPageState();
|
_HistoryPageState createState() => _HistoryPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HistoryPageState extends State<HistoryPage>
|
class _HistoryPageState extends State<HistoryPage> with SingleTickerProviderStateMixin {
|
||||||
with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
|
|
||||||
List<History> histories = [];
|
List<History> histories = [];
|
||||||
bool loading = true;
|
bool loading = true;
|
||||||
int? _expandedIndex;
|
int? _expandedIndex;
|
||||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
|
||||||
final CallService _callService = CallService();
|
|
||||||
|
|
||||||
// Create a MethodChannel instance.
|
|
||||||
static const MethodChannel _channel = MethodChannel('com.example.calllog');
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool get wantKeepAlive => true; // Preserve state when switching pages
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
if (loading && histories.isEmpty) {
|
if (loading) {
|
||||||
_buildHistories();
|
_buildHistories();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _refreshContacts() async {
|
|
||||||
final contactState = ContactState.of(context);
|
|
||||||
try {
|
|
||||||
await contactState.fetchContacts();
|
|
||||||
} catch (e) {
|
|
||||||
print('Error refreshing contacts: $e');
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(SnackBar(content: Text('Failed to refresh contacts')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _toggleFavorite(Contact contact) async {
|
|
||||||
try {
|
|
||||||
if (await FlutterContacts.requestPermission()) {
|
|
||||||
Contact? fullContact = await FlutterContacts.getContact(contact.id,
|
|
||||||
withProperties: true,
|
|
||||||
withAccounts: true,
|
|
||||||
withPhoto: true,
|
|
||||||
withThumbnail: true);
|
|
||||||
|
|
||||||
if (fullContact != null) {
|
|
||||||
fullContact.isStarred = !fullContact.isStarred;
|
|
||||||
await FlutterContacts.updateContact(fullContact);
|
|
||||||
}
|
|
||||||
await _refreshContacts();
|
|
||||||
} else {
|
|
||||||
print("Could not fetch contact details");
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("Error updating favorite status: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Failed to update favorite status')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Helper: Remove all non-digit characters for simple matching.
|
|
||||||
String sanitizeNumber(String number) {
|
|
||||||
return number.replaceAll(RegExp(r'\D'), '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Helper: Find a contact from our list by matching phone numbers.
|
|
||||||
Contact? findContactForNumber(String number, List<Contact> contacts) {
|
|
||||||
final sanitized = sanitizeNumber(number);
|
|
||||||
for (var contact in contacts) {
|
|
||||||
for (var phone in contact.phones) {
|
|
||||||
if (sanitizeNumber(phone.number) == sanitized) {
|
|
||||||
return contact;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Request permission for reading call logs.
|
|
||||||
Future<bool> _requestCallLogPermission() async {
|
|
||||||
var status = await Permission.phone.status;
|
|
||||||
if (!status.isGranted) {
|
|
||||||
status = await Permission.phone.request();
|
|
||||||
}
|
|
||||||
return status.isGranted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Build histories from the native call log using the method channel.
|
|
||||||
Future<void> _buildHistories() async {
|
Future<void> _buildHistories() async {
|
||||||
// Request permission.
|
|
||||||
bool hasPermission = await _requestCallLogPermission();
|
|
||||||
if (!hasPermission) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
const SnackBar(content: Text('Call log permission not granted')));
|
|
||||||
setState(() {
|
|
||||||
loading = false;
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve call logs from native code.
|
|
||||||
List<dynamic> nativeLogs = [];
|
|
||||||
try {
|
|
||||||
nativeLogs = await _channel.invokeMethod('getCallLogs');
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
print("Error fetching call logs: ${e.message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure contacts are loaded.
|
|
||||||
final contactState = ContactState.of(context);
|
final contactState = ContactState.of(context);
|
||||||
if (contactState.loading) {
|
if (contactState.loading) {
|
||||||
|
// Wait for contacts to be loaded
|
||||||
await Future.doWhile(() async {
|
await Future.doWhile(() async {
|
||||||
await Future.delayed(const Duration(milliseconds: 100));
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
return contactState.loading;
|
return contactState.loading;
|
||||||
@ -151,69 +53,30 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
}
|
}
|
||||||
List<Contact> contacts = contactState.contacts;
|
List<Contact> contacts = contactState.contacts;
|
||||||
|
|
||||||
List<History> callHistories = [];
|
if (contacts.isEmpty) {
|
||||||
// Process each log entry with intermittent yields to avoid freezing.
|
setState(() {
|
||||||
for (int i = 0; i < nativeLogs.length; i++) {
|
loading = false;
|
||||||
final entry = nativeLogs[i];
|
});
|
||||||
final String number = entry['number'] ?? '';
|
return;
|
||||||
if (number.isEmpty) continue;
|
|
||||||
|
|
||||||
// Convert timestamp to DateTime.
|
|
||||||
DateTime callDate =
|
|
||||||
DateTime.fromMillisecondsSinceEpoch(entry['date'] ?? 0);
|
|
||||||
|
|
||||||
int typeInt = entry['type'] ?? 0;
|
|
||||||
int duration = entry['duration'] ?? 0;
|
|
||||||
String callType;
|
|
||||||
String callStatus;
|
|
||||||
|
|
||||||
// Map integer values to call type/status.
|
|
||||||
// Commonly: 1 = incoming, 2 = outgoing, 3 = missed.
|
|
||||||
switch (typeInt) {
|
|
||||||
case 1:
|
|
||||||
callType = "incoming";
|
|
||||||
callStatus = (duration == 0) ? "missed" : "answered";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
callType = "outgoing";
|
|
||||||
callStatus = "answered";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
callType = "incoming";
|
|
||||||
callStatus = "missed";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
callType = "unknown";
|
|
||||||
callStatus = "unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find a matching contact.
|
|
||||||
Contact? matchedContact = findContactForNumber(number, contacts);
|
|
||||||
if (matchedContact == null) {
|
|
||||||
// Create a dummy contact if not found.
|
|
||||||
matchedContact = Contact(
|
|
||||||
id: "dummy-$number",
|
|
||||||
displayName: number,
|
|
||||||
phones: [Phone(number)],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
callHistories
|
|
||||||
.add(History(matchedContact, callDate, callType, callStatus, 1));
|
|
||||||
// Yield every 10 iterations to avoid blocking the UI.
|
|
||||||
if (i % 10 == 0) await Future.delayed(Duration(milliseconds: 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sort histories by most recent.
|
|
||||||
callHistories.sort((a, b) => b.date.compareTo(a.date));
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
histories = callHistories;
|
histories = List.generate(
|
||||||
|
contacts.length >= 10 ? 10 : contacts.length,
|
||||||
|
(index) => History(
|
||||||
|
contacts[index],
|
||||||
|
DateTime.now().subtract(Duration(hours: (index + 1) * 2)),
|
||||||
|
index % 2 == 0 ? 'outgoing' : 'incoming',
|
||||||
|
index % 3 == 0 ? 'missed' : 'answered',
|
||||||
|
index % 3 + 1,
|
||||||
|
),
|
||||||
|
);
|
||||||
loading = false;
|
loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
List _buildGroupedList(List<History> historyList) {
|
List _buildGroupedList(List<History> historyList) {
|
||||||
|
// Sort histories by date (most recent first)
|
||||||
historyList.sort((a, b) => b.date.compareTo(a.date));
|
historyList.sort((a, b) => b.date.compareTo(a.date));
|
||||||
|
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
@ -225,8 +88,7 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
List<History> olderHistories = [];
|
List<History> olderHistories = [];
|
||||||
|
|
||||||
for (var history in historyList) {
|
for (var history in historyList) {
|
||||||
final callDate =
|
final callDate = DateTime(history.date.year, history.date.month, history.date.day);
|
||||||
DateTime(history.date.year, history.date.month, history.date.day);
|
|
||||||
if (callDate == today) {
|
if (callDate == today) {
|
||||||
todayHistories.add(history);
|
todayHistories.add(history);
|
||||||
} else if (callDate == yesterday) {
|
} else if (callDate == yesterday) {
|
||||||
@ -236,6 +98,7 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Combine them with headers
|
||||||
final items = <dynamic>[];
|
final items = <dynamic>[];
|
||||||
if (todayHistories.isNotEmpty) {
|
if (todayHistories.isNotEmpty) {
|
||||||
items.add('Today');
|
items.add('Today');
|
||||||
@ -253,37 +116,16 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an icon reflecting call type and status.
|
|
||||||
Icon _getCallIcon(History history) {
|
|
||||||
IconData iconData;
|
|
||||||
Color iconColor;
|
|
||||||
if (history.callType == 'incoming') {
|
|
||||||
if (history.callStatus == 'missed') {
|
|
||||||
iconData = Icons.call_missed;
|
|
||||||
iconColor = Colors.red;
|
|
||||||
} else {
|
|
||||||
iconData = Icons.call_received;
|
|
||||||
iconColor = Colors.green;
|
|
||||||
}
|
|
||||||
} else if (history.callType == 'outgoing') {
|
|
||||||
iconData = Icons.call_made;
|
|
||||||
iconColor = Colors.green;
|
|
||||||
} else {
|
|
||||||
iconData = Icons.phone;
|
|
||||||
iconColor = Colors.white;
|
|
||||||
}
|
|
||||||
return Icon(iconData, color: iconColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context); // required due to AutomaticKeepAliveClientMixin
|
|
||||||
final contactState = ContactState.of(context);
|
final contactState = ContactState.of(context);
|
||||||
|
|
||||||
if (loading || contactState.loading) {
|
if (loading || contactState.loading) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
body: const Center(child: CircularProgressIndicator()),
|
body: const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,8 +141,8 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<History> missedCalls =
|
// Filter missed calls
|
||||||
histories.where((h) => h.callStatus == 'missed').toList();
|
List<History> missedCalls = histories.where((h) => h.callStatus == 'missed').toList();
|
||||||
|
|
||||||
final allItems = _buildGroupedList(histories);
|
final allItems = _buildGroupedList(histories);
|
||||||
final missedItems = _buildGroupedList(missedCalls);
|
final missedItems = _buildGroupedList(missedCalls);
|
||||||
@ -324,7 +166,9 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
),
|
),
|
||||||
body: TabBarView(
|
body: TabBarView(
|
||||||
children: [
|
children: [
|
||||||
|
// All Calls
|
||||||
_buildListView(allItems),
|
_buildListView(allItems),
|
||||||
|
// Missed Calls
|
||||||
_buildListView(missedItems),
|
_buildListView(missedItems),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -337,7 +181,9 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
itemCount: items.length,
|
itemCount: items.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final item = items[index];
|
final item = items[index];
|
||||||
|
|
||||||
if (item is String) {
|
if (item is String) {
|
||||||
|
// This is a header item
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
|
||||||
color: Colors.grey[900],
|
color: Colors.grey[900],
|
||||||
@ -353,70 +199,37 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
final history = item;
|
final history = item;
|
||||||
final contact = history.contact;
|
final contact = history.contact;
|
||||||
final isExpanded = _expandedIndex == index;
|
final isExpanded = _expandedIndex == index;
|
||||||
|
|
||||||
|
// Generate the avatar color
|
||||||
Color avatarColor = generateColorFromName(contact.displayName);
|
Color avatarColor = generateColorFromName(contact.displayName);
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: GestureDetector(
|
leading: (contact.thumbnail != null && contact.thumbnail!.isNotEmpty)
|
||||||
onTap: () {
|
? CircleAvatar(
|
||||||
showModalBottomSheet(
|
backgroundImage: MemoryImage(contact.thumbnail!),
|
||||||
context: context,
|
)
|
||||||
isScrollControlled: true,
|
: CircleAvatar(
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
builder: (context) {
|
|
||||||
return ContactModal(
|
|
||||||
contact: contact,
|
|
||||||
onEdit: () async {
|
|
||||||
if (await FlutterContacts.requestPermission()) {
|
|
||||||
final updatedContact =
|
|
||||||
await FlutterContacts.openExternalEdit(
|
|
||||||
contact.id);
|
|
||||||
if (updatedContact != null) {
|
|
||||||
await _refreshContacts();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(
|
|
||||||
'${contact.displayName} updated successfully!'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('Edit canceled or failed.'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onToggleFavorite: () {
|
|
||||||
_toggleFavorite(contact);
|
|
||||||
},
|
|
||||||
isFavorite: contact.isStarred,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: ObfuscatedAvatar(
|
|
||||||
imageBytes: contact.thumbnail,
|
|
||||||
radius: 25,
|
|
||||||
backgroundColor: avatarColor,
|
backgroundColor: avatarColor,
|
||||||
fallbackInitial: contact.displayName,
|
child: Text(
|
||||||
|
contact.displayName.isNotEmpty
|
||||||
|
? contact.displayName[0].toUpperCase()
|
||||||
|
: '?',
|
||||||
|
style: TextStyle(color: darken(avatarColor, 0.4)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
title: Text(
|
title: Text(
|
||||||
_obfuscateService.obfuscateData(contact.displayName),
|
contact.displayName,
|
||||||
style: const TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
DateFormat('MMM dd, hh:mm a').format(history.date),
|
'${history.callType} - ${history.callStatus} - ${DateFormat('MMM dd, hh:mm a').format(history.date)}',
|
||||||
style: const TextStyle(color: Colors.grey),
|
style: const TextStyle(color: Colors.grey),
|
||||||
),
|
),
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
_getCallIcon(history),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
Text(
|
||||||
'${history.attempts}x',
|
'${history.attempts}x',
|
||||||
style: const TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
@ -425,11 +238,18 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
icon: const Icon(Icons.phone, color: Colors.green),
|
icon: const Icon(Icons.phone, color: Colors.green),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (contact.phones.isNotEmpty) {
|
if (contact.phones.isNotEmpty) {
|
||||||
_callService.makeGsmCall(context, phoneNumber: contact.phones.first.number);
|
final Uri callUri =
|
||||||
|
Uri(scheme: 'tel', path: contact.phones.first.number);
|
||||||
|
if (await canLaunchUrl(callUri)) {
|
||||||
|
await launchUrl(callUri);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(content: Text('Could not launch call')),
|
||||||
content: Text('Contact has no phone number')),
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Contact has no phone number')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -445,100 +265,62 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
if (isExpanded)
|
if (isExpanded)
|
||||||
Container(
|
Container(
|
||||||
color: Colors.grey[850],
|
color: Colors.grey[850],
|
||||||
child: FutureBuilder<bool>(
|
child: Row(
|
||||||
future: BlockService().isNumberBlocked(
|
|
||||||
contact.phones.isNotEmpty
|
|
||||||
? contact.phones.first.number
|
|
||||||
: ''),
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
final isBlocked = snapshot.data ?? false;
|
|
||||||
return Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
TextButton.icon(
|
TextButton.icon(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (history.contact.phones.isNotEmpty) {
|
if (history.contact.phones.isNotEmpty) {
|
||||||
final Uri smsUri = Uri(
|
final Uri smsUri =
|
||||||
scheme: 'sms',
|
Uri(scheme: 'sms', path: history.contact.phones.first.number);
|
||||||
path: history.contact.phones.first.number);
|
|
||||||
if (await canLaunchUrl(smsUri)) {
|
if (await canLaunchUrl(smsUri)) {
|
||||||
await launchUrl(smsUri);
|
await launchUrl(smsUri);
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(content: Text('Could not send message')),
|
||||||
content:
|
|
||||||
Text('Could not send message')),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(content: Text('Contact has no phone number')),
|
||||||
content:
|
|
||||||
Text('Contact has no phone number')),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon:
|
icon: const Icon(Icons.message, color: Colors.white),
|
||||||
const Icon(Icons.message, color: Colors.white),
|
label: const Text('Message', style: TextStyle(color: Colors.white)),
|
||||||
label: const Text('Message',
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
),
|
),
|
||||||
TextButton.icon(
|
TextButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
// Navigate to Call Details page
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) =>
|
builder: (_) => CallDetailsPage(history: history),
|
||||||
CallDetailsPage(history: history),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.info, color: Colors.white),
|
icon: const Icon(Icons.info, color: Colors.white),
|
||||||
label: const Text('Details',
|
label: const Text('Details', style: TextStyle(color: Colors.white)),
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
),
|
),
|
||||||
TextButton.icon(
|
TextButton.icon(
|
||||||
onPressed: () async {
|
onPressed: () {
|
||||||
final phoneNumber = contact.phones.isNotEmpty
|
// Implement block number functionality
|
||||||
? contact.phones.first.number
|
|
||||||
: null;
|
|
||||||
if (phoneNumber == null) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(
|
||||||
content:
|
content: Text('Number blocked (functionality not implemented)'),
|
||||||
Text('Contact has no phone number')),
|
),
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isBlocked) {
|
|
||||||
await BlockService().unblockNumber(phoneNumber);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('$phoneNumber unblocked')),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await BlockService().blockNumber(phoneNumber);
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('$phoneNumber blocked')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
setState(() {});
|
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: const Icon(Icons.block, color: Colors.white),
|
||||||
isBlocked ? Icons.lock_open : Icons.block,
|
label: const Text('Block', style: TextStyle(color: Colors.white)),
|
||||||
color: Colors.white),
|
|
||||||
label: Text(isBlocked ? 'Unblock' : 'Block',
|
|
||||||
style: const TextStyle(color: Colors.white)),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -547,15 +329,12 @@ class _HistoryPageState extends State<HistoryPage>
|
|||||||
|
|
||||||
class CallDetailsPage extends StatelessWidget {
|
class CallDetailsPage extends StatelessWidget {
|
||||||
final History history;
|
final History history;
|
||||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
|
||||||
|
|
||||||
CallDetailsPage({super.key, required this.history});
|
const CallDetailsPage({Key? key, required this.history}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final contact = history.contact;
|
final contact = history.contact;
|
||||||
final contactBg = generateColorFromName(contact.displayName);
|
|
||||||
final contactLetter = darken(contactBg);
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
@ -567,38 +346,36 @@ class CallDetailsPage extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
// Display Contact Name and Thumbnail.
|
// Display Contact Name and Thumbnail
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
(contact.thumbnail != null && contact.thumbnail!.isNotEmpty)
|
(contact.thumbnail != null && contact.thumbnail!.isNotEmpty)
|
||||||
? ObfuscatedAvatar(
|
? CircleAvatar(
|
||||||
imageBytes: contact.thumbnail,
|
backgroundImage: MemoryImage(contact.thumbnail!),
|
||||||
radius: 30,
|
radius: 30,
|
||||||
backgroundColor: contactBg,
|
|
||||||
fallbackInitial: contact.displayName,
|
|
||||||
)
|
)
|
||||||
: CircleAvatar(
|
: CircleAvatar(
|
||||||
backgroundColor:
|
backgroundColor: Colors.grey[700],
|
||||||
generateColorFromName(contact.displayName),
|
|
||||||
radius: 30,
|
radius: 30,
|
||||||
child: Text(
|
child: Text(
|
||||||
contact.displayName.isNotEmpty
|
contact.displayName.isNotEmpty
|
||||||
? contact.displayName[0].toUpperCase()
|
? contact.displayName[0].toUpperCase()
|
||||||
: '?',
|
: '?',
|
||||||
style: TextStyle(color: contactLetter),
|
style: const TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
_obfuscateService.obfuscateData(contact.displayName),
|
contact.displayName,
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 24),
|
style: const TextStyle(color: Colors.white, fontSize: 24),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// Display call details.
|
|
||||||
|
// Display call type, status, date, attempts
|
||||||
DetailRow(
|
DetailRow(
|
||||||
label: 'Call Type:',
|
label: 'Call Type:',
|
||||||
value: history.callType,
|
value: history.callType,
|
||||||
@ -615,12 +392,14 @@ class CallDetailsPage extends StatelessWidget {
|
|||||||
label: 'Attempts:',
|
label: 'Attempts:',
|
||||||
value: '${history.attempts}',
|
value: '${history.attempts}',
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
|
// If you have more details like duration, contact number, etc.
|
||||||
if (contact.phones.isNotEmpty)
|
if (contact.phones.isNotEmpty)
|
||||||
DetailRow(
|
DetailRow(
|
||||||
label: 'Number:',
|
label: 'Number:',
|
||||||
value: _obfuscateService
|
value: contact.phones.first.number,
|
||||||
.obfuscateData(contact.phones.first.number),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -633,8 +412,7 @@ class DetailRow extends StatelessWidget {
|
|||||||
final String label;
|
final String label;
|
||||||
final String value;
|
final String value;
|
||||||
|
|
||||||
const DetailRow({Key? key, required this.label, required this.value})
|
const DetailRow({Key? key, required this.label, required this.value}) : super(key: key);
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -644,8 +422,7 @@ class DetailRow extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
label,
|
label,
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Colors.white70, fontWeight: FontWeight.bold),
|
||||||
color: Colors.white70, fontWeight: FontWeight.bold),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -1,91 +1,64 @@
|
|||||||
import 'package:dialer/services/obfuscate_service.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
|
import 'package:dialer/features/settings/settings.dart';
|
||||||
import 'package:dialer/features/contacts/contact_page.dart';
|
import 'package:dialer/features/contacts/contact_page.dart';
|
||||||
import 'package:dialer/features/favorites/favorites_page.dart';
|
import 'package:dialer/features/favorites/favorites_page.dart';
|
||||||
import 'package:dialer/features/history/history_page.dart';
|
import 'package:dialer/features/history/history_page.dart';
|
||||||
import 'package:dialer/features/composition/composition.dart';
|
import 'package:dialer/features/composition/composition.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import '../../widgets/contact_service.dart';
|
||||||
import 'package:dialer/features/settings/settings.dart';
|
|
||||||
import '../../services/contact_service.dart';
|
|
||||||
import 'package:dialer/features/voicemail/voicemail_page.dart';
|
|
||||||
import '../contacts/widgets/contact_modal.dart';
|
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
|
/// This MyHomePage now expects two callbacks.
|
||||||
|
/// - onMakeCall: used to start calls
|
||||||
|
/// - onRequestDialer: used to become default dialer
|
||||||
|
class MyHomePage extends StatefulWidget {
|
||||||
|
final Function(String) onMakeCall;
|
||||||
|
final Function onRequestDialer;
|
||||||
|
|
||||||
|
const MyHomePage({
|
||||||
|
Key? key,
|
||||||
|
required this.onMakeCall,
|
||||||
|
required this.onRequestDialer,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_MyHomePageState createState() => _MyHomePageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MyHomePageState extends State<MyHomePage>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
late TabController _tabController;
|
late TabController _tabController;
|
||||||
List<Contact> _allContacts = [];
|
List<Contact> _allContacts = [];
|
||||||
List<Contact> _contactSuggestions = [];
|
List<Contact> _contactSuggestions = [];
|
||||||
|
|
||||||
final ContactService _contactService = ContactService();
|
final ContactService _contactService = ContactService();
|
||||||
final ObfuscateService _obfuscateService = ObfuscateService();
|
|
||||||
final TextEditingController _searchController = TextEditingController();
|
|
||||||
late SearchController _searchBarController;
|
|
||||||
String _rawSearchInput = '';
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_tabController = TabController(length: 4, vsync: this, initialIndex: 2);
|
// We have 3 tabs: Favorites, History, Contacts
|
||||||
|
_tabController = TabController(length: 3, vsync: this, initialIndex: 1);
|
||||||
_tabController.addListener(_handleTabIndex);
|
_tabController.addListener(_handleTabIndex);
|
||||||
_searchBarController = SearchController();
|
|
||||||
_searchBarController.addListener(() {
|
|
||||||
if (_searchController.text != _searchBarController.text) {
|
|
||||||
_rawSearchInput = _searchBarController.text;
|
|
||||||
_searchController.text = _rawSearchInput;
|
|
||||||
_onSearchChanged(_searchBarController.text);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_fetchContacts();
|
_fetchContacts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _fetchContacts() async {
|
void _fetchContacts() async {
|
||||||
_allContacts = await _contactService.fetchContacts();
|
_allContacts = await _contactService.fetchContacts();
|
||||||
_contactSuggestions = List.from(_allContacts);
|
setState(() {});
|
||||||
if (mounted) setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _clearSearch() {
|
|
||||||
_searchController.clear();
|
|
||||||
_searchBarController.clear();
|
|
||||||
_rawSearchInput = '';
|
|
||||||
_onSearchChanged('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSearchChanged(String query) {
|
void _onSearchChanged(String query) {
|
||||||
setState(() {
|
|
||||||
if (query.isEmpty) {
|
if (query.isEmpty) {
|
||||||
_contactSuggestions = List.from(_allContacts);
|
_contactSuggestions = List.from(_allContacts);
|
||||||
} else {
|
} else {
|
||||||
final normalizedQuery = _normalizeString(query.toLowerCase());
|
|
||||||
_contactSuggestions = _allContacts.where((contact) {
|
_contactSuggestions = _allContacts.where((contact) {
|
||||||
final normalizedName = _normalizeString(contact.displayName.toLowerCase());
|
return contact.displayName.toLowerCase().contains(query.toLowerCase());
|
||||||
return normalizedName.contains(normalizedQuery);
|
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
});
|
setState(() {});
|
||||||
}
|
|
||||||
|
|
||||||
String _normalizeString(String input) {
|
|
||||||
const accentMap = {
|
|
||||||
'àáâãäå': 'a',
|
|
||||||
'èéêë': 'e',
|
|
||||||
'ìíîï': 'i',
|
|
||||||
'òóôõö': 'o',
|
|
||||||
'ùúûü': 'u',
|
|
||||||
'ç': 'c',
|
|
||||||
'ñ': 'n',
|
|
||||||
};
|
|
||||||
String normalized = input;
|
|
||||||
accentMap.forEach((accents, base) {
|
|
||||||
for (var accent in accents.split('')) {
|
|
||||||
normalized = normalized.replaceAll(accent, base);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return normalized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_searchController.dispose();
|
|
||||||
_searchBarController.dispose();
|
|
||||||
_tabController.removeListener(_handleTabIndex);
|
_tabController.removeListener(_handleTabIndex);
|
||||||
_tabController.dispose();
|
_tabController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@ -95,39 +68,13 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _toggleFavorite(Contact contact) async {
|
|
||||||
try {
|
|
||||||
if (await FlutterContacts.requestPermission()) {
|
|
||||||
Contact? fullContact = await FlutterContacts.getContact(
|
|
||||||
contact.id,
|
|
||||||
withProperties: true,
|
|
||||||
withAccounts: true,
|
|
||||||
withPhoto: true,
|
|
||||||
withThumbnail: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fullContact != null) {
|
|
||||||
fullContact.isStarred = !fullContact.isStarred;
|
|
||||||
await FlutterContacts.updateContact(fullContact);
|
|
||||||
_fetchContacts();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print("Could not fetch contact details");
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
print("Error updating favorite status: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Failed to update contact favorite status')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
|
// Persistent Search Bar
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
top: 24.0,
|
top: 24.0,
|
||||||
@ -142,102 +89,65 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color.fromARGB(255, 30, 30, 30),
|
color: const Color.fromARGB(255, 30, 30, 30),
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
border: Border.all(color: Colors.grey.shade800, width: 1),
|
border: Border(
|
||||||
|
top: BorderSide(color: Colors.grey.shade800, width: 1),
|
||||||
|
left: BorderSide(color: Colors.grey.shade800, width: 1),
|
||||||
|
right: BorderSide(color: Colors.grey.shade800, width: 1),
|
||||||
|
bottom: BorderSide(color: Colors.grey.shade800, width: 2),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
// Using Flutter 3.10+ SearchAnchor / SearchBar API:
|
||||||
child: SearchAnchor(
|
child: SearchAnchor(
|
||||||
searchController: _searchBarController,
|
builder:
|
||||||
builder: (BuildContext context, SearchController controller) {
|
(BuildContext context, SearchController controller) {
|
||||||
return GestureDetector(
|
return SearchBar(
|
||||||
|
controller: controller,
|
||||||
|
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
|
||||||
|
const EdgeInsets.only(
|
||||||
|
top: 6.0,
|
||||||
|
bottom: 6.0,
|
||||||
|
left: 16.0,
|
||||||
|
right: 16.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
controller.openView();
|
controller.openView();
|
||||||
|
_onSearchChanged('');
|
||||||
},
|
},
|
||||||
child: Container(
|
backgroundColor: MaterialStateProperty.all(
|
||||||
decoration: BoxDecoration(
|
const Color.fromARGB(255, 30, 30, 30),
|
||||||
color: const Color.fromARGB(255, 30, 30, 30),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
border: Border.all(color: Colors.grey.shade800, width: 1),
|
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
|
hintText: 'Search contacts',
|
||||||
child: Row(
|
hintStyle: MaterialStateProperty.all(
|
||||||
children: [
|
const TextStyle(color: Colors.grey, fontSize: 16.0),
|
||||||
const Icon(Icons.search, color: Colors.grey, size: 24.0),
|
|
||||||
const SizedBox(width: 8.0),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
_rawSearchInput.isEmpty
|
|
||||||
? 'Search contacts'
|
|
||||||
: _rawSearchInput,
|
|
||||||
style: const TextStyle(color: Colors.grey, fontSize: 16.0),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
),
|
||||||
),
|
leading: const Icon(
|
||||||
if (_rawSearchInput.isNotEmpty)
|
Icons.search,
|
||||||
GestureDetector(
|
|
||||||
onTap: _clearSearch,
|
|
||||||
child: const Icon(
|
|
||||||
Icons.clear,
|
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
size: 24.0,
|
size: 24.0,
|
||||||
),
|
),
|
||||||
),
|
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
||||||
],
|
RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
viewOnChanged: (query) {
|
viewOnChanged: (query) {
|
||||||
|
|
||||||
if (_searchBarController.text != query) {
|
|
||||||
_rawSearchInput = query;
|
|
||||||
_searchBarController.text = query;
|
|
||||||
_searchController.text = query;
|
|
||||||
}
|
|
||||||
_onSearchChanged(query);
|
_onSearchChanged(query);
|
||||||
},
|
},
|
||||||
suggestionsBuilder: (BuildContext context, SearchController controller) {
|
suggestionsBuilder:
|
||||||
|
(BuildContext context, SearchController controller) {
|
||||||
return _contactSuggestions.map((contact) {
|
return _contactSuggestions.map((contact) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
key: ValueKey(contact.id),
|
key: ValueKey(contact.id),
|
||||||
title: Text(
|
title: Text(
|
||||||
_obfuscateService.obfuscateData(contact.displayName),
|
contact.displayName,
|
||||||
style: const TextStyle(color: Colors.white),
|
style: const TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
// For example, you might call widget.onMakeCall(contact.phoneNumber)
|
||||||
controller.closeView(contact.displayName);
|
controller.closeView(contact.displayName);
|
||||||
showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
isScrollControlled: true,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
builder: (context) {
|
|
||||||
return ContactModal(
|
|
||||||
contact: contact,
|
|
||||||
onEdit: () async {
|
|
||||||
if (await FlutterContacts.requestPermission()) {
|
|
||||||
final updatedContact = await FlutterContacts
|
|
||||||
.openExternalEdit(contact.id);
|
|
||||||
if (updatedContact != null) {
|
|
||||||
_fetchContacts();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(
|
|
||||||
'${contact.displayName} updated successfully!'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text('Edit canceled or failed.'),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onToggleFavorite: () => _toggleFavorite(contact),
|
|
||||||
isFavorite: contact.isStarred,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
@ -245,6 +155,7 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// 3-dot menu
|
||||||
PopupMenuButton<String>(
|
PopupMenuButton<String>(
|
||||||
icon: const Icon(Icons.more_vert, color: Colors.white),
|
icon: const Icon(Icons.more_vert, color: Colors.white),
|
||||||
itemBuilder: (BuildContext context) => [
|
itemBuilder: (BuildContext context) => [
|
||||||
@ -252,6 +163,10 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
|||||||
value: 'settings',
|
value: 'settings',
|
||||||
child: Text('Settings'),
|
child: Text('Settings'),
|
||||||
),
|
),
|
||||||
|
const PopupMenuItem<String>(
|
||||||
|
value: 'becomeDialer',
|
||||||
|
child: Text('Become Default Dialer'),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
onSelected: (String value) {
|
onSelected: (String value) {
|
||||||
if (value == 'settings') {
|
if (value == 'settings') {
|
||||||
@ -259,12 +174,16 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
|||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => const SettingsPage()),
|
MaterialPageRoute(builder: (context) => const SettingsPage()),
|
||||||
);
|
);
|
||||||
|
} else if (value == 'becomeDialer') {
|
||||||
|
// Use the callback passed in from main.dart:
|
||||||
|
widget.onRequestDialer();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// Main content with TabBarView
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -274,14 +193,16 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
|||||||
FavoritesPage(),
|
FavoritesPage(),
|
||||||
HistoryPage(),
|
HistoryPage(),
|
||||||
ContactPage(),
|
ContactPage(),
|
||||||
VoicemailPage(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
// Floating action button for manual composition/dialpad
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 20,
|
right: 20,
|
||||||
bottom: 20,
|
bottom: 20,
|
||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
// Here you could do widget.onMakeCall('123456') or
|
||||||
|
// push to CompositionPage, etc.
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@ -309,19 +230,17 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
|||||||
Tab(
|
Tab(
|
||||||
icon: Icon(_tabController.index == 0
|
icon: Icon(_tabController.index == 0
|
||||||
? Icons.star
|
? Icons.star
|
||||||
: Icons.star_border)),
|
: Icons.star_border),
|
||||||
|
),
|
||||||
Tab(
|
Tab(
|
||||||
icon: Icon(_tabController.index == 1
|
icon: Icon(_tabController.index == 1
|
||||||
? Icons.access_time_filled
|
? Icons.access_time_filled
|
||||||
: Icons.access_time_outlined)),
|
: Icons.access_time_outlined),
|
||||||
|
),
|
||||||
Tab(
|
Tab(
|
||||||
icon: Icon(_tabController.index == 2
|
icon: Icon(_tabController.index == 2
|
||||||
? Icons.contacts
|
? Icons.contacts
|
||||||
: Icons.contacts_outlined)),
|
: Icons.contacts_outlined),
|
||||||
Tab(
|
|
||||||
icon: Icon(_tabController.index == 3
|
|
||||||
? Icons.voicemail
|
|
||||||
: Icons.voicemail_outlined),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
labelColor: Colors.white,
|
labelColor: Colors.white,
|
||||||
@ -333,10 +252,3 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
|
||||||
const MyHomePage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
_MyHomePageState createState() => _MyHomePageState();
|
|
||||||
}
|
|
@ -1,145 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:dialer/services/cryptography/asymmetric_crypto_service.dart';
|
|
||||||
|
|
||||||
class ManageKeysPage extends StatefulWidget {
|
|
||||||
const ManageKeysPage({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_ManageKeysPageState createState() => _ManageKeysPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ManageKeysPageState extends State<ManageKeysPage> {
|
|
||||||
final AsymmetricCryptoService _cryptoService = AsymmetricCryptoService();
|
|
||||||
List<Map<String, dynamic>> _keys = [];
|
|
||||||
bool _isLoading = false;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_loadKeys();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _loadKeys() async {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
List<Map<String, dynamic>> keys = await _cryptoService.getAllKeys();
|
|
||||||
setState(() {
|
|
||||||
_keys = keys;
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(SnackBar(content: Text('Error loading keys: $e')));
|
|
||||||
} finally {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _generateKey() async {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await _cryptoService.generateKeyPair();
|
|
||||||
await _loadKeys();
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(const SnackBar(content: Text('Key generated successfully')));
|
|
||||||
} catch (e) {
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(SnackBar(content: Text('Error generating key: $e')));
|
|
||||||
} finally {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _deleteKey(String alias) async {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = true;
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
await _cryptoService.deleteKeyPair(alias);
|
|
||||||
await _loadKeys();
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(const SnackBar(content: Text('Key deleted successfully')));
|
|
||||||
} catch (e) {
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(SnackBar(content: Text('Error deleting key: $e')));
|
|
||||||
} finally {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _viewPublicKey(String alias) async {
|
|
||||||
try {
|
|
||||||
final publicKey = await _cryptoService.getPublicKey(alias);
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => AlertDialog(
|
|
||||||
title: const Text('Public Key'),
|
|
||||||
content: SingleChildScrollView(child: Text(publicKey)),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
child: const Text('Close'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
ScaffoldMessenger.of(context)
|
|
||||||
.showSnackBar(SnackBar(content: Text('Error retrieving public key: $e')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Manage Keys'),
|
|
||||||
),
|
|
||||||
body: _isLoading
|
|
||||||
? const Center(child: CircularProgressIndicator())
|
|
||||||
: _keys.isEmpty
|
|
||||||
? const Center(child: Text('No keys found'))
|
|
||||||
: ListView.builder(
|
|
||||||
itemCount: _keys.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final keyData = _keys[index];
|
|
||||||
return ListTile(
|
|
||||||
title: Text(keyData['label'] ?? 'No label'),
|
|
||||||
subtitle: Text(keyData['alias'] ?? ''),
|
|
||||||
trailing: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.visibility),
|
|
||||||
tooltip: 'View Public Key',
|
|
||||||
onPressed: () => _viewPublicKey(keyData['alias']),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.delete),
|
|
||||||
tooltip: 'Delete Key',
|
|
||||||
onPressed: () => _deleteKey(keyData['alias']),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: _generateKey,
|
|
||||||
child: const Icon(Icons.add),
|
|
||||||
tooltip: 'Generate New Key',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
65
dialer/lib/features/settings/key/delete_key_pair.dart
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'key_storage.dart';
|
||||||
|
|
||||||
|
class DeleteKeyPairPage extends StatelessWidget {
|
||||||
|
const DeleteKeyPairPage({super.key});
|
||||||
|
|
||||||
|
Future<void> _deleteKeyPair(BuildContext context) async {
|
||||||
|
final keyStorage = KeyStorage();
|
||||||
|
await keyStorage.deleteKeys();
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('The key pair has been deleted.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showConfirmationDialog(BuildContext context) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('Confirm Deletion'),
|
||||||
|
content: const Text(
|
||||||
|
'Are you sure you want to delete the key pair? This action is irreversible.'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
child: const Text('Delete'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
_deleteKeyPair(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Delete a Key Pair'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
_showConfirmationDialog(context);
|
||||||
|
},
|
||||||
|
child: const Text('Delete Key Pair'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
138
dialer/lib/features/settings/key/export_private_key.dart
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:pointycastle/export.dart' as crypto;
|
||||||
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'key_storage.dart';
|
||||||
|
|
||||||
|
class ExportPrivateKeyPage extends StatefulWidget {
|
||||||
|
const ExportPrivateKeyPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ExportPrivateKeyPageState createState() => _ExportPrivateKeyPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ExportPrivateKeyPageState extends State<ExportPrivateKeyPage> {
|
||||||
|
final TextEditingController _passwordController = TextEditingController();
|
||||||
|
|
||||||
|
Future<void> _exportPrivateKey() async {
|
||||||
|
final keyStorage = KeyStorage();
|
||||||
|
final privateKeyPem = await keyStorage.getPrivateKey();
|
||||||
|
|
||||||
|
if (privateKeyPem == null) {
|
||||||
|
// Show error message if there's no key
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('No private key found to export.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final password = _passwordController.text;
|
||||||
|
if (password.isEmpty) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Please enter a password.'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final encryptedData = _encryptPrivateKey(privateKeyPem, password);
|
||||||
|
|
||||||
|
final outputFile = await FilePicker.platform.saveFile(
|
||||||
|
dialogTitle: 'Save encrypted private key',
|
||||||
|
fileName: 'private_key_encrypted.aes',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (outputFile != null) {
|
||||||
|
try {
|
||||||
|
final file = File(outputFile);
|
||||||
|
await file.writeAsBytes(encryptedData);
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Key Exported'),
|
||||||
|
content: const Text('The encrypted private key has been exported successfully.'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('OK'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('Failed to write file: $e'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint8List _encryptPrivateKey(String privateKey, String password) {
|
||||||
|
// Derive a key from the password using PBKDF2
|
||||||
|
final derivator = crypto.PBKDF2KeyDerivator(
|
||||||
|
crypto.HMac(crypto.SHA256Digest(), 64),
|
||||||
|
);
|
||||||
|
|
||||||
|
final salt = Uint8List.fromList(utf8.encode('some_salt')); // In production, use a random salt and store it securely
|
||||||
|
derivator.init(crypto.Pbkdf2Parameters(salt, 1000, 32));
|
||||||
|
final key = derivator.process(Uint8List.fromList(utf8.encode(password)));
|
||||||
|
|
||||||
|
// Initialize AES-CBC cipher with PKCS7 padding
|
||||||
|
final iv = Uint8List(16); // zero IV for example, in production use random IV and store it
|
||||||
|
final params = crypto.PaddedBlockCipherParameters<crypto.ParametersWithIV<crypto.KeyParameter>, Null>(
|
||||||
|
crypto.ParametersWithIV<crypto.KeyParameter>(crypto.KeyParameter(key), iv),
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
|
final cipher = crypto.PaddedBlockCipher('AES/CBC/PKCS7');
|
||||||
|
cipher.init(true, params);
|
||||||
|
|
||||||
|
final input = Uint8List.fromList(utf8.encode(privateKey));
|
||||||
|
final output = cipher.process(input);
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Export Private Key'),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Enter a password to encrypt the private key:',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: _passwordController,
|
||||||
|
obscureText: true,
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Password',
|
||||||
|
hintStyle: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _exportPrivateKey,
|
||||||
|
child: const Text('Export Encrypted Private Key'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
122
dialer/lib/features/settings/key/generate_new_key_pair.dart
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pointycastle/export.dart' as crypto;
|
||||||
|
import 'dart:math';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
import 'package:asn1lib/asn1lib.dart';
|
||||||
|
import 'key_storage.dart';
|
||||||
|
|
||||||
|
class GenerateNewKeyPairPage extends StatelessWidget {
|
||||||
|
const GenerateNewKeyPairPage({super.key});
|
||||||
|
|
||||||
|
Future<Map<String, String>> _generateKeyPair() async {
|
||||||
|
final keyParams = crypto.RSAKeyGeneratorParameters(
|
||||||
|
BigInt.parse('65537'),
|
||||||
|
2048,
|
||||||
|
64,
|
||||||
|
);
|
||||||
|
|
||||||
|
final secureRandom = crypto.FortunaRandom();
|
||||||
|
final random = Random.secure();
|
||||||
|
final seeds = List<int>.generate(32, (_) => random.nextInt(256));
|
||||||
|
secureRandom.seed(crypto.KeyParameter(Uint8List.fromList(seeds)));
|
||||||
|
|
||||||
|
final rngParams = crypto.ParametersWithRandom(keyParams, secureRandom);
|
||||||
|
final keyGenerator = crypto.RSAKeyGenerator();
|
||||||
|
keyGenerator.init(rngParams);
|
||||||
|
|
||||||
|
final pair = keyGenerator.generateKeyPair();
|
||||||
|
final publicKey = pair.publicKey as crypto.RSAPublicKey;
|
||||||
|
final privateKey = pair.privateKey as crypto.RSAPrivateKey;
|
||||||
|
|
||||||
|
final publicKeyPem = _encodePublicKeyToPemPKCS1(publicKey);
|
||||||
|
final privateKeyPem = _encodePrivateKeyToPemPKCS1(privateKey);
|
||||||
|
|
||||||
|
// Save keys securely
|
||||||
|
final keyStorage = KeyStorage();
|
||||||
|
await keyStorage.saveKeys(publicKey: publicKeyPem, privateKey: privateKeyPem);
|
||||||
|
|
||||||
|
return {'publicKey': publicKeyPem, 'privateKey': privateKeyPem};
|
||||||
|
}
|
||||||
|
|
||||||
|
String _encodePublicKeyToPemPKCS1(crypto.RSAPublicKey publicKey) {
|
||||||
|
final bytes = _encodePublicKeyToDer(publicKey);
|
||||||
|
return _formatPem(bytes, 'RSA PUBLIC KEY');
|
||||||
|
}
|
||||||
|
|
||||||
|
String _encodePrivateKeyToPemPKCS1(crypto.RSAPrivateKey privateKey) {
|
||||||
|
final bytes = _encodePrivateKeyToDer(privateKey);
|
||||||
|
return _formatPem(bytes, 'RSA PRIVATE KEY');
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint8List _encodePublicKeyToDer(crypto.RSAPublicKey publicKey) {
|
||||||
|
final algorithmSeq = ASN1Sequence();
|
||||||
|
// Create the OID directly with the arcs
|
||||||
|
algorithmSeq.add(ASN1ObjectIdentifier([1, 2, 840, 113549, 1, 1, 1]));
|
||||||
|
algorithmSeq.add(ASN1Null());
|
||||||
|
|
||||||
|
final publicKeySeq = ASN1Sequence();
|
||||||
|
publicKeySeq.add(ASN1Integer(publicKey.modulus!));
|
||||||
|
publicKeySeq.add(ASN1Integer(publicKey.exponent!));
|
||||||
|
|
||||||
|
final publicKeyBitString = ASN1BitString(Uint8List.fromList(publicKeySeq.encodedBytes));
|
||||||
|
|
||||||
|
final topLevelSeq = ASN1Sequence();
|
||||||
|
topLevelSeq.add(algorithmSeq);
|
||||||
|
topLevelSeq.add(publicKeyBitString);
|
||||||
|
|
||||||
|
return Uint8List.fromList(topLevelSeq.encodedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint8List _encodePrivateKeyToDer(crypto.RSAPrivateKey privateKey) {
|
||||||
|
final privateKeySeq = ASN1Sequence();
|
||||||
|
privateKeySeq.add(ASN1Integer(BigInt.from(0))); // Version
|
||||||
|
privateKeySeq.add(ASN1Integer(privateKey.n!));
|
||||||
|
privateKeySeq.add(ASN1Integer(privateKey.exponent!));
|
||||||
|
privateKeySeq.add(ASN1Integer(privateKey.d!));
|
||||||
|
privateKeySeq.add(ASN1Integer(privateKey.p!));
|
||||||
|
privateKeySeq.add(ASN1Integer(privateKey.q!));
|
||||||
|
privateKeySeq.add(ASN1Integer(privateKey.d! % (privateKey.p! - BigInt.one)));
|
||||||
|
privateKeySeq.add(ASN1Integer(privateKey.d! % (privateKey.q! - BigInt.one)));
|
||||||
|
privateKeySeq.add(ASN1Integer(privateKey.q!.modInverse(privateKey.p!)));
|
||||||
|
|
||||||
|
return Uint8List.fromList(privateKeySeq.encodedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _formatPem(Uint8List bytes, String label) {
|
||||||
|
final base64Data = base64Encode(bytes);
|
||||||
|
final chunks = RegExp('.{1,64}').allMatches(base64Data).map((m) => m.group(0)!);
|
||||||
|
return '-----BEGIN $label-----\n${chunks.join('\n')}\n-----END $label-----';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Generate a New Key Pair'),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () async {
|
||||||
|
await _generateKeyPair();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Keys Generated'),
|
||||||
|
content: const Text('The new key pair has been generated and stored securely.'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('OK'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('Generate a New Key Pair'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
28
dialer/lib/features/settings/key/key_storage.dart
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// key_storage.dart
|
||||||
|
|
||||||
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
|
||||||
|
class KeyStorage {
|
||||||
|
static const _publicKeyKey = 'public_key';
|
||||||
|
static const _privateKeyKey = 'private_key';
|
||||||
|
|
||||||
|
final FlutterSecureStorage _storage = const FlutterSecureStorage();
|
||||||
|
|
||||||
|
Future<void> saveKeys({required String publicKey, required String privateKey}) async {
|
||||||
|
await _storage.write(key: _publicKeyKey, value: publicKey);
|
||||||
|
await _storage.write(key: _privateKeyKey, value: privateKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getPublicKey() async {
|
||||||
|
return await _storage.read(key: _publicKeyKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getPrivateKey() async {
|
||||||
|
return await _storage.read(key: _privateKeyKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteKeys() async {
|
||||||
|
await _storage.delete(key: _publicKeyKey);
|
||||||
|
await _storage.delete(key: _privateKeyKey);
|
||||||
|
}
|
||||||
|
}
|
80
dialer/lib/features/settings/key/manage_keys_page.dart
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'show_public_key_qr.dart';
|
||||||
|
import 'show_public_key_text.dart';
|
||||||
|
import 'generate_new_key_pair.dart';
|
||||||
|
import 'export_private_key.dart';
|
||||||
|
import 'delete_key_pair.dart';
|
||||||
|
|
||||||
|
class KeyManagementPage extends StatelessWidget {
|
||||||
|
const KeyManagementPage({super.key});
|
||||||
|
|
||||||
|
void _navigateToOption(BuildContext context, String option) {
|
||||||
|
switch (option) {
|
||||||
|
case 'Display public key as text':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const DisplayPublicKeyTextPage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'Display public key as QR code':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const DisplayPublicKeyQRCodePage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'Generate a new key pair':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const GenerateNewKeyPairPage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'Export private key to password-encrypted file (AES 256)':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const ExportPrivateKeyPage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'Delete a key pair':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const DeleteKeyPairPage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final keyManagementOptions = [
|
||||||
|
'Display public key as text',
|
||||||
|
'Display public key as QR code',
|
||||||
|
'Generate a new key pair',
|
||||||
|
'Export private key to password-encrypted file (AES 256)',
|
||||||
|
'Delete a key pair',
|
||||||
|
];
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Key Management'),
|
||||||
|
),
|
||||||
|
body: ListView.builder(
|
||||||
|
itemCount: keyManagementOptions.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text(
|
||||||
|
keyManagementOptions[index],
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.white),
|
||||||
|
onTap: () {
|
||||||
|
_navigateToOption(context, keyManagementOptions[index]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
49
dialer/lib/features/settings/key/show_public_key_qr.dart
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pretty_qr_code/pretty_qr_code.dart';
|
||||||
|
import 'key_storage.dart';
|
||||||
|
|
||||||
|
class DisplayPublicKeyQRCodePage extends StatelessWidget {
|
||||||
|
const DisplayPublicKeyQRCodePage({super.key});
|
||||||
|
|
||||||
|
Future<String?> _loadPublicKey() async {
|
||||||
|
final keyStorage = KeyStorage();
|
||||||
|
return keyStorage.getPublicKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Public Key in QR Code'),
|
||||||
|
),
|
||||||
|
body: FutureBuilder<String?>(
|
||||||
|
future: _loadPublicKey(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
|
final publicKey = snapshot.data;
|
||||||
|
if (publicKey == null) {
|
||||||
|
return const Center(
|
||||||
|
child: Text(
|
||||||
|
'No public key found.',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Center(
|
||||||
|
child: PrettyQr(
|
||||||
|
data: publicKey,
|
||||||
|
size: 250,
|
||||||
|
roundEdges: true,
|
||||||
|
elementColor: Colors.white,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
50
dialer/lib/features/settings/key/show_public_key_text.dart
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'key_storage.dart';
|
||||||
|
|
||||||
|
class DisplayPublicKeyTextPage extends StatelessWidget {
|
||||||
|
const DisplayPublicKeyTextPage({super.key});
|
||||||
|
|
||||||
|
Future<String?> _loadPublicKey() async {
|
||||||
|
final keyStorage = KeyStorage();
|
||||||
|
return await keyStorage.getPublicKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Public Key as Text'),
|
||||||
|
),
|
||||||
|
body: FutureBuilder<String?>(
|
||||||
|
future: _loadPublicKey(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
}
|
||||||
|
|
||||||
|
final publicKey = snapshot.data;
|
||||||
|
if (publicKey == null) {
|
||||||
|
return const Center(
|
||||||
|
child: Text(
|
||||||
|
'No public key found.',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: SelectableText(
|
||||||
|
publicKey,
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:dialer/features/settings/call/settingsCall.dart';
|
import 'package:dialer/features/settings/call/settingsCall.dart';
|
||||||
// import 'package:dialer/features/settings/cryptography/';
|
import 'package:dialer/features/settings/sim/settings_accounts.dart';
|
||||||
|
import 'package:dialer/features/settings/key/manage_keys_page.dart';
|
||||||
import 'package:dialer/features/settings/blocked/settings_blocked.dart';
|
import 'package:dialer/features/settings/blocked/settings_blocked.dart';
|
||||||
import 'cryptography/key_management.dart';
|
|
||||||
|
|
||||||
class SettingsPage extends StatelessWidget {
|
class SettingsPage extends StatelessWidget {
|
||||||
const SettingsPage({super.key});
|
const SettingsPage({super.key});
|
||||||
@ -17,10 +17,16 @@ class SettingsPage extends StatelessWidget {
|
|||||||
MaterialPageRoute(builder: (context) => const SettingsCallPage()),
|
MaterialPageRoute(builder: (context) => const SettingsCallPage()),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case 'Sim settings':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const SettingsAccountsPage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
case 'Key management':
|
case 'Key management':
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => ManageKeysPage()),
|
MaterialPageRoute(builder: (context) => const KeyManagementPage()),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'Blocked numbers':
|
case 'Blocked numbers':
|
||||||
@ -40,6 +46,7 @@ class SettingsPage extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final settingsOptions = [
|
final settingsOptions = [
|
||||||
'Calling settings',
|
'Calling settings',
|
||||||
|
'Page of telephone accounts',
|
||||||
'Key management',
|
'Key management',
|
||||||
'Blocked numbers'
|
'Blocked numbers'
|
||||||
];
|
];
|
||||||
|
91
dialer/lib/features/settings/sim/choose_sim.dart
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mobile_number/mobile_number.dart';
|
||||||
|
|
||||||
|
class ChooseSimPage extends StatefulWidget {
|
||||||
|
const ChooseSimPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ChooseSimPageState createState() => _ChooseSimPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChooseSimPageState extends State<ChooseSimPage> {
|
||||||
|
List<SimCard> _simCards = [];
|
||||||
|
int? _selectedSimIndex;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_fetchSimCards();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _fetchSimCards() async {
|
||||||
|
try {
|
||||||
|
bool permissionsGranted = await MobileNumber.hasPhonePermission;
|
||||||
|
if (!permissionsGranted) {
|
||||||
|
await MobileNumber.requestPhonePermission;
|
||||||
|
permissionsGranted = await MobileNumber.hasPhonePermission;
|
||||||
|
}
|
||||||
|
if (permissionsGranted) {
|
||||||
|
List<SimCard>? simCards = await MobileNumber.getSimCards;
|
||||||
|
if (simCards != null && mounted) {
|
||||||
|
setState(() {
|
||||||
|
_simCards = simCards;
|
||||||
|
_selectedSimIndex = 0;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
print('No SIM cards found');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print('Phone permission denied');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to get SIM cards: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSimSelected(int? index) {
|
||||||
|
if (index != null) {
|
||||||
|
setState(() {
|
||||||
|
_selectedSimIndex = index;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Choose SIM'),
|
||||||
|
),
|
||||||
|
body: _simCards.isEmpty
|
||||||
|
? const Center(
|
||||||
|
child: Text(
|
||||||
|
'No SIM cards found',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ListView.builder(
|
||||||
|
itemCount: _simCards.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final sim = _simCards[index];
|
||||||
|
return ListTile(
|
||||||
|
title: Text(
|
||||||
|
'SIM ${index + 1}',
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'Operator: ${sim.carrierName ?? 'N/A'}',
|
||||||
|
style: const TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
trailing: Radio<int>(
|
||||||
|
value: index,
|
||||||
|
groupValue: _selectedSimIndex,
|
||||||
|
onChanged: _onSimSelected,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
57
dialer/lib/features/settings/sim/settings_accounts.dart
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'choose_sim.dart';
|
||||||
|
import 'sim_parameters.dart';
|
||||||
|
|
||||||
|
class SettingsAccountsPage extends StatelessWidget {
|
||||||
|
const SettingsAccountsPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
void _navigateToAccountOption(BuildContext context, String option) {
|
||||||
|
switch (option) {
|
||||||
|
case 'Chose SIM card':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const ChooseSimPage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'SIM card parameters':
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => const SimParametersPage()),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final accountOptions = [
|
||||||
|
'Chose SIM card',
|
||||||
|
'SIM card parameters',
|
||||||
|
];
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Sim settings'),
|
||||||
|
),
|
||||||
|
body: ListView.builder(
|
||||||
|
itemCount: accountOptions.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text(
|
||||||
|
accountOptions[index],
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
trailing:
|
||||||
|
const Icon(Icons.arrow_forward_ios, color: Colors.white),
|
||||||
|
onTap: () {
|
||||||
|
_navigateToAccountOption(context, accountOptions[index]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
89
dialer/lib/features/settings/sim/sim_parameters.dart
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mobile_number/mobile_number.dart';
|
||||||
|
|
||||||
|
class SimParametersPage extends StatefulWidget {
|
||||||
|
const SimParametersPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_SimParametersPageState createState() => _SimParametersPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SimParametersPageState extends State<SimParametersPage> {
|
||||||
|
List<SimCard> _simCards = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_fetchSimParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _fetchSimParameters() async {
|
||||||
|
try {
|
||||||
|
bool permissionsGranted = await MobileNumber.hasPhonePermission;
|
||||||
|
if (!permissionsGranted) {
|
||||||
|
await MobileNumber.requestPhonePermission;
|
||||||
|
// Check again if permission is granted
|
||||||
|
permissionsGranted = await MobileNumber.hasPhonePermission;
|
||||||
|
}
|
||||||
|
if (permissionsGranted) {
|
||||||
|
List<SimCard>? simCards = await MobileNumber.getSimCards;
|
||||||
|
if (simCards != null && mounted) {
|
||||||
|
setState(() {
|
||||||
|
_simCards = simCards;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
print('No SIM cards found');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print('Phone permission denied');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to get SIM cards: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSimInfo(SimCard sim, int index) {
|
||||||
|
return Card(
|
||||||
|
color: Colors.grey[850],
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(
|
||||||
|
'SIM ${index + 1}',
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
'''
|
||||||
|
Carrier Name: ${sim.carrierName ?? 'N/A'}
|
||||||
|
Country Iso: ${sim.countryIso ?? 'N/A'}
|
||||||
|
Display Name: ${sim.displayName ?? 'N/A'}
|
||||||
|
Slot Index: ${sim.slotIndex ?? 'N/A'}
|
||||||
|
Number: ${sim.number ?? 'N/A'}
|
||||||
|
''',
|
||||||
|
style: const TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('SIM Parameters'),
|
||||||
|
),
|
||||||
|
body: _simCards.isEmpty
|
||||||
|
? const Center(
|
||||||
|
child: Text(
|
||||||
|
'No SIM cards found',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ListView.builder(
|
||||||
|
itemCount: _simCards.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return _buildSimInfo(_simCards[index], index);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,209 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:audioplayers/audioplayers.dart';
|
|
||||||
|
|
||||||
class VoicemailPage extends StatefulWidget {
|
|
||||||
const VoicemailPage({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<VoicemailPage> createState() => _VoicemailPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _VoicemailPageState extends State<VoicemailPage> {
|
|
||||||
bool _expanded = false;
|
|
||||||
bool _isPlaying = false;
|
|
||||||
Duration _duration = Duration.zero;
|
|
||||||
Duration _position = Duration.zero;
|
|
||||||
late AudioPlayer _audioPlayer;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_audioPlayer = AudioPlayer();
|
|
||||||
_audioPlayer.onDurationChanged.listen((Duration d) {
|
|
||||||
setState(() => _duration = d);
|
|
||||||
});
|
|
||||||
_audioPlayer.onPositionChanged.listen((Duration p) {
|
|
||||||
setState(() => _position = p);
|
|
||||||
});
|
|
||||||
_audioPlayer.onPlayerComplete.listen((event) {
|
|
||||||
setState(() {
|
|
||||||
_isPlaying = false;
|
|
||||||
_position = Duration.zero;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _togglePlayPause() async {
|
|
||||||
if (_isPlaying) {
|
|
||||||
await _audioPlayer.pause();
|
|
||||||
} else {
|
|
||||||
await _audioPlayer.play(UrlSource('voicemail.mp3'));
|
|
||||||
}
|
|
||||||
setState(() => _isPlaying = !_isPlaying);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_audioPlayer.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
// appBar: AppBar(
|
|
||||||
// // title: const Text('Voicemail'),
|
|
||||||
// backgroundColor: Colors.black,
|
|
||||||
// ),
|
|
||||||
body: ListView(
|
|
||||||
children: [
|
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
setState(() {
|
|
||||||
_expanded = !_expanded;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: AnimatedContainer(
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
margin: const EdgeInsets.all(12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: const Color.fromARGB(255, 30, 30, 30),
|
|
||||||
borderRadius: BorderRadius.circular(12.0),
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: _expanded
|
|
||||||
? Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
const CircleAvatar(
|
|
||||||
radius: 28,
|
|
||||||
backgroundColor: Colors.amber,
|
|
||||||
child: Text(
|
|
||||||
"JD",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.deepOrange,
|
|
||||||
fontSize: 28,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: const [
|
|
||||||
Text(
|
|
||||||
'John Doe',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Wed 3:00 PM - 1:20 min',
|
|
||||||
style: TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
_isPlaying ? Icons.pause : Icons.play_arrow,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
onPressed: _togglePlayPause,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 200,
|
|
||||||
child: Slider(
|
|
||||||
min: 0,
|
|
||||||
max: _duration.inSeconds.toDouble(),
|
|
||||||
value: _position.inSeconds.toDouble(),
|
|
||||||
onChanged: (value) async {
|
|
||||||
final newPos = Duration(seconds: value.toInt());
|
|
||||||
await _audioPlayer.seek(newPos);
|
|
||||||
},
|
|
||||||
activeColor: Colors.blue,
|
|
||||||
inactiveColor: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: const [
|
|
||||||
Icon(Icons.call, color: Colors.green),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Call', style: TextStyle(color: Colors.white)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Row(
|
|
||||||
children: const [
|
|
||||||
Icon(Icons.message, color: Colors.blue),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Text', style: TextStyle(color: Colors.white)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Row(
|
|
||||||
children: const [
|
|
||||||
Icon(Icons.block, color: Colors.red),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Block', style: TextStyle(color: Colors.white)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Row(
|
|
||||||
children: const [
|
|
||||||
Icon(Icons.share, color: Colors.white),
|
|
||||||
SizedBox(width: 8),
|
|
||||||
Text('Share', style: TextStyle(color: Colors.white)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Row(
|
|
||||||
children: [
|
|
||||||
const CircleAvatar(
|
|
||||||
radius: 28,
|
|
||||||
backgroundColor: Colors.amber,
|
|
||||||
child: Text(
|
|
||||||
"JD",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.deepOrange,
|
|
||||||
fontSize: 28,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: const [
|
|
||||||
Text(
|
|
||||||
'John Doe',
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'Wed 3:00 PM - 1:20 min',
|
|
||||||
style: TextStyle(color: Colors.grey),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
bool isStealthMode = false;
|
|
@ -1,65 +1,166 @@
|
|||||||
import 'package:dialer/features/home/home_page.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:dialer/features/contacts/contact_state.dart';
|
|
||||||
import 'package:dialer/services/call_service.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'globals.dart' as globals;
|
|
||||||
import 'package:dialer/services/cryptography/asymmetric_crypto_service.dart';
|
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
void main() async {
|
void main() {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
runApp(const IcingDialerApp());
|
||||||
const stealthFlag = String.fromEnvironment('STEALTH', defaultValue: 'false');
|
}
|
||||||
globals.isStealthMode = stealthFlag.toLowerCase() == 'true';
|
|
||||||
|
|
||||||
final AsymmetricCryptoService cryptoService = AsymmetricCryptoService();
|
class IcingDialerApp extends StatefulWidget {
|
||||||
await cryptoService.initializeDefaultKeyPair();
|
const IcingDialerApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
// Request permissions before running the app
|
@override
|
||||||
await _requestPermissions();
|
State<IcingDialerApp> createState() => _IcingDialerAppState();
|
||||||
|
}
|
||||||
|
|
||||||
CallService();
|
class _IcingDialerAppState extends State<IcingDialerApp> {
|
||||||
|
// This channel must match the one in MainActivity.kt.
|
||||||
|
static const platform = MethodChannel('com.example.dialer/call_events');
|
||||||
|
bool isDefaultDialer = false;
|
||||||
|
|
||||||
runApp(
|
@override
|
||||||
MultiProvider(
|
void initState() {
|
||||||
providers: [
|
super.initState();
|
||||||
Provider<AsymmetricCryptoService>(
|
// Listen for method calls from the Android side.
|
||||||
create: (_) => cryptoService,
|
platform.setMethodCallHandler(handleMethodCalls);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Future<void> handleMethodCalls(MethodCall call) async {
|
||||||
|
switch (call.method) {
|
||||||
|
case 'onDefaultDialerSet':
|
||||||
|
// Update our UI to show that we are now the default dialer.
|
||||||
|
setState(() {
|
||||||
|
isDefaultDialer = true;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'onDefaultDialerDenied':
|
||||||
|
// Show a message to the user when they deny the request.
|
||||||
|
_showDefaultDialerDeniedDialog();
|
||||||
|
break;
|
||||||
|
case 'onIncomingCall':
|
||||||
|
final phoneNumber = call.arguments as String? ?? "Unknown";
|
||||||
|
_showIncomingCallDialog(phoneNumber);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print("Unhandled method: ${call.method}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show a dialog when the user denies the default dialer request.
|
||||||
|
void _showDefaultDialerDeniedDialog() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Permission Denied'),
|
||||||
|
content: const Text(
|
||||||
|
'To use this app as your default dialer, please grant the permission when prompted.'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text('OK'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: Dialer(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _requestPermissions() async {
|
// Show a dialog when an incoming call is intercepted.
|
||||||
Map<Permission, PermissionStatus> statuses = await [
|
void _showIncomingCallDialog(String phoneNumber) {
|
||||||
Permission.phone,
|
showDialog(
|
||||||
Permission.contacts,
|
context: context,
|
||||||
Permission.microphone,
|
barrierDismissible: false,
|
||||||
].request();
|
builder: (_) => AlertDialog(
|
||||||
if (statuses.values.every((status) => status.isGranted)) {
|
title: const Text('Incoming Call'),
|
||||||
print("All required permissions granted");
|
content: Text('Call from: $phoneNumber'),
|
||||||
const channel = MethodChannel('call_service');
|
actions: [
|
||||||
await channel.invokeMethod('permissionsGranted');
|
TextButton(
|
||||||
} else {
|
onPressed: () {
|
||||||
print("Permissions denied: ${statuses.entries.where((e) => !e.value.isGranted).map((e) => e.key).join(', ')}");
|
// (Here you could add code to reject the call.)
|
||||||
}
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text('Reject'),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
// (Here you could add code to accept the call.)
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: const Text('Accept'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Dialer extends StatelessWidget {
|
// Invoke the native method to request to be the default dialer.
|
||||||
const Dialer({super.key});
|
Future<void> requestDefaultDialer() async {
|
||||||
|
try {
|
||||||
|
await platform.invokeMethod('requestDefaultDialer');
|
||||||
|
} catch (e) {
|
||||||
|
print('Error requesting default dialer: $e');
|
||||||
|
// Show an error message if the request fails.
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Error requesting default dialer: $e')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ContactState(
|
return MaterialApp(
|
||||||
child: MaterialApp(
|
title: 'Icing Dialer',
|
||||||
navigatorKey: CallService.navigatorKey,
|
theme: ThemeData.dark(),
|
||||||
theme: ThemeData(
|
home: isDefaultDialer
|
||||||
brightness: Brightness.dark,
|
? const CallScreen()
|
||||||
|
: DefaultDialerSetupScreen(onRequestDefaultDialer: requestDefaultDialer),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Shown when the app is not yet the default dialer.
|
||||||
|
class DefaultDialerSetupScreen extends StatelessWidget {
|
||||||
|
final VoidCallback onRequestDefaultDialer;
|
||||||
|
const DefaultDialerSetupScreen({Key? key, required this.onRequestDefaultDialer})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: const Text('Set as Default Dialer')),
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'This app is not set as your default dialer.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: onRequestDefaultDialer,
|
||||||
|
child: const Text('Set as Default Dialer'),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
home: SafeArea(child: MyHomePage()),
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Shown when the app is the default dialer.
|
||||||
|
class CallScreen extends StatelessWidget {
|
||||||
|
const CallScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// A simple UI indicating that the app is waiting for incoming calls.
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(title: const Text('Icing Dialer')),
|
||||||
|
body: const Center(
|
||||||
|
child: Text('Waiting for incoming calls...'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,207 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import '../features/call/call_page.dart';
|
|
||||||
import '../features/call/incoming_call_page.dart';
|
|
||||||
|
|
||||||
class CallService {
|
|
||||||
static const MethodChannel _channel = MethodChannel('call_service');
|
|
||||||
static String? currentPhoneNumber;
|
|
||||||
static bool _isCallPageVisible = false;
|
|
||||||
static Map<String, dynamic>? _pendingCall;
|
|
||||||
static bool wasPhoneLocked = false;
|
|
||||||
|
|
||||||
static final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
|
||||||
|
|
||||||
CallService() {
|
|
||||||
_channel.setMethodCallHandler((call) async {
|
|
||||||
print('CallService: Handling method call: ${call.method}');
|
|
||||||
switch (call.method) {
|
|
||||||
case "callAdded":
|
|
||||||
final phoneNumber = call.arguments["callId"] as String;
|
|
||||||
final state = call.arguments["state"] as String;
|
|
||||||
currentPhoneNumber = phoneNumber.replaceFirst('tel:', '');
|
|
||||||
print('CallService: Call added, number: $currentPhoneNumber, state: $state');
|
|
||||||
if (state == "ringing") {
|
|
||||||
_handleIncomingCall(phoneNumber);
|
|
||||||
} else {
|
|
||||||
_navigateToCallPage();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "callStateChanged":
|
|
||||||
final state = call.arguments["state"] as String;
|
|
||||||
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
|
||||||
print('CallService: State changed to $state, wasPhoneLocked: $wasPhoneLocked');
|
|
||||||
if (state == "disconnected" || state == "disconnecting") {
|
|
||||||
_closeCallPage();
|
|
||||||
if (wasPhoneLocked) {
|
|
||||||
_channel.invokeMethod("callEndedFromFlutter");
|
|
||||||
}
|
|
||||||
} else if (state == "active" || state == "dialing") {
|
|
||||||
_navigateToCallPage();
|
|
||||||
} else if (state == "ringing") {
|
|
||||||
final phoneNumber = call.arguments["callId"] as String;
|
|
||||||
_handleIncomingCall(phoneNumber.replaceFirst('tel:', ''));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "callEnded":
|
|
||||||
case "callRemoved":
|
|
||||||
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
|
||||||
print('CallService: Call ended/removed, wasPhoneLocked: $wasPhoneLocked');
|
|
||||||
_closeCallPage();
|
|
||||||
if (wasPhoneLocked) {
|
|
||||||
_channel.invokeMethod("callEndedFromFlutter");
|
|
||||||
}
|
|
||||||
currentPhoneNumber = null;
|
|
||||||
break;
|
|
||||||
case "incomingCallFromNotification":
|
|
||||||
final phoneNumber = call.arguments["phoneNumber"] as String;
|
|
||||||
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
|
||||||
currentPhoneNumber = phoneNumber;
|
|
||||||
print('CallService: Incoming call from notification: $phoneNumber, wasPhoneLocked: $wasPhoneLocked');
|
|
||||||
_handleIncomingCall(phoneNumber);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleIncomingCall(String phoneNumber) {
|
|
||||||
final context = navigatorKey.currentContext;
|
|
||||||
if (context == null) {
|
|
||||||
print('CallService: Context is null, queuing incoming call: $phoneNumber');
|
|
||||||
_pendingCall = {"phoneNumber": phoneNumber};
|
|
||||||
Future.delayed(Duration(milliseconds: 500), () => _checkPendingCall());
|
|
||||||
} else {
|
|
||||||
_navigateToIncomingCallPage(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _checkPendingCall() {
|
|
||||||
if (_pendingCall != null) {
|
|
||||||
final context = navigatorKey.currentContext;
|
|
||||||
if (context != null) {
|
|
||||||
print('CallService: Processing queued call: ${_pendingCall!["phoneNumber"]}');
|
|
||||||
currentPhoneNumber = _pendingCall!["phoneNumber"];
|
|
||||||
_navigateToIncomingCallPage(context);
|
|
||||||
_pendingCall = null;
|
|
||||||
} else {
|
|
||||||
print('CallService: Context still null, retrying...');
|
|
||||||
Future.delayed(Duration(milliseconds: 500), () => _checkPendingCall());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _navigateToCallPage() {
|
|
||||||
final context = navigatorKey.currentContext;
|
|
||||||
if (context == null) {
|
|
||||||
print('CallService: Cannot navigate to CallPage, context is null');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_isCallPageVisible) {
|
|
||||||
print('CallService: CallPage already visible, skipping navigation');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
print('CallService: Navigating to CallPage');
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
settings: const RouteSettings(name: '/call'),
|
|
||||||
builder: (context) => CallPage(
|
|
||||||
displayName: currentPhoneNumber!,
|
|
||||||
phoneNumber: currentPhoneNumber!,
|
|
||||||
thumbnail: null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
).then((_) {
|
|
||||||
_isCallPageVisible = false;
|
|
||||||
print('CallService: CallPage popped, _isCallPageVisible set to false');
|
|
||||||
});
|
|
||||||
_isCallPageVisible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _navigateToIncomingCallPage(BuildContext context) {
|
|
||||||
if (_isCallPageVisible) {
|
|
||||||
print('CallService: IncomingCallPage already visible, skipping navigation');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
print('CallService: Navigating to IncomingCallPage');
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
settings: const RouteSettings(name: '/incoming_call'),
|
|
||||||
builder: (context) => IncomingCallPage(
|
|
||||||
displayName: currentPhoneNumber!,
|
|
||||||
phoneNumber: currentPhoneNumber!,
|
|
||||||
thumbnail: null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
).then((_) {
|
|
||||||
_isCallPageVisible = false;
|
|
||||||
print('CallService: IncomingCallPage popped, _isCallPageVisible set to false');
|
|
||||||
});
|
|
||||||
_isCallPageVisible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _closeCallPage() {
|
|
||||||
final context = navigatorKey.currentContext;
|
|
||||||
if (context == null) {
|
|
||||||
print('CallService: Cannot close page, context is null');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
print('CallService: Closing call page, _isCallPageVisible: $_isCallPageVisible');
|
|
||||||
if (Navigator.canPop(context)) {
|
|
||||||
print('CallService: Popping call page');
|
|
||||||
Navigator.pop(context);
|
|
||||||
_isCallPageVisible = false;
|
|
||||||
} else {
|
|
||||||
print('CallService: No page to pop');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Map<String, dynamic>> makeGsmCall(
|
|
||||||
BuildContext context, {
|
|
||||||
required String phoneNumber,
|
|
||||||
String? displayName,
|
|
||||||
Uint8List? thumbnail,
|
|
||||||
}) async {
|
|
||||||
try {
|
|
||||||
currentPhoneNumber = phoneNumber;
|
|
||||||
print('CallService: Making GSM call to $phoneNumber');
|
|
||||||
final result = await _channel.invokeMethod('makeGsmCall', {"phoneNumber": phoneNumber});
|
|
||||||
print('CallService: makeGsmCall result: $result');
|
|
||||||
final resultMap = Map<String, dynamic>.from(result as Map);
|
|
||||||
if (resultMap["status"] != "calling") {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text("Failed to initiate call")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return resultMap;
|
|
||||||
} catch (e) {
|
|
||||||
print("CallService: Error making call: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text("Error making call: $e")),
|
|
||||||
);
|
|
||||||
return {"status": "error", "message": e.toString()};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<Map<String, dynamic>> hangUpCall(BuildContext context) async {
|
|
||||||
try {
|
|
||||||
print('CallService: Hanging up call');
|
|
||||||
final result = await _channel.invokeMethod('hangUpCall');
|
|
||||||
print('CallService: hangUpCall result: $result');
|
|
||||||
final resultMap = Map<String, dynamic>.from(result as Map);
|
|
||||||
if (resultMap["status"] != "ended") {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text("Failed to end call")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return resultMap;
|
|
||||||
} catch (e) {
|
|
||||||
print("CallService: Error hanging up call: $e");
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text("Error hanging up call: $e")),
|
|
||||||
);
|
|
||||||
return {"status": "error", "message": e.toString()};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
|
||||||
|
|
||||||
// Service to manage contact-related operations
|
|
||||||
class ContactService {
|
|
||||||
Future<List<Contact>> fetchContacts() async {
|
|
||||||
if (await FlutterContacts.requestPermission()) {
|
|
||||||
return await FlutterContacts.getContacts(
|
|
||||||
withProperties: true,
|
|
||||||
withThumbnail: true,
|
|
||||||
withAccounts: true,
|
|
||||||
withGroups: true,
|
|
||||||
withPhoto: true);
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Contact>> fetchFavoriteContacts() async {
|
|
||||||
List<Contact> contacts = await fetchContacts();
|
|
||||||
return contacts.where((contact) => contact.isStarred).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> addNewContact(Contact contact) async {
|
|
||||||
await FlutterContacts.insertContact(contact);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to show an AlertDialog with a QR code for the contact's vCard
|
|
||||||
void showContactQRCodeDialog(BuildContext context, Contact contact) {
|
|
||||||
showDialog(
|
|
||||||
barrierColor: Colors.white24,
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: true,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
content: SizedBox(
|
|
||||||
width: 200,
|
|
||||||
height: 220,
|
|
||||||
child: QrImageView(
|
|
||||||
data: contact.toVCard(), // Generate vCard QR code
|
|
||||||
version: QrVersions.auto,
|
|
||||||
backgroundColor: Colors.white, // Make sure QR code is visible on black background
|
|
||||||
size: 200.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,170 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
||||||
import 'package:uuid/uuid.dart';
|
|
||||||
|
|
||||||
class AsymmetricCryptoService {
|
|
||||||
static const MethodChannel _channel = MethodChannel('com.example.keystore');
|
|
||||||
final FlutterSecureStorage _secureStorage = FlutterSecureStorage();
|
|
||||||
final String _aliasPrefix = 'icing_';
|
|
||||||
final Uuid _uuid = Uuid();
|
|
||||||
|
|
||||||
/// Generates an ECDSA P-256 key pair with a unique alias and stores its metadata.
|
|
||||||
Future<String> generateKeyPair({String? label}) async {
|
|
||||||
try {
|
|
||||||
// Generate a unique identifier for the key
|
|
||||||
final String uuid = _uuid.v4();
|
|
||||||
final String alias = '$_aliasPrefix$uuid';
|
|
||||||
|
|
||||||
// Invoke native method to generate the key pair
|
|
||||||
await _channel.invokeMethod('generateKeyPair', {'alias': alias});
|
|
||||||
|
|
||||||
// Store key metadata securely
|
|
||||||
final Map<String, dynamic> keyMetadata = {
|
|
||||||
'alias': alias,
|
|
||||||
'label': label ?? 'Key $uuid',
|
|
||||||
'created_at': DateTime.now().toIso8601String(),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Retrieve existing keys
|
|
||||||
final String? existingKeys = await _secureStorage.read(key: 'keys');
|
|
||||||
List<dynamic> keysList = existingKeys != null ? jsonDecode(existingKeys) : [];
|
|
||||||
|
|
||||||
// Add the new key
|
|
||||||
keysList.add(keyMetadata);
|
|
||||||
|
|
||||||
// Save updated keys list
|
|
||||||
await _secureStorage.write(key: 'keys', value: jsonEncode(keysList));
|
|
||||||
|
|
||||||
return alias;
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
throw Exception("Failed to generate key pair: ${e.message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Signs data using the specified key alias.
|
|
||||||
Future<String> signData(String alias, String data) async {
|
|
||||||
try {
|
|
||||||
final String signature = await _channel.invokeMethod('signData', {
|
|
||||||
'alias': alias,
|
|
||||||
'data': data,
|
|
||||||
});
|
|
||||||
return signature;
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
throw Exception("Failed to sign data with alias '$alias': ${e.message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves the public key for the specified alias.
|
|
||||||
Future<String> getPublicKey(String alias) async {
|
|
||||||
try {
|
|
||||||
final String publicKey = await _channel.invokeMethod('getPublicKey', {
|
|
||||||
'alias': alias,
|
|
||||||
});
|
|
||||||
return publicKey;
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
throw Exception("Failed to retrieve public key: ${e.message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Deletes the key pair associated with the specified alias and removes its metadata.
|
|
||||||
Future<void> deleteKeyPair(String alias) async {
|
|
||||||
try {
|
|
||||||
await _channel.invokeMethod('deleteKeyPair', {'alias': alias});
|
|
||||||
|
|
||||||
final String? existingKeys = await _secureStorage.read(key: 'keys');
|
|
||||||
if (existingKeys != null) {
|
|
||||||
List<dynamic> keysList = jsonDecode(existingKeys);
|
|
||||||
keysList.removeWhere((key) => key['alias'] == alias);
|
|
||||||
await _secureStorage.write(key: 'keys', value: jsonEncode(keysList));
|
|
||||||
}
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
throw Exception("Failed to delete key pair: ${e.message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves all stored key metadata.
|
|
||||||
Future<List<Map<String, dynamic>>> getAllKeys() async {
|
|
||||||
try {
|
|
||||||
final String? existingKeys = await _secureStorage.read(key: 'keys');
|
|
||||||
if (existingKeys == null) {
|
|
||||||
print("No keys found");
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
List<dynamic> keysList = jsonDecode(existingKeys);
|
|
||||||
return keysList.cast<Map<String, dynamic>>();
|
|
||||||
} catch (e) {
|
|
||||||
throw Exception("Failed to retrieve keys: $e");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Checks if a key pair exists for the given alias.
|
|
||||||
Future<bool> keyPairExists(String alias) async {
|
|
||||||
try {
|
|
||||||
final bool exists = await _channel.invokeMethod('keyPairExists', {'alias': alias});
|
|
||||||
return exists;
|
|
||||||
} on PlatformException catch (e) {
|
|
||||||
throw Exception("Failed to check key pair existence: ${e.message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initializes the default key pair if it doesn't exist.
|
|
||||||
Future<void> initializeDefaultKeyPair() async {
|
|
||||||
const String defaultAlias = 'icing_default';
|
|
||||||
final List<Map<String, dynamic>> keys = await getAllKeys();
|
|
||||||
|
|
||||||
// Check if the key exists in metadata
|
|
||||||
final bool defaultKeyExists = keys.any((key) => key['alias'] == defaultAlias);
|
|
||||||
|
|
||||||
if (!defaultKeyExists) {
|
|
||||||
await _channel.invokeMethod('generateKeyPair', {'alias': defaultAlias});
|
|
||||||
|
|
||||||
final Map<String, dynamic> keyMetadata = {
|
|
||||||
'alias': defaultAlias,
|
|
||||||
'label': 'Default Key',
|
|
||||||
'created_at': DateTime.now().toIso8601String(),
|
|
||||||
};
|
|
||||||
|
|
||||||
keys.add(keyMetadata);
|
|
||||||
await _secureStorage.write(key: 'keys', value: jsonEncode(keys));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Updates the label of a key with the specified alias.
|
|
||||||
///
|
|
||||||
/// [alias]: The unique alias of the key to update.
|
|
||||||
/// [newLabel]: The new label to assign to the key.
|
|
||||||
///
|
|
||||||
/// Throws an exception if the key is not found or the update fails.
|
|
||||||
Future<void> updateKeyLabel(String alias, String newLabel) async {
|
|
||||||
try {
|
|
||||||
// Retrieve existing keys
|
|
||||||
final String? existingKeys = await _secureStorage.read(key: 'keys');
|
|
||||||
if (existingKeys == null) {
|
|
||||||
throw Exception("No keys found to update.");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<dynamic> keysList = jsonDecode(existingKeys);
|
|
||||||
|
|
||||||
// Find the key with the specified alias
|
|
||||||
bool keyFound = false;
|
|
||||||
for (var key in keysList) {
|
|
||||||
if (key['alias'] == alias) {
|
|
||||||
key['label'] = newLabel;
|
|
||||||
keyFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!keyFound) {
|
|
||||||
throw Exception("Key with alias \"$alias\" not found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the updated keys list
|
|
||||||
await _secureStorage.write(key: 'keys', value: jsonEncode(keysList));
|
|
||||||
} catch (e) {
|
|
||||||
throw Exception("Failed to update key label: $e");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
// lib/services/obfuscate_service.dart
|
|
||||||
import 'package:dialer/widgets/color_darkener.dart';
|
|
||||||
|
|
||||||
import '../../globals.dart' as globals;
|
|
||||||
import 'dart:ui';
|
|
||||||
import 'dart:typed_data';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class ObfuscateService {
|
|
||||||
// Private constructor
|
|
||||||
ObfuscateService._privateConstructor();
|
|
||||||
|
|
||||||
// Singleton instance
|
|
||||||
static final ObfuscateService _instance = ObfuscateService._privateConstructor();
|
|
||||||
|
|
||||||
// Factory constructor to return the same instance
|
|
||||||
factory ObfuscateService() {
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Public method to obfuscate data
|
|
||||||
String obfuscateData(String data) {
|
|
||||||
if (globals.isStealthMode) {
|
|
||||||
return _obfuscateData(data);
|
|
||||||
} else {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private helper method for obfuscation logic
|
|
||||||
String _obfuscateData(String data) {
|
|
||||||
if (data.isNotEmpty) {
|
|
||||||
// Ensure the string has at least two characters to obfuscate
|
|
||||||
if (data.length == 1) {
|
|
||||||
return '${data[0]}';
|
|
||||||
} else {
|
|
||||||
return '${data[0]}...${data[data.length - 1]}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class ObfuscatedAvatar extends StatelessWidget {
|
|
||||||
final Uint8List? imageBytes;
|
|
||||||
final double radius;
|
|
||||||
final Color backgroundColor;
|
|
||||||
final String? fallbackInitial;
|
|
||||||
|
|
||||||
const ObfuscatedAvatar({
|
|
||||||
Key? key,
|
|
||||||
required this.imageBytes,
|
|
||||||
this.radius = 25,
|
|
||||||
this.backgroundColor = Colors.grey,
|
|
||||||
this.fallbackInitial,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
if (imageBytes != null && imageBytes!.isNotEmpty) {
|
|
||||||
return ClipOval(
|
|
||||||
child: ImageFiltered(
|
|
||||||
imageFilter: globals.isStealthMode
|
|
||||||
? ImageFilter.blur(sigmaX: 10, sigmaY: 10)
|
|
||||||
: ImageFilter.blur(sigmaX: 0, sigmaY: 0),
|
|
||||||
child: Image.memory(
|
|
||||||
imageBytes!,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
width: radius * 2,
|
|
||||||
height: radius * 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return CircleAvatar(
|
|
||||||
radius: radius,
|
|
||||||
backgroundColor: backgroundColor,
|
|
||||||
child: Text(
|
|
||||||
fallbackInitial != null && fallbackInitial!.isNotEmpty
|
|
||||||
? fallbackInitial![0].toUpperCase()
|
|
||||||
: '?',
|
|
||||||
style: TextStyle(
|
|
||||||
color: darken(backgroundColor),
|
|
||||||
fontSize: radius,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
31
dialer/lib/widgets/contact_service.dart
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
|
|
||||||
|
// Service to manage contact-related operations
|
||||||
|
class ContactService {
|
||||||
|
Future<List<Contact>> fetchContacts() async {
|
||||||
|
if (await FlutterContacts.requestPermission()) {
|
||||||
|
return await FlutterContacts.getContacts(
|
||||||
|
withProperties: true,
|
||||||
|
withThumbnail: true,
|
||||||
|
withAccounts: true,
|
||||||
|
withGroups: true,
|
||||||
|
withPhoto: true);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Contact>> fetchFavoriteContacts() async {
|
||||||
|
// Fetch all contacts
|
||||||
|
List<Contact> contacts = await fetchContacts();
|
||||||
|
|
||||||
|
// Filter contacts to only include those with isStarred: true
|
||||||
|
List<Contact> favoriteContacts =
|
||||||
|
contacts.where((contact) => contact.isStarred).toList();
|
||||||
|
|
||||||
|
return favoriteContacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> addNewContact(Contact contact) async {
|
||||||
|
await FlutterContacts.insertContact(contact);
|
||||||
|
}
|
||||||
|
}
|
59
dialer/packages/mobile_number/CHANGELOG.md
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
## 2.1.1
|
||||||
|
|
||||||
|
* Fix Android building
|
||||||
|
|
||||||
|
## 2.1.0
|
||||||
|
|
||||||
|
* Make min sdk to Flutter 3.0.0
|
||||||
|
|
||||||
|
## 2.0.0
|
||||||
|
|
||||||
|
* Remove null check operator from method ListenPhone
|
||||||
|
|
||||||
|
## 1.0.4
|
||||||
|
|
||||||
|
* Null safety support
|
||||||
|
|
||||||
|
## 1.0.3
|
||||||
|
|
||||||
|
* Fix crash because of null value on empty number
|
||||||
|
|
||||||
|
## 1.0.2
|
||||||
|
|
||||||
|
* Support old Flutter plugin V1
|
||||||
|
|
||||||
|
## 1.0.1
|
||||||
|
|
||||||
|
* Fix crash related to Android 10
|
||||||
|
|
||||||
|
## 1.0.0
|
||||||
|
|
||||||
|
* Addded has phone permission
|
||||||
|
* Added request phone permission
|
||||||
|
* Added phone permission listener
|
||||||
|
* Fix bugs
|
||||||
|
|
||||||
|
## 0.0.6
|
||||||
|
|
||||||
|
* Add sample image.
|
||||||
|
|
||||||
|
## 0.0.5
|
||||||
|
|
||||||
|
* Add support for dual sim card.
|
||||||
|
|
||||||
|
## 0.0.4
|
||||||
|
|
||||||
|
* Print exception message on debugging console.
|
||||||
|
|
||||||
|
## 0.0.3
|
||||||
|
|
||||||
|
* Migrate to AndroidX
|
||||||
|
|
||||||
|
## 0.0.2
|
||||||
|
|
||||||
|
* Add gt mobile number native code to Android
|
||||||
|
|
||||||
|
|
||||||
|
## 0.0.1
|
||||||
|
|
||||||
|
* Initial Release.
|
13
dialer/packages/mobile_number/LICENSE
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Copyright 2023 Amr Eniou
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
http://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.
|
66
dialer/packages/mobile_number/README.md
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# mobile_number
|
||||||
|
|
||||||
|
This is a FLutter Plugin to get the device mobile number.
|
||||||
|
#### Note: It works for Android only because getting mobile number of sim card is not supported in iOS.
|
||||||
|
#### Note: If the mobile number is not pre-exist on sim card it will not return te phone number.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
#### Link on Flutter plugins
|
||||||
|
https://pub.dev/packages/mobile_number
|
||||||
|
|
||||||
|
#### Note:
|
||||||
|
if you still using depecated FlutterActivty on MainActivity.java
|
||||||
|
which is import of
|
||||||
|
- `import io.flutter.app.FlutterActivity;`
|
||||||
|
|
||||||
|
not
|
||||||
|
- `import io.flutter.embedding.android.FlutterActivity;`
|
||||||
|
|
||||||
|
then you need to add the following to your MainActivity.java
|
||||||
|
```
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
MobileNumberPlugin.registerWith(registrarFor("com.amorenew.mobile_number.MobileNumberPlugin()"));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
#### Check Phone Permission
|
||||||
|
|
||||||
|
```await MobileNumber.hasPhonePermission```
|
||||||
|
|
||||||
|
#### Request Phone Permission
|
||||||
|
|
||||||
|
```await MobileNumber.requestPhonePermission```
|
||||||
|
|
||||||
|
#### Listen to widget resume after Phone Permission request
|
||||||
|
|
||||||
|
```MobileNumber.listenPhonePermission((isPermissionGranted) {
|
||||||
|
if (isPermissionGranted) {
|
||||||
|
//Get mobile number
|
||||||
|
} else {
|
||||||
|
//Request Phone Permission
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Get first sim card number
|
||||||
|
|
||||||
|
```Future<String> getMobileNumber() async {
|
||||||
|
final String mobileNumber = await MobileNumber.mobileNumber;
|
||||||
|
return mobileNumber;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Get List of sim cards for dual sim cards
|
||||||
|
|
||||||
|
```Future<List<SimCard>> geSimCards() async {
|
||||||
|
final List<SimCard> simCards = await MobileNumber.getSimCards;
|
||||||
|
return simCards;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|

|
41
dialer/packages/mobile_number/android/build.gradle
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
group 'com.amorenew.mobile_number'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:7.2.2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 33
|
||||||
|
namespace "com.amorenew.mobile_number"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
targetSdkVersion 33
|
||||||
|
minSdkVersion 21
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
lintOptions {
|
||||||
|
disable 'InvalidPackage'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation 'androidx.core:core:1.9.0'
|
||||||
|
// Other dependencies...
|
||||||
|
}
|
3
dialer/packages/mobile_number/android/gradle.properties
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
android.enableR8=true
|
||||||
|
android.useAndroidX=true
|
5
dialer/packages/mobile_number/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
@ -0,0 +1 @@
|
|||||||
|
{}
|
1
dialer/packages/mobile_number/android/settings.gradle
Normal file
@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'mobile_number'
|
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.amorenew.mobile_number"> <!-- Package is "com.amorenew.mobile_number" -->
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE"
|
||||||
|
android:maxSdkVersion="29" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
|
||||||
|
<meta-data
|
||||||
|
android:name="flutterEmbedding"
|
||||||
|
android:value="2" />
|
||||||
|
</manifest>
|
@ -0,0 +1,262 @@
|
|||||||
|
package com.amorenew.mobile_number;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
class CountryToPhonePrefix {
|
||||||
|
|
||||||
|
private static Map<String, String> map = new HashMap<>();
|
||||||
|
|
||||||
|
static String prefixFor(String iso2CountryCode) {
|
||||||
|
String result = map.get(iso2CountryCode.toUpperCase());
|
||||||
|
if (result == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
map.put("AC", "247");
|
||||||
|
map.put("AD", "376");
|
||||||
|
map.put("AE", "971");
|
||||||
|
map.put("AF", "93");
|
||||||
|
map.put("AG", "1268");
|
||||||
|
map.put("AI", "1264");
|
||||||
|
map.put("AL", "355");
|
||||||
|
map.put("AM", "374");
|
||||||
|
map.put("AN", "599");
|
||||||
|
map.put("AO", "244");
|
||||||
|
map.put("AR", "54");
|
||||||
|
map.put("AS", "1684");
|
||||||
|
map.put("AT", "43");
|
||||||
|
map.put("AU", "61");
|
||||||
|
map.put("AW", "297");
|
||||||
|
map.put("AX", "35818");
|
||||||
|
// map.put("AZ", "37497");
|
||||||
|
map.put("AZ", "994");
|
||||||
|
map.put("BA", "387");
|
||||||
|
map.put("BB", "1246");
|
||||||
|
map.put("BD", "880");
|
||||||
|
map.put("BE", "32");
|
||||||
|
map.put("BF", "226");
|
||||||
|
map.put("BG", "359");
|
||||||
|
map.put("BH", "973");
|
||||||
|
map.put("BI", "257");
|
||||||
|
map.put("BJ", "229");
|
||||||
|
map.put("BM", "1441");
|
||||||
|
map.put("BN", "673");
|
||||||
|
map.put("BO", "591");
|
||||||
|
map.put("BR", "55");
|
||||||
|
map.put("BS", "1242");
|
||||||
|
map.put("BT", "975");
|
||||||
|
map.put("BW", "267");
|
||||||
|
map.put("BY", "375");
|
||||||
|
map.put("BZ", "501");
|
||||||
|
map.put("CA", "1");
|
||||||
|
map.put("CC", "61");
|
||||||
|
map.put("CD", "243");
|
||||||
|
map.put("CF", "236");
|
||||||
|
map.put("CG", "242");
|
||||||
|
map.put("CH", "41");
|
||||||
|
map.put("CI", "225");
|
||||||
|
map.put("CK", "682");
|
||||||
|
map.put("CL", "56");
|
||||||
|
map.put("CM", "237");
|
||||||
|
map.put("CN", "86");
|
||||||
|
map.put("CO", "57");
|
||||||
|
map.put("CR", "506");
|
||||||
|
map.put("CS", "381");
|
||||||
|
map.put("CU", "53");
|
||||||
|
map.put("CV", "238");
|
||||||
|
map.put("CX", "61");
|
||||||
|
// map.put("CY", "90392");
|
||||||
|
map.put("CY", "357");
|
||||||
|
map.put("CZ", "420");
|
||||||
|
map.put("DE", "49");
|
||||||
|
map.put("DJ", "253");
|
||||||
|
map.put("DK", "45");
|
||||||
|
map.put("DM", "1767");
|
||||||
|
map.put("DO", "1809"); // and 1829?
|
||||||
|
map.put("DZ", "213");
|
||||||
|
map.put("EC", "593");
|
||||||
|
map.put("EE", "372");
|
||||||
|
map.put("EG", "20");
|
||||||
|
map.put("EH", "212");
|
||||||
|
map.put("ER", "291");
|
||||||
|
map.put("ES", "34");
|
||||||
|
map.put("ET", "251");
|
||||||
|
map.put("FI", "358");
|
||||||
|
map.put("FJ", "679");
|
||||||
|
map.put("FK", "500");
|
||||||
|
map.put("FM", "691");
|
||||||
|
map.put("FO", "298");
|
||||||
|
map.put("FR", "33");
|
||||||
|
map.put("GA", "241");
|
||||||
|
map.put("GB", "44");
|
||||||
|
map.put("GD", "1473");
|
||||||
|
map.put("GE", "995");
|
||||||
|
map.put("GF", "594");
|
||||||
|
map.put("GG", "44");
|
||||||
|
map.put("GH", "233");
|
||||||
|
map.put("GI", "350");
|
||||||
|
map.put("GL", "299");
|
||||||
|
map.put("GM", "220");
|
||||||
|
map.put("GN", "224");
|
||||||
|
map.put("GP", "590");
|
||||||
|
map.put("GQ", "240");
|
||||||
|
map.put("GR", "30");
|
||||||
|
map.put("GT", "502");
|
||||||
|
map.put("GU", "1671");
|
||||||
|
map.put("GW", "245");
|
||||||
|
map.put("GY", "592");
|
||||||
|
map.put("HK", "852");
|
||||||
|
map.put("HN", "504");
|
||||||
|
map.put("HR", "385");
|
||||||
|
map.put("HT", "509");
|
||||||
|
map.put("HU", "36");
|
||||||
|
map.put("ID", "62");
|
||||||
|
map.put("IE", "353");
|
||||||
|
map.put("IL", "972");
|
||||||
|
map.put("IM", "44");
|
||||||
|
map.put("IN", "91");
|
||||||
|
map.put("IO", "246");
|
||||||
|
map.put("IQ", "964");
|
||||||
|
map.put("IR", "98");
|
||||||
|
map.put("IS", "354");
|
||||||
|
map.put("IT", "39");
|
||||||
|
map.put("JE", "44");
|
||||||
|
map.put("JM", "1876");
|
||||||
|
map.put("JO", "962");
|
||||||
|
map.put("JP", "81");
|
||||||
|
map.put("KE", "254");
|
||||||
|
map.put("KG", "996");
|
||||||
|
map.put("KH", "855");
|
||||||
|
map.put("KI", "686");
|
||||||
|
map.put("KM", "269");
|
||||||
|
map.put("KN", "1869");
|
||||||
|
map.put("KP", "850");
|
||||||
|
map.put("KR", "82");
|
||||||
|
map.put("KW", "965");
|
||||||
|
map.put("KY", "1345");
|
||||||
|
map.put("KZ", "7");
|
||||||
|
map.put("LA", "856");
|
||||||
|
map.put("LB", "961");
|
||||||
|
map.put("LC", "1758");
|
||||||
|
map.put("LI", "423");
|
||||||
|
map.put("LK", "94");
|
||||||
|
map.put("LR", "231");
|
||||||
|
map.put("LS", "266");
|
||||||
|
map.put("LT", "370");
|
||||||
|
map.put("LU", "352");
|
||||||
|
map.put("LV", "371");
|
||||||
|
map.put("LY", "218");
|
||||||
|
map.put("MA", "212");
|
||||||
|
map.put("MC", "377");
|
||||||
|
// map.put("MD", "373533");
|
||||||
|
map.put("MD", "373");
|
||||||
|
map.put("ME", "382");
|
||||||
|
map.put("MG", "261");
|
||||||
|
map.put("MH", "692");
|
||||||
|
map.put("MK", "389");
|
||||||
|
map.put("ML", "223");
|
||||||
|
map.put("MM", "95");
|
||||||
|
map.put("MN", "976");
|
||||||
|
map.put("MO", "853");
|
||||||
|
map.put("MP", "1670");
|
||||||
|
map.put("MQ", "596");
|
||||||
|
map.put("MR", "222");
|
||||||
|
map.put("MS", "1664");
|
||||||
|
map.put("MT", "356");
|
||||||
|
map.put("MU", "230");
|
||||||
|
map.put("MV", "960");
|
||||||
|
map.put("MW", "265");
|
||||||
|
map.put("MX", "52");
|
||||||
|
map.put("MY", "60");
|
||||||
|
map.put("MZ", "258");
|
||||||
|
map.put("NA", "264");
|
||||||
|
map.put("NC", "687");
|
||||||
|
map.put("NE", "227");
|
||||||
|
map.put("NF", "672");
|
||||||
|
map.put("NG", "234");
|
||||||
|
map.put("NI", "505");
|
||||||
|
map.put("NL", "31");
|
||||||
|
map.put("NO", "47");
|
||||||
|
map.put("NP", "977");
|
||||||
|
map.put("NR", "674");
|
||||||
|
map.put("NU", "683");
|
||||||
|
map.put("NZ", "64");
|
||||||
|
map.put("OM", "968");
|
||||||
|
map.put("PA", "507");
|
||||||
|
map.put("PE", "51");
|
||||||
|
map.put("PF", "689");
|
||||||
|
map.put("PG", "675");
|
||||||
|
map.put("PH", "63");
|
||||||
|
map.put("PK", "92");
|
||||||
|
map.put("PL", "48");
|
||||||
|
map.put("PM", "508");
|
||||||
|
map.put("PR", "1787"); // and 1939 ?
|
||||||
|
map.put("PS", "970");
|
||||||
|
map.put("PT", "351");
|
||||||
|
map.put("PW", "680");
|
||||||
|
map.put("PY", "595");
|
||||||
|
map.put("QA", "974");
|
||||||
|
map.put("RE", "262");
|
||||||
|
map.put("RO", "40");
|
||||||
|
map.put("RS", "381");
|
||||||
|
map.put("RU", "7");
|
||||||
|
map.put("RW", "250");
|
||||||
|
map.put("SA", "966");
|
||||||
|
map.put("SB", "677");
|
||||||
|
map.put("SC", "248");
|
||||||
|
map.put("SD", "249");
|
||||||
|
map.put("SE", "46");
|
||||||
|
map.put("SG", "65");
|
||||||
|
map.put("SH", "290");
|
||||||
|
map.put("SI", "386");
|
||||||
|
map.put("SJ", "47");
|
||||||
|
map.put("SK", "421");
|
||||||
|
map.put("SL", "232");
|
||||||
|
map.put("SM", "378");
|
||||||
|
map.put("SN", "221");
|
||||||
|
map.put("SO", "252");
|
||||||
|
map.put("SR", "597");
|
||||||
|
map.put("ST", "239");
|
||||||
|
map.put("SV", "503");
|
||||||
|
map.put("SY", "963");
|
||||||
|
map.put("SZ", "268");
|
||||||
|
map.put("TA", "290");
|
||||||
|
map.put("TC", "1649");
|
||||||
|
map.put("TD", "235");
|
||||||
|
map.put("TG", "228");
|
||||||
|
map.put("TH", "66");
|
||||||
|
map.put("TJ", "992");
|
||||||
|
map.put("TK", "690");
|
||||||
|
map.put("TL", "670");
|
||||||
|
map.put("TM", "993");
|
||||||
|
map.put("TN", "216");
|
||||||
|
map.put("TO", "676");
|
||||||
|
map.put("TR", "90");
|
||||||
|
map.put("TT", "1868");
|
||||||
|
map.put("TV", "688");
|
||||||
|
map.put("TW", "886");
|
||||||
|
map.put("TZ", "255");
|
||||||
|
map.put("UA", "380");
|
||||||
|
map.put("UG", "256");
|
||||||
|
map.put("US", "1");
|
||||||
|
map.put("UY", "598");
|
||||||
|
map.put("UZ", "998");
|
||||||
|
map.put("VA", "379");
|
||||||
|
map.put("VC", "1784");
|
||||||
|
map.put("VE", "58");
|
||||||
|
map.put("VG", "1284");
|
||||||
|
map.put("VI", "1340");
|
||||||
|
map.put("VN", "84");
|
||||||
|
map.put("VU", "678");
|
||||||
|
map.put("WF", "681");
|
||||||
|
map.put("WS", "685");
|
||||||
|
map.put("YE", "967");
|
||||||
|
map.put("YT", "262");
|
||||||
|
map.put("ZA", "27");
|
||||||
|
map.put("ZM", "260");
|
||||||
|
map.put("ZW", "263");
|
||||||
|
}}
|
@ -0,0 +1,248 @@
|
|||||||
|
package com.amorenew.mobile_number;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.telephony.SubscriptionInfo;
|
||||||
|
import android.telephony.SubscriptionManager;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.flutter.embedding.engine.plugins.FlutterPlugin;
|
||||||
|
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
|
||||||
|
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
|
||||||
|
import io.flutter.plugin.common.BinaryMessenger;
|
||||||
|
import io.flutter.plugin.common.EventChannel;
|
||||||
|
import io.flutter.plugin.common.MethodCall;
|
||||||
|
import io.flutter.plugin.common.MethodChannel;
|
||||||
|
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||||
|
import io.flutter.plugin.common.MethodChannel.Result;
|
||||||
|
import io.flutter.plugin.common.PluginRegistry.Registrar;
|
||||||
|
import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MobileNumberPlugin
|
||||||
|
*/
|
||||||
|
public class MobileNumberPlugin implements FlutterPlugin, ActivityAware, MethodCallHandler, RequestPermissionsResultListener {
|
||||||
|
private static final int MY_PERMISSIONS_REQUEST_READ_PHONE_STATE = 0;
|
||||||
|
final String Event_phonePermissionResult = "requestPhonePermission=";
|
||||||
|
private EventChannel.EventSink permissionEvent;
|
||||||
|
private Context applicationContext;
|
||||||
|
private Activity activity;
|
||||||
|
private TelephonyManager telephonyManager;
|
||||||
|
private Result result;
|
||||||
|
private MethodChannel methodChannel;
|
||||||
|
private EventChannel permissionEventChannel;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin registration.
|
||||||
|
*/
|
||||||
|
public static void registerWith(Registrar registrar) {
|
||||||
|
final MobileNumberPlugin instance = new MobileNumberPlugin();
|
||||||
|
instance.onAttachedToEngine(registrar.context(), registrar.messenger(), registrar.activity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
|
||||||
|
onAttachedToEngine(flutterPluginBinding.getApplicationContext(), flutterPluginBinding.getBinaryMessenger(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onAttachedToEngine(Context applicationContext, BinaryMessenger messenger, Activity _activity) {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
if(_activity!=null)
|
||||||
|
this.activity=_activity;
|
||||||
|
methodChannel = new MethodChannel(messenger, "mobile_number");
|
||||||
|
methodChannel.setMethodCallHandler(this);
|
||||||
|
permissionEventChannel = new EventChannel(messenger, "phone_permission_event");
|
||||||
|
permissionEventChannel.setStreamHandler(new EventChannel.StreamHandler() {
|
||||||
|
@Override
|
||||||
|
public void onListen(Object o, EventChannel.EventSink eventSink) {
|
||||||
|
permissionEvent = eventSink;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancel(Object o) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetachedFromEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) {
|
||||||
|
//MobileNumberPlugin.activity = activityPluginBinding.getActivity();
|
||||||
|
//activityV2 = activityPluginBinding.getActivity();
|
||||||
|
activity = activityPluginBinding.getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetachedFromActivityForConfigChanges() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding activityPluginBinding) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetachedFromActivity() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMethodCall(MethodCall call, Result result) {
|
||||||
|
this.result = result;
|
||||||
|
final String method_GetMobileNumber = "getMobileNumber";
|
||||||
|
final String method_hasPhonePermission = "hasPhonePermission";
|
||||||
|
final String method_requestPhonePermission = "requestPhonePermission";
|
||||||
|
switch (call.method) {
|
||||||
|
case method_GetMobileNumber:
|
||||||
|
telephonyManager = (TelephonyManager) applicationContext
|
||||||
|
.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
getMobileNumber();
|
||||||
|
break;
|
||||||
|
case method_hasPhonePermission:
|
||||||
|
result.success(hasPhonePermission());
|
||||||
|
break;
|
||||||
|
case method_requestPhonePermission:
|
||||||
|
requestPhonePermission();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result.notImplemented();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasPhonePermission() {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
|
||||||
|
return ContextCompat.checkSelfPermission(applicationContext,
|
||||||
|
Manifest.permission.READ_PHONE_NUMBERS) == PackageManager.PERMISSION_GRANTED;
|
||||||
|
} else {
|
||||||
|
return ContextCompat.checkSelfPermission(applicationContext,
|
||||||
|
Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestPhonePermission() {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
|
||||||
|
if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
|
||||||
|
Manifest.permission.READ_PHONE_NUMBERS)) {
|
||||||
|
// Show an explanation to the user *asynchronously* -- don't block
|
||||||
|
// this thread waiting for the user's response! After the user
|
||||||
|
// sees the explanation, try again to request the permission.
|
||||||
|
} else {
|
||||||
|
ActivityCompat.requestPermissions(activity,
|
||||||
|
new String[]{Manifest.permission.READ_PHONE_NUMBERS}, MY_PERMISSIONS_REQUEST_READ_PHONE_STATE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
|
||||||
|
Manifest.permission.READ_PHONE_STATE)) {
|
||||||
|
} else {
|
||||||
|
ActivityCompat.requestPermissions(activity,
|
||||||
|
new String[]{Manifest.permission.READ_PHONE_STATE}, MY_PERMISSIONS_REQUEST_READ_PHONE_STATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getMobileNumber() {
|
||||||
|
if (!hasPhonePermission()) {
|
||||||
|
requestPhonePermission();
|
||||||
|
} else {
|
||||||
|
// Permission has already been granted
|
||||||
|
generateMobileNumber();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("HardwareIds")
|
||||||
|
private void generateMobileNumber() {
|
||||||
|
JSONArray simJsonArray = new JSONArray();
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
|
for (SubscriptionInfo subscriptionInfo : getSubscriptions()) {
|
||||||
|
SimCard simCard = new SimCard(telephonyManager, subscriptionInfo);
|
||||||
|
simJsonArray.put(simCard.toJSON());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (simJsonArray.length()==0) {
|
||||||
|
SimCard simCard = getSingleSimCard();
|
||||||
|
if (simCard != null) {
|
||||||
|
simJsonArray.put(simCard.toJSON());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simJsonArray.toString().isEmpty()) {
|
||||||
|
Log.d("UNAVAILABLE", "No phone number on sim card#3");
|
||||||
|
result.error("UNAVAILABLE", "No phone number on sim card", null);
|
||||||
|
} else result.success(simJsonArray.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("HardwareIds")
|
||||||
|
SimCard getSingleSimCard() {
|
||||||
|
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_PHONE_NUMBERS) == PackageManager.PERMISSION_DENIED
|
||||||
|
&& ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_DENIED) {
|
||||||
|
Log.e("UNAVAILABLE", "No phone number on sim card Permission Denied#2", null);
|
||||||
|
return null;
|
||||||
|
} else if (telephonyManager.getLine1Number() == null || telephonyManager.getLine1Number().isEmpty()) {
|
||||||
|
Log.e("UNAVAILABLE", "No phone number on sim card#2", null);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new SimCard(telephonyManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
|
||||||
|
List<SubscriptionInfo> getSubscriptions() {
|
||||||
|
final SubscriptionManager subscriptionManager = (SubscriptionManager) activity.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
||||||
|
|
||||||
|
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_PHONE_NUMBERS) == PackageManager.PERMISSION_DENIED
|
||||||
|
&& ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_DENIED) {
|
||||||
|
Log.e("UNAVAILABLE", "No phone number on sim card Permission Denied#1", null);
|
||||||
|
return new ArrayList<>();
|
||||||
|
} else if (subscriptionManager == null) {
|
||||||
|
Log.e("UNAVAILABLE", "No phone number on sim card#1", null);
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return subscriptionManager.getActiveSubscriptionInfoList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||||
|
@NonNull int[] grantResults) {
|
||||||
|
// If request is cancelled, the result arrays are empty.
|
||||||
|
if (requestCode == MY_PERMISSIONS_REQUEST_READ_PHONE_STATE) {
|
||||||
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
if (permissionEvent != null)
|
||||||
|
permissionEvent.success(true);
|
||||||
|
generateMobileNumber();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (permissionEvent != null)
|
||||||
|
permissionEvent.success(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.error("PERMISSION", "onRequestPermissionsResult is not granted", null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package com.amorenew.mobile_number;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.telephony.SubscriptionInfo;
|
||||||
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public class SimCard {
|
||||||
|
|
||||||
|
private String carrierName = "";
|
||||||
|
private String displayName = "";
|
||||||
|
private int slotIndex = 0;
|
||||||
|
private String number = "";
|
||||||
|
private String countryIso = "";
|
||||||
|
private String countryPhonePrefix = "";
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
|
||||||
|
public SimCard(TelephonyManager telephonyManager, SubscriptionInfo subscriptionInfo) {
|
||||||
|
this.carrierName = subscriptionInfo.getCarrierName().toString();
|
||||||
|
this.displayName = subscriptionInfo.getDisplayName().toString();
|
||||||
|
this.slotIndex = subscriptionInfo.getSimSlotIndex();
|
||||||
|
this.number = subscriptionInfo.getNumber();
|
||||||
|
if (subscriptionInfo.getCountryIso() != null && !subscriptionInfo.getCountryIso().isEmpty())
|
||||||
|
this.countryIso = subscriptionInfo.getCountryIso();
|
||||||
|
else if (telephonyManager.getSimCountryIso() != null)
|
||||||
|
this.countryIso = telephonyManager.getSimCountryIso();
|
||||||
|
this.countryPhonePrefix = CountryToPhonePrefix.prefixFor(this.countryIso);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint({"MissingPermission", "HardwareIds"})
|
||||||
|
public SimCard(TelephonyManager telephonyManager) {
|
||||||
|
if (telephonyManager.getSimOperator() != null)
|
||||||
|
carrierName = telephonyManager.getSimOperatorName();
|
||||||
|
if (telephonyManager.getSimOperator() != null)
|
||||||
|
displayName = telephonyManager.getSimOperatorName();
|
||||||
|
if (telephonyManager.getSimCountryIso() != null) {
|
||||||
|
countryIso = telephonyManager.getSimCountryIso();
|
||||||
|
countryPhonePrefix = CountryToPhonePrefix.prefixFor(countryIso);
|
||||||
|
}
|
||||||
|
if (telephonyManager.getLine1Number() != null && !telephonyManager.getLine1Number().isEmpty()) {
|
||||||
|
if (telephonyManager.getLine1Number().startsWith("0"))
|
||||||
|
number = countryPhonePrefix + telephonyManager.getLine1Number().substring(1);
|
||||||
|
number = telephonyManager.getLine1Number();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// final JSONArray jsonArray = new JSONArray();
|
||||||
|
|
||||||
|
JSONObject toJSON() {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
try {
|
||||||
|
json.put("carrierName", carrierName);
|
||||||
|
json.put("displayName", displayName);
|
||||||
|
json.put("slotIndex", slotIndex);
|
||||||
|
json.put("number", number);
|
||||||
|
json.put("countryIso", countryIso);
|
||||||
|
json.put("countryPhonePrefix", countryPhonePrefix);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
16
dialer/packages/mobile_number/example/README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# mobile_number_example
|
||||||
|
|
||||||
|
Demonstrates how to use the mobile_number plugin.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
This project is a starting point for a Flutter application.
|
||||||
|
|
||||||
|
A few resources to get you started if this is your first Flutter project:
|
||||||
|
|
||||||
|
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
|
||||||
|
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
|
||||||
|
|
||||||
|
For help getting started with Flutter, view our
|
||||||
|
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||||
|
samples, guidance on mobile development, and a full API reference.
|
@ -0,0 +1,58 @@
|
|||||||
|
def localProperties = new Properties()
|
||||||
|
def localPropertiesFile = rootProject.file('local.properties')
|
||||||
|
if (localPropertiesFile.exists()) {
|
||||||
|
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||||
|
localProperties.load(reader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||||
|
if (flutterRoot == null) {
|
||||||
|
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||||
|
if (flutterVersionCode == null) {
|
||||||
|
flutterVersionCode = '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||||
|
if (flutterVersionName == null) {
|
||||||
|
flutterVersionName = '1.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdk 33
|
||||||
|
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.example.mobile_number_example"
|
||||||
|
minSdkVersion 21
|
||||||
|
targetSdkVersion 33
|
||||||
|
versionCode flutterVersionCode.toInteger()
|
||||||
|
versionName flutterVersionName
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
signingConfig signingConfigs.debug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lint {
|
||||||
|
disable 'InvalidPackage'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flutter {
|
||||||
|
source '../..'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation 'junit:junit:4.13.2'
|
||||||
|
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||||
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.mobile_number_example">
|
||||||
|
<!-- Flutter needs it to communicate with the running application
|
||||||
|
to allow setting breakpoints, to provide hot reload, etc.
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
@ -0,0 +1,58 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.mobile_number_example">
|
||||||
|
|
||||||
|
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
||||||
|
calls FlutterMain.startInitialization(this); in its onCreate method.
|
||||||
|
In most cases you can leave this as-is, but you if you want to provide
|
||||||
|
additional functionality it is fine to subclass or reimplement
|
||||||
|
FlutterApplication and put your custom class here. -->
|
||||||
|
<application
|
||||||
|
android:name="${applicationName}"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="mobile_number_example">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
|
android:hardwareAccelerated="true"
|
||||||
|
android:launchMode="singleTop"
|
||||||
|
android:theme="@style/LaunchTheme"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:exported="true">
|
||||||
|
<!-- This keeps the window background of the activity showing
|
||||||
|
until Flutter renders its first frame. It can be removed if
|
||||||
|
there is no splash screen (such as the default splash screen
|
||||||
|
defined in @style/LaunchTheme). -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data
|
||||||
|
android:name="io.flutter.embedding.android.NormalTheme"
|
||||||
|
android:resource="@style/NormalTheme" />
|
||||||
|
<!-- Displays an Android View that continues showing the launch screen
|
||||||
|
Drawable until Flutter paints its first frame, then this splash
|
||||||
|
screen fades out. A splash screen is useful to avoid any visual
|
||||||
|
gap between the end of Android's launch screen and the painting of
|
||||||
|
Flutter's first frame. -->
|
||||||
|
<meta-data
|
||||||
|
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
||||||
|
android:resource="@drawable/launch_background" />
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
||||||
|
android:value="true" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".EmbeddingV1Activity"
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
|
||||||
|
android:hardwareAccelerated="true"
|
||||||
|
android:theme="@style/LaunchTheme"
|
||||||
|
android:windowSoftInputMode="adjustResize" />
|
||||||
|
|
||||||
|
<meta-data
|
||||||
|
android:name="flutterEmbedding"
|
||||||
|
android:value="2" />
|
||||||
|
|
||||||
|
</application>
|
||||||
|
</manifest>
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.example.mobile_number_example;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.amorenew.mobile_number.MobileNumberPlugin;
|
||||||
|
import io.flutter.app.FlutterActivity;
|
||||||
|
|
||||||
|
public class EmbeddingV1Activity extends FlutterActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
MobileNumberPlugin.registerWith(registrarFor("com.amorenew.mobile_number.MobileNumberPlugin()"));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.example.mobile_number_example;
|
||||||
|
|
||||||
|
import io.flutter.embedding.android.FlutterActivity;
|
||||||
|
|
||||||
|
|
||||||
|
public class MainActivity extends FlutterActivity {
|
||||||
|
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public void configureFlutterEngine(FlutterEngine flutterEngine) {
|
||||||
|
// super.configureFlutterEngine(flutterEngine);
|
||||||
|
// flutterEngine.getPlugins().add(new com.example.mobile_number.MobileNumberPlugin());
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Modify this file to customize your launch splash screen -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@android:color/white" />
|
||||||
|
|
||||||
|
<!-- You can insert your own image assets here -->
|
||||||
|
<!-- <item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@mipmap/launch_image" />
|
||||||
|
</item> -->
|
||||||
|
</layer-list>
|
After Width: | Height: | Size: 544 B |
After Width: | Height: | Size: 442 B |
After Width: | Height: | Size: 721 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<!-- Show a splash screen on the activity. Automatically removed when
|
||||||
|
Flutter draws its first frame -->
|
||||||
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||||
|
This theme determines the color of the Android Window while your
|
||||||
|
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||||
|
running.
|
||||||
|
|
||||||
|
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||||
|
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<item name="android:windowBackground">@android:color/white</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
@ -0,0 +1,7 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.mobile_number_example">
|
||||||
|
<!-- Flutter needs it to communicate with the running application
|
||||||
|
to allow setting breakpoints, to provide hot reload, etc.
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
29
dialer/packages/mobile_number/example/android/build.gradle
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:7.2.2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.buildDir = '../build'
|
||||||
|
subprojects {
|
||||||
|
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||||
|
}
|
||||||
|
subprojects {
|
||||||
|
project.evaluationDependsOn(':app')
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
android.enableJetifier=true
|
||||||
|
android.useAndroidX=true
|
||||||
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
android.enableR8=true
|
6
dialer/packages/mobile_number/example/android/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#Tue May 19 14:57:48 GST 2020
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
@ -0,0 +1 @@
|
|||||||
|
{}
|
@ -0,0 +1,15 @@
|
|||||||
|
include ':app'
|
||||||
|
|
||||||
|
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
|
||||||
|
|
||||||
|
def plugins = new Properties()
|
||||||
|
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
|
||||||
|
if (pluginsFile.exists()) {
|
||||||
|
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins.each { name, path ->
|
||||||
|
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
|
||||||
|
include ":$name"
|
||||||
|
project(":$name").projectDir = pluginDirectory
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
include ':app'
|
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>App</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>io.flutter.flutter.app</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>App</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>MinimumOSVersion</key>
|
||||||
|
<string>8.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
@ -0,0 +1,2 @@
|
|||||||
|
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||||
|
#include "Generated.xcconfig"
|
@ -0,0 +1,2 @@
|
|||||||
|
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||||
|
#include "Generated.xcconfig"
|
84
dialer/packages/mobile_number/example/ios/Podfile
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
# Uncomment this line to define a global platform for your project
|
||||||
|
# platform :ios, '9.0'
|
||||||
|
|
||||||
|
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||||
|
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||||
|
|
||||||
|
project 'Runner', {
|
||||||
|
'Debug' => :debug,
|
||||||
|
'Profile' => :release,
|
||||||
|
'Release' => :release,
|
||||||
|
}
|
||||||
|
|
||||||
|
def parse_KV_file(file, separator='=')
|
||||||
|
file_abs_path = File.expand_path(file)
|
||||||
|
if !File.exists? file_abs_path
|
||||||
|
return [];
|
||||||
|
end
|
||||||
|
generated_key_values = {}
|
||||||
|
skip_line_start_symbols = ["#", "/"]
|
||||||
|
File.foreach(file_abs_path) do |line|
|
||||||
|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
|
||||||
|
plugin = line.split(pattern=separator)
|
||||||
|
if plugin.length == 2
|
||||||
|
podname = plugin[0].strip()
|
||||||
|
path = plugin[1].strip()
|
||||||
|
podpath = File.expand_path("#{path}", file_abs_path)
|
||||||
|
generated_key_values[podname] = podpath
|
||||||
|
else
|
||||||
|
puts "Invalid plugin specification: #{line}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
generated_key_values
|
||||||
|
end
|
||||||
|
|
||||||
|
target 'Runner' do
|
||||||
|
# Flutter Pod
|
||||||
|
|
||||||
|
copied_flutter_dir = File.join(__dir__, 'Flutter')
|
||||||
|
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
|
||||||
|
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
|
||||||
|
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
|
||||||
|
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
|
||||||
|
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
|
||||||
|
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
|
||||||
|
|
||||||
|
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
|
||||||
|
unless File.exist?(generated_xcode_build_settings_path)
|
||||||
|
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
|
||||||
|
end
|
||||||
|
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
|
||||||
|
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
|
||||||
|
|
||||||
|
unless File.exist?(copied_framework_path)
|
||||||
|
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
|
||||||
|
end
|
||||||
|
unless File.exist?(copied_podspec_path)
|
||||||
|
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Keep pod path relative so it can be checked into Podfile.lock.
|
||||||
|
pod 'Flutter', :path => 'Flutter'
|
||||||
|
|
||||||
|
# Plugin Pods
|
||||||
|
|
||||||
|
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
|
||||||
|
# referring to absolute paths on developers' machines.
|
||||||
|
system('rm -rf .symlinks')
|
||||||
|
system('mkdir -p .symlinks/plugins')
|
||||||
|
plugin_pods = parse_KV_file('../.flutter-plugins')
|
||||||
|
plugin_pods.each do |name, path|
|
||||||
|
symlink = File.join('.symlinks', 'plugins', name)
|
||||||
|
File.symlink(path, symlink)
|
||||||
|
pod name, :path => File.join(symlink, 'ios')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
post_install do |installer|
|
||||||
|
installer.pods_project.targets.each do |target|
|
||||||
|
target.build_configurations.each do |config|
|
||||||
|
config.build_settings['ENABLE_BITCODE'] = 'NO'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,506 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 46;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||||
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
|
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
||||||
|
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
|
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
|
||||||
|
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
|
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
|
||||||
|
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
|
||||||
|
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
|
||||||
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||||
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||||
|
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 10;
|
||||||
|
files = (
|
||||||
|
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
|
||||||
|
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
|
||||||
|
);
|
||||||
|
name = "Embed Frameworks";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||||
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||||
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||||
|
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||||
|
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||||
|
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||||
|
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||||
|
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||||
|
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||||
|
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
|
||||||
|
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
|
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||||
|
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
|
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
97C146EB1CF9000F007C117D /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
|
||||||
|
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
3B80C3931E831B6300D905FE /* App.framework */,
|
||||||
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||||
|
9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
||||||
|
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||||
|
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||||
|
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||||
|
);
|
||||||
|
name = Flutter;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146E51CF9000F007C117D = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9740EEB11CF90186004384FC /* Flutter */,
|
||||||
|
97C146F01CF9000F007C117D /* Runner */,
|
||||||
|
97C146EF1CF9000F007C117D /* Products */,
|
||||||
|
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146EF1CF9000F007C117D /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
97C146EE1CF9000F007C117D /* Runner.app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146F01CF9000F007C117D /* Runner */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
|
||||||
|
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
|
||||||
|
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||||
|
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||||
|
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||||
|
97C147021CF9000F007C117D /* Info.plist */,
|
||||||
|
97C146F11CF9000F007C117D /* Supporting Files */,
|
||||||
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||||
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||||
|
);
|
||||||
|
path = Runner;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146F11CF9000F007C117D /* Supporting Files */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
97C146F21CF9000F007C117D /* main.m */,
|
||||||
|
);
|
||||||
|
name = "Supporting Files";
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
97C146ED1CF9000F007C117D /* Runner */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||||
|
buildPhases = (
|
||||||
|
9740EEB61CF901F6004384FC /* Run Script */,
|
||||||
|
97C146EA1CF9000F007C117D /* Sources */,
|
||||||
|
97C146EB1CF9000F007C117D /* Frameworks */,
|
||||||
|
97C146EC1CF9000F007C117D /* Resources */,
|
||||||
|
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||||
|
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = Runner;
|
||||||
|
productName = Runner;
|
||||||
|
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
97C146E61CF9000F007C117D /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0910;
|
||||||
|
ORGANIZATIONNAME = "The Chromium Authors";
|
||||||
|
TargetAttributes = {
|
||||||
|
97C146ED1CF9000F007C117D = {
|
||||||
|
CreatedOnToolsVersion = 7.3.1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
|
||||||
|
compatibilityVersion = "Xcode 3.2";
|
||||||
|
developmentRegion = English;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 97C146E51CF9000F007C117D;
|
||||||
|
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
97C146ED1CF9000F007C117D /* Runner */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
97C146EC1CF9000F007C117D /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
||||||
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||||
|
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
|
||||||
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||||
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
|
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "Thin Binary";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
|
||||||
|
};
|
||||||
|
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "Run Script";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
||||||
|
};
|
||||||
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
97C146EA1CF9000F007C117D /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
|
||||||
|
97C146F31CF9000F007C117D /* main.m in Sources */,
|
||||||
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
97C146FB1CF9000F007C117D /* Base */,
|
||||||
|
);
|
||||||
|
name = Main.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
97C147001CF9000F007C117D /* Base */,
|
||||||
|
);
|
||||||
|
name = LaunchScreen.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
249021D3217E4FDB00AE95B9 /* Profile */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Profile;
|
||||||
|
};
|
||||||
|
249021D4217E4FDB00AE95B9 /* Profile */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
|
DEVELOPMENT_TEAM = S8QB4VV633;
|
||||||
|
ENABLE_BITCODE = NO;
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
);
|
||||||
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
|
LIBRARY_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.example.mobileNumberExample;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
};
|
||||||
|
name = Profile;
|
||||||
|
};
|
||||||
|
97C147031CF9000F007C117D /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
97C147041CF9000F007C117D /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
97C147061CF9000F007C117D /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
|
ENABLE_BITCODE = NO;
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
);
|
||||||
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
|
LIBRARY_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.example.mobileNumberExample;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
97C147071CF9000F007C117D /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
|
ENABLE_BITCODE = NO;
|
||||||
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
);
|
||||||
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||||
|
LIBRARY_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"$(PROJECT_DIR)/Flutter",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.example.mobileNumberExample;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
97C147031CF9000F007C117D /* Debug */,
|
||||||
|
97C147041CF9000F007C117D /* Release */,
|
||||||
|
249021D3217E4FDB00AE95B9 /* Profile */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
97C147061CF9000F007C117D /* Debug */,
|
||||||
|
97C147071CF9000F007C117D /* Release */,
|
||||||
|
249021D4217E4FDB00AE95B9 /* Profile */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 97C146E61CF9000F007C117D /* Project object */;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "group:Runner.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
@ -0,0 +1,93 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "0910"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||||
|
BuildableName = "Runner.app"
|
||||||
|
BlueprintName = "Runner"
|
||||||
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||||
|
BuildableName = "Runner.app"
|
||||||
|
BlueprintName = "Runner"
|
||||||
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
language = ""
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||||
|
BuildableName = "Runner.app"
|
||||||
|
BlueprintName = "Runner"
|
||||||
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
<AdditionalOptions>
|
||||||
|
</AdditionalOptions>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Profile"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||||
|
BuildableName = "Runner.app"
|
||||||
|
BlueprintName = "Runner"
|
||||||
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
7
dialer/packages/mobile_number/example/ios/Runner.xcworkspace/contents.xcworkspacedata
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "group:Runner.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
@ -0,0 +1,6 @@
|
|||||||
|
#import <Flutter/Flutter.h>
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@interface AppDelegate : FlutterAppDelegate
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,13 @@
|
|||||||
|
#include "AppDelegate.h"
|
||||||
|
#include "GeneratedPluginRegistrant.h"
|
||||||
|
|
||||||
|
@implementation AppDelegate
|
||||||
|
|
||||||
|
- (BOOL)application:(UIApplication *)application
|
||||||
|
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
|
[GeneratedPluginRegistrant registerWithRegistry:self];
|
||||||
|
// Override point for customization after application launch.
|
||||||
|
return [super application:application didFinishLaunchingWithOptions:launchOptions];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
@ -0,0 +1,122 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-20x20@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-20x20@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-40x40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-40x40@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-60x60@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-60x60@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-20x20@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-20x20@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-29x29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-40x40@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-40x40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-76x76@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-76x76@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "83.5x83.5",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-83.5x83.5@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "1024x1024",
|
||||||
|
"idiom" : "ios-marketing",
|
||||||
|
"filename" : "Icon-App-1024x1024@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 564 B |