Android: Add context menu in the downloader for going to a core's wiki page
This commit is contained in:
parent
4f2909e3b5
commit
8b14bbc6e2
|
@ -0,0 +1,4 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/go_to_wiki_ctx_item"
|
||||
android:title="@string/downloadable_cores_ctx_goto_wiki"/>
|
||||
</menu>
|
|
@ -45,6 +45,10 @@
|
|||
<string name="download_core_confirm_msg">Are you sure you want to download %1$s?</string>
|
||||
<string name="downloading_msg">Downloading %1$s…</string>
|
||||
|
||||
<!-- Core Downloader - Downloadable Cores Context Menu -->
|
||||
<string name="downloadable_cores_ctx_title">Actions</string>
|
||||
<string name="downloadable_cores_ctx_goto_wiki">Go to core wiki page</string>
|
||||
|
||||
<!-- Display Refresh Rate Test Class -->
|
||||
<string name="refresh_rate_calibration">Refresh rate calibration</string>
|
||||
<string name="touch_screen_with_fingers">Touch the screen with your fingers for more accurate measurements.</string>
|
||||
|
|
|
@ -26,13 +26,20 @@ import android.app.AlertDialog;
|
|||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.retroarch.R;
|
||||
|
@ -74,6 +81,7 @@ public final class DownloadableCoresFragment extends ListFragment
|
|||
{
|
||||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
final ListView coreList = (ListView) inflater.inflate(R.layout.coremanager_listview, container, false);
|
||||
registerForContextMenu(coreList);
|
||||
|
||||
final DownloadableCoresAdapter adapter = new DownloadableCoresAdapter(getActivity(), android.R.layout.simple_list_item_2);
|
||||
adapter.setNotifyOnChange(true);
|
||||
|
@ -108,6 +116,37 @@ public final class DownloadableCoresFragment extends ListFragment
|
|||
notification.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
|
||||
{
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
|
||||
menu.setHeaderTitle(R.string.downloadable_cores_ctx_title);
|
||||
|
||||
MenuInflater inflater = getActivity().getMenuInflater();
|
||||
inflater.inflate(R.menu.downloadable_cores_context_menu, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item)
|
||||
{
|
||||
final AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo();
|
||||
|
||||
switch (item.getItemId())
|
||||
{
|
||||
case R.id.go_to_wiki_ctx_item:
|
||||
{
|
||||
String coreUrlPart = ((DownloadableCore)getListView().getItemAtPosition(info.position)).getCoreName().replace(" ", "_");
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://wiki.libretro.com/index.php?title=" + coreUrlPart));
|
||||
startActivity(browserIntent);
|
||||
return true;
|
||||
}
|
||||
|
||||
default:
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
// Async event responsible for populating the Downloadable Cores list.
|
||||
private static final class PopulateCoresListOperation extends AsyncTask<Void, Void, ArrayList<DownloadableCore>>
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue