From ad4ecbab0e56d989c62636982f7fb7e7ae55e76e Mon Sep 17 00:00:00 2001 From: TwistedUmbrella Date: Mon, 3 Mar 2014 11:37:29 -0500 Subject: [PATCH 1/7] Integrate an inline messaging system using Android GCM --- shell/android/res/layout/drawer_menu.xml | 119 ++-- shell/android/res/layout/toast_layout.xml | 32 + shell/android/res/values/strings.xml | 2 + .../com/reicast/emulator/AboutFragment.java | 9 +- .../com/reicast/emulator/MainActivity.java | 16 +- .../com/reicast/emulator/config/Config.java | 37 ++ shell/debug/AndroidManifest.xml | 26 +- shell/debug/build.xml | 2 +- shell/debug/res/drawable/gradient_bg.xml | 12 + .../debug/res/drawable/gradient_bg_hover.xml | 12 + shell/debug/res/drawable/image_bg.xml | 14 + shell/debug/res/drawable/list_selector.xml | 9 + shell/debug/res/layout/dialog_item.xml | 57 ++ shell/debug/res/layout/dialog_message.xml | 38 ++ shell/debug/res/values/colors.xml | 5 + shell/debug/res/values/strings.xml | 2 +- shell/debug/res/values/themes.xml | 12 + .../src/com/reicast/emulator/debug/Debug.java | 554 ++++++++++++++++++ .../com/reicast/emulator/debug/Debugger.java | 28 - .../emulator/debug/ExpandableListView.java | 33 ++ .../emulator/debug/GcmBroadcastReceiver.java | 89 +++ .../emulator/debug/RequestArchive.java | 123 ++++ 22 files changed, 1146 insertions(+), 85 deletions(-) create mode 100755 shell/android/res/layout/toast_layout.xml create mode 100755 shell/debug/res/drawable/gradient_bg.xml create mode 100755 shell/debug/res/drawable/gradient_bg_hover.xml create mode 100755 shell/debug/res/drawable/image_bg.xml create mode 100755 shell/debug/res/drawable/list_selector.xml create mode 100644 shell/debug/res/layout/dialog_item.xml create mode 100644 shell/debug/res/layout/dialog_message.xml create mode 100755 shell/debug/res/values/colors.xml create mode 100644 shell/debug/res/values/themes.xml create mode 100644 shell/debug/src/com/reicast/emulator/debug/Debug.java delete mode 100644 shell/debug/src/com/reicast/emulator/debug/Debugger.java create mode 100644 shell/debug/src/com/reicast/emulator/debug/ExpandableListView.java create mode 100644 shell/debug/src/com/reicast/emulator/debug/GcmBroadcastReceiver.java create mode 100644 shell/debug/src/com/reicast/emulator/debug/RequestArchive.java diff --git a/shell/android/res/layout/drawer_menu.xml b/shell/android/res/layout/drawer_menu.xml index c13daa8f1..62ce95152 100644 --- a/shell/android/res/layout/drawer_menu.xml +++ b/shell/android/res/layout/drawer_menu.xml @@ -3,8 +3,8 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:background="@drawable/background" > + android:background="@drawable/background" + android:orientation="vertical" > + android:gravity="center_vertical|left" + android:orientation="horizontal" > + android:textAppearance="@style/BaseText" + android:textSize="28dp" /> + android:gravity="center_vertical|left" + android:orientation="horizontal" > + android:textAppearance="@style/BaseText" + android:textSize="28dp" /> + android:gravity="center_vertical|left" + android:orientation="horizontal" > + android:textAppearance="@style/BaseText" + android:textSize="28dp" /> + android:gravity="center_vertical|left" + android:orientation="horizontal" > + android:textAppearance="@style/BaseText" + android:textSize="28dp" /> + android:gravity="center_vertical|left" + android:orientation="horizontal" > + android:textAppearance="@style/BaseText" + android:textSize="28dp" /> + android:gravity="center_vertical|left" + android:orientation="horizontal" > + android:textAppearance="@style/BaseText" + android:textSize="28dp" /> + + + + + + + diff --git a/shell/android/res/layout/toast_layout.xml b/shell/android/res/layout/toast_layout.xml new file mode 100755 index 000000000..d9a5993fe --- /dev/null +++ b/shell/android/res/layout/toast_layout.xml @@ -0,0 +1,32 @@ + + + + + + + \ No newline at end of file diff --git a/shell/android/res/values/strings.xml b/shell/android/res/values/strings.xml index 72cb6e40f..99229ceba 100644 --- a/shell/android/res/values/strings.xml +++ b/shell/android/res/values/strings.xml @@ -15,6 +15,7 @@ Flash Missing. The Dreamcast Flash is required for this emulator to work. Place the Flash file in %1$s/data/dc_flash.bin You have to provide the BIOS The data folder is assumed + GitHub Native Unavailable! BOOT BIOS SELECT CURRENT FOLDER @@ -87,6 +88,7 @@ Paths Input About + Messages Rate Me ON diff --git a/shell/android/src/com/reicast/emulator/AboutFragment.java b/shell/android/src/com/reicast/emulator/AboutFragment.java index dabe8812b..324087aa2 100644 --- a/shell/android/src/com/reicast/emulator/AboutFragment.java +++ b/shell/android/src/com/reicast/emulator/AboutFragment.java @@ -93,6 +93,7 @@ import android.widget.SlidingDrawer.OnDrawerOpenListener; import android.widget.TextView; import android.widget.Toast; +import com.reicast.emulator.config.Config; import com.reicast.emulator.debug.GitAdapter; @SuppressWarnings("deprecation") @@ -258,9 +259,7 @@ public class AboutFragment extends Fragment { } catch (JSONException e) { handler.post(new Runnable() { public void run() { - Toast.makeText(parentActivity, - "GitHub Native Unavailable!", Toast.LENGTH_LONG) - .show(); + Config.customNotify(parentActivity, R.drawable.ic_github, R.string.git_broken); slidingGithub.close(); } }); @@ -268,9 +267,7 @@ public class AboutFragment extends Fragment { } catch (Exception e) { handler.post(new Runnable() { public void run() { - Toast.makeText(parentActivity, - "GitHub Native Unavailable!", Toast.LENGTH_LONG) - .show(); + Config.customNotify(parentActivity, R.drawable.ic_github, R.string.git_broken); slidingGithub.close(); } }); diff --git a/shell/android/src/com/reicast/emulator/MainActivity.java b/shell/android/src/com/reicast/emulator/MainActivity.java index 6a71452e9..ead481498 100644 --- a/shell/android/src/com/reicast/emulator/MainActivity.java +++ b/shell/android/src/com/reicast/emulator/MainActivity.java @@ -53,6 +53,7 @@ public class MainActivity extends SlidingFragmentActivity implements private UncaughtExceptionHandler mUEHandler; + private Intent debugger; public static boolean debugUser; Gamepad pad = new Gamepad(); @@ -65,8 +66,8 @@ public class MainActivity extends SlidingFragmentActivity implements mPrefs = PreferenceManager.getDefaultSharedPreferences(this); - Intent debugger = new Intent("com.reicast.emulator.debug.Debugger"); - debugger.setAction("com.reicast.emulator.DEBUG"); + debugger = new Intent("com.reicast.emulator.debug.Debug"); + debugger.setAction("reicast.emulator.DEBUG"); if (isCallable(debugger)) { MainActivity.debugUser = true; } @@ -283,6 +284,17 @@ public class MainActivity extends SlidingFragmentActivity implements } }); } + + View messages = findViewById(R.id.message_menu); + if (MainActivity.debugUser) { + messages.setOnClickListener(new OnClickListener() { + public void onClick(View view) { + startActivity(debugger); + } + }); + } else { + messages.setVisibility(View.GONE); + } } }); findViewById(R.id.header_list).setOnTouchListener(new OnTouchListener() { diff --git a/shell/android/src/com/reicast/emulator/config/Config.java b/shell/android/src/com/reicast/emulator/config/Config.java index 5401f5fae..2fae922ae 100644 --- a/shell/android/src/com/reicast/emulator/config/Config.java +++ b/shell/android/src/com/reicast/emulator/config/Config.java @@ -1,10 +1,20 @@ package com.reicast.emulator.config; +import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; +import android.util.DisplayMetrics; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; import com.android.util.DreamTime; +import com.reicast.emulator.R; import com.reicast.emulator.emu.JNIdc; public class Config { @@ -75,4 +85,31 @@ public class Config { JNIdc.dreamtime(DreamTime.getDreamtime()); } + public static void customNotify(Activity activity, int icon, int message) { + LayoutInflater inflater = activity.getLayoutInflater(); + View layout = inflater.inflate(R.layout.toast_layout, + (ViewGroup) activity.findViewById(R.id.toast_layout_root)); + + ImageView image = (ImageView) layout.findViewById(R.id.image); + if (icon != -1) { + image.setImageResource(icon); + } else { + image.setImageResource(R.drawable.ic_launcher); + } + + TextView text = (TextView) layout.findViewById(R.id.text); + text.setText(activity.getString(message)); + + DisplayMetrics metrics = new DisplayMetrics(); + activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); + final float scale = activity.getResources().getDisplayMetrics().density; + int toastPixels = (int) ((metrics.widthPixels * scale + 0.5f) / 14); + + Toast toast = new Toast(activity); + toast.setGravity(Gravity.BOTTOM, 0, toastPixels); + toast.setDuration(Toast.LENGTH_SHORT); + toast.setView(layout); + toast.show(); + } + } diff --git a/shell/debug/AndroidManifest.xml b/shell/debug/AndroidManifest.xml index 2acdba003..57a016c4f 100644 --- a/shell/debug/AndroidManifest.xml +++ b/shell/debug/AndroidManifest.xml @@ -9,18 +9,38 @@ android:targetSdkVersion="18" /> + + + + + + - + android:label="@string/app_name"> + - + + + + + + + + + \ No newline at end of file diff --git a/shell/debug/build.xml b/shell/debug/build.xml index 8164f2645..35d10a74f 100644 --- a/shell/debug/build.xml +++ b/shell/debug/build.xml @@ -1,5 +1,5 @@ - + + + + \ No newline at end of file diff --git a/shell/debug/res/drawable/gradient_bg_hover.xml b/shell/debug/res/drawable/gradient_bg_hover.xml new file mode 100755 index 000000000..aab77af2e --- /dev/null +++ b/shell/debug/res/drawable/gradient_bg_hover.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/shell/debug/res/drawable/image_bg.xml b/shell/debug/res/drawable/image_bg.xml new file mode 100755 index 000000000..a1004de21 --- /dev/null +++ b/shell/debug/res/drawable/image_bg.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/shell/debug/res/drawable/list_selector.xml b/shell/debug/res/drawable/list_selector.xml new file mode 100755 index 000000000..fb1560c2e --- /dev/null +++ b/shell/debug/res/drawable/list_selector.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/shell/debug/res/layout/dialog_item.xml b/shell/debug/res/layout/dialog_item.xml new file mode 100644 index 000000000..a18331bd9 --- /dev/null +++ b/shell/debug/res/layout/dialog_item.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + diff --git a/shell/debug/res/layout/dialog_message.xml b/shell/debug/res/layout/dialog_message.xml new file mode 100644 index 000000000..db9d185ad --- /dev/null +++ b/shell/debug/res/layout/dialog_message.xml @@ -0,0 +1,38 @@ + + + + + +