summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-09-12 12:37:50 +0000
committerEvgeny Zinoviev <me@ch1p.io>2021-11-07 14:02:33 +0000
commite7b06539da77aca49d6fb7ae3bb8b6a03ea92469 (patch)
tree07858090cd7f2a72c377a6e20e896bb01d92e130 /java
parentdead11187ab86d7d57f506c4360952687c742e70 (diff)
enable auto-recording featureauto-records
Change-Id: Ie625437f422daaffb7b751776ad76039b0ac6041
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/app/res/values/cm_strings.xml4
-rw-r--r--java/com/android/dialer/app/res/xml/sound_settings.xml5
-rw-r--r--java/com/android/incallui/CallButtonPresenter.java27
3 files changed, 36 insertions, 0 deletions
diff --git a/java/com/android/dialer/app/res/values/cm_strings.xml b/java/com/android/dialer/app/res/values/cm_strings.xml
index 84d6ef735..3b6e88527 100644
--- a/java/com/android/dialer/app/res/values/cm_strings.xml
+++ b/java/com/android/dialer/app/res/values/cm_strings.xml
@@ -36,6 +36,10 @@
<string name="call_recording_category_title">Call recording</string>
<string name="call_recording_format_key" translatable="false">call_recording_format</string>
<string name="call_recording_format">Audio format</string>
+
+ <string name="auto_call_recording_title">Record automatically</string>
+ <string name="auto_call_recording_key" translatable="false">auto_call_recording</string>
+
<string name="wb_amr_format" translatable="false">AMR-WB</string>
<string name="aac_format" translatable="false">AAC</string>
diff --git a/java/com/android/dialer/app/res/xml/sound_settings.xml b/java/com/android/dialer/app/res/xml/sound_settings.xml
index aa025874f..d31ea9e5c 100644
--- a/java/com/android/dialer/app/res/xml/sound_settings.xml
+++ b/java/com/android/dialer/app/res/xml/sound_settings.xml
@@ -83,6 +83,11 @@
android:entryValues="@array/call_recording_encoder_values"
android:defaultValue="0" />
+ <SwitchPreference
+ android:defaultValue="false"
+ android:key="@string/auto_call_recording_key"
+ android:title="@string/auto_call_recording_title"/>
+
</PreferenceCategory>
</PreferenceScreen>
diff --git a/java/com/android/incallui/CallButtonPresenter.java b/java/com/android/incallui/CallButtonPresenter.java
index cff283c21..c3ccdc1eb 100644
--- a/java/com/android/incallui/CallButtonPresenter.java
+++ b/java/com/android/incallui/CallButtonPresenter.java
@@ -22,6 +22,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Trace;
+import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.os.UserManagerCompat;
@@ -74,6 +75,7 @@ public class CallButtonPresenter
private DialerCall call;
private boolean isInCallButtonUiReady;
private PhoneAccountHandle otherAccount;
+ private boolean isRecording = false;
private CallRecorder.RecordingProgressListener recordingProgressListener =
new CallRecorder.RecordingProgressListener() {
@@ -115,6 +117,12 @@ public class CallButtonPresenter
CallRecorder recorder = CallRecorder.getInstance();
recorder.addRecordingProgressListener(recordingProgressListener);
+ if (recorder.isRecording()) {
+ inCallButtonUi.setCallRecordingState(true);
+ } else {
+ inCallButtonUi.setCallRecordingState(false);
+ }
+
// Update the buttons state immediately for the current call
onStateChange(InCallState.NO_CALLS, inCallPresenter.getInCallState(), CallList.getInstance());
isInCallButtonUiReady = true;
@@ -144,6 +152,11 @@ public class CallButtonPresenter
@Override
public void onStateChange(InCallState oldState, InCallState newState, CallList callList) {
Trace.beginSection("CallButtonPresenter.onStateChange");
+
+ CallRecorder recorder = CallRecorder.getInstance();
+ boolean isEnabled = PreferenceManager.getDefaultSharedPreferences(context)
+ .getBoolean(context.getString(R.string.auto_call_recording_key), false);
+
if (call != null) {
call.removeListener(this);
}
@@ -152,6 +165,17 @@ public class CallButtonPresenter
} else if (newState == InCallState.INCALL) {
call = callList.getActiveOrBackgroundCall();
+ // Enable recording automatically according to preferences
+ if (!isRecording && isEnabled && call != null) {
+ isRecording = true;
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ callRecordClicked(true);
+ }
+ }, 500);
+ }
+
// When connected to voice mail, automatically shows the dialpad.
// (On previous releases we showed it when in-call shows up, before waiting for
// OUTGOING. We may want to do that once we start showing "Voice mail" label on
@@ -167,6 +191,9 @@ public class CallButtonPresenter
}
call = callList.getIncomingCall();
} else {
+ if (isEnabled && recorder.isRecording()) {
+ recorder.finishRecording();
+ }
call = null;
}