updated to newest target API and some updates within gradle dependiences

fix/get-all-stations-hangout
Mateusz Lubecki 2021-11-25 22:58:57 +01:00
rodzic f19b196aac
commit 8628529de0
6 zmienionych plików z 72 dodań i 54 usunięć

Wyświetl plik

@ -11,7 +11,7 @@ android {
defaultConfig {
applicationId "cc.pogoda.mobile.pogodacc"
minSdkVersion 24
targetSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
@ -47,11 +47,11 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.okhttp3:logging-interceptor:3.14.7'
implementation 'com.squareup.okhttp3:okhttp:3.14.7'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.2'
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.1'
implementation 'org.greenrobot:eventbus:3.0.0'

Wyświetl plik

@ -16,6 +16,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/Theme.Pogodacc">
<activity
android:name=".activity.ExportDataActivity"

Wyświetl plik

@ -5,7 +5,10 @@ import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.os.strictmode.Violation;
import android.view.Menu;
import android.widget.ImageButton;
@ -135,6 +138,12 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.VmPolicy.Builder b = new StrictMode.VmPolicy.Builder();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
StrictMode.VmPolicy policy = b.detectAll().detectNonSdkApiUsage().penaltyListener((Runnable r) -> r.run(), (Violation v) -> {v.printStackTrace();}).build();
StrictMode.setVmPolicy(policy);
}
// register to Event bus to receive events when a station is added od removed from favourites
EventBus.getDefault().register(this);

Wyświetl plik

@ -33,15 +33,14 @@ public class TrendActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String stationName = (String)getIntent().getExtras().get("station");
setContentView(R.layout.activity_trend);
NavArgument.Builder builder = new NavArgument.Builder();
this.station = stationName;
Bundle bundle = new Bundle();
bundle.putString("station", stationName);
this.station = stationName;
setContentView(R.layout.activity_trend);
NavArgument.Builder builder = new NavArgument.Builder();
BottomNavigationView navView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each

Wyświetl plik

@ -109,44 +109,59 @@ public class WindTrendViewModel extends ViewModel {
}
public boolean updateData() {
Trend trend = trendDao.getStationTrend(station);
if (station != null && station.length() > 0) {
Trend trend = trendDao.getStationTrend(station);
if (trend != null) {
if (trend != null) {
// format the time and date according to current locale
String dt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT).format(LocalDateTime.ofEpochSecond(trend.last_timestamp, 0, ZoneOffset.UTC).atOffset(ZoneOffset.UTC).atZoneSameInstant(ZoneOffset.systemDefault()));
// format the time and date according to current locale
String dt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT).format(LocalDateTime.ofEpochSecond(trend.last_timestamp, 0, ZoneOffset.UTC).atOffset(ZoneOffset.UTC).atZoneSameInstant(ZoneOffset.systemDefault()));
lastMeasuremenetTime.postValue(dt);
displayedStationName.postValue(trend.displayed_name);
lastMeasuremenetTime.postValue(dt);
displayedStationName.postValue(trend.displayed_name);
if (!trend.current_wind_qf.equals("NOT_AVALIABLE") && !trend.current_wind_qf.equals("NO_DATA")) {
if (AppConfiguration.replaceMsWithKnots) {
// if knots
currentMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.current_value));
twoHoursMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.two_hours_value));
fourHoursMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.four_hours_value));
sixHoursMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.six_hours_value));
eightHoursMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.eight_hours_value));
if (!trend.current_wind_qf.equals("NOT_AVALIABLE") && !trend.current_wind_qf.equals("NO_DATA")) {
if (AppConfiguration.replaceMsWithKnots) {
// if knots
currentMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.current_value));
twoHoursMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.two_hours_value));
fourHoursMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.four_hours_value));
sixHoursMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.six_hours_value));
eightHoursMeanValue.postValue(String.format("%.0f kts", trend.average_wind_speed_trend.eight_hours_value));
currentGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.current_value));
twoHoursGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.two_hours_value));
fourHoursGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.four_hours_value));
sixHoursGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.six_hours_value));
eightHoursGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.eight_hours_value));
currentGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.current_value));
twoHoursGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.two_hours_value));
fourHoursGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.four_hours_value));
sixHoursGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.six_hours_value));
eightHoursGustValue.postValue(String.format("%.0f kts", trend.maximum_wind_speed_trend.eight_hours_value));
} else {
// if meters per second
currentMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.current_value));
twoHoursMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.two_hours_value));
fourHoursMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.four_hours_value));
sixHoursMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.six_hours_value));
eightHoursMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.eight_hours_value));
currentGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.current_value));
twoHoursGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.two_hours_value));
fourHoursGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.four_hours_value));
sixHoursGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.six_hours_value));
eightHoursGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.eight_hours_value));
}
} else {
// if meters per second
currentMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.current_value));
twoHoursMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.two_hours_value));
fourHoursMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.four_hours_value));
sixHoursMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.six_hours_value));
eightHoursMeanValue.postValue(String.format("%.1f m/s", trend.average_wind_speed_trend.eight_hours_value));
currentMeanValue.postValue("--");
twoHoursMeanValue.postValue("--");
fourHoursMeanValue.postValue("--");
sixHoursMeanValue.postValue("--");
eightHoursMeanValue.postValue("--");
currentGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.current_value));
twoHoursGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.two_hours_value));
fourHoursGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.four_hours_value));
sixHoursGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.six_hours_value));
eightHoursGustValue.postValue(String.format("%.1f m/s", trend.maximum_wind_speed_trend.eight_hours_value));
currentGustValue.postValue("--");
twoHoursGustValue.postValue("--");
fourHoursGustValue.postValue("--");
sixHoursGustValue.postValue("--");
eightHoursGustValue.postValue("--");
}
return true;
} else {
currentMeanValue.postValue("--");
twoHoursMeanValue.postValue("--");
@ -159,23 +174,11 @@ public class WindTrendViewModel extends ViewModel {
fourHoursGustValue.postValue("--");
sixHoursGustValue.postValue("--");
eightHoursGustValue.postValue("--");
return false;
}
return true;
}
else {
currentMeanValue.postValue("--");
twoHoursMeanValue.postValue("--");
fourHoursMeanValue.postValue("--");
sixHoursMeanValue.postValue("--");
eightHoursMeanValue.postValue("--");
currentGustValue.postValue("--");
twoHoursGustValue.postValue("--");
fourHoursGustValue.postValue("--");
sixHoursGustValue.postValue("--");
eightHoursGustValue.postValue("--");
return false;
}
return false;
}
}

Wyświetl plik

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">pogoda.cc</domain>
</domain-config>
</network-security-config>