| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7fa7bf8 commit 448d216
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,17 +104,25 @@ class MainActivity : AppCompatActivity() { | |||
| 104 | 104 | } | |
| 105 | 105 | ||
| 106 | 106 | private fun requestPermissions(context:Context) { | |
| 107 | - if(!Settings.isLoggedIn(context)) { | ||
| 108 | - return | ||
| 109 | - } | ||
| 110 | 107 | Timber.d("requesting permissions") | |
| 111 | 108 | val requestPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { permissions -> | |
| 112 | 109 | permissions.entries.forEach { | |
| 113 | 110 | Timber.d("${it.key} = ${it.value}") | |
| 114 | 111 | } | |
| 115 | 112 | } | |
| 116 | - val permissions = arrayOf(Manifest.permission.READ_CALL_LOG) | ||
| 113 | + | ||
| 114 | + var permissions = arrayOf( | ||
| 115 | + Manifest.permission.SEND_SMS, | ||
| 116 | + Manifest.permission.RECEIVE_SMS, | ||
| 117 | + Manifest.permission.READ_SMS | ||
| 118 | + ) | ||
| 119 | + | ||
| 120 | + if(Build.VERSION.SDK_INT >= 33) { | ||
| 121 | + permissions += Manifest.permission.POST_NOTIFICATIONS | ||
| 122 | + } | ||
| 123 | + | ||
| 117 | 124 | requestPermissionLauncher.launch(permissions) | |
| 125 | + | ||
| 118 | 126 | Timber.d("creating permissions launcher") | |
| 119 | 127 | } | |
| 120 | 128 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,8 @@ object Settings { | |||
| 16 | 16 | private const val SETTINGS_SIM2_ACTIVE = "SETTINGS_SIM2_ACTIVE_STATUS" | |
| 17 | 17 | private const val SETTINGS_SIM1_INCOMING_ACTIVE = "SETTINGS_SIM1_INCOMING_ACTIVE" | |
| 18 | 18 | private const val SETTINGS_SIM2_INCOMING_ACTIVE = "SETTINGS_SIM2_INCOMING_ACTIVE" | |
| 19 | + private const val SETTINGS_SIM1_INCOMING_CALL_ACTIVE = "SETTINGS_SIM1_INCOMING_CALL_ACTIVE" | ||
| 20 | + private const val SETTINGS_SIM2_INCOMING_CALL_ACTIVE = "SETTINGS_SIM2_INCOMING_CALL_ACTIVE" | ||
| 19 | 21 | private const val SETTINGS_DEBUG_LOG_ENABLED = "SETTINGS_DEBUG_LOG_ENABLED" | |
| 20 | 22 | private const val SETTINGS_API_KEY = "SETTINGS_API_KEY" | |
| 21 | 23 | private const val SETTINGS_SERVER_URL = "SETTINGS_SERVER_URL" | |
@@ -114,6 +116,32 @@ object Settings { | |||
| 114 | 116 | return activeStatus | |
| 115 | 117 | } | |
| 116 | 118 | ||
| 119 | + fun isIncomingCallEventsEnabled(context: Context, sim: String): Boolean { | ||
| 120 | + var setting = this.SETTINGS_SIM1_INCOMING_CALL_ACTIVE | ||
| 121 | + if (sim == Constants.SIM2) { | ||
| 122 | + setting = this.SETTINGS_SIM2_INCOMING_CALL_ACTIVE | ||
| 123 | + } | ||
| 124 | + val activeStatus = PreferenceManager | ||
| 125 | + .getDefaultSharedPreferences(context) | ||
| 126 | + .getBoolean(setting,false) | ||
| 127 | + | ||
| 128 | + Timber.d("SETTINGS_${sim}_INCOMING_CALL_ACTIVE: [$activeStatus]") | ||
| 129 | + return activeStatus | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + fun setIncomingCallEventsEnabled(context: Context, sim: String, enabled: Boolean) { | ||
| 133 | + var setting = this.SETTINGS_SIM1_INCOMING_CALL_ACTIVE | ||
| 134 | + if (sim == Constants.SIM2) { | ||
| 135 | + setting = this.SETTINGS_SIM2_INCOMING_CALL_ACTIVE | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + PreferenceManager.getDefaultSharedPreferences(context) | ||
| 139 | + .edit() | ||
| 140 | + .putBoolean(setting, enabled) | ||
| 141 | + .apply() | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + | ||
| 117 | 145 | fun isDebugLogEnabled(context: Context) : Boolean { | |
| 118 | 146 | Timber.d(Settings::isDebugLogEnabled.name) | |
| 119 | 147 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,6 +68,16 @@ class SettingsActivity : AppCompatActivity() { | |||
| 68 | 68 | sim2OutgoingMessages.setOnCheckedChangeListener{ _, isChecked -> run { Settings.setActiveStatusAsync(context, isChecked, Constants.SIM2) } } | |
| 69 | 69 | ||
| 70 | 70 | handleEncryptionSettings(context) | |
| 71 | + handleIncomingCallEventsSim1(context) | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + private fun handleIncomingCallEventsSim1(context: Context) { | ||
| 75 | + val enableIncomingCallEvents = findViewById<SwitchMaterial>(R.id.settingsSim1EnableIncomingCallEvents) | ||
| 76 | + enableIncomingCallEvents.isChecked = Settings.isIncomingCallEventsEnabled(context, Constants.SIM1) | ||
| 77 | + enableIncomingCallEvents.setOnCheckedChangeListener{ _, isChecked -> run { | ||
| 78 | + requestReadCallLogPermission(context) | ||
| 79 | + Timber.d("how are you [${isChecked}]") | ||
| 80 | + }} | ||
| 71 | 81 | } | |
| 72 | 82 | ||
| 73 | 83 | private fun handleEncryptionSettings(context: Context) { | |
@@ -120,25 +130,21 @@ class SettingsActivity : AppCompatActivity() { | |||
| 120 | 130 | } | |
| 121 | 131 | ||
| 122 | 132 | private fun requestReadCallLogPermission(context: Context) { | |
| 133 | + if(!Settings.isLoggedIn(context)) { | ||
| 134 | + return | ||
| 135 | + } | ||
| 123 | 136 | Timber.d("requesting permissions") | |
| 124 | 137 | val requestPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { permissions -> | |
| 125 | 138 | permissions.entries.forEach { | |
| 126 | 139 | Timber.d("${it.key} = ${it.value}") | |
| 127 | 140 | } | |
| 128 | 141 | } | |
| 129 | - | ||
| 130 | - var permissions = arrayOf( | ||
| 131 | - Manifest.permission.SEND_SMS, | ||
| 132 | - Manifest.permission.RECEIVE_SMS, | ||
| 133 | - Manifest.permission.READ_SMS | ||
| 142 | + val permissions = arrayOf( | ||
| 143 | + Manifest.permission.READ_CALL_LOG, | ||
| 144 | + Manifest.permission.READ_PHONE_STATE | ||
| 134 | 145 | ) | |
| 135 | 146 | ||
| 136 | - if(Build.VERSION.SDK_INT >= 33) { | ||
| 137 | - permissions += Manifest.permission.POST_NOTIFICATIONS | ||
| 138 | - } | ||
| 139 | - | ||
| 140 | 147 | requestPermissionLauncher.launch(permissions) | |
| 141 | - | ||
| 142 | 148 | Timber.d("creating permissions launcher") | |
| 143 | 149 | } | |
| 144 | 150 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,5 +14,11 @@ class PhoneStateReceiver : BroadcastReceiver() { | |||
| 14 | 14 | val subscriptionId = intent.extras!!.getString(TelephonyManager.EXTRA_SUBSCRIPTION_ID) | |
| 15 | 15 | val number = intent.extras!!.getString(TelephonyManager.EXTRA_INCOMING_NUMBER) | |
| 16 | 16 | Timber.w("state = [${stateStr}] number = [${number}], subscriptionID = [${subscriptionId}]") | |
| 17 | + val bundle = intent.extras | ||
| 18 | + if (bundle != null) { | ||
| 19 | + for (key in bundle.keySet()) { | ||
| 20 | + Timber.w(key + " : " + if (bundle[key] != null) bundle[key] else "NULL") | ||
| 21 | + } | ||
| 22 | + } | ||
| 17 | 23 | } | |
| 18 | 24 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,6 +76,17 @@ | |||
| 76 | 76 | android:textSize="18sp" | |
| 77 | 77 | tools:ignore="TouchTargetSizeCheck" /> | |
| 78 | 78 | ||
| 79 | + | ||
| 80 | + <com.google.android.material.switchmaterial.SwitchMaterial | ||
| 81 | + android:id="@+id/settingsSim1EnableIncomingCallEvents" | ||
| 82 | + android:layout_width="match_parent" | ||
| 83 | + android:layout_height="wrap_content" | ||
| 84 | + android:layout_marginBottom="16dp" | ||
| 85 | + android:minHeight="48dp" | ||
| 86 | + android:text="@string/enable_incoming_call_events_sim1" | ||
| 87 | + android:textSize="18sp" | ||
| 88 | + tools:ignore="TouchTargetSizeCheck" /> | ||
| 89 | + | ||
| 79 | 90 | <com.google.android.material.textfield.TextInputLayout | |
| 80 | 91 | android:id="@+id/settingsSIM2Layout" | |
| 81 | 92 | style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,13 +20,14 @@ | |||
| 20 | 20 | <string name="main_app_settings">App Settings</string> | |
| 21 | 21 | <string name="settings_sim1">SIM1</string> | |
| 22 | 22 | <string name="settings_sim_2">SIM2</string> | |
| 23 | - <string name="settings_outgoing_messages_sim1">Enable Outgoing Messages (SIM1)</string> | ||
| 24 | - <string name="settings_incoming_messages_sim1">Enable Incoming Messages (SIM1)</string> | ||
| 25 | - <string name="settings_incoming_messages_sim2">Enable Incoming Messages (SIM2)</string> | ||
| 26 | - <string name="settings_outgoing_messages_sim2">Enable Outgoing Messages (SIM2)</string> | ||
| 27 | - <string name="login_phone_number_sim1">Phone Number (SIM1)</string> | ||
| 28 | - <string name="login_phone_number_sim2">Phone Number (SIM2)</string> | ||
| 23 | + <string name="settings_outgoing_messages_sim1">Enable SIM1 outgoing messages</string> | ||
| 24 | + <string name="settings_incoming_messages_sim1">Enable SIM1 incoming messages</string> | ||
| 25 | + <string name="settings_incoming_messages_sim2">Enable SIM2 incoming messages</string> | ||
| 26 | + <string name="settings_outgoing_messages_sim2">Enable SIM2 outgoing messages</string> | ||
| 27 | + <string name="login_phone_number_sim1">Phone number (SIM1)</string> | ||
| 28 | + <string name="login_phone_number_sim2">Phone number (SIM2)</string> | ||
| 29 | 29 | <string name="encryption_key">Encryption Key</string> | |
| 30 | - <string name="encrypt_received_messages">Encrypt Received Messages</string> | ||
| 31 | - <string name="enable_debug_logs">Enable Debug Logs</string> | ||
| 30 | + <string name="encrypt_received_messages">Encrypt received messages</string> | ||
| 31 | + <string name="enable_debug_logs">Enable debug logs</string> | ||
| 32 | + <string name="enable_incoming_call_events_sim1">Enable SIM1 incoming call events</string> | ||
| 32 | 33 | </resources> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments