Skip to content

Commit

Permalink
Merge branch 'Fragments' of https://github.com/daneren2005/Subsonic.git
Browse files Browse the repository at this point in the history
  • Loading branch information
daneren2005 committed May 17, 2013
2 parents 7182604 + 3c62063 commit 72b9feb
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 45 deletions.
4 changes: 3 additions & 1 deletion subsonic-android/res/raw/changelog.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="4.0.0" versioncode="46" >
<release version="4.0.0" versioncode="46" releasedate="5/16/2013">
<change>Converted everything to fragments!</change>
<change>Swipe to switch tabs</change>
<change>Breadcrumb trail when going down several levels</change>
<change>Require double tapping back to exit app</change>
<change>Change log dialog for new versions</change>
<change>Endless loading on album lists (ie: Random, Recently Added, etc...) instead of pressing more</change>
<change>Look at what is now playing from main tabs</change>
<change>Added Playing: Track/Total to Now Playing action bar</change>
<change>When clicking on a album in search, the parent is also added to the back stack</change>
<change>Added total time to playlist/album headers</change>
<change>Fixed a lot of the menu items not working when using search</change>
<change>Update to Light/Dark themes</change>
</release>
</changelog>
10 changes: 5 additions & 5 deletions subsonic-android/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
<item name="android:windowFullscreen">true</item>
</style>

<style name="Widget.DSub.ActionBarStyle.Light" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/menubar_button_normal</item>
<item name="android:background">@drawable/actionbar_background</item>
<item name="backgroundStacked">@drawable/actionbar_background</item>
<item name="android:backgroundStacked">@drawable/actionbar_background</item>
<style name="Widget.DSub.ActionBarStyle.Light" parent="Widget.Sherlock.Light.ActionBar.Solid">
<item name="background">@android:color/transparent</item>
<item name="android:background">@android:color/transparent</item>
<item name="backgroundStacked">@android:color/transparent</item>
<item name="android:backgroundStacked">@android:color/transparent</item>
</style>

<style name="Widget.DSub.ActionBarStyle.Dark" parent="Widget.Sherlock.ActionBar.Solid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import android.support.v4.view.ViewPager;
Expand All @@ -23,7 +27,9 @@
import github.daneren2005.dsub.fragments.SelectPlaylistFragment;
import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadServiceImpl;
import github.daneren2005.dsub.updates.Updater;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.ChangeLog;
Expand Down Expand Up @@ -54,6 +60,7 @@ public void onCreate(Bundle savedInstanceState) {
startActivity(intent);
}
setContentView(R.layout.main);
loadSettings();

