[Android] Initial implementation of the extended info menu.

Most fragments are not implemented yet. This is just a working base framework for it.
This commit is contained in:
Lioncash 2014-01-07 19:47:15 -05:00
parent 7acc64eb0a
commit 45964e4b46
8 changed files with 178 additions and 28 deletions

View File

@ -33,6 +33,7 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="org.dolphinemu.dolphinemu.about.AboutActivity"/>
<activity android:name="org.dolphinemu.dolphinemu.gamelist.GameListActivity"/> <activity android:name="org.dolphinemu.dolphinemu.gamelist.GameListActivity"/>
<activity <activity

View File

@ -12,6 +12,10 @@
<string name="build_revision">ビルドのバージョン</string> <string name="build_revision">ビルドのバージョン</string>
<string name="supports_gles3">サポートのOpenGL ES 3</string> <string name="supports_gles3">サポートのOpenGL ES 3</string>
<string name="supports_neon">サポートのNEON</string> <string name="supports_neon">サポートのNEON</string>
<string name="cpu">CPU</string>
<string name="gles_two">GLES 2</string>
<string name="gles_three">GLES 3</string>
<string name="desktop_gl">OpenGL</string>
<!-- Folder Browser --> <!-- Folder Browser -->
<string name="current_dir">現在のディレクトリ: %1$s</string> <string name="current_dir">現在のディレクトリ: %1$s</string>

View File

@ -12,6 +12,11 @@
<string name="build_revision">Build Revision</string> <string name="build_revision">Build Revision</string>
<string name="supports_gles3">Supports OpenGL ES 3</string> <string name="supports_gles3">Supports OpenGL ES 3</string>
<string name="supports_neon">Supports NEON</string> <string name="supports_neon">Supports NEON</string>
<string name="general">General</string>
<string name="cpu">CPU</string>
<string name="gles_two">GLES 2</string>
<string name="gles_three">GLES 3</string>
<string name="desktop_gl">OpenGL</string>
<!-- Folder Browser --> <!-- Folder Browser -->
<string name="current_dir">Current Dir: %1$s</string> <string name="current_dir">Current Dir: %1$s</string>

View File

@ -0,0 +1,151 @@
package org.dolphinemu.dolphinemu.about;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.settings.video.VideoSettingsFragment;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.ActionBar.TabListener;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
/**
* Activity for the about menu, which displays info
* related to the CPU and GPU. Along with misc other info.
*/
public final class AboutActivity extends Activity implements TabListener
{
private ViewPager viewPager;
private boolean supportsGles3;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set the view pager
setContentView(R.layout.viewpager);
viewPager = (ViewPager) findViewById(R.id.pager);
// Check if GLES3 is supported
supportsGles3 = VideoSettingsFragment.SupportsGLES3();
// Initialize the ViewPager adapter.
final ViewPagerAdapter adapter = new ViewPagerAdapter(getFragmentManager());
viewPager.setAdapter(adapter);
// Set up the ActionBar
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.addTab(actionBar.newTab().setText(R.string.general).setTabListener(this));
actionBar.addTab(actionBar.newTab().setText(R.string.cpu).setTabListener(this));
actionBar.addTab(actionBar.newTab().setText(R.string.gles_two).setTabListener(this));
if (supportsGles3)
actionBar.addTab(actionBar.newTab().setText(R.string.gles_three).setTabListener(this));
// TODO: Check if Desktop GL is possible before enabling.
actionBar.addTab(actionBar.newTab().setText(R.string.desktop_gl).setTabListener(this));
// Set the page change listener
viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener()
{
@Override
public void onPageSelected(int position)
{
actionBar.setSelectedNavigationItem(position);
}
});
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft)
{
// When the given tab is selected, switch to the corresponding page in the ViewPager.
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft)
{
// Do nothing.
}
@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft)
{
// Do nothing.
}
/**
* {@link FragmentPagerAdapter} subclass responsible for handling
* the individual {@link Fragment}s within the {@link ViewPager}.
*/
private final class ViewPagerAdapter extends FragmentPagerAdapter
{
public ViewPagerAdapter(FragmentManager fm)
{
super(fm);
}
@Override
public Fragment getItem(int position)
{
switch (position)
{
case 0: return new DolphinInfoFragment();
// TODO: The rest of these fragments
case 1: return new Fragment(); // CPU
case 2: return new Fragment(); // GLES 2
case 3: return new Fragment(); // GLES 3
case 4: return new Fragment(); // Desktop GL
default: // Should never happen
return null;
}
}
@Override
public int getCount()
{
// TODO: In the future, make sure to take into account
// whether or not regular Desktop GL is possible.
if (supportsGles3)
{
return 5;
}
else
{
return 4;
}
}
@Override
public CharSequence getPageTitle(int position)
{
switch (position)
{
case 0:
return getString(R.string.general);
case 1:
return getString(R.string.cpu);
case 2:
return getString(R.string.gles_two);
case 3:
return getString(R.string.gles_three);
case 4:
return getString(R.string.desktop_gl);
default: // Should never happen
return null;
}
}
}
}

View File

