Finalize first version of mobile app.
LocationBasedServices/mowesta/pipeline/head This commit looks good

Implement deletion, customization.
Improve diagram views.
Various sdk and app fixes.
Expose body parameter in api to generate working proxies.
Remove more unused code.
This commit is contained in:
Marcus Handte
2020-06-09 21:59:07 +02:00
parent 6f191124b9
commit cfce90108a
67 changed files with 1632 additions and 180 deletions
-1
View File
@@ -25,7 +25,6 @@ ext {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(":android-feign")
implementation project(":android-sdk")
implementation "javax.xml.bind:jaxb-api:${versionJaxb}"
+21
View File
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -15,6 +15,11 @@ import androidx.core.app.ActivityCompat;
import androidx.core.content.PermissionChecker;
import androidx.preference.PreferenceManager;
import com.mowesta.android.app.database.FavoriteDatabase;
import com.mowesta.android.app.repository.UserCredentials;
import com.mowesta.android.app.task.DatabaseTask;
import com.mowesta.android.app.task.RefreshTask;
import com.mowesta.android.app.task.SyncTask;
import com.mowesta.android.app.util.PermissionUtil;
import java.io.File;
@@ -34,6 +39,11 @@ public class MowestaActivity extends AppCompatActivity {
*/
public static String TAG = "MowestaActivity";
/**
* One hour in milliseconds.
*/
private static final int ONE_HOUR = 60*60*1000;
/**
* The code used to request the permissions.
*/
@@ -44,6 +54,32 @@ public class MowestaActivity extends AppCompatActivity {
*/
private MowestaSettings settings;
/**
* The application.
*/
private IApp app;
/**
* The task that determines whether we should automatically refresh or update
* the database.
*/
protected DatabaseTask<FavoriteDatabase, Void, Long> favoriteTask = new DatabaseTask<>(
(input, database) -> database.getAccessor().getUpdateTime(),
(input, result) -> {
if (result != null && result < System.currentTimeMillis() - ONE_HOUR) {
Log.d(TAG, "Starting automatic favorite synchronization.");
UserCredentials c = app.getUserRepository().getCredentials().getValue();
FavoriteDatabase db = app.getFavoriteRepository().getDatabase();
if (c != null) new SyncTask(db, null).execute(app.getClientFactory().createClient(c));
new RefreshTask(db, null).execute(app.getClientFactory().createClient());
} else {
Log.d(TAG, "Ignoring request for favorite synchronization since data is up-to-date.");
}
}
);
/**
* The listener that observes the activation of the mowesta sdk service
* and checks for the permissions.
@@ -63,6 +99,8 @@ public class MowestaActivity extends AppCompatActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = (IApp) getApplication();
favoriteTask.execute(null, app.getFavoriteRepository().getDatabase());
settings = new MowestaSettings(getApplication());
setContentView(R.layout.activity_app);
installHttpCache();
@@ -5,11 +5,13 @@ import android.content.Context;
import android.content.SharedPreferences;
import androidx.preference.PreferenceManager;
import com.mowesta.android.app.database.FavoriteDatabase;
import com.mowesta.android.app.repository.ClientFactory;
import com.mowesta.android.app.repository.DeviceRepository;
import com.mowesta.android.app.repository.FavoriteRepository;
import com.mowesta.android.app.repository.UserCredentials;
import com.mowesta.android.app.repository.UserRepository;
import com.mowesta.android.app.task.DatabaseTask;
/**
* Te main application of the application that is used
@@ -19,6 +21,7 @@ import com.mowesta.android.app.repository.UserRepository;
*/
public class MowestaApp extends Application implements IApp {
/**
* The user repository.
*/
@@ -38,8 +41,8 @@ public class MowestaApp extends Application implements IApp {
@Override
public void onCreate() {
super.onCreate();
userRepository = new UserRepository.Builder().build(this);
deviceRepository = new DeviceRepository.Builder().build(this);
userRepository = new UserRepository.Builder().setTrace(false).build(this);
deviceRepository = new DeviceRepository.Builder().setTrace(false).build(this);
favoriteRepository = new FavoriteRepository(this);
MowestaService.startService(this);
}
@@ -6,6 +6,7 @@ import android.content.SharedPreferences;
import android.content.res.Resources;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import androidx.preference.PreferenceManager;
import com.mowesta.android.sdk.SdkSettings;
@@ -35,6 +36,42 @@ public class MowestaSettings extends SdkSettings {
*/
public static final String COLLECTION_SHOWN = "collection_shown";
/**
* The key to a boolean to store whether the diagram will use
* celsius (true) or fahrenheit (false).
*/
public static final String TEMPERATURE_CELSIUS = "temperature_celsius";
/**
* The key to a boolean to show/hide the precipitation.
*/
public static final String SHOW_PRECIPITATION = "show_precipitation";
/**
* The key to a boolean to show/hide the wind speed and direction.
*/
public static final String SHOW_WIND = "show_wind";
/**
* The key to a boolean to show/hide the cloud coverage.
*/
public static final String SHOW_CLOUD = "show_cloud";
/**
* The key to a boolean to show/hide the humidty.
*/
public static final String SHOW_HUMIDITY = "show_humidity";
/**
* The key to a boolean to show/hide the snow depth.
*/
public static final String SHOW_SNOW = "show_snow";
/**
* The key to a boolean to show/hide the pressure.
*/
public static final String SHOW_PRESSURE = "show_pressure";
/**
* Creates the settings with the context.
*
@@ -130,5 +167,168 @@ public class MowestaSettings extends SdkSettings {
}
/**
* Determines whether the diagram uses celsius or fahrenheit.
*
* @return True if the diagram uses celsius, false if fahrenheit
*/
public boolean isTemperatureCelsius() {
boolean defaultValue = getResources().getBoolean(R.bool.temperature_celsius_default);
return preferences.getBoolean(TEMPERATURE_CELSIUS, defaultValue);
}
/**
* Sets the boolean to indicate whether the diagram uses fahrenheit
* or celsius.
*
* @param value The value.
*/
public void setTemperatureCelsius(boolean value) {
SharedPreferences.Editor e = preferences.edit();
e.putBoolean(TEMPERATURE_CELSIUS, value);
e.apply();
}
/**
* Determines whether the temperature is in celsisus or fahrenheit without object allocation.
*
* @param context The context.
* @return True if temperature is in celsius.
*/
public static boolean isTemperatureCelsisus(@NonNull Context context) {
boolean defaultValue = context.getResources().getBoolean(R.bool.temperature_celsius_default);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
return preferences.getBoolean(TEMPERATURE_CELSIUS, defaultValue);
}
/**
* Determines whether the cloud coverage is shown.
*
* @return True to show, false to hide.
*/
public boolean isShowCloud() {
boolean defaultValue = getResources().getBoolean(R.bool.show_cloud_default);
return preferences.getBoolean(SHOW_CLOUD, defaultValue);
}
/**
* Sets the boolean to determine whether the cloud coverage is shown.
*
* @param value True to show, false to hide.
*/
public void setShowCloud(boolean value) {
SharedPreferences.Editor e = preferences.edit();
e.putBoolean(SHOW_CLOUD, value);
e.apply();
}
/**
* Determines whether the humidity is shown.
*
* @return True to show, false to hide.
*/
public boolean isShowHumidity() {
boolean defaultValue = getResources().getBoolean(R.bool.show_humidity_default);
return preferences.getBoolean(SHOW_HUMIDITY, defaultValue);
}
/**
* Sets the boolean to determine whether the humidity is shown.
*
* @param value True to show, false to hide.
*/
public void setShowHumidity(boolean value) {
SharedPreferences.Editor e = preferences.edit();
e.putBoolean(SHOW_HUMIDITY, value);
e.apply();
}
/**
* Determines whether the pressure is shown.
*
* @return True to show, false to hide.
*/
public boolean isShowPressure() {
boolean defaultValue = getResources().getBoolean(R.bool.show_pressure_default);
return preferences.getBoolean(SHOW_PRESSURE, defaultValue);
}
/**
* Sets the boolean to determine whether the pressure is shown.
*
* @param value True to show, false to hide.
*/
public void setShowPressure(boolean value) {
SharedPreferences.Editor e = preferences.edit();
e.putBoolean(SHOW_PRESSURE, value);
e.apply();
}
/**
* Determines whether the precipitation is shown.
*
* @return True to show, false to hide.
*/
public boolean isShowPrecipitation() {
boolean defaultValue = getResources().getBoolean(R.bool.show_precipitation_default);
return preferences.getBoolean(SHOW_PRECIPITATION, defaultValue);
}
/**
* Sets the boolean to determine whether the precipitation is shown.
*
* @param value True to show, false to hide.
*/
public void setShowPrecipitation(boolean value) {
SharedPreferences.Editor e = preferences.edit();
e.putBoolean(SHOW_PRECIPITATION, value);
e.apply();
}
/**
* Determines whether the wind is shown.
*
* @return True to show, false to hide.
*/
public boolean isShowWind() {
boolean defaultValue = getResources().getBoolean(R.bool.show_wind_default);
return preferences.getBoolean(SHOW_WIND, defaultValue);
}
/**
* Sets the boolean to determine whether the wind is shown.
*
* @param value True to show, false to hide.
*/
public void setShowWind(boolean value) {
SharedPreferences.Editor e = preferences.edit();
e.putBoolean(SHOW_WIND, value);
e.apply();
}
/**
* Determines whether the snow depth is shown.
*
* @return True to show, false to hide.
*/
public boolean isShowSnow() {
boolean defaultValue = getResources().getBoolean(R.bool.show_snow_default);
return preferences.getBoolean(SHOW_SNOW, defaultValue);
}
/**
* Sets the boolean to determine whether the snow depth is shown.
*
* @param value True to show, false to hide.
*/
public void setShowSnow(boolean value) {
SharedPreferences.Editor e = preferences.edit();
e.putBoolean(SHOW_SNOW, value);
e.apply();
}
}
@@ -0,0 +1,85 @@
package com.mowesta.android.app.adapter;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
/**
* A live data object for boolean preferences that automatically
* handles the subscription based on the observer count.
*
* @author Marcus
*/
public class PreferenceLiveData extends MutableLiveData<Boolean> {
/**
* The key.
*/
private String key;
/**
* The default value.
*/
private boolean defaultValue;
/**
* The preferences to attach to.
*/
private SharedPreferences preferences;
/**
* The listener to track changes to the value.
*/
private SharedPreferences.OnSharedPreferenceChangeListener listener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String k) {
if (key.equals(k)) {
boolean newValue = sharedPreferences.getBoolean(key, defaultValue);
if (newValue != getValue()) {
setValue(newValue);
}
}
}
};
/**
* Creates a new preference live data object for the shared preferences
* using the key assuming that it stores boolean values and the default
* value.
*
* @param preferences The preferences.
* @param key The key.
* @param defaultValue The default value.
*/
public PreferenceLiveData(@NonNull SharedPreferences preferences, @NonNull String key, boolean defaultValue) {
this.key = key;
this.preferences = preferences;
this.defaultValue = defaultValue;
}
@Override
public void setValue(Boolean value) {
super.setValue(value);
if (value != preferences.getBoolean(key, defaultValue)) {
SharedPreferences.Editor e = preferences.edit();
e.putBoolean(key, value);
e.apply();
}
}
@Override
protected void onActive() {
super.onActive();
preferences.registerOnSharedPreferenceChangeListener(listener);
setValue(preferences.getBoolean(key, defaultValue));
}
@Override
protected void onInactive() {
super.onInactive();
preferences.unregisterOnSharedPreferenceChangeListener(listener);
}
}
@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.TypeConverters;
import com.fasterxml.jackson.databind.MapperFeature;
@@ -31,7 +32,12 @@ import java.io.IOException;
*
* @author Marcus
*/
@Entity(primaryKeys = { "type", "id" }, tableName = "favorite")
@Entity(primaryKeys = { "type", "id" }, tableName = "favorite", indices = {
@Index({"weatherTime", "deleted"}),
@Index({"locationTime", "deleted"}),
@Index({"deleted", "position"}),
@Index({"added", "deleted"})
})
public class Favorite {
/**
@@ -27,6 +27,16 @@ public interface FavoriteAccessor {
@Query("select * from favorite where not deleted order by position")
LiveData<List<Favorite>> getActive();
/**
* returns the oldest entry in the database to determine whether
* an automatic refresh is necessary.
*
* @return The minimum time.
*/
@Query("select min(locationTime, weatherTime) from favorite where not deleted")
Long getUpdateTime();
/**
* Returns all favorites ordered by their position.
*
@@ -71,7 +81,7 @@ public interface FavoriteAccessor {
/**
* Returns the number of local favorites that
* defintively require synchronization.
* definitively require synchronization.
*
* @return The number of local favorites to sync.
*/
@@ -82,6 +92,6 @@ public interface FavoriteAccessor {
* Deletes all favorites from the database.
*/
@Query("delete from favorite")
void resetAll();
void clearAll();
}
@@ -10,7 +10,7 @@ import androidx.room.RoomDatabase;
* is used as a cache to ensure that the locations can
* be accessed offline.
*/
@Database(entities = { Favorite.class }, version = 2, exportSchema = false)
@Database(entities = { Favorite.class }, version = 3, exportSchema = false)
public abstract class FavoriteDatabase extends RoomDatabase {
/**
@@ -0,0 +1,89 @@
package com.mowesta.android.app.fragment;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.mowesta.android.app.MowestaSettings;
import com.mowesta.android.app.R;
/**
* A fragment that extends the network fragment with an additional
* menu to handle the diagram.
*
* @author Marcus
*/
public abstract class AbstractDiagramFragment extends AbstractNetworkFragment {
/**
* The settings to read the state of the unit.
*/
private MowestaSettings settings;
/**
* A preference listener that is running as long as we are resumed.
*/
private SharedPreferences.OnSharedPreferenceChangeListener unitListener = (prefs, key) -> {
if (MowestaSettings.TEMPERATURE_CELSIUS.equals(key)) onUnitChanged();
};
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
settings = new MowestaSettings(getActivity().getApplication());
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onResume() {
super.onResume();
settings.getPreferences().registerOnSharedPreferenceChangeListener(unitListener);
onUnitChanged();
}
@Override
public void onPause() {
super.onPause();
settings.getPreferences().unregisterOnSharedPreferenceChangeListener(unitListener);
}
/**
* Called whenever the unit changes. Subclasses may overwrite this,
* but should call through to super.
*/
public void onUnitChanged() {
getActivity().invalidateOptionsMenu();
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_unit, menu);
boolean celsius = settings.isTemperatureCelsius();
menu.findItem(R.id.unit_celsius).setVisible(celsius);
menu.findItem(R.id.unit_fahrenheit).setVisible(!celsius);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.unit_fahrenheit:
settings.setTemperatureCelsius(true);
return true;
case R.id.unit_celsius:
settings.setTemperatureCelsius(false);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
@@ -2,6 +2,9 @@ package com.mowesta.android.app.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@@ -2,6 +2,9 @@ package com.mowesta.android.app.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@@ -68,6 +71,32 @@ public class CityFragment extends AbstractPlaceFragment {
return getView().findViewById(R.id.bottom_navigation);
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_customize, menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_customize:
getChildFragmentManager()
.beginTransaction()
.add(new CustomizeDialogFragment(), "customize")
.commit();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -98,4 +127,6 @@ public class CityFragment extends AbstractPlaceFragment {
NavigationUI.setupWithNavController(layout, toolbar, controller, builder.build());
return root;
}
}
@@ -25,6 +25,7 @@ import com.mowesta.android.feign.model.City;
import com.mowesta.android.feign.model.Country;
import com.mowesta.android.feign.model.State;
import com.mowesta.android.feign.model.WeatherCondition;
import com.mowesta.android.feign.model.WeatherStation;
import java.util.ArrayList;
import java.util.List;
@@ -76,6 +77,17 @@ public class CityInfoFragment extends CityFragment.ChildFragment {
model.getBoundary().observe(getViewLifecycleOwner(), (b) -> updateMap.run());
binding.setModel(model);
binding.setCondition(condition);
NavController controller = Navigation.findNavController(getActivity(), R.id.navigation_app);
binding.setStationListener(new CityViewModel.OnStationSelectedListener() {
@Override
public void onStationSelected(WeatherStation station) {
// go to the station fragment
NavOptions.Builder opts = new NavOptions.Builder().setEnterAnim(R.anim.slide_in_right).setExitAnim(R.anim.slide_out_left);
Bundle bundle = new Bundle();
bundle.putLong("id", station.getId());
controller.navigate(R.id.destination_station, bundle, opts.build());
}
});
binding.setLifecycleOwner(getViewLifecycleOwner());
return binding.getRoot();
}
@@ -0,0 +1,36 @@
package com.mowesta.android.app.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.mowesta.android.app.R;
import com.mowesta.android.app.databinding.DialogCustomizeBinding;
import com.mowesta.android.app.model.CustomizeViewModel;
/**
* A bottom sheet dialog that enables the user to customize the weather data.
*
* @author Marcus
*/
public class CustomizeDialogFragment extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
DialogCustomizeBinding binding = DataBindingUtil.inflate(inflater, R.layout.dialog_customize, container, false);
CustomizeViewModel model = new ViewModelProvider(this).get(CustomizeViewModel.class);
binding.setModel(model);
binding.setLifecycleOwner(getViewLifecycleOwner());
binding.setCloseListener(() -> { this.dismiss(); });
return binding.getRoot();
}
}
@@ -7,6 +7,7 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
@@ -34,7 +35,7 @@ import com.mowesta.android.feign.model.Measurement;
*
* @author Marcus
*/
public class DeviceFragment extends AbstractNetworkFragment {
public class DeviceFragment extends AbstractDiagramFragment {
@Override
protected AbstractNetworkViewModel getNetworkViewModel() {
@@ -50,7 +51,7 @@ public class DeviceFragment extends AbstractNetworkFragment {
View root = binding.getRoot();
CollapsingToolbarLayout layout = root.findViewById(R.id.layout_toolbar);
Toolbar toolbar = root.findViewById(R.id.toolbar);
MapView mapView = root.findViewById(R.id.map);
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
model.getDevice().observe(getViewLifecycleOwner(), (device)-> {
String title = "";
if (device != null) {
@@ -100,4 +101,10 @@ public class DeviceFragment extends AbstractNetworkFragment {
recyclerView.setAdapter(adapter);
}
@Override
public void onUnitChanged() {
super.onUnitChanged();
RecyclerView recyclerView = getView().findViewById(R.id.recycler);
recyclerView.getAdapter().notifyDataSetChanged();
}
}
@@ -76,6 +76,13 @@ public class FavoritesFragment extends Fragment {
}
}
}));
View layoutHelp = view.findViewById(R.id.favorites_help);
View layoutList = view.findViewById(R.id.favorites_list);
model.getFavorites().observe(getViewLifecycleOwner(), (list)-> {
boolean empty = (list == null || list.size() == 0);
layoutHelp.setVisibility(empty ? View.VISIBLE: View.GONE);
layoutList.setVisibility(empty ? View.GONE: View.VISIBLE);
});
}
@Override
@@ -7,11 +7,18 @@ import com.google.android.gms.oss.licenses.OssLicensesMenuActivity;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.mowesta.android.app.BuildConfig;
import com.mowesta.android.app.IApp;
import com.mowesta.android.app.MowestaApp;
import com.mowesta.android.app.MowestaService;
import com.mowesta.android.app.MowestaSettings;
import com.mowesta.android.app.R;
import com.mowesta.android.app.database.FavoriteDatabase;
import com.mowesta.android.app.repository.DeviceRepository;
import com.mowesta.android.app.task.DatabaseTask;
import com.mowesta.android.sdk.SdkRepository;
import com.mowesta.android.sdk.task.ClearTask;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
@@ -92,6 +99,11 @@ public class SettingsFragment extends PreferenceFragmentCompat {
*/
private static final String KEY_DEVELOPMENT_TOKEN = "development_token";
/**
* The key to clear the sdk cache.
*/
private static final String KEY_DEVELOPMENT_CLEAR_CACHE = "development_clear_cache";
/**
* The key for the notification preference category.
*/
@@ -146,6 +158,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
bindReset();
bindTerms();
bindLicenses();
bindSdkSettings();
return v;
}
@@ -309,6 +322,9 @@ public class SettingsFragment extends PreferenceFragmentCompat {
});
}
/**
* Binds the terms preference.
*/
private void bindTerms() {
setClickListener(KEY_ABOUT_TERMS, new Preference.OnPreferenceClickListener() {
@Override
@@ -319,7 +335,9 @@ public class SettingsFragment extends PreferenceFragmentCompat {
});
}
/**
* Binds the license preference.
*/
private void bindLicenses() {
setClickListener(KEY_ABOUT_LICENSES, new Preference.OnPreferenceClickListener() {
@Override
@@ -331,6 +349,21 @@ public class SettingsFragment extends PreferenceFragmentCompat {
});
}
/**
* Binds the sdk settings.
*/
private void bindSdkSettings() {
setClickListener(KEY_DEVELOPMENT_CLEAR_CACHE, new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new ClearTask(SdkRepository.getInstance(getActivity().getApplication()), false, () -> {
Toast.makeText(preference.getContext(), R.string.setting_development_clear_message, Toast.LENGTH_SHORT).show();
}).execute();
return false;
}
});
}
/**
* Enables the developmentGroup mode.
*/
@@ -397,9 +430,29 @@ public class SettingsFragment extends PreferenceFragmentCompat {
b.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//getRepository().user.setValue(null);
//getRepository().deviceHandle.setValue(null); // remove the device handle
getActivity().finish();
// stop the service and its background processing
Log.d(TAG, "Resetting the device.");
Activity activity = getActivity();
MowestaService.stopService(activity);
// reset the settings
MowestaApp app = (MowestaApp)activity.getApplication();
SdkRepository sdk = SdkRepository.getInstance(app);
MowestaSettings settings = new MowestaSettings(app);
settings.setPrivacyMeasure(false);
settings.setCollectionShown(false);
app.getUserRepository().clearCredentials();
app.getDeviceRepository().clearDevice();
new ClearTask(sdk, true, ()-> {
new DatabaseTask<FavoriteDatabase, Void, Void>
((input, database)-> {
Log.d(TAG, "Clearing database.");
database.getAccessor().clearAll();
return null;
},(input, result)-> {
Log.d(TAG, "Finishing the activity.");
activity.finish();
}).execute(null, app.getFavoriteRepository().getDatabase());
}).execute();
}
});
b.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@@ -1,13 +1,18 @@
package com.mowesta.android.app.fragment;
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
@@ -24,6 +29,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.locoslab.android.leafless.MapView;
import com.locoslab.android.leafless.marker.Marker;
import com.locoslab.library.geometry.wgs.Coordinate;
import com.mowesta.android.app.MowestaSettings;
import com.mowesta.android.app.R;
import com.mowesta.android.app.adapter.CityEntryPagedListAdapter;
import com.mowesta.android.app.adapter.DiagramEntryPagedListAdapter;
@@ -45,7 +51,7 @@ import com.mowesta.android.feign.model.WeatherStation;
*
* @author Marcus
*/
public class StationFragment extends AbstractNetworkFragment {
public class StationFragment extends AbstractDiagramFragment {
/**
* The marker displayed on the map.
@@ -71,6 +77,7 @@ public class StationFragment extends AbstractNetworkFragment {
View root = binding.getRoot();
CollapsingToolbarLayout layout = root.findViewById(R.id.layout_toolbar);
Toolbar toolbar = root.findViewById(R.id.toolbar);
((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
MapView mapView = root.findViewById(R.id.map);
MapViewUtil.setupNonInteractiveMap(mapView);
model.getStation().observe(getViewLifecycleOwner(), (station)-> {
@@ -161,6 +168,14 @@ public class StationFragment extends AbstractNetworkFragment {
(expanded?BottomSheetBehavior.STATE_EXPANDED:BottomSheetBehavior.STATE_COLLAPSED));
}
@Override
public void onUnitChanged() {
super.onUnitChanged();
RecyclerView recyclerView = getView().findViewById(R.id.recycler);
recyclerView.getAdapter().notifyDataSetChanged();
}
}
@@ -1,5 +1,6 @@
package com.mowesta.android.app.fragment;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -158,12 +159,20 @@ public class VideoFragment extends Fragment {
*/
TimeUtils timeUtils;
/**
* The last position that we fetched from the player.
*/
private int lastPosition;
/**
* Timer.
*/
Runnable timer = () -> {
int secs = player.getCurrentPosition() / 1000;
long time = args.getVideo().getTime() + (args.getVideo().getStart() + secs) * 60 * 60 * 1000;
lastPosition = player.getCurrentPosition();
int secs = lastPosition / 1000;
double hps = args.getVideo().getFph() / (double)args.getVideo().getFps();
int hours = (int)(secs / hps);
long time = args.getVideo().getTime() + (args.getVideo().getStart() + hours) * 60 * 60 * 1000;
int dayRes = timeUtils.getDayName(time);
String day;
if (dayRes != 0) {
@@ -176,8 +185,6 @@ public class VideoFragment extends Fragment {
handler.postDelayed(this.timer, 500);
};
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -204,11 +211,11 @@ public class VideoFragment extends Fragment {
args.getVideo().getSouthWest().getLongitude(), args.getVideo().getSouthWest().getLatitude());
player.setVideoURI(Uri.parse(args.getVideo().getUrl()));
if (savedInstanceState != null) {
player.seekTo(savedInstanceState.getInt("position", 0));
if (savedInstanceState.getBoolean("playing")) player.start();
} else {
player.start();
int pos = savedInstanceState.getInt("position", 0);
Log.d(TAG, "Resuming playback at position " + pos + ".");
player.seekTo(pos);
}
player.start();
if (args.getCity() != null) {
timezone = args.getCity().getTimezone();
marker.setPosition(args.getCity().getCoordinate().getLongitude(), args.getCity().getCoordinate().getLatitude());
@@ -221,8 +228,8 @@ public class VideoFragment extends Fragment {
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt("position", player.getCurrentPosition());
outState.putBoolean("playing", player.isPlaying());
Log.d(TAG, "Saving playback position at " + lastPosition + ".");
outState.putInt("position", lastPosition);
}
@Override
@@ -591,7 +591,8 @@ public class BindingAdapters {
view.setVisibility(View.GONE);
} else {
view.setVisibility(View.VISIBLE);
view.setText(view.getResources().getString(R.string.format_compact, (float)entry.getTemperature().getAbsoluteValue()));
float temp = BindingTransforms.getTemperature(view.getContext(), entry.getTemperature().getAbsoluteValue());
view.setText(view.getResources().getString(R.string.format_compact, temp));
}
}
@@ -1,10 +1,13 @@
package com.mowesta.android.app.model;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.PreferenceManager;
import com.mowesta.android.app.MowestaSettings;
import com.mowesta.android.app.R;
import com.mowesta.android.app.view.JamIcon;
import com.mowesta.android.app.view.WeatherIcon;
@@ -22,6 +25,23 @@ import java.util.Map;
public class BindingTransforms {
/**
* Returns the temperature as float in celsius or fahrenheit based on
* the user's current settings.
*
* @param context The context.
* @param celsius The temperature in celsius.
* @return The temperature in celsisus or fahrenheit.
*/
public static float getTemperature(@NonNull Context context, double celsius) {
if (MowestaSettings.isTemperatureCelsisus(context)) {
return (float)celsius;
} else {
return (float) Math.round((celsius * 9 / 5) + 32);
}
}
/**
* Returns the best (non-null) name from a map of names given the current
* language settings and the preference for short values.
@@ -3,11 +3,9 @@ package com.mowesta.android.app.model;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.mowesta.android.app.IApp;
import com.mowesta.android.app.R;
import com.mowesta.android.app.database.Favorite;
import com.mowesta.android.app.database.FavoriteDatabase;
@@ -36,6 +34,20 @@ import java.util.List;
*/
public class CityViewModel extends AbstractPlaceViewModel {
/**
* A listener that is informed when a station is selected.
*/
public interface OnStationSelectedListener {
/**
* Called when a station is selected.
*
* @param station The selected station.
*/
void onStationSelected(WeatherStation station);
}
/**
* The current weather condition.
*/
@@ -96,7 +108,9 @@ public class CityViewModel extends AbstractPlaceViewModel {
*/
private final MutableLiveData<Geometry> boundary = new MutableLiveData<>();
/**
* The loader for the city data.
*/
private final ApiTask<RequestParameter<Long>, City> cityLoader = new ApiTask<>
((input, client) -> client.getCity(input.getValue()),
(input, result) -> { completeRequest(input, () -> city.setValue(result)); },
@@ -16,7 +16,7 @@ import com.mowesta.android.feign.model.WeatherCondition;
*
* @author Marcus
*/
public class ConditionViewModel extends AndroidViewModel {
public class ConditionViewModel extends CustomizeViewModel {
/**
* The title to display.
@@ -0,0 +1,125 @@
package com.mowesta.android.app.model;
import android.app.Application;
import android.content.SharedPreferences;
import android.content.res.Resources;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import com.mowesta.android.app.MowestaSettings;
import com.mowesta.android.app.R;
import com.mowesta.android.app.adapter.PreferenceLiveData;
/**
* The view model that enables the customization.
*/
public class CustomizeViewModel extends AndroidViewModel {
/**
* The live data with the precipitation.
*/
private final PreferenceLiveData showPrecipitation;
/**
* The live data with the wind speed and direction.
*/
private final PreferenceLiveData showWind;
/**
* The live data with the cloud coverage.
*/
private final PreferenceLiveData showCloud;
/**
* The live data with the humidity.
*/
private final PreferenceLiveData showHumidity;
/**
* The live data with the snow.
*/
private final PreferenceLiveData showSnow;
/**
* The live data with the pressure.
*/
private final PreferenceLiveData showPressure;
/**
* Creates a new view model and initializes it from the settings.
*
* @param application The application.
*/
public CustomizeViewModel(@NonNull Application application) {
super(application);
Resources r = application.getResources();
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(application);
showPressure = new PreferenceLiveData(p, MowestaSettings.SHOW_PRESSURE, r.getBoolean(R.bool.show_pressure_default));
showSnow = new PreferenceLiveData(p, MowestaSettings.SHOW_SNOW, r.getBoolean(R.bool.show_snow_default));
showHumidity = new PreferenceLiveData(p, MowestaSettings.SHOW_HUMIDITY, r.getBoolean(R.bool.show_humidity_default));
showCloud = new PreferenceLiveData(p, MowestaSettings.SHOW_CLOUD, r.getBoolean(R.bool.show_cloud_default));
showWind = new PreferenceLiveData(p, MowestaSettings.SHOW_WIND, r.getBoolean(R.bool.show_wind_default));
showPrecipitation = new PreferenceLiveData(p, MowestaSettings.SHOW_PRECIPITATION, r.getBoolean(R.bool.show_precipitation_default));
}
/**
* Returns the live data to control the visibility of the cloud.
*
* @return The live data to control the cloud visibility.
*/
public MutableLiveData<Boolean> getShowCloud() {
return showCloud;
}
/**
* Returns the live data to control the visibility of the humidity.
*
* @return The live data to control the humidity visibility.
*/
public MutableLiveData<Boolean> getShowHumidity() {
return showHumidity;
}
/**
* Returns the live data to control the visibility of the precipitation.
*
* @return The live data to control the precipitation visibility.
*/
public MutableLiveData<Boolean> getShowPrecipitation() {
return showPrecipitation;
}
/**
* Returns the live data to control the visibility of the pressure.
*
* @return The live data to control the pressure visibility.
*/
public MutableLiveData<Boolean> getShowPressure() {
return showPressure;
}
/**
* Returns the live data to control the visibility of the show.
*
* @return The live data to control the show visibility.
*/
public MutableLiveData<Boolean> getShowSnow() {
return showSnow;
}
/**
* Returns the live data to control the visibility of the wind.
*
* @return The live data to control the wind visibility.
*/
public MutableLiveData<Boolean> getShowWind() {
return showWind;
}
}
@@ -129,10 +129,10 @@ public class LoginViewModel extends AndroidViewModel {
/**
* Links an existing device with the user.
*/
final ApiTask<UserCredentials, Device> linkTask = new ApiTask<UserCredentials, Device>((input, client) -> {
return client.setCurrentDeviceUser();
final ApiTask<Object[], Device> linkTask = new ApiTask<Object[], Device>((input, client) -> {
return client.setCurrentDeviceUser((Device)input[1]);
}, (input, result) -> {
getUserRepository().setCredentials(input);
getUserRepository().setCredentials((UserCredentials)input[0]);
getDeviceRepository().setDevice(result);
destination.setValue(Destination.DEVICES);
}, (input, status) -> {
@@ -144,6 +144,7 @@ public class LoginViewModel extends AndroidViewModel {
} else {
failure.setValue(R.string.login_failure_network);
}
System.out.println("Failure is: " + status);
});
@@ -192,6 +193,7 @@ public class LoginViewModel extends AndroidViewModel {
loginEnabled.setValue(Boolean.TRUE);
explanationText.setValue(R.string.login_explain_update);
loginButtonText.setValue(R.string.login_button_update);
noLoginButtonText.setValue(R.string.login_button_continue);
}
} else {
registerButtonVisible.setValue(Boolean.TRUE);
@@ -421,8 +423,9 @@ public class LoginViewModel extends AndroidViewModel {
DefaultApi api = getClientFactory().createClient(credentials);
passwordTask.execute(credentials, api);
} else {
Device device = getDeviceRepository().getDevice().getValue();
DefaultApi api = getClientFactory().createClient(credentials, getDeviceRepository().getHandle().getValue());
linkTask.execute(credentials, api);
linkTask.execute(new Object[] { credentials, device }, api);
}
} else {
DefaultApi api = getClientFactory().createClient(credentials);
@@ -16,7 +16,7 @@ import com.mowesta.android.feign.model.WeatherCondition;
*
* @author Marcus
*/
public class SummaryViewModel extends AndroidViewModel {
public class SummaryViewModel extends CustomizeViewModel {
/**
* The minimum values.
@@ -413,6 +413,7 @@ public class SummaryViewModel extends AndroidViewModel {
r.setTemperature(wc.getTemperature());
r.setTime(wc.getTime());
r.setWindSpeed(wc.getWindSpeed());
r.setWindDirection(wc.getWindDirection());
r.setType(wc.getType());
return r;
}
@@ -1,12 +1,16 @@
package com.mowesta.android.app.repository;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mowesta.android.app.IApp;
import com.mowesta.android.feign.model.Device;
import com.mowesta.android.feign.model.DeviceHandle;
import com.mowesta.android.feign.model.User;
/**
* The device repository stores the state about the device.
@@ -15,6 +19,11 @@ import com.mowesta.android.feign.model.DeviceHandle;
*/
public class DeviceRepository extends Repository {
/**
* The log tag.
*/
private static final String TAG = "DeviceRepository";
/**
* A builder for the device repository.
*/
@@ -30,6 +39,22 @@ public class DeviceRepository extends Repository {
*/
private String handle;
/**
* A flag to trace changes.
*/
private boolean trace;
/**
* Enables tracing.
*
* @param trace True to enable, false to disable.
* @return The builder for chaining.
*/
public DeviceRepository.Builder setTrace(boolean trace) {
this.trace = trace;
return this;
}
/**
* Sets the initial device.
*
@@ -77,6 +102,14 @@ public class DeviceRepository extends Repository {
*/
public DeviceRepository build(IApp application) {
DeviceRepository r = new DeviceRepository(application);
if (trace) {
r.getDevice().observeForever((d) -> {
Log.d(TAG, "Setting device to " + (d==null?"null":d.getId()) + " with user " + (d==null?"null":d.getUser()) + ".");
});
r.getHandle().observeForever((h) -> {
Log.d(TAG, "Setting handle to " + h + ".");
});
}
FileStoreObserver<Device> deviceObserver = new FileStoreObserver<Device>(application.getContext(), Device.class, "device.json", false);
FileStoreObserver<String> handleObserver = new FileStoreObserver<String>(application.getContext(), String.class, "handle.json", true);
r.device.setValue(device == null ? deviceObserver.loadValue() : device);
@@ -1,6 +1,7 @@
package com.mowesta.android.app.repository;
import android.os.Build;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
@@ -18,6 +19,11 @@ import com.mowesta.android.feign.model.User;
*/
public class UserRepository extends Repository {
/**
* The log tag.
*/
private static final String TAG = "UserRepository";
/**
* A builder for the user repository.
*
@@ -35,6 +41,11 @@ public class UserRepository extends Repository {
*/
private UserCredentials credentials;
/**
* A flag to trace changes.
*/
private boolean trace;
/**
* Sets the initial user.
*
@@ -46,6 +57,17 @@ public class UserRepository extends Repository {
return this;
}
/**
* Enables tracing.
*
* @param trace True to enable, false to disable.
* @return The builder for chaining.
*/
public Builder setTrace(boolean trace) {
this.trace = trace;
return this;
}
/**
* Sets the initial user credentials.
*
@@ -83,6 +105,17 @@ public class UserRepository extends Repository {
*/
public UserRepository build(IApp application) {
UserRepository r = new UserRepository(application);
if (trace) {
r.state.observeForever((s) -> {
Log.d(TAG, "Setting state to " + s.name());
});
r.credentials.observeForever((c)-> {
Log.d(TAG, "Setting credentials to " + (c==null?"null":(c.getLogin()+":"+c.getPassword())) + ".");
});
r.user.observeForever((u)-> {
Log.d(TAG, "Setting user to " + (u==null?"null":(u.getLogin() + ":" + u.getId())) + ".");
});
}
FileStoreObserver<User> userObserver = new FileStoreObserver<User>(application.getContext(), User.class, "user.json", false);
FileStoreObserver<UserCredentials> credentialsObserver = new FileStoreObserver<UserCredentials>(application.getContext(), UserCredentials.class, "credentials.json", true);
r.user.setValue(user == null ? userObserver.loadValue() : user);
@@ -210,6 +243,7 @@ public class UserRepository extends Repository {
*/
public void clearCredentials() {
this.credentials.setValue(null);
this.user.setValue(null);
this.state.setValue(State.INVALID);
}
@@ -1,22 +0,0 @@
package com.mowesta.android.app.task;
import android.os.AsyncTask;
import com.mowesta.android.app.MowestaApp;
/**
* Base class for the AsyncTasks
*
* @author Arman
*/
public abstract class AbstractTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
/**
* Reference to the app
*/
protected MowestaApp app;
AbstractTask(MowestaApp app) {
this.app = app;
}
}
@@ -9,6 +9,7 @@ import com.mowesta.android.feign.api.DefaultApi;
import com.mowesta.android.feign.model.City;
import com.mowesta.android.feign.model.CityPage;
import java.util.ArrayList;
import java.util.List;
/**
@@ -58,20 +59,24 @@ public class RefreshTask {
* The task that updates the database in the background
* using the sequential executor.
*/
DatabaseTask<FavoriteDatabase, Favorite, Void> updateTask = new DatabaseTask<>(
(input, database) -> {
Favorite target = database.getAccessor().findById(input.getType(), input.getId());
if (target != null && !target.isDeleted()) {
target.setLocation(input.getLocation());
target.setBoundary(input.getBoundary());
target.setCity(input.getCity());
target.setForecast(input.getForecast());
target.setStation(input.getStation());
target.setWeatherTime(input.getWeatherTime());
target.setLocationTime(input.getLocationTime());
target.setCondition(input.getCondition());
database.getAccessor().update(target);
}
DatabaseTask<FavoriteDatabase, List<Favorite>, Void> updateTask = new DatabaseTask<>(
(list, database) -> {
database.runInTransaction(() -> {
for (Favorite input: list) {
Favorite target = database.getAccessor().findById(input.getType(), input.getId());
if (target != null && !target.isDeleted()) {
target.setLocation(input.getLocation());
target.setBoundary(input.getBoundary());
target.setCity(input.getCity());
target.setForecast(input.getForecast());
target.setStation(input.getStation());
target.setWeatherTime(input.getWeatherTime());
target.setLocationTime(input.getLocationTime());
target.setCondition(input.getCondition());
database.getAccessor().update(target);
}
}
});
return null;
}, (input, output) -> { });
@@ -98,15 +103,17 @@ public class RefreshTask {
@Override
protected Boolean doInBackground(Void... voids) {
List<Favorite> favorites = database.getAccessor().getAll();
List<Favorite> modified = new ArrayList<>();
try {
for (Favorite f: favorites) {
if (! f.isDeleted()) {
refresh(client, f);
updateTask.execute(f, database);
if (! f.isDeleted() && refresh(client, f)) {
modified.add(f);
}
}
if (modified.size() > 0) updateTask.execute(modified, database);
return true;
} catch (Exception e) {
if (modified.size() > 0) updateTask.execute(modified, database);
return false;
}
}
@@ -124,10 +131,13 @@ public class RefreshTask {
*
* @param client The client.
* @param target The target.
* @return True if modified, false otherwise.
*/
private void refresh(DefaultApi client, Favorite target) {
private boolean refresh(DefaultApi client, Favorite target) {
boolean modified = false;
long now = System.currentTimeMillis();
if (now - target.getLocationTime() > ONE_DAY || isLocationIncomplete(target)) {
modified = true;
City city = null;
switch (target.getType()) {
case CITY:
@@ -159,6 +169,7 @@ public class RefreshTask {
target.setWeatherTime(now);
}
} else if (now - target.getWeatherTime() > TWO_MINUTES || isWeatherIncomplete(target)) {
modified = true;
City city = target.getCity();
if (city != null) {
target.setForecast(client.getCityForecast(city.getId()));
@@ -166,6 +177,7 @@ public class RefreshTask {
target.setWeatherTime(now);
}
}
return modified;
}
/**
@@ -148,9 +148,14 @@ public class SyncTask {
// apply all changes remotely
client.setCurrentUserSettings(settings);
// apply all changes locally
for (Favorite f: changedFavorites) database.getAccessor().update(f);
for (Favorite f: deletedFavorites) database.getAccessor().delete(f);
for (Favorite f: newFavorites) database.getAccessor().add(f);
database.runInTransaction(new Runnable() {
@Override
public void run() {
for (Favorite f: changedFavorites) database.getAccessor().update(f);
for (Favorite f: deletedFavorites) database.getAccessor().delete(f);
for (Favorite f: newFavorites) database.getAccessor().add(f);
}
});
return true;
} catch (Exception e) {
return false;
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M22,11h-4.17l3.24,-3.24 -1.41,-1.42L15,11h-2V9l4.66,-4.66 -1.42,-1.41L13,6.17V2h-2v4.17L7.76,2.93 6.34,4.34 11,9v2H9L4.34,6.34 2.93,7.76 6.17,11H2v2h4.17l-3.24,3.24 1.41,1.42L9,13h2v2l-4.66,4.66 1.42,1.41L11,17.83V22h2v-4.17l3.24,3.24 1.42,-1.41L13,15v-2h2l4.66,4.66 1.41,-1.42L17.83,13H22z"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2L18,7L6,7v12zM8,9h8v10L8,19L8,9zM15.5,4l-1,-1h-5l-1,1L5,4v2h14L19,4z"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M2,20h20v-4L2,16v4zM4,17h2v2L4,19v-2zM2,4v4h20L22,4L2,4zM6,7L4,7L4,5h2v2zM2,14h20v-4L2,10v4zM4,11h2v2L4,13v-2z"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M1,9l2,2c4.97,-4.97 13.03,-4.97 18,0l2,-2C16.93,2.93 7.08,2.93 1,9zM9,17l3,3 3,-3c-1.65,-1.66 -4.34,-1.66 -6,0zM5,13l2,2c2.76,-2.76 7.24,-2.76 10,0l2,-2C15.14,9.14 8.87,9.14 5,13z"/>
</vector>
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="56.7532dp"
android:height="56.7532dp"
android:tint="#FFFFFF"
android:viewportWidth="1755.38"
android:viewportHeight="1755.38">
<path
android:pathData="M181.92,586.9c0,-58.39 20.51,-108.21 61.54,-149.01 41.25,-40.8 90.84,-61.32 148.78,-61.32 57.94,0 107.53,20.51 148.78,61.54 41.03,41.25 61.54,90.84 61.54,148.78 0,57.93 -20.52,107.53 -61.54,148.78 -41.25,41.03 -90.84,61.54 -148.78,61.54 -57.94,0 -107.53,-20.51 -148.78,-61.54 -41.03,-41.25 -61.54,-90.85 -61.54,-148.78zM291.48,586.9c0,27.73 9.92,51.4 29.53,71.23 19.84,19.61 43.51,29.53 71.24,29.53 27.73,0 51.4,-9.92 71.24,-29.53 19.61,-19.84 29.53,-43.51 29.53,-71.23 0,-27.73 -9.92,-51.4 -29.53,-71.24 -19.84,-19.61 -43.51,-29.53 -71.24,-29.53 -27.73,0 -51.4,9.92 -71.24,29.53 -19.61,19.84 -29.53,43.51 -29.53,71.24z"
android:fillColor="#B0000000"
android:fillType="nonZero"/>
<path
android:pathData="M1384.11,1005.51l189.35,58.16c-29.08,106.63 -77.54,185.75 -145.17,237.6 -67.63,51.62 -153.29,77.54 -257.21,77.54 -128.72,0 -234.44,-43.95 -317.4,-131.87 -82.73,-87.92 -124.21,-208.07 -124.21,-360.68 0,-161.18 41.7,-286.51 124.88,-375.78 83.18,-89.27 192.74,-133.9 328.44,-133.9 118.57,0 214.83,35.16 288.77,105.27 44.18,41.48 77.09,100.99 99.19,178.76l-193.42,45.99c-11.5,-50.04 -35.39,-89.72 -71.68,-118.8 -36.52,-29.08 -80.7,-43.51 -132.55,-43.51 -71.91,0 -130.3,25.7 -174.93,77.32 -44.86,51.4 -67.18,134.81 -67.18,250.22 0,122.18 22.09,209.42 66.05,261.27 44.18,52.07 101.44,78 172,78 52.07,0 96.93,-16.45 134.35,-49.59 37.42,-33.14 64.47,-84.98 80.7,-155.99z"
android:fillColor="#B0000000"
android:fillType="nonZero"/>
</vector>
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="56.7532dp"
android:height="56.7532dp"
android:tint="#FFFFFF"
android:viewportWidth="27985.17"
android:viewportHeight="27985.17">
<path
android:pathData="M4043.1,9485.9c0,-930.8 327,-1725.1 981.1,-2375.5 657.7,-650.5 1448.3,-977.5 2371.9,-977.5 923.6,0 1714.3,327 2371.9,981.1 654,657.7 981.1,1448.3 981.1,2371.9 0,923.6 -327.1,1714.2 -981.1,2371.9 -657.7,654 -1448.3,981.1 -2371.9,981.1 -923.6,0 -1714.3,-327 -2371.9,-981.1 -654.1,-657.7 -981.1,-1448.3 -981.1,-2371.9zM5789.7,9485.9c0,442 158.1,819.4 470.8,1135.6 316.3,312.7 693.7,470.8 1135.7,470.8 442,0 819.4,-158.1 1135.7,-470.8 312.6,-316.2 470.8,-693.6 470.8,-1135.6 0,-442.1 -158.1,-819.4 -470.8,-1135.7 -316.3,-312.7 -693.7,-470.8 -1135.7,-470.8 -442,0 -819.4,158.1 -1135.7,470.8 -312.6,316.3 -470.8,693.6 -470.8,1135.7z"
android:fillColor="#B0000000"
android:fillType="nonZero"/>
<path
android:pathData="M13333.1,21852.3l0,-15439.1l10609,0l0,2609.1l-7482.3,0l0,3665.7l6468.9,0l0,2609.2l-6468.9,0l0,6555.1z"
android:fillColor="#B0000000"
android:fillType="nonZero"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M4,15h16v-2L4,13v2zM4,19h16v-2L4,17v2zM4,11h16L20,9L4,9v2zM4,5v2h16L20,5L4,5z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#B0000000" android:pathData="M4,15h16v-2L4,13v2zM4,19h16v-2L4,17v2zM4,11h16L20,9L4,9v2zM4,5v2h16L20,5L4,5z"/>
</vector>
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false"
android:drawable="@android:color/transparent"/>
<item android:state_selected="true"
android:drawable="@color/colorAccent"/>
</selector>
@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="model"
type="com.mowesta.android.app.model.CustomizeViewModel" />
<variable
name="closeListener"
type="Runnable" />
</data>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/header"
android:background="@color/colorAccent"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Space
android:layout_width="@dimen/space_medium"
android:layout_height="wrap_content"/>
<ImageView
android:contentDescription="@null"
android:layout_width="48dp"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:src="@drawable/ic_view_headline_black_24dp"/>
<TextView
android:layout_weight="1"
android:layout_marginStart="@dimen/space_medium"
android:layout_marginEnd="@dimen/space_medium"
android:layout_gravity="center_vertical"
style="@style/TextAppearance.MaterialComponents.Subtitle1"
android:text="@string/action_customize"
android:singleLine="true"
android:ellipsize="end"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<ImageButton
android:contentDescription="@string/button_close"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:onClick="@{ () -> closeListener.run() }"
style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
android:src="@drawable/ic_baseline_close_24" />
</LinearLayout>
<androidx.core.widget.NestedScrollView
android:layout_height="270dp"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_medium"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.mowesta.android.app.view.WeatherView
android:layout_width="40dp"
android:layout_height="40dp"
android:textSize="24dp"
android:gravity="center"
app:weather="RAINDROPS" />
<Switch
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
android:ellipsize="end"
android:checked="@={ model.showPrecipitation }"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_precipitation"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.mowesta.android.app.view.WeatherView
android:layout_width="40dp"
android:layout_height="40dp"
android:textSize="24dp"
android:gravity="center"
app:weather="WIND_DIRECTION" />
<Switch
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
android:ellipsize="end"
android:checked="@={ model.showWind }"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_wind_speed"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.mowesta.android.app.view.WeatherView
android:layout_width="40dp"
android:layout_height="40dp"
android:textSize="24dp"
android:gravity="center"
app:weather="CLOUD" />
<Switch
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
android:ellipsize="end"
android:checked="@={ model.showCloud }"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_cloud_coverage"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.mowesta.android.app.view.WeatherView
android:layout_width="40dp"
android:layout_height="40dp"
android:textSize="24dp"
android:gravity="center"
app:weather="HUMIDITY" />
<Switch
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
android:ellipsize="end"
android:checked="@={ model.showHumidity }"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_humidity"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.mowesta.android.app.view.WeatherView
android:layout_width="40dp"
android:layout_height="40dp"
android:textSize="24dp"
android:gravity="center"
app:weather="SNOWFLAKE_COLD" />
<Switch
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
android:ellipsize="end"
android:checked="@={ model.showSnow }"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_snow_depth"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.mowesta.android.app.view.WeatherView
android:layout_width="40dp"
android:layout_height="40dp"
android:textSize="24dp"
android:gravity="center"
app:weather="BAROMETER" />
<Switch
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
android:ellipsize="end"
android:checked="@={ model.showPressure }"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_pressure"/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</layout>
@@ -11,14 +11,14 @@
name="closeListener"
type="Runnable" />
</data>
<RelativeLayout
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="400dp">
<LinearLayout
android:id="@+id/header"
android:background="@color/colorAccent"
android:elevation="4dp"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Space
@@ -50,12 +50,9 @@
<androidx.core.widget.NestedScrollView
android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_below="@id/header"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true">
android:layout_width="match_parent">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
@@ -416,7 +413,7 @@
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
</LinearLayout>
@@ -5,6 +5,7 @@
<data>
<variable name="model" type="com.mowesta.android.app.model.CityViewModel" />
<variable name="stationListener" type="com.mowesta.android.app.model.CityViewModel.OnStationSelectedListener" />
<variable name="condition" type="com.mowesta.android.app.model.ConditionViewModel" />
</data>
@@ -21,7 +22,9 @@
layout="@layout/view_condition"
app:model="@{condition}" />
<include layout="@layout/view_city_detail" app:model="@{model}" />
<include layout="@layout/view_city_detail"
app:model="@{model}"
app:stationListener="@{stationListener}" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
@@ -20,6 +20,7 @@
<ImageView
android:id="@+id/logo_sun"
android:contentDescription="@null"
android:layout_width="90dp"
android:layout_alignParentEnd="true"
android:layout_margin="@dimen/space_medium"
@@ -126,6 +127,7 @@
<ImageView
android:id="@+id/logo_ude"
android:layout_weight="1"
android:contentDescription="@string/collection_logo_ude"
android:src="@drawable/logo_ude"
android:scaleType="centerInside"
android:layout_width="0dp"
@@ -138,6 +140,7 @@
<ImageView
android:id="@+id/logo_fair"
android:layout_weight="1"
android:contentDescription="@string/collection_logo_fair"
android:padding="@dimen/space_medium"
android:src="@drawable/logo_fair"
android:scaleType="centerInside"
@@ -22,6 +22,7 @@
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="end|top"
android:visibility="gone"
app:tint="@color/black"
app:backgroundTint="@color/colorAccent"
android:contentDescription="@string/action_device_add"
@@ -5,6 +5,117 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/fragment_recycler" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:id="@+id/favorites_help"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/space_medium"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_medium"
android:text="@string/favorite_explain_empty"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_gravity="center_vertical"
android:contentDescription="@null"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_search_black_24dp" />
<Space
android:layout_width="@dimen/space_medium"
android:layout_height="wrap_content"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_medium"
android:text="@string/favorite_explain_search"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_gravity="center_vertical"
android:contentDescription="@null"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_favorite_black_24dp" />
<Space
android:layout_width="@dimen/space_medium"
android:layout_height="wrap_content"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_medium"
android:text="@string/favorite_explain_add"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_gravity="center_vertical"
android:contentDescription="@null"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_baseline_menu_24" />
<Space
android:layout_width="@dimen/space_medium"
android:layout_height="wrap_content"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_medium"
android:text="@string/favorite_explain_drawer"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<include layout="@layout/fragment_recycler"
android:id="@+id/favorites_list"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp" />
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
@@ -111,7 +111,9 @@
<com.google.android.material.textview.MaterialTextView
android:id="@+id/button_register"
style="@style/text_small_hyperlink"
style="@style/TextAppearance.MaterialComponents.Caption"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
@@ -56,8 +56,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="@{ () -> continueListener.run() }"
android:text="@string/terms_button_accept"
android:theme="@style/button_highlighted"/>
android:text="@string/terms_button_accept" />
</LinearLayout>
</LinearLayout>
@@ -7,6 +7,9 @@
<variable
name="model"
type="com.mowesta.android.app.model.CityViewModel" />
<variable
type="com.mowesta.android.app.model.CityViewModel.OnStationSelectedListener"
name="stationListener" />
</data>
<com.google.android.material.card.MaterialCardView
@@ -40,7 +43,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
<com.google.android.material.textview.MaterialTextView
tools:text="Essen"
cityName="@{model.city}"
android:ellipsize="end"
@@ -48,7 +51,7 @@
android:textAppearance="?attr/textAppearanceBody1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
<com.google.android.material.textview.MaterialTextView
android:id="@+id/city_state"
android:clickable="true"
android:focusable="true"
@@ -60,7 +63,7 @@
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
<com.google.android.material.textview.MaterialTextView
android:id="@+id/city_country"
tools:text="Deutschland"
android:clickable="true"
@@ -131,6 +134,35 @@
cityPopulation="@{model.city}"
tools:text="100023" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="@{ model.station == null ? View.GONE : View.VISIBLE }"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<ImageView
android:layout_width="50dp"
android:layout_height="20dp"
android:padding="1dp"
android:gravity="center_horizontal"
android:contentDescription="@string/label_station"
tools:targetApi="O"
android:tooltipText="@string/label_station"
android:src="@drawable/ic_toys_black_24dp" />
<com.google.android.material.textview.MaterialTextView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:gravity="end"
android:clickable="true"
android:focusable="true"
android:onClick="@{ () -> stationListener.onStationSelected(model.station) }"
style="@style/TextAppearance.Mowesta.LinkAccent"
stationName="@{model.station}"
tools:text="Essen Bredeney" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -40,7 +40,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
<com.google.android.material.textview.MaterialTextView
tools:text="Morgen"
android:text="@{model.title}"
android:ellipsize="end"
@@ -48,7 +48,7 @@
android:textAppearance="?attr/textAppearanceBody1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
<com.google.android.material.textview.MaterialTextView
tools:text="28.03.2020"
android:text="@{model.subtitle}"
android:textAppearance="?attr/textAppearanceBody1"
@@ -64,7 +64,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingBottom="16dp"
android:paddingEnd="16dp"
android:paddingStart="16dp">
@@ -81,7 +80,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="16dp">
android:layout_marginTop="8dp">
<com.mowesta.android.app.view.WeatherView
android:layout_width="50dp"
android:layout_height="wrap_content"
@@ -104,6 +103,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
visible="@{model.showPrecipitation}"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
@@ -127,6 +127,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
visible="@{model.showWind}"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
@@ -148,6 +149,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
visible="@{model.showCloud}"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
android:layout_width="50dp"
@@ -171,6 +173,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
visible="@{model.showHumidity}"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
android:layout_width="50dp"
@@ -194,6 +197,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
visible="@{model.showSnow}"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
android:layout_width="50dp"
@@ -217,6 +221,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
visible="@{model.showPressure}"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
android:layout_width="50dp"
@@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="model"
type="com.mowesta.android.app.model.SummaryViewModel" />
@@ -46,7 +47,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
<com.google.android.material.textview.MaterialTextView
tools:text="Morgen"
android:text="@{model.title}"
android:ellipsize="end"
@@ -54,7 +55,7 @@
android:textAppearance="?attr/textAppearanceBody1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
<com.google.android.material.textview.MaterialTextView
tools:text="28.03.2020"
android:text="@{model.subtitle}"
android:textAppearance="?attr/textAppearanceBody1"
@@ -68,7 +69,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="8dp"
android:paddingTop="0dp"
android:paddingBottom="16dp"
android:paddingEnd="16dp"
android:paddingStart="16dp">
@@ -84,7 +85,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="16dp">
android:layout_marginTop="8dp">
<com.mowesta.android.app.view.WeatherView
android:layout_width="40dp"
android:layout_height="wrap_content"
@@ -116,6 +117,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
visible="@{model.showPrecipitation}"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
android:layout_width="40dp"
@@ -147,6 +149,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
visible="@{model.showWind}"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
@@ -176,6 +179,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
visible="@{model.showCloud}"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
@@ -208,6 +212,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
visible="@{model.showHumidity}"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
@@ -240,6 +245,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
visible="@{model.showSnow}"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
@@ -272,6 +278,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
visible="@{model.showPressure}"
android:orientation="horizontal"
android:layout_marginTop="4dp">
<com.mowesta.android.app.view.WeatherView
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="@string/action_customize"
android:id="@+id/action_customize"
android:icon="@drawable/ic_view_headline_white_24dp"
android:menuCategory="container"
app:showAsAction="ifRoom"/>
</menu>
@@ -4,17 +4,21 @@
<item android:title="@string/action_favorite_add"
android:id="@+id/action_favorite_add"
android:icon="@drawable/ic_favorite_border_white_24dp"
android:menuCategory="system"
app:showAsAction="ifRoom" />
<item android:title="@string/action_favorite_remove"
android:id="@+id/action_favorite_remove"
android:icon="@drawable/ic_favorite_white_24dp"
android:menuCategory="system"
app:showAsAction="ifRoom"/>
<item android:title="@string/action_google_maps"
android:id="@+id/action_google_maps"
android:icon="@drawable/ic_map_white_24dp"
android:menuCategory="system"
app:showAsAction="ifRoom"/>
<item android:title="@string/action_wikipedia"
android:id="@+id/action_wikipedia"
android:icon="@drawable/ic_info_outline_white_24dp"
android:menuCategory="system"
app:showAsAction="ifRoom"/>
</menu>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="@string/action_switch_to_fahrenheit"
app:showAsAction="ifRoom"
android:id="@+id/unit_celsius"
android:icon="@drawable/ic_celsius_white_24"/>
<item android:title="@string/action_switch_to_celsius"
app:showAsAction="ifRoom"
android:id="@+id/unit_fahrenheit"
android:icon="@drawable/ic_fahrenheit_white_24"/>
</menu>
+32 -22
View File
@@ -20,23 +20,21 @@
<string name="login_explain_update">Falls Du ein MoWeSta Konto hast, können wir das Gerät damit verbinden. Dadurch kannst Du Deine Favoriten zwischen mehreren Geräten teilen und Du kannst von jeder MoWeSta App auf Deine Messungen zugreifen.</string>
<string name="login_explain_password">Die letzte Anmeldung ist fehlgeschlagen. Falls Du Dein Passwort an einem anderen Gerät geändert hast, gib bitte Dein neues Passwort ein. Falls Du Dein Konto gelöscht hast, setze das Gerät über die Einstellungen zurück.</string>
<string name="login_hint_user">Login</string>
<string name="login_text">Bitte logge dich ein.</string>
<string name="login_hint_user">Kontoname</string>
<string name="login_hint_password">Passwort</string>
<string name="login_button_create">Anmelden und Gerät einrichten</string>
<string name="login_button_update">Anmelden und Gerät verbinden</string>
<string name="login_button_create">Anmelden und einrichten</string>
<string name="login_button_update">Anmelden und verbinden</string>
<string name="login_button_password">Passwort ändern</string>
<string name="login_text_register">Falls Du noch keins hast, kannst Du Dir <b>hier</b> ein neues Konto kostenlos anlegen.</string>
<string name="login_button_continue">Weiter ohne Anmeldung</string>
<string name="login_button_continue">Ohne Anmeldung einrichten</string>
<string name="login_failure_credentials">Anmeldefehler, bitte prüfe Deine Zugangsdaten.</string>
<string name="login_button_retry">Nochmal anmelden</string>
<string name="login_failure_network">Einrichtung fehlgeschlagen. Hat Dein Gerät gerade kein Netz?</string>
<string name="login_failure_conflict">Dein Gerät ist bereits mit einem Konto verbunden.</string>
<string name="login_error_login_missing">Bitte gib Deinen Nutzernamen ein.</string>
<string name="login_error_login_too_short">Dein Nutzername ist zu kurz.</string>
<string name="login_error_login_too_long">Dein Nutzername ist zu lang.</string>
<string name="login_error_login_invalid_chars">Dein Nutzername enthält ungültige Zeichen.</string>
<string name="login_error_login_too_short">Dein Kontoname ist zu kurz.</string>
<string name="login_error_login_too_long">Dein Kontoname ist zu lang.</string>
<string name="login_error_login_invalid_chars">Dein Kontoname enthält ungültige Zeichen.</string>
<string name="login_error_password_missing">Bitte gib Dein Passwort ein.</string>
<string name="login_error_password_too_short">Dein Passwort ist zu kurz.</string>
@@ -51,6 +49,10 @@
<string name="collection_on_off">Jetzt mitmachen</string>
<string name="collection_button_continue">Lass uns loslegen</string>
<string name="favorite_explain_empty">Hier findest Du normalerweise Deine Lieblingsorte. Scheinbar hast Du aber noch keine Orte hinzugefügt.</string>
<string name="favorite_explain_search">Um Orte anzuzeigen, tippe auf das Lupensymbol oben rechts und gib die ersten Buchstaben des Ortsnamens ein. Tippe danach auf den gewünschten Ort in der Liste mit den Suchergebnissen.</string>
<string name="favorite_explain_add">Um einen Lieblingsort hinzuzufügen, lass Dir den Ort anzeigen und tippe einmal auf die Schaltfläche mit dem Herzsymbol oben rechts. Um einen Lieblingsort zu entfernen, tippe einfach nochmal auf das Herzsymbol.</string>
<string name="favorite_explain_drawer">Weitere Funktionen findest Du auch im Hauptmenü. Um das Hauptmenü zu öffnen, wische mit einem Finger von ganz links nach rechts über Deinen Bildschirm oder tippe auf das Menüsymbol oben links.</string>
<!-- Settings -->
@@ -59,7 +61,7 @@
<string name="setting_privacy_measure_summary">Aktiviert die Erfassung von Messungen im Hintergrund. Deaktivierung beendet die Messung und Übertragung von Daten.</string>
<string name="setting_privacy_reset_title">Zurücksetzen</string>
<string name="setting_privacy_reset_summary">Entfernt alle auf dem Gerät gespeicherten Daten und setzt die Geräteregistierung zurück. Nach der Ausführung muss das Gerät erneut registriert werden.</string>
<string name="setting_privacy_reset_message">Möchtest Du wirklich alle Daten löschen? Dieser Vorgang ist unumkehrbar.</string>
<string name="setting_privacy_reset_message">Möchtest Du wirklich ALLE Daten löschen? Das kannst Du nicht mehr rückgängig machen!</string>
<string name="setting_category_notification">Benachrichtigungen</string>
<string name="setting_notification_app_title">Anwendung</string>
<string name="setting_notification_app_summary">Ermöglicht das Ein- und Ausblenden von Benachrichtigungen, die von der App erstellt werden.</string>
@@ -73,13 +75,21 @@
<string name="setting_about_build_title">Version</string>
<string name="setting_about_build_summary">$code$ | $version$ @ $build$</string>
<string name="setting_category_development">Entwicklung</string>
<string name="setting_development_device">Geräteninfos</string>
<string name="setting_development_device">Geräteinfos</string>
<string name="setting_development_token">Geräteschlüssel</string>
<string name="setting_mowesta_url_title">MoWeSta Url</string>
<string name="setting_mowesta_url_title">Dienstadresse</string>
<string name="setting_mowesta_url_summary">Konfiguriert die URL der MoWeSta API, die vom HTTP Client der App verwendet wird.</string>
<string name="setting_development_clear_title">Cache löschen</string>
<string name="setting_development_clear_summary">Löscht alle gecachten Standortdaten vom Gerät.</string>
<string name="setting_development_clear_message">Der Cache wurde gelöscht.</string>
<string name="setting_development_mode_enter">Du bist jetzt im Entwicklermodus.</string>
<string name="setting_development_mode_leave">Du bist jetzt wieder im normalen Modus.</string>
<string name="setting_development_mode_leave">Du bist jetzt wieder im Anwendermodus.</string>
<string name="setting_development_cache_title">Cache nutzen</string>
<string name="setting_development_cache_summary">Nutzung gecachter Standortdaten zur Standortbestimmung.</string>
<string name="setting_development_gps_title">Gps nutzen</string>
<string name="setting_development_gps_summary">Nutzung des internen Gps-Empfängers zur Standortbestimmung.</string>
<string name="setting_development_net_title">Netzwerk nutzen</string>
<string name="setting_development_net_summary">Nutzung der verfügbaren Netzwerkdaten zur Standortbestimmung.</string>
<string name="direction_east">Ost</string>
<string name="direction_north">Nord</string>
@@ -117,10 +127,10 @@
<string name="weather_snow_shower_moderate_heavy">Schneeschauer</string>
<string name="weather_thunderstorm_slight_moderate">Leichte Gewitter</string>
<string name="weather_thunderstorm_hail_heavy">Starke Gewitter</string>
<string name="source_icon_global">Numerische Vorhersage (DWD ICON Global)</string>
<string name="source_icon_europe">Numerische Vorhersage (DWD ICON Europa)</string>
<string name="source_cosmo_europe">Numerische Vorhersage (DWD COSMO-D2 Europa)</string>
<string name="source_weather_station">Messung durch Wetterstation</string>
<string name="source_icon_global">DWD ICON Global</string>
<string name="source_icon_europe">DWD ICON Europa</string>
<string name="source_cosmo_europe">DWD COSMO-D2 Europa</string>
<string name="source_weather_station">DWD Wetterstation</string>
<string name="video_source_icon_global">ICON Global</string>
<string name="video_source_icon_europe">ICON Europa</string>
<string name="video_source_cosmo_europe">D2 Europa</string>
@@ -142,8 +152,6 @@
<string name="label_local_time">Ortszeit</string>
<string name="label_source">Quelle</string>
<string name="label_time">Zeit</string>
<string name="label_date">Datum</string>
<string name="label_temperature">Temperatur</string>
<string name="label_wind_speed">Windgeschwindigkeit</string>
<string name="label_cloud_coverage">Wolkendichte</string>
@@ -151,8 +159,6 @@
<string name="label_humidity">Luftfeuchtigkeit</string>
<string name="label_snow_depth">Schneehöhe</string>
<string name="label_precipitation">Niederschlag</string>
<string name="label_longitude">Längengrad</string>
<string name="label_latitude">Breitengrad</string>
<string name="label_altitude">Höhe</string>
<string name="label_name">Name</string>
<string name="label_operator">Betreiber</string>
@@ -185,6 +191,7 @@
<string name="city_info_day">Tag</string>
<string name="city_info_time">Tageszeit</string>
<string name="city_info_hour">Stunde</string>
<string name="label_station">Wetterstation</string>
<string name="label_full_day">Gesamter Tag</string>
<string name="label_morning">Morgens</string>
<string name="label_afternoon">Mittags</string>
@@ -205,6 +212,9 @@
<string name="action_wikipedia">Bei Wikipedia anzeigen</string>
<string name="action_refresh">Aktualisieren</string>
<string name="action_device_add">Gerät hinzufügen</string>
<string name="action_switch_to_fahrenheit">In Fahrenheit anzeigen</string>
<string name="action_switch_to_celsius">In Celsius anzeigen</string>
<string name="action_customize">Ansicht anpassen</string>
<string name="snackbar_error">Fehler beim Laden der Daten.</string>
<string name="snackbar_reload">Neu\nladen</string>
@@ -4,9 +4,7 @@
<color name="white">#ffffff</color>
<color name="colorPrimary">#00695C</color>
<color name="colorPrimaryOverlay">#A000695C</color>
<color name="colorPrimaryLight">#439889</color>
<color name="colorPrimaryDark">#003d33</color>
<color name="colorAccent">#f9a825</color>
<color name="colorAccentLight">#ffd95a</color>
<color name="colorGray">#eeeeee</color>
</resources>
@@ -28,6 +28,14 @@
<bool name="development_mode_default">false</bool>
<bool name="privacy_measure_default">false</bool>
<bool name="collection_shown_default">false</bool>
<bool name="temperature_celsius_default">true</bool>
<bool name="show_precipitation_default">true</bool>
<bool name="show_wind_default">true</bool>
<bool name="show_cloud_default">true</bool>
<bool name="show_snow_default">true</bool>
<bool name="show_pressure_default">true</bool>
<bool name="show_humidity_default">true</bool>
+27 -14
View File
@@ -21,7 +21,6 @@
<string name="login_explain_update">If you have an MoWeSta account, we can link your device to it. This allows you to share your favorites across multiple devices and you can also access your measurements from any MoWeSta app.</string>
<string name="login_explain_password">The last login attempt failed. If you have changed your password on another device, please enter your new password. If you have deleted your account, please reset the device via the app settings.</string>
<string name="login_hint_user">Username</string>
<string name="login_text">Please log in.</string>
<string name="login_hint_password">Password</string>
<string name="login_button_create">Register with account</string>
<string name="login_button_update">Link with account</string>
@@ -33,7 +32,6 @@
<string name="login_failure_network">Please check your internet connection.</string>
<string name="login_failure_conflict">Your device is already connected with an account.</string>
<string name="login_error_login_missing">Please enter your login.</string>
<string name="login_error_login_too_short">Your login is too short.</string>
<string name="login_error_login_too_long">Your login is too long.</string>
<string name="login_error_login_invalid_chars">Your login contains invalid characters.</string>
@@ -51,14 +49,19 @@
<string name="collection_on_off">Participate now</string>
<string name="collection_button_continue">Let\'s get started</string>
<string name="favorite_explain_empty">Here you can view your favorite places, but apparently you did not add a place just yet.</string>
<string name="favorite_explain_search">To find a place, tap the magnifier icon in the upper right corner and enter the first few characters of its name. Then, tap on the place in the list of search results.</string>
<string name="favorite_explain_add">To add a favorite place, find the place and tap once on the button with the heart icon. To remove the place, tap the heart icon again.</string>
<string name="favorite_explain_drawer">You can find more features in the navigation menu. To open the menu, swipe your finger from the leftmost corner of your screen to the right or tap the menu icon in the upper left corner.</string>
<!-- Settings -->
<string name="setting_category_privacy">Privacy</string>
<string name="setting_privacy_measure_title">Measurements</string>
<string name="setting_privacy_measure_summary">Enables the service to perform measurements in the background. If disabled, the application will no longer perform and upload measurements.</string>
<string name="setting_privacy_reset_title">Reset</string>
<string name="setting_privacy_reset_summary">Removes all app data stored on your device and unregisters the device. After deletion, you will have to re-register your device.</string>
<string name="setting_privacy_reset_message">Do you really want remove all app data? This cannot be undone.</string>
<string name="setting_privacy_reset_message">Do you really want remove ALL data? You cannot undo this later!</string>
<string name="setting_category_notification">Notifications</string>
<string name="setting_notification_app_title">Application</string>
<string name="setting_notification_app_summary">Tap to control which app notifications are displayed in your notification area while the app is running.</string>
@@ -72,12 +75,22 @@
<string name="setting_about_build_title">Version</string>
<string name="setting_about_build_summary">$code$ | $version$ @ $build$</string>
<string name="setting_category_development">Development</string>
<string name="setting_development_device">Device Infos</string>
<string name="setting_development_token">Device Token</string>
<string name="setting_mowesta_url_title">MoWeSta Url</string>
<string name="setting_mowesta_url_summary">Sets the url to the MoWeSta api that is used by the app\'s HTTP client.</string>
<string name="setting_development_mode_enter">You are now in development mode.</string>
<string name="setting_development_mode_leave">You are now back in normal mode.</string>
<string name="setting_development_device">Device Info</string>
<string name="setting_development_token">Device Key</string>
<string name="setting_mowesta_url_title">Service Address</string>
<string name="setting_mowesta_url_summary">Sets the URL to the MoWeSta API that is used by the app\'s HTTP client.</string>
<string name="setting_development_clear_title">Clear Cache</string>
<string name="setting_development_clear_summary">Clears all cached location information from the device.</string>
<string name="setting_development_clear_message">Location cache cleared.</string>
<string name="setting_development_mode_enter">You are now in developer mode.</string>
<string name="setting_development_mode_leave">You are now back in user mode.</string>
<string name="setting_development_cache_title">Use Cache</string>
<string name="setting_development_cache_summary">Consider the local cache as a source of location information.</string>
<string name="setting_development_gps_title">Use Gps</string>
<string name="setting_development_gps_summary">Consider the built-in GPS as a source of location information.</string>
<string name="setting_development_net_title">Use Net</string>
<string name="setting_development_net_summary">Consider the network as a source of location information.</string>
<string name="direction_east">East</string>
<string name="direction_north">North</string>
@@ -139,8 +152,6 @@
<string name="label_local_time">Local Time</string>
<string name="label_source">Source</string>
<string name="label_time">Time</string>
<string name="label_date">Date</string>
<string name="label_temperature">Temperature</string>
<string name="label_wind_speed">Wind Speed</string>
<string name="label_cloud_coverage">Cloud Coverage</string>
@@ -148,8 +159,6 @@
<string name="label_humidity">Humidity</string>
<string name="label_snow_depth">Snow Depth</string>
<string name="label_precipitation">Precipitation</string>
<string name="label_longitude">Longitude</string>
<string name="label_latitude">Latitude</string>
<string name="label_altitude">Altitude</string>
<string name="label_name">Name</string>
@@ -184,6 +193,7 @@
<string name="city_info_day">Day</string>
<string name="city_info_time">Time</string>
<string name="city_info_hour">Hour</string>
<string name="label_station">Weather station</string>
<string name="label_full_day">Full day</string>
<string name="label_morning">Morning</string>
<string name="label_afternoon">Afternoon</string>
@@ -204,6 +214,9 @@
<string name="action_wikipedia">Open in Wikipedia </string>
<string name="action_refresh">Refresh</string>
<string name="action_device_add">Add device</string>
<string name="action_switch_to_fahrenheit">Show as Fahrenheit</string>
<string name="action_switch_to_celsius">Show as Celsius</string>
<string name="action_customize">Customize view</string>
<string name="snackbar_error">Failed to load data.</string>
<string name="snackbar_reload">Reload</string>
+1 -24
View File
@@ -1,30 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- text styles -->
<style name="text_medium" parent="TextAppearance.AppCompat.Medium">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">18sp</item>
</style>
<style name="text_small" parent="TextAppearance.AppCompat.Small">
<item name="android:textColor">@color/black</item>
</style>
<style name="text_medium_inverse" parent="TextAppearance.AppCompat.Medium.Inverse">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">18sp</item>
</style>
<style name="text_small_hyperlink" parent="text_small">
<item name="android:textColor">@color/colorPrimary</item>
<item name="android:textStyle">bold</item>
</style>
<!-- button styles -->
<style name="button" parent="Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/colorPrimaryLight</item>
<item name="android:textColor">@android:color/white</item>
</style>
<style name="button_highlighted" parent="@style/button">
<item name="colorButtonNormal">@color/colorAccentLight</item>
<item name="android:textColor">@android:color/black</item>
</style>
</resources>
@@ -40,8 +40,4 @@
<item name="android:textColor">@color/colorAccent</item>
</style>
<style name="settingsTheme" parent="PreferenceThemeOverlay">
<item name="android:textAppearanceLarge">@style/text_medium</item>
<item name="android:textAppearanceLargeInverse">@style/text_medium_inverse</item>
</style>
</resources>
+24 -2
View File
@@ -3,7 +3,7 @@
<PreferenceCategory android:title="@string/setting_category_privacy" >
<CheckBoxPreference
android:icon="@drawable/ic_gps_fixed_black_24dp"
android:icon="@drawable/ic_baseline_ac_unit_24"
android:key="privacy_measure"
android:defaultValue="@bool/privacy_measure_default"
android:summary="@string/setting_privacy_measure_summary"
@@ -61,7 +61,29 @@
android:key="mowesta_url"
android:title="@string/setting_mowesta_url_title"
android:summary="@string/setting_mowesta_url_summary" />
<Preference
android:icon="@drawable/ic_baseline_delete_outline_24"
android:key="development_clear_cache"
android:title="@string/setting_development_clear_title"
android:summary="@string/setting_development_clear_summary"/>
<CheckBoxPreference
android:icon="@drawable/ic_baseline_storage_24"
android:key="mowesta_sdk_use_cache"
android:defaultValue="@bool/mowesta_sdk_use_cache_default"
android:summary="@string/setting_development_cache_summary"
android:title="@string/setting_development_cache_title" />
<CheckBoxPreference
android:icon="@drawable/ic_gps_fixed_black_24dp"
android:key="mowesta_sdk_use_gps"
android:defaultValue="@bool/mowesta_sdk_use_gps_default"
android:summary="@string/setting_development_gps_summary"
android:title="@string/setting_development_gps_title" />
<CheckBoxPreference
android:icon="@drawable/ic_baseline_wifi_24"
android:key="mowesta_sdk_use_network"
android:defaultValue="@bool/mowesta_sdk_use_network_default"
android:summary="@string/setting_development_net_summary"
android:title="@string/setting_development_net_title" />
</PreferenceCategory>
</PreferenceScreen>
+1 -1
View File
@@ -27,7 +27,7 @@ android {
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(":android-feign")
api project(":android-feign")
implementation "androidx.appcompat:appcompat:${versionAndroidXAppcompat}"
@@ -115,6 +115,15 @@ public abstract class BufferDatabase extends RoomDatabase {
return result;
}
/**
* Clears all data from the database.
*/
@Transaction
public void clearAll() {
deleteData();
deleteMeasurements();
}
// methods used for testing
/**
@@ -187,6 +196,19 @@ public abstract class BufferDatabase extends RoomDatabase {
*/
@Query("select * from data where measurement=:measurement")
abstract List<DataEntity> getDataForMeasurement(long measurement);
/**
* Deletes all measurements without their data.
*/
@Query("delete from measurement")
abstract void deleteMeasurements();
/**
* Deletes all data without their measurements.
*/
@Query("delete from data")
abstract void deleteData();
}
@@ -0,0 +1,90 @@
package com.mowesta.android.sdk.task;
import android.os.AsyncTask;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mowesta.android.sdk.SdkRepository;
import com.mowesta.android.sdk.database.LocationEntity;
import com.mowesta.android.sdk.database.NetworkEntity;
import java.util.List;
/**
* A task that clears the location cache and optionally the buffer database.
*
* @author Marcus
*/
public class ClearTask extends AsyncTask<Void, Void, Void> {
/**
* An interface to synchronize with the task completion.
*/
public interface OnCompletionListener {
/**
* Called to signal the task completion.
*/
void onCompletion();
}
/**
* The log tag.
*/
private static final String TAG = "ClearTask";
/**
* The repository to get hold of the database.
*/
@NonNull private SdkRepository repository;
/**
* The completion listener.
*/
@Nullable private OnCompletionListener completionListener;
/**
* Flag to control whether to delete the measurements as well.
*/
private boolean measurements;
/**
* Creates a new task to clear the cache and optionally the measurements.
*
* @param repository The repository.
* @param withMeasurements Flag to control whether the measurements should also be wiped.
* @param completionListener The optional completion listener.
*/
public ClearTask(@NonNull SdkRepository repository, boolean withMeasurements, @Nullable OnCompletionListener completionListener) {
this.repository = repository;
this.completionListener = completionListener;
this.measurements = withMeasurements;
}
/**
* Executes the task on the thread pool executor.
*/
public void execute() {
executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
@Override
protected Void doInBackground(Void... voids) {
Log.d(TAG, "Clearing the cache database.");
repository.getCacheDatabase().getAccessor().clearAll();
if (measurements) {
Log.d(TAG, "Clearing the buffer database.");
repository.getBufferDatabase().getAccessor().clearAll();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
if (completionListener != null)
completionListener.onCompletion();
}
}
@@ -80,7 +80,7 @@ public interface IDeviceService {
})
@PermitAll
@RolesAllowed({Roles.DEVICE, Roles.USER})
Response setCurrentDeviceUser(@NotNull @Valid Device device);
Response setCurrentDeviceUser(@ApiParam(value = "The device data.", required = true)@NotNull @Valid Device device);
/**
* Returns the current device.
BIN
View File
Binary file not shown.