diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-02-09 21:39:57 +0100 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-02-09 21:39:57 +0100 |
commit | db952297c516600547924aa6c9ebca53fd3bfea8 (patch) | |
tree | 8aae53991a44d1831a2d540ef96da4f499e178eb /src/main/java/de/pixart/messenger | |
parent | b10b73caad1737cce836193414feeb8379b886e0 (diff) |
integrate alternative codec for voice recorder via attachment settings
Diffstat (limited to 'src/main/java/de/pixart/messenger')
3 files changed, 19 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()); |