implement audiopicker class
This commit is contained in:
parent
ecaa32455f
commit
3b62928056
@ -156,5 +156,18 @@ THE SOFTWARE.
|
||||
android:name="FilebrowserStartActivity"
|
||||
android:theme="@style/BackActionBar" />
|
||||
|
||||
<activity android:name="AudioPickerActivity" android:theme="@style/DialogMinWidth"
|
||||
android:excludeFromRecents="true" android:exported="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="file"/>
|
||||
<data android:mimeType="audio/*"/>
|
||||
<data android:mimeType="application/ogg"/>
|
||||
<data android:mimeType="application/x-ogg"/>
|
||||
<data android:mimeType="application/itunes"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
82
res/layout/audiopicker.xml
Normal file
82
res/layout/audiopicker.xml
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2012 Christopher Eby <kreed@kreed.org>
|
||||
|
||||
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:divider="?android:attr/dividerHorizontal"
|
||||
android:showDividers="middle"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginLeft="4dip"
|
||||
android:src="@drawable/icon" />
|
||||
<TextView
|
||||
android:id="@+id/filepath"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dip"
|
||||
android:layout_marginTop="16dip"
|
||||
android:layout_marginLeft="8dip"
|
||||
android:layout_marginRight="8dip" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:id="@+id/cancel"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/cancel"
|
||||
android:singleLine="true" />
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:id="@+id/enqueue"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/enqueue"
|
||||
android:singleLine="true" />
|
||||
<Button
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:id="@+id/play"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/play"
|
||||
android:singleLine="true" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -110,6 +110,7 @@ THE SOFTWARE.
|
||||
|
||||
<!-- styles -->
|
||||
<style name="Dialog" parent="android:Theme.Holo.Dialog" />
|
||||
<style name="DialogMinWidth" parent="android:Theme.Holo.Dialog.MinWidth" />
|
||||
<style name="AlertDialogItem">
|
||||
<item name="android:textColor">?android:textColorAlertDialogListItem</item>
|
||||
</style>
|
||||
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package ch.blinkenlights.android.vanilla;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Button;
|
||||
|
||||
|
||||
public class AudioPickerActivity extends PlaybackActivity {
|
||||
|
||||
private Uri mUri;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mUri = intent.getData();
|
||||
if (mUri == null || mUri.getScheme().equals("file") == false) { // we do not support streaming
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.audiopicker);
|
||||
|
||||
TextView filePath = (TextView)findViewById(R.id.filepath);
|
||||
filePath.setText(mUri.getLastPathSegment());
|
||||
|
||||
// Bind all 3 clickbuttons
|
||||
Button cancelButton = (Button)findViewById(R.id.cancel);
|
||||
cancelButton.setOnClickListener(this);
|
||||
Button enqueueButton = (Button)findViewById(R.id.enqueue);
|
||||
enqueueButton.setOnClickListener(this);
|
||||
enqueueButton.setEnabled( PlaybackService.hasInstance() ); // only active if vanilla is still running
|
||||
Button playButton = (Button)findViewById(R.id.play);
|
||||
playButton.setOnClickListener(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
int mode;
|
||||
|
||||
switch(view.getId()) {
|
||||
case R.id.enqueue:
|
||||
mode = LibraryActivity.ACTION_ENQUEUE;
|
||||
break;
|
||||
case R.id.play:
|
||||
mode = LibraryActivity.ACTION_PLAY;
|
||||
break;
|
||||
default:
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
String path = mUri.getPath();
|
||||
PlaybackService service = PlaybackService.get(this);
|
||||
|
||||
QueryTask query = MediaUtils.buildFileQuery(path, Song.FILLED_PROJECTION);
|
||||
query.mode = mode;
|
||||
|
||||
service.addSongs(query);
|
||||
service.play();
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user