Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 782e3abc authored by Amit Kumar's avatar Amit Kumar
Browse files

Add shortcut support for oreo, Fix number of bugs and refactor project

parent 1f11f0e1
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ android {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
@@ -62,6 +66,7 @@ dependencies {

    debugImplementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
    debugImplementation 'com.google.firebase:firebase-core:16.0.4'
    debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'

    implementation 'org.greenrobot:eventbus:3.1.1'

@@ -87,6 +92,11 @@ dependencies {
    // Rx Relay
    implementation "com.jakewharton.rxrelay2:rxrelay:${rootProject.ext.rxRelayVersion}"

    // Room
    implementation "android.arch.persistence.room:runtime:1.1.1"
    annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
    implementation "com.android.support:support-annotations:${rootProject.ext.supportLibraryVersion}"

    // Unit test dependencies
    testImplementation "junit:junit:${rootProject.ext.junitVersion}"
    testImplementation "org.robolectric:robolectric:${rootProject.ext.robolectricVersion}"
+11 −10
Original line number Diff line number Diff line
package org.indin.blisslaunchero.framework;
package org.indin.blisslaunchero.core;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;

import org.indin.blisslaunchero.framework.utils.Constants;
import org.indin.blisslaunchero.core.utils.Constants;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -59,6 +59,7 @@ public class Preferences {
     */
    public static final String LAYOUT_PRESENT = "layout_present";
    public static final String FIRST_TIME = "org.indin.blisslaunchero.FIRST_TIME";
    private static final String ACTION_USAGE = "org.indin.blisslaunchero.ACTION_USAGE";

    private Preferences() {
    }
@@ -332,14 +333,6 @@ public class Preferences {
        getPrefs(context).edit().putLong(key, System.currentTimeMillis()).apply();
    }

    public static boolean getLayoutPresent(Context context) {
        return getPrefs(context).getBoolean(LAYOUT_PRESENT, false);
    }

    public static void setLayoutPresent(Context context) {
        getPrefs(context).edit().putBoolean(LAYOUT_PRESENT, true).apply();
    }

    public static boolean isFirstTime(Context context){
        return getPrefs(context).getBoolean(FIRST_TIME, true);
    }
@@ -348,6 +341,14 @@ public class Preferences {
        getPrefs(context).edit().putBoolean(FIRST_TIME, false).apply();
    }

    public static boolean shouldOpenUsageAccess(Context context){
        return getPrefs(context).getBoolean(ACTION_USAGE, true);
    }

    public static void setNotOpenUsageAccess(Context context){
        getPrefs(context).edit().putBoolean(ACTION_USAGE, false).apply();
    }

    public static boolean getNotificationAccess(Context context){
        return getPrefs(context).getBoolean(NOTIFICATION_ACCESS, false);
    }
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ import android.widget.Button;
import android.widget.Toast;

import org.indin.blisslaunchero.R;
import org.indin.blisslaunchero.framework.Preferences;
import org.indin.blisslaunchero.core.Preferences;

import java.util.HashSet;
import java.util.List;
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import android.net.ConnectivityManager;
import android.os.IBinder;
import android.util.Log;

import org.indin.blisslaunchero.framework.utils.Constants;
import org.indin.blisslaunchero.core.utils.Constants;

public class DeviceStatusService extends Service {

+102 −7
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@ package org.indin.blisslaunchero.features.weather;

import static cyanogenmod.providers.WeatherContract.WeatherColumns.TempUnit.CELSIUS;
import static cyanogenmod.providers.WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT;
import static cyanogenmod.providers.WeatherContract.WeatherColumns.WindSpeedUnit.KPH;
import static cyanogenmod.providers.WeatherContract.WeatherColumns.WindSpeedUnit.MPH;

import android.annotation.SuppressLint;
import android.content.Context;
@@ -13,7 +15,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;

import org.indin.blisslaunchero.R;
import org.indin.blisslaunchero.framework.Preferences;
import org.indin.blisslaunchero.core.Preferences;

import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -28,14 +30,106 @@ public class ForecastBuilder {

    private static final String TAG = "ForecastBuilder";

    /**
     * This method is used to build the forecast panel
     *
     * @param context      Context to be used
     * @param weatherPanel a view that will contain the forecast
     * @param w            the Weather info object that contains the forecast data
     */
    @SuppressLint("InflateParams")
    public static void buildLargePanel(Context context, View weatherPanel, WeatherInfo w) {
        if (weatherPanel == null) {
            Log.d(TAG, "Invalid view passed");
            return;
        }

        int color = Preferences.weatherFontColor(context);
        final boolean useMetric = Preferences.useMetricUnits(context);
        double temp = w.getTemperature();
        double todayLow = w.getTodaysLow();
        double todayHigh = w.getTodaysHigh();

        int tempUnit = w.getTemperatureUnit();
        if (tempUnit == FAHRENHEIT && useMetric) {
            temp = WeatherUtils.fahrenheitToCelsius(temp);
            todayLow = WeatherUtils.fahrenheitToCelsius(todayLow);
            todayHigh = WeatherUtils.fahrenheitToCelsius(todayHigh);
            tempUnit = CELSIUS;
        } else if (tempUnit == CELSIUS && !useMetric) {
            temp = WeatherUtils.celsiusToFahrenheit(temp);
            todayLow = WeatherUtils.celsiusToFahrenheit(todayLow);
            todayHigh = WeatherUtils.celsiusToFahrenheit(todayHigh);
            tempUnit = FAHRENHEIT;
        }

        // Set the current conditions
        // Weather Image
        ImageView weatherImage = weatherPanel.findViewById(R.id.weather_image);
        String iconsSet = Preferences.getWeatherIconSet(context);
        weatherImage.setImageBitmap(
                WeatherIconUtils.getWeatherIconBitmap(context, iconsSet, color,
                        w.getConditionCode(), WeatherIconUtils.getNextHigherDensity(context)));

        // City
        TextView city = weatherPanel.findViewById(R.id.weather_city);
        city.setText(w.getCity());

        // Weather Condition
        TextView weatherCondition = weatherPanel.findViewById(R.id.weather_condition);
        weatherCondition.setText(
                org.indin.blisslaunchero.features.weather.WeatherUtils.resolveWeatherCondition(
                        context,
                        w.getConditionCode()));

        // Weather Temps
        TextView weatherTemp = weatherPanel.findViewById(
                R.id.weather_current_temperature);
        weatherTemp.setText(WeatherUtils.formatTemperature(temp, tempUnit));

        // Weather Temps Panel additional networkItems
        final String low = WeatherUtils.formatTemperature(todayLow, tempUnit);
        final String high = WeatherUtils.formatTemperature(todayHigh, tempUnit);
        TextView weatherLowHigh = weatherPanel.findViewById(R.id.weather_low_high);
        weatherLowHigh.setText(String.format("%s / %s", low, high));

        double windSpeed = w.getWindSpeed();
        int windSpeedUnit = w.getWindSpeedUnit();
        if (windSpeedUnit == MPH && useMetric) {
            windSpeedUnit = KPH;
            windSpeed = org.indin.blisslaunchero.features.weather.WeatherUtils.milesToKilometers(
                    windSpeed);
        } else if (windSpeedUnit == KPH && !useMetric) {
            windSpeedUnit = MPH;
            windSpeed = org.indin.blisslaunchero.features.weather.WeatherUtils.kilometersToMiles(
                    windSpeed);
        }


        // Humidity and Wind
        TextView weatherHumWind = weatherPanel.findViewById(R.id.weather_chance_rain);
        weatherHumWind.setText(
                String.format("%s, %s %s",
                        org.indin.blisslaunchero.features.weather.WeatherUtils.formatHumidity(
                                w.getHumidity()),
                        org.indin.blisslaunchero.features.weather.WeatherUtils.formatWindSpeed(
                                context, windSpeed, windSpeedUnit),
                        org.indin.blisslaunchero.features.weather.WeatherUtils
                                .resolveWindDirection(
                                        context, w.getWindDirection())));
        LinearLayout forecastView = weatherPanel.findViewById(R.id.forecast_view);
        buildSmallPanel(context, forecastView, w);
    }

    /**
     * This method is used to build the small, horizontal forecasts panel
     *
     * @param context    Context to be used
     * @param smallPanel a horizontal linearlayout that will contain the forecasts
     * @param smallPanel a horizontal {@link LinearLayout} that will contain the forecasts
     * @param w          the Weather info object that contains the forecast data
     */
    @SuppressLint("InflateParams")
    public static void buildSmallPanel(Context context, LinearLayout smallPanel, WeatherInfo w) {
    private static void buildSmallPanel(Context context, LinearLayout smallPanel, WeatherInfo w) {
        if (smallPanel == null) {
            Log.d(TAG, "Invalid view passed");
            return;
@@ -100,7 +194,8 @@ public class ForecastBuilder {
                highTemp = cyanogenmod.weather.util.WeatherUtils.celsiusToFahrenheit(highTemp);
                tempUnit = FAHRENHEIT;
            }
            String dayLow = cyanogenmod.weather.util.WeatherUtils.formatTemperature(lowTemp, tempUnit);
            String dayLow = cyanogenmod.weather.util.WeatherUtils.formatTemperature(lowTemp,
                    tempUnit);
            String dayHigh = WeatherUtils.formatTemperature(highTemp, tempUnit);
            TextView temps = forecastItem.findViewById(R.id.weather_temps);
            temps.setText(String.format("%s\n%s", dayLow, dayHigh));
Loading