Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding profiles support. #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<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 exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
1 change: 1 addition & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<activity android:name=".presentation.activity.MovieDetailsActivity" android:theme="@android:style/Theme.NoTitleBar" />
<activity android:name=".presentation.activity.TvShowDetailsActivity" android:theme="@android:style/Theme.NoTitleBar" />
<activity android:name=".presentation.activity.ListActivity" android:theme="@android:style/Theme.NoTitleBar" />
<activity android:name=".presentation.activity.ProfileActivity" android:theme="@android:style/Theme.NoTitleBar" />
<activity android:name=".presentation.activity.GridActivity" android:theme="@android:style/Theme.NoTitleBar" />
<activity android:name=".presentation.activity.TvShowLibraryActivity" android:theme="@android:style/Theme.NoTitleBar" />
<activity android:name=".presentation.activity.NowPlayingActivity" android:theme="@android:style/Theme.NoTitleBar" />
Expand Down
Binary file added res/drawable-hdpi-v4/default_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi-v4/icon_home_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/default_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable/icon_home_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions res/layout/profile_password.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_width="280dip">
<LinearLayout
android:layout_height="wrap_content"
android:id="@+id/password_linearLayout"
android:layout_width="match_parent"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp">
<TextView
android:text="Enter the password:"
android:layout_height="wrap_content"
android:layout_width="match_parent">
</TextView>
<EditText
android:maxLines="1"
android:id="@+id/password_text"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:password="true">
<requestFocus></requestFocus>
</EditText>
</LinearLayout>
<LinearLayout
android:id="@+id/password_buttonbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
style="@android:style/ButtonBar" android:padding="5dp">
<Button
android:id="@+id/password_button_send"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Send" />
<Button
android:id="@+id/password_button_cancel"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</LinearLayout>
5 changes: 5 additions & 0 deletions res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
android:title="Show Pictures"
android:summary="Show the &quot;Browse your Pictures&quot; item"
android:enabled="true" android:defaultValue="true" />
<CheckBoxPreference
android:key="setting_show_home_profiles"
android:title="Show Profiles"
android:summary="Show the &quot;List of Profiles&quot; item"
android:enabled="true" android:defaultValue="false" />
<CheckBoxPreference
android:key="setting_show_home_powerdown"
android:title="Show Power Down"
Expand Down
13 changes: 12 additions & 1 deletion src/org/xbmc/android/remote/business/AbstractManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.xbmc.api.data.IControlClient;
import org.xbmc.api.data.IInfoClient;
import org.xbmc.api.data.IMusicClient;
import org.xbmc.api.data.IProfileClient;
import org.xbmc.api.data.ITvShowClient;
import org.xbmc.api.data.IVideoClient;
import org.xbmc.api.object.ICoverArt;
Expand Down Expand Up @@ -136,7 +137,17 @@ protected IVideoClient video(Context context) throws WifiStateException {
protected IMusicClient music(Context context) throws WifiStateException {
return ClientFactory.getMusicClient(this, context);
}


/**
* Returns the ProfileClient class
* @param response Response object
* @return
* @throws WifiStateException
*/
protected IProfileClient profile(Context context) throws WifiStateException {
return ClientFactory.getProfileClient(this, context);
}

protected ITvShowClient shows(Context context) throws WifiStateException {
return ClientFactory.getTvShowClient(this, context);
}
Expand Down
13 changes: 12 additions & 1 deletion src/org/xbmc/android/remote/business/AbstractThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.xbmc.api.business.DataResponse;
import org.xbmc.api.business.INotifiableManager;
import org.xbmc.api.data.IMusicClient;
import org.xbmc.api.data.IProfileClient;
import org.xbmc.api.data.ITvShowClient;
import org.xbmc.api.data.IVideoClient;
import org.xbmc.api.presentation.INotifiableController;
Expand Down Expand Up @@ -90,7 +91,17 @@ protected static IVideoClient video(INotifiableManager manager, final Context co
protected static ITvShowClient tvshow(INotifiableManager manager, final Context context) throws WifiStateException {
return ClientFactory.getTvShowClient(manager, context);
}


/**
* Returns the ProfileClient class
* @param manager Manager referencet
* @return
* @throws WifiStateException
*/
protected static IProfileClient profile(INotifiableManager manager, final Context context) throws WifiStateException {
return ClientFactory.getProfileClient(manager, context);
}

/**
* Calls the UI thread's callback code.
* @param controller Controller reference
Expand Down
8 changes: 8 additions & 0 deletions src/org/xbmc/android/remote/business/DownloadThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ public static boolean download(final DataResponse<Bitmap> response, final ICover
case MediaType.PICTURES:
done(controller, response);
break;
case MediaType.PROFILE:
try {
bitmap = profile(manager, context).getCover(manager, cover, thumbSize);
} catch (WifiStateException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
break;
default:
done(controller, response);
break;
Expand Down
4 changes: 4 additions & 0 deletions src/org/xbmc/android/remote/business/ManagerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.xbmc.api.business.IEventClientManager;
import org.xbmc.api.business.IInfoManager;
import org.xbmc.api.business.IMusicManager;
import org.xbmc.api.business.IProfileManager;
import org.xbmc.api.business.ITvShowManager;
import org.xbmc.api.business.IVideoManager;
import org.xbmc.api.presentation.INotifiableController;
Expand All @@ -48,6 +49,9 @@ public static ITvShowManager getTvManager(INotifiableController controller) {
public static IMusicManager getMusicManager(INotifiableController controller) {
return ManagerThread.music(controller);
}
public static IProfileManager getProfileManager(INotifiableController controller) {
return ManagerThread.profile(controller);
}
public static IEventClientManager getEventClientManager(INotifiableController controller) {
if (sEventClientManager == null) {
sEventClientManager = new EventClientManager();
Expand Down
9 changes: 8 additions & 1 deletion src/org/xbmc/android/remote/business/ManagerThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class ManagerThread extends Thread {
private final MusicManager mMusicManager;
private final VideoManager mVideoManager;
private final TvShowManager mTvShowManager;
private final ProfileManager mProfileManager;

private ManagerThread() {
super("ManagerThread");
Expand All @@ -50,6 +51,7 @@ private ManagerThread() {
mMusicManager = new MusicManager();
mVideoManager = new VideoManager();
mTvShowManager = new TvShowManager();
mProfileManager = new ProfileManager();
}
public static ManagerThread get() {
if (sManagerThread == null) {
Expand All @@ -75,6 +77,7 @@ public void run() {
mMusicManager.setHandler(mHandler);
mVideoManager.setHandler(mHandler);
mTvShowManager.setHandler(mHandler);
mProfileManager.setHandler(mHandler);
Looper.loop();
}

Expand All @@ -98,7 +101,11 @@ public static VideoManager video(INotifiableController controller) {
vm.setController(controller);
return vm;
}

public static ProfileManager profile(INotifiableController controller) {
final ProfileManager pm = get().mProfileManager;
pm.setController(controller);
return pm;
}
public static TvShowManager shows(INotifiableController controller) {
final TvShowManager shows = get().mTvShowManager;
shows.setController(controller);
Expand Down
81 changes: 81 additions & 0 deletions src/org/xbmc/android/remote/business/ProfileManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2005-2009 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC Remote; see the file license. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/

package org.xbmc.android.remote.business;

import java.net.SocketTimeoutException;
import java.util.ArrayList;

import org.xbmc.api.business.DataResponse;
import org.xbmc.api.business.INotifiableManager;
import org.xbmc.api.business.ISortableManager;
import org.xbmc.api.business.IProfileManager;
import org.xbmc.api.object.Profile;

import android.content.Context;

/**
* Asynchronously wraps the {@link org.xbmc.httpapi.client.ProfileClient} class.
*
* @author Team XBMC
*/
public class ProfileManager extends AbstractManager implements IProfileManager, ISortableManager, INotifiableManager {

/**
* Gets all profiles from database
* @param response Response object
*/
public void getProfiles(final DataResponse<ArrayList<Profile>> response, final Context context) {
mHandler.post(new Command<ArrayList<Profile>>(response, this) {
@Override
public void doRun() throws Exception {
response.value = profile(context).getProfiles(ProfileManager.this);
}
});
}

/**
* Gets the current active profile
* @param response Response object
*/
public void GetCurrentProfile(final DataResponse<String> response, final Context context) {
mHandler.post(new Command<String>(response, this) {
@Override
public void doRun() throws Exception, SocketTimeoutException {
response.value = profile(context).getCurrentProfile(ProfileManager.this);
}
});
}

/**
* Loads a new profile
* @param response Response object
* @param profileName The new profile to load
* @param profilePassword The password for the new profile
*/
public void loadProfile(final DataResponse<Boolean> response, final String profileName, final String profilePassword, final Context context) {
mHandler.post(new Command<Boolean>(response, this) {
public void doRun() throws Exception{
response.value = profile(context).loadProfile(ProfileManager.this, profileName, profilePassword);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 2005-2009 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC Remote; see the file license. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/

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

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

import org.xbmc.android.remote.R;
import org.xbmc.android.remote.presentation.activity.AbsListActivity;
import org.xbmc.android.remote.presentation.controller.ProfileListController;
import org.xbmc.android.remote.presentation.controller.RemoteController;

/**
* Activity for remote control. At the moment that's the good ol' Xbox remote
* control, more to come...
*
* @author Team XBMC
*/
public class ProfileActivity extends ListActivity {

private ProfileListController mProfileListController;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mProfileListController = (ProfileListController)mListController;
}

@Override
public Dialog onCreateDialog(int id) {
super.onCreateDialog(id);
return mProfileListController.onCreateDialog(id, this);
}

@Override
public void onPrepareDialog(int id, Dialog dialog) {
super.onPrepareDialog(id, dialog);
mProfileListController.onPrepareDialog(id, dialog);
}

@Override
protected void onResume() {
super.onResume();
mProfileListController.onActivityResume(this);
}

@Override
protected void onPause() {
super.onPause();
mProfileListController.onActivityPause();
}

}
Loading