summaryrefslogtreecommitdiff
path: root/Source/Android/src
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2013-08-14 15:03:07 -0400
committerLioncash <mathew1800@gmail.com>2013-08-14 15:03:07 -0400
commit94397a44cc556198caf79da20f649a928758cbcc (patch)
treeb20d5a8d5f16cbe12af124a2810175b24764446d /Source/Android/src
parent6f1612d99cb7acd79434eac24916a9d0b0c52ff5 (diff)
[Android] General formatting clean-up.
Made some class variables final, since they should convey that they cannot be changed after the first assignment. Made the formatting consistent between files.
Diffstat (limited to 'Source/Android/src')
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java21
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java36
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java17
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java14
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java56
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java47
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java26
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java40
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java45
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java30
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java3
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java20
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java3
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java30
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java24
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java4
16 files changed, 269 insertions, 147 deletions
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
index 1e2ff17061..e05d1c7db2 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
@@ -16,7 +16,8 @@ import java.util.List;
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
-public final class AboutFragment extends Fragment {
+public final class AboutFragment extends Fragment
+{
private static Activity m_activity;
private ListView mMainList;
@@ -25,13 +26,14 @@ public final class AboutFragment extends Fragment {
boolean Configuring = false;
boolean firstEvent = true;
- public AboutFragment() {
+ public AboutFragment()
+ {
// Empty constructor required for fragment subclasses
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
View rootView = inflater.inflate(R.layout.gamelist_listview, container, false);
mMainList = (ListView) rootView.findViewById(R.id.gamelist);
@@ -47,15 +49,20 @@ public final class AboutFragment extends Fragment {
return mMainList;
}
+
@Override
- public void onAttach(Activity activity) {
+ public void onAttach(Activity activity)
+ {
super.onAttach(activity);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
- try {
+ try
+ {
m_activity = activity;
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e)
+ {
throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener");
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java
index ff4e989d28..d1e23d1e53 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java
@@ -25,24 +25,32 @@ public final class DolphinEmulator<MainActivity> extends Activity
private float screenWidth;
private float screenHeight;
- private void CopyAsset(String asset, String output) {
+ private void CopyAsset(String asset, String output)
+ {
InputStream in = null;
OutputStream out = null;
- try {
+
+ try
+ {
in = getAssets().open(asset);
out = new FileOutputStream(output);
copyFile(in, out);
in.close();
out.close();
- } catch(IOException e) {
+ }
+ catch(IOException e)
+ {
Log.e("DolphinEmulator", "Failed to copy asset file: " + asset, e);
}
}
- private void copyFile(InputStream in, OutputStream out) throws IOException {
+ private void copyFile(InputStream in, OutputStream out) throws IOException
+ {
byte[] buffer = new byte[1024];
int read;
- while((read = in.read(buffer)) != -1){
+
+ while((read = in.read(buffer)) != -1)
+ {
out.write(buffer, 0, read);
}
}
@@ -54,6 +62,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
if (Running)
NativeLibrary.StopEmulation();
}
+
@Override
public void onPause()
{
@@ -61,6 +70,7 @@ public final class DolphinEmulator<MainActivity> extends Activity
if (Running)
NativeLibrary.PauseEmulation();
}
+
@Override
public void onResume()
{
@@ -71,7 +81,8 @@ public final class DolphinEmulator<MainActivity> extends Activity
/** Called when the activity is first created. */
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState)
+ {
super.onCreate(savedInstanceState);
if (savedInstanceState == null)
{
@@ -158,7 +169,8 @@ public final class DolphinEmulator<MainActivity> extends Activity
// Gets button presses
@Override
- public boolean dispatchKeyEvent(KeyEvent event) {
+ public boolean dispatchKeyEvent(KeyEvent event)
+ {
int action = 0;
// Special catch for the back key
@@ -180,7 +192,8 @@ public final class DolphinEmulator<MainActivity> extends Activity
if (Running)
{
- switch (event.getAction()) {
+ switch (event.getAction())
+ {
case KeyEvent.ACTION_DOWN:
action = 0;
break;
@@ -198,8 +211,10 @@ public final class DolphinEmulator<MainActivity> extends Activity
}
@Override
- public boolean dispatchGenericMotionEvent(MotionEvent event) {
- if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running) {
+ public boolean dispatchGenericMotionEvent(MotionEvent event)
+ {
+ if (((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0) || !Running)
+ {
return super.dispatchGenericMotionEvent(event);
}
@@ -213,5 +228,4 @@ public final class DolphinEmulator<MainActivity> extends Activity
return true;
}
-
} \ No newline at end of file
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java
index f180a5b198..e60378c2cd 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java
@@ -14,7 +14,8 @@ import android.widget.Toast;
import java.io.File;
import java.util.*;
-public final class FolderBrowser extends Fragment {
+public final class FolderBrowser extends Fragment
+{
private Activity m_activity;
private FolderBrowserAdapter adapter;
private ListView mDrawerList;
@@ -77,9 +78,9 @@ public final class FolderBrowser extends Fragment {
mDrawerList.setAdapter(adapter);
mDrawerList.setOnItemClickListener(mMenuItemClickListener);
}
+
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState)
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
if(currentDir == null)
currentDir = new File(Environment.getExternalStorageDirectory().getPath());
@@ -111,14 +112,18 @@ public final class FolderBrowser extends Fragment {
};
@Override
- public void onAttach(Activity activity) {
+ public void onAttach(Activity activity)
+ {
super.onAttach(activity);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
- try {
+ try
+ {
m_activity = activity;
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e)
+ {
throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener");
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java
index ea326ecca4..dea96ce9d6 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java
@@ -1,7 +1,6 @@
package org.dolphinemu.dolphinemu;
import android.content.Context;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -11,13 +10,14 @@ import android.widget.TextView;
import java.util.List;
-public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>{
+public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
+{
+ private final Context c;
+ private final int id;
+ private final List<FolderBrowserItem> items;
- private Context c;
- private int id;
- private List<FolderBrowserItem> items;
-
- public FolderBrowserAdapter(Context context, int textViewResourceId, List<FolderBrowserItem> objects) {
+ public FolderBrowserAdapter(Context context, int textViewResourceId, List<FolderBrowserItem> objects)
+ {
super(context, textViewResourceId, objects);
c = context;
id = textViewResourceId;
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java
index 564de80df4..2bd61cb0f2 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java
@@ -23,7 +23,8 @@ import java.util.List;
* Refer to the license.txt file included.
*/
public final class GameListActivity extends Activity
- implements GameListFragment.OnGameListZeroListener{
+ implements GameListFragment.OnGameListZeroListener
+{
private int mCurFragmentNum = 0;
private Fragment mCurFragment;
@@ -43,7 +44,8 @@ public final class GameListActivity extends Activity
}
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(Bundle savedInstanceState)
+ {
super.onCreate(savedInstanceState);
setContentView(R.layout.gamelist_activity);
mMe = this;
@@ -94,16 +96,19 @@ public final class GameListActivity extends Activity
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
}
+
public void SwitchPage(int toPage)
{
if (mCurFragmentNum == toPage)
return;
+
switch (mCurFragmentNum)
{
// Folder browser
case 1:
recreateFragment();
- break;
+ break;
+
// Settings
case 2:
{
@@ -147,6 +152,7 @@ public final class GameListActivity extends Activity
}
}
break;
+
case 3: // Gamepad settings
{
InputConfigAdapter adapter = ((InputConfigFragment)mCurFragment).getAdapter();
@@ -162,11 +168,13 @@ public final class GameListActivity extends Activity
}
}
break;
+
case 0: // Game List
case 4: // About
/* Do Nothing */
break;
}
+
switch(toPage)
{
case 0:
@@ -177,6 +185,7 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
}
break;
+
case 1:
{
Toast.makeText(mMe, getString(R.string.loading_browser), Toast.LENGTH_SHORT).show();
@@ -186,6 +195,7 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
}
break;
+
case 2:
{
Toast.makeText(mMe, getString(R.string.loading_settings), Toast.LENGTH_SHORT).show();
@@ -195,6 +205,7 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
}
break;
+
case 3:
{
Toast.makeText(mMe, getString(R.string.loading_gamepad), Toast.LENGTH_SHORT).show();
@@ -204,6 +215,7 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
}
break;
+
case 4:
{
Toast.makeText(mMe, getString(R.string.about), Toast.LENGTH_SHORT).show();
@@ -213,10 +225,12 @@ public final class GameListActivity extends Activity
fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit();
}
break;
+
default:
break;
}
}
+
private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@@ -232,57 +246,75 @@ public final class GameListActivity extends Activity
*/
@Override
- protected void onPostCreate(Bundle savedInstanceState) {
+ protected void onPostCreate(Bundle savedInstanceState)
+ {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}
@Override
- public void onConfigurationChanged(Configuration newConfig) {
+ public void onConfigurationChanged(Configuration newConfig)
+ {
super.onConfigurationChanged(newConfig);
- // Pass any configuration change to the drawer toggls
+ // Pass any configuration change to the drawer toggle
mDrawerToggle.onConfigurationChanged(newConfig);
}
/* Called whenever we call invalidateOptionsMenu() */
@Override
- public boolean onPrepareOptionsMenu(Menu menu) {
+ public boolean onPrepareOptionsMenu(Menu menu)
+ {
return super.onPrepareOptionsMenu(menu);
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
// The action bar home/up action should open or close the drawer.
// ActionBarDrawerToggle will take care of this.
- if (mDrawerToggle.onOptionsItemSelected(item)) {
+ if (mDrawerToggle.onOptionsItemSelected(item))
+ {
return true;
}
+
return super.onOptionsItemSelected(item);
}
+
public void onBackPressed()
{
SwitchPage(0);
}
- public interface OnGameConfigListener {
+ public interface OnGameConfigListener
+ {
public boolean onMotionEvent(MotionEvent event);
public boolean onKeyEvent(KeyEvent event);
}
+
// Gets move(triggers, joystick) events
@Override
- public boolean dispatchGenericMotionEvent(MotionEvent event) {
+ public boolean dispatchGenericMotionEvent(MotionEvent event)
+ {
if (mCurFragmentNum == 3)
+ {
if (((OnGameConfigListener)mCurFragment).onMotionEvent(event))
return true;
+ }
+
return super.dispatchGenericMotionEvent(event);
}
+
// Gets button presses
@Override
- public boolean dispatchKeyEvent(KeyEvent event) {
+ public boolean dispatchKeyEvent(KeyEvent event)
+ {
if (mCurFragmentNum == 3)
+ {
if (((OnGameConfigListener)mCurFragment).onKeyEvent(event))
return true;
+ }
+
return super.dispatchKeyEvent(event);
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java
index e31072d2b7..d7170bb474 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListAdapter.java
@@ -10,13 +10,14 @@ import android.widget.TextView;
import java.util.List;
-public final class GameListAdapter extends ArrayAdapter<GameListItem>{
+public final class GameListAdapter extends ArrayAdapter<GameListItem>
+{
+ private final Context c;
+ private final int id;
+ private final List<GameListItem>items;
- private Context c;
- private int id;
- private List<GameListItem>items;
-
- public GameListAdapter(Context context, int textViewResourceId, List<GameListItem> objects) {
+ public GameListAdapter(Context context, int textViewResourceId, List<GameListItem> objects)
+ {
super(context, textViewResourceId, objects);
c = context;
id = textViewResourceId;
@@ -29,26 +30,30 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>{
}
@Override
- public View getView(int position, View convertView, ViewGroup parent) {
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
View v = convertView;
- if (v == null) {
+ if (v == null)
+ {
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, null);
}
- final GameListItem o = items.get(position);
- if (o != null) {
- TextView t1 = (TextView) v.findViewById(R.id.GameItemTitle);
- TextView t2 = (TextView) v.findViewById(R.id.GameItemSubText);
- ImageView v1 = (ImageView) v.findViewById(R.id.GameItemIcon);
-
- if(t1!=null)
- t1.setText(o.getName());
- if(t2!=null)
- t2.setText(o.getData());
- if(v1!=null)
- v1.setImageBitmap(o.getImage());
- }
+ final GameListItem item = items.get(position);
+ if (item != null)
+ {
+ TextView title = (TextView) v.findViewById(R.id.GameItemTitle);
+ TextView subtitle = (TextView) v.findViewById(R.id.GameItemSubText);
+ ImageView icon = (ImageView) v.findViewById(R.id.GameItemIcon);
+
+ if(title != null)
+ title.setText(item.getName());
+ if(subtitle != null)
+ subtitle.setText(item.getData());
+ if(icon != null)
+ icon.setImageBitmap(item.getImage());
+ }
+
return v;
}
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java
index a513530a28..13f66c1c83 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java
@@ -31,13 +31,16 @@ public final class GameListFragment extends Fragment
private static GameListActivity mMe;
OnGameListZeroListener mCallback;
- public interface OnGameListZeroListener {
+ public interface OnGameListZeroListener
+ {
public void onZeroFiles();
}
- public GameListFragment() {
+ public GameListFragment()
+ {
// Empty constructor required for fragment subclasses
}
+
private void Fill()
{
List<GameListItem> fls = new ArrayList<GameListItem>();
@@ -51,7 +54,7 @@ public final class GameListFragment extends Fragment
{
String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + a, "");
File currentDir = new File(BrowseDir);
- File[]dirs = currentDir.listFiles();
+ File[] dirs = currentDir.listFiles();
try
{
for(File entry : dirs)
@@ -81,8 +84,8 @@ public final class GameListFragment extends Fragment
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
+ {
View rootView = inflater.inflate(R.layout.gamelist_listview, container, false);
mMainList = (ListView) rootView.findViewById(R.id.gamelist);
mMainList.setOnItemClickListener(mGameItemClickListener);
@@ -91,6 +94,7 @@ public final class GameListFragment extends Fragment
return mMainList;
}
+
private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@@ -102,6 +106,7 @@ public final class GameListFragment extends Fragment
}
}
};
+
private void onFileClick(String o)
{
Toast.makeText(mMe, getString(R.string.file_clicked) + o, Toast.LENGTH_SHORT).show();
@@ -111,16 +116,21 @@ public final class GameListFragment extends Fragment
mMe.setResult(Activity.RESULT_OK, intent);
mMe.finish();
}
+
@Override
- public void onAttach(Activity activity) {
+ public void onAttach(Activity activity)
+ {
super.onAttach(activity);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
- try {
+ try
+ {
mCallback = (OnGameListZeroListener) activity;
mMe = (GameListActivity) activity;
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e)
+ {
throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener");
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java
index 58cc291326..a9ef41c6d4 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListItem.java
@@ -8,36 +8,44 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-public final class GameListItem implements Comparable<GameListItem>{
- private String name;
- private String data;
- private String path;
+public final class GameListItem implements Comparable<GameListItem>
+{
+ private final String name;
+ private final String data;
+ private final String path;
+ private final boolean isValid;
private Bitmap image;
- private boolean m_valid;
- public GameListItem(Context ctx, String n,String d,String p, boolean valid)
+ public GameListItem(Context ctx, String name, String data, String path, boolean isValid)
{
- name = n;
- data = d;
- path = p;
- m_valid = valid;
+ this.name = name;
+ this.data = data;
+ this.path = path;
+ this.isValid = isValid;
+
File file = new File(path);
if (!file.isDirectory() && !path.equals(""))
{
int[] Banner = NativeLibrary.GetBanner(path);
if (Banner[0] == 0)
{
- try {
- InputStream path = ctx.getAssets().open("NoBanner.png");
- image = BitmapFactory.decodeStream(path);
- } catch (IOException e) {
+ try
+ {
+ InputStream noBannerPath = ctx.getAssets().open("NoBanner.png");
+ image = BitmapFactory.decodeStream(noBannerPath);
+ }
+ catch (IOException e)
+ {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
+ {
image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888);
+ }
+
name = NativeLibrary.GetTitle(path);
}
}
@@ -56,13 +64,15 @@ public final class GameListItem implements Comparable<GameListItem>{
{
return path;
}
+
public Bitmap getImage()
{
return image;
}
+
public boolean isValid()
{
- return m_valid;
+ return isValid;
}
public int compareTo(GameListItem o)
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java
index ad3a5211c8..12541b8b37 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigAdapter.java
@@ -14,13 +14,14 @@ import java.util.List;
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
-public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem> {
- private Context c;
- private int id;
- private List<InputConfigItem> items;
+public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem>
+{
+ private final Context c;
+ private final int id;
+ private final List<InputConfigItem> items;
- public InputConfigAdapter(Context context, int textViewResourceId,
- List<InputConfigItem> objects) {
+ public InputConfigAdapter(Context context, int textViewResourceId, List<InputConfigItem> objects)
+ {
super(context, textViewResourceId, objects);
c = context;
id = textViewResourceId;
@@ -31,26 +32,30 @@ public final class InputConfigAdapter extends ArrayAdapter<InputConfigItem> {
{
return items.get(i);
}
+
@Override
- public View getView(int position, View convertView, ViewGroup parent) {
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
View v = convertView;
- if (v == null) {
+ if (v == null)
+ {
LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(id, parent, false);
}
- final InputConfigItem o = items.get(position);
- if (o != null) {
- TextView t1 = (TextView) v.findViewById(R.id.FolderTitle);
- TextView t2 = (TextView) v.findViewById(R.id.FolderSubTitle);
-
- if(t1!=null)
- t1.setText(o.getName());
- if(t2!=null)
- t2.setText(o.getBind());
+
+ final InputConfigItem item = items.get(position);
+ if (item != null)
+ {
+ TextView title = (TextView) v.findViewById(R.id.FolderTitle);
+ TextView subtitle = (TextView) v.findViewById(R.id.FolderSubTitle);
+
+ if(title != null)
+ title.setText(item.getName());
+
+ if(subtitle != null)
+ subtitle.setText(item.getBind());
}
+
return v;
}
-
-
-
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java
index 5be1416944..530f8b1d3b 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java
@@ -19,7 +19,8 @@ import java.util.List;
* Refer to the license.txt file included.
*/
public final class InputConfigFragment extends Fragment
- implements GameListActivity.OnGameConfigListener{
+ implements GameListActivity.OnGameConfigListener
+{
private Activity m_activity;
private ListView mDrawerList;
private InputConfigAdapter adapter;
@@ -31,20 +32,24 @@ public final class InputConfigFragment extends Fragment
{
if (input == null)
return "null"; // Happens when the inputdevice is from an unknown source
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
+ {
return input.getDescriptor();
+ }
else
{
List<InputDevice.MotionRange> motions = input.getMotionRanges();
String fakeid = "";
+
for (InputDevice.MotionRange range : motions)
fakeid += range.getAxis();
+
return fakeid;
}
}
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState)
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
List<InputConfigItem> Input = new ArrayList<InputConfigItem>();
Input.add(new InputConfigItem(getString(R.string.draw_onscreen_controls), "Android-ScreenControls", "True"));
@@ -77,6 +82,7 @@ public final class InputConfigFragment extends Fragment
mDrawerList.setOnItemClickListener(mMenuItemClickListener);
return mDrawerList;
}
+
private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
@@ -100,6 +106,7 @@ public final class InputConfigFragment extends Fragment
o.setBind(newBind);
adapter.insert(o, position);
break;
+
default: // gamepad controls
Toast.makeText(m_activity, getString(R.string.press_button_to_config, o.getName()), Toast.LENGTH_SHORT).show();
@@ -120,10 +127,12 @@ public final class InputConfigFragment extends Fragment
o.setBind(bind);
adapter.insert(o, configPosition);
}
+
public InputConfigAdapter getAdapter()
{
return adapter;
}
+
// Called from GameListActivity
public boolean onMotionEvent(MotionEvent event)
{
@@ -166,10 +175,12 @@ public final class InputConfigFragment extends Fragment
}
return true;
}
+
public boolean onKeyEvent(KeyEvent event)
{
Log.w("InputConfigFragment", "Got Event " + event.getAction());
- switch (event.getAction()) {
+ switch (event.getAction())
+ {
case KeyEvent.ACTION_DOWN:
case KeyEvent.ACTION_UP:
if (Configuring)
@@ -179,6 +190,7 @@ public final class InputConfigFragment extends Fragment
Configuring = false;
return true;
}
+
default:
break;
}
@@ -187,14 +199,18 @@ public final class InputConfigFragment extends Fragment
}
@Override
- public void onAttach(Activity activity) {
+ public void onAttach(Activity activity)
+ {
super.onAttach(activity);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
- try {
+ try
+ {
m_activity = activity;
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e)
+ {
throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener");
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java
index 13bf8b9f3c..70e68261ec 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java
@@ -9,7 +9,8 @@ package org.dolphinemu.dolphinemu;
/**
* Represents a controller input item (button, stick, etc).
*/
-public final class InputConfigItem implements Comparable<InputConfigItem>{
+public final class InputConfigItem implements Comparable<InputConfigItem>
+{
private String m_name;
private String m_Config;
private String m_bind;
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java
index edeb3eeac4..ffe89714be 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java
@@ -4,12 +4,14 @@ import android.content.Context;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
-public final class NativeGLSurfaceView extends SurfaceView {
+public final class NativeGLSurfaceView extends SurfaceView
+{
static private Thread myRun;
static private boolean Running = false;
static private boolean Created = false;
- public NativeGLSurfaceView(Context context) {
+ public NativeGLSurfaceView(Context context)
+ {
super(context);
if (!Created)
{
@@ -20,8 +22,10 @@ public final class NativeGLSurfaceView extends SurfaceView {
NativeLibrary.Run(getHolder().getSurface());
}
};
+
getHolder().addCallback(new SurfaceHolder.Callback() {
- public void surfaceCreated(SurfaceHolder holder) {
+ public void surfaceCreated(SurfaceHolder holder)
+ {
// TODO Auto-generated method stub
if (!Running)
{
@@ -30,17 +34,17 @@ public final class NativeGLSurfaceView extends SurfaceView {
}
}
- public void surfaceChanged(SurfaceHolder arg0, int arg1,
- int arg2, int arg3) {
+ public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3)
+ {
// TODO Auto-generated method stub
-
}
- public void surfaceDestroyed(SurfaceHolder arg0) {
+ public void surfaceDestroyed(SurfaceHolder arg0)
+ {
// TODO Auto-generated method stub
-
}
});
+
Created = true;
}
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java
index 5d6aa1ac23..14f7527c1d 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java
@@ -13,7 +13,8 @@ import android.view.Surface;
* Class which contains methods that interact
* with the native side of the Dolphin code.
*/
-public final class NativeLibrary {
+public final class NativeLibrary
+{
public static native void onTouchEvent(int Action, float X, float Y);
public static native void onGamePadEvent(String Device, int Button, int Action);
public static native void onGamePadMoveEvent(String Device, int Axis, float Value);
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java
index 5dd2afa969..ad69a89a9d 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java
@@ -17,10 +17,12 @@ import javax.microedition.khronos.opengles.GL10;
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
-public final class PrefsFragment extends PreferenceFragment {
+public final class PrefsFragment extends PreferenceFragment
+{
private Activity m_activity;
- static public class VersionCheck {
+ static public class VersionCheck
+ {
EGL10 mEGL;
EGLDisplay mEGLDisplay;
EGLConfig[] mEGLConfigs;
@@ -31,8 +33,8 @@ public final class PrefsFragment extends PreferenceFragment {
String mThreadOwner;
- public VersionCheck() {
-
+ public VersionCheck()
+ {
int[] version = new int[2];
int[] attribList = new int[] {
EGL10.EGL_WIDTH, 1,
@@ -69,11 +71,14 @@ public final class PrefsFragment extends PreferenceFragment {
{
return mGL.glGetString(GL10.GL_VENDOR);
}
+
public String getRenderer()
{
return mGL.glGetString(GL10.GL_RENDERER);
}
- private EGLConfig chooseConfig() {
+
+ private EGLConfig chooseConfig()
+ {
int[] attribList = new int[] {
EGL10.EGL_DEPTH_SIZE, 0,
EGL10.EGL_STENCIL_SIZE, 0,
@@ -95,6 +100,7 @@ public final class PrefsFragment extends PreferenceFragment {
return mEGLConfigs[0]; // Best match is probably the first configuration
}
}
+
static public boolean SupportsGLES3()
{
VersionCheck mbuffer = new VersionCheck();
@@ -134,8 +140,10 @@ public final class PrefsFragment extends PreferenceFragment {
}
return mSupportsGLES3;
}
+
@Override
- public void onCreate(Bundle savedInstanceState) {
+ public void onCreate(Bundle savedInstanceState)
+ {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
@@ -197,14 +205,18 @@ public final class PrefsFragment extends PreferenceFragment {
}
@Override
- public void onAttach(Activity activity) {
+ public void onAttach(Activity activity)
+ {
super.onAttach(activity);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
- try {
+ try
+ {
m_activity = activity;
- } catch (ClassCastException e) {
+ }
+ catch (ClassCastException e)
+ {
throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener");
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java
index d47cbc96ba..11c071b026 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java
@@ -9,14 +9,13 @@ import android.widget.TextView;
import java.util.List;
-public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>{
-
- private Context c;
- private int id;
- private List<SideMenuItem>items;
+public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>
+{
+ private final Context c;
+ private final int id;
+ private final List<SideMenuItem>items;
- public SideMenuAdapter(Context context, int textViewResourceId,
- List<SideMenuItem> objects)
+ public SideMenuAdapter(Context context, int textViewResourceId, List<SideMenuItem> objects)
{
super(context, textViewResourceId, objects);
c = context;
@@ -28,6 +27,7 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>{
{
return items.get(i);
}
+
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
@@ -38,13 +38,13 @@ public final class SideMenuAdapter extends ArrayAdapter<SideMenuItem>{
v = vi.inflate(id, null);
}
- final SideMenuItem o = items.get(position);
- if (o != null)
+ final SideMenuItem item = items.get(position);
+ if (item != null)
{
- TextView t1 = (TextView) v.findViewById(R.id.SideMenuTitle);
+ TextView title = (TextView) v.findViewById(R.id.SideMenuTitle);
- if(t1!=null)
- t1.setText(o.getName());
+ if(title != null)
+ title.setText(item.getName());
}
return v;
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java
index 25869b77e7..51ebc93c19 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java
@@ -12,8 +12,8 @@ package org.dolphinemu.dolphinemu;
*/
public final class SideMenuItem implements Comparable<SideMenuItem>
{
- private String m_name;
- private int m_id;
+ private final String m_name;
+ private final int m_id;
/**
* Constructor