diff options
Diffstat (limited to 'Source/Android')
30 files changed, 942 insertions, 404 deletions
diff --git a/Source/Android/res/drawable-hdpi/ic_menu_file.png b/Source/Android/res/drawable-hdpi/ic_menu_file.png Binary files differnew file mode 100644 index 0000000000..f204740905 --- /dev/null +++ b/Source/Android/res/drawable-hdpi/ic_menu_file.png diff --git a/Source/Android/res/drawable-hdpi/ic_menu_folder.png b/Source/Android/res/drawable-hdpi/ic_menu_folder.png Binary files differnew file mode 100644 index 0000000000..6f441b41da --- /dev/null +++ b/Source/Android/res/drawable-hdpi/ic_menu_folder.png diff --git a/Source/Android/res/drawable-mdpi/ic_menu_file.png b/Source/Android/res/drawable-mdpi/ic_menu_file.png Binary files differnew file mode 100644 index 0000000000..dee2577897 --- /dev/null +++ b/Source/Android/res/drawable-mdpi/ic_menu_file.png diff --git a/Source/Android/res/drawable-mdpi/ic_menu_folder.png b/Source/Android/res/drawable-mdpi/ic_menu_folder.png Binary files differnew file mode 100644 index 0000000000..cc81e57f7e --- /dev/null +++ b/Source/Android/res/drawable-mdpi/ic_menu_folder.png diff --git a/Source/Android/res/drawable-xhdpi/ic_menu_file.png b/Source/Android/res/drawable-xhdpi/ic_menu_file.png Binary files differnew file mode 100644 index 0000000000..85369c338e --- /dev/null +++ b/Source/Android/res/drawable-xhdpi/ic_menu_file.png diff --git a/Source/Android/res/drawable-xhdpi/ic_menu_folder.png b/Source/Android/res/drawable-xhdpi/ic_menu_folder.png Binary files differnew file mode 100644 index 0000000000..78500a93c1 --- /dev/null +++ b/Source/Android/res/drawable-xhdpi/ic_menu_folder.png diff --git a/Source/Android/res/layout/about_layout.xml b/Source/Android/res/layout/about_layout.xml new file mode 100644 index 0000000000..7189fd7ce5 --- /dev/null +++ b/Source/Android/res/layout/about_layout.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical" > + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:orientation="vertical" > + + <TextView + android:id="@+id/FolderTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="5dip" + android:layout_marginTop="5dip" + android:singleLine="true" + android:text="Title" + android:textStyle="bold" /> + + <TextView + android:id="@+id/FolderSubTitle" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginLeft="10dip" + android:text="Subtitle" /> + + </LinearLayout> +</LinearLayout>
\ No newline at end of file diff --git a/Source/Android/res/layout/folderbrowser.xml b/Source/Android/res/layout/folderbrowser.xml index 82b94e238f..d3ee4538fa 100644 --- a/Source/Android/res/layout/folderbrowser.xml +++ b/Source/Android/res/layout/folderbrowser.xml @@ -1,29 +1,53 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" - android:layout_height="fill_parent" - android:orientation="vertical" > - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:orientation="vertical" > + android:layout_height="?android:attr/listPreferredItemHeight" + android:padding="3dip"> + + <ImageView + android:id="@+id/ImageIcon" + android:layout_width="wrap_content" + android:layout_height="fill_parent" + + android:layout_alignParentTop="true" + android:layout_alignParentBottom="true" + android:layout_marginRight="6dip"/> - <TextView - android:id="@+id/FolderTitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="5dip" - android:layout_marginTop="5dip" - android:singleLine="true" - android:text="Title" - android:textStyle="bold" /> - - <TextView - android:id="@+id/FolderSubTitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="10dip" - android:text="Subtitle" /> - - </LinearLayout> -</LinearLayout> + <TextView + android:id="@+id/FolderSubTitle" + android:layout_width="fill_parent" + android:layout_height="26dip" + + android:layout_toRightOf="@id/ImageIcon" + android:layout_alignParentBottom="true" + android:layout_alignParentRight="true" + + android:singleLine="true" + android:ellipsize="marquee" + android:text="Subtitle" /> + + <TextView + android:id="@+id/FolderTitle" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + + android:layout_toRightOf="@id/ImageIcon" + android:layout_alignParentRight="true" + android:layout_alignParentTop="true" + android:layout_above="@id/FolderSubTitle" + android:layout_alignWithParentIfMissing="true" + + android:gravity="center_vertical" + android:text="Title" + android:textStyle="bold" /> + + <ImageView + android:src="@android:drawable/divider_horizontal_dark" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:scaleType="fitXY" + android:paddingLeft="5dp" + android:paddingRight="5dp" + android:paddingBottom="2dp" + android:paddingTop="2dp" /> +</RelativeLayout> diff --git a/Source/Android/res/layout/prefs.xml b/Source/Android/res/layout/prefs.xml index 34700f56b7..d8d8664a97 100644 --- a/Source/Android/res/layout/prefs.xml +++ b/Source/Android/res/layout/prefs.xml @@ -2,23 +2,23 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <PreferenceCategory - android:summary="Settings" - android:title="CPU Settings" + android:summary="@string/settings" + android:title="@string/cpu_settings" android:key="cpuprefcat"> <CheckBoxPreference android:key="dualcorepref" - android:summary="On/Off" - android:title="Dual Core" /> + android:summary="@string/on_off" + android:title="@string/dual_core" /> </PreferenceCategory> <PreferenceCategory - android:summary="Settings" - android:title="Video Settings" + android:summary="@string/settings" + android:title="@string/video_settings" android:key="videoprefcat"> <ListPreference android:entries="@array/gpuOptions" android:entryValues="@array/gpuValues" android:key="gpupref" - android:summary="Video backend to use" - android:title="Video Backend" /> + android:summary="@string/video_backend_to_use" + android:title="@string/video_backend" /> </PreferenceCategory> </PreferenceScreen>
\ No newline at end of file diff --git a/Source/Android/res/layout/sidemenu.xml b/Source/Android/res/layout/sidemenu.xml index 76bc937489..6f4b8d3e5d 100644 --- a/Source/Android/res/layout/sidemenu.xml +++ b/Source/Android/res/layout/sidemenu.xml @@ -5,10 +5,6 @@ android:gravity="left" android:orientation="vertical" > - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" > - <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" @@ -26,6 +22,5 @@ android:textStyle="bold" /> </LinearLayout> - </LinearLayout> </LinearLayout> diff --git a/Source/Android/res/values-ja/strings.xml b/Source/Android/res/values-ja/strings.xml new file mode 100644 index 0000000000..329d464ccb --- /dev/null +++ b/Source/Android/res/values-ja/strings.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + + <!-- Title of the app --> + <string name="app_name">Dolphin Emulator</string> + + <!-- Navigation-related Strings --> + <string name="drawer_open">ナビゲーションウィンドウを開く</string> + <string name="drawer_close">ナビゲーションウィンドウを閉じる</string> + + <!-- About Fragment --> + <string name="build_revision">ビルドのバージョン:</string> + <string name="supports_gles3">サポートのOpenGL ES 3:</string> + + <!-- Folder Browser --> + <string name="current_dir">現在のディレクトリ: </string> + <string name="parent_directory">親ディレクトリ</string> + <string name="folder">フォルダ</string> + <string name="file_size">ファイルサイズ: </string> + <string name="cant_use_compressed_filetypes">圧縮ファイル形式はサポートされていません</string> + + <!-- Game List Activity --> + <string name="game_list">ゲームリスト</string> + <string name="browse_folder">フォルダの参照</string> + <string name="settings">設定</string> + <string name="gamepad_config">ゲームパッド設定</string> + <string name="about">について</string> + <string name="loading_browser">ファイルブラウザのロード</string> + <string name="loading_settings">設定のロード</string> + <string name="loading_gamepad">ゲームパッド設定のロード</string> + <string name="loading_about">メニューについてのロード</string> + + <!-- Game List Fragment --> + <string name="file_clicked">クリックされたファイル: </string> + + <!-- Input Config Fragment --> + <string name="draw_onscreen_controls">画面上のコントロールを描画</string> + <string name="button_a">Aボタン</string> + <string name="button_b">Bボタン</string> + <string name="button_start">スタートボタン</string> + <string name="button_x">Xボタン</string> + <string name="button_y">Yボタン</string> + <string name="button_z">Zボタン</string> + <string name="dpad_up">D-Pad: ↑</string> + <string name="dpad_down">D-Pad: ↓</string> + <string name="dpad_left">D-Pad: ←</string> + <string name="dpad_right">D-Pad: →</string> + <string name="main_stick_up">コントロールスティック: ↑</string> + <string name="main_stick_down">コントロールスティック: ↓</string> + <string name="main_stick_left">コントロールスティック: ←</string> + <string name="main_stick_right">コントロールスティック: →</string> + <string name="c_stick_up">C-スティック: ↑</string> + <string name="c_stick_down">C-スティック: ↓</string> + <string name="c_stick_left">C-スティック: ←</string> + <string name="c_stick_right">C-スティック: →</string> + <string name="trigger_left">左のトリガー</string> + <string name="trigger_right">右のトリガー</string> + + <string name="not_drawing_onscreen_controls">コントロールは画面上に描画されていない</string> + <string name="drawing_onscreen_controls">コントロールは画面上に描画されています</string> + <string name="press_button_to_config">%1$sを設定するにはボタンを押して</string> + + <!-- Prefs Fragment --> + <string name="interpreter">Interpreter</string> + <string name="jit64_recompiler">JIT64 Recompiler</string> + <string name="jitil_recompiler">JITIL Recompiler</string> + <string name="jit_arm_recompiler">JIT ARM Recompiler</string> + <string name="cpu_core">CPUコア</string> + <string name="cpu_settings">CPU設定</string> + <string name="emu_core_to_use">使用するエミュレーションコア</string> + <string name="dual_core">デュアルコア</string> + <string name="on_off">有効/無効</string> + + <string name="video_settings">ビデオ設定</string> + <string name="software_renderer">Software Renderer</string> + <string name="video_backend">ビデオレンダラ</string> + <string name="video_backend_to_use">使用するビデオレンダラー</string> + + <!-- Miscellaneous --> + <string name="yes">はい</string> + <string name="no">いいえ</string> + +</resources> diff --git a/Source/Android/res/values/prefvalues.xml b/Source/Android/res/values/prefvalues.xml index 409666e328..8564801f6f 100644 --- a/Source/Android/res/values/prefvalues.xml +++ b/Source/Android/res/values/prefvalues.xml @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string-array name="gpuOptions"> + <string-array name="gpuOptions" translatable="false"> <item>Software Renderer</item> <item>OpenGL ES 3</item> </string-array> - <string-array name="gpuValues"> + <string-array name="gpuValues" translatable="false"> <item>Software Renderer</item> <item>OGL</item> </string-array> diff --git a/Source/Android/res/values/strings.xml b/Source/Android/res/values/strings.xml index 40a14e3b4e..ea1e02297a 100644 --- a/Source/Android/res/values/strings.xml +++ b/Source/Android/res/values/strings.xml @@ -1,8 +1,83 @@ <?xml version="1.0" encoding="utf-8"?> <resources> + <!-- Title of the app --> <string name="app_name">Dolphin Emulator</string> + + <!-- Navigation-related Strings --> <string name="drawer_open">Open navigation drawer</string> <string name="drawer_close">Close navigation drawer</string> + + <!-- About Fragment --> + <string name="build_revision">Build Revision:</string> + <string name="supports_gles3">Supports OpenGL ES 3:</string> + + <!-- Folder Browser --> + <string name="current_dir">Current Dir: </string> + <string name="parent_directory">Parent Directory</string> + <string name="folder">Folder</string> + <string name="file_size">File Size: </string> + <string name="cant_use_compressed_filetypes">Can not use compressed file types</string> + + <!-- Game List Activity --> + <string name="game_list">Game List</string> + <string name="browse_folder">Browse Folder</string> + <string name="settings">Settings</string> + <string name="gamepad_config">Gamepad Config</string> + <string name="about">About</string> + <string name="loading_browser">Loading up the browser</string> + <string name="loading_settings">Loading up settings</string> + <string name="loading_gamepad">Loading up gamepad config</string> + <string name="loading_about">Loading about menu</string> + + <!-- Game List Fragment --> + <string name="file_clicked">File clicked: </string> + + <!-- Input Config Fragment --> + <string name="draw_onscreen_controls">Draw on-screen controls</string> + <string name="button_a">Button A</string> + <string name="button_b">Button B</string> + <string name="button_start">Button Start</string> + <string name="button_x">Button X</string> + <string name="button_y">Button Y</string> + <string name="button_z">Button Z</string> + <string name="dpad_up">D-Pad Up</string> + <string name="dpad_down">D-Pad Down</string> + <string name="dpad_left">D-Pad Left</string> + <string name="dpad_right">D-Pad Right</string> + <string name="main_stick_up">Main Stick Up</string> + <string name="main_stick_down">Main Stick Down</string> + <string name="main_stick_left">Main Stick Left</string> + <string name="main_stick_right">Main Stick Right</string> + <string name="c_stick_up">C Stick Up</string> + <string name="c_stick_down">C Stick Down</string> + <string name="c_stick_left">C Stick Left</string> + <string name="c_stick_right">C Stick Right</string> + <string name="trigger_left">Trigger L</string> + <string name="trigger_right">Trigger R</string> + + <string name="not_drawing_onscreen_controls">Not drawing on-screen controls</string> + <string name="drawing_onscreen_controls">Drawing on-screen controls</string> + <string name="press_button_to_config">Press button to configure %1$s</string> + + <!-- Prefs Fragment --> + <string name="interpreter">Interpreter</string> + <string name="jit64_recompiler">JIT64 Recompiler</string> + <string name="jitil_recompiler">JITIL Recompiler</string> + <string name="jit_arm_recompiler">JIT ARM Recompiler</string> + <string name="cpu_core">CPU Core</string> + <string name="cpu_settings">CPU Settings</string> + <string name="emu_core_to_use">Emulation core to use</string> + <string name="dual_core">Dual Core</string> + <string name="on_off">On/Off</string> + + <string name="video_settings">Video Settings</string> + <string name="software_renderer">Software Renderer</string> + <string name="video_backend">Video Backend</string> + <string name="video_backend_to_use">Video backend to use</string> + + <!-- Miscellaneous --> + <string name="yes">Yes</string> + <string name="no">No</string> </resources> diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java index 5c47b79a3e..e05d1c7db2 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java @@ -16,45 +16,53 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class AboutFragment extends Fragment { +public final class AboutFragment extends Fragment +{ private static Activity m_activity; private ListView mMainList; private FolderBrowserAdapter adapter; - private int configPosition = 0; 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); + + String yes = getString(R.string.yes); + String no = getString(R.string.no); - List<GameListItem> Input = new ArrayList<GameListItem>(); - int a = 0; + List<FolderBrowserItem> Input = new ArrayList<FolderBrowserItem>(); + Input.add(new FolderBrowserItem(m_activity, getString(R.string.build_revision), NativeLibrary.GetVersionString(), "", true)); + Input.add(new FolderBrowserItem(m_activity, getString(R.string.supports_gles3), PrefsFragment.SupportsGLES3() ? yes : no, "", true)); - Input.add(a++, new GameListItem(m_activity, "Build Revision", NativeLibrary.GetVersionString(), "", true)); - Input.add(a++, new GameListItem(m_activity, "Supports OpenGL ES 3", PrefsFragment.SupportsGLES3() ? "Yes" : "No", "", true)); - adapter = new FolderBrowserAdapter(m_activity, R.layout.folderbrowser, Input); + adapter = new FolderBrowserAdapter(m_activity, R.layout.about_layout, Input); mMainList.setAdapter(adapter); 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 6cad8cb3bd..d1e23d1e53 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java @@ -17,7 +17,7 @@ import android.view.WindowManager; import java.io.*; import java.util.List; -public class DolphinEmulator<MainActivity> extends Activity +public final class DolphinEmulator<MainActivity> extends Activity { static private NativeGLSurfaceView GLview = null; static private boolean Running = false; @@ -25,27 +25,32 @@ public 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(); - in = null; - out.flush(); out.close(); - out = null; - } catch(IOException e) { - Log.e("tag", "Failed to copy asset file: " + asset, 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); } } @@ -57,6 +62,7 @@ public class DolphinEmulator<MainActivity> extends Activity if (Running) NativeLibrary.StopEmulation(); } + @Override public void onPause() { @@ -64,6 +70,7 @@ public class DolphinEmulator<MainActivity> extends Activity if (Running) NativeLibrary.PauseEmulation(); } + @Override public void onResume() { @@ -74,11 +81,11 @@ public 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) { - Intent ListIntent = new Intent(this, GameListActivity.class); startActivityForResult(ListIntent, 1); @@ -96,41 +103,19 @@ public class DolphinEmulator<MainActivity> extends Activity directory.mkdirs(); // Copy assets if needed - java.io.File file = new java.io.File( - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "GC" + File.separator + "dsp_coef.bin"); + File file = new File(GCDir + File.separator + "dsp_coef.bin"); if(!file.exists()) { - CopyAsset("ButtonA.png", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "ButtonA.png"); - CopyAsset("ButtonB.png", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "ButtonB.png"); - CopyAsset("ButtonStart.png", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "ButtonStart.png"); - CopyAsset("NoBanner.png", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "NoBanner.png"); - CopyAsset("GCPadNew.ini", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "Config" + File.separator + "GCPadNew.ini"); - CopyAsset("Dolphin.ini", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "Config" + File.separator + "Dolphin.ini"); - CopyAsset("dsp_coef.bin", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "GC" + File.separator + "dsp_coef.bin"); - CopyAsset("dsp_rom.bin", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "GC" + File.separator + "dsp_rom.bin"); - CopyAsset("font_ansi.bin", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "GC" + File.separator + "font_ansi.bin"); - CopyAsset("font_sjis.bin", - Environment.getExternalStorageDirectory()+File.separator+ - "dolphin-emu" + File.separator + "GC" + File.separator + "font_sjis.bin"); + CopyAsset("ButtonA.png", BaseDir + File.separator + "ButtonA.png"); + CopyAsset("ButtonB.png", BaseDir + File.separator + "ButtonB.png"); + CopyAsset("ButtonStart.png", BaseDir + File.separator + "ButtonStart.png"); + CopyAsset("NoBanner.png", BaseDir + File.separator + "NoBanner.png"); + CopyAsset("GCPadNew.ini", ConfigDir + File.separator + "GCPadNew.ini"); + CopyAsset("Dolphin.ini", ConfigDir + File.separator + "Dolphin.ini"); + CopyAsset("dsp_coef.bin", GCDir + File.separator + "dsp_coef.bin"); + CopyAsset("dsp_rom.bin", GCDir + File.separator + "dsp_rom.bin"); + CopyAsset("font_ansi.bin", GCDir + File.separator + "font_ansi.bin"); + CopyAsset("font_sjis.bin", GCDir + File.separator + "font_sjis.bin"); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = prefs.edit(); @@ -169,11 +154,9 @@ public class DolphinEmulator<MainActivity> extends Activity @Override public boolean onTouchEvent(MotionEvent event) { - float X, Y; - int Action; - X = event.getX(); - Y = event.getY(); - Action = event.getActionMasked(); + float X = event.getX(); + float Y = event.getY(); + int Action = event.getActionMasked(); // Converts button locations 0 - 1 to OGL screen coords -1.0 - 1.0 float ScreenX = ((X / screenWidth) * 2.0f) - 1.0f; @@ -186,7 +169,8 @@ public 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 @@ -208,7 +192,8 @@ public class DolphinEmulator<MainActivity> extends Activity if (Running) { - switch (event.getAction()) { + switch (event.getAction()) + { case KeyEvent.ACTION_DOWN: action = 0; break; @@ -226,21 +211,21 @@ public 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); } InputDevice input = event.getDevice(); List<InputDevice.MotionRange> motions = input.getMotionRanges(); - for (int a = 0; a < motions.size(); ++a) + + for (InputDevice.MotionRange range : motions) { - InputDevice.MotionRange range; - range = motions.get(a); - NativeLibrary.onGamePadMoveEvent(InputConfigFragment.getInputDesc(input), range.getAxis(), event.getAxisValue(range.getAxis())); + NativeLibrary.onGamePadMoveEvent(InputConfigFragment.getInputDesc(input), range.getAxis(), event.getAxisValue(range.getAxis())); } return true; } - -}
\ No newline at end of file +}
\ 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 9094486197..3e2c93a3eb 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 class FolderBrowser extends Fragment { +public final class FolderBrowser extends Fragment +{ private Activity m_activity; private FolderBrowserAdapter adapter; private ListView mDrawerList; @@ -24,14 +25,14 @@ public class FolderBrowser extends Fragment { // Populates the FolderView with the given currDir's contents. private void Fill(File currDir) { - m_activity.setTitle("Current Dir: " + currDir.getName()); + m_activity.setTitle(getString(R.string.current_dir) + currDir.getName()); File[] dirs = currDir.listFiles(); - List<GameListItem>dir = new ArrayList<GameListItem>(); - List<GameListItem>fls = new ArrayList<GameListItem>(); + List<FolderBrowserItem>dir = new ArrayList<FolderBrowserItem>(); + List<FolderBrowserItem>fls = new ArrayList<FolderBrowserItem>(); // Supported extensions to filter by Set<String> validExts = new HashSet<String>(Arrays.asList(".gcm", ".iso", ".wbfs", ".gcz", ".dol", ".elf", ".dff")); - Set<String> archiveExts = new HashSet<String>(Arrays.asList(".zip", ".rar", ".7z")); + Set<String> invalidExts = new HashSet<String>(Arrays.asList(".zip", ".rar", ".7z")); // Search for any directories or supported files within the current dir. try @@ -44,17 +45,17 @@ public class FolderBrowser extends Fragment { { if(entry.isDirectory()) { - dir.add(new GameListItem(m_activity, entryName,"Folder",entry.getAbsolutePath(), true)); + dir.add(new FolderBrowserItem(m_activity, entryName, entry.getAbsolutePath(), true)); } else { if (validExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) { - fls.add(new GameListItem(m_activity, entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), true)); + fls.add(new FolderBrowserItem(m_activity, entryName,getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), true)); } - else if (archiveExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) + else if (invalidExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) { - fls.add(new GameListItem(m_activity, entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), false)); + fls.add(new FolderBrowserItem(m_activity, entryName,getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), false)); } } } @@ -70,16 +71,16 @@ public class FolderBrowser extends Fragment { // Check for a parent directory to the one we're currently in. if (!currDir.getPath().equalsIgnoreCase("/")) - dir.add(0, new GameListItem(m_activity, "..", "Parent Directory", currDir.getParent(), true)); + dir.add(0, new FolderBrowserItem(m_activity, "..", getString(R.string.parent_directory), currDir.getParent(), true)); adapter = new FolderBrowserAdapter(m_activity, R.layout.folderbrowser, dir); mDrawerList = (ListView) rootView.findViewById(R.id.gamelist); 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()); @@ -94,29 +95,35 @@ public class FolderBrowser extends Fragment { { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - GameListItem o = adapter.getItem(position); - if(o.getData().equalsIgnoreCase("folder") || o.getData().equalsIgnoreCase("parent directory")) + FolderBrowserItem o = adapter.getItem(position); + if(o.isDirectory() || o.getSubtitle().equalsIgnoreCase(getString(R.string.parent_directory))) { currentDir = new File(o.getPath()); Fill(currentDir); } else - if (o.isValid()) + { + if (o.isValidItem()) FolderSelected(); else - Toast.makeText(m_activity, "Can not use compressed file types.", Toast.LENGTH_LONG).show(); + Toast.makeText(m_activity, getString(R.string.cant_use_compressed_filetypes), Toast.LENGTH_LONG).show(); + } } }; @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 30c1747781..979ad35865 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java @@ -1,58 +1,88 @@ package org.dolphinemu.dolphinemu; import android.content.Context; +import android.content.res.Resources; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageView; import android.widget.TextView; import java.util.List; -public class FolderBrowserAdapter extends ArrayAdapter<GameListItem>{ +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<GameListItem>items; - - public FolderBrowserAdapter(Context context, int textViewResourceId, - List<GameListItem> objects) { + public FolderBrowserAdapter(Context context, int textViewResourceId, List<FolderBrowserItem> objects) + { super(context, textViewResourceId, objects); c = context; id = textViewResourceId; items = objects; } - public GameListItem getItem(int i) + public FolderBrowserItem getItem(int i) { 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) { - LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - v = vi.inflate(id, null); + if (v == null) + { + LayoutInflater vi = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + v = vi.inflate(id, parent, false); } - final GameListItem o = items.get(position); - if (o != null) { - TextView t1 = (TextView) v.findViewById(R.id.FolderTitle); - TextView t2 = (TextView) v.findViewById(R.id.FolderSubTitle); + + final FolderBrowserItem item = items.get(position); + if (item != null) + { + ImageView iconView = (ImageView) v.findViewById(R.id.ImageIcon); + TextView mainText = (TextView) v.findViewById(R.id.FolderTitle); + TextView subtitleText = (TextView) v.findViewById(R.id.FolderSubTitle); - if(t1!=null) + if(mainText != null) { - t1.setText(o.getName()); - if (!o.isValid()) - t1.setTextColor(0xFFFF0000); + mainText.setText(item.getName()); + + if (!item.isValidItem()) + { + mainText.setTextColor(0xFFFF0000); + } + } + + if(subtitleText != null) + { + // Remove the subtitle for all folders, except for the parent directory folder. + if (item.isDirectory() && !item.getSubtitle().equals(c.getResources().getString(R.string.parent_directory))) + { + subtitleText.setVisibility(View.GONE); + } + else + { + subtitleText.setText(item.getSubtitle()); + } + } + + if (iconView != null) + { + if (item.isDirectory()) + { + iconView.setImageResource(R.drawable.ic_menu_folder); + } + else + { + iconView.setImageResource(R.drawable.ic_menu_file); + } } - if(t2!=null) - t2.setText(o.getData()); } return v; } - - - } - diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java new file mode 100644 index 0000000000..a895da8c43 --- /dev/null +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java @@ -0,0 +1,131 @@ +package org.dolphinemu.dolphinemu; + +import java.io.File; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.drawable.Drawable; + +/** + * Represents an item in the folder browser list. + */ +public final class FolderBrowserItem implements Comparable<FolderBrowserItem> +{ + private final Context ctx; + private final String name; + private final String subtitle; + private final String path; + private final boolean isValid; + private final File underlyingFile; + + /** + * Constructor + * + * @param ctx Context this FolderBrowserItem is being used in. + * @param name The name of the file/folder represented by this item. + * @param subtitle The subtitle of this FolderBrowserItem to display. + * @param path The path of the file/folder represented by this item. + * @param isValid Whether or not this item represents a file type that can be handled. + */ + public FolderBrowserItem(Context ctx, String name, String subtitle, String path, boolean isValid) + { + this.ctx = ctx; + this.name = name; + this.subtitle = subtitle; + this.path = path; + this.isValid = isValid; + this.underlyingFile = new File(path); + } + + /** + * Constructor. Initializes a FolderBrowserItem with an empty subtitle. + * + * @param ctx Context this FolderBrowserItem is being used in. + * @param name The name of the file/folder represented by this item. + * @param path The path of the file/folder represented by this item. + * @param isValid Whether or not this item represents a file type that can be handled. + */ + public FolderBrowserItem(Context ctx, String name, String path, boolean isValid) + { + this.ctx = ctx; + this.name = name; + this.subtitle = ""; + this.path = path; + this.isValid = isValid; + this.underlyingFile = new File(path); + } + + /** + * Gets the name of the file/folder represented by this FolderBrowserItem. + * + * @return the name of the file/folder represented by this FolderBrowserItem. + */ + public String getName() + { + return name; + } + + /** + * Gets the subtitle text of this FolderBrowserItem. + * + * @return the subtitle text of this FolderBrowserItem. + */ + public String getSubtitle() + { + return subtitle; + } + + /** + * Gets the path of the file/folder represented by this FolderBrowserItem. + * + * @return the path of the file/folder represented by this FolderBrowserItem. + */ + public String getPath() + { + return path; + } + + /** + * Gets whether or not the file represented + * by this FolderBrowserItem is supported + * and can be handled correctly. + * + * @return whether or not the file represented + * by this FolderBrowserItem is supported + * and can be handled correctly. + */ + public boolean isValidItem() + { + return isValid; + } + + /** + * Gets the {@link File} representation of the underlying file/folder + * represented by this FolderBrowserItem. + * + * @return the {@link File} representation of the underlying file/folder + * represented by this FolderBrowserItem. + */ + public File getUnderlyingFile() + { + return underlyingFile; + } + + /** + * Gets whether or not this FolderBrowserItem represents a directory. + * + * @return true if this FolderBrowserItem represents a directory, false otherwise. + */ + public boolean isDirectory() + { + return underlyingFile.isDirectory(); + } + + public int compareTo(FolderBrowserItem other) + { + if(this.name != null) + return this.name.toLowerCase().compareTo(other.getName().toLowerCase()); + else + throw new IllegalArgumentException(); + } +} diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java index 9a48de4d8b..2bd61cb0f2 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java @@ -22,8 +22,9 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class GameListActivity extends Activity - implements GameListFragment.OnGameListZeroListener{ +public final class GameListActivity extends Activity + implements GameListFragment.OnGameListZeroListener +{ private int mCurFragmentNum = 0; private Fragment mCurFragment; @@ -43,7 +44,8 @@ public 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; @@ -52,11 +54,11 @@ public class GameListActivity extends Activity mDrawerList = (ListView) findViewById(R.id.left_drawer); List<SideMenuItem> dir = new ArrayList<SideMenuItem>(); - dir.add(new SideMenuItem("Game List", 0)); - dir.add(new SideMenuItem("Browse Folder", 1)); - dir.add(new SideMenuItem("Settings", 2)); - dir.add(new SideMenuItem("Gamepad Config", 3)); - dir.add(new SideMenuItem("About", 4)); + dir.add(new SideMenuItem(getString(R.string.game_list), 0)); + dir.add(new SideMenuItem(getString(R.string.browse_folder), 1)); + dir.add(new SideMenuItem(getString(R.string.settings), 2)); + dir.add(new SideMenuItem(getString(R.string.gamepad_config), 3)); + dir.add(new SideMenuItem(getString(R.string.about), 4)); mDrawerAdapter = new SideMenuAdapter(this, R.layout.sidemenu, dir); mDrawerList.setAdapter(mDrawerAdapter); @@ -94,16 +96,19 @@ public 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 class GameListActivity extends Activity } } break; + case 3: // Gamepad settings { InputConfigAdapter adapter = ((InputConfigFragment)mCurFragment).getAdapter(); @@ -162,11 +168,13 @@ public class GameListActivity extends Activity } } break; + case 0: // Game List case 4: // About /* Do Nothing */ break; } + switch(toPage) { case 0: @@ -177,46 +185,52 @@ public class GameListActivity extends Activity fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + case 1: { - Toast.makeText(mMe, "Loading up the browser", Toast.LENGTH_SHORT).show(); + Toast.makeText(mMe, getString(R.string.loading_browser), Toast.LENGTH_SHORT).show(); mCurFragmentNum = 1; mCurFragment = new FolderBrowser(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + case 2: { - Toast.makeText(mMe, "Loading up settings", Toast.LENGTH_SHORT).show(); + Toast.makeText(mMe, getString(R.string.loading_settings), Toast.LENGTH_SHORT).show(); mCurFragmentNum = 2; mCurFragment = new PrefsFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + case 3: { - Toast.makeText(mMe, "Loading up gamepad config", Toast.LENGTH_SHORT).show(); + Toast.makeText(mMe, getString(R.string.loading_gamepad), Toast.LENGTH_SHORT).show(); mCurFragmentNum = 3; mCurFragment = new InputConfigFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, mCurFragment).commit(); } break; + case 4: { - Toast.makeText(mMe, "Loading up About", Toast.LENGTH_SHORT).show(); + Toast.makeText(mMe, getString(R.string.about), Toast.LENGTH_SHORT).show(); mCurFragmentNum = 4; mCurFragment = new AboutFragment(); FragmentManager fragmentManager = getFragmentManager(); 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 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 986f33555b..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 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 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 152c18662b..13f66c1c83 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java @@ -24,20 +24,23 @@ import java.util.Set; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class GameListFragment extends Fragment +public final class GameListFragment extends Fragment { private ListView mMainList; private GameListAdapter mGameAdapter; 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>(); @@ -49,9 +52,9 @@ public class GameListFragment extends Fragment for (int a = 0; a < intDirectories; ++a) { - String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(a), ""); + 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) @@ -63,7 +66,7 @@ public class GameListFragment extends Fragment if(!entry.isDirectory()) { if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) - fls.add(new GameListItem(mMe.getApplicationContext(), entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), true)); + fls.add(new GameListItem(mMe.getApplicationContext(), entryName, getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), true)); } } } @@ -81,8 +84,8 @@ public 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,36 +94,43 @@ public class GameListFragment extends Fragment return mMainList; } + private AdapterView.OnItemClickListener mGameItemClickListener = new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { GameListItem o = mGameAdapter.getItem(position); - if(!(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory"))) + if(!(o.getData().equalsIgnoreCase(getString(R.string.folder))||o.getData().equalsIgnoreCase(getString(R.string.parent_directory)))) { onFileClick(o.getPath()); } } }; + private void onFileClick(String o) { - Toast.makeText(mMe, "File Clicked: " + o, Toast.LENGTH_SHORT).show(); + Toast.makeText(mMe, getString(R.string.file_clicked) + o, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra("Select", o); 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 427cd132f8..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 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 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 b0984dd08a..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 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 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, null); + 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 3a6e855c3b..530f8b1d3b 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigFragment.java @@ -18,8 +18,9 @@ import java.util.List; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class InputConfigFragment extends Fragment - implements GameListActivity.OnGameConfigListener{ +public final class InputConfigFragment extends Fragment + implements GameListActivity.OnGameConfigListener +{ private Activity m_activity; private ListView mDrawerList; private InputConfigAdapter adapter; @@ -31,45 +32,47 @@ public 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>(); - int a = 0; - - Input.add(a++, new InputConfigItem("Draw on-screen controls", "Android-ScreenControls", "True")); - Input.add(a++, new InputConfigItem("Button A", "Android-InputA")); - Input.add(a++, new InputConfigItem("Button B", "Android-InputB")); - Input.add(a++, new InputConfigItem("Button Start", "Android-InputStart")); - Input.add(a++, new InputConfigItem("Button X", "Android-InputX")); - Input.add(a++, new InputConfigItem("Button Y", "Android-InputY")); - Input.add(a++, new InputConfigItem("Button Z", "Android-InputZ")); - Input.add(a++, new InputConfigItem("D-Pad Up", "Android-DPadUp")); - Input.add(a++, new InputConfigItem("D-Pad Down", "Android-DPadDown")); - Input.add(a++, new InputConfigItem("D-Pad Left", "Android-DPadLeft")); - Input.add(a++, new InputConfigItem("D-Pad Right", "Android-DPadRight")); - Input.add(a++, new InputConfigItem("Main Stick Up", "Android-MainUp")); - Input.add(a++, new InputConfigItem("Main Stick Down", "Android-MainDown")); - Input.add(a++, new InputConfigItem("Main Stick Left", "Android-MainLeft")); - Input.add(a++, new InputConfigItem("Main Stick Right", "Android-MainRight")); - Input.add(a++, new InputConfigItem("C Stick Up", "Android-CStickUp")); - Input.add(a++, new InputConfigItem("C Stick Down", "Android-CStickDown")); - Input.add(a++, new InputConfigItem("C Stick Left", "Android-CStickLeft")); - Input.add(a++, new InputConfigItem("C Stick Right", "Android-CStickRight")); - Input.add(a++, new InputConfigItem("Trigger L", "Android-InputL")); - Input.add(a++, new InputConfigItem("Trigger R", "Android-InputR")); + Input.add(new InputConfigItem(getString(R.string.draw_onscreen_controls), "Android-ScreenControls", "True")); + Input.add(new InputConfigItem(getString(R.string.button_a), "Android-InputA")); + Input.add(new InputConfigItem(getString(R.string.button_b), "Android-InputB")); + Input.add(new InputConfigItem(getString(R.string.button_start), "Android-InputStart")); + Input.add(new InputConfigItem(getString(R.string.button_x), "Android-InputX")); + Input.add(new InputConfigItem(getString(R.string.button_y), "Android-InputY")); + Input.add(new InputConfigItem(getString(R.string.button_z), "Android-InputZ")); + Input.add(new InputConfigItem(getString(R.string.dpad_up), "Android-DPadUp")); + Input.add(new InputConfigItem(getString(R.string.dpad_down), "Android-DPadDown")); + Input.add(new InputConfigItem(getString(R.string.dpad_left), "Android-DPadLeft")); + Input.add(new InputConfigItem(getString(R.string.dpad_right), "Android-DPadRight")); + Input.add(new InputConfigItem(getString(R.string.main_stick_up), "Android-MainUp")); + Input.add(new InputConfigItem(getString(R.string.main_stick_down), "Android-MainDown")); + Input.add(new InputConfigItem(getString(R.string.main_stick_left), "Android-MainLeft")); + Input.add(new InputConfigItem(getString(R.string.main_stick_right), "Android-MainRight")); + Input.add(new InputConfigItem(getString(R.string.c_stick_up), "Android-CStickUp")); + Input.add(new InputConfigItem(getString(R.string.c_stick_down), "Android-CStickDown")); + Input.add(new InputConfigItem(getString(R.string.c_stick_left), "Android-CStickLeft")); + Input.add(new InputConfigItem(getString(R.string.c_stick_right), "Android-CStickRight")); + Input.add(new InputConfigItem(getString(R.string.trigger_left), "Android-InputL")); + Input.add(new InputConfigItem(getString(R.string.trigger_right), "Android-InputR")); adapter = new InputConfigAdapter(m_activity, R.layout.folderbrowser, Input); View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); @@ -79,6 +82,7 @@ public 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) @@ -90,20 +94,22 @@ public class InputConfigFragment extends Fragment String newBind; if (o.getBind().equals("True")) { - Toast.makeText(m_activity, "Not Drawing on screen controls", Toast.LENGTH_SHORT).show(); + Toast.makeText(m_activity, getString(R.string.not_drawing_onscreen_controls), Toast.LENGTH_SHORT).show(); newBind = "False"; } else { - Toast.makeText(m_activity, "Drawing on screen controls", Toast.LENGTH_SHORT).show(); + Toast.makeText(m_activity, getString(R.string.drawing_onscreen_controls), Toast.LENGTH_SHORT).show(); newBind = "True"; } adapter.remove(o); o.setBind(newBind); adapter.insert(o, position); break; + default: // gamepad controls - Toast.makeText(m_activity, "Press button to configure " + o.getName(), Toast.LENGTH_SHORT).show(); + + Toast.makeText(m_activity, getString(R.string.press_button_to_config, o.getName()), Toast.LENGTH_SHORT).show(); configPosition = position; Configuring = true; firstEvent = true; @@ -112,19 +118,21 @@ public class InputConfigFragment extends Fragment } }; - static ArrayList<Float> m_values = new ArrayList<Float>(); + private static ArrayList<Float> m_values = new ArrayList<Float>(); - void AssignBind(String bind) + private void AssignBind(String bind) { InputConfigItem o = adapter.getItem(configPosition); adapter.remove(o); o.setBind(bind); adapter.insert(o, configPosition); } + public InputConfigAdapter getAdapter() { return adapter; } + // Called from GameListActivity public boolean onMotionEvent(MotionEvent event) { @@ -138,17 +146,20 @@ public class InputConfigFragment extends Fragment if (firstEvent) { m_values.clear(); - for (InputDevice.MotionRange range : motions) { + + for (InputDevice.MotionRange range : motions) + { m_values.add(event.getAxisValue(range.getAxis())); } + firstEvent = false; } else { for (int a = 0; a < motions.size(); ++a) { - InputDevice.MotionRange range; - range = motions.get(a); + InputDevice.MotionRange range = motions.get(a); + if (m_values.get(a) > (event.getAxisValue(range.getAxis()) + 0.5f)) { AssignBind("Device '" + InputConfigFragment.getInputDesc(input) + "'-Axis " + range.getAxis() + "-"); @@ -164,10 +175,12 @@ public class InputConfigFragment extends Fragment } return true; } + public boolean onKeyEvent(KeyEvent event) { - Log.w("Dolphinemu", "Got Event " + event.getAction()); - switch (event.getAction()) { + Log.w("InputConfigFragment", "Got Event " + event.getAction()); + switch (event.getAction()) + { case KeyEvent.ACTION_DOWN: case KeyEvent.ACTION_UP: if (Configuring) @@ -177,6 +190,7 @@ public class InputConfigFragment extends Fragment Configuring = false; return true; } + default: break; } @@ -185,14 +199,18 @@ public 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 7511406dc9..70e68261ec 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java @@ -1,49 +1,92 @@ -package org.dolphinemu.dolphinemu; - -/** +/* * Copyright 2013 Dolphin Emulator Project * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class InputConfigItem implements Comparable<InputConfigItem>{ + +package org.dolphinemu.dolphinemu; + +/** + * Represents a controller input item (button, stick, etc). + */ +public final class InputConfigItem implements Comparable<InputConfigItem> +{ private String m_name; private String m_Config; private String m_bind; - private void Init(String n, String c, String d) + private void Init(String name, String config, String defaultBind) { - m_name = n; - m_Config = c; + m_name = name; + m_Config = config; String ConfigValues[] = m_Config.split("-"); String Key = ConfigValues[0]; String Value = ConfigValues[1]; - m_bind = NativeLibrary.GetConfig("Dolphin.ini", Key, Value, d); + m_bind = NativeLibrary.GetConfig("Dolphin.ini", Key, Value, defaultBind); } - public InputConfigItem(String n, String c, String d) + /** + * Constructor + * + * @param name Name of the input config item. + * @param config Name of the key in the configuration file that this control modifies. + * @param defaultBind Default binding to fall back upon if binding fails. + */ + public InputConfigItem(String name, String config, String defaultBind) { - Init(n, c, d); + Init(name, config, defaultBind); } - public InputConfigItem(String n, String c) + /** + * Constructor that creates an InputConfigItem + * that has a default binding of "None" + * + * @param name Name of the input config item. + * @param config Name of the key in the configuration file that this control modifies. + */ + public InputConfigItem(String name, String config) { - Init(n, c, "None"); + Init(name, config, "None"); } + + /** + * Gets the name of this InputConfigItem. + * + * @return the name of this InputConfigItem + */ public String getName() { return m_name; } + + /** + * Gets the config key this InputConfigItem modifies. + * + * @return the config key this InputConfigItem modifies. + */ public String getConfig() { return m_Config; } + + /** + * Gets the currently set binding of this InputConfigItem + * + * @return the currently set binding of this InputConfigItem + */ public String getBind() { return m_bind; } - public void setBind(String b) + + /** + * Sets a new binding for this InputConfigItem. + * + * @param bind The new binding. + */ + public void setBind(String bind) { - m_bind = b; + m_bind = bind; } public int compareTo(InputConfigItem o) diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeGLSurfaceView.java index 030c7ed823..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 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 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 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 f089362c38..14f7527c1d 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -1,14 +1,20 @@ +/* + * Copyright 2013 Dolphin Emulator Project + * Licensed under GPLv2 + * Refer to the license.txt file included. + */ + package org.dolphinemu.dolphinemu; import android.util.Log; import android.view.Surface; /** - * Copyright 2013 Dolphin Emulator Project - * Licensed under GPLv2 - * Refer to the license.txt file included. + * Class which contains methods that interact + * with the native side of the Dolphin code. */ -public 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 1263c03798..ad69a89a9d 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java @@ -1,5 +1,7 @@ package org.dolphinemu.dolphinemu; +import java.util.HashMap; + import android.app.Activity; import android.os.Build; import android.os.Bundle; @@ -15,10 +17,12 @@ import javax.microedition.khronos.opengles.GL10; * Licensed under GPLv2 * Refer to the license.txt file included. */ -public 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; @@ -29,8 +33,8 @@ public class PrefsFragment extends PreferenceFragment { String mThreadOwner; - public VersionCheck() { - + public VersionCheck() + { int[] version = new int[2]; int[] attribList = new int[] { EGL10.EGL_WIDTH, 1, @@ -38,13 +42,18 @@ public class PrefsFragment extends PreferenceFragment { EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE }; + int EGL_CONTEXT_CLIENT_VERSION = 0x3098; + int[] ctx_attribs = new int[] { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL10.EGL_NONE + }; // No error checking performed, minimum required code to elucidate logic mEGL = (EGL10) EGLContext.getEGL(); mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); mEGL.eglInitialize(mEGLDisplay, version); mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated - mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, null); + mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, ctx_attribs); mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList); mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); mGL = (GL10) mEGLContext.getGL(); @@ -62,11 +71,14 @@ public 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, @@ -88,35 +100,38 @@ public class PrefsFragment extends PreferenceFragment { return mEGLConfigs[0]; // Best match is probably the first configuration } } + static public boolean SupportsGLES3() { - String m_GLVersion; - String m_GLVendor; - String m_GLRenderer; - VersionCheck mbuffer = new VersionCheck(); - m_GLVersion = mbuffer.getVersion(); - m_GLVendor = mbuffer.getVendor(); - m_GLRenderer = mbuffer.getRenderer(); + String m_GLVersion = mbuffer.getVersion(); + String m_GLVendor = mbuffer.getVendor(); + String m_GLRenderer = mbuffer.getRenderer(); boolean mSupportsGLES3 = false; - if (m_GLVersion.contains("OpenGL ES 3.0") || - m_GLVersion.equals("OpenGL ES 3.0")) // 3.0 support + // Check for OpenGL ES 3 support (General case). + if (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0")) mSupportsGLES3 = true; + + // Checking for OpenGL ES 3 support for certain Qualcomm devices. if (!mSupportsGLES3 && m_GLVendor.equals("Qualcomm")) { if (m_GLRenderer.contains("Adreno (TM) 3")) { - int mVStart, mVEnd = 0; + int mVStart = m_GLVersion.indexOf("V@") + 2; + int mVEnd = 0; float mVersion; - mVStart = m_GLVersion.indexOf("V@") + 2; + for (int a = mVStart; a < m_GLVersion.length(); ++a) + { if (m_GLVersion.charAt(a) == ' ') { mVEnd = a; break; } + } + mVersion = Float.parseFloat(m_GLVersion.substring(mVStart, mVEnd)); if (mVersion >= 14.0f) @@ -125,47 +140,41 @@ public 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 addPreferencesFromResource(R.layout.prefs); final ListPreference etp = new ListPreference(m_activity); - CharSequence[] _entries; - CharSequence[] _entryvalues; + final HashMap<CharSequence, CharSequence> entries = new HashMap<CharSequence, CharSequence>(); if (Build.CPU_ABI.contains("x86")) { - _entries = new CharSequence[] { - "Interpreter", - "JIT64 Recompiler", - "JITIL Recompiler", - }; - _entryvalues = new CharSequence[] {"0", "1", "2"}; + entries.put(getString(R.string.interpreter), "0"); + entries.put(getString(R.string.jit64_recompiler), "1"); + entries.put(getString(R.string.jitil_recompiler), "2"); } else if (Build.CPU_ABI.contains("arm")) { - _entries = new CharSequence[] { - "Interpreter", - "JIT ARM Recompiler", - }; - _entryvalues = new CharSequence[] {"0", "3"}; + entries.put(getString(R.string.interpreter), "0"); + entries.put(getString(R.string.jit_arm_recompiler), "3"); } else { - _entries = new CharSequence[] { - "Interpreter", - }; - _entryvalues = new CharSequence[] {"0"}; + entries.put(getString(R.string.interpreter), "0"); } - - etp.setEntries(_entries); - etp.setEntryValues(_entryvalues); + + // Convert the key/value sections to arrays respectively so the list can be set. + // If Java had proper generics it wouldn't look this disgusting. + etp.setEntries(entries.keySet().toArray(new CharSequence[entries.size()])); + etp.setEntryValues(entries.values().toArray(new CharSequence[entries.size()])); etp.setKey("cpupref"); - etp.setTitle("CPU Core"); - etp.setSummary("Emulation core to use"); + etp.setTitle(getString(R.string.cpu_core)); + etp.setSummary(getString(R.string.emu_core_to_use)); PreferenceCategory mCategory = (PreferenceCategory) findPreference("cpuprefcat"); mCategory.addPreference(etp); @@ -180,31 +189,34 @@ public class PrefsFragment extends PreferenceFragment { final ListPreference videobackend = new ListPreference(m_activity); - _entries = new CharSequence[] { - "Software Renderer", - }; - _entryvalues = new CharSequence[] {"Software Renderer"}; + // Add available graphics renderers to the hashmap to add to the list. + entries.clear(); + entries.put(getString(R.string.software_renderer), "Software Renderer"); videobackend.setKey("gpupref"); - videobackend.setTitle("Video Backend"); - videobackend.setSummary("Video backend to use"); + videobackend.setTitle(getString(R.string.video_backend)); + videobackend.setSummary(getString(R.string.video_backend_to_use)); - videobackend.setEntries(_entries); - videobackend.setEntryValues(_entryvalues); + videobackend.setEntries(entries.keySet().toArray(new CharSequence[entries.size()])); + videobackend.setEntryValues(entries.values().toArray(new CharSequence[entries.size()])); mCategory.addPreference(videobackend); } } @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 599ce5007a..11c071b026 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java @@ -9,41 +9,45 @@ import android.widget.TextView; import java.util.List; -public 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; id = textViewResourceId; items = objects; } + public SideMenuItem getItem(int i) - { + { return items.get(i); - } - @Override - public View getView(int position, View convertView, ViewGroup parent) { - View v = convertView; - if (v == null) { - LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - v = vi.inflate(id, null); - } - final SideMenuItem o = items.get(position); - if (o != null) { - TextView t1 = (TextView) v.findViewById(R.id.SideMenuTitle); - - if(t1!=null) - t1.setText(o.getName()); - } - return v; - } - - - + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) + { + View v = convertView; + if (v == null) + { + LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + v = vi.inflate(id, null); + } + + final SideMenuItem item = items.get(position); + if (item != null) + { + TextView title = (TextView) v.findViewById(R.id.SideMenuTitle); + + 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 e24842bed1..51ebc93c19 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java @@ -1,25 +1,47 @@ -package org.dolphinemu.dolphinemu; - -/** +/* * Copyright 2013 Dolphin Emulator Project * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class SideMenuItem implements Comparable<SideMenuItem>{ - private String m_name; - private int m_id; +package org.dolphinemu.dolphinemu; + - public SideMenuItem(String n, int id) +/** + * Represents an item that goes in the sidemenu of the app. + */ +public final class SideMenuItem implements Comparable<SideMenuItem> +{ + private final String m_name; + private final int m_id; + + /** + * Constructor + * + * @param name The name of the SideMenuItem. + * @param id ID number of this specific SideMenuItem. + */ + public SideMenuItem(String name, int id) { - m_name = n; + m_name = name; m_id = id; } + /** + * Gets the name of this SideMenuItem. + * + * @return the name of this SideMenuItem. + */ public String getName() { return m_name; } + + /** + * Gets the ID of this SideMenuItem. + * + * @return the ID of this SideMenuItem. + */ public int getID() { return m_id; |
