aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian.schneppe@pix-art.de>2020-02-09 21:39:57 +0100
committerChristian Schneppe <christian.schneppe@pix-art.de>2020-02-09 21:39:57 +0100
commitdb952297c516600547924aa6c9ebca53fd3bfea8 (patch)
tree8aae53991a44d1831a2d540ef96da4f499e178eb /src
parentb10b73caad1737cce836193414feeb8379b886e0 (diff)
integrate alternative codec for voice recorder via attachment settings
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java1
-rw-r--r--src/main/java/de/pixart/messenger/ui/RecordingActivity.java18
-rw-r--r--src/main/res/values/defaults.xml1
-rw-r--r--src/main/res/values/strings.xml2
-rw-r--r--src/main/res/xml/preferences.xml5
6 files changed, 27 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 6f857889b..e5b6582d1 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -1009,6 +1009,10 @@ public class XmppConnectionService extends Service {
return getBooleanPreference(SettingsActivity.AWAY_WHEN_SCREEN_IS_OFF, R.bool.away_when_screen_off);
}
+ public boolean alternativeVoiceSettings() {
+ return getBooleanPreference("alternative_voice_settings", R.bool.alternative_voice_settings);
+ }
+
public int getCompressImageResolutionPreference() {
switch (getPreferences().getString("image_compression", getResources().getString(R.string.image_compression))) {
case "low":
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index ef09a6a41..320c1eb8b 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1799,6 +1799,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
break;
case ATTACHMENT_CHOICE_RECORD_VOICE:
intent = new Intent(getActivity(), RecordingActivity.class);
+ intent.putExtra("ALTERNATIVE_CODEC", activity.xmppConnectionService.alternativeVoiceSettings());
break;
case ATTACHMENT_CHOICE_LOCATION:
intent = new Intent(getActivity(), ShareLocationActivity.class);
diff --git a/src/main/java/de/pixart/messenger/ui/RecordingActivity.java b/src/main/java/de/pixart/messenger/ui/RecordingActivity.java
index cf247f920..1b1ea64c2 100644
--- a/src/main/java/de/pixart/messenger/ui/RecordingActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/RecordingActivity.java
@@ -12,6 +12,7 @@ import android.os.Handler;
import android.os.SystemClock;
import android.util.Log;
import android.view.View;
+import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
@@ -39,6 +40,7 @@ public class RecordingActivity extends AppCompatActivity implements View.OnClick
private MediaRecorder mRecorder;
private long mStartTime = 0;
+ private boolean alternativeCodec = false;
private CountDownLatch outputFileWrittenLatch = new CountDownLatch(1);
@@ -59,6 +61,7 @@ public class RecordingActivity extends AppCompatActivity implements View.OnClick
protected void onCreate(Bundle savedInstanceState) {
setTheme(ThemeHelper.findDialog(this));
super.onCreate(savedInstanceState);
+ supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_recording);
this.setTitle(R.string.attach_record_voice);
this.binding.cancelButton.setOnClickListener(this);
@@ -70,6 +73,8 @@ public class RecordingActivity extends AppCompatActivity implements View.OnClick
@Override
protected void onStart() {
super.onStart();
+ Intent intent = getIntent();
+ alternativeCodec = intent != null && intent.getBooleanExtra("ALTERNATIVE_CODEC", getResources().getBoolean(R.bool.alternative_voice_settings));
if (!startRecording()) {
this.binding.shareButton.setEnabled(false);
this.binding.timer.setTextAppearance(this, R.style.TextAppearance_Conversations_Title);
@@ -92,10 +97,15 @@ public class RecordingActivity extends AppCompatActivity implements View.OnClick
private boolean startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
- mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
- mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
- mRecorder.setAudioEncodingBitRate(96000);
- mRecorder.setAudioSamplingRate(22050);
+ if (alternativeCodec) {
+ mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
+ mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+ } else {
+ mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
+ mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
+ mRecorder.setAudioEncodingBitRate(96000);
+ mRecorder.setAudioSamplingRate(22050);
+ }
setupOutputFile();
mRecorder.setOutputFile(mOutputFile.getAbsolutePath());
diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml
index ecfd9b224..2c3ea9331 100644
--- a/src/main/res/values/defaults.xml
+++ b/src/main/res/values/defaults.xml
@@ -72,6 +72,7 @@
<string name="default_font_size">small</string>
<string name="default_channel_discovery">JABBER_NETWORK</string>
<bool name="use_unicolored_chatbg">false</bool>
+ <bool name="alternative_voice_settings">false</bool>
<string-array name="domains">
<item>pix-art.de</item>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 95075eb63..d2d3dfea3 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -998,4 +998,6 @@
<string name="your_server_invitation">Your server invitation</string>
<string name="pref_use_unicolored_chatbg_summary">Use unicolored background in chats.</string>
<string name="pref_use_unicolored_chatbg">Use unicolored background</string>
+ <string name="pref_alternative_voice_settings_summary">If you have problems during voice recording, use this setting to change the codec.</string>
+ <string name="pref_alternative_voice_settings">Alternative voice recording method</string>
</resources>
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index a17ef3ae2..8bc0d0372 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -251,6 +251,11 @@
android:key="video_compression"
android:summary="@string/pref_video_quality_summary"
android:title="@string/pref_video_quality" />
+ <CheckBoxPreference
+ android:defaultValue="@bool/alternative_voice_settings"
+ android:key="alternative_voice_settings"
+ android:summary="@string/pref_alternative_voice_settings_summary"
+ android:title="@string/pref_alternative_voice_settings" />
</PreferenceScreen>
<!--status-->
<PreferenceScreen