Hide jukebox option when user is not enabled for it, fix crashes

This commit is contained in:
Joshua Bahnsen 2013-12-06 19:29:37 -07:00
parent ecc078e30f
commit 975dafed47
2 changed files with 249 additions and 0 deletions

View File

@ -0,0 +1,182 @@
/*
This file is part of UltraSonic.
Subsonic 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 3 of the License, or
(at your option) any later version.
Subsonic 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 Subsonic. If not, see <http://www.gnu.org/licenses/>.
Copyright 2013 (C) Joshua Bahnsen
*/
package com.thejoshwa.ultrasonic.androidapp.domain;
/**
* Information about the Subsonic server.
*
* @author Joshua Bahnsen
*/
public class UserInfo
{
private String userName;
private String email;
private boolean scrobblingEnabled;
private boolean adminRole;
private boolean settingsRole;
private boolean downloadRole;
private boolean uploadRole;
private boolean playlistRole;
private boolean coverArtRole;
private boolean commentRole;
private boolean podcastRole;
private boolean streamRole;
private boolean jukeboxRole;
private boolean shareRole;
public String getUserName()
{
return this.userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getEmail()
{
return this.email;
}
public void setEmail(String email)
{
this.email = email;
}
public boolean getScrobblingEnabled()
{
return this.scrobblingEnabled;
}
public void setScrobblingEnabled(boolean scrobblingEnabled)
{
this.scrobblingEnabled = scrobblingEnabled;
}
public boolean getAdminRole()
{
return this.adminRole;
}
public void setAdminRole(boolean adminRole)
{
this.adminRole = adminRole;
}
public boolean getSettingsRole()
{
return this.settingsRole;
}
public void setSettingsRole(boolean settingsRole)
{
this.settingsRole = settingsRole;
}
public boolean getDownloadRole()
{
return this.downloadRole;
}
public void setDownloadRole(boolean downloadRole)
{
this.downloadRole = downloadRole;
}
public boolean getUploadRole()
{
return this.uploadRole;
}
public void setUploadRole(boolean uploadRole)
{
this.uploadRole = uploadRole;
}
public boolean getPlaylistRole()
{
return this.playlistRole;
}
public void setPlaylistRole(boolean playlistRole)
{
this.playlistRole = playlistRole;
}
public boolean getCoverArtRole()
{
return this.coverArtRole;
}
public void setCoverArtRole(boolean coverArtRole)
{
this.coverArtRole = coverArtRole;
}
public boolean getCommentRole()
{
return this.commentRole;
}
public void setCommentRole(boolean commentRole)
{
this.commentRole = commentRole;
}
public boolean getPodcastRole()
{
return this.podcastRole;
}
public void setPodcastRole(boolean podcastRole)
{
this.podcastRole = podcastRole;
}
public boolean getStreamRole()
{
return this.streamRole;
}
public void setStreamRole(boolean streamRole)
{
this.streamRole = streamRole;
}
public boolean getJukeboxRole()
{
return this.jukeboxRole;
}
public void setJukeboxRole(boolean jukeboxRole)
{
this.jukeboxRole = jukeboxRole;
}
public boolean getShareRole()
{
return this.shareRole;
}
public void setShareRole(boolean shareRole)
{
this.shareRole = shareRole;
}
}

View File

@ -0,0 +1,67 @@
package com.thejoshwa.ultrasonic.androidapp.service.parser;
import android.content.Context;
import com.thejoshwa.ultrasonic.androidapp.R;
import com.thejoshwa.ultrasonic.androidapp.domain.UserInfo;
import com.thejoshwa.ultrasonic.androidapp.util.ProgressListener;
import org.xmlpull.v1.XmlPullParser;
import java.io.Reader;
/**
* @author Joshua Bahnsen
*/
public class UserInfoParser extends AbstractParser
{
public UserInfoParser(Context context)
{
super(context);
}
public UserInfo parse(Reader reader, ProgressListener progressListener) throws Exception
{
updateProgress(progressListener, R.string.parser_reading);
init(reader);
UserInfo result = new UserInfo();
int eventType;
do
{
eventType = nextParseEvent();
if (eventType == XmlPullParser.START_TAG)
{
String name = getElementName();
if ("user".equals(name))
{
result.setAdminRole(getBoolean("adminRole"));
result.setCommentRole(getBoolean("commentRole"));
result.setCoverArtRole(getBoolean("coverArtRole"));
result.setDownloadRole(getBoolean("downloadRole"));
result.setEmail(get("email"));
result.setJukeboxRole(getBoolean("jukeboxRole"));
result.setPlaylistRole(getBoolean("playlistRole"));
result.setPodcastRole(getBoolean("podcastRole"));
result.setScrobblingEnabled(getBoolean("scrobblingEnabled"));
result.setSettingsRole(getBoolean("settingsRole"));
result.setShareRole(getBoolean("shareRole"));
result.setStreamRole(getBoolean("streamRole"));
result.setUploadRole(getBoolean("uploadRole"));
result.setUserName(get("username"));
}
else if ("error".equals(name))
{
handleError();
}
}
} while (eventType != XmlPullParser.END_DOCUMENT);
validate();
updateProgress(progressListener, R.string.parser_reading_done);
return result;
}
}