Commit d0709c84 authored by Michael Merg's avatar Michael Merg
Browse files

UI: add option to hide the miniplayer (LongClick)

parent 88c40334
......@@ -17,4 +17,8 @@
<string name="search_history">History</string>
<string name="clear_history">Clear History</string>
<string name="search_found_results">%1$d Results Found</string>
<string name="show_player">Show Player</string>
<string name="hide_mini_player">Hide Mini-Player</string>
<string name="play">Play</string>
<string name="pause">Pause</string>
</resources>
......@@ -10,15 +10,14 @@ import org.videolan.vlc.android.widget.FlingViewGroup.ViewSwitchListener;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
public class AudioBrowserActivity extends Activity {
public final static String TAG = "VLC/AudioBrowserActivity";
......
......@@ -8,6 +8,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore.Audio.AudioColumns;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
......@@ -34,6 +35,7 @@ public class MainActivity extends TabActivity {
private int mCurrentState = 0;
private ImageButton mChangeTab;
private AudioMiniPlayer mAudioPlayer;
private AudioServiceController mAudioController;
@Override
......@@ -65,9 +67,9 @@ public class MainActivity extends TabActivity {
// add mini audio player
mAudioPlayer = (AudioMiniPlayer) findViewById(R.id.audio_mini_player);
AudioServiceController audioController = AudioServiceController.getInstance();
audioController.addAudioPlayer(mAudioPlayer);
mAudioPlayer.setAudioPlayerControl(audioController);
mAudioController = AudioServiceController.getInstance();
mAudioController.addAudioPlayer(mAudioPlayer);
mAudioPlayer.setAudioPlayerControl(mAudioController);
/* Load media items from database and storage */
MediaLibrary.getInstance().loadMediaItems();
......@@ -132,9 +134,29 @@ public class MainActivity extends TabActivity {
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.play_pause:
if (mAudioController.isPlaying()) {
mAudioController.pause();
} else {
mAudioController.play();
}
case R.id.show_player:
// TODO: start audio player activity
break;
case R.id.hide_mini_player:
hideAudioPlayer();
break;
}
return super.onContextItemSelected(item);
}
public void hideAudioPlayer() {
mAudioPlayer.setVisibility(AudioMiniPlayer.GONE);
mAudioController.stop();
}
public void showAudioPlayer() {
......@@ -173,7 +195,7 @@ public class MainActivity extends TabActivity {
* Get instance e.g. for Context or Handler
* @return this ;)
*/
protected static MainActivity getInstance() {
public static MainActivity getInstance() {
return mInstance;
}
......
package org.videolan.vlc.android.widget;
import org.videolan.vlc.android.MainActivity;
import org.videolan.vlc.android.R;
import org.videolan.vlc.android.Util;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
......@@ -68,8 +73,7 @@ public class AudioMiniPlayer extends LinearLayout {
mPlayPause.setOnClickListener(onPlayPauseClickListener);
mSeekbar = (SeekBar) findViewById(R.id.timeline);
LinearLayout miniPlayer = (LinearLayout) findViewById(R.id.mini_player);
miniPlayer.setOnClickListener(new OnClickListener() {
this.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
......@@ -78,8 +82,32 @@ public class AudioMiniPlayer extends LinearLayout {
}
});
this.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
showContextMenu();
return true;
}
});
}
@Override
protected void onCreateContextMenu(ContextMenu menu) {
MenuInflater inflater = MainActivity.getInstance().getMenuInflater();
inflater.inflate(R.menu.audio_player_mini, menu);
MenuItem hmi = menu.findItem(R.id.hide_mini_player);
MenuItem pp = menu.findItem(R.id.play_pause);
if (mAudioPlayerControl.isPlaying()) {
hmi.setEnabled(false);
pp.setTitle(R.string.pause);
} else {
pp.setTitle(R.string.play);
}
super.onCreateContextMenu(menu);
}
public void setAudioPlayerControl(AudioMiniPlayerControl control) {
mAudioPlayerControl = control;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment