Skip to content

Commit 4d4cdd8

Browse files
committed
- linter
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
1 parent bfa9db9 commit 4d4cdd8

4 files changed

Lines changed: 44 additions & 43 deletions

File tree

app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class CallActivity : CallBaseActivity() {
247247
private val cameraSwitchHandler = Handler()
248248

249249
private val callTimeHandler = Handler(Looper.getMainLooper())
250-
250+
251251
// Track if we're intentionally leaving the call
252252
private var isIntentionallyLeavingCall = false
253253

@@ -327,7 +327,7 @@ class CallActivity : CallBaseActivity() {
327327
) { permissionMap: Map<String, Boolean> ->
328328
// Log permission results
329329
Log.d(TAG, "Permission request completed with results: $permissionMap")
330-
330+
331331
val rationaleList: MutableList<String> = ArrayList()
332332
val audioPermission = permissionMap[Manifest.permission.RECORD_AUDIO]
333333
if (audioPermission != null) {
@@ -383,9 +383,7 @@ class CallActivity : CallBaseActivity() {
383383
} else {
384384
true // Older Android versions have permission by default
385385
}
386-
387-
Log.d(TAG, "DEBUGNotification permission granted: $notificationPermissionGranted, isConnectionEstablished: $isConnectionEstablished")
388-
386+
389387
if (!isConnectionEstablished) {
390388
Log.d(TAG, "Proceeding with prepareCall() despite notification permission status")
391389
prepareCall()
@@ -416,10 +414,10 @@ class CallActivity : CallBaseActivity() {
416414
Log.d(TAG, "onCreate")
417415
super.onCreate(savedInstanceState)
418416
sharedApplication!!.componentApplication.inject(this)
419-
417+
420418
// Register broadcast receiver for ending call from notification
421419
val endCallFilter = IntentFilter(END_CALL_FROM_NOTIFICATION)
422-
420+
423421
// Use the proper utility function with ReceiverFlag for Android 14+ compatibility
424422
// This receiver is for internal app use only (notification actions), so it should NOT be exported
425423
registerPermissionHandlerBroadcastReceiver(
@@ -429,7 +427,7 @@ class CallActivity : CallBaseActivity() {
429427
null,
430428
ReceiverFlag.NotExported
431429
)
432-
430+
433431
Log.d(TAG, "Broadcast receiver registered successfully")
434432

435433
callViewModel = ViewModelProvider(this, viewModelFactory)[CallViewModel::class.java]
@@ -1059,7 +1057,7 @@ class CallActivity : CallBaseActivity() {
10591057
permissionsToRequest.add(Manifest.permission.BLUETOOTH_CONNECT)
10601058
}
10611059
}
1062-
1060+
10631061
// Check notification permission for Android 13+ (API 33+)
10641062
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
10651063
if (permissionUtil!!.isPostNotificationsPermissionGranted()) {
@@ -1103,20 +1101,23 @@ class CallActivity : CallBaseActivity() {
11031101
Log.d(TAG, "Starting foreground service with notification permission")
11041102
CallForegroundService.start(applicationContext, conversationName, intent.extras)
11051103
} else {
1106-
Log.w(TAG, "Notification permission not granted - call will work but without persistent notification")
1104+
Log.w(
1105+
TAG,
1106+
"Notification permission not granted - call will work but without persistent notification"
1107+
)
11071108
// Show warning to user that notification permission is missing (10 seconds)
11081109
Snackbar.make(
11091110
binding!!.root,
11101111
resources.getString(R.string.nc_notification_permission_hint),
1111-
10000
1112+
SEC_10
11121113
).show()
11131114
}
11141115
} else {
11151116
// Android 12 and below - notification permission is automatically granted
11161117
Log.d(TAG, "Starting foreground service (Android 12-)")
11171118
CallForegroundService.start(applicationContext, conversationName, intent.extras)
11181119
}
1119-
1120+
11201121
if (!microphoneOn) {
11211122
onMicrophoneClick()
11221123
}
@@ -1127,7 +1128,7 @@ class CallActivity : CallBaseActivity() {
11271128
// The call should not hang just because notification permission was denied
11281129
// Always proceed with call setup regardless of notification permission
11291130
Log.d(TAG, "Ensuring call proceeds even without notification permission")
1130-
1131+
11311132
if (isVoiceOnlyCall) {
11321133
binding!!.selfVideoViewWrapper.visibility = View.GONE
11331134
} else if (permissionUtil!!.isCameraPermissionGranted()) {
@@ -1155,11 +1156,7 @@ class CallActivity : CallBaseActivity() {
11551156
for (rationale in rationaleList) {
11561157
rationalesWithLineBreaks.append(rationale).append("\n\n")
11571158
}
1158-
1159-
// Log when permission rationale dialog is shown
1160-
Log.d(TAG, "Showing permission rationale dialog for permissions: $permissionsToRequest")
1161-
Log.d(TAG, "Rationale includes notification permission: ${permissionsToRequest.contains(Manifest.permission.POST_NOTIFICATIONS)}")
1162-
1159+
11631160
val dialogBuilder = MaterialAlertDialogBuilder(this)
11641161
.setTitle(R.string.nc_permissions_rationale_dialog_title)
11651162
.setMessage(rationalesWithLineBreaks)
@@ -1173,7 +1170,7 @@ class CallActivity : CallBaseActivity() {
11731170
if (permissionsToRequest.contains(Manifest.permission.POST_NOTIFICATIONS)) {
11741171
Log.w(TAG, "Notification permission specifically dismissed - proceeding with call anyway")
11751172
}
1176-
1173+
11771174
// Proceed with call even when notification permission is dismissed
11781175
if (!isConnectionEstablished) {
11791176
Log.d(TAG, "Proceeding with prepareCall() after dismissing notification permission")
@@ -1452,7 +1449,7 @@ class CallActivity : CallBaseActivity() {
14521449
Log.d(TAG, "onDestroy called")
14531450
Log.d(TAG, "onDestroy: isIntentionallyLeavingCall=$isIntentionallyLeavingCall")
14541451
Log.d(TAG, "onDestroy: currentCallStatus=$currentCallStatus")
1455-
1452+
14561453
if (signalingMessageReceiver != null) {
14571454
signalingMessageReceiver!!.removeListener(localParticipantMessageListener)
14581455
signalingMessageReceiver!!.removeListener(offerMessageListener)
@@ -1474,20 +1471,20 @@ class CallActivity : CallBaseActivity() {
14741471
if (isIntentionallyLeavingCall || currentCallStatus === CallStatus.LEAVING) {
14751472
CallForegroundService.stop(applicationContext)
14761473
}
1477-
1474+
14781475
Log.d(TAG, "onDestroy: Releasing proximity sensor - updating to IDLE state")
14791476
powerManagerUtils!!.updatePhoneState(PowerManagerUtils.PhoneState.IDLE)
14801477
Log.d(TAG, "onDestroy: Proximity sensor released")
1481-
1478+
14821479
// Unregister receiver
14831480
try {
14841481
Log.d(TAG, "Unregistering endCallFromNotificationReceiver...")
14851482
unregisterReceiver(endCallFromNotificationReceiver)
14861483
Log.d(TAG, "endCallFromNotificationReceiver unregistered successfully")
1487-
} catch (e: Exception) {
1484+
} catch (e: IllegalArgumentException) {
14881485
Log.w(TAG, "Failed to unregister endCallFromNotificationReceiver", e)
14891486
}
1490-
1487+
14911488
super.onDestroy()
14921489
}
14931490

@@ -2064,7 +2061,7 @@ class CallActivity : CallBaseActivity() {
20642061
Log.d(TAG, "hangup! shutDownView=$shutDownView, endCallForAll=$endCallForAll")
20652062
Log.d(TAG, "hangup! isIntentionallyLeavingCall=$isIntentionallyLeavingCall")
20662063
Log.d(TAG, "hangup! powerManagerUtils state before cleanup: ${powerManagerUtils != null}")
2067-
2064+
20682065
if (shutDownView) {
20692066
setCallState(CallStatus.LEAVING)
20702067
}
@@ -3228,6 +3225,7 @@ class CallActivity : CallBaseActivity() {
32283225

32293226
private const val CALLING_TIMEOUT: Long = 45000
32303227
private const val PULSE_ANIMATION_DURATION: Int = 310
3228+
private const val SEC_10 = 10000
32313229

32323230
private const val DELAY_ON_ERROR_STOP_THRESHOLD: Int = 16
32333231

app/src/main/java/com/nextcloud/talk/activities/CallBaseActivity.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public abstract class CallBaseActivity extends BaseActivity {
3434
long onCreateTime;
3535

3636

37-
private OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
37+
private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
3838
@Override
3939
public void handleOnBackPressed() {
4040
if (isPipModePossible()) {
@@ -65,7 +65,7 @@ public void onCreate(Bundle savedInstanceState) {
6565
getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);
6666
}
6767

68-
public void hideNavigationIfNoPipAvailable(){
68+
public void hideNavigationIfNoPipAvailable() {
6969
if (!isPipModePossible()) {
7070
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
7171
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
@@ -139,14 +139,14 @@ void enterPipMode() {
139139
}
140140

141141
boolean isPipModePossible() {
142-
boolean deviceHasPipFeature = getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
143-
144-
AppOpsManager appOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
145-
boolean isPipFeatureGranted = appOpsManager.checkOpNoThrow(
146-
AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
147-
android.os.Process.myUid(),
148-
BuildConfig.APPLICATION_ID) == AppOpsManager.MODE_ALLOWED;
149-
return deviceHasPipFeature && isPipFeatureGranted;
142+
boolean deviceHasPipFeature = getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE);
143+
144+
AppOpsManager appOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
145+
boolean isPipFeatureGranted = appOpsManager.checkOpNoThrow(
146+
AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
147+
android.os.Process.myUid(),
148+
BuildConfig.APPLICATION_ID) == AppOpsManager.MODE_ALLOWED;
149+
return deviceHasPipFeature && isPipFeatureGranted;
150150
}
151151

152152
private boolean shouldFinishOnStop() {

app/src/main/java/com/nextcloud/talk/receivers/EndCallReceiver.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class EndCallReceiver : BroadcastReceiver() {
1818
const val END_CALL_ACTION = "com.nextcloud.talk.END_CALL"
1919
const val END_CALL_FROM_NOTIFICATION = "com.nextcloud.talk.END_CALL_FROM_NOTIFICATION"
2020
}
21-
21+
2222
override fun onReceive(context: Context?, intent: Intent?) {
2323
if (intent?.action == END_CALL_ACTION) {
2424
Log.i(TAG, "Received end call broadcast")
25-
25+
2626
// Stop the foreground service
2727
context?.let {
2828
CallForegroundService.stop(it)
29-
29+
3030
// Send broadcast to CallActivity to end the call
3131
val endCallIntent = Intent(END_CALL_FROM_NOTIFICATION)
3232
endCallIntent.setPackage(context.packageName)

app/src/main/java/com/nextcloud/talk/services/CallForegroundService.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ class CallForegroundService : Service() {
6161
val contentTitle = conversationName?.takeIf { it.isNotBlank() }
6262
?: getString(R.string.nc_call_ongoing_notification_default_title)
6363
val pendingIntent = createContentIntent(callExtras)
64-
64+
6565
val returnToCallAction = NotificationCompat.Action.Builder(
6666
R.drawable.ic_call_white_24dp,
6767
getString(R.string.nc_call_ongoing_notification_return_action),
6868
pendingIntent
6969
).build()
70-
70+
7171
val endCallPendingIntent = createEndCallIntent(callExtras)
72-
72+
7373
val endCallAction = NotificationCompat.Action.Builder(
7474
R.drawable.ic_baseline_close_24,
7575
getString(R.string.nc_call_ongoing_notification_end_action),
@@ -100,14 +100,17 @@ class CallForegroundService : Service() {
100100

101101
private fun createContentIntent(callExtras: Bundle?): PendingIntent {
102102
val intent = Intent(this, CallActivity::class.java).apply {
103-
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
103+
flags =
104+
Intent.FLAG_ACTIVITY_SINGLE_TOP or
105+
Intent.FLAG_ACTIVITY_CLEAR_TOP or
106+
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
104107
callExtras?.let { putExtras(Bundle(it)) }
105108
}
106109

107110
val flags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
108111
return PendingIntent.getActivity(this, 0, intent, flags)
109112
}
110-
113+
111114
private fun createEndCallIntent(callExtras: Bundle?): PendingIntent {
112115
val intent = Intent(this, EndCallReceiver::class.java).apply {
113116
action = END_CALL_ACTION

0 commit comments

Comments
 (0)