Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Start making it so the side pane is visible on all activiti…
…es by converting them to fragments. Only Browse Folder and Gamepad Config remain. Fix a issue that Lioncash introduced where no games would show up in the folder browser or the game list.
  • Loading branch information
Sonicadvance1 committed Jul 16, 2013
1 parent fbd6732 commit 023922c
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 317 deletions.
4 changes: 2 additions & 2 deletions Source/Android/AndroidManifest.xml
Expand Up @@ -36,13 +36,13 @@
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
</activity>
<activity
android:name=".PrefsActivity" >
android:name=".PrefsFragment" >
</activity>
<activity
android:name=".GameListActivity" >
</activity>
<activity
android:name=".AboutActivity" >
android:name=".AboutFragment" >
</activity>
</application>

Expand Down
31 changes: 0 additions & 31 deletions Source/Android/src/org/dolphinemu/dolphinemu/AboutActivity.java

This file was deleted.

61 changes: 61 additions & 0 deletions Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java
@@ -0,0 +1,61 @@
package org.dolphinemu.dolphinemu;

import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
public 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() {
// Empty constructor required for fragment subclasses
}

@Override
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);

List<GameListItem> Input = new ArrayList<GameListItem>();
int a = 0;

Input.add(a++, new GameListItem(m_activity, "Build Revision", NativeLibrary.GetVersionString(), "", true));
adapter = new FolderBrowserAdapter(m_activity, R.layout.folderbrowser, Input);
mMainList.setAdapter(adapter);

return mMainList;
}
@Override
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 {
m_activity = activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnGameListZeroListener");
}
}
}
Expand Up @@ -50,11 +50,11 @@ private void Fill(File currDir)
}
else
{
if (validExts.contains(entryName.toLowerCase()))
if (validExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.'))))
{
fls.add(new GameListItem(getApplicationContext(), entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), true));
}
else if (archiveExts.contains(entryName.toLowerCase()))
else if (archiveExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.'))))
{
fls.add(new GameListItem(getApplicationContext(), entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), false));
}
Expand Down
154 changes: 90 additions & 64 deletions Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java
Expand Up @@ -28,6 +28,7 @@
public class GameListActivity extends Activity
implements GameListFragment.OnGameListZeroListener{

private int mCurPage = 0;
enum keyTypes {TYPE_STRING, TYPE_BOOL};

private ActionBarDrawerToggle mDrawerToggle;
Expand All @@ -53,10 +54,11 @@ protected void onCreate(Bundle savedInstanceState) {
mDrawerList = (ListView) findViewById(R.id.left_drawer);

List<SideMenuItem> dir = new ArrayList<SideMenuItem>();
dir.add(new SideMenuItem("Browse Folder", 0));
dir.add(new SideMenuItem("Settings", 1));
dir.add(new SideMenuItem("Gamepad Config", 2));
dir.add(new SideMenuItem("About", 3));
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));

mDrawerAdapter = new SideMenuAdapter(this, R.layout.sidemenu, dir);
mDrawerList.setAdapter(mDrawerAdapter);
Expand Down Expand Up @@ -94,67 +96,15 @@ private void recreateFragment()
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
}

private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
private void SwitchPage(int toPage)
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
if (mCurPage == toPage)
return;
switch (mCurPage)
{
SideMenuItem o = mDrawerAdapter.getItem(position);
mDrawerLayout.closeDrawer(mDrawerList);

switch(o.getID())
{
case 0:
Toast.makeText(mMe, "Loading up the browser", Toast.LENGTH_SHORT).show();
Intent ListIntent = new Intent(mMe, FolderBrowser.class);
startActivityForResult(ListIntent, 1);
break;
case 1:
Toast.makeText(mMe, "Loading up settings", Toast.LENGTH_SHORT).show();
Intent SettingIntent = new Intent(mMe, PrefsActivity.class);
startActivityForResult(SettingIntent, 2);
break;
case 2:
Toast.makeText(mMe, "Loading up gamepad config", Toast.LENGTH_SHORT).show();
Intent ConfigIntent = new Intent(mMe, InputConfigActivity.class);
startActivityForResult(ConfigIntent, 3);
break;
case 3:
Toast.makeText(mMe, "Loading up About", Toast.LENGTH_SHORT).show();
Intent AboutIntent = new Intent(mMe, AboutActivity.class);
startActivityForResult(AboutIntent, 3);
break;
default:
break;
}

}
};
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);

switch (requestCode)
{
// Browse
case 1:
if (resultCode == Activity.RESULT_OK)
{
String FileName = data.getStringExtra("Select");
Toast.makeText(this, "Folder Selected: " + FileName, Toast.LENGTH_SHORT).show();
String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
int intDirectories = Integer.parseInt(Directories);
Directories = Integer.toString(intDirectories + 1);
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPathes", Directories);
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(intDirectories), FileName);

recreateFragment();
}
break;
// Settings
case 2:

{
String Keys[] = {
"cpupref",
"dualcorepref",
Expand Down Expand Up @@ -193,9 +143,85 @@ public void onActivityResult(int requestCode, int resultCode, Intent data)
}

}
break;
}
break;
case 0: // Settings
case 3: // Gamepad settings
/* Do Nothing */
/* Do Nothing */
break;
}
switch(toPage)
{
case 0:
{
mCurPage = 0;
Fragment fragment = new GameListFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
}
break;
case 1:
Toast.makeText(mMe, "Loading up the browser", Toast.LENGTH_SHORT).show();
Intent ListIntent = new Intent(mMe, FolderBrowser.class);
startActivityForResult(ListIntent, 1);
break;
case 2:
{
Toast.makeText(mMe, "Loading up settings", Toast.LENGTH_SHORT).show();
mCurPage = 2;
Fragment fragment = new PrefsFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
}
break;
case 3:
Toast.makeText(mMe, "Loading up gamepad config", Toast.LENGTH_SHORT).show();
Intent ConfigIntent = new Intent(mMe, InputConfigActivity.class);
startActivityForResult(ConfigIntent, 3);
break;
case 4:
{
Toast.makeText(mMe, "Loading up About", Toast.LENGTH_SHORT).show();
mCurPage = 4;
Fragment fragment = new AboutFragment();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
}
break;
default:
break;
}
}
private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
SideMenuItem o = mDrawerAdapter.getItem(position);
mDrawerLayout.closeDrawer(mDrawerList);
SwitchPage(o.getID());
}
};
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);

switch (requestCode)
{
// Browse
case 1:
if (resultCode == Activity.RESULT_OK)
{
String FileName = data.getStringExtra("Select");
Toast.makeText(this, "Folder Selected: " + FileName, Toast.LENGTH_SHORT).show();
String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
int intDirectories = Integer.parseInt(Directories);
Directories = Integer.toString(intDirectories + 1);
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPathes", Directories);
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(intDirectories), FileName);

recreateFragment();
}
break;
}
}
Expand Down Expand Up @@ -235,7 +261,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
public void onBackPressed()
{

SwitchPage(0);
}


Expand Down
Expand Up @@ -62,7 +62,7 @@ private void Fill()
{
if(!entry.isDirectory())
{
if (exts.contains(entryName.toLowerCase()))
if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.'))))
fls.add(new GameListItem(mMe.getApplicationContext(), entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), true));
}
}
Expand Down

0 comments on commit 023922c

Please sign in to comment.