@ -4,7 +4,7 @@
* Refer to the license.txt file included. * Refer to the license.txt file included.
*/ */
package org.dolphinemu.dolphinemu; package org.dolphinemu.dolphinemu.about;
import android.app.ListFragment; import android.app.ListFragment;
import android.content.Context; import android.content.Context;
@ -19,12 +19,14 @@ import android.widget.TextView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.settings.video.VideoSettingsFragment; import org.dolphinemu.dolphinemu.settings.video.VideoSettingsFragment;
/** /**
* Represents the about screen. * Represents the about screen.
*/ */
public final class AboutFragment extends ListFragment public final class DolphinInfoFragment extends ListFragment
{ {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
@ -39,14 +41,14 @@ public final class AboutFragment extends ListFragment
Input.add(new AboutFragmentItem(getString(R.string.supports_gles3), VideoSettingsFragment.SupportsGLES3() ? yes : no)); Input.add(new AboutFragmentItem(getString(R.string.supports_gles3), VideoSettingsFragment.SupportsGLES3() ? yes : no));
Input.add(new AboutFragmentItem(getString(R.string.supports_neon), NativeLibrary.SupportsNEON() ? yes : no)); Input.add(new AboutFragmentItem(getString(R.string.supports_neon), NativeLibrary.SupportsNEON() ? yes : no));
AboutFragmentAdapter adapter = new AboutFragmentAdapter(getActivity(), R.layout.about_layout, Input); InfoFragmentAdapter adapter = new InfoFragmentAdapter(getActivity(), R.layout.about_layout, Input);
rootView.setAdapter(adapter); rootView.setAdapter(adapter);
rootView.setEnabled(false); // Makes the list view non-clickable. rootView.setEnabled(false); // Makes the list view non-clickable.
return rootView; return rootView;
} }
// Represents an item in the AboutFragment. // Represents an item in the DolphinInfoFragment.
private static final class AboutFragmentItem private static final class AboutFragmentItem
{ {
private final String title; private final String title;
@ -69,14 +71,14 @@ public final class AboutFragment extends ListFragment
} }
} }
// The adapter that manages the displaying of items in this AboutFragment. // The adapter that manages the displaying of items in this DolphinInfoFragment.
private static final class AboutFragmentAdapter extends ArrayAdapter<AboutFragmentItem> private static final class InfoFragmentAdapter extends ArrayAdapter<AboutFragmentItem>
{ {
private final Context ctx; private final Context ctx;
private final int id; private final int id;
private final List<AboutFragmentItem> items; private final List<AboutFragmentItem> items;
public AboutFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items) public InfoFragmentAdapter(Context ctx, int id, List<AboutFragmentItem> items)
{ {
super(ctx, id, items); super(ctx, id, items);

View File

@ -23,9 +23,10 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ListView; import android.widget.ListView;
import org.dolphinemu.dolphinemu.AboutFragment;
import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.about.AboutActivity;
import org.dolphinemu.dolphinemu.folderbrowser.FolderBrowser; import org.dolphinemu.dolphinemu.folderbrowser.FolderBrowser;
import org.dolphinemu.dolphinemu.settings.PrefsActivity; import org.dolphinemu.dolphinemu.settings.PrefsActivity;
import org.dolphinemu.dolphinemu.sidemenu.SideMenuAdapter; import org.dolphinemu.dolphinemu.sidemenu.SideMenuAdapter;
@ -119,11 +120,7 @@ public final class GameListActivity extends Activity
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.device_compat_warning); builder.setTitle(R.string.device_compat_warning);
builder.setMessage(R.string.device_compat_warning_msg); builder.setMessage(R.string.device_compat_warning_msg);
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.yes, null);
public void onClick(DialogInterface dialog, int which) {
// Do Nothing. Just create the Yes button
}
});
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) public void onClick(DialogInterface dialog, int which)
{ {
@ -184,13 +181,8 @@ public final class GameListActivity extends Activity
case 3: // About case 3: // About
{ {
mCurFragmentNum = 3; Intent intent = new Intent(this, AboutActivity.class);
final AboutFragment aboutFragment = new AboutFragment(); startActivity(intent);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, aboutFragment);
ft.addToBackStack(null);
ft.commit();
invalidateOptionsMenu();
} }
break; break;
@ -261,7 +253,8 @@ public final class GameListActivity extends Activity
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.clear_game_list); builder.setTitle(R.string.clear_game_list);
builder.setMessage(getString(R.string.clear_game_list_confirm)); builder.setMessage(getString(R.string.clear_game_list_confirm));
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener(){ builder.setNegativeButton(R.string.no, null);
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) public void onClick(DialogInterface dialog, int which)
{ {
String directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0"); String directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
@ -279,12 +272,6 @@ public final class GameListActivity extends Activity
((GameListFragment) getFragmentManager().findFragmentById(R.id.content_frame)).clearGameList(); ((GameListFragment) getFragmentManager().findFragmentById(R.id.content_frame)).clearGameList();
} }
}); });
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
// Do nothing. This just make "No" appear.
}
});
builder.show(); builder.show();
} }

View File

@ -41,7 +41,7 @@ public final class PrefsActivity extends Activity implements ActionBar.TabListen
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// Set the ViewPager. // Set the ViewPager.
setContentView(R.layout.prefs_viewpager); setContentView(R.layout.viewpager);
mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager = (ViewPager) findViewById(R.id.pager);
// Set the ViewPager adapter. // Set the ViewPager adapter.