Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Add an option to clear the game list.
  • Loading branch information
lioncash committed Aug 23, 2013
1 parent c2aef25 commit 1469342
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source/Android/res/values-ja/strings.xml
Expand Up @@ -19,6 +19,8 @@
<string name="file_size">ファイルサイズ: </string>

<!-- Game List Activity -->
<string name="clear_game_list">クリア</string>
<string name="clear_game_list_confirm">ゲームリストからすべての項目を削除しますか?</string>
<string name="game_list">ゲームリスト</string>
<string name="browse_folder">フォルダの参照</string>
<string name="settings">設定</string>
Expand Down
2 changes: 2 additions & 0 deletions Source/Android/res/values/strings.xml
Expand Up @@ -19,6 +19,8 @@
<string name="file_size">File Size: </string>

<!-- Game List Activity -->
<string name="clear_game_list">Clear game list</string>
<string name="clear_game_list_confirm">Do you want to clear the game list?</string>
<string name="game_list">Game List</string>
<string name="browse_folder">Browse Folder</string>
<string name="settings">Settings</string>
Expand Down
Expand Up @@ -7,15 +7,18 @@
package org.dolphinemu.dolphinemu.gamelist;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
import android.view.*;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -248,6 +251,20 @@ public boolean onPrepareOptionsMenu(Menu menu)
{
return super.onPrepareOptionsMenu(menu);
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Only show this in the game list.
if (this.mCurFragmentNum == 0)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.gamelist_menu, menu);
return true;
}

return false;
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
Expand All @@ -259,6 +276,38 @@ public boolean onOptionsItemSelected(MenuItem item)
return true;
}

// If clear game list is pressed.
if (item.getItemId() == R.id.clearGameList)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.clear_game_list);
builder.setMessage(getString(R.string.clear_game_list_confirm));
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which)
{
String directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0");
int intDirs = Integer.parseInt(directories);

for (int i = 0; i < intDirs; i++)
{
NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + i, "");
}

ArrayAdapter<GameListItem> adapter = ((GameListFragment)GameListActivity.this.mCurFragment).getAdapter();
adapter.clear();
adapter.notifyDataSetChanged();
}
});
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which)
{
// Do nothing. This just make "No" appear.
}
});

builder.show();
}

return super.onOptionsItemSelected(item);
}

Expand Down
Expand Up @@ -51,6 +51,16 @@ public final class GameListFragment extends Fragment
*/
void onZeroFiles();
}

/**
* Gets the adapter for this fragment.
*
* @return the adapter for this fragment.
*/
public GameListAdapter getAdapter()
{
return mGameAdapter;
}

private void Fill()
{
Expand Down

0 comments on commit 1469342

Please sign in to comment.