add favs and sort
This commit is contained in:
parent
9a67b5f594
commit
acaba1b7ec
4 changed files with 69 additions and 58 deletions
|
|
@ -43,5 +43,5 @@ android {
|
|||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.github.axet:android-audio-library:0.0.69' // compile project(':android-audio-library')
|
||||
compile 'com.github.axet:android-audio-library:0.1.0' // compile project(':android-audio-library')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import android.util.Log;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
|
@ -108,22 +109,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
list = (ListView) findViewById(R.id.list);
|
||||
recordings = new Recordings(this, list) {
|
||||
@Override
|
||||
public void sort() {
|
||||
sort(Collections.reverseOrder(new SortFiles()));
|
||||
}
|
||||
};
|
||||
recordings = new Recordings(this, list);
|
||||
list.setAdapter(recordings);
|
||||
list.setEmptyView(findViewById(R.id.empty_list));
|
||||
|
||||
if (Storage.permitted(MainActivity.this, PERMISSIONS, 1)) {
|
||||
try {
|
||||
storage.migrateLocalStorage();
|
||||
} catch (RuntimeException e) {
|
||||
Error(e);
|
||||
}
|
||||
}
|
||||
recordings.setToolbar((ViewGroup) findViewById(R.id.recording_toolbar));
|
||||
|
||||
RecordingService.startIfEnabled(this);
|
||||
|
||||
|
|
@ -198,6 +187,14 @@ public class MainActivity extends AppCompatActivity {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Storage.permitted(MainActivity.this, PERMISSIONS)) {
|
||||
try {
|
||||
storage.migrateLocalStorage();
|
||||
} catch (RuntimeException e) {
|
||||
Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
final int selected = getLastRecording();
|
||||
Runnable done = new Runnable() {
|
||||
@Override
|
||||
|
|
@ -218,10 +215,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
};
|
||||
progressEmpty.setVisibility(View.VISIBLE);
|
||||
progressText.setVisibility(View.GONE);
|
||||
if (Storage.permitted(this, PERMISSIONS))
|
||||
recordings.load(done);
|
||||
else
|
||||
recordings.load(done);
|
||||
recordings.load(done);
|
||||
|
||||
checkPending();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
|
@ -30,6 +31,7 @@ import android.view.MenuItem;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.github.axet.androidlibrary.widgets.SilencePreferenceCompat;
|
||||
import com.github.axet.androidlibrary.widgets.StoragePathPreferenceCompat;
|
||||
import com.github.axet.audiolibrary.app.Storage;
|
||||
import com.github.axet.audiorecorder.R;
|
||||
import com.github.axet.audiorecorder.app.MainApplication;
|
||||
|
|
@ -54,6 +56,8 @@ import java.util.List;
|
|||
*/
|
||||
public class SettingsActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
public static final String[] PERMISSIONS = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
public static <T> T[] removeElement(Class<T> c, T[] aa, int i) {
|
||||
List<T> ll = Arrays.asList(aa);
|
||||
ll = new ArrayList<>(ll);
|
||||
|
|
@ -122,34 +126,6 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
|
|||
.getString(preference.getKey(), ""));
|
||||
}
|
||||
|
||||
static void initPrefs(PreferenceManager pm, PreferenceScreen screen) {
|
||||
final Context context = screen.getContext();
|
||||
ListPreference enc = (ListPreference) pm.findPreference(MainApplication.PREFERENCE_ENCODING);
|
||||
String v = enc.getValue();
|
||||
CharSequence[] ee = Factory.getEncodingTexts(context);
|
||||
CharSequence[] vv = Factory.getEncodingValues(context);
|
||||
if (ee.length > 1) {
|
||||
enc.setEntries(ee);
|
||||
enc.setEntryValues(vv);
|
||||
|
||||
int i = enc.findIndexOfValue(v);
|
||||
if (i == -1) {
|
||||
enc.setValueIndex(0);
|
||||
} else {
|
||||
enc.setValueIndex(i);
|
||||
}
|
||||
|
||||
bindPreferenceSummaryToValue(enc);
|
||||
} else {
|
||||
screen.removePreference(enc);
|
||||
}
|
||||
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_RATE));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_THEME));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_CHANNELS));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_FORMAT));
|
||||
}
|
||||
|
||||
public static int getAppTheme(Context context) {
|
||||
return MainApplication.getTheme(context, R.style.AppThemeLight, R.style.AppThemeDark);
|
||||
}
|
||||
|
|
@ -202,17 +178,8 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
|
|||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
switch (requestCode) {
|
||||
case 1:
|
||||
if (Storage.permitted(this, permissions))
|
||||
;
|
||||
else
|
||||
Toast.makeText(this, R.string.not_permitted, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public static final String[] PERMISSIONS = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (key.equals(MainApplication.PREFERENCE_THEME)) {
|
||||
|
|
@ -250,6 +217,36 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
|
|||
public GeneralPreferenceFragment() {
|
||||
}
|
||||
|
||||
void initPrefs(PreferenceManager pm, PreferenceScreen screen) {
|
||||
final Context context = screen.getContext();
|
||||
ListPreference enc = (ListPreference) pm.findPreference(MainApplication.PREFERENCE_ENCODING);
|
||||
String v = enc.getValue();
|
||||
CharSequence[] ee = Factory.getEncodingTexts(context);
|
||||
CharSequence[] vv = Factory.getEncodingValues(context);
|
||||
if (ee.length > 1) {
|
||||
enc.setEntries(ee);
|
||||
enc.setEntryValues(vv);
|
||||
|
||||
int i = enc.findIndexOfValue(v);
|
||||
if (i == -1) {
|
||||
enc.setValueIndex(0);
|
||||
} else {
|
||||
enc.setValueIndex(i);
|
||||
}
|
||||
|
||||
bindPreferenceSummaryToValue(enc);
|
||||
} else {
|
||||
screen.removePreference(enc);
|
||||
}
|
||||
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_RATE));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_THEME));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_CHANNELS));
|
||||
bindPreferenceSummaryToValue(pm.findPreference(MainApplication.PREFERENCE_FORMAT));
|
||||
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) pm.findPreference(MainApplication.PREFERENCE_STORAGE);
|
||||
s.setPermissionsDialog(this, PERMISSIONS, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
setHasOptionsMenu(true);
|
||||
|
|
@ -267,6 +264,23 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
StoragePathPreferenceCompat s = (StoragePathPreferenceCompat) findPreference(MainApplication.PREFERENCE_STORAGE);
|
||||
|
||||
switch (requestCode) {
|
||||
case 1:
|
||||
if (Storage.permitted(getContext(), permissions))
|
||||
;
|
||||
else
|
||||
Toast.makeText(getContext(), R.string.not_permitted, Toast.LENGTH_SHORT).show();
|
||||
s.onRequestPermissionsResult();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
|
|
|||
|
|
@ -20,11 +20,14 @@
|
|||
android:padding="5dp"
|
||||
android:text="32G free ~ 3 hours left" />
|
||||
|
||||
<include layout="@layout/toolbar" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/empty_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:padding="5dp">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -51,7 +54,7 @@
|
|||
<ListView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="61dp"></ListView>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue