Commit a763e9f4 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Code cleanup

parent c2917f97
...@@ -22,18 +22,13 @@ package org.videolan.vlc.gui; ...@@ -22,18 +22,13 @@ package org.videolan.vlc.gui;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import org.videolan.vlc.AudioServiceController; import org.videolan.vlc.AudioServiceController;
import org.videolan.vlc.LibVLC; import org.videolan.vlc.LibVLC;
import org.videolan.vlc.MediaLibrary; import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R; import org.videolan.vlc.R;
import org.videolan.vlc.VLCCallbackTask; import org.videolan.vlc.VLCCallbackTask;
import org.videolan.vlc.gui.audio.AudioActivityGroup;
import org.videolan.vlc.gui.audio.AudioBrowserActivity; import org.videolan.vlc.gui.audio.AudioBrowserActivity;
import org.videolan.vlc.gui.audio.AudioListActivity;
import org.videolan.vlc.gui.audio.AudioPlayerActivity;
import org.videolan.vlc.gui.video.VideoActivityGroup;
import org.videolan.vlc.gui.video.VideoListActivity; import org.videolan.vlc.gui.video.VideoListActivity;
import org.videolan.vlc.gui.video.VideoListAdapter; import org.videolan.vlc.gui.video.VideoListAdapter;
import org.videolan.vlc.gui.video.VideoPlayerActivity; import org.videolan.vlc.gui.video.VideoPlayerActivity;
...@@ -42,16 +37,12 @@ import org.videolan.vlc.widget.AudioMiniPlayer; ...@@ -42,16 +37,12 @@ import org.videolan.vlc.widget.AudioMiniPlayer;
import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab; import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.ActionBar.TabListener;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.SherlockFragmentActivity;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityGroup;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.app.TabActivity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
...@@ -64,8 +55,6 @@ import android.content.pm.PackageManager.NameNotFoundException; ...@@ -64,8 +55,6 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.util.Log; import android.util.Log;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
...@@ -82,7 +71,6 @@ import android.widget.ImageButton; ...@@ -82,7 +71,6 @@ import android.widget.ImageButton;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TabHost; import android.widget.TabHost;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends SherlockFragmentActivity { public class MainActivity extends SherlockFragmentActivity {
public final static String TAG = "VLC/MainActivity"; public final static String TAG = "VLC/MainActivity";
...@@ -97,9 +85,6 @@ public class MainActivity extends SherlockFragmentActivity { ...@@ -97,9 +85,6 @@ public class MainActivity extends SherlockFragmentActivity {
private static final String PREF_SHOW_INFO = "show_info"; private static final String PREF_SHOW_INFO = "show_info";
private ActionBar mActionBar; private ActionBar mActionBar;
private TabHost mTabHost;
private int mCurrentState = 0;
private ImageButton mChangeTab;
private AudioMiniPlayer mAudioPlayer; private AudioMiniPlayer mAudioPlayer;
private AudioServiceController mAudioController; private AudioServiceController mAudioController;
private View mInfoLayout; private View mInfoLayout;
...@@ -122,11 +107,9 @@ public class MainActivity extends SherlockFragmentActivity { ...@@ -122,11 +107,9 @@ public class MainActivity extends SherlockFragmentActivity {
LibVLC.useIOMX(this); LibVLC.useIOMX(this);
/* Initialize variables */ /* Initialize variables */
mChangeTab = (ImageButton) findViewById(R.id.change_tab);
mInfoLayout = (View) findViewById(R.id.info_layout); mInfoLayout = (View) findViewById(R.id.info_layout);
mInfoProgress = (ProgressBar) findViewById(R.id.info_progress); mInfoProgress = (ProgressBar) findViewById(R.id.info_progress);
mInfoText = (TextView) findViewById(R.id.info_text); mInfoText = (TextView) findViewById(R.id.info_text);
mTabHost = (TabHost)findViewById(android.R.id.tabhost);
/* Initialize the tabs */ /* Initialize the tabs */
...@@ -246,8 +229,6 @@ public class MainActivity extends SherlockFragmentActivity { ...@@ -246,8 +229,6 @@ public class MainActivity extends SherlockFragmentActivity {
// Intent to start new Activity // Intent to start new Activity
Intent intent; Intent intent;
Activity activity;
// Handle item selection // Handle item selection
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.ml_menu_sortby_name: case R.id.ml_menu_sortby_name:
......
/*****************************************************************************
* AudioActivityGroup.java
*****************************************************************************
* Copyright © 2011-2012 VLC authors and VideoLAN
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package org.videolan.vlc.gui.audio;
import java.util.ArrayList;
import org.videolan.vlc.AudioServiceController;
import android.app.Activity;
import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
public class AudioActivityGroup extends ActivityGroup {
public final static String TAG = "VLC/AudioActivityGroup";
private ArrayList<String> mHistory;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHistory = new ArrayList<String>();
// Load VideoListActivity by default
Intent intent = new Intent(this, AudioBrowserActivity.class);
startChildAcitvity("AudioBrowserActivity", intent);
}
@Override
protected void onResume() {
AudioServiceController.getInstance().bindAudioService(this);
super.onResume();
}
@Override
protected void onPause() {
AudioServiceController.getInstance().unbindAudioService(this);
super.onPause();
}
public void startChildAcitvity(String id, Intent intent) {
Window window = getLocalActivityManager().startActivity(
id, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
mHistory.add(id);
setContentView(window.getDecorView());
}
}
@Override
public void finishFromChild(Activity child) {
LocalActivityManager manager = getLocalActivityManager();
int index = mHistory.size() - 1;
if (index > 0) {
manager.destroyActivity(mHistory.get(index), true);
mHistory.remove(index);
index--;
String id = mHistory.get(index);
Activity activity = manager.getActivity(id);
setContentView(activity.getWindow().getDecorView());
} else {
finish();
}
}
@Override
public void onBackPressed() {
int index = mHistory.size() - 1;
if (index > 0) {
getCurrentActivity().finish();
return;
}
super.onBackPressed();
}
}
...@@ -31,7 +31,6 @@ import org.videolan.vlc.R; ...@@ -31,7 +31,6 @@ import org.videolan.vlc.R;
import com.actionbarsherlock.app.SherlockListActivity; import com.actionbarsherlock.app.SherlockListActivity;
import android.app.ListActivity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
......
/*****************************************************************************
* VideoActivityGroup.java
*****************************************************************************
* Copyright © 2011-2012 VLC authors and VideoLAN
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package org.videolan.vlc.gui.video;
import java.util.ArrayList;
import org.videolan.vlc.AudioServiceController;
import android.app.Activity;
import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
public class VideoActivityGroup extends ActivityGroup {
public final static String TAG = "VLC/VideoActivityGroup";
private ArrayList<String> mHistory;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.mHistory = new ArrayList<String>();
// Load VideoListActivity by default
Intent intent = new Intent(this, VideoListActivity.class);
startChildAcitvity("VideoListActivity", intent);
}
@Override
protected void onResume() {
AudioServiceController.getInstance().bindAudioService(this);
super.onResume();
}
@Override
protected void onPause() {
AudioServiceController.getInstance().unbindAudioService(this);
super.onPause();
}
public void startChildAcitvity(String id, Intent intent) {
Window window = getLocalActivityManager().startActivity(
id, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
mHistory.add(id);
setContentView(window.getDecorView());
}
}
@Override
public void finishFromChild(Activity child) {
LocalActivityManager manager = getLocalActivityManager();
int index = mHistory.size() - 1;
if (index > 0) {
manager.destroyActivity(mHistory.get(index), true);
mHistory.remove(index);
index--;
String id = mHistory.get(index);
Activity activity = manager.getActivity(id);
setContentView(activity.getWindow().getDecorView());
} else {
finish();
}
}
@Override
public void onBackPressed() {
int index = mHistory.size() - 1;
if (index > 0) {
getCurrentActivity().finish();
return;
}
super.onBackPressed();
}
}
...@@ -30,13 +30,8 @@ import org.videolan.vlc.MediaLibrary; ...@@ -30,13 +30,8 @@ import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R; import org.videolan.vlc.R;
import org.videolan.vlc.ThumbnailerManager; import org.videolan.vlc.ThumbnailerManager;
import org.videolan.vlc.gui.PreferencesActivity; import org.videolan.vlc.gui.PreferencesActivity;
import org.videolan.vlc.gui.SearchActivity;
import org.videolan.vlc.interfaces.ISortable; import org.videolan.vlc.interfaces.ISortable;
import com.actionbarsherlock.app.SherlockListActivity;
import com.actionbarsherlock.app.SherlockListFragment;
import android.app.ListActivity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
...@@ -49,6 +44,8 @@ import android.view.ViewGroup; ...@@ -49,6 +44,8 @@ import android.view.ViewGroup;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import com.actionbarsherlock.app.SherlockListFragment;
public class VideoListActivity extends SherlockListFragment implements ISortable { public class VideoListActivity extends SherlockListFragment implements ISortable {
private LinearLayout mNoFileLayout; private LinearLayout mNoFileLayout;
......
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