Advertisement
Guest User

Hyperspin Launch Source

a guest
Jan 7th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.04 KB | None | 0 0
  1. // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
  2. // Jad home page: http://www.geocities.com/kpdus/jad.html
  3. // Decompiler options: braces fieldsfirst space lnc
  4.  
  5. package com.shieldcade.hyperspin;
  6.  
  7. import android.app.AlertDialog;
  8. import android.app.NativeActivity;
  9. import android.content.ComponentName;
  10. import android.content.Context;
  11. import android.content.DialogInterface;
  12. import android.content.Intent;
  13. import android.content.SharedPreferences;
  14. import android.content.pm.ApplicationInfo;
  15. import android.content.pm.PackageManager;
  16. import android.net.Uri;
  17. import android.os.Bundle;
  18. import android.text.Html;
  19. import android.util.Log;
  20. import android.view.View;
  21. import android.view.Window;
  22. import android.widget.Toast;
  23. import java.io.File;
  24. import java.text.DateFormat;
  25. import java.text.SimpleDateFormat;
  26. import java.util.Date;
  27. import java.util.zip.ZipEntry;
  28. import java.util.zip.ZipFile;
  29.  
  30. public class HSFENativeActivity extends NativeActivity
  31. {
  32.     private class ToastError
  33.         implements Runnable
  34.     {
  35.  
  36.         String text;
  37.         final HSFENativeActivity this$0;
  38.  
  39.         public void run()
  40.         {
  41.             Toast.makeText(HSFENativeActivity.this, text, 0).show();
  42.         }
  43.  
  44.         public ToastError(String s)
  45.         {
  46.             this$0 = HSFENativeActivity.this;
  47.             super();
  48.             text = s;
  49.         }
  50.     }
  51.  
  52.  
  53.     public static final String TAG = "HSFENativeActivity";
  54.  
  55.     public HSFENativeActivity()
  56.     {
  57.     }
  58.  
  59.     private void setUiVisibility(View view, int i)
  60.     {
  61.         if ((i & 4) == 0)
  62.         {
  63.             view.setSystemUiVisibility(5638);
  64.         }
  65.     }
  66.  
  67.     private void setupExtrasIntent(Intent intent, String s, String s1, String s2, String s3)
  68.     {
  69.         intent.putExtra(s, (new StringBuilder(String.valueOf(s2))).append("/").append(s1).append(".").append(s3).toString());
  70.         Log.d("HSFENativeActivity", (new StringBuilder("Extras Intent: ")).append(intent.getComponent().getPackageName()).append("/").append(intent.getComponent().getClassName()).append(" Action: ").append(intent.getAction()).append(" Extra: ").append(s).append(" ").append(intent.getStringExtra(s)).toString());
  71.     }
  72.  
  73.     private void setupLibretroIntent(Intent intent, String s, String s1, String s2, String s3, String s4)
  74.     {
  75.         Context context = getApplicationContext();
  76.         intent.putExtra("ROM", (new StringBuilder(String.valueOf(s2))).append("/").append(s1).append(".").append(s3).toString());
  77.         intent.putExtra("LIBRETRO", (new StringBuilder("/data/data/")).append(s).append("/").append(s4).toString());
  78.         intent.putExtra("CONFIGFILE", (new StringBuilder("/data/data/")).append(s).append("/retroarch.cfg").toString());
  79.         intent.putExtra("IME", android.provider.Settings.Secure.getString(context.getContentResolver(), "default_input_method"));
  80.         intent.putExtra("DATADIR", (new StringBuilder("/data/data/")).append(s).toString());
  81.         Log.d("HSFENativeActivity", (new StringBuilder("Retroarch Intent: ")).append(intent.getComponent().getPackageName()).append(" ROM: ").append(intent.getStringExtra("ROM")).append(" LIBRETRO: ").append(intent.getStringExtra("LIBRETRO")).append(" CONFIGFILE: ").append(intent.getStringExtra("CONFIGFILE")).append(" IME: ").append(intent.getStringExtra("IME")).append(" DATADIR: ").append(intent.getStringExtra("DATADIR")).toString());
  82.     }
  83.  
  84.     private void setupUriIntent(Intent intent, String s, String s1, String s2)
  85.     {
  86.         intent.setData(Uri.parse((new StringBuilder("file://")).append(s1).append("/").append(s).append(".").append(s2).toString()));
  87.         Log.d("HSFENativeActivity", (new StringBuilder("Uri Intent: ")).append(intent.getComponent().getPackageName()).append("/").append(intent.getComponent().getClassName()).append(" Action: ").append(intent.getAction()).append(" Rom: ").append(intent.getDataString()).toString());
  88.     }
  89.  
  90.     private void showAboutDialog()
  91.     {
  92.         String s;
  93.         Object obj;
  94.         obj = "Build Date: ";
  95.         s = ((String) (obj));
  96.         ZipFile zipfile = new ZipFile(getPackageManager().getApplicationInfo(getPackageName(), 0).sourceDir);
  97.         s = ((String) (obj));
  98.         long l = zipfile.getEntry("classes.dex").getTime();
  99.         s = ((String) (obj));
  100.         obj = (new StringBuilder(String.valueOf("Build Date: "))).append(SimpleDateFormat.getDateInstance().format(new Date(l))).toString();
  101.         s = ((String) (obj));
  102.         try
  103.         {
  104.             zipfile.close();
  105.         }
  106.         catch (Exception exception)
  107.         {
  108.             exception = (new StringBuilder(String.valueOf(s))).append("Unknown").toString();
  109.         }
  110.         s = (new StringBuilder(String.valueOf(obj))).append("<br/><br/>").toString();
  111.         obj = new android.app.AlertDialog.Builder(this);
  112.         ((android.app.AlertDialog.Builder) (obj)).setTitle("About");
  113.         ((android.app.AlertDialog.Builder) (obj)).setMessage(Html.fromHtml((new StringBuilder(String.valueOf(s))).append(getString(0x7f030001)).toString()));
  114.         ((android.app.AlertDialog.Builder) (obj)).create().show();
  115.         return;
  116.     }
  117.  
  118.     public boolean launchApp(String s)
  119.     {
  120.         Intent intent = getPackageManager().getLaunchIntentForPackage(s);
  121.         try
  122.         {
  123.             startActivity(intent);
  124.         }
  125.         catch (Exception exception)
  126.         {
  127.             s = (new StringBuilder("Warning - Attempting to launch an invalid app: ")).append(s).toString();
  128.             Log.w("HSFENativeActivity", s);
  129.             runOnUiThread(new ToastError(s));
  130.             return false;
  131.         }
  132.         return true;
  133.     }
  134.  
  135.     public boolean launchEmulator(String s, String s1, String s2, String s3, String s4, String s5)
  136.     {
  137.         String as[];
  138.         int i;
  139.         as = s4.split(",");
  140.         i = 0;
  141.         break MISSING_BLOCK_LABEL_13;
  142.         while (i < as.length && !(new File((new StringBuilder(String.valueOf(s3))).append("/").append(s2).append(".").append(as[i]).toString())).exists())
  143.         {
  144.             i++;
  145.         }
  146.         if (i >= as.length)
  147.         {
  148.             Log.w("HSFENativeActivity", "Warning - Attempting to launch missing rom");
  149.             runOnUiThread(new ToastError("Warning - Attempting to launch missing rom"));
  150.             return false;
  151.         }
  152.         break MISSING_BLOCK_LABEL_114;
  153.         String as1[] = s1.split("\\|");
  154.         s4 = s5.split("\\|");
  155.         s = s4;
  156.         if (s4.length < as1.length)
  157.         {
  158.             s = new String[as1.length];
  159.             System.arraycopy(s4, 0, s, 0, s4.length);
  160.         }
  161.         int j = 0;
  162.         do
  163.         {
  164.             if (j >= as1.length)
  165.             {
  166.                 s = (new StringBuilder("Warning - Attempting to launch invalid emulator(s): ")).append(s1).toString();
  167.                 Log.w("HSFENativeActivity", s);
  168.                 runOnUiThread(new ToastError(s));
  169.                 return false;
  170.             }
  171.             boolean flag = true;
  172.             Log.w("HSFENativeActivity", (new StringBuilder("Attempting ")).append(j).append(": ").append(as1[j]).append(" args: ").append(s[j]).toString());
  173.             s5 = new Intent();
  174.             s4 = as1[j].split("/");
  175.             s5.setComponent(new ComponentName(s4[0], s4[1]));
  176.             if (s4[0].equals("com.retroarch"))
  177.             {
  178.                 setupLibretroIntent(s5, s4[0], s2, s3, as[i], s[j]);
  179.             } else
  180.             if (s[j] != null && !s[j].isEmpty())
  181.             {
  182.                 setupExtrasIntent(s5, s[j], s2, s3, as[i]);
  183.             } else
  184.             {
  185.                 s5.setAction("android.intent.action.VIEW");
  186.                 setupUriIntent(s5, s2, s3, as[i]);
  187.             }
  188.             try
  189.             {
  190.                 startActivity(s5);
  191.             }
  192.             // Misplaced declaration of an exception variable
  193.             catch (String s5)
  194.             {
  195.                 Log.w("HSFENativeActivity", (new StringBuilder("Warning - Launching ")).append(s4[0]).append(" failed").toString());
  196.                 flag = false;
  197.             }
  198.             if (flag)
  199.             {
  200.                 return true;
  201.             }
  202.             j++;
  203.         } while (true);
  204.     }
  205.  
  206.     protected void onCreate(Bundle bundle)
  207.     {
  208.         final View decorView = getWindow().getDecorView();
  209.         decorView.setOnSystemUiVisibilityChangeListener(new android.view.View.OnSystemUiVisibilityChangeListener() {
  210.  
  211.             final HSFENativeActivity this$0;
  212.             private final View val$decorView;
  213.  
  214.             public void onSystemUiVisibilityChange(int i)
  215.             {
  216.                 setUiVisibility(decorView, i);
  217.             }
  218.  
  219.            
  220.             {
  221.                 this$0 = HSFENativeActivity.this;
  222.                 decorView = view;
  223.                 super();
  224.             }
  225.         });
  226.         super.onCreate(bundle);
  227.     }
  228.  
  229.     public void onWindowFocusChanged(boolean flag)
  230.     {
  231.         super.onWindowFocusChanged(flag);
  232.         if (flag)
  233.         {
  234.             setUiVisibility(getWindow().getDecorView(), 0);
  235.         }
  236.     }
  237.  
  238.     public int putgetSharedPrefsFromIni(String s, int i)
  239.     {
  240.         Object obj = getPreferences(0);
  241.         if (i >= 0)
  242.         {
  243.             obj = ((SharedPreferences) (obj)).edit();
  244.             ((android.content.SharedPreferences.Editor) (obj)).putInt(s, i);
  245.             ((android.content.SharedPreferences.Editor) (obj)).commit();
  246.             return -1;
  247.         } else
  248.         {
  249.             return ((SharedPreferences) (obj)).getInt(s, -1);
  250.         }
  251.     }
  252.  
  253.     public void showExitDialog()
  254.     {
  255.         runOnUiThread(new Runnable() {
  256.  
  257.             final HSFENativeActivity this$0;
  258.  
  259.             public void run()
  260.             {
  261.                 android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(HSFENativeActivity.this);
  262.                 builder.setTitle("No Hyperspin Data Folder Found!");
  263.                 builder.setMessage("Valid locations are \"/storage/usbdrive/Hyperspin\", \"/storage/sdcard1/Hyperspin\", or \"/storage/sdcard0/Hyperspin\". Please visit Hyperspin-fe.com for more info.");
  264.                 builder.setPositiveButton("OK", null);
  265.                 builder.setOnDismissListener(new android.content.DialogInterface.OnDismissListener() {
  266.  
  267.                     final _cls2 this$1;
  268.  
  269.                     public void onDismiss(DialogInterface dialoginterface)
  270.                     {
  271.                         finish();
  272.                     }
  273.  
  274.            
  275.             {
  276.                 this$1 = _cls2.this;
  277.                 super();
  278.             }
  279.                 });
  280.                 builder.create().show();
  281.             }
  282.  
  283.  
  284.            
  285.             {
  286.                 this$0 = HSFENativeActivity.this;
  287.                 super();
  288.             }
  289.         });
  290.     }
  291.  
  292.     public void showMenu()
  293.     {
  294.         runOnUiThread(new Runnable() {
  295.  
  296.             final HSFENativeActivity this$0;
  297.  
  298.             public void run()
  299.             {
  300.                 android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(HSFENativeActivity.this);
  301.                 builder.setItems(0x7f040000, new android.content.DialogInterface.OnClickListener() {
  302.  
  303.                     final _cls1 this$1;
  304.  
  305.                     public void onClick(DialogInterface dialoginterface, int i)
  306.                     {
  307.                         switch (i)
  308.                         {
  309.                         default:
  310.                             return;
  311.  
  312.                         case 0: // '\0'
  313.                             showAboutDialog();
  314.                             break;
  315.                         }
  316.                     }
  317.  
  318.            
  319.             {
  320.                 this$1 = _cls1.this;
  321.                 super();
  322.             }
  323.                 });
  324.                 builder.create().show();
  325.             }
  326.  
  327.  
  328.            
  329.             {
  330.                 this$0 = HSFENativeActivity.this;
  331.                 super();
  332.             }
  333.         });
  334.     }
  335.  
  336.     static
  337.     {
  338.         System.loadLibrary("avformat");
  339.         System.loadLibrary("avcodec");
  340.         System.loadLibrary("swscale");
  341.         System.loadLibrary("avutil");
  342.     }
  343.  
  344.  
  345. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement