commit 8568212428b4e721423bec247e81a4aa090970ff Author: gered Date: Mon Mar 4 19:17:16 2013 -0500 Initial commit in preparation for further work to improve this app. Since it's been a long while since I've worked on it and it was never version controlled to begin with... diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..a4763d1 --- /dev/null +++ b/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a0d8995 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.apk +*.ap_ +*.dex +*.class +bin/ +gen/ +local.properties diff --git a/.project b/.project new file mode 100644 index 0000000..eab381d --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + HTPCRemote + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f77b31c --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..f1cddec --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/proguard-project.txt b/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/project.properties b/project.properties new file mode 100644 index 0000000..6f9611b --- /dev/null +++ b/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt + +# Project target. +target=android-10 diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..96a442e Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ diff --git a/res/drawable-hdpi/remote_button.png b/res/drawable-hdpi/remote_button.png new file mode 100644 index 0000000..562db54 Binary files /dev/null and b/res/drawable-hdpi/remote_button.png differ diff --git a/res/drawable-hdpi/remote_button_big.png b/res/drawable-hdpi/remote_button_big.png new file mode 100644 index 0000000..e2d48a0 Binary files /dev/null and b/res/drawable-hdpi/remote_button_big.png differ diff --git a/res/drawable-hdpi/remote_button_long_horiz.png b/res/drawable-hdpi/remote_button_long_horiz.png new file mode 100644 index 0000000..a2d38c7 Binary files /dev/null and b/res/drawable-hdpi/remote_button_long_horiz.png differ diff --git a/res/drawable-hdpi/remote_button_long_vert.png b/res/drawable-hdpi/remote_button_long_vert.png new file mode 100644 index 0000000..a57be95 Binary files /dev/null and b/res/drawable-hdpi/remote_button_long_vert.png differ diff --git a/res/drawable-hdpi/remote_button_small.png b/res/drawable-hdpi/remote_button_small.png new file mode 100644 index 0000000..3a6c83c Binary files /dev/null and b/res/drawable-hdpi/remote_button_small.png differ diff --git a/res/drawable-ldpi/ic_launcher.png b/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 0000000..9923872 Binary files /dev/null and b/res/drawable-ldpi/ic_launcher.png differ diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..359047d Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..71c6d76 Binary files /dev/null and b/res/drawable-xhdpi/ic_launcher.png differ diff --git a/res/drawable/remote_back.png b/res/drawable/remote_back.png new file mode 100644 index 0000000..344baff Binary files /dev/null and b/res/drawable/remote_back.png differ diff --git a/res/drawable/remote_back_bg.xml b/res/drawable/remote_back_bg.xml new file mode 100644 index 0000000..9a91f0c --- /dev/null +++ b/res/drawable/remote_back_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_back_pressed.png b/res/drawable/remote_back_pressed.png new file mode 100644 index 0000000..a66f40f Binary files /dev/null and b/res/drawable/remote_back_pressed.png differ diff --git a/res/drawable/remote_dpad_down.png b/res/drawable/remote_dpad_down.png new file mode 100644 index 0000000..4ec5d34 Binary files /dev/null and b/res/drawable/remote_dpad_down.png differ diff --git a/res/drawable/remote_dpad_down_bg.xml b/res/drawable/remote_dpad_down_bg.xml new file mode 100644 index 0000000..8697444 --- /dev/null +++ b/res/drawable/remote_dpad_down_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_dpad_down_pressed.png b/res/drawable/remote_dpad_down_pressed.png new file mode 100644 index 0000000..7b19459 Binary files /dev/null and b/res/drawable/remote_dpad_down_pressed.png differ diff --git a/res/drawable/remote_dpad_left.png b/res/drawable/remote_dpad_left.png new file mode 100644 index 0000000..a01a3a6 Binary files /dev/null and b/res/drawable/remote_dpad_left.png differ diff --git a/res/drawable/remote_dpad_left_bg.xml b/res/drawable/remote_dpad_left_bg.xml new file mode 100644 index 0000000..0723ed9 --- /dev/null +++ b/res/drawable/remote_dpad_left_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_dpad_left_pressed.png b/res/drawable/remote_dpad_left_pressed.png new file mode 100644 index 0000000..c7432a6 Binary files /dev/null and b/res/drawable/remote_dpad_left_pressed.png differ diff --git a/res/drawable/remote_dpad_right.png b/res/drawable/remote_dpad_right.png new file mode 100644 index 0000000..28ca632 Binary files /dev/null and b/res/drawable/remote_dpad_right.png differ diff --git a/res/drawable/remote_dpad_right_bg.xml b/res/drawable/remote_dpad_right_bg.xml new file mode 100644 index 0000000..3800ece --- /dev/null +++ b/res/drawable/remote_dpad_right_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_dpad_right_pressed.png b/res/drawable/remote_dpad_right_pressed.png new file mode 100644 index 0000000..ca6f9be Binary files /dev/null and b/res/drawable/remote_dpad_right_pressed.png differ diff --git a/res/drawable/remote_dpad_up.png b/res/drawable/remote_dpad_up.png new file mode 100644 index 0000000..047e8f1 Binary files /dev/null and b/res/drawable/remote_dpad_up.png differ diff --git a/res/drawable/remote_dpad_up_bg.xml b/res/drawable/remote_dpad_up_bg.xml new file mode 100644 index 0000000..be1f398 --- /dev/null +++ b/res/drawable/remote_dpad_up_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_dpad_up_pressed.png b/res/drawable/remote_dpad_up_pressed.png new file mode 100644 index 0000000..9f089f4 Binary files /dev/null and b/res/drawable/remote_dpad_up_pressed.png differ diff --git a/res/drawable/remote_fastforward.png b/res/drawable/remote_fastforward.png new file mode 100644 index 0000000..075534d Binary files /dev/null and b/res/drawable/remote_fastforward.png differ diff --git a/res/drawable/remote_fastforward_bg.xml b/res/drawable/remote_fastforward_bg.xml new file mode 100644 index 0000000..8f0de6e --- /dev/null +++ b/res/drawable/remote_fastforward_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_fastforward_pressed.png b/res/drawable/remote_fastforward_pressed.png new file mode 100644 index 0000000..90e0124 Binary files /dev/null and b/res/drawable/remote_fastforward_pressed.png differ diff --git a/res/drawable/remote_home.png b/res/drawable/remote_home.png new file mode 100644 index 0000000..1cf2389 Binary files /dev/null and b/res/drawable/remote_home.png differ diff --git a/res/drawable/remote_home_bg.xml b/res/drawable/remote_home_bg.xml new file mode 100644 index 0000000..1251175 --- /dev/null +++ b/res/drawable/remote_home_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_home_pressed.png b/res/drawable/remote_home_pressed.png new file mode 100644 index 0000000..ef3235e Binary files /dev/null and b/res/drawable/remote_home_pressed.png differ diff --git a/res/drawable/remote_info.png b/res/drawable/remote_info.png new file mode 100644 index 0000000..867c4a7 Binary files /dev/null and b/res/drawable/remote_info.png differ diff --git a/res/drawable/remote_info_bg.xml b/res/drawable/remote_info_bg.xml new file mode 100644 index 0000000..aa09095 --- /dev/null +++ b/res/drawable/remote_info_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_info_pressed.png b/res/drawable/remote_info_pressed.png new file mode 100644 index 0000000..a9d4ece Binary files /dev/null and b/res/drawable/remote_info_pressed.png differ diff --git a/res/drawable/remote_menu.png b/res/drawable/remote_menu.png new file mode 100644 index 0000000..435b1c4 Binary files /dev/null and b/res/drawable/remote_menu.png differ diff --git a/res/drawable/remote_menu_bg.xml b/res/drawable/remote_menu_bg.xml new file mode 100644 index 0000000..b6527ad --- /dev/null +++ b/res/drawable/remote_menu_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_menu_pressed.png b/res/drawable/remote_menu_pressed.png new file mode 100644 index 0000000..3a8b30b Binary files /dev/null and b/res/drawable/remote_menu_pressed.png differ diff --git a/res/drawable/remote_ok.png b/res/drawable/remote_ok.png new file mode 100644 index 0000000..3926a7d Binary files /dev/null and b/res/drawable/remote_ok.png differ diff --git a/res/drawable/remote_ok_bg.xml b/res/drawable/remote_ok_bg.xml new file mode 100644 index 0000000..91edc7d --- /dev/null +++ b/res/drawable/remote_ok_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_ok_pressed.png b/res/drawable/remote_ok_pressed.png new file mode 100644 index 0000000..e0d53b0 Binary files /dev/null and b/res/drawable/remote_ok_pressed.png differ diff --git a/res/drawable/remote_osd.png b/res/drawable/remote_osd.png new file mode 100644 index 0000000..f64229e Binary files /dev/null and b/res/drawable/remote_osd.png differ diff --git a/res/drawable/remote_osd_bg.xml b/res/drawable/remote_osd_bg.xml new file mode 100644 index 0000000..f59b6bc --- /dev/null +++ b/res/drawable/remote_osd_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_osd_pressed.png b/res/drawable/remote_osd_pressed.png new file mode 100644 index 0000000..27e5f19 Binary files /dev/null and b/res/drawable/remote_osd_pressed.png differ diff --git a/res/drawable/remote_pause.png b/res/drawable/remote_pause.png new file mode 100644 index 0000000..a510bb4 Binary files /dev/null and b/res/drawable/remote_pause.png differ diff --git a/res/drawable/remote_pause_bg.xml b/res/drawable/remote_pause_bg.xml new file mode 100644 index 0000000..55e5390 --- /dev/null +++ b/res/drawable/remote_pause_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_pause_pressed.png b/res/drawable/remote_pause_pressed.png new file mode 100644 index 0000000..8e07dd2 Binary files /dev/null and b/res/drawable/remote_pause_pressed.png differ diff --git a/res/drawable/remote_play.png b/res/drawable/remote_play.png new file mode 100644 index 0000000..ae12c04 Binary files /dev/null and b/res/drawable/remote_play.png differ diff --git a/res/drawable/remote_play_bg.xml b/res/drawable/remote_play_bg.xml new file mode 100644 index 0000000..9c5884d --- /dev/null +++ b/res/drawable/remote_play_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_play_pressed.png b/res/drawable/remote_play_pressed.png new file mode 100644 index 0000000..32eecfb Binary files /dev/null and b/res/drawable/remote_play_pressed.png differ diff --git a/res/drawable/remote_playpause.png b/res/drawable/remote_playpause.png new file mode 100644 index 0000000..94e640e Binary files /dev/null and b/res/drawable/remote_playpause.png differ diff --git a/res/drawable/remote_playpause_bg.xml b/res/drawable/remote_playpause_bg.xml new file mode 100644 index 0000000..848b17b --- /dev/null +++ b/res/drawable/remote_playpause_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_playpause_pressed.png b/res/drawable/remote_playpause_pressed.png new file mode 100644 index 0000000..9e13e0c Binary files /dev/null and b/res/drawable/remote_playpause_pressed.png differ diff --git a/res/drawable/remote_power.png b/res/drawable/remote_power.png new file mode 100644 index 0000000..08c6837 Binary files /dev/null and b/res/drawable/remote_power.png differ diff --git a/res/drawable/remote_power_bg.xml b/res/drawable/remote_power_bg.xml new file mode 100644 index 0000000..2fbc3f8 --- /dev/null +++ b/res/drawable/remote_power_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_power_big.png b/res/drawable/remote_power_big.png new file mode 100644 index 0000000..aad77f7 Binary files /dev/null and b/res/drawable/remote_power_big.png differ diff --git a/res/drawable/remote_power_big_bg.xml b/res/drawable/remote_power_big_bg.xml new file mode 100644 index 0000000..2dc28ce --- /dev/null +++ b/res/drawable/remote_power_big_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_power_big_pressed.png b/res/drawable/remote_power_big_pressed.png new file mode 100644 index 0000000..606baeb Binary files /dev/null and b/res/drawable/remote_power_big_pressed.png differ diff --git a/res/drawable/remote_power_pressed.png b/res/drawable/remote_power_pressed.png new file mode 100644 index 0000000..2b385bf Binary files /dev/null and b/res/drawable/remote_power_pressed.png differ diff --git a/res/drawable/remote_rewind.png b/res/drawable/remote_rewind.png new file mode 100644 index 0000000..5c86ecb Binary files /dev/null and b/res/drawable/remote_rewind.png differ diff --git a/res/drawable/remote_rewind_bg.xml b/res/drawable/remote_rewind_bg.xml new file mode 100644 index 0000000..1e12b13 --- /dev/null +++ b/res/drawable/remote_rewind_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_rewind_pressed.png b/res/drawable/remote_rewind_pressed.png new file mode 100644 index 0000000..218a0b8 Binary files /dev/null and b/res/drawable/remote_rewind_pressed.png differ diff --git a/res/drawable/remote_skip_next.png b/res/drawable/remote_skip_next.png new file mode 100644 index 0000000..3039ab6 Binary files /dev/null and b/res/drawable/remote_skip_next.png differ diff --git a/res/drawable/remote_skip_next_bg.xml b/res/drawable/remote_skip_next_bg.xml new file mode 100644 index 0000000..e0cf70d --- /dev/null +++ b/res/drawable/remote_skip_next_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_skip_next_pressed.png b/res/drawable/remote_skip_next_pressed.png new file mode 100644 index 0000000..cfe41f2 Binary files /dev/null and b/res/drawable/remote_skip_next_pressed.png differ diff --git a/res/drawable/remote_skip_previous.png b/res/drawable/remote_skip_previous.png new file mode 100644 index 0000000..42f297e Binary files /dev/null and b/res/drawable/remote_skip_previous.png differ diff --git a/res/drawable/remote_skip_previous_bg.xml b/res/drawable/remote_skip_previous_bg.xml new file mode 100644 index 0000000..fd2aa0e --- /dev/null +++ b/res/drawable/remote_skip_previous_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_skip_previous_pressed.png b/res/drawable/remote_skip_previous_pressed.png new file mode 100644 index 0000000..a2026b6 Binary files /dev/null and b/res/drawable/remote_skip_previous_pressed.png differ diff --git a/res/drawable/remote_stop.png b/res/drawable/remote_stop.png new file mode 100644 index 0000000..a74a067 Binary files /dev/null and b/res/drawable/remote_stop.png differ diff --git a/res/drawable/remote_stop_bg.xml b/res/drawable/remote_stop_bg.xml new file mode 100644 index 0000000..413a1b8 --- /dev/null +++ b/res/drawable/remote_stop_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_stop_pressed.png b/res/drawable/remote_stop_pressed.png new file mode 100644 index 0000000..2f72574 Binary files /dev/null and b/res/drawable/remote_stop_pressed.png differ diff --git a/res/drawable/remote_togglefullscreen.png b/res/drawable/remote_togglefullscreen.png new file mode 100644 index 0000000..a338043 Binary files /dev/null and b/res/drawable/remote_togglefullscreen.png differ diff --git a/res/drawable/remote_togglefullscreen_bg.xml b/res/drawable/remote_togglefullscreen_bg.xml new file mode 100644 index 0000000..637b9ef --- /dev/null +++ b/res/drawable/remote_togglefullscreen_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/res/drawable/remote_togglefullscreen_pressed.png b/res/drawable/remote_togglefullscreen_pressed.png new file mode 100644 index 0000000..bd9bea5 Binary files /dev/null and b/res/drawable/remote_togglefullscreen_pressed.png differ diff --git a/res/layout-land/widget_remote_control_big.xml b/res/layout-land/widget_remote_control_big.xml new file mode 100644 index 0000000..9a58805 --- /dev/null +++ b/res/layout-land/widget_remote_control_big.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-land/widget_remote_control_medium.xml b/res/layout-land/widget_remote_control_medium.xml new file mode 100644 index 0000000..2c3b30a --- /dev/null +++ b/res/layout-land/widget_remote_control_medium.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-land/widget_remote_control_small.xml b/res/layout-land/widget_remote_control_small.xml new file mode 100644 index 0000000..48a6d6d --- /dev/null +++ b/res/layout-land/widget_remote_control_small.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/remote_control.xml b/res/layout/remote_control.xml new file mode 100644 index 0000000..7419353 --- /dev/null +++ b/res/layout/remote_control.xml @@ -0,0 +1,290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/test_layout.xml b/res/layout/test_layout.xml new file mode 100644 index 0000000..5c7650e --- /dev/null +++ b/res/layout/test_layout.xml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/widget_remote_control_big.xml b/res/layout/widget_remote_control_big.xml new file mode 100644 index 0000000..c2413b2 --- /dev/null +++ b/res/layout/widget_remote_control_big.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/widget_remote_control_medium.xml b/res/layout/widget_remote_control_medium.xml new file mode 100644 index 0000000..81a23ff --- /dev/null +++ b/res/layout/widget_remote_control_medium.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/widget_remote_control_small.xml b/res/layout/widget_remote_control_small.xml new file mode 100644 index 0000000..9249163 --- /dev/null +++ b/res/layout/widget_remote_control_small.xml @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values-land/widget_dimensions_big.xml b/res/values-land/widget_dimensions_big.xml new file mode 100644 index 0000000..ee406ab --- /dev/null +++ b/res/values-land/widget_dimensions_big.xml @@ -0,0 +1,15 @@ + + + + 61dp + 61dp + 78dp + 78dp + 156dp + 156dp + 320dp + 320dp + 1dp + 2dp + + \ No newline at end of file diff --git a/res/values-land/widget_dimensions_medium.xml b/res/values-land/widget_dimensions_medium.xml new file mode 100644 index 0000000..37b469a --- /dev/null +++ b/res/values-land/widget_dimensions_medium.xml @@ -0,0 +1,15 @@ + + + + 45dp + 45dp + 58dp + 58dp + 116dp + 116dp + 240dp + 240dp + 1dp + 2dp + + \ No newline at end of file diff --git a/res/values-land/widget_dimensions_small.xml b/res/values-land/widget_dimensions_small.xml new file mode 100644 index 0000000..6de5b88 --- /dev/null +++ b/res/values-land/widget_dimensions_small.xml @@ -0,0 +1,15 @@ + + + + 29dp + 29dp + 38dp + 38dp + 76dp + 76dp + 160dp + 160dp + 1dp + 2dp + + \ No newline at end of file diff --git a/res/values-sw360dp/activity_dimensions.xml b/res/values-sw360dp/activity_dimensions.xml new file mode 100644 index 0000000..f680f3d --- /dev/null +++ b/res/values-sw360dp/activity_dimensions.xml @@ -0,0 +1,13 @@ + + + + 65dp + 65dp + 84dp + 84dp + 165dp + 165dp + 11dp + 6dp + + \ No newline at end of file diff --git a/res/values-sw800dp/activity_dimensions.xml b/res/values-sw800dp/activity_dimensions.xml new file mode 100644 index 0000000..dffd47b --- /dev/null +++ b/res/values-sw800dp/activity_dimensions.xml @@ -0,0 +1,16 @@ + + + + 130dp + 130dp + 180dp + 180dp + 360dp + 360dp + 740dp + 740dp + 25dp + 3dp + 5dp + + \ No newline at end of file diff --git a/res/values-sw800dp/widget_dimensions_big.xml b/res/values-sw800dp/widget_dimensions_big.xml new file mode 100644 index 0000000..23de100 --- /dev/null +++ b/res/values-sw800dp/widget_dimensions_big.xml @@ -0,0 +1,15 @@ + + + + 74dp + 74dp + 94dp + 94dp + 188dp + 188dp + 384dp + 384dp + 1dp + 2dp + + \ No newline at end of file diff --git a/res/values-sw800dp/widget_dimensions_medium.xml b/res/values-sw800dp/widget_dimensions_medium.xml new file mode 100644 index 0000000..23c4120 --- /dev/null +++ b/res/values-sw800dp/widget_dimensions_medium.xml @@ -0,0 +1,15 @@ + + + + 55dp + 55dp + 70dp + 70dp + 140dp + 140dp + 288dp + 288dp + 1dp + 2dp + + \ No newline at end of file diff --git a/res/values-sw800dp/widget_dimensions_small.xml b/res/values-sw800dp/widget_dimensions_small.xml new file mode 100644 index 0000000..dc16ab8 --- /dev/null +++ b/res/values-sw800dp/widget_dimensions_small.xml @@ -0,0 +1,15 @@ + + + + 35dp + 35dp + 45dp + 45dp + 90dp + 90dp + 189dp + 189dp + 1dp + 2dp + + \ No newline at end of file diff --git a/res/values/activity_dimensions.xml b/res/values/activity_dimensions.xml new file mode 100644 index 0000000..79b1daf --- /dev/null +++ b/res/values/activity_dimensions.xml @@ -0,0 +1,13 @@ + + + + 57dp + 57dp + 73dp + 73dp + 145dp + 145dp + 10dp + 5dp + + \ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml new file mode 100644 index 0000000..7ce9886 --- /dev/null +++ b/res/values/colors.xml @@ -0,0 +1,5 @@ + + + #00000000 + #ff1c1c1c + diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..ad0271d --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,5 @@ + + + HTPC Remote + + \ No newline at end of file diff --git a/res/values/styles.xml b/res/values/styles.xml new file mode 100644 index 0000000..60d37f2 --- /dev/null +++ b/res/values/styles.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/res/values/widget_dimensions_big.xml b/res/values/widget_dimensions_big.xml new file mode 100644 index 0000000..cac3375 --- /dev/null +++ b/res/values/widget_dimensions_big.xml @@ -0,0 +1,11 @@ + + + + 61dp + 61dp + 78dp + 78dp + 156dp + 156dp + + \ No newline at end of file diff --git a/res/values/widget_dimensions_medium.xml b/res/values/widget_dimensions_medium.xml new file mode 100644 index 0000000..a5e6593 --- /dev/null +++ b/res/values/widget_dimensions_medium.xml @@ -0,0 +1,11 @@ + + + + 45dp + 45dp + 58dp + 58dp + 116dp + 116dp + + \ No newline at end of file diff --git a/res/values/widget_dimensions_small.xml b/res/values/widget_dimensions_small.xml new file mode 100644 index 0000000..6de5b88 --- /dev/null +++ b/res/values/widget_dimensions_small.xml @@ -0,0 +1,15 @@ + + + + 29dp + 29dp + 38dp + 38dp + 76dp + 76dp + 160dp + 160dp + 1dp + 2dp + + \ No newline at end of file diff --git a/res/xml/widget_remote_control_big_provider.xml b/res/xml/widget_remote_control_big_provider.xml new file mode 100644 index 0000000..21fbf30 --- /dev/null +++ b/res/xml/widget_remote_control_big_provider.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/res/xml/widget_remote_control_medium_provider.xml b/res/xml/widget_remote_control_medium_provider.xml new file mode 100644 index 0000000..a4233f8 --- /dev/null +++ b/res/xml/widget_remote_control_medium_provider.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/res/xml/widget_remote_control_small_provider.xml b/res/xml/widget_remote_control_small_provider.xml new file mode 100644 index 0000000..ce6e9c3 --- /dev/null +++ b/res/xml/widget_remote_control_small_provider.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/src/com/geredking/htpcremote/HtpcRemoteActivity.java b/src/com/geredking/htpcremote/HtpcRemoteActivity.java new file mode 100644 index 0000000..98e66fb --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcRemoteActivity.java @@ -0,0 +1,27 @@ +package com.geredking.htpcremote; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; + +public class HtpcRemoteActivity extends Activity +{ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.remote_control); + } + + public void onRemoteButtonClick(View v) + { + if (v.getTag() != null) + { + Intent intent = new Intent(this, HtpcRemoteService.class); + intent.setAction(v.getTag().toString()); + intent.addCategory(HtpcRemoteService.INTENT_CATEGORY_BUTTON_PRESS); + startService(intent); + } + } +} \ No newline at end of file diff --git a/src/com/geredking/htpcremote/HtpcRemoteApplication.java b/src/com/geredking/htpcremote/HtpcRemoteApplication.java new file mode 100644 index 0000000..cf05311 --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcRemoteApplication.java @@ -0,0 +1,34 @@ +package com.geredking.htpcremote; + +import com.geredking.htpcremote.remotes.RemoteControl; +import com.geredking.htpcremote.remotes.RemoteControlFactory; + +import android.app.Application; +import android.util.Log; + +public class HtpcRemoteApplication extends Application +{ + private RemoteControl mRemote = null; + + public RemoteControl getRemoteControl() + { + if (mRemote == null) + { + Log.d("HtpcRemoteApplication", "No existing RemoteControl instance, creating one."); + mRemote = RemoteControlFactory.create(this); + } + + return mRemote; + } + + public void refreshRemoteControlConfig() + { + if (mRemote == null) + Log.d("HtpcRemoteApplication", "No existing RemoteControl instance. No need to refresh config."); + else + { + Log.d("HtpcRemoteApplication", "Recreating RemoteControl instance to use new configuration."); + mRemote = RemoteControlFactory.create(this); + } + } +} diff --git a/src/com/geredking/htpcremote/HtpcRemoteService.java b/src/com/geredking/htpcremote/HtpcRemoteService.java new file mode 100644 index 0000000..88553d2 --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcRemoteService.java @@ -0,0 +1,43 @@ +package com.geredking.htpcremote; + +import android.app.IntentService; +import android.content.Intent; +import android.util.Log; + +public class HtpcRemoteService extends IntentService +{ + public static final String SERVICE_NAME = "HtpcRemoteService"; + public static final String INTENT_CATEGORY_BUTTON_PRESS = "com.geredking.htpcremote.INTENT_CATEGORY_BUTTON_PRESS"; + + private HtpcRemoteApplication mApplication; + + public HtpcRemoteService() + { + super(SERVICE_NAME); + } + + @Override + public void onCreate() + { + super.onCreate(); + mApplication = (HtpcRemoteApplication)getApplication(); + } + + @Override + protected void onHandleIntent(Intent intent) + { + Log.d(SERVICE_NAME, String.format("Handling intent: %s", intent)); + String action = intent.getAction(); + if (action == null) + { + Log.d(SERVICE_NAME, "Nothing to handle"); + return; + } + + if (intent.hasCategory(INTENT_CATEGORY_BUTTON_PRESS)) + { + Log.d(SERVICE_NAME, String.format("Running RemoteControl command for action \"%s\"", action)); + mApplication.getRemoteControl().doCommand(action); + } + } +} diff --git a/src/com/geredking/htpcremote/HtpcRemoteWidgetBigProvider.java b/src/com/geredking/htpcremote/HtpcRemoteWidgetBigProvider.java new file mode 100644 index 0000000..08640e8 --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcRemoteWidgetBigProvider.java @@ -0,0 +1,15 @@ +package com.geredking.htpcremote; + +import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.util.Log; + +public class HtpcRemoteWidgetBigProvider extends HtpcRemoteWidgetProvider +{ + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) + { + Log.d("HtpcRemoteWidgetBigProvider", "onUpdate"); + setupWidget(context, appWidgetManager, appWidgetIds, R.layout.widget_remote_control_big); + } +} diff --git a/src/com/geredking/htpcremote/HtpcRemoteWidgetMediumProvider.java b/src/com/geredking/htpcremote/HtpcRemoteWidgetMediumProvider.java new file mode 100644 index 0000000..7c06638 --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcRemoteWidgetMediumProvider.java @@ -0,0 +1,15 @@ +package com.geredking.htpcremote; + +import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.util.Log; + +public class HtpcRemoteWidgetMediumProvider extends HtpcRemoteWidgetProvider +{ + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) + { + Log.d("HtpcRemoteWidgetMediumProvider", "onUpdate"); + setupWidget(context, appWidgetManager, appWidgetIds, R.layout.widget_remote_control_medium); + } +} diff --git a/src/com/geredking/htpcremote/HtpcRemoteWidgetProvider.java b/src/com/geredking/htpcremote/HtpcRemoteWidgetProvider.java new file mode 100644 index 0000000..40b09ad --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcRemoteWidgetProvider.java @@ -0,0 +1,48 @@ +package com.geredking.htpcremote; + +import com.geredking.htpcremote.remotes.RemoteButton; + +import android.app.PendingIntent; +import android.appwidget.AppWidgetManager; +import android.appwidget.AppWidgetProvider; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.util.Log; +import android.widget.RemoteViews; + +public abstract class HtpcRemoteWidgetProvider extends AppWidgetProvider +{ + protected void setupWidget(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds, int viewId) + { + Log.d("HtpcRemoteWidgetProvider", "Setting button click event handling intents"); + + RemoteViews views = new RemoteViews(context.getPackageName(), viewId); + ComponentName widget = new ComponentName(context, this.getClass()); + + setButtonClick(context, views, R.id.remoteButtonOK, RemoteButton.OK); + setButtonClick(context, views, R.id.remoteButtonUp, RemoteButton.DPAD_UP); + setButtonClick(context, views, R.id.remoteButtonLeft, RemoteButton.DPAD_LEFT); + setButtonClick(context, views, R.id.remoteButtonRight, RemoteButton.DPAD_RIGHT); + setButtonClick(context, views, R.id.remoteButtonDown, RemoteButton.DPAD_DOWN); + setButtonClick(context, views, R.id.remoteButtonOsd, RemoteButton.OSD); + setButtonClick(context, views, R.id.remoteButtonMenu, RemoteButton.MENU); + setButtonClick(context, views, R.id.remoteButtonPower, RemoteButton.POWER); + setButtonClick(context, views, R.id.remoteButtonBack, RemoteButton.BACK); + setButtonClick(context, views, R.id.remoteButtonPlay, RemoteButton.PLAY); + setButtonClick(context, views, R.id.remoteButtonStop, RemoteButton.STOP); + setButtonClick(context, views, R.id.remoteButtonPrevious, RemoteButton.SKIP_PREVIOUS); + setButtonClick(context, views, R.id.remoteButtonNext, RemoteButton.SKIP_NEXT); + + appWidgetManager.updateAppWidget(widget, views); + } + + private void setButtonClick(Context context, RemoteViews views, int viewId, String action) + { + Intent intent = new Intent(context, HtpcRemoteService.class); + intent.setAction(action); + intent.addCategory(HtpcRemoteService.INTENT_CATEGORY_BUTTON_PRESS); + PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0); + views.setOnClickPendingIntent(viewId, pendingIntent); + } +} \ No newline at end of file diff --git a/src/com/geredking/htpcremote/HtpcRemoteWidgetSmallProvider.java b/src/com/geredking/htpcremote/HtpcRemoteWidgetSmallProvider.java new file mode 100644 index 0000000..89ce545 --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcRemoteWidgetSmallProvider.java @@ -0,0 +1,15 @@ +package com.geredking.htpcremote; + +import android.appwidget.AppWidgetManager; +import android.content.Context; +import android.util.Log; + +public class HtpcRemoteWidgetSmallProvider extends HtpcRemoteWidgetProvider +{ + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) + { + Log.d("HtpcRemoteWidgetSmallProvider", "onUpdate"); + setupWidget(context, appWidgetManager, appWidgetIds, R.layout.widget_remote_control_small); + } +} diff --git a/src/com/geredking/htpcremote/HtpcServer.java b/src/com/geredking/htpcremote/HtpcServer.java new file mode 100644 index 0000000..7835f57 --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcServer.java @@ -0,0 +1,23 @@ +package com.geredking.htpcremote; + +public class HtpcServer +{ + private HtpcServerConfig mConfig; + private NetworkClient mClient; + + public HtpcServer(HtpcServerConfig config, NetworkClient client) + { + mConfig = config; + mClient = client; + } + + public HtpcServerConfig getConfig() + { + return mConfig; + } + + public NetworkClient getClient() + { + return mClient; + } +} diff --git a/src/com/geredking/htpcremote/HtpcServerConfig.java b/src/com/geredking/htpcremote/HtpcServerConfig.java new file mode 100644 index 0000000..59a7bd4 --- /dev/null +++ b/src/com/geredking/htpcremote/HtpcServerConfig.java @@ -0,0 +1,123 @@ +package com.geredking.htpcremote; + +import java.util.Formatter; + +public class HtpcServerConfig +{ + private String mHost; + private int mPort; + private String mResource; + private boolean mAuthRequired; + private String mUsername; + private String mPassword; + private boolean mWakeOnLanSet; + private String mWakeOnLanBroadcast; + private String mWakeOnLanMacAddr; + + public String getHost() + { + return mHost; + } + + public void setHost(String host) + { + mHost = host; + } + + public int getPort() + { + return mPort; + } + + public void setPort(int port) + { + mPort = port; + } + + public String getResource() + { + return mResource; + } + + public void setResource(String resource) + { + mResource = resource; + } + + public boolean isAuthRequired() + { + return mAuthRequired; + } + + public void setAuthRequired(boolean required) + { + mAuthRequired = required; + } + + public String getUsername() + { + return mUsername; + } + + public void setUsername(String username) + { + mUsername = username; + } + + public String getPassword() + { + return mPassword; + } + + public void setPassword(String password) + { + mPassword = password; + } + + public boolean isWakeOnLanSet() + { + return mWakeOnLanSet; + } + + public void setWakeOnLan(boolean set) + { + mWakeOnLanSet = set; + } + + public String getWakeOnLanBroadcast() + { + return mWakeOnLanBroadcast; + } + + public void setWakeOnLanBroadcast(String addr) + { + mWakeOnLanBroadcast = addr; + } + + public String getWakeOnLanMacAddr() + { + return mWakeOnLanMacAddr; + } + + public void setWakeOnLanMacAddr(String addr) + { + mWakeOnLanMacAddr = addr; + } + + @Override + public String toString() + { + Formatter f = new Formatter(); + f.format("Host: %s\n", mHost); + f.format("Port: %d\n", mPort); + f.format("Resource: %s\n", mResource); + f.format("Auth Required: %b\n", mAuthRequired); + f.format("Username: %s\n", mUsername); + f.format("Password: %s\n", mPassword); + f.format("Wake On Lan Set: %b\n", mWakeOnLanSet); + f.format("Wake On Lan Broadcast Address: %s\n", mWakeOnLanBroadcast); + f.format("Wake On Lan MAC Address: %s\n", mWakeOnLanMacAddr); + + return f.toString(); + } +} diff --git a/src/com/geredking/htpcremote/NetworkClient.java b/src/com/geredking/htpcremote/NetworkClient.java new file mode 100644 index 0000000..19e5d55 --- /dev/null +++ b/src/com/geredking/htpcremote/NetworkClient.java @@ -0,0 +1,197 @@ +package com.geredking.htpcremote; + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.InterfaceAddress; +import java.net.NetworkInterface; +import java.util.List; + +import org.apache.http.HttpHost; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.StatusLine; +import org.apache.http.auth.Credentials; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URLEncodedUtils; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.PlainSocketFactory; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.impl.auth.BasicScheme; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; +import org.apache.http.util.EntityUtils; + +import android.content.Context; +import android.net.Uri; +import android.net.wifi.WifiManager; +import android.util.Log; + +public class NetworkClient +{ + private final static String URL_STRING_ENCODING = "UTF-8"; + private final static int CONNECTION_TIMEOUT = 2000; + private final static int SOCKET_TIMEOUT = 2000; + + private Context mContext; + private ClientConnectionManager mClientManager; + private HttpClient mHttpClient; + + public NetworkClient(Context context) + { + mContext = context; + + HttpParams params = new BasicHttpParams(); + HttpConnectionParams.setConnectionTimeout(params, CONNECTION_TIMEOUT); + HttpConnectionParams.setConnectionTimeout(params, SOCKET_TIMEOUT); + + SchemeRegistry registry = new SchemeRegistry(); + registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); + + mClientManager = new ThreadSafeClientConnManager(params, registry); + mHttpClient = new DefaultHttpClient(mClientManager, params); + } + + public void sendHttpGet(String host, int port, String path) throws Exception + { + sendHttpGet(host, port, path, null, null, null); + } + + public void sendHttpGet(String host, int port, String path, List params) throws Exception + { + sendHttpGet(host, port, path, params, null, null); + } + + public void sendHttpGet(String host, int port, String path, List params, String username, String password) throws Exception + { + HttpHost httpHost = new HttpHost(host, port, "http"); + Uri.Builder b = Uri.parse(httpHost.toURI()).buildUpon(); + b.encodedPath(path); + if (params != null) + b.query(URLEncodedUtils.format(params, URL_STRING_ENCODING)); + + HttpGet get = new HttpGet(b.build().toString()); + if (username != null && password != null) + { + Credentials credentials = new UsernamePasswordCredentials(username, password); + get.addHeader(BasicScheme.authenticate(credentials, URL_STRING_ENCODING, false)); + } + + Log.d("NetworkClient.sendHttpGet", String.format("Sending to: %s", get.getURI())); + HttpResponse response = mHttpClient.execute(get); + + StatusLine responseStatus = response.getStatusLine(); + Log.d("NetworkClient.sendHttpGet", String.format("Response status: %d %s", responseStatus.getStatusCode(), responseStatus.getReasonPhrase())); + + String responseString = EntityUtils.toString(response.getEntity()); + if (responseString != null) + Log.d("NetworkClient.sendHttpGet", String.format("Response body: %s",responseString)); + } + + public void sendHttpPost(String host, int port, String path) throws Exception + { + sendHttpPost(host, port, path, null, null, null); + } + + public void sendHttpPost(String host, int port, String path, List params) throws Exception + { + sendHttpPost(host, port, path, params, null, null); + } + + public void sendHttpPost(String host, int port, String path, List params, String username, String password) throws Exception + { + HttpHost httpHost = new HttpHost(host, port, "http"); + Uri.Builder b = Uri.parse(httpHost.toURI()).buildUpon(); + b.encodedPath(path); + + HttpPost post = new HttpPost(b.build().toString()); + if (username != null && password != null) + { + Credentials credentials = new UsernamePasswordCredentials(username, password); + post.addHeader(BasicScheme.authenticate(credentials, URL_STRING_ENCODING, false)); + } + if (params != null) + post.setEntity(new UrlEncodedFormEntity(params)); + + Log.d("NetworkClient.sendHttpPost", String.format("Sending to: %s", post.getURI())); + HttpResponse response = mHttpClient.execute(post); + + StatusLine responseStatus = response.getStatusLine(); + Log.d("NetworkClient.sendHttpPost", String.format("Response status: %d %s", responseStatus.getStatusCode(), responseStatus.getReasonPhrase())); + + String responseString = EntityUtils.toString(response.getEntity()); + if (responseString != null) + Log.d("NetworkClient.sendHttpPost", String.format("Response body: %s", responseString)); + } + + public void sendWakeOnLanPacket(InetAddress broadcastAddr, String macAddr) throws Exception + { + byte[] macBytes = getMacAddressBytes(macAddr); + byte[] bytes = new byte[6 + 16 * macBytes.length]; + for (int i = 0; i < 6; i++) + bytes[i] = (byte)0xff; + + for (int i = 6; i < bytes.length; i += macBytes.length) + System.arraycopy(macBytes, 0, bytes, i, macBytes.length); + + DatagramPacket packet = new DatagramPacket(bytes, bytes.length, broadcastAddr, 9); + DatagramSocket socket = new DatagramSocket(); + socket.send(packet); + socket.close(); + } + + public boolean isWifiEnabled() + { + WifiManager wifiManager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); + return wifiManager.isWifiEnabled(); + } + + private InterfaceAddress getWifiAddress() throws Exception + { + WifiManager wifiManager = (WifiManager)mContext.getSystemService(Context.WIFI_SERVICE); + if (!wifiManager.isWifiEnabled()) + return null; + + int ip = wifiManager.getConnectionInfo().getIpAddress(); + InetAddress wifiIp = InetAddress.getByName(String.format("%d.%d.%d.%d", (ip & 0xff), (ip >> 8 & 0xff), (ip >> 16 & 0xff), (ip >> 24 & 0xff))); + + NetworkInterface wifiInterface = NetworkInterface.getByInetAddress(wifiIp); + List addresses = wifiInterface.getInterfaceAddresses(); + for (InterfaceAddress a : addresses) + { + if (a.getAddress().equals(wifiIp)) + return a; + } + + return null; + } + + private byte[] getMacAddressBytes(String macAddr) throws IllegalArgumentException + { + byte[] bytes = new byte[6]; + String[] hex = macAddr.split("(\\:|\\-)"); + + if (hex.length != 6) + throw new IllegalArgumentException("Invalid MAC address."); + + try + { + for (int i = 0; i < 6; ++i) + bytes[i] = (byte)Integer.parseInt(hex[i], 16); + } + catch (NumberFormatException e) + { + throw new IllegalArgumentException("Invalid hex digit in MAC address."); + } + + return bytes; + } +} diff --git a/src/com/geredking/htpcremote/NetworkUtils.java b/src/com/geredking/htpcremote/NetworkUtils.java new file mode 100644 index 0000000..11608a7 --- /dev/null +++ b/src/com/geredking/htpcremote/NetworkUtils.java @@ -0,0 +1,154 @@ +package com.geredking.htpcremote; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.net.InetAddress; +import java.net.Socket; + +public final class NetworkUtils +{ + public static String getMacAddressOf(String host) throws Exception + { + // try to see if the host with the IP is accessible. this also puts the IP + // in /proc/net/arp so we can read it's MAC address from there + // TODO: is this the best way to accomplish this? + InetAddress ipAddr = InetAddress.getByName(host); + boolean reachable = isReachable(ipAddr); + if (!reachable) + throw new Exception("Unable to reach host."); + + // try to find the matching MAC address in /proc/net/arp + BufferedReader reader = null; + String ip = ipAddr.getHostAddress(); + try + { + reader = new BufferedReader(new FileReader("/proc/net/arp")); + } + catch (Exception e) + { + throw new Exception("Error accessing ARP cache.", e); + } + + try + { + String line; + while ((line = reader.readLine()) != null) + { + String[] parts = line.split(" +"); + if (parts != null && parts.length >= 4 && ip.equals(parts[0])) + { + String macAddr = parts[3]; + if (macAddr.matches("..:..:..:..:..:..")) + return macAddr; + } + } + } + catch (Exception e) + { + throw new Exception("Error parsing ARP cache information.", e); + } + finally + { + reader.close(); + } + + return null; + } + + public static boolean areOnSameNetwork(InetAddress addr1, InetAddress addr2, int cidr) throws Exception + { + byte[] addr1Bytes = addr1.getAddress(); + byte[] addr2Bytes = addr2.getAddress(); + byte[] subnetMaskBytes = getSubnetMaskBytes(cidr); + + for (int i = 0; i < addr1Bytes.length; ++i) + { + if ((addr1Bytes[i] & subnetMaskBytes[i]) != (addr2Bytes[i] & subnetMaskBytes[i])) + return false; + } + + return true; + } + + public static InetAddress getBroadcastAddress(InetAddress addr, int cidr) throws Exception + { + byte[] addrBytes = addr.getAddress(); + byte[] subnetMaskBytes = getSubnetMaskBytes(cidr); + + byte[] broadcastBytes = new byte[addrBytes.length]; + + for (int i = 0; i < addrBytes.length; ++i) + broadcastBytes[i] = (byte)(addrBytes[i] | ~subnetMaskBytes[i]); + + return InetAddress.getByAddress(broadcastBytes); + } + + public static InetAddress getSubnetMask(int cidr) throws Exception + { + byte[] maskBytes = getSubnetMaskBytes(cidr); + return InetAddress.getByAddress(maskBytes); + } + + private static byte[] getSubnetMaskBytes(int cidr) + { + int mask = 0xffffffff << (32 - cidr); + return new byte[] { + (byte)(mask >> 24), + (byte)(mask >> 16 & 0xff), + (byte)(mask >> 8 & 0xff), + (byte)(mask & 0xff) + }; + } + + public static boolean isReachable(InetAddress addr) + { + String pingCommand = String.format("ping -c 4 %s", addr.getHostAddress()); + + try + { + Process proc = Runtime.getRuntime().exec(pingCommand); + proc.waitFor(); + int result = proc.exitValue(); + if (result == 0) + return true; + else + return false; + + } + catch (Exception e) + { + return false; + } + } + + public static boolean isPortAvailable(InetAddress addr, int port) + { + Socket socket = null; + boolean reachable; + try + { + socket = new Socket(addr, port); + reachable = true; + } + catch (IOException e) + { + reachable = false; + } + finally + { + if (socket != null) + { + try + { + socket.close(); + } + catch (IOException e) + { + } + } + } + + return reachable; + } +} diff --git a/src/com/geredking/htpcremote/Utils.java b/src/com/geredking/htpcremote/Utils.java new file mode 100644 index 0000000..ad24cf6 --- /dev/null +++ b/src/com/geredking/htpcremote/Utils.java @@ -0,0 +1,38 @@ +package com.geredking.htpcremote; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +public final class Utils +{ + public static String convertStreamToString(InputStream stream) + { + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + StringBuilder sb = new StringBuilder(); + + String line = null; + try + { + while ((line = reader.readLine()) != null) + sb.append(line + "\n"); + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + try + { + stream.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + return sb.toString(); + } +} diff --git a/src/com/geredking/htpcremote/commands/HtpcServerCommand.java b/src/com/geredking/htpcremote/commands/HtpcServerCommand.java new file mode 100644 index 0000000..213ac3f --- /dev/null +++ b/src/com/geredking/htpcremote/commands/HtpcServerCommand.java @@ -0,0 +1,8 @@ +package com.geredking.htpcremote.commands; + +import com.geredking.htpcremote.HtpcServer; + +public abstract class HtpcServerCommand +{ + public abstract void run(HtpcServer server); +} diff --git a/src/com/geredking/htpcremote/commands/WakeOnLanPowerCommand.java b/src/com/geredking/htpcremote/commands/WakeOnLanPowerCommand.java new file mode 100644 index 0000000..620d402 --- /dev/null +++ b/src/com/geredking/htpcremote/commands/WakeOnLanPowerCommand.java @@ -0,0 +1,31 @@ +package com.geredking.htpcremote.commands; + +import java.net.InetAddress; + +import android.util.Log; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.HtpcServerConfig; + +public class WakeOnLanPowerCommand extends HtpcServerCommand +{ + @Override + public void run(HtpcServer server) + { + HtpcServerConfig config = server.getConfig(); + + if (config.isWakeOnLanSet()) + { + try + { + InetAddress broadcastAddr = InetAddress.getByName(config.getWakeOnLanBroadcast()); + String macAddr = config.getWakeOnLanMacAddr(); + server.getClient().sendWakeOnLanPacket(broadcastAddr, macAddr); + } + catch (Exception e) + { + Log.e("WakeOnLanPowerCommand", e.getMessage(), e); + } + } + } +} diff --git a/src/com/geredking/htpcremote/remotes/RemoteButton.java b/src/com/geredking/htpcremote/remotes/RemoteButton.java new file mode 100644 index 0000000..a93be08 --- /dev/null +++ b/src/com/geredking/htpcremote/remotes/RemoteButton.java @@ -0,0 +1,23 @@ +package com.geredking.htpcremote.remotes; + +public class RemoteButton +{ + public final static String POWER = "button.power"; + public final static String HOME = "button.home"; + public final static String TOGGLEFULLSCREEN = "button.togglefullscreen"; + public final static String MENU = "button.menu"; + public final static String INFO = "button.info"; + public final static String OSD = "button.osd"; + public final static String BACK = "button.back"; + public final static String DPAD_UP = "button.dpad_up"; + public final static String DPAD_LEFT = "button.dpad_left"; + public final static String DPAD_RIGHT = "button.dpad_right"; + public final static String DPAD_DOWN = "button.dpad_down"; + public final static String OK = "button.ok"; + public final static String SKIP_PREVIOUS = "button.skip_previous"; + public final static String SKIP_NEXT = "button.skip_next"; + public final static String FASTFORWARD = "button.fastforward"; + public final static String REWIND = "button.rewind"; + public final static String PLAY = "button.play"; + public final static String STOP = "button.stop"; +} diff --git a/src/com/geredking/htpcremote/remotes/RemoteControl.java b/src/com/geredking/htpcremote/remotes/RemoteControl.java new file mode 100644 index 0000000..6efc96c --- /dev/null +++ b/src/com/geredking/htpcremote/remotes/RemoteControl.java @@ -0,0 +1,44 @@ +package com.geredking.htpcremote.remotes; + +import java.util.HashMap; +import java.util.Map; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.commands.HtpcServerCommand; + +import android.content.Context; +import android.util.Log; + +public abstract class RemoteControl +{ + private HtpcServer mServer; + private Map mCommandMap; + + public RemoteControl(HtpcServer server, Context context) + { + mServer = server; + mCommandMap = new HashMap(); + } + + public void doCommand(String name) + { + final HtpcServerCommand command = mCommandMap.get(name); + if (command != null) + { + Log.d("RemoteControl", String.format("doCommand: %s", name)); + Thread t = new Thread(new Runnable() { + public void run() { + command.run(mServer); + } + }); + t.start(); + } + else + Log.e("RemoteControl", String.format("INVALID doCommand: %s", name)); + } + + protected void registerCommand(String name, HtpcServerCommand command) + { + mCommandMap.put(name, command); + } +} diff --git a/src/com/geredking/htpcremote/remotes/RemoteControlFactory.java b/src/com/geredking/htpcremote/remotes/RemoteControlFactory.java new file mode 100644 index 0000000..b576092 --- /dev/null +++ b/src/com/geredking/htpcremote/remotes/RemoteControlFactory.java @@ -0,0 +1,46 @@ +package com.geredking.htpcremote.remotes; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.HtpcServerConfig; +import com.geredking.htpcremote.NetworkClient; +import com.geredking.htpcremote.xbmc.XbmcRemoteControl; + +import android.content.Context; +import android.util.Log; + +public final class RemoteControlFactory +{ + public static RemoteControl create(Context context) + { + // TODO: check preferences to see which subclass of RemoteControl to instantiate + + HtpcServer server = createServer(getCurrentServerConfig(), context); + return new XbmcRemoteControl(server, context); + } + + public static HtpcServerConfig getCurrentServerConfig() + { + // TODO: deserialize config object from preferences + HtpcServerConfig config = new HtpcServerConfig(); + + config.setHost("10.0.0.30"); + config.setPort(8080); + config.setResource("/xbmcCmds/xbmcHttp?command=%s"); + config.setAuthRequired(true); + config.setUsername("xbmc"); + config.setPassword(""); + config.setWakeOnLan(true); + config.setWakeOnLanBroadcast("10.0.0.255"); + config.setWakeOnLanMacAddr("00:01:2E:2B:7C:DE"); + + Log.d("RemoteControlFactory", String.format("Obtained configuration:\n%s", config.toString())); + + return config; + } + + private static HtpcServer createServer(HtpcServerConfig config, Context context) + { + NetworkClient client = new NetworkClient(context); + return new HtpcServer(config, client); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/XbmcCommand.java b/src/com/geredking/htpcremote/xbmc/XbmcCommand.java new file mode 100644 index 0000000..9453efd --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/XbmcCommand.java @@ -0,0 +1,30 @@ +package com.geredking.htpcremote.xbmc; + +import android.net.Uri; +import android.util.Log; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.HtpcServerConfig; +import com.geredking.htpcremote.commands.HtpcServerCommand; + +public abstract class XbmcCommand extends HtpcServerCommand +{ + protected void command(HtpcServer server, String command) + { + HtpcServerConfig config = server.getConfig(); + + String path = String.format(config.getResource(), Uri.encode(command)); + + try + { + if (config.isAuthRequired()) + server.getClient().sendHttpGet(config.getHost(), config.getPort(), path, null, config.getUsername(), config.getPassword()); + else + server.getClient().sendHttpGet(config.getHost(), config.getPort(), path); + } + catch (Exception e) + { + Log.e("XbmcCommand", String.format("Exception occurred during command: %s", command), e); + } + } +} diff --git a/src/com/geredking/htpcremote/xbmc/XbmcRemoteControl.java b/src/com/geredking/htpcremote/xbmc/XbmcRemoteControl.java new file mode 100644 index 0000000..ecb6b07 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/XbmcRemoteControl.java @@ -0,0 +1,40 @@ +package com.geredking.htpcremote.xbmc; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.commands.WakeOnLanPowerCommand; +import com.geredking.htpcremote.remotes.RemoteButton; +import com.geredking.htpcremote.remotes.RemoteControl; +import com.geredking.htpcremote.xbmc.commands.*; + +import android.content.Context; +import android.util.Log; + +public class XbmcRemoteControl extends RemoteControl +{ + public XbmcRemoteControl(HtpcServer server, Context context) + { + super(server, context); + + Log.d("XbmcRemoteControl", "Register commands for XBMC remote control"); + + registerCommand(RemoteButton.POWER, new WakeOnLanPowerCommand()); + registerCommand(RemoteButton.HOME, new HomeCommand()); + registerCommand(RemoteButton.TOGGLEFULLSCREEN, new ToggleFullscreenCommand()); + registerCommand(RemoteButton.MENU, new MenuCommand()); + registerCommand(RemoteButton.INFO, new InfoCommand()); + registerCommand(RemoteButton.OSD, new OsdCommand()); + registerCommand(RemoteButton.BACK, new BackCommand()); + registerCommand(RemoteButton.OK, new OkCommand()); + registerCommand(RemoteButton.PLAY, new PlayCommand()); + registerCommand(RemoteButton.STOP, new StopCommand()); + registerCommand(RemoteButton.FASTFORWARD, new FastforwardCommand()); + registerCommand(RemoteButton.REWIND, new RewindCommand()); + registerCommand(RemoteButton.SKIP_NEXT, new SkipNextCommand()); + registerCommand(RemoteButton.SKIP_PREVIOUS, new SkipPreviousCommand()); + registerCommand(RemoteButton.DPAD_UP, new DpadUpCommand()); + registerCommand(RemoteButton.DPAD_DOWN, new DpadDownCommand()); + registerCommand(RemoteButton.DPAD_LEFT, new DpadLeftCommand()); + registerCommand(RemoteButton.DPAD_RIGHT, new DpadRightCommand()); + } + +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/BackCommand.java b/src/com/geredking/htpcremote/xbmc/commands/BackCommand.java new file mode 100644 index 0000000..1ea7bdb --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/BackCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class BackCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "SendKey(275)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/DpadDownCommand.java b/src/com/geredking/htpcremote/xbmc/commands/DpadDownCommand.java new file mode 100644 index 0000000..e5a1603 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/DpadDownCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class DpadDownCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "SendKey(271)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/DpadLeftCommand.java b/src/com/geredking/htpcremote/xbmc/commands/DpadLeftCommand.java new file mode 100644 index 0000000..17bb659 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/DpadLeftCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class DpadLeftCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "SendKey(272)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/DpadRightCommand.java b/src/com/geredking/htpcremote/xbmc/commands/DpadRightCommand.java new file mode 100644 index 0000000..f9dd053 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/DpadRightCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class DpadRightCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "SendKey(273)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/DpadUpCommand.java b/src/com/geredking/htpcremote/xbmc/commands/DpadUpCommand.java new file mode 100644 index 0000000..287feab --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/DpadUpCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class DpadUpCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "SendKey(270)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/FastforwardCommand.java b/src/com/geredking/htpcremote/xbmc/commands/FastforwardCommand.java new file mode 100644 index 0000000..3221439 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/FastforwardCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class FastforwardCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "Action(77)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/HomeCommand.java b/src/com/geredking/htpcremote/xbmc/commands/HomeCommand.java new file mode 100644 index 0000000..4f167af --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/HomeCommand.java @@ -0,0 +1,15 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class HomeCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + // 0xF01B corresponds to XBMC's "escape" keyboard mapping + // ref: http://groups.google.com/group/commandfusion/browse_thread/thread/e07d37e903cbe486 + command(server, "SendKey(0xF01B)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/InfoCommand.java b/src/com/geredking/htpcremote/xbmc/commands/InfoCommand.java new file mode 100644 index 0000000..b1a1eda --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/InfoCommand.java @@ -0,0 +1,15 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class InfoCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + // 0xF049 corresponds to XBMC's "i" keyboard mapping + // ref: http://groups.google.com/group/commandfusion/browse_thread/thread/e07d37e903cbe486 + command(server, "SendKey(0xF049)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/MenuCommand.java b/src/com/geredking/htpcremote/xbmc/commands/MenuCommand.java new file mode 100644 index 0000000..4a58a63 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/MenuCommand.java @@ -0,0 +1,15 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class MenuCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + // 0xF043 corresponds to XBMC's "c" keyboard mapping + // ref: http://groups.google.com/group/commandfusion/browse_thread/thread/e07d37e903cbe486 + command(server, "SendKey(0xF043)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/OkCommand.java b/src/com/geredking/htpcremote/xbmc/commands/OkCommand.java new file mode 100644 index 0000000..827eb3c --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/OkCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class OkCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "SendKey(256)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/OsdCommand.java b/src/com/geredking/htpcremote/xbmc/commands/OsdCommand.java new file mode 100644 index 0000000..b1fc342 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/OsdCommand.java @@ -0,0 +1,15 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class OsdCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + // 0xF04D corresponds to XBMC's "m" keyboard mapping + // ref: http://groups.google.com/group/commandfusion/browse_thread/thread/e07d37e903cbe486 + command(server, "SendKey(0xF04D)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/PlayCommand.java b/src/com/geredking/htpcremote/xbmc/commands/PlayCommand.java new file mode 100644 index 0000000..0e764a2 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/PlayCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class PlayCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "Action(12)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/RewindCommand.java b/src/com/geredking/htpcremote/xbmc/commands/RewindCommand.java new file mode 100644 index 0000000..4314056 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/RewindCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class RewindCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "Action(78)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/SkipNextCommand.java b/src/com/geredking/htpcremote/xbmc/commands/SkipNextCommand.java new file mode 100644 index 0000000..411eac0 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/SkipNextCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class SkipNextCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "Action(14)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/SkipPreviousCommand.java b/src/com/geredking/htpcremote/xbmc/commands/SkipPreviousCommand.java new file mode 100644 index 0000000..6ba95d9 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/SkipPreviousCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class SkipPreviousCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "Action(15)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/StopCommand.java b/src/com/geredking/htpcremote/xbmc/commands/StopCommand.java new file mode 100644 index 0000000..a749d20 --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/StopCommand.java @@ -0,0 +1,13 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class StopCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + command(server, "Action(13)"); + } +} diff --git a/src/com/geredking/htpcremote/xbmc/commands/ToggleFullscreenCommand.java b/src/com/geredking/htpcremote/xbmc/commands/ToggleFullscreenCommand.java new file mode 100644 index 0000000..1f9c6ed --- /dev/null +++ b/src/com/geredking/htpcremote/xbmc/commands/ToggleFullscreenCommand.java @@ -0,0 +1,15 @@ +package com.geredking.htpcremote.xbmc.commands; + +import com.geredking.htpcremote.HtpcServer; +import com.geredking.htpcremote.xbmc.XbmcCommand; + +public class ToggleFullscreenCommand extends XbmcCommand +{ + @Override + public void run(HtpcServer server) + { + // 0xF009 corresponds to XBMC's "tab" keyboard mapping + // ref: http://groups.google.com/group/commandfusion/browse_thread/thread/e07d37e903cbe486 + command(server, "SendKey(0xF009)"); + } +}