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

Commit 9896b41e authored by Aayush Gupta's avatar Aayush Gupta
Browse files

OpenWeatherMapWeatherProvider: Massive rework



- Update and add copyright for E FOUNDATION
- Pull lineage-sdk jar file from BlissLauncher Q to avoid API conflicts
- Resolve deprecated code warnings
- Add support for dark & light theme modes
- Refactor DEFAULT_OWM_KEY implementation
- Bump major version to indicate massive changes

Signed-off-by: Aayush Gupta's avatarAayush Gupta <theimpulson@e.email>
parent a394d678
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ stages:
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
- sed -i -e 's/<string name="default_key"><\/string>/<string name="default_key">'${DEFAULT_OWM_KEY}'<\/string>/g' app/src/main/res/values/strings.xml

cache:
  key: ${CI_PROJECT_ID}
+11 −8
Original line number Diff line number Diff line
apply plugin: 'com.android.application'
plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
@@ -7,8 +9,9 @@ android {
        applicationId "org.lineageos.openweathermapprovider"
        minSdkVersion 27
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        versionCode 2
        versionName "2.0.0"
        buildConfigField "String", "DEFAULT_OWM_KEY", "\"$System.env.DEFAULT_OWM_KEY\""
    }

    signingConfigs {
@@ -29,10 +32,7 @@ android {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    lintOptions {
        // These depend on translations
        disable 'MissingTranslation'
@@ -41,9 +41,12 @@ android {
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['lineage-sdk.jar'])
    compileOnly fileTree(dir: 'libs', include: ['lineage-sdk.jar'])
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation "com.google.android.material:material:1.4.0"
    implementation 'com.google.code.gson:gson:2.8.7'
    implementation 'com.squareup.retrofit2:retrofit:2.6.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
    implementation 'com.squareup.okhttp3:okhttp:4.1.0'
    implementation "androidx.preference:preference:1.1.1"
}
−3.45 MiB (400 KiB)

File changed.

No diff preview for this file type.

+18 −14
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The CyanogenMod Project

     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.
<!--
  ~ Copyright (C) 2016 The CyanogenMod Project
  ~ Copyright (C) 2021 E FOUNDATION
  ~
  ~ 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.
  -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.lineageos.openweathermapprovider">
@@ -22,6 +24,8 @@

    <application
        android:allowBackup="true"
        android:fullBackupOnly="true"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
+6 −5
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The CyanogenMod Project
 * Copyright (C) 2021 E FOUNDATION
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -50,8 +51,8 @@ public class OpenWeatherMapProviderService extends WeatherProviderService

    private OpenWeatherMapService mOpenWeatherMapService;

    private Map<ServiceRequest,WeatherUpdateRequestTask> mWeatherUpdateRequestMap = new HashMap<>();
    private Map<ServiceRequest,LookupCityNameRequestTask> mLookupCityRequestMap = new HashMap<>();
    private final Map<ServiceRequest,WeatherUpdateRequestTask> mWeatherUpdateRequestMap = new HashMap<>();
    private final Map<ServiceRequest,LookupCityNameRequestTask> mLookupCityRequestMap = new HashMap<>();
    //OpenWeatherMap recommends to wait 10 min between requests
    private final static long REQUEST_THRESHOLD = 1000L * 60L * 10L;
    private long mLastRequestTimestamp = -REQUEST_THRESHOLD;
@@ -70,7 +71,7 @@ public class OpenWeatherMapProviderService extends WeatherProviderService
        final SharedPreferences preferences
                = PreferenceManager.getDefaultSharedPreferences(this);
        preferences.registerOnSharedPreferenceChangeListener(this);
        final String mApiId = preferences.getString(API_KEY, getString(R.string.default_key));
        final String mApiId = preferences.getString(API_KEY, BuildConfig.DEFAULT_OWM_KEY);
        mOpenWeatherMapService.setApiKey(mApiId);
    }

@@ -148,7 +149,7 @@ public class OpenWeatherMapProviderService extends WeatherProviderService
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        if (key.equals(API_KEY)) {
            Log.d(TAG, "API key has changed");
            final String mApiKey = sharedPreferences.getString(key, getString(R.string.default_key));
            final String mApiKey = sharedPreferences.getString(key, BuildConfig.DEFAULT_OWM_KEY);
            mOpenWeatherMapService.setApiKey(mApiKey);
        }
    }
Loading