Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 335c1994 authored by 2bllw8's avatar 2bllw8 Committed by luca020400
Browse files

Recorder: add recording elapsed time below the title

Change-Id: I9b47ec483d64f214431c91af2e01288169187502
parent 0b5c4233
Loading
Loading
Loading
Loading
+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.
@@ -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;
@@ -60,6 +61,7 @@ public class RecorderActivity extends AppCompatActivity {
    private ImageView mPauseResume;

    private TextView mRecordingText;
    private TextView mElapsedTimeText;
    private WaveFormView mRecordingVisualizer;

    private LocationHelper mLocationHelper;
@@ -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;
@@ -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());
@@ -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);
    }
@@ -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);
+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);
}
+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.
@@ -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;
@@ -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);
+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.
@@ -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"