diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index 9c6e919..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-Pogoda.cc
\ No newline at end of file
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
index b933e0e..0ea4922 100644
--- a/.idea/deploymentTargetDropDown.xml
+++ b/.idea/deploymentTargetDropDown.xml
@@ -7,11 +7,11 @@
-
+
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8a465d4..f18c4e2 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -24,6 +24,7 @@
+
diff --git a/app/build.gradle b/app/build.gradle
index 28f5556..30abe34 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -3,7 +3,7 @@ plugins {
}
android {
- compileSdkVersion 31
+ compileSdkVersion 33
buildToolsVersion "30.0.3"
apply plugin: "androidx.navigation.safeargs"
@@ -11,9 +11,9 @@ android {
defaultConfig {
applicationId "cc.pogoda.mobile.meteosystem"
minSdkVersion 24
- targetSdkVersion 31
- versionCode 18
- versionName "0.18-beta"
+ targetSdkVersion 33
+ versionCode 19
+ versionName "0.19"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/java/cc/pogoda/mobile/meteosystem/Main.java b/app/src/main/java/cc/pogoda/mobile/meteosystem/Main.java
index 1d8d0f1..ae1e621 100644
--- a/app/src/main/java/cc/pogoda/mobile/meteosystem/Main.java
+++ b/app/src/main/java/cc/pogoda/mobile/meteosystem/Main.java
@@ -26,6 +26,7 @@ import cc.pogoda.mobile.meteosystem.file.FileNames;
import cc.pogoda.mobile.meteosystem.service.GetAllStationsService;
import cc.pogoda.mobile.meteosystem.type.AllStationsReceivedEvent;
import cc.pogoda.mobile.meteosystem.type.AvailableParameters;
+import cc.pogoda.mobile.meteosystem.type.ThemeColours;
import cc.pogoda.mobile.meteosystem.type.WeatherStation;
import cc.pogoda.mobile.meteosystem.type.WeatherStationListEvent;
import cc.pogoda.mobile.meteosystem.type.web.Summary;
@@ -77,6 +78,15 @@ public class Main extends Application {
*/
private HashMap hashmapAllStationSystemNameToAvailParameters = null;
+ public ThemeColours getThemeColours() {
+ return themeColours;
+ }
+
+ /**
+ * Used everywhere, where a colour of any element is set programatically (not globally from the theme)
+ */
+ private ThemeColours themeColours;
+
public File getDirectory() {
return directory;
}
@@ -138,6 +148,8 @@ public class Main extends Application {
favouritiesFile = new FavouritiesFile(fileNames);
+ themeColours = new ThemeColours();
+
// Download all stations from API in background via JobIntentService. Results are send
//back with Broadcast receiver.
startGetAllStationsService();
diff --git a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/FavouritesActivity.java b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/FavouritesActivity.java
index 27160a9..d547fa8 100644
--- a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/FavouritesActivity.java
+++ b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/FavouritesActivity.java
@@ -1,6 +1,10 @@
package cc.pogoda.mobile.meteosystem.activity;
+import android.app.PendingIntent;
+import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.os.Bundle;
+import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;
diff --git a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/MainActivity.java b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/MainActivity.java
index cb553cc..e21a2c9 100644
--- a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/MainActivity.java
+++ b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/MainActivity.java
@@ -8,8 +8,10 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Bundle;
+import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageButton;
@@ -18,6 +20,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import com.google.android.material.color.MaterialColors;
+
import org.greenrobot.eventbus.EventBus;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.format.DateTimeFormatter;
@@ -34,6 +38,7 @@ import cc.pogoda.mobile.meteosystem.activity.handler.MainActImageButtonFavourite
import cc.pogoda.mobile.meteosystem.activity.handler.MainActImageButtonSettingsClickEvent;
import cc.pogoda.mobile.meteosystem.config.AppConfiguration;
import cc.pogoda.mobile.meteosystem.file.CopyLog;
+import cc.pogoda.mobile.meteosystem.type.ThemeColours;
public class MainActivity extends AppCompatActivity {
@@ -93,6 +98,42 @@ public class MainActivity extends AppCompatActivity {
settingsButton.setOnClickListener(
new MainActImageButtonSettingsClickEvent(this, main.getConfFile()));
+ ThemeColours colours = ((Main) getApplication()).getThemeColours();
+
+ TypedValue typedValue = new TypedValue();
+ Resources.Theme theme = getTheme();
+
+ //MaterialColors.getColor(, R.attr.colorOnPrimary);
+
+ theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
+ TypedArray arr = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimary});
+ colours.colorPrimary = arr.getColor(0, -1);
+ arr.recycle();
+
+ theme.resolveAttribute(R.attr.colorPrimaryVariant, typedValue, true);
+ arr = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimaryVariant});
+ colours.colorPrimaryVariant = arr.getColor(0, -1);
+ arr.recycle();
+
+ theme.resolveAttribute(R.attr.colorOnPrimary, typedValue, true);
+ arr = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorOnPrimary});
+ colours.colorOnPrimary = arr.getColor(0, -1);
+ arr.recycle();
+
+ theme.resolveAttribute(R.attr.colorSecondary, typedValue, true);
+ arr = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorSecondary});
+ colours.colorSecondary = arr.getColor(0, -1);
+ arr.recycle();
+
+ theme.resolveAttribute(R.attr.colorSecondaryVariant, typedValue, true);
+ arr = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorSecondaryVariant});
+ colours.colorSecondaryVariant = arr.getColor(0, -1);
+ arr.recycle();
+
+ theme.resolveAttribute(R.attr.colorOnSecondary, typedValue, true);
+ arr = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorOnSecondary});
+ colours.colorOnSecondary = arr.getColor(0, -1);
+ arr.recycle();
}
@Override
diff --git a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/StationDetailsSummaryActivity.java b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/StationDetailsSummaryActivity.java
index 657b090..12fa920 100644
--- a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/StationDetailsSummaryActivity.java
+++ b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/StationDetailsSummaryActivity.java
@@ -48,7 +48,7 @@ public class StationDetailsSummaryActivity extends AppCompatActivity {
elems = new StationSummaryActElements();
- int color = ContextCompat.getColor(this, android.R.color.secondary_text_light);
+ int color = main.getThemeColours().colorOnSecondary;
Summary summary = null;
SummaryDao summary_dao = new SummaryDao();
diff --git a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/StationDetailsWindRoseActivity.java b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/StationDetailsWindRoseActivity.java
index ca65410..a5b0a9a 100644
--- a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/StationDetailsWindRoseActivity.java
+++ b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/StationDetailsWindRoseActivity.java
@@ -2,6 +2,7 @@ package cc.pogoda.mobile.meteosystem.activity;
import androidx.appcompat.app.AppCompatActivity;
+import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
@@ -60,6 +61,8 @@ public class StationDetailsWindRoseActivity extends AppCompatActivity {
elements.maxGust = findViewById(R.id.textViewWindRoseMaxHourGust);
elements.minAverage = findViewById(R.id.textViewWindRoseMinHourSpeed);
elements.pressure = findViewById(R.id.textViewWindRosePressure);
+ elements.goodColor = ((Main) getApplication()).getThemeColours().colorOnSecondary;
+ elements.badColor = Color.RED;
elements.setActivity(this);
// create the handler which will update the screen in background
@@ -67,12 +70,6 @@ public class StationDetailsWindRoseActivity extends AppCompatActivity {
SummaryDao summary_dao = new SummaryDao();
-// // get the set of current values to preconfigure all elements on this activity
-// summary = summary_dao.getStationSummary(station.getSystemName());
-//
-// // update parameters (like turn the wind direction arrow)
-// elements.updateFromSummary(summary, station.getAvailableParameters());
-
handler = new Handler();
// check if this station is on favourites list
diff --git a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/updater/FavouritesStationDetailsOnListUpdater.java b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/updater/FavouritesStationDetailsOnListUpdater.java
index 1694730..0cedf8a 100644
--- a/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/updater/FavouritesStationDetailsOnListUpdater.java
+++ b/app/src/main/java/cc/pogoda/mobile/meteosystem/activity/updater/FavouritesStationDetailsOnListUpdater.java
@@ -18,6 +18,7 @@ import java.util.Vector;
import cc.pogoda.mobile.meteosystem.activity.updater.thread.FavouritesStationSummaryUpdaterThread;
import cc.pogoda.mobile.meteosystem.dao.AvailableParametersDao;
import cc.pogoda.mobile.meteosystem.type.AvailableParameters;
+import cc.pogoda.mobile.meteosystem.type.ThemeColours;
import cc.pogoda.mobile.meteosystem.type.web.AvailableParametersWeb;
import cc.pogoda.mobile.meteosystem.type.web.QualityFactor;
import cc.pogoda.mobile.meteosystem.type.web.Summary;
@@ -56,11 +57,17 @@ public class FavouritesStationDetailsOnListUpdater implements Runnable {
*/
private boolean enabled;
- public FavouritesStationDetailsOnListUpdater(Handler _handler, HashMap _station_system_name_to_summary, HashMap _avail_params) {
+ /**
+ * Used everywhere, where a colour of any element is set programatically (not globally from the theme)
+ */
+ private ThemeColours themeColours;
+
+ public FavouritesStationDetailsOnListUpdater(Handler _handler, HashMap _station_system_name_to_summary, HashMap _avail_params, ThemeColours _themeColours) {
handler = _handler;
stationsToUpdate = new HashMap<>();
availParams = _avail_params;
stationNameSummary = _station_system_name_to_summary;
+ themeColours = _themeColours;
}
public boolean isEnabled() {
@@ -139,7 +146,7 @@ public class FavouritesStationDetailsOnListUpdater implements Runnable {
toUpdate.setTextColor(Color.RED);
}
else {
- toUpdate.setTextColor(androidx.activity.R.color.secondary_text_default_material_light);
+ toUpdate.setTextColor(themeColours.colorPrimary);
}
}
else {
diff --git a/app/src/main/java/cc/pogoda/mobile/meteosystem/adapter/WeatherStationRecyclerViewAdapter.java b/app/src/main/java/cc/pogoda/mobile/meteosystem/adapter/WeatherStationRecyclerViewAdapter.java
index f1a0c4c..d151758 100644
--- a/app/src/main/java/cc/pogoda/mobile/meteosystem/adapter/WeatherStationRecyclerViewAdapter.java
+++ b/app/src/main/java/cc/pogoda/mobile/meteosystem/adapter/WeatherStationRecyclerViewAdapter.java
@@ -163,7 +163,11 @@ public class WeatherStationRecyclerViewAdapter extends RecyclerView.Adapter
\ No newline at end of file