/*
 * Copyright 2011 Uwe Trottmann
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package com.battlelancer.seriesguide;

import com.battlelancer.seriesguide.ui.SeriesGuidePreferences;
import com.battlelancer.seriesguide.util.ImageProvider;
import com.battlelancer.seriesguide.util.Utils;
import com.google.analytics.tracking.android.EasyTracker;
import com.uwetrottmann.androidutils.AndroidUtils;

import android.app.Application;
import android.preference.PreferenceManager;

public class SeriesGuideApplication extends Application {

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

        Utils.runNotificationService(this);

        final String theme = PreferenceManager.getDefaultSharedPreferences(this).getString(
                SeriesGuidePreferences.KEY_THEME, "0");
        Utils.updateTheme(theme);

        EasyTracker.getInstance().setContext(getApplicationContext());
    }

    @Override
    public void onLowMemory() {
        if (!AndroidUtils.isICSOrHigher()) {
            // clear the whole cache as Honeycomb and below don't support
            // onTrimMemory (used directly in our ImageProvider)
            ImageProvider.getInstance(this).clearCache();
        }
    }

}

@@ -990,16 +990,149 @@
 nager;%0A%0A
+/**%0A * Initializes settings and services and on pre-ICS implements actions for low%0A * memory state.%0A * %0A * @author Uwe Trottmann%0A */%0A
 public c
@@ -1264,44 +1264,320 @@
     
-Utils.runNotificationService(this);%0A
+// initialize settings on first run%0A        PreferenceManager.setDefaultValues(this, R.layout.preferences, false);%0A%0A        // ensure the notifications service is started (we also restart it on%0A        // boot)%0A        Utils.runNotificationService(this);%0A%0A        // load the current theme into a global variable
 %0A   
@@ -1752,24 +1752,70 @@
 me(theme);%0A%0A
+        // set a context for Google Analytics%0A
         Easy

Initialize app settings on first run