Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/.svn/*" kind="src" path="src"/>
<classpathentry excluding="**/.svn/*" kind="src" path="gen"/>
<classpathentry excluding="**/.svn/*" kind="src" path="lib-src"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="lib/jmdns.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/.svn/*" kind="src" path="src"/>
<classpathentry excluding="**/.svn/*" kind="src" path="gen"/>
<classpathentry excluding="**/.svn/*" kind="src" path="lib-src"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="lib/jmdns.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
Empty file added hello.txt
Empty file.
60 changes: 33 additions & 27 deletions res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@
android:key="setting_instances"
android:title="Manage XBMC Hosts"
android:summary="Add, edit and remove the XBMC instances in your LAN.">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="org.xbmc.android.remote"
android:targetClass="org.xbmc.android.remote.presentation.activity.HostSettingsActivity"
android:data="" />
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="org.xbmc.android.remote"
android:targetClass="org.xbmc.android.remote.presentation.activity.HostSettingsActivity"
android:data="" />
</PreferenceScreen>
<!-- CheckBoxPreference
android:disableDependentsState="true"
android:key="setting_mdns" android:defaultValue="false"
android:title="Use Zeroconf for IP/Port discovery"
<!-- CheckBoxPreference
android:disableDependentsState="true"
android:key="setting_mdns" android:defaultValue="false"
android:title="Use Zeroconf for IP/Port discovery"
android:summary="Use Zeroconf to discover the IP and Ports of XBMC."
android:enabled="false" /-->
android:enabled="false" /-->
<CheckBoxPreference
android:key="setting_vibrate_on_touch"
android:title="Vibrate on Touch"
android:summary="Makes the remote control vibrate on touch." android:defaultValue="true"/>
</PreferenceCategory>
<PreferenceCategory android:title="Startup">
<CheckBoxPreference
android:key="setting_startup_onboot"
android:title="Start on boot"
<CheckBoxPreference
android:key="setting_startup_onboot"
android:title="Start on boot"
android:summary="Start xbmcremote on boot"/>
</PreferenceCategory>

<PreferenceCategory android:title="On-Screen Notifications">
<CheckBoxPreference
android:key="setting_show_notification"
android:title="Statusbar notifications"
android:summary="Show now playing notifications in the status bar."
<CheckBoxPreference
android:key="setting_show_notification"
android:title="Statusbar notifications"
android:summary="Show now playing notifications in the status bar."
android:enabled="true" />
<CheckBoxPreference
<CheckBoxPreference
android:key="setting_show_sms"
android:title="Show incoming SMS"
android:summary="Shows incoming SMS with contact name and picture on your TV."
android:selectable="true" android:defaultValue="false"/>
<CheckBoxPreference
android:key="setting_show_call"
<CheckBoxPreference
android:key="setting_show_call"
android:title="Show incoming calls"
android:summary="Pauses playback and shows incoming calls with contact name and picture on your TV."
android:selectable="true"
Expand Down Expand Up @@ -82,6 +82,12 @@
android:entries="@array/KeyguardPreferenceEntries"
android:entryValues="@array/KeyguardPreferenceValues"
android:defaultValue="0" />
<CheckBoxPreference
android:key="setting_auto_rotate"
android:title="Auto rotate screen"
android:summary="Auto rotate the screen based on device orientation."
android:selectable="true"
android:enabled="true" android:defaultValue="true" />
</PreferenceCategory>
<PreferenceCategory android:title="Miscellaneous options">
<CheckBoxPreference
Expand All @@ -95,7 +101,7 @@
android:title="Confirm Play on XBMC"
android:summary="Show a confirmation screen when playing media URLs on XBMC."
android:selectable="true"
android:enabled="true" android:defaultValue="true" />
android:enabled="true" android:defaultValue="true" />
<ListPreference
android:key="setting_default_selection_action"
android:title="Action on selection"
Expand All @@ -109,21 +115,21 @@
android:key="setting_send_repeats"
android:title="Explicitly Send Repeats"
android:summary="Explicitly send repeating key presses to host."
android:enabled="true"
android:defaultValue="false" />
android:enabled="true"
android:defaultValue="false" />
<CheckBoxPreference
android:key="setting_send_single_click"
android:title="Send Single Keypress"
android:summary="Send only a single keypress to host."
android:dependency="setting_send_repeats"
android:defaultValue="false" />
android:dependency="setting_send_repeats"
android:defaultValue="false" />
<EditTextPreference
android:key="setting_repeat_rate"
android:title="Keypress Repeat Rate"
android:summary="In milliseconds, specify often repeats should be sent."
android:dialogTitle="Repeat Rate (MS)"
android:numeric="integer"
android:dependency="setting_send_repeats"
android:dependency="setting_send_repeats"
android:defaultValue="250" />
</PreferenceCategory>
</PreferenceScreen>
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,64 @@

package org.xbmc.android.remote.presentation.activity;

import static org.xbmc.android.remote.presentation.controller.SettingsController.PREF_AUTO_ROTATE;

import java.util.ArrayList;
import android.app.Activity;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.media.AudioManager;
import android.preference.PreferenceManager;

class ConfigurationManager implements OnSharedPreferenceChangeListener {

public final static String PREF_KEYGUARD_DISABLED = "setting_disable_keyguard";


public final static String KEYGUARD_STATUS_ENABLED = "0";
public final static String KEYGUARD_STATUS_REMOTE_ONLY = "1";
public final static String KEYGUARD_STATUS_ALL = "2";

public final static int INT_KEYGUARD_STATUS_ENABLED = 0;
public final static int INT_KEYGUARD_STATUS_REMOTE_ONLY = 1;
public final static int INT_KEYGUARD_STATUS_ALL = 2;

public final static String KEYGUARD_TAG = "xbmc_remote_keyguard_lock";

private static ConfigurationManager sInstance;

private Activity mActivity;

private int mKeyguardState = 0;

private int mOrientation;
private ArrayList<String> portraitList;

private KeyguardManager.KeyguardLock mKeyguardLock = null;

private ConfigurationManager(Activity activity) {
mActivity = activity;
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
prefs.registerOnSharedPreferenceChangeListener(this);
mKeyguardState = Integer.parseInt(prefs.getString(PREF_KEYGUARD_DISABLED, KEYGUARD_STATUS_ENABLED));
portraitList = new ArrayList<String>();
try {
ActivityInfo[] info = mActivity.getPackageManager().getPackageInfo(mActivity.getPackageName(), PackageManager.GET_ACTIVITIES).activities;
for (int i = 0; i < info.length; i++) {
if(info[i].screenOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
portraitList.add(info[i].name);
}
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}

mOrientation = (prefs.getBoolean(PREF_AUTO_ROTATE, true)) ? ActivityInfo.SCREEN_ORIENTATION_SENSOR :
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}

public static ConfigurationManager getInstance(Activity activity) {
Expand All @@ -68,15 +91,15 @@ public static ConfigurationManager getInstance(Activity activity) {
}

//Use with extreme care! this could return null, so you need to null-check
//in the calling code!
//in the calling code!
public static ConfigurationManager getInstance() {
return sInstance;
}

public Context getActiveContext() {
return sInstance.mActivity;
}

public void disableKeyguard(Activity activity) {
if (mKeyguardLock != null) {
mKeyguardLock.disableKeyguard();
Expand All @@ -86,7 +109,7 @@ public void disableKeyguard(Activity activity) {
mKeyguardLock.disableKeyguard();
}
}

public void enableKeyguard() {
if (mKeyguardLock != null) {
mKeyguardLock.reenableKeyguard();
Expand All @@ -102,9 +125,12 @@ public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
disableKeyguard(mActivity);
else
enableKeyguard();
} else if(key.equals(PREF_AUTO_ROTATE)) {
mOrientation = (prefs.getBoolean(PREF_AUTO_ROTATE, true)) ? ActivityInfo.SCREEN_ORIENTATION_SENSOR :
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
}
}

public void onActivityResume(Activity activity) {
switch (mKeyguardState) {
case INT_KEYGUARD_STATUS_REMOTE_ONLY:
Expand All @@ -120,16 +146,19 @@ public void onActivityResume(Activity activity) {
enableKeyguard();
break;
}

activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
mActivity = activity;
if(!portraitList.contains(mActivity.getComponentName().getClassName())) {
mActivity.setRequestedOrientation(mOrientation);
}
}

public void onActivityPause() {
if (mKeyguardLock != null){
mKeyguardLock.reenableKeyguard();
mKeyguardLock = null;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@

/**
* Gesture mode. Let's see how this works out...
*
*
* @author Team XBMC
*/
public class GestureRemoteActivity extends Activity {

private final static String TAG = "GestureRemoteActivity";

private ConfigurationManager mConfigurationManager;
private RemoteController mRemoteController;

private static final int MENU_NOW_PLAYING = 401;
private static final int MENU_SWITCH_BUTTONS = 402;
// private static final int MENU_SWITCH_MOUSE = 403;
Expand All @@ -59,7 +59,7 @@ public class GestureRemoteActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Display d = getWindowManager().getDefaultDisplay();
final int w = d.getWidth();
final int h = d.getHeight();
Expand All @@ -71,15 +71,15 @@ public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "AR = " + ar + ", normal layout.");
setContentView(R.layout.remote_gesture);
}

