Loading app/src/main/java/org/lineageos/recorder/RecorderActivity.java +15 −2 Original line number Diff line number Diff line /* * Copyright (C) 2017-2021 The LineageOS Project * Copyright (C) 2017-2022 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -32,6 +32,7 @@ import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import android.telephony.TelephonyManager; import android.text.format.DateUtils; import android.view.View; import android.widget.ImageView; import android.widget.TextView; Loading Loading @@ -60,6 +61,7 @@ public class RecorderActivity extends AppCompatActivity { private ImageView mPauseResume; private TextView mRecordingText; private TextView mElapsedTimeText; private WaveFormView mRecordingVisualizer; private LocationHelper mLocationHelper; Loading Loading @@ -94,6 +96,9 @@ public class RecorderActivity extends AppCompatActivity { case SoundRecorderService.MSG_SOUND_AMPLITUDE: setVisualizerAmplitude((int) msg.obj); break; case SoundRecorderService.MSG_TIME_ELAPSED: setElapsedTime((long) msg.obj); break; default: super.handleMessage(msg); break; Loading Loading @@ -140,6 +145,7 @@ public class RecorderActivity extends AppCompatActivity { ImageView settings = findViewById(R.id.sound_settings); mRecordingText = findViewById(R.id.main_title); mElapsedTimeText = findViewById(R.id.main_elapsed_time); mRecordingVisualizer = findViewById(R.id.main_recording_visualizer); mSoundFab.setOnClickListener(v -> toggleSoundRecorder()); Loading Loading @@ -213,6 +219,11 @@ public class RecorderActivity extends AppCompatActivity { mRecordingVisualizer.post(() -> mRecordingVisualizer.setAmplitude(amplitude)); } private void setElapsedTime(long seconds) { mElapsedTimeText.post(() -> mElapsedTimeText.setText( DateUtils.formatElapsedTime(seconds))); } private void toggleAfterPermissionRequest() { new Handler(Looper.getMainLooper()).postDelayed(this::toggleSoundRecorder, 500); } Loading Loading @@ -258,10 +269,12 @@ public class RecorderActivity extends AppCompatActivity { if (UiStatus.READY == status) { mRecordingText.setText(getString(R.string.main_sound_action)); mSoundFab.setImageResource(R.drawable.ic_action_record); mRecordingVisualizer.setVisibility(View.INVISIBLE); mElapsedTimeText.setVisibility(View.GONE); mRecordingVisualizer.setVisibility(View.GONE); mPauseResume.setVisibility(View.GONE); } else { mSoundFab.setImageResource(R.drawable.ic_action_stop); mElapsedTimeText.setVisibility(View.VISIBLE); mRecordingVisualizer.setVisibility(View.VISIBLE); mRecordingVisualizer.setAmplitude(0); mPauseResume.setVisibility(View.VISIBLE); Loading app/src/main/java/org/lineageos/recorder/service/IAudioVisualizer.javadeleted 100644 → 0 +0 −21 Original line number Diff line number Diff line /* * Copyright (C) 2021 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.lineageos.recorder.service; public interface IAudioVisualizer { void setAmplitude(int amplitude); } app/src/main/java/org/lineageos/recorder/ui/WaveFormView.java +2 −4 Original line number Diff line number Diff line /* * Copyright (C) 2021 The LineageOS Project * Copyright (C) 2021-2022 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -26,9 +26,8 @@ import android.util.AttributeSet; import android.view.View; import org.lineageos.recorder.R; import org.lineageos.recorder.service.IAudioVisualizer; public class WaveFormView extends View implements IAudioVisualizer { public class WaveFormView extends View { private static final int DEFAULT_NUMBER_OF_WAVES = 5; private static final int DEFAULT_MAX_AUDIO_VALUE = 1500; Loading Loading @@ -136,7 +135,6 @@ public class WaveFormView extends View implements IAudioVisualizer { invalidate(); } @Override public void setAmplitude(int amplitude) { synchronized (mAmpLock) { mAmplitude = Math.min(amplitude / mMaxAudioValue, mIdleAmplitude); Loading app/src/main/res/layout/activity_main.xml +13 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (c) 2017-2021 The LineageOS Project Copyright (c) 2017-2022 The LineageOS Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. Loading Loading @@ -34,6 +34,18 @@ app:layout_constraintTop_toTopOf="parent" tools:text="@string/main_sound_action" /> <TextView android:id="@+id/main_elapsed_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="28sp" android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/main_title" tools:text="12:34" tools:visibility="visible" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/sound_fab" android:layout_width="wrap_content" Loading Loading
app/src/main/java/org/lineageos/recorder/RecorderActivity.java +15 −2 Original line number Diff line number Diff line /* * Copyright (C) 2017-2021 The LineageOS Project * Copyright (C) 2017-2022 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -32,6 +32,7 @@ import android.os.Message; import android.os.Messenger; import android.os.RemoteException; import android.telephony.TelephonyManager; import android.text.format.DateUtils; import android.view.View; import android.widget.ImageView; import android.widget.TextView; Loading Loading @@ -60,6 +61,7 @@ public class RecorderActivity extends AppCompatActivity { private ImageView mPauseResume; private TextView mRecordingText; private TextView mElapsedTimeText; private WaveFormView mRecordingVisualizer; private LocationHelper mLocationHelper; Loading Loading @@ -94,6 +96,9 @@ public class RecorderActivity extends AppCompatActivity { case SoundRecorderService.MSG_SOUND_AMPLITUDE: setVisualizerAmplitude((int) msg.obj); break; case SoundRecorderService.MSG_TIME_ELAPSED: setElapsedTime((long) msg.obj); break; default: super.handleMessage(msg); break; Loading Loading @@ -140,6 +145,7 @@ public class RecorderActivity extends AppCompatActivity { ImageView settings = findViewById(R.id.sound_settings); mRecordingText = findViewById(R.id.main_title); mElapsedTimeText = findViewById(R.id.main_elapsed_time); mRecordingVisualizer = findViewById(R.id.main_recording_visualizer); mSoundFab.setOnClickListener(v -> toggleSoundRecorder()); Loading Loading @@ -213,6 +219,11 @@ public class RecorderActivity extends AppCompatActivity { mRecordingVisualizer.post(() -> mRecordingVisualizer.setAmplitude(amplitude)); } private void setElapsedTime(long seconds) { mElapsedTimeText.post(() -> mElapsedTimeText.setText( DateUtils.formatElapsedTime(seconds))); } private void toggleAfterPermissionRequest() { new Handler(Looper.getMainLooper()).postDelayed(this::toggleSoundRecorder, 500); } Loading Loading @@ -258,10 +269,12 @@ public class RecorderActivity extends AppCompatActivity { if (UiStatus.READY == status) { mRecordingText.setText(getString(R.string.main_sound_action)); mSoundFab.setImageResource(R.drawable.ic_action_record); mRecordingVisualizer.setVisibility(View.INVISIBLE); mElapsedTimeText.setVisibility(View.GONE); mRecordingVisualizer.setVisibility(View.GONE); mPauseResume.setVisibility(View.GONE); } else { mSoundFab.setImageResource(R.drawable.ic_action_stop); mElapsedTimeText.setVisibility(View.VISIBLE); mRecordingVisualizer.setVisibility(View.VISIBLE); mRecordingVisualizer.setAmplitude(0); mPauseResume.setVisibility(View.VISIBLE); Loading
app/src/main/java/org/lineageos/recorder/service/IAudioVisualizer.javadeleted 100644 → 0 +0 −21 Original line number Diff line number Diff line /* * Copyright (C) 2021 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.lineageos.recorder.service; public interface IAudioVisualizer { void setAmplitude(int amplitude); }
app/src/main/java/org/lineageos/recorder/ui/WaveFormView.java +2 −4 Original line number Diff line number Diff line /* * Copyright (C) 2021 The LineageOS Project * Copyright (C) 2021-2022 The LineageOS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -26,9 +26,8 @@ import android.util.AttributeSet; import android.view.View; import org.lineageos.recorder.R; import org.lineageos.recorder.service.IAudioVisualizer; public class WaveFormView extends View implements IAudioVisualizer { public class WaveFormView extends View { private static final int DEFAULT_NUMBER_OF_WAVES = 5; private static final int DEFAULT_MAX_AUDIO_VALUE = 1500; Loading Loading @@ -136,7 +135,6 @@ public class WaveFormView extends View implements IAudioVisualizer { invalidate(); } @Override public void setAmplitude(int amplitude) { synchronized (mAmpLock) { mAmplitude = Math.min(amplitude / mMaxAudioValue, mIdleAmplitude); Loading
app/src/main/res/layout/activity_main.xml +13 −1 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (c) 2017-2021 The LineageOS Project Copyright (c) 2017-2022 The LineageOS Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. Loading Loading @@ -34,6 +34,18 @@ app:layout_constraintTop_toTopOf="parent" tools:text="@string/main_sound_action" /> <TextView android:id="@+id/main_elapsed_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="28sp" android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/main_title" tools:text="12:34" tools:visibility="visible" /> <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/sound_fab" android:layout_width="wrap_content" Loading