Skip to content

Commit bc6ee07

Browse files
committed
minor
1 parent baf6e9e commit bc6ee07

File tree

13 files changed

+160
-81
lines changed

13 files changed

+160
-81
lines changed

android/phiola/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "com.github.stsaz.phiola"
99
minSdkVersion 16
1010
targetSdk 33
11-
versionCode 20505
12-
versionName '2.5-beta5'
11+
versionCode 20506
12+
versionName '2.5-rc6'
1313
}
1414

1515
buildFeatures {

android/phiola/src/main/java/com/github/stsaz/phiola/Explorer.java

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@
1111

1212
import androidx.core.app.ActivityCompat;
1313

14+
import java.util.ArrayList;
15+
1416
class Explorer {
1517
private static final String TAG = "phiola.Explorer";
1618
private final Core core;
1719
private final GUI gui;
1820
private final MainActivity main;
1921

2022
private boolean up_dir; // Show "UP" directory link
21-
private String parent, display_path;
22-
private String[] display_rows, file_names;
23-
private int n_dirs;
23+
private String parent, display_path, cur_filter;
24+
private String[] display_rows, file_names, display_rows_full, file_names_full;
25+
private int n_dirs, n_dirs_full;
2426

2527
Explorer(Core core, MainActivity main) {
2628
this.core = core;
@@ -87,6 +89,7 @@ void event(int ev, int pos) {
8789
}
8890

8991
void fill() {
92+
this.cur_filter = null;
9093
if (gui.cur_path.isEmpty())
9194
list_show_root();
9295
else
@@ -107,32 +110,40 @@ private void list_show(String path) {
107110
}
108111

109112
UtilNative.Files f = core.util.dirList(path, 0);
110-
file_names = f.file_names;
111-
display_rows = f.display_rows;
112-
n_dirs = f.n_directories;
113-
core.dbglog(TAG, "%d entries, %d directories", file_names.length, n_dirs);
113+
this.file_names_full = f.file_names;
114+
this.display_rows_full = f.display_rows;
115+
this.n_dirs_full = f.n_directories;
114116

115-
display_path = String.format("[%s]", path);
117+
this.display_path = String.format("[%s]", path);
116118
gui.cur_path = path;
117119

118120
/* Prevent from going upper than sdcard because
119121
it may be impossible to come back (due to file permissions) */
120-
parent = null;
122+
this.parent = null;
121123
if (Util.array_ifind(core.storage_paths, path) < 0)
122-
parent = Util.path_split2(path)[0];
124+
this.parent = Util.path_split2(path)[0];
125+
126+
this.up_dir = true;
127+
128+
filter(this.cur_filter);
129+
}
123130

124-
up_dir = true;
131+
private void full_view() {
132+
this.file_names = this.file_names_full;
133+
this.display_rows = this.display_rows_full;
134+
this.n_dirs = this.n_dirs_full;
125135
}
126136

127137
/** Show the list of all available storage directories. */
128138
private void list_show_root() {
129-
file_names = core.storage_paths;
130-
n_dirs = core.storage_paths.length;
131-
display_rows = core.storage_paths;
139+
this.file_names_full = core.storage_paths;
140+
this.display_rows_full = core.storage_paths;
141+
this.n_dirs_full = core.storage_paths.length;
142+
full_view();
132143

133-
display_path = main.getString(R.string.explorer_stg_dirs);
144+
this.display_path = main.getString(R.string.explorer_stg_dirs);
134145
gui.cur_path = "";
135-
up_dir = false;
146+
this.up_dir = false;
136147
}
137148

138149
int file_idx(String fn) {
@@ -143,4 +154,34 @@ int file_idx(String fn) {
143154
}
144155
return -1;
145156
}
157+
158+
void filter(String filter) {
159+
if (filter == null)
160+
filter = "";
161+
boolean advance = (this.cur_filter != null
162+
&& filter.length() > this.cur_filter.length());
163+
this.cur_filter = filter;
164+
if (filter.isEmpty() || !advance) {
165+
full_view();
166+
if (filter.isEmpty())
167+
return;
168+
}
169+
170+
ArrayList<String> rows = new ArrayList<>(), fns = new ArrayList<>();
171+
filter = filter.toLowerCase();
172+
int i = 0, nd = 0;
173+
for (String s : display_rows) {
174+
if (s.toLowerCase().contains(filter)) {
175+
rows.add(s);
176+
fns.add(this.file_names[i]);
177+
}
178+
i++;
179+
if (i == this.n_dirs)
180+
nd = rows.size();
181+
}
182+
183+
this.display_rows = rows.toArray(new String[0]);
184+
this.file_names = fns.toArray(new String[0]);
185+
this.n_dirs = nd;
186+
}
146187
}

android/phiola/src/main/java/com/github/stsaz/phiola/MLib.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void fill() {
6666

6767
this.display_rows = this.display_rows_full;
6868
this.file_names = this.file_names_full;
69+
this.cur_filter = null;
6970
}
7071

7172
void filter(String filter) {

android/phiola/src/main/java/com/github/stsaz/phiola/MainActivity.java

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private boolean file_menu_click(MenuItem item) {
172172
file_del_cur(); break;
173173

174174
case R.id.action_file_move:
175-
file_move_cur(); break;
175+
file_move(null, queue.active_pos()); break;
176176

177177
default:
178178
return false;
@@ -261,6 +261,8 @@ private void list_sort_menu_show() {
261261
}
262262

263263
private boolean item_menu_click(MenuItem item) {
264+
String fn;
265+
264266
switch (item.getItemId()) {
265267

266268
case R.id.action_list_remove:
@@ -269,12 +271,23 @@ private boolean item_menu_click(MenuItem item) {
269271
case R.id.action_file_explore:
270272
explorer_file_show(queue.visible_url(item_menu_qi)); break;
271273

272-
case R.id.action_file_delete: {
273-
String fn = queue.visible_url(item_menu_qi);
274+
case R.id.action_file_delete:
275+
fn = queue.visible_url(item_menu_qi);
274276
if (!fn.isEmpty())
275277
file_delete_ask(item_menu_qi, fn);
276278
break;
277-
}
279+
280+
case R.id.action_file_move:
281+
fn = queue.visible_url(item_menu_qi);
282+
if (!fn.isEmpty())
283+
file_move(fn, item_menu_qi);
284+
break;
285+
286+
case R.id.action_list_next_add_sel:
287+
fn = queue.visible_url(item_menu_qi);
288+
if (!fn.isEmpty())
289+
list_next_add(fn);
290+
break;
278291

279292
default:
280293
return false;
@@ -604,17 +617,13 @@ private void explorer_click() {
604617
b.bexplorer.setTextOff(name);
605618
}
606619

607-
if (gui.view == GUI.V_EXPLORER) {
620+
if (!gui.filter_hide)
621+
b.tfilter.setQuery("", false);
622+
623+
if (gui.view == GUI.V_EXPLORER)
608624
explorer.fill();
609-
if (!gui.filter_hide)
610-
b.tfilter.setVisibility(View.INVISIBLE);
611-
} else {
612-
if (!gui.filter_hide) {
613-
b.tfilter.setVisibility(View.VISIBLE);
614-
b.tfilter.setQuery("", false);
615-
}
625+
else
616626
library.fill();
617-
}
618627

619628
list_update();
620629
if (gui.view == GUI.V_LIBRARY)
@@ -634,7 +643,6 @@ private void plist_click() {
634643
gui.view = GUI.V_PLAYLIST;
635644
if (!gui.filter_hide) {
636645
b.tfilter.setQuery(gui.list_filter, false);
637-
b.tfilter.setVisibility(View.VISIBLE);
638646
queue.current_filter(gui.list_filter);
639647
}
640648

@@ -708,22 +716,22 @@ private void file_delete_ask(int pos, String fn) {
708716
b.show();
709717
}
710718

711-
private void file_move_cur() {
719+
private void file_move(String fn, int pos) {
712720
gui.dlg_question(this, "Move file"
713-
, String.format("Move the current file to %s ?", gui.cur_path)
721+
, String.format("Move file to %s ?", gui.cur_path)
714722
, "Move File", "Do nothing"
715-
, (dialog, which) -> { file_move_cur_confirmed(); }
723+
, (dialog, which) -> { file_move_confirmed(fn, pos); }
716724
);
717725
}
718726

719-
private void file_move_cur_confirmed() {
720-
String fn = queue.active_track_url();
727+
private void file_move_confirmed(String fn, int pos) {
728+
boolean r;
721729
if (fn == null)
722-
return;
723-
724-
String e = core.util.fileMove(fn, gui.cur_path);
725-
if (!e.isEmpty()) {
726-
core.errlog(TAG, "file move: %s", e);
730+
r = queue.active_track_move(pos, gui.cur_path);
731+
else
732+
r = queue.visible_track_move(pos, gui.cur_path);
733+
if (!r) {
734+
core.errlog(TAG, "file move: ERROR");
727735
return;
728736
}
729737

@@ -839,6 +847,8 @@ private void plist_filter(String filter) {
839847
queue.current_filter(filter);
840848
else if (gui.view == GUI.V_LIBRARY)
841849
library.filter(filter);
850+
else if (gui.view == GUI.V_EXPLORER)
851+
explorer.filter(filter);
842852
list_update();
843853
}
844854

@@ -972,12 +982,18 @@ private void list_switch_i(int i) {
972982
list_switched(i);
973983
}
974984

975-
private void list_next_add_cur() {
976-
int qi = queue.next_list_add_cur();
985+
private void list_next_add(String url) {
986+
int qi = queue.next_add(url);
977987
if (qi >= 0)
978988
gui.msg_show(this, String.format(getString(R.string.mlist_trk_added), qi+1));
979989
}
980990

991+
private void list_next_add_cur() {
992+
String url = core.track.cur_url();
993+
if (!url.isEmpty())
994+
list_next_add(url);
995+
}
996+
981997
private void list_files_move() {
982998
gui.dlg_question(this, "Move files"
983999
, String.format("Move all files in the current list to %s ?", gui.cur_path)
@@ -987,7 +1003,7 @@ private void list_files_move() {
9871003
}
9881004

9891005
private void list_files_move_confirmed() {
990-
int n = queue.move_all(gui.cur_path);
1006+
int n = queue.visible_move_all(gui.cur_path);
9911007
String s = String.format("Moved %d files", n);
9921008
if (n < 0)
9931009
s = "Some files were NOT moved";

android/phiola/src/main/java/com/github/stsaz/phiola/Phiola.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ to the index within its parent (not filtered) list */
188188
<0 if some files were not moved. */
189189
native int quMoveAll(long q, String dst_dir);
190190

191+
/** Move file to the specified directory. */
192+
native int quRename(long q, int pos, String target, int flags);
193+
191194
static final int
192195
QUFILTER_URL = 1,
193196
QUFILTER_META = 2;

android/phiola/src/main/java/com/github/stsaz/phiola/Queue.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ interface QueueNotify {
113113
void on_change(int how, int pos);
114114
}
115115

116+
/**
117+
* "visible": Currently selected list (may be filtered)
118+
* "current": Currently selected list (not filtered)
119+
* "active": The list of the currently playing track
120+
*/
116121
class Queue {
117122
private static final String TAG = "phiola.Queue";
118123
private Core core;
@@ -398,17 +403,12 @@ int switch_list(int i) {
398403
int current_index() { return i_selected; }
399404
long current_id() { return queues.get(i_selected).q; }
400405

401-
/** Add currently playing track to next list.
406+
/** Add track to next list.
402407
Return the modified list index. */
403-
int next_list_add_cur() {
408+
int next_add(String url) {
404409
if (queues.size() == 1) return -1;
405410

406-
String url = core.track.cur_url();
407-
if (url.isEmpty())
408-
return -1;
409-
410411
int ni = index_next(i_active);
411-
filter_close();
412412
queues.get(ni).add(url, 0);
413413
return ni;
414414
}
@@ -524,7 +524,7 @@ String display_line(int i) {
524524
return phi.quDisplayLine(q_visible().q, i);
525525
}
526526

527-
int move_all(String dst_dir) {
527+
int visible_move_all(String dst_dir) {
528528
return phi.quMoveAll(q_visible().q, dst_dir);
529529
}
530530

@@ -533,6 +533,14 @@ void active_remove(int pos) {
533533
queues.get(i_active).remove(pos);
534534
}
535535

536+
boolean active_track_move(int pos, String target_dir) {
537+
return 0 == phi.quRename(queues.get(i_active).q, pos, target_dir, 0);
538+
}
539+
540+
boolean visible_track_move(int pos, String target_dir) {
541+
return 0 == phi.quRename(q_visible().q, pos, target_dir, 0);
542+
}
543+
536544
void current_clear() {
537545
core.dbglog(TAG, "clear");
538546
filter_close();

android/phiola/src/main/java/com/github/stsaz/phiola/UtilNative.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class UtilNative {
8282

8383
native void storagePaths(String[] paths);
8484
native String trash(String trash_dir, String filepath);
85-
native String fileMove(String filepath, String target_dir);
8685

8786
static class Files {
8887
String[] display_rows;

android/phiola/src/main/res/menu/item.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@
1111
<item android:id="@+id/action_file_delete"
1212
android:title="@string/mitem_file_delete" />
1313

14+
<item android:id="@+id/action_file_move"
15+
android:title="@string/mitem_file_move" />
16+
17+
<item android:id="@+id/action_list_next_add_sel"
18+
android:title="@string/mlist_next_add_sel" />
19+
1420
</menu>

android/phiola/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<string name="mlist_clear">List: Clear</string>
4040
<string name="mlist_show_track">List: Show Current Track</string>
4141
<string name="mlist_next_add">List: Add Current to Next</string>
42+
<string name="mlist_next_add_sel">Add to Next List</string>
4243
<string name="mlist_trk_added">Added track to Playlist %d</string>
4344
<string name="mlist_sort">List: Sort...</string>
4445
<string name="mlist_sort_filename">List: Sort by File Path</string>
@@ -57,6 +58,7 @@
5758
<string name="mitem_list_remove">Remove from List</string>
5859
<string name="mitem_file_show">Show in Explorer</string>
5960
<string name="mitem_file_delete">Delete File from Storage</string>
61+
<string name="mitem_file_move">Quick-Move File</string>
6062

6163
<string name="sett_interface">Interface</string>
6264
<string name="sett_dark">Dark Theme</string>

src/format/reader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ static const char* fmtr_hdr(struct fmt_rd *f, phi_track *t, struct avpk_info *hd
102102
t->audio.format.format |= 0x0100;
103103
switch (t->audio.format.format) {
104104
case 0:
105+
t->audio.format.format = PHI_PCM_FLOAT32; break;
106+
105107
case PHI_PCM_8:
106108
case PHI_PCM_16:
107109
case PHI_PCM_24:

0 commit comments

Comments
 (0)