From f52cb2826a1b31ea905ffc2774592aa8770594ac Mon Sep 17 00:00:00 2001 From: Dimowner Date: Sat, 17 Aug 2019 23:05:22 +0300 Subject: [PATCH] Not show options menu when no selected record --- .../dimowner/audiorecorder/app/main/MainActivity.java | 10 ++++++++++ .../dimowner/audiorecorder/app/main/MainContract.java | 3 +++ .../dimowner/audiorecorder/app/main/MainPresenter.java | 6 ++++++ .../java/com/dimowner/audiorecorder/data/Prefs.java | 1 + .../com/dimowner/audiorecorder/data/PrefsImpl.java | 6 +++++- 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/dimowner/audiorecorder/app/main/MainActivity.java b/app/src/main/java/com/dimowner/audiorecorder/app/main/MainActivity.java index cbdc37ee..64a4e1df 100644 --- a/app/src/main/java/com/dimowner/audiorecorder/app/main/MainActivity.java +++ b/app/src/main/java/com/dimowner/audiorecorder/app/main/MainActivity.java @@ -484,6 +484,16 @@ public void hideImportProgress() { btnImport.setVisibility(View.VISIBLE); } + @Override + public void showOptionsMenu() { + btnShare.setVisibility(View.VISIBLE); + } + + @Override + public void hideOptionsMenu() { + btnShare.setVisibility(View.INVISIBLE); + } + @Override public void showRecordProcessing() { pnlRecordProcessing.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/dimowner/audiorecorder/app/main/MainContract.java b/app/src/main/java/com/dimowner/audiorecorder/app/main/MainContract.java index 51a0d0c6..6f1836b4 100644 --- a/app/src/main/java/com/dimowner/audiorecorder/app/main/MainContract.java +++ b/app/src/main/java/com/dimowner/audiorecorder/app/main/MainContract.java @@ -50,6 +50,9 @@ interface View extends Contract.View { void showImportStart(); void hideImportProgress(); + void showOptionsMenu(); + void hideOptionsMenu(); + void showRecordProcessing(); void hideRecordProcessing(); diff --git a/app/src/main/java/com/dimowner/audiorecorder/app/main/MainPresenter.java b/app/src/main/java/com/dimowner/audiorecorder/app/main/MainPresenter.java index cf7c44f9..af3e74b8 100644 --- a/app/src/main/java/com/dimowner/audiorecorder/app/main/MainPresenter.java +++ b/app/src/main/java/com/dimowner/audiorecorder/app/main/MainPresenter.java @@ -96,6 +96,10 @@ public void bindView(final MainContract.View v) { view.hideImportProgress(); } + if (!prefs.hasAskToRenameAfterStopRecordingSetting()) { + prefs.setAskToRenameAfterStopRecording(true); + } + if (appRecorder.isRecording()) { view.showRecordingStart(); view.keepScreenOn(prefs.isKeepScreenOn()); @@ -441,6 +445,7 @@ public void run() { view.showWaveForm(record.getAmps(), songDuration); view.showName(FileUtil.removeFileExtension(record.getName())); view.showDuration(TimeUtils.formatTimeIntervalHourMinSec2(songDuration / 1000)); + view.showOptionsMenu(); view.hideProgress(); } } @@ -482,6 +487,7 @@ public void run() { view.showName(""); view.showDuration(TimeUtils.formatTimeIntervalHourMinSec2(0)); view.hideProgress(); + view.hideOptionsMenu(); } } }); diff --git a/app/src/main/java/com/dimowner/audiorecorder/data/Prefs.java b/app/src/main/java/com/dimowner/audiorecorder/data/Prefs.java index b34f163d..69967b27 100644 --- a/app/src/main/java/com/dimowner/audiorecorder/data/Prefs.java +++ b/app/src/main/java/com/dimowner/audiorecorder/data/Prefs.java @@ -25,6 +25,7 @@ public interface Prefs { void setStoreDirPublic(boolean b); boolean isAskToRenameAfterStopRecording(); + boolean hasAskToRenameAfterStopRecordingSetting(); void setAskToRenameAfterStopRecording(boolean b); long getActiveRecord(); diff --git a/app/src/main/java/com/dimowner/audiorecorder/data/PrefsImpl.java b/app/src/main/java/com/dimowner/audiorecorder/data/PrefsImpl.java index 6f764a0b..0b3f1c7f 100644 --- a/app/src/main/java/com/dimowner/audiorecorder/data/PrefsImpl.java +++ b/app/src/main/java/com/dimowner/audiorecorder/data/PrefsImpl.java @@ -72,7 +72,6 @@ public void firstRunExecuted() { SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean(PREF_KEY_IS_FIRST_RUN, false); editor.putBoolean(PREF_KEY_IS_STORE_DIR_PUBLIC, true); - editor.putBoolean(PREF_KEY_IS_ASK_TO_RENAME_AFTER_STOP_RECORDING, true); editor.apply(); // setStoreDirPublic(true); } @@ -94,6 +93,11 @@ public boolean isAskToRenameAfterStopRecording() { return sharedPreferences.contains(PREF_KEY_IS_ASK_TO_RENAME_AFTER_STOP_RECORDING) && sharedPreferences.getBoolean(PREF_KEY_IS_ASK_TO_RENAME_AFTER_STOP_RECORDING, true); } + @Override + public boolean hasAskToRenameAfterStopRecordingSetting() { + return sharedPreferences.contains(PREF_KEY_IS_ASK_TO_RENAME_AFTER_STOP_RECORDING); + } + @Override public void setAskToRenameAfterStopRecording(boolean b) { SharedPreferences.Editor editor = sharedPreferences.edit();