// remove nasty top fading edge
FrameLayout topFrame = (FrameLayout)findViewById(android.R.id.content);
topFrame.setForeground(null);
GestureRemoteView view = (GestureRemoteView)findViewById(R.id.RemoteXboxGestureZone);

GestureRemoteView view = (GestureRemoteView)findViewById(R.id.RemoteXboxGestureZone);
mRemoteController = new RemoteController(getApplicationContext());
view.setGestureListener(mRemoteController.startGestureThread(this.getApplicationContext()));

mConfigurationManager = ConfigurationManager.getInstance(this);
// mConfigurationManager.initKeyguard(true);
setupButtons();
Expand All @@ -101,20 +101,20 @@ public void onPrepareDialog(int id, Dialog dialog) {
public boolean onTrackballEvent(MotionEvent event) {
return mRemoteController.onTrackballEvent(event);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return mRemoteController.onKeyDown(keyCode, event) ? true : super.onKeyDown(keyCode, event);
}

@Override
protected void onResume() {
super.onResume();
getSharedPreferences("global", Context.MODE_PRIVATE).edit().putInt(RemoteController.LAST_REMOTE_PREFNAME, RemoteController.LAST_REMOTE_GESTURE).commit();
mRemoteController.onActivityResume(this);
mConfigurationManager.onActivityResume(this);
}

@Override
protected void onPause() {
super.onPause();
Expand All @@ -128,7 +128,7 @@ protected void onPause() {
private void setupButtons() {
// display
mRemoteController.setupButton(findViewById(R.id.RemoteXboxImgBtnDisplay), ButtonCodes.REMOTE_DISPLAY);

// seek back
mRemoteController.setupButton(findViewById(R.id.RemoteXboxImgBtnSeekBack), ButtonCodes.REMOTE_REVERSE);
// play
Expand All @@ -145,7 +145,7 @@ private void setupButtons() {
// next
mRemoteController.setupButton(findViewById(R.id.RemoteXboxImgBtnNext), ButtonCodes.REMOTE_SKIP_PLUS);
}

public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_SWITCH_BUTTONS, 0, "Switch to buttons").setIcon(R.drawable.menu_remote);
menu.add(0, MENU_NOW_PLAYING, 0, "Now playing").setIcon(R.drawable.menu_nowplaying);
Expand All @@ -162,7 +162,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
break;
case MENU_SWITCH_BUTTONS:
intent = new Intent(this, RemoteActivity.class);
intent.addFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(intent.getFlags());
break;
case MENU_ENTER_TEXT:
showDialog(RemoteController.DIALOG_SENDTEXT);
Expand Down
Loading