[Android] General cleanup. Add more documentation.

Remove some accidental changes that slipped through. Don't want to have input settings in the settings menu just yet.
This commit is contained in:
Lioncash 2013-08-22 08:18:56 -04:00
parent 951bbcd6ce
commit 41c25d0c90
14 changed files with 232 additions and 70 deletions

View File

@ -23,17 +23,8 @@ import org.dolphinemu.dolphinemu.settings.VideoSettingsFragment;
public final class AboutFragment extends Fragment
{
private static Activity m_activity;
private ListView mMainList;
private FolderBrowserAdapter adapter;
boolean Configuring = false;
boolean firstEvent = true;
public AboutFragment()
{
// Empty constructor required for fragment subclasses
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

View File

@ -4,12 +4,20 @@ import android.content.Context;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
/**
* The surface that rendering is done to.
*/
public final class NativeGLSurfaceView extends SurfaceView
{
private static Thread myRun;
private static boolean Running = false;
private static boolean Created = false;
/**
* Constructor.
*
* @param context The current {@link Context}.
*/
public NativeGLSurfaceView(Context context)
{
super(context);

View File

@ -19,6 +19,19 @@ import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
/**
* A basic folder browser {@link Fragment} that allows
* the user to select ISOs/ROMs for playing within the
* emulator.
* <p>
* Any valid ISO/ROM selected in this will be added to
* the game list for easy browsing the next time the
* application is used.
* <p>
* Note that invalid items will be shown in the color red. <br/>
* Also note that this file browser does not display files
* or directories that are hidden
*/
public final class FolderBrowser extends Fragment
{
private Activity m_activity;
@ -69,7 +82,7 @@ public final class FolderBrowser extends Fragment
}
catch (Exception ex)
{
Log.d("EXCEPTION", ex.toString());
Log.e("Exception-FolderBrowser", ex.toString());
}
}
@ -136,6 +149,8 @@ public final class FolderBrowser extends Fragment
+ " must implement OnGameListZeroListener");
}
}
private void FolderSelected()
{
String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");

View File

@ -12,6 +12,12 @@ import android.widget.TextView;
import org.dolphinemu.dolphinemu.R;
/**
* The {@link ArrayAdapter} that backs the file browser.
* <p>
* This is responsible for correctly handling the display
* of the items for the UI.
*/
public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
{
private final Context c;
@ -26,6 +32,7 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
items = objects;
}
@Override
public FolderBrowserItem getItem(int i)
{
return items.get(i);

View File

@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.gamelist;
import android.app.Activity;
@ -26,9 +32,8 @@ import org.dolphinemu.dolphinemu.sidemenu.SideMenuAdapter;
import org.dolphinemu.dolphinemu.sidemenu.SideMenuItem;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
* The activity that implements all of the functions
* for the game list.
*/
public final class GameListActivity extends Activity
implements GameListFragment.OnGameListZeroListener
@ -40,8 +45,24 @@ public final class GameListActivity extends Activity
private DrawerLayout mDrawerLayout;
private SideMenuAdapter mDrawerAdapter;
private ListView mDrawerList;
/**
* Interface defining methods which handle
* the binding of specific key presses within
* the input mapping settings.
*/
public interface OnGameConfigListener
{
boolean onMotionEvent(MotionEvent event);
boolean onKeyEvent(KeyEvent event);
}
// Called from the game list fragment
/**
* Called from the {@link GameListFragment}.
* <p>
* This is called when there are no games
* currently present within the game list.
*/
public void onZeroFiles()
{
mDrawerLayout.openDrawer(mDrawerList);
@ -100,6 +121,12 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
}
/**
* Switches to the {@link Fragment} represented
* by the given ID number.
*
* @param toPage the number representing the {@link Fragment} to switch to.l
*/
public void SwitchPage(int toPage)
{
if (mCurFragmentNum == toPage)
@ -194,11 +221,11 @@ public final class GameListActivity extends Activity
SwitchPage(o.getID());
}
};
/**
* When using the ActionBarDrawerToggle, you must call it during
* onPostCreate() and onConfigurationChanged()...
*/
@Override
protected void onPostCreate(Bundle savedInstanceState)
{
@ -235,17 +262,12 @@ public final class GameListActivity extends Activity
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed()
{
SwitchPage(0);
}
public interface OnGameConfigListener
{
public boolean onMotionEvent(MotionEvent event);
public boolean onKeyEvent(KeyEvent event);
}
// Gets move(triggers, joystick) events
@Override
public boolean dispatchGenericMotionEvent(MotionEvent event)

View File

@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.gamelist;
import android.content.Context;
@ -12,6 +18,11 @@ import java.util.List;
import org.dolphinemu.dolphinemu.R;
/**
* The adapter backing the game list.
* <p>
* Responsible for handling each game list item individually.
*/
public final class GameListAdapter extends ArrayAdapter<GameListItem>
{
private final Context c;
@ -26,6 +37,7 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
items = objects;
}
@Override
public GameListItem getItem(int i)
{
return items.get(i);

View File

@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.gamelist;
import android.app.Activity;
@ -22,26 +28,28 @@ import java.util.Set;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
* The {@link Fragment} responsible for displaying the game list.
*/
public final class GameListFragment extends Fragment
{
private ListView mMainList;
private GameListAdapter mGameAdapter;
private static GameListActivity mMe;
OnGameListZeroListener mCallback;
private OnGameListZeroListener mCallback;
/**
* Interface that defines how to handle the case
* when there are zero game.
*/
public interface OnGameListZeroListener
{
public void onZeroFiles();
}
public GameListFragment()
{
// Empty constructor required for fragment subclasses
/**
* This is called when there are no games
* currently present within the game list.
*/
void onZeroFiles();
}
private void Fill()
@ -97,8 +105,11 @@ public final class GameListFragment extends Fragment
mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_layout, fls);
mMainList.setAdapter(mGameAdapter);
if (fls.size() == 0)
if (fls.isEmpty())
{
mCallback.onZeroFiles();
}
}
@Override

View File

@ -1,8 +1,15 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.gamelist;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import java.io.File;
import java.io.IOException;
@ -10,6 +17,9 @@ import java.io.InputStream;
import org.dolphinemu.dolphinemu.NativeLibrary;
/**
* Represents an item in the game list.
*/
public final class GameListItem implements Comparable<GameListItem>
{
private String name;
@ -18,6 +28,15 @@ public final class GameListItem implements Comparable<GameListItem>
private final boolean isValid;
private Bitmap image;
/**
* Constructor.
*
* @param ctx The current {@link Context}
* @param name The name of this GameListItem.
* @param data The subtitle for this GameListItem
* @param path The file path for the game represented by this GameListItem.
* @param isValid Whether or not the emulator can handle this file.
*/
public GameListItem(Context ctx, String name, String data, String path, boolean isValid)
{
this.name = name;
@ -44,8 +63,7 @@ public final class GameListItem implements Comparable<GameListItem>
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("Exception-GameListItem", e.toString());
}
}
else
@ -57,26 +75,51 @@ public final class GameListItem implements Comparable<GameListItem>
}
}
/**
* Gets the name of this GameListItem.
*
* @return the name of this GameListItem.
*/
public String getName()
{
return name;
}
/**
* Gets the subtitle of this GameListItem.
*
* @return the subtitle of this GameListItem.
*/
public String getData()
{
return data;
}
/**
* Gets the file path of the game represented by this GameListItem.
*
* @return the file path of the game represented by this GameListItem.
*/
public String getPath()
{
return path;
}
/**
* Gets the image data for this game as a {@link Bitmap}.
*
* @return the image data for this game as a {@link Bitmap}.
*/
public Bitmap getImage()
{
return image;
}
/**
* Gets whether or not the emulator can handle this GameListItem.
*
* @return true, if this GameListItem can be handled by the emulator; false, otherwise.
*/
public boolean isValid()
{
return isValid;

View File

@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.inputconfig;
import android.content.Context;
@ -12,9 +18,9 @@ import java.util.List;
import org.dolphinemu.dolphinemu.R;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
* The adapter backing the input mapping configuration.
* <p>
* Responsible for handling the list items.
*/
public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem>
{
@ -30,6 +36,7 @@ public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem>
items = objects;
}
@Override
public InputConfigItem getItem(int i)
{
return items.get(i);

View File

@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.inputconfig;
import android.app.Activity;
@ -17,9 +23,8 @@ import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
* The {@link Fragment} responsible for implementing the functionality
* within the input control mapping config.
*/
public final class InputConfigFragment extends Fragment
implements GameListActivity.OnGameConfigListener
@ -31,7 +36,14 @@ public final class InputConfigFragment extends Fragment
private boolean Configuring = false;
private boolean firstEvent = true;
static public String getInputDesc(InputDevice input)
/**
* Gets the descriptor for the given {@link InputDevice}.
*
* @param input The {@link InputDevice} to get the descriptor of.
*
* @return the descriptor for the given {@link InputDevice}.
*/
public static String getInputDesc(InputDevice input)
{
if (input == null)
return "null"; // Happens when the inputdevice is from an unknown source
@ -109,6 +121,11 @@ public final class InputConfigFragment extends Fragment
adapter.insert(o, configPosition);
}
/**
* Gets the current {@link InputConfigAdapter}
*
* @return the current {@link InputConfigAdapter}.
*/
public InputConfigAdapter getAdapter()
{
return adapter;
@ -157,6 +174,7 @@ public final class InputConfigFragment extends Fragment
return true;
}
// Called from GameListActivity
public boolean onKeyEvent(KeyEvent event)
{
Log.w("InputConfigFragment", "Got Event " + event.getAction());

View File

@ -7,7 +7,6 @@
package org.dolphinemu.dolphinemu.settings;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.inputconfig.InputConfigFragment;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
@ -31,12 +30,12 @@ public final class PrefsActivity extends Activity implements ActionBar.TabListen
* keep every loaded fragment in memory. If this becomes too memory intensive, it may be best to
* switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/
SectionsPagerAdapter mSectionsPagerAdapter;
private SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
private ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState)
@ -73,7 +72,6 @@ public final class PrefsActivity extends Activity implements ActionBar.TabListen
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(actionBar.newTab().setText(R.string.cpu_settings).setTabListener(this));
actionBar.addTab(actionBar.newTab().setText("Input Settings").setTabListener(this));
actionBar.addTab(actionBar.newTab().setText(R.string.video_settings).setTabListener(this));
}
@ -94,8 +92,8 @@ public final class PrefsActivity extends Activity implements ActionBar.TabListen
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to one of the
* sections/tabs/pages.
* A {@link FragmentPagerAdapter} that returns a fragment
* corresponding to one of the sections/tabs/pages.
*/
public final class SectionsPagerAdapter extends FragmentPagerAdapter
{
@ -113,9 +111,6 @@ public final class PrefsActivity extends Activity implements ActionBar.TabListen
return new CPUSettingsFragment();
case 1:
return new InputConfigFragment();
case 2:
return new VideoSettingsFragment();
default: // Should never happen.
@ -127,7 +122,7 @@ public final class PrefsActivity extends Activity implements ActionBar.TabListen
public int getCount()
{
// Show total pages.
return 3;
return 2;
}
@Override
@ -139,9 +134,6 @@ public final class PrefsActivity extends Activity implements ActionBar.TabListen
return getString(R.string.cpu_settings).toUpperCase();
case 1:
return "Input Settings";//getString(R.string)
case 2:
return getString(R.string.video_settings).toUpperCase();
default: // Should never happen.

View File

@ -27,15 +27,19 @@ public final class VideoSettingsFragment extends PreferenceFragment
{
private Activity m_activity;
public static class VersionCheck
/**
* Class which provides a means to check various
* info about the OpenGL ES support for a device.
*/
public static final class VersionCheck
{
EGL10 mEGL;
EGLDisplay mEGLDisplay;
EGLConfig[] mEGLConfigs;
EGLConfig mEGLConfig;
EGLContext mEGLContext;
EGLSurface mEGLSurface;
GL10 mGL;
private EGL10 mEGL;
private EGLDisplay mEGLDisplay;
private EGLConfig[] mEGLConfigs;
private EGLConfig mEGLConfig;
private EGLContext mEGLContext;
private EGLSurface mEGLSurface;
private GL10 mGL;
String mThreadOwner;
@ -68,16 +72,31 @@ public final class VideoSettingsFragment extends PreferenceFragment
mThreadOwner = Thread.currentThread().getName();
}
/**
* Gets the OpenGL ES version string.
*
* @return the OpenGL ES version string.
*/
public String getVersion()
{
return mGL.glGetString(GL10.GL_VERSION);
}
/**
* Gets the OpenGL ES vendor string.
*
* @return the OpenGL ES vendor string.
*/
public String getVendor()
{
return mGL.glGetString(GL10.GL_VENDOR);
}
/**
* Gets the name of the OpenGL ES renderer.
*
* @return the name of the OpenGL ES renderer.
*/
public String getRenderer()
{
return mGL.glGetString(GL10.GL_RENDERER);
@ -107,6 +126,11 @@ public final class VideoSettingsFragment extends PreferenceFragment
}
}
/**
* Checks if this device supports OpenGL ES 3.
*
* @return true if this device supports OpenGL ES 3; false otherwise.
*/
public static boolean SupportsGLES3()
{
VersionCheck mbuffer = new VersionCheck();

View File

@ -1,3 +1,9 @@
/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
package org.dolphinemu.dolphinemu.sidemenu;
import android.content.Context;
@ -11,6 +17,11 @@ import java.util.List;
import org.dolphinemu.dolphinemu.R;
/**
* Adapter that backs the sidebar menu.
* <p>
* Responsible for handling the elements of each sidebar item.
*/
public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
{
private final Context c;
@ -25,6 +36,7 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
items = objects;
}
@Override
public SideMenuItem getItem(int i)
{
return items.get(i);

View File

@ -12,8 +12,8 @@ package org.dolphinemu.dolphinemu.sidemenu;
*/
public final class SideMenuItem implements Comparable<SideMenuItem>
{
private final String m_name;
private final int m_id;
private final String name;
private final int id;
/**
* Constructor
@ -23,8 +23,8 @@ public final class SideMenuItem implements Comparable<SideMenuItem>
*/
public SideMenuItem(String name, int id)
{
m_name = name;
m_id = id;
this.name = name;
this.id = id;
}
/**
@ -34,7 +34,7 @@ public final class SideMenuItem implements Comparable<SideMenuItem>
*/
public String getName()
{
return m_name;
return name;
}
/**
@ -44,13 +44,13 @@ public final class SideMenuItem implements Comparable<SideMenuItem>
*/
public int getID()
{
return m_id;
return id;
}
public int compareTo(SideMenuItem o)
{
if (this.m_name != null)
return this.m_name.toLowerCase().compareTo(o.getName().toLowerCase());
if (name != null)
return this.name.toLowerCase().compareTo(o.getName().toLowerCase());
else
throw new IllegalArgumentException();
}