Commit e4fe10e5 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Extract Equalizer into DialogFragment

Close #296
parent bd514e5e
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="512dp"
android:minHeight="512dp"
android:orientation="vertical"
android:layout_marginBottom="@dimen/actionBarSize" >
android:padding="@dimen/default_margin" >
<LinearLayout
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="512dp"
android:layout_height="448dp"
android:orientation="vertical"
android:layout_marginBottom="@dimen/actionBarSize" >
android:minHeight="448dp"
android:minWidth="512dp"
android:padding="@dimen/default_margin" >
<LinearLayout
android:layout_width="wrap_content"
......
......@@ -71,12 +71,12 @@ import org.videolan.vlc.extensions.ExtensionListing;
import org.videolan.vlc.extensions.ExtensionManagerService;
import org.videolan.vlc.extensions.api.VLCExtensionItem;
import org.videolan.vlc.gui.audio.AudioBrowserFragment;
import org.videolan.vlc.gui.audio.EqualizerFragment;
import org.videolan.vlc.gui.browser.BaseBrowserFragment;
import org.videolan.vlc.gui.browser.ExtensionBrowser;
import org.videolan.vlc.gui.browser.FileBrowserFragment;
import org.videolan.vlc.gui.browser.MediaBrowserFragment;
import org.videolan.vlc.gui.browser.NetworkBrowserFragment;
import org.videolan.vlc.gui.dialogs.AdvOptionsDialog;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.gui.network.MRLPanelFragment;
import org.videolan.vlc.gui.preferences.PreferencesActivity;
......@@ -609,7 +609,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
}
break;
case R.id.ml_menu_equalizer:
showSecondaryFragment(SecondaryActivity.EQUALIZER);
new EqualizerFragment().show(getSupportFragmentManager(), "equalizer");
break;
// Refresh
case R.id.ml_menu_refresh:
......
......@@ -52,7 +52,6 @@ public class SecondaryActivity extends AudioPlayerContainerActivity {
public static final String KEY_FRAGMENT = "fragment";
public static final String ALBUMS_SONGS = "albumsSongs";
public static final String EQUALIZER = "equalizer";
public static final String ABOUT = "about";
public static final String VIDEO_GROUP_LIST = "videoGroupList";
public static final String STORAGE_BROWSER = "storage_browser";
......@@ -141,8 +140,6 @@ public class SecondaryActivity extends AudioPlayerContainerActivity {
Bundle args = new Bundle();
args.putParcelable(AudioBrowserFragment.TAG_ITEM, getIntent().getParcelableExtra(AudioBrowserFragment.TAG_ITEM));
mFragment.setArguments(args);
} else if(id.equals(EQUALIZER)) {
mFragment = new EqualizerFragment();
} else if(id.equals(ABOUT)) {
mFragment = new AboutFragment();
} else if(id.equals(VIDEO_GROUP_LIST)) {
......
......@@ -22,6 +22,7 @@ package org.videolan.vlc.gui.audio;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDialogFragment;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater;
import android.view.View;
......@@ -41,11 +42,12 @@ import org.videolan.libvlc.MediaPlayer;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.PlaybackServiceFragment;
import org.videolan.vlc.gui.view.EqualizerBar;
import org.videolan.vlc.interfaces.OnEqualizerBarChangeListener;
import org.videolan.vlc.util.VLCOptions;
import org.videolan.vlc.gui.view.EqualizerBar;
public class EqualizerFragment extends PlaybackServiceFragment {
public class EqualizerFragment extends AppCompatDialogFragment implements PlaybackService.Client.Callback {
private PlaybackService mService;
public final static String TAG = "VLC/EqualizerFragment";
private SwitchCompat button;
......@@ -55,10 +57,6 @@ public class EqualizerFragment extends PlaybackServiceFragment {
private MediaPlayer.Equalizer mEqualizer = null;
private static final int BAND_COUNT = MediaPlayer.Equalizer.getBandCount();
/* All subclasses of Fragment must include a public empty constructor. */
public EqualizerFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(getResources().getString(R.string.equalizer));
......@@ -70,6 +68,18 @@ public class EqualizerFragment extends PlaybackServiceFragment {
return v;
}
@Override
public void onStart() {
super.onStart();
PlaybackServiceFragment.registerPlaybackService(this, this);
}
@Override
public void onStop() {
super.onStop();
PlaybackServiceFragment.unregisterPlaybackService(this, this);
}
private void saveViewChildren(View v) {
button = (SwitchCompat) v.findViewById(R.id.equalizer_button);
equalizer_presets = (Spinner) v.findViewById(R.id.equalizer_presets);
......@@ -77,10 +87,14 @@ public class EqualizerFragment extends PlaybackServiceFragment {
bands_layout = (LinearLayout) v.findViewById(R.id.equalizer_bands);
}
@Override
public void onConnected(PlaybackService service) {
super.onConnected(service);
mService = service;
}
@Override
public void onDisconnected() {
mService = null;
}
private void fillViews() {
......
......@@ -53,7 +53,7 @@ import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.PlaybackServiceFragment;
import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.gui.audio.EqualizerFragment;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import org.videolan.vlc.gui.view.AutoFitRecyclerView;
......@@ -226,6 +226,10 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
newFragment = SelectChapterDialog.newInstance(mTheme);
tag = "select_chapter";
break;
case ID_EQUALIZER:
newFragment = new EqualizerFragment();
tag = "equalizer";
break;
case ID_SAVE_PLAYLIST:
UiTools.addToPlaylist(getActivity(), mService.getMedias());
dismiss();
......@@ -481,10 +485,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
}
break;
case ID_EQUALIZER:
Intent i = new Intent(getActivity(), SecondaryActivity.class);
i.putExtra("fragment", SecondaryActivity.EQUALIZER);
startActivity(i);
dismiss();
showFragment(ID_EQUALIZER);
break;
case ID_SAVE_PLAYLIST:
showFragment(ID_SAVE_PLAYLIST);
......@@ -545,6 +546,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
mAdapter.addOption(new Option(ID_SLEEP, R.attr.ic_sleep_normal_style, getString(R.string.sleep_title)));
mAdapter.addOption(new Option(ID_PLAYBACK_SPEED, R.attr.ic_speed_normal_style, getString(R.string.playback_speed)));
mAdapter.addOption(new Option(ID_JUMP_TO, R.attr.ic_jumpto_normal_style, getString(R.string.jump_to_time)));
mAdapter.addOption(new Option(ID_EQUALIZER, R.attr.ic_equalizer_normal_style, getString(R.string.equalizer)));
if (mMode == MODE_VIDEO) {
if (!tvUi)
......@@ -564,7 +566,6 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
large_items++;
}
} else {
mAdapter.addOption(new Option(ID_EQUALIZER, R.attr.ic_equalizer_normal_style, getString(R.string.equalizer)));
mAdapter.addOption(new Option(ID_SAVE_PLAYLIST, R.attr.ic_save, getString(R.string.playlist_save)));
}
setDialogDimensions(large_items);
......
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