From 927d3bd6ec424babf3069020d512c777f194cfde Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 28 Jan 2018 12:41:18 +0200 Subject: [PATCH] fixed help --- .../android/limbo/main/LimboActivity.java | 39 ++-------------- .../android/limbo/main/LimboSDLActivity.java | 9 +--- .../android/limbo/main/LimboVNCActivity.java | 12 ++--- .../max2idea/android/limbo/utils/UIUtils.java | 44 +++++++++++++++++++ 4 files changed, 52 insertions(+), 52 deletions(-) diff --git a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboActivity.java b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboActivity.java index 775229c9e..f1fc0b082 100644 --- a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboActivity.java +++ b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboActivity.java @@ -315,7 +315,7 @@ public synchronized void handleMessage(Message msg) { if (messageType != null && messageType == Config.UIUTILS_SHOWALERT_HTML) { String title = (String) b.get("title"); String body = (String) b.get("body"); - UIAlertHtml(title, body, activity); + UIUtils.UIAlertHtml(title, body, activity); } if (messageType != null && messageType == Config.STATUS_CHANGED) { String status_changed = (String) b.get("status_changed"); @@ -435,7 +435,7 @@ public static void UIAlertLicense(String title, String html, final Activity acti public void onClick(DialogInterface dialog, int which) { if (isFirstLaunch()) { install(); - onHelp(); + UIUtils.onHelp(activity); onChangeLog(); } setFirstLaunch(); @@ -457,21 +457,7 @@ public void onCancel(DialogInterface dialog) { alertDialog.show(); } - public static void UIAlertHtml(String title, String html, Activity activity) { - AlertDialog alertDialog; - alertDialog = new AlertDialog.Builder(activity).create(); - alertDialog.setTitle(title); - WebView webview = new WebView(activity); - webview.loadData(html, "text/html", "UTF-8"); - alertDialog.setView(webview); - alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - return; - } - }); - alertDialog.show(); - } // Generic Message to update UI public static void sendHandlerMessage(Handler handler, int message_type, String message_var, String message_value) { @@ -528,25 +514,6 @@ private static void onTap() { } } - private static void onHelp() { - PackageInfo pInfo = null; - - try { - pInfo = activity.getPackageManager().getPackageInfo(activity.getClass().getPackage().getName(), - PackageManager.GET_META_DATA); - } catch (NameNotFoundException e) { - e.printStackTrace(); - } - - FileUtils fileutils = new FileUtils(); - try { - showAlertHtml(Config.APP_NAME + " v" + pInfo.versionName, fileutils.LoadFile(activity, "HELP", false), - OShandler); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } private static void onChangeLog() { PackageInfo pInfo = null; @@ -5677,7 +5644,7 @@ public boolean onOptionsItemSelected(final MenuItem item) { } else if (item.getItemId() == this.IMPORT) { this.onImportMachines(); } else if (item.getItemId() == this.HELP) { - this.onHelp(); + UIUtils.onHelp(this); } else if (item.getItemId() == this.VIEWLOG) { this.onViewLog(); } else if (item.getItemId() == this.CHANGELOG) { diff --git a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboSDLActivity.java b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboSDLActivity.java index 3944e3b3f..77c1fc3ca 100644 --- a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboSDLActivity.java +++ b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboSDLActivity.java @@ -529,7 +529,7 @@ public boolean onOptionsItemSelected(final MenuItem item) { this.setZoomable(); } else if (item.getItemId() == this.QUIT) { } else if (item.getItemId() == R.id.itemHelp) { - this.onMenuHelp(); + UIUtils.onHelp(this); } else if (item.getItemId() == R.id.itemHideToolbar) { this.onHideToolbar(); } else if (item.getItemId() == R.id.itemViewLog) { @@ -562,13 +562,6 @@ public void onHideToolbar(){ } } - private static void onMenuHelp() { - String url = "https://github.com/limboemu/limbo"; - Intent i = new Intent(Intent.ACTION_VIEW); - i.setData(Uri.parse(url)); - LimboActivity.activity.startActivity(i); - - } private void onMouse() { diff --git a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboVNCActivity.java b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboVNCActivity.java index fce2d1ef7..7a4092ba3 100644 --- a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboVNCActivity.java +++ b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/main/LimboVNCActivity.java @@ -52,6 +52,7 @@ import com.limbo.emu.lib.R; import com.max2idea.android.limbo.utils.DrivesDialogBox; import com.max2idea.android.limbo.utils.FileUtils; +import com.max2idea.android.limbo.utils.MachineOpenHelper; import com.max2idea.android.limbo.utils.QmpClient; import com.max2idea.android.limbo.utils.UIUtils; @@ -384,7 +385,7 @@ public boolean onOptionsItemSelected(final MenuItem item) { } else if (item.getItemId() == R.id.itemCenterMouse) { return onMouse(); } else if (item.getItemId() == R.id.itemHelp) { - this.onMenuHelp(); + UIUtils.onHelp(this); } else if (item.getItemId() == R.id.itemHideToolbar) { this.onHideToolbar(); } else if (item.getItemId() == R.id.itemViewLog) { @@ -976,13 +977,6 @@ public void run() { return save_state; } - private static void onMenuHelp() { - String url = "https://github.com/limboemu/limbo"; - Intent i = new Intent(Intent.ACTION_VIEW); - i.setData(Uri.parse(url)); - LimboActivity.activity.startActivity(i); - - } public void onBackPressed() { @@ -1011,6 +1005,8 @@ public void onHideToolbar(){ public void onConnected() { this.resumeVMMonitor(); LimboActivity.currMachine.paused = 0; + MachineOpenHelper.getInstance(activity).update(LimboActivity.currMachine, + MachineOpenHelper.getInstance(activity).PAUSED, 0 + ""); } } diff --git a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/utils/UIUtils.java b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/utils/UIUtils.java index 09e7b6420..20351a718 100644 --- a/limbo-android-lib/src/main/java/com/max2idea/android/limbo/utils/UIUtils.java +++ b/limbo-android-lib/src/main/java/com/max2idea/android/limbo/utils/UIUtils.java @@ -1,8 +1,12 @@ package com.max2idea.android.limbo.utils; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.pm.ActivityInfo; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; import android.graphics.Point; import android.os.Handler; import android.os.Looper; @@ -11,11 +15,15 @@ import android.support.v7.widget.Toolbar; import android.view.Display; import android.view.Gravity; +import android.webkit.WebView; import android.widget.Toast; import com.limbo.emu.lib.R; +import com.max2idea.android.limbo.main.Config; import com.max2idea.android.limbo.main.LimboSettingsManager; +import java.io.IOException; + public class UIUtils { public static void toastLong(final Context activity, final String errStr) { @@ -114,4 +122,40 @@ public static boolean isLandscapeOrientation(Activity activity) return false; return true; } + + + public static void onHelp(Activity activity) { + PackageInfo pInfo = null; + + try { + pInfo = activity.getPackageManager().getPackageInfo(activity.getApplicationContext().getPackageName(), + PackageManager.GET_META_DATA); + } catch (Exception e) { + e.printStackTrace(); + } + + FileUtils fileutils = new FileUtils(); + try { + UIAlertHtml(Config.APP_NAME + " v" + pInfo.versionName, fileutils.LoadFile(activity, "HELP", false), activity); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void UIAlertHtml(String title, String html, Activity activity) { + + AlertDialog alertDialog; + alertDialog = new AlertDialog.Builder(activity).create(); + alertDialog.setTitle(title); + WebView webview = new WebView(activity); + webview.loadData(html, "text/html", "UTF-8"); + alertDialog.setView(webview); + alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + return; + } + }); + alertDialog.show(); + } }