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

Commit 51530a28 authored by Nicholas Sauer's avatar Nicholas Sauer Committed by Android (Google) Code Review
Browse files

Merge "[FM] FM recording time will display incorrectly when recording time is...

Merge "[FM] FM recording time will display incorrectly when recording time is beyond 60 minutes" into lmp-mr1-dev
parents 663032eb ec7335dd
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public class FmRecordActivity extends Activity implements
    private static final String FM_ENTER_RECORD_SCREEN = "fmradio.enter.record.screen";
    private static final String TAG_SAVE_RECORDINGD = "SaveRecording";
    private static final int MSG_UPDATE_NOTIFICATION = 1000;
    private static final int TIME_BASE = 60;
    private Context mContext;
    private TextView mMintues;
    private TextView mSeconds;
@@ -226,6 +227,7 @@ public class FmRecordActivity extends Activity implements
        }
        // Trigger to refreshing timer text if still in record
        if (!isStopRecording()) {
            mHandler.removeMessages(FmListener.MSGID_REFRESH);
            mHandler.sendEmptyMessage(FmListener.MSGID_REFRESH);
        }
        // Clear notification, it only need show when in background
@@ -331,6 +333,7 @@ public class FmRecordActivity extends Activity implements
            }
            mPlayIndicator.startAnimation();
            mStopRecordButton.setEnabled(true);
            mHandler.removeMessages(FmListener.MSGID_REFRESH);
            mHandler.sendEmptyMessage(FmListener.MSGID_REFRESH);
        };

@@ -340,6 +343,14 @@ public class FmRecordActivity extends Activity implements
        };
    };

    private String addPaddingForString(long time) {
        StringBuilder builder = new StringBuilder();
        if (time >= 0 && time < 10) {
            builder.append("0");
        }
        return builder.append(time).toString();
    }

    private final Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
@@ -347,11 +358,9 @@ public class FmRecordActivity extends Activity implements
                case FmListener.MSGID_REFRESH:
                    if (mService != null) {
                        long recordTime = mService.getRecordTime();
                        Date date = new Date(recordTime);
                        SimpleDateFormat format = new SimpleDateFormat("mm:ss");
                        String[] timeText = format.format(date).split(":");
                        mMintues.setText(timeText[0]);
                        mSeconds.setText(timeText[1]);
                        recordTime = recordTime / 1000L;
                        mMintues.setText(addPaddingForString(recordTime / TIME_BASE));
                        mSeconds.setText(addPaddingForString(recordTime % TIME_BASE));

                        // Check storage free space
                        String recordingSdcard = FmUtils.getDefaultStoragePath();