add new filebrowser files
This commit is contained in:
parent
85efbd7573
commit
76cfe8e680
66
res/layout/filebrowser_content.xml
Normal file
66
res/layout/filebrowser_content.xml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2013 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/path_display"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:text="" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/save_button"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="XUSE" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:background="@color/divider_color"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/list"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:divider="@color/divider_color"
|
||||||
|
android:dividerHeight="1dip"
|
||||||
|
android:listSelector="@drawable/selectable_item_bg"
|
||||||
|
android:scrollbarStyle="outsideInset" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ch.blinkenlights.android.vanilla;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.io.File;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
|
||||||
|
public class FilebrowserStartActivity extends PlaybackActivity {
|
||||||
|
|
||||||
|
private ListView mListView;
|
||||||
|
private TextView mPathDisplay;
|
||||||
|
private Button mSaveButton;
|
||||||
|
private FilebrowserStartAdapter mListAdapter;
|
||||||
|
private String mCurrentPath;
|
||||||
|
private SharedPreferences.Editor mPrefEditor;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setTitle("TRNS: FILEPCKER");
|
||||||
|
setContentView(R.layout.filebrowser_content);
|
||||||
|
|
||||||
|
mCurrentPath = (String)getFilesystemBrowseStart().getAbsolutePath();
|
||||||
|
mPrefEditor = PlaybackService.getSettings(this).edit();
|
||||||
|
mListAdapter = new FilebrowserStartAdapter(this, R.layout.showqueue_row);
|
||||||
|
mPathDisplay = (TextView) findViewById(R.id.path_display);
|
||||||
|
mListView = (ListView) findViewById(R.id.list);
|
||||||
|
mSaveButton = (Button) findViewById(R.id.save_button);
|
||||||
|
|
||||||
|
mListView.setAdapter(mListAdapter);
|
||||||
|
mListView.setOnItemClickListener(new OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
jumpToDirectory(position);
|
||||||
|
}});
|
||||||
|
|
||||||
|
mSaveButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mPrefEditor.putString("filesystem_browse_start", mCurrentPath);
|
||||||
|
mPrefEditor.commit();
|
||||||
|
finish();
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Called when we are displayed (again)
|
||||||
|
** This will always refresh the whole song list
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
refreshDirectoryList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Enters selected directory at 'pos'
|
||||||
|
*/
|
||||||
|
private void jumpToDirectory(int pos) {
|
||||||
|
String dirent = mListAdapter.getItem(pos);
|
||||||
|
|
||||||
|
if(pos == 0) {
|
||||||
|
mCurrentPath = (new File(mCurrentPath)).getParent();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mCurrentPath += "/" + dirent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* let java fixup any strange paths */
|
||||||
|
mCurrentPath = (new File(mCurrentPath == null ? "/" : mCurrentPath)).getAbsolutePath();
|
||||||
|
|
||||||
|
refreshDirectoryList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** display mCurrentPath in the dialog
|
||||||
|
*/
|
||||||
|
private void refreshDirectoryList() {
|
||||||
|
File path = new File(mCurrentPath);
|
||||||
|
File[]dirs = path.listFiles();
|
||||||
|
|
||||||
|
mListAdapter.clear();
|
||||||
|
mListAdapter.add("../");
|
||||||
|
|
||||||
|
if(dirs != null) {
|
||||||
|
Arrays.sort(dirs);
|
||||||
|
for(File fentry: dirs) {
|
||||||
|
if(fentry.isDirectory()) {
|
||||||
|
mListAdapter.add(fentry.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(this, "Failed to display "+mCurrentPath, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
mPathDisplay.setText(mCurrentPath);
|
||||||
|
mListView.setSelectionFromTop(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ch.blinkenlights.android.vanilla;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
|
||||||
|
public class FilebrowserStartAdapter extends ArrayAdapter<String> {
|
||||||
|
|
||||||
|
int resource;
|
||||||
|
Context context;
|
||||||
|
private final Drawable mFolderIcon;
|
||||||
|
|
||||||
|
public FilebrowserStartAdapter(Context ctx, int res) {
|
||||||
|
super(ctx, res);
|
||||||
|
context = ctx;
|
||||||
|
resource = res;
|
||||||
|
mFolderIcon = context.getResources().getDrawable(R.drawable.folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
|
||||||
|
View row = inflater.inflate(resource, parent, false);
|
||||||
|
String label = getItem(position);
|
||||||
|
TextView target = ((TextView)row.findViewById(R.id.text));
|
||||||
|
|
||||||
|
target.setText(label);
|
||||||
|
target.setCompoundDrawablesWithIntrinsicBounds(mFolderIcon, null, null, null);
|
||||||
|
|
||||||
|
/* not used here (yet) */
|
||||||
|
View pmark = ((View)row.findViewById(R.id.playmark));
|
||||||
|
pmark.setVisibility(View.INVISIBLE);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user