Add game details as webpage popup during launch process
Currently supports games with standard naming (i.e. Dead or Alive 2) or brackets for details (i.e. Dead or Alive 2 [NTSC-J])
This commit is contained in:
parent
207a063fa1
commit
9de771f30e
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/webframe"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:scrollbars="none" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -42,6 +42,8 @@
|
||||||
|
|
||||||
<string name="games_listing">Game List</string>
|
<string name="games_listing">Game List</string>
|
||||||
|
|
||||||
|
<string name="game_details">Game Information</string>
|
||||||
|
|
||||||
<string name="report_issue">Previous Crash Detected</string>
|
<string name="report_issue">Previous Crash Detected</string>
|
||||||
<string name="bios_config">Configuration failed!</string>
|
<string name="bios_config">Configuration failed!</string>
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,12 @@ import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -26,6 +30,7 @@ import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
@ -35,6 +40,12 @@ import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.View.OnTouchListener;
|
import android.view.View.OnTouchListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
|
import android.webkit.CookieSyncManager;
|
||||||
|
import android.webkit.WebSettings;
|
||||||
|
import android.webkit.WebSettings.PluginState;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
@ -309,9 +320,15 @@ public class FileBrowser extends Fragment {
|
||||||
new OnClickListener() {
|
new OnClickListener() {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
vib.vibrate(50);
|
vib.vibrate(50);
|
||||||
mCallback.onGameSelected(game != null ? Uri
|
String title = "";
|
||||||
.fromFile(game) : Uri.EMPTY);
|
if (name.contains("[")) {
|
||||||
vib.vibrate(250);
|
title = name.substring(0, name.lastIndexOf("["));
|
||||||
|
} else {
|
||||||
|
title = name.substring(0, name.lastIndexOf("."));
|
||||||
|
}
|
||||||
|
String url = "http://www.retrocollect.com/videogamedatabase/results.php?gamename="
|
||||||
|
+ title.replace(" ", "+") + "&mode=releases&platform=21";
|
||||||
|
displayDetails(title, url, game);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -325,13 +342,80 @@ public class FileBrowser extends Fragment {
|
||||||
|| arg1.getActionMasked() == MotionEvent.ACTION_UP) {
|
|| arg1.getActionMasked() == MotionEvent.ACTION_UP) {
|
||||||
view.setBackgroundDrawable(orig_bg);
|
view.setBackgroundDrawable(orig_bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
list.addView(childview);
|
list.addView(childview);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayDetails(String message, String url, final File game) {
|
||||||
|
final AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
||||||
|
builder.setCancelable(true);
|
||||||
|
builder.setTitle(R.string.game_details);
|
||||||
|
builder.setMessage(message);
|
||||||
|
LayoutInflater infalter = LayoutInflater.from(parentActivity);
|
||||||
|
final View popWebView = infalter.inflate(R.layout.webview, null);
|
||||||
|
WebView mWebView = (WebView) popWebView.findViewById(R.id.webframe);
|
||||||
|
mWebView = configureWebview(url, parentActivity, mWebView);
|
||||||
|
builder.setView(popWebView);
|
||||||
|
builder.setPositiveButton("Close",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setPositiveButton("Launch",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
mCallback.onGameSelected(game != null ? Uri
|
||||||
|
.fromFile(game) : Uri.EMPTY);
|
||||||
|
vib.vibrate(250);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static WebView configureWebview(String url, Context context,
|
||||||
|
WebView mWebView) {
|
||||||
|
mWebView.getSettings().setSupportZoom(true);
|
||||||
|
mWebView.getSettings().setBuiltInZoomControls(true);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
mWebView.getSettings().setDisplayZoomControls(false);
|
||||||
|
}
|
||||||
|
mWebView.setInitialScale(1);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
|
||||||
|
mWebView.getSettings().setUseWideViewPort(true);
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
|
||||||
|
mWebView.getSettings().setLoadWithOverviewMode(true);
|
||||||
|
}
|
||||||
|
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
mWebView.getSettings().setPluginState(PluginState.ON);
|
||||||
|
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
|
||||||
|
mWebView.clearHistory();
|
||||||
|
mWebView.clearFormData();
|
||||||
|
mWebView.clearCache(true);
|
||||||
|
CookieSyncManager.createInstance(context);
|
||||||
|
CookieManager cookieManager = CookieManager.getInstance();
|
||||||
|
cookieManager.removeAllCookie();
|
||||||
|
CookieSyncManager.getInstance().stopSync();
|
||||||
|
mWebView.setWebViewClient(new WebViewClient() {
|
||||||
|
@Override
|
||||||
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
|
view.loadUrl(url);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mWebView.loadUrl(url);
|
||||||
|
return mWebView;
|
||||||
|
}
|
||||||
|
|
||||||
void navigate(final File root_sd) {
|
void navigate(final File root_sd) {
|
||||||
LinearLayout v = (LinearLayout) parentActivity
|
LinearLayout v = (LinearLayout) parentActivity
|
||||||
|
|
Loading…
Reference in New Issue