diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-05-16 20:28:33 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-05-16 20:28:33 -0700 |
commit | 72b9feb331d3691bc31c08313054785e97b8de7f (patch) | |
tree | 8841edd1d1216dc4310d0a58eeeaf5a1fa7d1716 /subsonic-android/src | |
parent | 7182604e3f3cd9770264e9947696506c766434ee (diff) | |
parent | 3c62063b794b6c8385a34330f4268fe4949b4662 (diff) | |
download | dsub-72b9feb331d3691bc31c08313054785e97b8de7f.tar.gz dsub-72b9feb331d3691bc31c08313054785e97b8de7f.tar.bz2 dsub-72b9feb331d3691bc31c08313054785e97b8de7f.zip |
Merge branch 'Fragments' of https://github.com/daneren2005/Subsonic.git
Diffstat (limited to 'subsonic-android/src')
4 files changed, 61 insertions, 39 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java index 8ca0fdac..d0eb86ef 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java @@ -5,8 +5,12 @@ import android.app.PendingIntent; 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; @@ -23,7 +27,9 @@ import github.daneren2005.dsub.fragments.SelectArtistFragment; 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; @@ -54,6 +60,7 @@ public class MainActivity extends SubsonicActivity { startActivity(intent); } setContentView(R.layout.main); + loadSettings(); View bottomBar = findViewById(R.id.bottom_bar); bottomBar.setOnClickListener(new View.OnClickListener() { @@ -159,6 +166,7 @@ public class MainActivity extends SubsonicActivity { super.onPostCreate(bundle); showInfoDialog(); + checkUpdates(); ChangeLog changeLog = new ChangeLog(this, Util.getPreferences(this)); if(changeLog.isFirstRun()) { @@ -222,12 +230,46 @@ public class MainActivity extends SubsonicActivity { 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); } diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java index f8d0019b..15b8421f 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -30,7 +30,6 @@ import github.daneren2005.dsub.R; 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;
@@ -331,18 +330,6 @@ public class SubsonicActivity extends SherlockFragmentActivity implements OnItem 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;
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java index ec938ca9..3ccd8a0b 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java @@ -2,11 +2,9 @@ package github.daneren2005.dsub.fragments; 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;
@@ -48,7 +46,6 @@ public class MainFragment extends SubsonicFragment { this.inflater = inflater;
rootView = inflater.inflate(R.layout.home, container, false);
- loadSettings();
createLayout();
return rootView;
@@ -202,23 +199,6 @@ public class MainFragment extends SubsonicFragment { });
}
- 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();
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/ChangeLog.java b/subsonic-android/src/github/daneren2005/dsub/view/ChangeLog.java index 630fb021..b847733e 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/ChangeLog.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/ChangeLog.java @@ -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;}"; @@ -125,6 +126,7 @@ public class ChangeLog { 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"; } /** @@ -406,9 +408,15 @@ public class ChangeLog { // 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); @@ -489,6 +497,8 @@ public class ChangeLog { } catch (NumberFormatException e) { versionCode = NO_VERSION; } + + String releaseDate = xml.getAttributeValue(null, ReleaseTag.ATTRIBUTE_RELEASE_DATE); if (!full && versionCode <= mLastVersionCode) { return true; @@ -505,7 +515,7 @@ public class ChangeLog { eventType = xml.next(); } - ReleaseItem release = new ReleaseItem(versionCode, version, changes); + ReleaseItem release = new ReleaseItem(versionCode, version, releaseDate, changes); changelog.put(versionCode, release); return false; @@ -524,15 +534,18 @@ public class ChangeLog { * 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; } } |