// Path: app/src/main/java/ooo/oxo/apps/earth/LegacyEarthSharedState.java
// public class LegacyEarthSharedState {
// 
//     @SuppressWarnings("unused")
//     private static final String TAG = "LegacyEarthSharedState";
// 
//     private final Context context;
//     private final SharedPreferences preferences;
// 
//     public LegacyEarthSharedState(Context context) {
//         this.context = context;
//         this.preferences = context.getSharedPreferences("earth", Context.MODE_PRIVATE);
//     }
// 
//     @Nullable
//     public String getLastEarth() {
//         return preferences.getString("last_earth", null);
//     }
// 
//     public long getInterval() {
//         return preferences.getLong("interval", TimeUnit.MINUTES.toMillis(10));
//     }
// 
//     public int getResolution() {
//         if (!BuildConfig.USE_OXO_SERVER) {
//             return 550;
//         }
// 
//         int resolution = preferences.getInt("resolution", 0);
// 
//         if (resolution == 0) {
//             DisplayMetrics metrics = context.getResources().getDisplayMetrics();
//             resolution = Resolutions.findBestResolution(metrics);
//         }
// 
//         return resolution;
//     }
// 
//     public boolean getWifiOnly() {
//         return preferences.getBoolean("wifi_only", true);
//     }
// 
// }
// 
// Path: app/src/main/java/ooo/oxo/apps/earth/provider/SettingsContract.java
// @SuppressWarnings("WeakerAccess")
// public class SettingsContract {
// 
//     public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".settings";
// 
//     public static final Uri CONTENT_URI = new Uri.Builder()
//             .scheme(ContentResolver.SCHEME_CONTENT)
//             .authority(AUTHORITY)
//             .path("settings")
//             .build();
// 
//     static final String TABLE = "settings";
// 
//     public static class Columns {
//         public static final String INTERVAL = "interval";
//         public static final String RESOLUTION = "resolution";
//         public static final String WIFI_ONLY = "wifi_only";
//         public static final String DEBUG = "debug";
//         public static final String OFFSET_L = "offset_l";
//         public static final String OFFSET_S = "offset_s";
//         public static final String SCALE = "scale";
//     }
// 
// }


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import ooo.oxo.apps.earth.LegacyEarthSharedState;
import ooo.oxo.apps.earth.provider.SettingsContract;
/*
 * Mantou Earth - Live your wallpaper with live earth
 * Copyright (C) 2015-2019 XiNGRZ <xxx@oxo.ooo>
 *
 * This program 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.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package ooo.oxo.apps.earth.dao;




public class Settings {

    public long interval;

    public int resolution;

    public boolean wifiOnly;

    public float offsetLong;

    public float offsetShort;

    public float scale;

    public boolean debug;

    public static Settings fromLegacySharedState(Context context) {
        LegacyEarthSharedState sharedState = new LegacyEarthSharedState(context);

        Settings settings = new Settings();

        settings.interval = sharedState.getInterval();
        settings.resolution = sharedState.getResolution();
        settings.wifiOnly = sharedState.getWifiOnly();
        settings.offsetLong = 0f;
        settings.offsetShort = 0f;
        settings.scale = 1f;

        return settings;
    }

    @Nullable
    public static Settings fromCursor(@NonNull Cursor cursor) {
        if (!cursor.moveToNext()) {
            return null;
        }

        Settings settings = new Settings();
// Path: app/src/main/java/ooo/oxo/apps/earth/LegacyEarthSharedState.java
// public class LegacyEarthSharedState {
// 
//     @SuppressWarnings("unused")
//     private static final String TAG = "LegacyEarthSharedState";
// 
//     private final Context context;
//     private final SharedPreferences preferences;
// 
//     public LegacyEarthSharedState(Context context) {
//         this.context = context;
//         this.preferences = context.getSharedPreferences("earth", Context.MODE_PRIVATE);
//     }
// 
//     @Nullable
//     public String getLastEarth() {
//         return preferences.getString("last_earth", null);
//     }
// 
//     public long getInterval() {
//         return preferences.getLong("interval", TimeUnit.MINUTES.toMillis(10));
//     }
// 
//     public int getResolution() {
//         if (!BuildConfig.USE_OXO_SERVER) {
//             return 550;
//         }
// 
//         int resolution = preferences.getInt("resolution", 0);
// 
//         if (resolution == 0) {
//             DisplayMetrics metrics = context.getResources().getDisplayMetrics();
//             resolution = Resolutions.findBestResolution(metrics);
//         }
// 
//         return resolution;
//     }
// 
//     public boolean getWifiOnly() {
//         return preferences.getBoolean("wifi_only", true);
//     }
// 
// }
// 
// Path: app/src/main/java/ooo/oxo/apps/earth/provider/SettingsContract.java
// @SuppressWarnings("WeakerAccess")
// public class SettingsContract {
// 
//     public static final String AUTHORITY = BuildConfig.APPLICATION_ID + ".settings";
// 
//     public static final Uri CONTENT_URI = new Uri.Builder()
//             .scheme(ContentResolver.SCHEME_CONTENT)
//             .authority(AUTHORITY)
//             .path("settings")
//             .build();
// 
//     static final String TABLE = "settings";
// 
//     public static class Columns {
//         public static final String INTERVAL = "interval";
//         public static final String RESOLUTION = "resolution";
//         public static final String WIFI_ONLY = "wifi_only";
//         public static final String DEBUG = "debug";
//         public static final String OFFSET_L = "offset_l";
//         public static final String OFFSET_S = "offset_s";
//         public static final String SCALE = "scale";
//     }
// 
// }


// Path: app/src/main/java/ooo/oxo/apps/earth/dao/Settings.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import ooo.oxo.apps.earth.LegacyEarthSharedState;
import ooo.oxo.apps.earth.provider.SettingsContract;

/*
 * Mantou Earth - Live your wallpaper with live earth
 * Copyright (C) 2015-2019 XiNGRZ <xxx@oxo.ooo>
 *
 * This program 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.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package ooo.oxo.apps.earth.dao;




public class Settings {

    public long interval;

    public int resolution;

    public boolean wifiOnly;

    public float offsetLong;

    public float offsetShort;

    public float scale;

    public boolean debug;

    public static Settings fromLegacySharedState(Context context) {
        LegacyEarthSharedState sharedState = new LegacyEarthSharedState(context);

        Settings settings = new Settings();

        settings.interval = sharedState.getInterval();
        settings.resolution = sharedState.getResolution();
        settings.wifiOnly = sharedState.getWifiOnly();
        settings.offsetLong = 0f;
        settings.offsetShort = 0f;
        settings.scale = 1f;

        return settings;
    }

    @Nullable
    public static Settings fromCursor(@NonNull Cursor cursor) {
        if (!cursor.moveToNext()) {
            return null;
        }

        Settings settings = new Settings();
        settings.interval = cursor.getLong(cursor.getColumnIndexOrThrow(SettingsContract.Columns.INTERVAL));