View bottomBar = findViewById(R.id.bottom_bar);
bottomBar.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -159,6 +166,7 @@ protected void onPostCreate(Bundle bundle) {
super.onPostCreate(bundle);

showInfoDialog();
checkUpdates();

ChangeLog changeLog = new ChangeLog(this, Util.getPreferences(this));
if(changeLog.isFirstRun()) {
Expand Down Expand Up @@ -222,12 +230,46 @@ private void update() {
trackView.setText(song.getTitle());
artistView.setText(song.getArtist());
getImageLoader().loadImage(coverArtView, song, false, false);
startButton.setImageResource((getDownloadService().getPlayerState() == PlayerState.STARTED) ? R.drawable.media_pause : R.drawable.media_start);
int[] attrs = new int[] {(getDownloadService().getPlayerState() == PlayerState.STARTED) ? R.attr.media_button_pause : R.attr.media_button_start};
TypedArray typedArray = this.obtainStyledAttributes(attrs);
Drawable drawable = typedArray.getDrawable(0);
startButton.setImageDrawable(drawable);
typedArray.recycle();
}

public void checkUpdates() {
try {
String version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
int ver = Integer.parseInt(version.replace(".", ""));
Updater updater = new Updater(ver);
updater.checkUpdates(this);
}
catch(Exception e) {

}
}

private void loadSettings() {
PreferenceManager.setDefaultValues(this, R.xml.settings, false);
SharedPreferences prefs = Util.getPreferences(this);
if (!prefs.contains(Constants.PREFERENCES_KEY_CACHE_LOCATION)) {
SharedPreferences.Editor editor = prefs.edit();
editor.putString(Constants.PREFERENCES_KEY_CACHE_LOCATION, FileUtil.getDefaultMusicDirectory().getPath());
editor.commit();
}

if (!prefs.contains(Constants.PREFERENCES_KEY_OFFLINE)) {
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(Constants.PREFERENCES_KEY_OFFLINE, false);
editor.putInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1);
editor.commit();
}
}

private void showInfoDialog() {
if (!infoDialogDisplayed) {
infoDialogDisplayed = true;
Log.i(TAG, Util.getRestUrl(this, null));
if (Util.getRestUrl(this, null).contains("demo.subsonic.org")) {
Util.info(this, R.string.main_welcome_title, R.string.main_welcome_text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import github.daneren2005.dsub.fragments.SubsonicFragment;
import github.daneren2005.dsub.service.DownloadService;
import github.daneren2005.dsub.service.DownloadServiceImpl;
import github.daneren2005.dsub.updates.Updater;
import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.Util;
Expand Down Expand Up @@ -331,18 +330,6 @@ public TabPagerAdapter getPagerAdapter() {
return pagerAdapter;
}

public void checkUpdates() {
try {
String version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
int ver = Integer.parseInt(version.replace(".", ""));
Updater updater = new Updater(ver);
updater.checkUpdates(SubsonicActivity.this);
}
catch(Exception e) {

}
}

public static String getThemeName() {
return theme;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.StatFs;
import android.preference.PreferenceManager;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -48,7 +46,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bu
this.inflater = inflater;
rootView = inflater.inflate(R.layout.home, container, false);

loadSettings();
createLayout();

return rootView;
Expand Down Expand Up @@ -202,23 +199,6 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
});
}

private void loadSettings() {
PreferenceManager.setDefaultValues(context, R.xml.settings, false);
SharedPreferences prefs = Util.getPreferences(context);
if (!prefs.contains(Constants.PREFERENCES_KEY_CACHE_LOCATION)) {
SharedPreferences.Editor editor = prefs.edit();
editor.putString(Constants.PREFERENCES_KEY_CACHE_LOCATION, FileUtil.getDefaultMusicDirectory().getPath());
editor.commit();
}

if (!prefs.contains(Constants.PREFERENCES_KEY_OFFLINE)) {
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(Constants.PREFERENCES_KEY_OFFLINE, false);
editor.putInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1);
editor.commit();
}
}

private void setActiveServer(int instance) {
if (Util.getActiveServer(context) != instance) {
DownloadService service = getDownloadService();
Expand Down
23 changes: 18 additions & 5 deletions subsonic-android/src/github/daneren2005/dsub/view/ChangeLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public class ChangeLog {
* Default CSS styles used to format the change log.
*/
private static final String DEFAULT_CSS =
"h1 { margin-left: 0px; font-size: 1.2em;}" +
"div.title { margin-left: 0px; font-size: 1.2em; text-align: center;}" +
"div.subtitle {margin-left: 0px; font-size: .8em; text-align: center;}" +
"li { margin-left: 0px;}" +
"ul { padding-left: 2em;}";

Expand Down Expand Up @@ -125,6 +126,7 @@ protected interface ReleaseTag {
static final String NAME = "release";
static final String ATTRIBUTE_VERSION = "version";
static final String ATTRIBUTE_VERSION_CODE = "versioncode";
static final String ATTRIBUTE_RELEASE_DATE = "releasedate";
}

/**
Expand Down Expand Up @@ -406,9 +408,15 @@ private String getLog(boolean full) {
// if necessary.
ReleaseItem release = changelog.get(key, defaultChangelog.get(key));

sb.append("<h1>");
sb.append("<div class='title'>");
sb.append(String.format(versionFormat, release.versionName));
sb.append("</h1><ul>");
sb.append("</div>");
if(release.releaseDate != null) {
sb.append("<div class='subtitle'>");
sb.append(release.releaseDate);
sb.append("</div>");
}
sb.append("<ul>");
for (String change : release.changes) {
sb.append("<li>");
sb.append(change);
Expand Down Expand Up @@ -489,6 +497,8 @@ private boolean parseReleaseTag(XmlPullParser xml, boolean full,
} catch (NumberFormatException e) {
versionCode = NO_VERSION;
}

String releaseDate = xml.getAttributeValue(null, ReleaseTag.ATTRIBUTE_RELEASE_DATE);

if (!full && versionCode <= mLastVersionCode) {
return true;
Expand All @@ -505,7 +515,7 @@ private boolean parseReleaseTag(XmlPullParser xml, boolean full,
eventType = xml.next();
}

ReleaseItem release = new ReleaseItem(versionCode, version, changes);
ReleaseItem release = new ReleaseItem(versionCode, version, releaseDate, changes);
changelog.put(versionCode, release);

return false;
Expand All @@ -524,15 +534,18 @@ protected static class ReleaseItem {
* Version name of the release.
*/
public final String versionName;

public final String releaseDate;

/**
* List of changes introduced with that release.
*/
public final List<String> changes;

ReleaseItem(int versionCode, String versionName, List<String> changes) {
ReleaseItem(int versionCode, String versionName, String releaseDate, List<String> changes) {
this.versionCode = versionCode;
this.versionName = versionName;
this.releaseDate = releaseDate;
this.changes = changes;
}
}
Expand Down

0 comments on commit 72b9feb

Please sign in to comment.