9 Commits
Author SHA1 Message Date
handte a175a98236 Release 1.0.17
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-10 22:29:07 +02:00
handte 1f619a93db Immediately update widgets on configuration change.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-10 22:15:01 +02:00
handte 9f596c4f2c Fix terms fragement navigation no available in core graph.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-08 13:48:10 +02:00
handte e3105027ae Update to 1.0.17-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-05 12:08:02 +02:00
handte 955230f233 Release 1.0.16
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-04 15:12:50 +02:00
handte c56a601e5c Fix shadow and update preview image.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-04 15:01:54 +02:00
handte 107cff1f86 Improved widget layout, fix refresh timings.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-04 13:29:56 +02:00
handte 89fbc26dd2 Fix null pointer on slow connections.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-03 20:52:23 +02:00
handte 58e5c45ef0 Update to 1.0.16-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-06-03 19:59:40 +02:00
22 changed files with 97 additions and 33 deletions
+1 -1
View File
@@ -89,7 +89,7 @@ android {
applicationId "com.mowesta.android.app"
minSdkVersion 19
targetSdkVersion 29
versionCode 15
versionCode 17
versionName "${version}"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -19,6 +19,9 @@ import com.mowesta.android.app.repository.DeviceRepository;
import com.mowesta.android.app.repository.FavoriteRepository;
import com.mowesta.android.app.repository.UserRepository;
import com.mowesta.android.app.repository.WidgetRepository;
import com.mowesta.android.app.widget.AbstractWidgetProvider;
import com.mowesta.android.app.widget.ForecastWidgetProvider;
import com.mowesta.android.app.widget.MeasureWidgetProvider;
import com.mowesta.android.app.widget.WidgetReceiver;
import java.io.File;
@@ -31,6 +34,13 @@ import java.io.File;
*/
public class MowestaApp extends Application implements IApp {
/**
* The widget providers of the app.
*/
private AbstractWidgetProvider[] widgetProviders = {
new ForecastWidgetProvider(),
new MeasureWidgetProvider()
};
/**
* The user repository.
@@ -81,7 +91,9 @@ public class MowestaApp extends Application implements IApp {
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
WidgetReceiver.updateWidgets(this);
for (int i = widgetProviders.length - 1; i >= 0; i--) {
widgetProviders[i].triggerUpdates(this, false);
}
}
@Override
@@ -123,7 +123,7 @@ public class ForecastWidgetFragment extends AbstractNetworkFragment {
return w;
}, (input, result) -> {
ForecastWidgetProvider provider = new ForecastWidgetProvider();
provider.triggerUpdate(app, input);
provider.triggerUpdate(app, input, true);
if (!activity.isDestroyed()) {
activity.finish();
}
@@ -197,7 +197,7 @@ public class MeasureWidgetFragment extends AbstractNetworkFragment {
return w;
}, (input, result) -> {
MeasureWidgetProvider provider = new MeasureWidgetProvider();
provider.triggerUpdate(app, input);
provider.triggerUpdate(app, input, true);
if (!activity.isDestroyed()) {
activity.finish();
}
@@ -334,7 +334,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
setClickListener(KEY_ABOUT_TERMS, new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Navigation.findNavController(getActivity(), R.id.navigation_app).navigate(R.id.destination_terms);
Navigation.findNavController(getActivity(), R.id.navigation_app).navigate(R.id.destination_review);
return false;
}
});
@@ -396,9 +396,9 @@ public class CityViewModel extends AbstractPlaceViewModel {
*/
private void updateVideos() {
if (city.getValue() == null || videos.getValue() == null) {
iconEurope.setValue(null);
iconGlobal.setValue(null);
cosmoEurope.setValue(null);
iconEurope.setValue(new ArrayList<>());
iconGlobal.setValue(new ArrayList<>());
cosmoEurope.setValue(new ArrayList<>());
} else {
List<VideoViewModel> ieu = new ArrayList<>();
List<VideoViewModel> igl = new ArrayList<>();
@@ -2,6 +2,7 @@ package com.mowesta.android.app.widget;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
@@ -60,7 +61,7 @@ public abstract class AbstractWidgetProvider extends AppWidgetProvider {
super.onUpdate(context, appWidgetManager, appWidgetIds);
Log.d(TAG, "Updating widget data for " + Arrays.toString(appWidgetIds));
for (int i = 0; i < appWidgetIds.length; i++) {
triggerUpdate(context, appWidgetIds[i]);
triggerUpdate(context, appWidgetIds[i], true);
}
}
@@ -68,7 +69,7 @@ public abstract class AbstractWidgetProvider extends AppWidgetProvider {
public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
super.onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions);
Log.d(TAG, "Updating widget data for " + appWidgetId + " due to change.");
triggerUpdate(context, appWidgetId);
triggerUpdate(context, appWidgetId, false);
}
@Override
@@ -128,16 +129,19 @@ public abstract class AbstractWidgetProvider extends AppWidgetProvider {
* Triggers the widget service to perform an update.
*
* @param context The context.
* @param schedule Determines whether we also perform a background update.
* @param id The id.
*/
public void triggerUpdate(Context context, int id) {
WidgetService.scheduleUpdate(context, type, id);
public void triggerUpdate(Context context, int id, boolean schedule) {
if (schedule) WidgetService.scheduleUpdate(context, type, id);
Log.d(TAG, "Start database query for widget " + id + ".");
DatabaseTask<WidgetDatabase, Integer, Widget> task = new DatabaseTask<WidgetDatabase, Integer, Widget>((input, database)-> {
List<Widget> widgets = database.getAccessor().get(type, input);
if (widgets.isEmpty()) return null;
else return widgets.get(0);
}, (input, widget)-> {
if (widget != null) {
Log.d(TAG, "Finish database query for widget " + input + ".");
updateWidget(context, widget);
}
});
@@ -160,6 +164,7 @@ public abstract class AbstractWidgetProvider extends AppWidgetProvider {
int maxWidth = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, 0);
int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, 0);
int maxHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, 0);
Log.d(TAG, String.format("Widget %d: Width(%d-%d) Height(%d-%d)", id, minWidth, maxWidth, minHeight, maxHeight));
if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
return new int[] { minWidth, maxHeight };
} else {
@@ -178,5 +183,20 @@ public abstract class AbstractWidgetProvider extends AppWidgetProvider {
public abstract void updateWidget(Context context, Widget widget);
/**
* Updates all widgets of the provider.
*
* @param context The context.
* @param schedule True to also schedule a background update.
* @return True if any update has been scheduled.
*/
public boolean triggerUpdates(Context context, boolean schedule) {
AppWidgetManager manager = AppWidgetManager.getInstance(context);
int[] ids = manager.getAppWidgetIds(new ComponentName(context, getClass()));
for (int id: ids) {
triggerUpdate(context, id, schedule);
}
return ids.length > 0;
}
}
@@ -58,7 +58,7 @@ public class ForecastWidgetProvider extends AbstractWidgetProvider {
/**
* The space to allocate for a single day view.
*/
private static final int WIDTH_DAY = 80;
private static final int WIDTH_DAY = 75;
/**
* The width for borders around the day views.
@@ -121,10 +121,12 @@ public class ForecastWidgetProvider extends AbstractWidgetProvider {
views.setViewVisibility(R.id.widget_container_text, width < (BREAK_HORIZONTAL_2 * scale) ? View.GONE : View.VISIBLE);
views.removeAllViews(R.id.widget_container_days);
int count = Math.min(days.size(), (int)((width - WIDTH_BORDER) / (WIDTH_DAY * scale)));
if (height > (BREAK_VERTICAL * scale) && count > 1) {
if (height > (BREAK_VERTICAL * scale) && count > 0) {
views.addView(R.id.widget_container_days, new RemoteViews(context.getPackageName(), R.layout.widget_forecast_spacer));
for (int i = 0; i < count; i++) {
RemoteViews day = createDayView(context, days.get(i), unit);
views.addView(R.id.widget_container_days, day);
views.addView(R.id.widget_container_days, new RemoteViews(context.getPackageName(), R.layout.widget_forecast_spacer));
}
}
MowestaSettings settings = new MowestaSettings((Application) context.getApplicationContext());
@@ -13,7 +13,10 @@ import android.util.Log;
import com.mowesta.android.app.database.Widget;
/**
* The receiver that will
* The receiver that is called periodically by the alarm
* manager to perform widget updates every x minutes.
*
* @author Marcus
*/
public class WidgetReceiver extends BroadcastReceiver {
@@ -90,7 +93,7 @@ public class WidgetReceiver extends BroadcastReceiver {
*/
private static PendingIntent createIntent(Context context) {
Intent intent = new Intent(context, WidgetReceiver.class);
return PendingIntent.getBroadcast(context, 2298, intent, PendingIntent.FLAG_UPDATE_CURRENT);
return PendingIntent.getBroadcast(context, REQuEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
/**
@@ -73,6 +73,7 @@ public class WidgetService extends JobIntentService {
* @param type The widget type.
*/
public static void scheduleUpdate(Context context, int type, int reference) {
Log.d(TAG, "Schedule background update for widget " + reference + " type " + type + ".");
Intent intent = new Intent();
intent.setClass(context, JobIntentService.class);
intent.putExtra(EXTRA_WIDGET_TYPE, type);
@@ -103,13 +104,13 @@ public class WidgetService extends JobIntentService {
long time = System.currentTimeMillis();
City[] city = new City[] { widget.getData(City.class) };
long[] dataTime = new long[] { widget.getDataTime() };
if (city[0] == null || dataTime[0] - time > DELAY_DATA) {
if (city[0] == null || time - dataTime[0] > DELAY_DATA) {
city[0] = api.getCity(widget.getDataId());
dataTime[0] = time;
}
WeatherForecast[] content = new WeatherForecast[] { widget.getContent(WeatherForecast.class) };
long[] contentTime = new long[] { widget.getContentTime() };
if (content[0] == null || contentTime[0] - time > DELAY_CONTENT) {
if (content[0] == null || time - contentTime[0] > DELAY_CONTENT) {
content[0] = api.getCityForecast(widget.getDataId());
contentTime[0] = time;
}
@@ -138,13 +139,13 @@ public class WidgetService extends JobIntentService {
long time = System.currentTimeMillis();
Device[] device = new Device[] { widget.getData(Device.class) };
long[] dataTime = new long[] { widget.getDataTime() };
if (device[0] == null || dataTime[0] - time > DELAY_DATA) {
if (device[0] == null || time - dataTime[0] > DELAY_DATA) {
device[0] = api.getDevice(widget.getDataId());
dataTime[0] = time;
}
Measurement[] content = new Measurement[] { widget.getContent(Measurement.class) };
long[] contentTime = new long[] { widget.getContentTime() };
if (content[0] == null || contentTime[0] - time > DELAY_CONTENT) {
if (content[0] == null || time - contentTime[0] > DELAY_CONTENT) {
MeasurementPage page = api.getDeviceMeasurements(widget.getDataId(), 0l, time, 0, 1);
if (page.getElements().size() > 0) {
content[0] = page.getElements().get(0);
Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 37 KiB

@@ -5,7 +5,7 @@
android:id="@+id/widget_forecast"
android:orientation="vertical"
android:gravity="center_vertical"
tools:layout_width="260dp"
tools:layout_width="match_parent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
@@ -14,18 +14,20 @@
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/widget_forecast_spacer"/>
<LinearLayout
android:id="@+id/widget_container_condition"
android:orientation="horizontal"
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/widget_condition_temperature"
android:layout_gravity="center_vertical"
android:textColor="@color/white"
android:textSize="28sp"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:paddingBottom="4dp"
android:shadowColor="@color/black"
android:shadowDx="1"
@@ -71,12 +73,13 @@
android:id="@+id/widget_container_text"
android:visibility="visible"
android:orientation="vertical"
android:gravity="center"
android:layout_weight="1"
android:layout_width="0dp"
android:gravity="start"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/widget_location_name"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textColor="@color/white"
android:shadowColor="@color/black"
android:textStyle="bold"
@@ -91,6 +94,8 @@
tools:text="Bergheim (Troisdorf)"/>
<TextView
android:id="@+id/widget_condition_text"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textColor="@color/white"
android:textStyle="bold"
android:shadowColor="@color/black"
@@ -104,7 +109,7 @@
android:maxLines="1"
tools:text="Überwiegend Sonnig"/>
</LinearLayout>
<include layout="@layout/widget_forecast_spacer"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="8dp"
@@ -2,13 +2,10 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:layout_width="90dp"
tools:layout_height="36dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:gravity="left"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
@@ -49,6 +46,8 @@
android:textColor="@color/white"
android:shadowColor="@color/black"
android:shadowRadius="3"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textStyle="bold"
android:shadowDx="1"
android:shadowDy="1"
@@ -61,6 +60,8 @@
<TextView
android:id="@+id/widget_day_temperature"
android:textColor="@color/white"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textStyle="bold"
android:shadowColor="@color/black"
android:shadowDx="1"
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="false"
android:orientation="horizontal"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="0dp">
</LinearLayout>
@@ -64,6 +64,8 @@
android:layout_height="wrap_content"
android:textColor="@color/white"
android:shadowColor="@color/black"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textStyle="bold"
android:shadowRadius="3"
android:shadowDx="1"
@@ -79,6 +81,8 @@
android:layout_height="wrap_content"
android:textColor="@color/white"
android:shadowColor="@color/black"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textStyle="bold"
android:shadowRadius="3"
android:shadowDx="1"
@@ -52,6 +52,8 @@
android:layout_gravity="center_vertical"
android:textColor="@color/white"
android:shadowColor="@color/black"
android:paddingStart="1dp"
android:paddingEnd="1dp"
android:textStyle="bold"
android:shadowRadius="3"
android:shadowDx="1"
@@ -77,6 +77,11 @@
android:id="@+id/destination_connect"
tools:layout="@layout/fragment_connect"
android:name="com.mowesta.android.app.fragment.ConnectFragment" />
<fragment
android:id="@+id/destination_review"
android:name="com.mowesta.android.app.fragment.TermsFragment"
android:label="@string/navigation_terms"
android:layout="@layout/fragment_terms" />
<include app:graph="@navigation/navigation_drawer" />
<action
android:id="@+id/action_drawer"
+1 -1
View File
@@ -24,7 +24,7 @@ allprojects {
// set version for our project
group = 'com.mowesta'
version = '1.0.15'
version = '1.0.17'
// set versions for our libraries
ext {
@@ -73,7 +73,7 @@ public class WeatherSessionBean extends AbstractPrincipalSessionBean {
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public WeatherForecast getForecast(Coordinate location) {
SearchManager manager = Search.getSearchManager(infinispanSession.getDataCache());
List<WeatherForecastContainer> containers = WeatherForecastContainer.findByLocation(manager, location, 10);
List<WeatherForecastContainer> containers = WeatherForecastContainer.findByLocation(manager, location, 20);
// compute the map of forecasts (distance is considered since list is ordered)
Map<WeatherSource, WeatherForecast> forecasts = new HashMap<>();
for (int i = containers.size() - 1; i >= 0; i--) {