aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-05-16 19:04:48 -0700
committerScott Jackson <daneren2005@gmail.com>2013-05-16 19:04:48 -0700
commit4bfa0b7fd89ffd679ed71b2548e4494c5a2dc4a3 (patch)
tree20fdc10cb1e656a4657a11825262fa922cec41fe /subsonic-android/src/github/daneren2005
parent876a297aeb31445957001f6e4d4fc159d8dccc4e (diff)
downloaddsub-4bfa0b7fd89ffd679ed71b2548e4494c5a2dc4a3.tar.gz
dsub-4bfa0b7fd89ffd679ed71b2548e4494c5a2dc4a3.tar.bz2
dsub-4bfa0b7fd89ffd679ed71b2548e4494c5a2dc4a3.zip
Fix a bunch of the first run stuff
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java36
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SubsonicActivity.java13
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java20
3 files changed, 36 insertions, 33 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..e5835f80 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
@@ -5,8 +5,10 @@ import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.SharedPreferences;
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 +25,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 +58,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 +164,7 @@ public class MainActivity extends SubsonicActivity {
super.onPostCreate(bundle);
showInfoDialog();
+ checkUpdates();
ChangeLog changeLog = new ChangeLog(this, Util.getPreferences(this));
if(changeLog.isFirstRun()) {
@@ -224,10 +230,40 @@ public class MainActivity extends SubsonicActivity {
getImageLoader().loadImage(coverArtView, song, false, false);
startButton.setImageResource((getDownloadService().getPlayerState() == PlayerState.STARTED) ? R.drawable.media_pause : R.drawable.media_start);
}
+
+ 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();