show remaining session
This commit is contained in:
parent
a759c67f31
commit
1bc42a41e2
3 changed files with 46 additions and 30 deletions
|
|
@ -666,30 +666,8 @@ public class MainActivity extends AppCompatActivity implements AbsListView.OnScr
|
|||
void updateHeader() {
|
||||
File f = storage.getStoragePath();
|
||||
long free = storage.getFree(f);
|
||||
|
||||
long sec = storage.average(free);
|
||||
|
||||
String str = "";
|
||||
|
||||
long diff = sec;
|
||||
int diffSeconds = (int) (diff / 1000 % 60);
|
||||
int diffMinutes = (int) (diff / (60 * 1000) % 60);
|
||||
int diffHours = (int) (diff / (60 * 60 * 1000) % 24);
|
||||
int diffDays = (int) (diff / (24 * 60 * 60 * 1000));
|
||||
|
||||
if (diffDays > 0) {
|
||||
str = getResources().getQuantityString(R.plurals.days, diffDays, diffDays);
|
||||
} else if (diffHours > 0) {
|
||||
str = getResources().getQuantityString(R.plurals.hours, diffHours, diffHours);
|
||||
} else if (diffMinutes > 0) {
|
||||
str = getResources().getQuantityString(R.plurals.minutes, diffMinutes, diffMinutes);
|
||||
} else if (diffSeconds > 0) {
|
||||
str = getResources().getQuantityString(R.plurals.seconds, diffSeconds, diffSeconds);
|
||||
}
|
||||
|
||||
String ss = String.format("%s free ~ %s left", MainApplication.formatSize(free), str);
|
||||
|
||||
TextView text = (TextView) findViewById(R.id.space_left);
|
||||
text.setText(ss);
|
||||
text.setText(((MainApplication)getApplication()).formatFree(free, sec));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
wasRinging = true;
|
||||
if (thread != null) {
|
||||
stopRecording("playerPause (hold by call)");
|
||||
stopRecording("pause (hold by call)");
|
||||
pausedByCall = true;
|
||||
}
|
||||
break;
|
||||
|
|
@ -160,11 +160,11 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
state = (TextView) findViewById(R.id.recording_state);
|
||||
title = (TextView) findViewById(R.id.recording_title);
|
||||
|
||||
edit(false, false);
|
||||
|
||||
storage = new Storage(this);
|
||||
sound = new Sound(this);
|
||||
|
||||
edit(false, false);
|
||||
|
||||
try {
|
||||
targetFile = storage.getNewFile();
|
||||
} catch (RuntimeException e) {
|
||||
|
|
@ -338,7 +338,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
}
|
||||
|
||||
void stopRecording(String status) {
|
||||
state.setText(status);
|
||||
setState(status);
|
||||
pause.setImageResource(R.drawable.ic_mic_24dp);
|
||||
|
||||
stopRecording();
|
||||
|
|
@ -366,7 +366,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
|
||||
void edit(boolean b, boolean animate) {
|
||||
if (b) {
|
||||
state.setText("edit");
|
||||
setState("edit");
|
||||
editPlay(false);
|
||||
|
||||
View box = findViewById(R.id.recording_edit_box);
|
||||
|
|
@ -401,7 +401,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
});
|
||||
} else {
|
||||
editSample = -1;
|
||||
state.setText("pause");
|
||||
setState("pause");
|
||||
editPlay(false);
|
||||
pitch.stop();
|
||||
|
||||
|
|
@ -410,6 +410,21 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
void setState(String s) {
|
||||
long free = storage.getFree(storage.getTempRecording());
|
||||
|
||||
final SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
int rate = Integer.parseInt(shared.getString(MainApplication.PREFERENCE_RATE, ""));
|
||||
int m = RawSamples.CHANNEL_CONFIG == AudioFormat.CHANNEL_IN_MONO ? 1 : 2;
|
||||
int c = RawSamples.AUDIO_FORMAT == AudioFormat.ENCODING_PCM_16BIT ? 2 : 1;
|
||||
|
||||
long perSec = (c * m * rate);
|
||||
long sec = free / perSec * 1000;
|
||||
|
||||
state.setText(s + " (" + ((MainApplication) getApplication()).formatFree(free, sec) + ")");
|
||||
}
|
||||
|
||||
void editPlay(boolean b) {
|
||||
View box = findViewById(R.id.recording_edit_box);
|
||||
final ImageView playButton = (ImageView) box.findViewById(R.id.recording_play);
|
||||
|
|
@ -524,7 +539,7 @@ public class RecordingActivity extends AppCompatActivity {
|
|||
edit(false, true);
|
||||
pitch.setOnTouchListener(null);
|
||||
|
||||
state.setText("recording");
|
||||
setState("recording");
|
||||
|
||||
sound.silent();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,29 @@ public class MainApplication extends Application {
|
|||
return String.format("%02d", tt);
|
||||
}
|
||||
|
||||
public String formatFree(long free, long left) {
|
||||
String str = "";
|
||||
|
||||
long diff = left;
|
||||
|
||||
int diffSeconds = (int) (diff / 1000 % 60);
|
||||
int diffMinutes = (int) (diff / (60 * 1000) % 60);
|
||||
int diffHours = (int) (diff / (60 * 60 * 1000) % 24);
|
||||
int diffDays = (int) (diff / (24 * 60 * 60 * 1000));
|
||||
|
||||
if (diffDays > 0) {
|
||||
str = getResources().getQuantityString(R.plurals.days, diffDays, diffDays);
|
||||
} else if (diffHours > 0) {
|
||||
str = getResources().getQuantityString(R.plurals.hours, diffHours, diffHours);
|
||||
} else if (diffMinutes > 0) {
|
||||
str = getResources().getQuantityString(R.plurals.minutes, diffMinutes, diffMinutes);
|
||||
} else if (diffSeconds > 0) {
|
||||
str = getResources().getQuantityString(R.plurals.seconds, diffSeconds, diffSeconds);
|
||||
}
|
||||
|
||||
return String.format("%s free ~ %s left", MainApplication.formatSize(free), str);
|
||||
}
|
||||
|
||||
public static String formatSize(long s) {
|
||||
if (s > 0.1 * 1024 * 1024 * 1024) {
|
||||
float f = s / 1024f / 1024f / 1024f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue