16 Commits
Author SHA1 Message Date
Marcus Handte 220325f1ed Release 1.0.6
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-16 23:24:50 +02:00
handte 124f570e9d Prevent non-finite sensor values in sdk.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-16 21:04:10 +02:00
handte 77a0ec44c6 Improve handling of broken measurements.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-16 20:40:01 +02:00
handte 7e93d8bcdd Extend video api model, reorder app videos.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-16 20:15:47 +02:00
handte 585bfc7635 Disable non-release deployments, add color scale tool.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-16 09:37:00 +02:00
handte 61501c54ba Update to 1.0.6-SNAPSHOT
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-14 23:00:47 +02:00
handte f4c9999368 Release 1.0.5
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-14 22:24:19 +02:00
handte b681689f09 Update to 1.0.5-SNAPSHOT
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-13 00:16:50 +02:00
Marcus Handte f8ff826106 Release 1.0.4
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-12 22:22:11 +02:00
handte dfb0469fa6 Update to 1.0.3-SNAPSHOT
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-12 00:21:22 +02:00
handte d293bd66ef Release 1.0.2
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-12 00:10:56 +02:00
handte 9a7a94415d Release 1.0.1
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-11 23:35:27 +02:00
Marcus Handte e053eff8bf Fixes and improvements in apps.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-11 00:57:24 +02:00
Adriano Markovic 4dd7044fc2 Added the weather station marker on the city view map.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-10 15:26:56 +02:00
handte 3a11a2acc6 Remove trailing full stops in emails.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-10 12:24:18 +02:00
Marcus Handte f26369a64f Update to 1.0.1-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-09 23:57:29 +02:00
176 changed files with 2608 additions and 666 deletions
Vendored
+9 -6
View File
@@ -21,6 +21,7 @@ node {
}
def version = ''
def release = false;
// configure the deployer based on the version
stage('Configure') {
@@ -28,10 +29,11 @@ node {
println "Version is: '${version}'"
if (version.endsWith("-SNAPSHOT")) {
println "Using internal-snapshots for publication."
gradleBuild.deployer server: server, repo: 'internal-snapshots'
gradleBuild.deployer server: server, repo: 'internal-snapshots'
} else {
println "Using internal-releases for publication."
gradleBuild.deployer server: server, repo: 'internal-releases'
gradleBuild.deployer server: server, repo: 'internal-releases'
release = true;
}
}
@@ -45,25 +47,26 @@ node {
// deploy the maven publications to artifactory
stage ('Publish') {
if (env.BRANCH_NAME == "master") {
if (env.BRANCH_NAME == "master" && release) {
withCredentials([string(credentialsId: 'mowesta-keystore-password', variable: 'PASSWD')]) {
def switches = "-Djenkins.build.number=${env.BUILD_NUMBER} -Dandroid.keystore.password=${PASSWD}".toString()
gradleInfo = gradleBuild.run buildFile: 'build.gradle', tasks: 'artifactoryPublish', switches: switches
}
} else {
echo "Skipping deployment for non-master branch."
echo "Skipping deployment for non-release version or non-master branch."
}
}
// deploy the build output on the server
stage ('Deploy') {
if (env.BRANCH_NAME == "master") {
// release = true; // uncomment to temporary enable snapshot deployments
if (env.BRANCH_NAME == "master" && release) {
withCredentials([sshUserPrivateKey(credentialsId: "mowesta-server-key", keyFileVariable: "keyfile")]) {
sh "scp -i ${keyfile} site-ear/build/libs/site-ear-${version}.ear wildfly@apps.nes.uni-due.de:/opt/wildfly-17-mowesta/standalone/deployments/mowesta.ear"
sh "scp -i ${keyfile} android-app/build/outputs/apk/release/*.apk wildfly@apps.nes.uni-due.de:/opt/android/mowesta/"
}
} else {
echo "Skipping deployment for non-master branch."
echo "Skipping deployment for non-release version or non-master branch."
}
}
+8 -5
View File
@@ -20,6 +20,7 @@ ext {
versionAndroidXViewpager = '1.0.0'
versionGoogleMaterial = '1.1.0'
versionAndroidXSwipeRefresh = '1.0.0'
versionExoPlayer = '2.11.5'
}
@@ -51,6 +52,10 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-process:${versionAndroidXLifecycle}"
implementation "com.google.android.exoplayer:exoplayer-core:${versionExoPlayer}"
implementation "com.google.android.exoplayer:exoplayer-ui:${versionExoPlayer}"
implementation "androidx.room:room-runtime:${versionAndroidXRoom}"
annotationProcessor "androidx.room:room-compiler:${versionAndroidXRoom}"
testImplementation "androidx.room:room-testing:${versionAndroidXRoom}"
@@ -81,14 +86,13 @@ android {
compileSdkVersion 29
defaultConfig {
applicationId "com.mowesta.android.app"
minSdkVersion 23
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionCode 6
versionName "${version}"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resValue "string", "application_long", "MoWeSta"
resValue "string", "application_short", "MoWeSta"
multiDexEnabled true
vectorDrawables {
useSupportLibrary = true
@@ -115,8 +119,7 @@ android {
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-dbg"
resValue "string", "application_long", "MoWeStaDbg"
resValue "string", "application_short", "MWSDBG"
resValue "string", "application_long", "MoWeSta (Debug)"
}
}
+3
View File
@@ -14,6 +14,9 @@
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-sdk tools:overrideLibrary="androidx.security" />
<application android:name=".MowestaApp"
tools:targetApi="24"
android:networkSecurityConfig="@xml/network"
@@ -2,6 +2,7 @@ package com.mowesta.android.app;
import android.content.Context;
import com.google.android.exoplayer2.upstream.cache.Cache;
import com.mowesta.android.app.repository.ClientFactory;
import com.mowesta.android.app.repository.DeviceRepository;
import com.mowesta.android.app.repository.FavoriteRepository;
@@ -50,5 +51,11 @@ public interface IApp {
*/
ClientFactory getClientFactory();
/**
* Returns the exo player media cache.
*
* @return The cache to store videos.
*/
Cache getMediaCache();
}
@@ -1,21 +1,31 @@
package com.mowesta.android.app;
import android.content.Intent;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.net.http.HttpResponseCache;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.Manifest;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.PermissionChecker;
import androidx.navigation.NavDeepLinkBuilder;
import androidx.navigation.NavDirections;
import androidx.navigation.Navigation;
import androidx.preference.PreferenceManager;
import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
import com.mowesta.android.app.database.FavoriteDatabase;
import com.mowesta.android.app.generated.callback.OnClickListener;
import com.mowesta.android.app.repository.UserCredentials;
import com.mowesta.android.app.task.DatabaseTask;
import com.mowesta.android.app.task.RefreshTask;
@@ -106,6 +116,13 @@ public class MowestaActivity extends AppCompatActivity {
installHttpCache();
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// got to navigation drawer when user presses notification
setIntent(intent);
Navigation.findNavController(this, R.id.navigation_app).navigate(R.id.action_drawer);
}
@Override
protected void onResume() {
@@ -155,7 +172,7 @@ public class MowestaActivity extends AppCompatActivity {
*/
private void requestPermissions() {
Log.d(TAG, "Requesting permissions.");
ActivityCompat.requestPermissions(this, PermissionUtil.getPermissions(this), CODE_REQUEST_PERMISSIONS);
ActivityCompat.requestPermissions(this, PermissionUtil.getNonGrantedPermissions(this), CODE_REQUEST_PERMISSIONS);
}
/**
@@ -179,6 +196,21 @@ public class MowestaActivity extends AppCompatActivity {
Log.d(TAG, "Permission result: " + b.toString());
if (!granted) {
settings.setPrivacyMeasure(false);
View coordinator = findViewById(R.id.layout_coordinator);
Snackbar.make(coordinator, R.string.message_no_permission, Snackbar.LENGTH_LONG )
.setAction(R.string.button_configure, (view) -> {
// go to app settings
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
try {
startActivity(intent);
} catch (Exception e) {
Snackbar.make(coordinator, R.string.message_configure_failed,
Snackbar.LENGTH_SHORT).show();
}
}).show();
} else {
MowestaService.startService(this);
}
@@ -5,13 +5,16 @@ import android.content.Context;
import android.content.SharedPreferences;
import androidx.preference.PreferenceManager;
import com.mowesta.android.app.database.FavoriteDatabase;
import com.google.android.exoplayer2.database.ExoDatabaseProvider;
import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.android.exoplayer2.upstream.cache.LeastRecentlyUsedCacheEvictor;
import com.google.android.exoplayer2.upstream.cache.SimpleCache;
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;
import java.io.File;
/**
* Te main application of the application that is used
@@ -37,6 +40,11 @@ public class MowestaApp extends Application implements IApp {
*/
protected FavoriteRepository favoriteRepository;
/**
* The cache to store videos.
*/
protected SimpleCache mediaCache;
@Override
public void onCreate() {
@@ -79,5 +87,14 @@ public class MowestaApp extends Application implements IApp {
return new ClientFactory(basePath);
}
@Override
public Cache getMediaCache() {
if (mediaCache == null) {
mediaCache = new SimpleCache(new File(this.getCacheDir(), "videos"),
new LeastRecentlyUsedCacheEvictor(25 * 1000 * 1000),
new ExoDatabaseProvider(getContext()));
}
return mediaCache;
}
}
@@ -72,6 +72,11 @@ public class MowestaSettings extends SdkSettings {
*/
public static final String SHOW_PRESSURE = "show_pressure";
/**
* The key to a boolean to show/hide the scale on videos.
*/
public static final String SHOW_SCALE = "show_scale";
/**
* Creates the settings with the context.
*
@@ -1,10 +1,8 @@
package com.mowesta.android.app.fragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@@ -14,6 +12,7 @@ import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
@@ -26,6 +25,8 @@ import com.mowesta.android.app.databinding.ViewConditionBinding;
import com.mowesta.android.app.model.CityViewModel;
import com.mowesta.android.app.model.ConditionViewModel;
import com.mowesta.android.app.model.SummaryViewModel;
import com.mowesta.android.app.util.TabletUtil;
import com.mowesta.android.feign.model.WeatherCondition;
import java.util.List;
@@ -49,7 +50,23 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ViewPager2 pager = view.findViewById(R.id.pager);
CityViewModel model = getCityViewModel();
pager.setAdapter(new ForecastAdapter(this));
model.getNavigation().observe(getViewLifecycleOwner(), (request) -> {
if (request != null) {
switch (request.getType()) {
case DAY:
pager.setCurrentItem(0, true);
break;
case TIME:
pager.setCurrentItem(1, true);
break;
case HOUR:
pager.setCurrentItem(2, true);
break;
}
}
});
TabLayout tabs = view.findViewById(R.id.tabs);
new TabLayoutMediator(tabs, pager, (tab, position) -> {
switch (position) {
@@ -103,6 +120,9 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
*/
public static class ForecastRecyclerFragment extends CityFragment.ChildFragment {
/** A handler to post updates. */
private Handler handler = new Handler();
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -118,18 +138,108 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
int page = getArguments().getInt("page");
switch (page) {
case 0:
recyclerView.setAdapter(new SummaryAdapter(getViewLifecycleOwner(), getCityViewModel().getDay()));
TabletUtil.setGridLayout(recyclerView, 400);
recyclerView.setAdapter(new SummaryAdapter(getViewLifecycleOwner(), model.getDay(), (summary) -> {
if (summary == null || summary.getFirstCondition() == null) return;
long time = summary.getFirstCondition().getTime();
List<SummaryViewModel> models = model.getTime().getValue();
for (int i = 0; i < models.size(); i++) {
SummaryViewModel s = models.get(i);
if (s.getFirstCondition() != null && s.getFirstCondition().getTime() == time) {
model.getNavigation().setValue(new CityViewModel.NavigationRequest(CityViewModel.ForecastType.TIME, i));
break;
}
}
}));
model.getNavigation().observe(getViewLifecycleOwner(), (request) -> {
if (request == null) return;
if (request.getType() == CityViewModel.ForecastType.DAY) {
recyclerView.post(() -> {
scrollRecyclerViewToPosition(recyclerView, request.getPosition());
model.getNavigation().setValue(null);
});
}
});
break;
case 1:
recyclerView.setAdapter(new SummaryAdapter(getViewLifecycleOwner(), getCityViewModel().getTime()));
TabletUtil.setGridLayout(recyclerView, 400);
recyclerView.setAdapter(new SummaryAdapter(getViewLifecycleOwner(), model.getTime(), (summary) -> {
if (summary == null || summary.getFirstCondition() == null) return;
long time = summary.getFirstCondition().getTime();
List<ConditionViewModel> models = model.getHour().getValue();
for (int i = 0; i < models.size(); i++) {
ConditionViewModel c = models.get(i);
WeatherCondition wc = c.getCondition().getValue();
if (wc != null && wc.getTime() == time) {
model.getNavigation().setValue(new CityViewModel.NavigationRequest(CityViewModel.ForecastType.HOUR, i));
break;
}
}
}));
model.getNavigation().observe(getViewLifecycleOwner(), (request) -> {
if (request == null) return;
if (request.getType() == CityViewModel.ForecastType.TIME) {
recyclerView.post(() -> {
scrollRecyclerViewToPosition(recyclerView, request.getPosition());
model.getNavigation().setValue(null);
});
}
});
break;
default:
recyclerView.setAdapter(new ConditionAdapter(getViewLifecycleOwner(), getCityViewModel().getHour()));
TabletUtil.setGridLayout(recyclerView, 300);
recyclerView.setAdapter(new ConditionAdapter(getViewLifecycleOwner(), getCityViewModel().getHour(), (condition) -> {
if (condition == null || condition.getCondition().getValue() == null) return;
long time = condition.getCondition().getValue().getTime();
List<SummaryViewModel> models = model.getDay().getValue();
for (int i = 0; i < models.size(); i++) {
SummaryViewModel s = models.get(i);
if (s.getFirstCondition() != null && s.getLastCondition() != null
&& s.getLastCondition().getTime() >= time && s.getFirstCondition().getTime() <= time) {
model.getNavigation().setValue(new CityViewModel.NavigationRequest(CityViewModel.ForecastType.DAY, i));
break;
}
}
}));
model.getNavigation().observe(getViewLifecycleOwner(), (request) -> {
if (request == null) return;
if (request.getType() == CityViewModel.ForecastType.HOUR) {
recyclerView.post(() -> {
scrollRecyclerViewToPosition(recyclerView, request.getPosition());
model.getNavigation().setValue(null);
});
}
});
break;
}
}
}
/**
* Scrolls a recycler view to the specified position using a smooth scroll effect
* that ist limited in motion.
*
* @param view The view.
* @param position The position.
*/
private static void scrollRecyclerViewToPosition(RecyclerView view, int position) {
GridLayoutManager layout = (GridLayoutManager)view.getLayoutManager();
int current = layout.findFirstVisibleItemPosition();
int last = layout.findLastVisibleItemPosition();
int diff = Math.max(1, last - current) * 3;
if (Math.abs(current - position) > diff) {
if (current < position) current = position - diff;
else current = position + diff;
}
view.scrollToPosition(current);
view.post(() -> {
view.smoothScrollToPosition(position);
});
}
/**
* A recycler view adapter that can display a list of weather summaries.
*
@@ -145,10 +255,22 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
* The live data that provides updates.
*/
private LiveData<List<SummaryViewModel>> model;
/**
* The click listener for the summary model.
*/
private SummaryViewModel.OnSummarySelectedListener listener;
public SummaryAdapter(LifecycleOwner lifecycleOwner, LiveData<List<SummaryViewModel>> model) {
/**
* Creates a new adapter.
*
* @param lifecycleOwner The lifecycle owner.
* @param model The model to observe.
* @param listener The listener to handle clicks.
*/
public SummaryAdapter(LifecycleOwner lifecycleOwner, LiveData<List<SummaryViewModel>> model, SummaryViewModel.OnSummarySelectedListener listener) {
this.lifecycleOwner = lifecycleOwner;
this.model = model;
this.listener = listener;
this.model.observe(lifecycleOwner, (data)-> {
this.notifyDataSetChanged();
});
@@ -159,6 +281,7 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
public SummaryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ViewSummaryBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.view_summary, parent, false);
binding.setLifecycleOwner(lifecycleOwner);
binding.setListener(listener);
SummaryViewHolder holder = new SummaryViewHolder(binding);
return holder;
}
@@ -226,15 +349,21 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
*/
private LiveData<List<ConditionViewModel>> model;
/**
* The listener for the cards.
*/
private ConditionViewModel.OnConditionSelectedListener listener;
/**
* Creates a new adapter for weather conditions.
*
* @param lifecycleOwner The lifecycle owner.
* @param model The list of weather conditions to show.
*/
public ConditionAdapter(LifecycleOwner lifecycleOwner, LiveData<List<ConditionViewModel>> model) {
public ConditionAdapter(LifecycleOwner lifecycleOwner, LiveData<List<ConditionViewModel>> model, ConditionViewModel.OnConditionSelectedListener listener) {
this.lifecycleOwner = lifecycleOwner;
this.model = model;
this.listener = listener;
this.model.observe(lifecycleOwner, (data)-> {
this.notifyDataSetChanged();
});
@@ -245,6 +374,7 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
public ConditionViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
ViewConditionBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.view_condition, parent, false);
binding.setLifecycleOwner(lifecycleOwner);
binding.setListener(listener);
ConditionViewHolder holder = new ConditionViewHolder(binding);
return holder;
}
@@ -46,6 +46,12 @@ public class CityInfoFragment extends CityFragment.ChildFragment {
FragmentCityInfoBinding binding = DataBindingUtil.inflate(inflater, R.layout.fragment_city_info, container, false);
MapView mapView = binding.getRoot().findViewById(R.id.map_detail);
MapViewUtil.setupInteractiveMap(mapView);
// reduce brightness of map (technically, we should generate a night mode in leafless but this needs to be fixed in the library)
if (getResources().getBoolean(R.bool.dark_mode)) {
mapView.setAlpha(0.5f);
} else {
mapView.setAlpha(1f);
}
CityViewModel model = new ViewModelProvider(getParentFragment().getParentFragment()).get(CityViewModel.class);
ConditionViewModel condition = new ViewModelProvider(this).get(ConditionViewModel.class);
Runnable updateCondition = () -> {
@@ -77,7 +83,7 @@ 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);
NavController appController = Navigation.findNavController(getActivity(), R.id.navigation_app);
binding.setStationListener(new CityViewModel.OnStationSelectedListener() {
@Override
public void onStationSelected(WeatherStation station) {
@@ -85,9 +91,13 @@ public class CityInfoFragment extends CityFragment.ChildFragment {
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());
appController.navigate(R.id.destination_station, bundle, opts.build());
}
});
NavController cityController = Navigation.findNavController(getActivity(), R.id.navigation_city);
binding.setConditionListener(m -> {
cityController.navigate(R.id.destination_city_forecast);
});
binding.setLifecycleOwner(getViewLifecycleOwner());
return binding.getRoot();
}
@@ -11,6 +11,7 @@ import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.recyclerview.widget.RecyclerView;
@@ -23,7 +24,9 @@ import com.mowesta.android.app.R;
import com.mowesta.android.app.databinding.ViewVideoBinding;
import com.mowesta.android.app.model.CityViewModel;
import com.mowesta.android.app.model.VideoViewModel;
import com.mowesta.android.app.util.TabletUtil;
import java.util.ArrayList;
import java.util.List;
/**
@@ -43,21 +46,33 @@ public class CityVideoFragment extends CityFragment.ChildFragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ViewPager2 pager = view.findViewById(R.id.pager);
pager.setAdapter(new VideoAdpter(this));
TabLayout tabs = view.findViewById(R.id.tabs);
new TabLayoutMediator(tabs, pager, (tab, position) -> {
switch (position) {
case 0:
tab.setText(R.string.video_source_icon_global);
break;
case 1:
tab.setText(R.string.video_source_icon_europe);
break;
default:
tab.setText(R.string.video_source_cosmo_europe);
break;
}
}).attach();
List<Integer> pages = new ArrayList<>();
CityViewModel model = getCityViewModel();
Observer<List<VideoViewModel>> videoObserver = (v) -> {
pages.clear();
if (model.getIconGlobal().getValue().size() > 0) pages.add(0, 0);
if (model.getIconEurope().getValue().size() > 0) pages.add(0, 1);
if (model.getCosmoEurope().getValue().size() > 0) pages.add(0, 2);
pager.setAdapter(new VideoAdpter(this, pages));
new TabLayoutMediator(tabs, pager, (tab, position) -> {
int page = pages.get(position);
switch (page) {
case 0:
tab.setText(R.string.video_source_icon_global);
break;
case 1:
tab.setText(R.string.video_source_icon_europe);
break;
default:
tab.setText(R.string.video_source_cosmo_europe);
break;
}
}).attach();
};
model.getCosmoEurope().observe(getViewLifecycleOwner(), videoObserver);
model.getIconEurope().observe(getViewLifecycleOwner(), videoObserver);
model.getIconGlobal().observe(getViewLifecycleOwner(), videoObserver);
}
/**
@@ -67,8 +82,11 @@ public class CityVideoFragment extends CityFragment.ChildFragment {
*/
private static class VideoAdpter extends FragmentStateAdapter {
public VideoAdpter(@NonNull Fragment fragment) {
private List<Integer> pages;
public VideoAdpter(@NonNull Fragment fragment, @NonNull List<Integer> pages) {
super(fragment);
this.pages = pages;
}
@NonNull
@@ -76,14 +94,14 @@ public class CityVideoFragment extends CityFragment.ChildFragment {
public Fragment createFragment(int position) {
VideoRecyclerFragment fragment = new VideoRecyclerFragment();
Bundle bundle = new Bundle();
bundle.putInt("page", position);
bundle.putInt("page", pages.get(position));
fragment.setArguments(bundle);
return fragment;
}
@Override
public int getItemCount() {
return 3;
return pages.size();
}
}
@@ -105,6 +123,7 @@ public class CityVideoFragment extends CityFragment.ChildFragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RecyclerView recyclerView = getView().findViewById(R.id.recycler);
TabletUtil.setGridLayout(recyclerView, 400);
CityViewModel model = getCityViewModel();
int page = getArguments().getInt("page");
VideoViewModel.OnVideoSelectedListener listener = (video) -> {
@@ -1,5 +1,7 @@
package com.mowesta.android.app.fragment;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@@ -13,6 +15,8 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -23,7 +27,9 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import androidx.cursoradapter.widget.CursorAdapter;
import androidx.customview.widget.Openable;
import androidx.databinding.DataBindingUtil;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModelProvider;
import androidx.navigation.NavController;
@@ -41,6 +47,7 @@ import com.mowesta.android.app.model.AbstractNetworkViewModel;
import com.mowesta.android.app.model.DrawerViewModel;
import com.mowesta.android.app.model.LocationViewModel;
import com.mowesta.android.app.repository.UserCredentials;
import com.mowesta.android.app.util.DisplayUtils;
import com.mowesta.android.feign.model.LocationHierarchy;
import com.mowesta.android.feign.model.LocationHierarchyPage;
@@ -75,6 +82,28 @@ public class DrawerFragment extends AbstractNetworkFragment {
setHasOptionsMenu(true);
}
@Override
public void onResume() {
super.onResume();
// navigate to settings, if user pressed notification
handleNotificationIntent();
}
/**
* Checks if the intent was generated by the background service and
* opens the settings screen, if this is the case
*/
private void handleNotificationIntent() {
Intent intent = getActivity().getIntent();
if (intent.hasExtra(getString(R.string.mowesta_sdk_notification_activity_extra_name))) {
String value = intent.getStringExtra(getString(R.string.mowesta_sdk_notification_activity_extra_name));
if (value != null && value.equals(getString(R.string.mowesta_sdk_notification_activity_extra_value))) {
Navigation.findNavController(getView().findViewById(R.id.navigation_drawer)).navigate(R.id.destination_settings);
getActivity().setIntent(new Intent());
}
}
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -93,7 +122,7 @@ public class DrawerFragment extends AbstractNetworkFragment {
SearchView search = (SearchView)menu.findItem(R.id.action_search).getActionView();
search.setQueryHint(getString(R.string.action_search));
SearchView.SearchAutoComplete complete = search.findViewById(androidx.appcompat.R.id.search_src_text);
complete.setDropDownBackgroundResource(R.color.white);
complete.setDropDownBackgroundResource(R.color.bg_search);
final DrawerViewModel model = new ViewModelProvider(this).get(DrawerViewModel.class);
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
@@ -155,7 +184,18 @@ public class DrawerFragment extends AbstractNetworkFragment {
super.onViewCreated(view, savedInstanceState);
NavController navController = Navigation.findNavController(view.findViewById(R.id.navigation_drawer));
AppBarConfiguration.Builder builder = new AppBarConfiguration.Builder(R.id.destination_favorites);
builder.setOpenableLayout(view.findViewById(R.id.layout_drawer));
View drawer = view.findViewById(R.id.layout_drawer);
if (drawer != null) builder.setOpenableLayout((Openable)drawer);
View sun = view.findViewById(R.id.logo_sun);
AnimatorSet set = new AnimatorSet();
ObjectAnimator first = ObjectAnimator.ofFloat(sun, "translationY", DisplayUtils.dpToPixels(getContext(), 120), 0f);
first.setDuration(750);
first.setInterpolator(new OvershootInterpolator());
ObjectAnimator last = ObjectAnimator.ofFloat(sun, "translationX", DisplayUtils.dpToPixels(getContext(), 120), 0f);
last.setInterpolator(new AccelerateDecelerateInterpolator());
last.setDuration(750);
set.playTogether(first, last);
set.start();
Toolbar toolbar = view.findViewById(R.id.toolbar);
CollapsingToolbarLayout layout = view.findViewById(R.id.layout_toolbar);
NavigationUI.setupWithNavController(layout, toolbar, navController, builder.build());
@@ -25,6 +25,7 @@ import com.mowesta.android.app.database.Favorite;
import com.mowesta.android.app.databinding.ViewFavoriteEntryBinding;
import com.mowesta.android.app.model.FavoritesViewModel;
import com.mowesta.android.app.model.FavoritesViewModel.OnFavoriteSelectedListener;
import com.mowesta.android.app.util.TabletUtil;
import java.util.List;
@@ -51,6 +52,7 @@ public class FavoritesFragment extends Fragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
RecyclerView recyclerView = view.findViewById(R.id.recycler);
TabletUtil.setGridLayout(recyclerView, 300);
SwipeRefreshLayout swipeRefreshLayout = view.findViewById(R.id.swipe_refresh);
FavoritesViewModel model = new ViewModelProvider(getActivity()).get(FavoritesViewModel.class);
model.getRefreshing().observe(getViewLifecycleOwner(), (refreshing) -> {
@@ -155,6 +155,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
settings = new MowestaSettings(getActivity().getApplication());
updateBuild();
updateNotification();
bindDevice();
bindReset();
bindTerms();
bindLicenses();
@@ -162,35 +163,6 @@ public class SettingsFragment extends PreferenceFragmentCompat {
return v;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Preference preferenceDevice = findPreference(KEY_DEVELOPMENT_DEVICE);
IApp app = (IApp)getActivity().getApplication();
DeviceRepository repo = app.getDeviceRepository();
repo.getDevice().observe(getViewLifecycleOwner(), (device) -> {
String value = "";
if (device != null) {
StringBuilder b = new StringBuilder();
b.append(device.getId());
b.append(" | ");
b.append(device.getManufacturer());
b.append(" | ");
b.append(device.getModel());
b.append(" | ");
b.append(device.getDevice());
value = b.toString();
}
preferenceDevice.setSummary(value);
});
Preference preferenceToken = findPreference(KEY_DEVELOPMENT_TOKEN);
repo.getHandle().observe(getViewLifecycleOwner(), (handle) -> {
String value = "";
if (handle != null) value = handle;
preferenceToken.setSummary(value);
});
}
private void updateMeasure() {
CheckBoxPreference preference = (CheckBoxPreference)findPreference(MowestaSettings.PRIVACY_MEASURE);
if (preference != null && preference.isChecked() != settings.isPrivacyMeasure()) {
@@ -308,6 +280,39 @@ public class SettingsFragment extends PreferenceFragmentCompat {
};
}
/**
* Updates the device and token preference based on the state of
* the repository.
*/
private void bindDevice() {
Preference preferenceDevice = findPreference(KEY_DEVELOPMENT_DEVICE);
IApp app = (IApp)getActivity().getApplication();
DeviceRepository repo = app.getDeviceRepository();
repo.getDevice().observe(getViewLifecycleOwner(), (device) -> {
String value = "";
if (device != null) {
StringBuilder b = new StringBuilder();
b.append(device.getId());
b.append(" | ");
b.append(device.getManufacturer());
b.append(" | ");
b.append(device.getModel());
b.append(" | ");
b.append(device.getDevice());
value = b.toString();
}
if (preferenceDevice != null)
preferenceDevice.setSummary(value);
});
Preference preferenceToken = findPreference(KEY_DEVELOPMENT_TOKEN);
repo.getHandle().observe(getViewLifecycleOwner(), (handle) -> {
String value = "";
if (handle != null) value = handle;
if (preferenceToken != null)
preferenceToken.setSummary(value);
});
}
/**
* Binds the listener to reset the device.
@@ -426,7 +431,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
MaterialAlertDialogBuilder b = new MaterialAlertDialogBuilder(getActivity());
b.setTitle(R.string.setting_privacy_reset_title);
b.setMessage(R.string.setting_privacy_reset_message);
b.setIcon(R.drawable.ic_delete_forever_black_24dp);
b.setIcon(R.drawable.ic_delete_forever_normal_24);
b.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -79,13 +79,13 @@ public class SplashFragment extends Fragment {
View subtitle = root.findViewById(R.id.splash_subtitle);
View world = root.findViewById(R.id.splash_world);
AnimatorSet set = new AnimatorSet();
ValueAnimator gradientAnimator = ValueAnimator.ofArgb(0xFF00695C, 0xFFABBDD1);
ValueAnimator gradientAnimator = ValueAnimator.ofFloat(0, 1);
gradientAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
gradientAnimator.setDuration(750);
int[] colors = new int[] { 0xFF00695C, 0xFF00695C };
drawable.setColors(colors);
gradientAnimator.addUpdateListener(animation -> {
int color = (int)animation.getAnimatedValue();
int color = interpolate((float)animation.getAnimatedValue(), 0xFF00695C, 0xFFCBCDD1);
colors[0] = color;
drawable.setColors(colors);
});
@@ -150,4 +150,27 @@ public class SplashFragment extends Fragment {
return !settings.isCollectionShown();
}
private static int interpolate(float fraction, int startInt, int endInt) {
float startA = ((startInt >> 24) & 0xff) / 255.0f;
float startR = ((startInt >> 16) & 0xff) / 255.0f;
float startG = ((startInt >> 8) & 0xff) / 255.0f;
float startB = ( startInt & 0xff) / 255.0f;
float endA = ((endInt >> 24) & 0xff) / 255.0f;
float endR = ((endInt >> 16) & 0xff) / 255.0f;
float endG = ((endInt >> 8) & 0xff) / 255.0f;
float endB = ( endInt & 0xff) / 255.0f;
float a = startA + fraction * (endA - startA);
float r = startR + fraction * (endR - startR);
float g = startG + fraction * (endG - startG);
float b = startB + fraction * (endB - startB);
return Math.max(0, Math.min(255, (int)(255 * a))) << 24 |
Math.max(0, Math.min(255, (int)(255 * r))) << 16 |
Math.max(0, Math.min(255, (int)(255 * g))) << 8 |
Math.max(0, Math.min(255, (int)(255 * b)));
}
}
@@ -1,6 +1,8 @@
package com.mowesta.android.app.fragment;
import android.media.MediaPlayer;
import android.app.Application;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -8,17 +10,37 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.MediaController;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.VideoView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.cache.CacheDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
import com.mowesta.android.app.IApp;
import com.mowesta.android.app.MowestaSettings;
import com.mowesta.android.app.R;
import com.mowesta.android.app.adapter.PreferenceLiveData;
import com.mowesta.android.app.model.AbstractNetworkViewModel;
import com.mowesta.android.app.task.ImageTask;
import com.mowesta.android.app.util.ContentScaler;
import com.mowesta.android.app.util.DateFormatter;
import com.mowesta.android.app.util.MercatorPositioner;
import com.mowesta.android.app.util.TimeUtils;
import com.mowesta.android.app.view.MarkerView;
import com.mowesta.android.feign.model.City;
@@ -31,7 +53,7 @@ import java.io.IOException;
*
* @author Marcus
*/
public class VideoFragment extends Fragment {
public class VideoFragment extends AbstractNetworkFragment {
/**
* The log tag.
@@ -107,7 +129,8 @@ public class VideoFragment extends Fragment {
* @param bundle The bundle.
* @return The arguments.
*/
public static @Nullable Args fromBundle(@NonNull Bundle bundle) {
public static @Nullable Args fromBundle(@Nullable Bundle bundle) {
if (bundle == null) return null;
WeatherVideo video = null;
City city = null;
ObjectMapper mapper = new ObjectMapper();
@@ -123,68 +146,82 @@ public class VideoFragment extends Fragment {
}
}
/**
* The video player.
*/
VideoView player;
/**
* The time overlay.
*/
TextView overlay;
/**
* The arguments.
*/
Args args;
private TextView overlay;
/**
* The handler for the timing.
*/
Handler handler = new Handler();
private Handler handler = new Handler();
/**
* The date formatter.
*/
DateFormatter formatter;
private DateFormatter formatter;
/**
* The timezone string.
*/
String timezone;
private String timezone;
/**
* The time utils for formatting.
*/
TimeUtils timeUtils;
private TimeUtils timeUtils;
/**
* The last position that we fetched from the player.
* The marker view to be updated upon changes.
*/
private int lastPosition;
private MarkerView marker;
/**
* Timer.
* The exoplayer view model.
*/
private ExoPlayerViewModel model;
/**
* The player.
*/
private PlayerView player;
/**
* The weather video to compute the timings.
*/
private WeatherVideo video;
/**
* Posts updates if the marker view size changes.
*/
View.OnLayoutChangeListener markerListener = new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
updateVideo(right - left, bottom - top);
}
};
/**
* A timer task to poll the video player for the current position.
*/
Runnable timer = () -> {
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) {
day = getString(dayRes);
} else {
day = formatter.asDate(time, timezone);
}
long lastPosition = model.exoPlayer.getCurrentPosition();
long secs = lastPosition / 1000;
double hps = video.getFph() / (double)video.getFps();
long hours = (long)(secs / hps);
long time = video.getTime() + (video.getStart() + hours) * 60 * 60 * 1000;
String day = timeUtils.getDayName(getContext(), time);
String hour = formatter.asTime(time, timezone);
overlay.setText(getResources().getString(R.string.format_two_lines, day, hour));
handler.postDelayed(this.timer, 500);
};
@Override
protected AbstractNetworkViewModel getNetworkViewModel() {
return new ViewModelProvider(this).get(ExoPlayerViewModel.class);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@@ -193,54 +230,213 @@ public class VideoFragment extends Fragment {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
model = new ViewModelProvider(this).get(ExoPlayerViewModel.class);
ImageButton zoomButton = view.findViewById(R.id.video_zoom);
player = view.findViewById(R.id.video_view);
player.setShowBuffering(PlayerView.SHOW_BUFFERING_ALWAYS);
overlay = view.findViewById(R.id.video_time);
MarkerView marker = view.findViewById(R.id.video_marker);
MediaController controller = new MediaController(view.getContext());
controller.setAnchorView(player);
player.setMediaController(controller);
if (getArguments() != null) {
args = Args.fromBundle(getArguments());
}
if (args == null) {
if (getActivity() != null) {
getActivity().onBackPressed();
}
} else {
marker.setBounds(args.getVideo().getNorthEast().getLongitude(), args.getVideo().getNorthEast().getLatitude(),
args.getVideo().getSouthWest().getLongitude(), args.getVideo().getSouthWest().getLatitude());
player.setVideoURI(Uri.parse(args.getVideo().getUrl()));
if (savedInstanceState != null) {
int pos = savedInstanceState.getInt("position", 0);
Log.d(TAG, "Resuming playback at position " + pos + ".");
player.seekTo(pos);
}
player.start();
View frame = LayoutInflater.from(view.getContext()).inflate(R.layout.view_marker, player.getOverlayFrameLayout(), true);
marker = frame.findViewById(R.id.video_marker);
ImageView scaleImage = frame.findViewById(R.id.video_scale_image);
View scaleBackground = frame.findViewById(R.id.video_scale_background);
ImageButton scaleButton = view.findViewById(R.id.video_scale);
scaleButton.setOnClickListener((v) -> {
model.showScale.setValue(!model.showScale.getValue());
});
model.showScale.observe(getViewLifecycleOwner(), (v) -> {
int visible = v?View.VISIBLE:View.GONE;
scaleBackground.setVisibility(visible);
scaleImage.setVisibility(visible);
int img = v?R.drawable.ic_remove_circle_normal_24:R.drawable.ic_remove_circle_outline_normal_24;
int txt = v?R.string.button_hide_scale:R.string.button_show_scale;
scaleButton.setContentDescription(getString(txt));
scaleButton.setImageResource(img);
});
Args args = Args.fromBundle(getArguments());
if (args != null) {
video = args.getVideo();
if (args.getCity() != null) {
timezone = args.getCity().getTimezone();
marker.setPosition(args.getCity().getCoordinate().getLongitude(), args.getCity().getCoordinate().getLatitude());
City city = args.getCity();
timezone = city.getTimezone();
MercatorPositioner p = new MercatorPositioner();
p.setPosition(city.getCoordinate().getLongitude(), city.getCoordinate().getLatitude());
p.setBounds(video.getNorthEast().getLongitude(), video.getNorthEast().getLatitude(),
video.getSouthWest().getLongitude(), video.getSouthWest().getLatitude());
model.markerX = p.getRelativeX();
model.markerY = p.getRelativeY();
}
timeUtils = new TimeUtils(System.currentTimeMillis(), timezone);
formatter = new DateFormatter(getContext());
}
}
if (model.exoPlayer == null) {
model.exoPlayer = new SimpleExoPlayer.Builder(getContext()).build();
model.scaler.setContent(video.getWidth(), video.getHeight());
IApp app = (IApp)getActivity().getApplication();
DataSource.Factory dataSourceFactory = new CacheDataSourceFactory
(app.getMediaCache(), new DefaultHttpDataSourceFactory( Util.getUserAgent
(getContext(), getContext().getPackageName()), null));
MediaSource videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(video.getUrl()));
model.exoPlayer.prepare(videoSource);
model.exoPlayer.setPlayWhenReady(true);
model.scaleUrl = video.getScale();
model.reload();
}
player.setPlayer(model.exoPlayer);
model.scaleImage.observe(getViewLifecycleOwner(), (b)-> {
scaleImage.setImageBitmap(b);
});
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
Log.d(TAG, "Saving playback position at " + lastPosition + ".");
outState.putInt("position", lastPosition);
model.mode.observe(getViewLifecycleOwner(), (mode) -> {
if (mode == ContentScaler.ScaleMode.FIT) {
zoomButton.setImageResource(R.drawable.ic_zoom_out_map_normal_24);
zoomButton.setContentDescription(getString(R.string.button_fill_screen));
player.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
} else {
zoomButton.setImageResource(R.drawable.ic_aspect_ratio_normal_24);
zoomButton.setContentDescription(getString(R.string.button_fit_screen));
player.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_ZOOM);
}
if (model.markerX != null && model.markerY != null) {
updateVideo(marker.getWidth(), marker.getHeight());
}
});
zoomButton.setOnClickListener((v) -> {
model.mode.setValue(model.mode.getValue() == ContentScaler.ScaleMode.FILL?
ContentScaler.ScaleMode.FIT: ContentScaler.ScaleMode.FILL);
});
}
}
@Override
public void onResume() {
super.onResume();
handler.postDelayed(timer, 500);
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if (video != null) {
handler.postDelayed(timer, 500);
if (model.markerX != null && model.markerY != null) {
marker.setVisibility(View.VISIBLE);
marker.addOnLayoutChangeListener(markerListener);
updateVideo(marker.getWidth(), marker.getHeight());
} else {
marker.setVisibility(View.GONE);
}
}
}
@Override
public void onPause() {
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
marker.removeOnLayoutChangeListener(markerListener);
handler.removeCallbacks(timer);
super.onPause();
}
/**
* Computes the marker position and the "optimal" translation
* of the video view.
*
* @param width The width.
* @param height The height.
*/
private void updateVideo(int width, int height) {
model.scaler.setScreen(width, height);
double scale = model.scaler.getScale();
// video with and height
double vidW = scale * model.scaler.getContentWidth();
double vidH = scale * model.scaler.getContentHeight();
// overlap in x and y
double overX = Math.max(0, (vidW - width) / 2);
double overY = Math.max(0, (vidH - height) / 2);
// shift around the center (positive is to left and down)
double shiftX = model.markerX - .5;
double shiftY = model.markerY - .5;
// shift in pixels, limited to overlap
double pShiftX = Math.min(overX, Math.abs(shiftX * vidW));
double pShiftY = Math.min(overY, Math.abs(shiftY * vidH));
if (shiftX > 0) pShiftX = -pShiftX;
if (shiftY > 0) pShiftY = -pShiftY;
player.getVideoSurfaceView().setTranslationX((float)pShiftX);
player.getVideoSurfaceView().setTranslationY((float)pShiftY);
if (model.mode.getValue() == ContentScaler.ScaleMode.FILL) {
marker.setP((float)(model.markerX * vidW + pShiftX - overX),
(float)(model.markerY * vidH + pShiftY - overY));
} else {
marker.setP((float)(width / 2 + shiftX * vidW + pShiftX - overX),
(float)(height / 2 + shiftY * vidH + pShiftY - overY));
}
}
/**
* The view model to store the exo player instance when
* the view is destroyed.
*/
public static class ExoPlayerViewModel extends AbstractNetworkViewModel {
/**
* The exo player (initialized only once).
*/
ExoPlayer exoPlayer;
/**
* The current scale mode.
*/
final MutableLiveData<ContentScaler.ScaleMode> mode = new MutableLiveData<>(ContentScaler.ScaleMode.FILL);
/**
* A boolean preference to show the scale.
*/
final PreferenceLiveData showScale;
/**
* The relative position of the marker in x.
*/
Double markerX;
/**
* The relative position of the marker in y.
*/
Double markerY;
/**
* The content scaler.
*/
final ContentScaler scaler = new ContentScaler();
/**
* The scale image.
*/
final MutableLiveData<Bitmap> scaleImage = new MutableLiveData<>();
/**
* The weather video's scale image.
*/
String scaleUrl;
/**
* Creates a view model.
*/
public ExoPlayerViewModel(Application application) {
super(application);
MowestaSettings s = new MowestaSettings(application);
showScale = new PreferenceLiveData(s.getPreferences(), MowestaSettings.SHOW_SCALE,
s.getContext().getResources().getBoolean(R.bool.show_scale_defaut));
mode.observeForever((m)->scaler.setMode(m));
}
@Override
public void reload() {
long requestCode = newRequestCode();
scaleImage.setValue(null);
if (scaleUrl != null) {
new ImageTask((url, bitmap)-> {
if (bitmap == null) finishRequest(requestCode, true);
else completeRequest(requestCode, () -> scaleImage.setValue(bitmap));
}).execute(scaleUrl);
}
}
}
}
@@ -1,7 +1,6 @@
package com.mowesta.android.app.model;
import android.graphics.Bitmap;
import android.text.format.DateFormat;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@@ -122,20 +121,20 @@ public class BindingAdapters {
*/
@BindingAdapter("locationImage")
public static void setLocationImage(@NonNull ImageView view, @Nullable LocationHierarchy location) {
int icon = R.drawable.ic_public_black_24dp;
int icon = R.drawable.ic_public_normal_24;
String contentDescription = null;
if (location != null) {
switch (location.getType()) {
case CITY:
icon = R.drawable.ic_place_black_24dp;
icon = R.drawable.ic_place_normal_24;
contentDescription = view.getResources().getString(R.string.label_city);
break;
case STATE:
icon = R.drawable.ic_map_black_24dp;
icon = R.drawable.ic_map_normal_24;
contentDescription = view.getResources().getString(R.string.label_state);
break;
case COUNTRY:
icon = R.drawable.ic_public_black_24dp;
icon = R.drawable.ic_public_normal_24;
contentDescription = view.getResources().getString(R.string.label_country);
break;
}
@@ -576,7 +575,7 @@ public class BindingAdapters {
}
@BindingAdapter("datetime")
public static void setGuidelinePosition(@NonNull TextView textView, @Nullable DiagramEntry<?> entry) {
public static void setDiagramDateTime(@NonNull TextView textView, @Nullable DiagramEntry<?> entry) {
if (entry == null) {
textView.setText("");
} else {
@@ -710,7 +709,7 @@ public class BindingAdapters {
@BindingAdapter("favoriteIcon")
public static void setFavoriteIcon(ImageView view, @Nullable Favorite favorite) {
int res = R.drawable.ic_place_black_24dp;
int res = R.drawable.ic_place_normal_24;
String contentDescription = null;
if (favorite != null) {
switch (favorite.getType()) {
@@ -720,11 +719,11 @@ public class BindingAdapters {
break;
case COUNTRY:
contentDescription = view.getResources().getString(R.string.label_country);
res = R.drawable.ic_public_black_24dp;
res = R.drawable.ic_public_normal_24;
break;
case STATE:
contentDescription = view.getResources().getString(R.string.label_state);
res = R.drawable.ic_map_black_24dp;
res = R.drawable.ic_map_normal_24;
break;
}
}
@@ -769,7 +768,7 @@ public class BindingAdapters {
view.setImageResource(BindingTransforms.getOsIcon(device.getOs()));
view.setContentDescription(view.getContext().getString(BindingTransforms.getOsLabel(device.getOs())));
} else {
view.setImageResource(R.drawable.ic_devices_black_24dp);
view.setImageResource(R.drawable.ic_devices_normal_24);
view.setContentDescription(null);
}
}
@@ -1,11 +1,9 @@
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;
@@ -334,9 +332,9 @@ public class BindingTransforms {
public static int getOsIcon(Device.OsEnum os) {
switch (os) {
case IOS:
return R.drawable.ic_phone_iphone_black_24dp;
return R.drawable.ic_phone_iphone_normal_24;
case ANDROID:
return R.drawable.ic_android_black_24dp;
return R.drawable.ic_android_normal_24;
case ARDUINO:
return R.drawable.ic_memory_black_24dp;
}
@@ -47,6 +47,53 @@ public class CityViewModel extends AbstractPlaceViewModel {
void onStationSelected(WeatherStation station);
}
/** The view types to navigate to. */
public enum ForecastType { DAY, TIME, HOUR }
/**
* A navigation request caused by a click on a summary.
*/
public static class NavigationRequest {
/** The list type to navigate to. */
private @NonNull
ForecastType type;
/** The condition to navigate to. */
private @NonNull int position;
/**
* Creates a new request.
*
* @param type The type.
* @param position The position.
*/
public NavigationRequest(@NonNull ForecastType type, @NonNull int position) {
this.type = type;
this.position = position;
}
/**
* Returns the list type to navigate to.
*
* @return The type.
*/
@NonNull
public ForecastType getType() {
return type;
}
/**
* Returns the position to navigate to.
*
* @return The position.
*/
@NonNull
public int getPosition() {
return position;
}
}
/**
* The current weather condition.
@@ -108,6 +155,11 @@ public class CityViewModel extends AbstractPlaceViewModel {
*/
private final MutableLiveData<Geometry> boundary = new MutableLiveData<>();
/**
* The livedata to handle navigation between the different forecast fragments.
*/
private final MutableLiveData<NavigationRequest> navigation = new MutableLiveData<>();
/**
* The loader for the city data.
*/
@@ -132,7 +184,7 @@ public class CityViewModel extends AbstractPlaceViewModel {
(input, status) -> { finishRequest(input, true); });
private final ApiTask<RequestParameter<Long>, List<WeatherVideo>> videoLoader = new ApiTask<>
((input, client) -> client.getLatestCityVideos(input.getValue()),
((input, client) -> client.getLatestCityVideos(input.getValue()),
(input, result) -> { completeRequest(input, () -> videos.setValue(result)); },
(input, status) -> { finishRequest(input, true); });
@@ -186,6 +238,7 @@ public class CityViewModel extends AbstractPlaceViewModel {
super(application);
id.observeForever((value) -> {
long code = newRequestCode();
navigation.setValue(null);
favorite.setValue(null);
forecast.setValue(null);
city.setValue(null);
@@ -201,6 +254,8 @@ public class CityViewModel extends AbstractPlaceViewModel {
forecast.observeForever((c)-> updateConditions());
city.observeForever((c)-> { updateConditions(); updateVideos(); updateLinks(); } );
videos.observeForever((c) -> updateVideos());
}
@Override
@@ -220,6 +275,15 @@ public class CityViewModel extends AbstractPlaceViewModel {
return favorite;
}
/**
* Returns the navigation live data to handle transition between views.
*
* @return The navigation.
*/
public MutableLiveData<NavigationRequest> getNavigation() {
return navigation;
}
/**
* Returns the city.
*
@@ -394,8 +458,10 @@ public class CityViewModel extends AbstractPlaceViewModel {
for (WeatherCondition c: wc) {
long end = d.getEnd(c);
ConditionViewModel vm = new ConditionViewModel(getApplication());
int title = d.getDayName(c.getTime());
vm.setData(title == 0 ? null: getApplication().getString(title), null, c, tz);
long time = c.getTime();
String title = d.getDayName(getApplication(), time);
String subtitle = getApplication().getString(R.string.format_two_parts, df.asTime(time, tz), df.asDate(time, tz));
vm.setData(title, subtitle, c, tz);
hours.add(vm);
if (currentDay == null) {
currentDay = new ArrayList<>();
@@ -437,9 +503,7 @@ public class CityViewModel extends AbstractPlaceViewModel {
List<SummaryViewModel> models = new ArrayList<>();
for (List<WeatherCondition> ds: days) {
long time = d.getTime(ds);
String title = df.asDate(time, tz);
int res = d.getDayName(time);
if (res != 0) title = getApplication().getString(res);
String title = d.getDayName(getApplication(), time);
SummaryViewModel summary = new SummaryViewModel(getApplication());
WeatherCondition[] data = new WeatherCondition[ds.size()];
data = ds.toArray(data);
@@ -450,9 +514,7 @@ public class CityViewModel extends AbstractPlaceViewModel {
models = new ArrayList<>();
for (List<WeatherCondition> ts: times) {
long time = d.getTime(ts);
String title = df.asDate(time, tz);
int res = d.getDayName(time);
if (res != 0) title = getApplication().getString(res);
String title = d.getDayName(getApplication(), time);
int slot = d.getSlotName(time);
SummaryViewModel summary = new SummaryViewModel(getApplication());
WeatherCondition[] data = new WeatherCondition[ts.size()];
@@ -18,6 +18,21 @@ import com.mowesta.android.feign.model.WeatherCondition;
*/
public class ConditionViewModel extends CustomizeViewModel {
/**
* A click listener for weather condition cards.
*/
public interface OnConditionSelectedListener {
/**
* Called when the condition is selected.
*
* @param model The condition that has been clicked.
*/
void onConditionSelected(ConditionViewModel model);
}
/**
* The title to display.
*/
@@ -144,7 +144,6 @@ public class LoginViewModel extends AndroidViewModel {
} else {
failure.setValue(R.string.login_failure_network);
}
System.out.println("Failure is: " + status);
});
@@ -0,0 +1,168 @@
package com.mowesta.android.app.model;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Observer;
import java.text.Normalizer;
public class SetupViewModel extends AndroidViewModel {
final MutableLiveData<String> networkName = new MutableLiveData<>("");
final MutableLiveData<FormStatus> networkNameStatus = new MutableLiveData<>();
final MutableLiveData<String> networkPassword = new MutableLiveData<>("");
final MutableLiveData<FormStatus> networkPasswordStatus = new MutableLiveData<>();
final MutableLiveData<String> deviceName = new MutableLiveData<>("");
final MutableLiveData<FormStatus> deviceNameStatus = new MutableLiveData<>();
final MutableLiveData<String> longitude = new MutableLiveData<>("");
final MutableLiveData<FormStatus> longitudeStatus = new MutableLiveData<>();
final MutableLiveData<String> latitude = new MutableLiveData<>("");
final MutableLiveData<FormStatus> latitudeStatus = new MutableLiveData<>();
final MutableLiveData<Boolean> manualPosition = new MutableLiveData<>(Boolean.FALSE);
final MutableLiveData<Boolean> gpsRegistered = new MutableLiveData<>(Boolean.FALSE);
final MutableLiveData<Boolean> gpsEnabled = new MutableLiveData<>(Boolean.TRUE);
final MutableLiveData<Boolean> valid = new MutableLiveData<>(Boolean.FALSE);
/**
* Creates the view model.
*
* @param application The application.
*/
public SetupViewModel(@NonNull Application application) {
super(application);
Observer<Boolean> gpsEnabledListener = (b) -> { gpsEnabled.setValue(!gpsRegistered.getValue() && !manualPosition.getValue()); };
manualPosition.observeForever(gpsEnabledListener);
gpsRegistered.observeForever(gpsEnabledListener);
}
/**
* Returns the live data with the network name.
*
* @return The live data with the network name.
*/
public MutableLiveData<String> getNetworkName() {
return networkName;
}
/**
* Returns the live data with the status for the network name.
*
* @return The live data with the status for the network name.
*/
public MutableLiveData<FormStatus> getNetworkNameStatus() {
return networkNameStatus;
}
/**
* Returns the live data with the network password.
*
* @return The live data with the network password.
*/
public MutableLiveData<String> getNetworkPassword() {
return networkPassword;
}
/**
* Returns the live data with the status for the network password.
*
* @return The live data with the status for the network password.
*/
public MutableLiveData<FormStatus> getNetworkPasswordStatus() {
return networkPasswordStatus;
}
/**
* Returns the live data with the device name.
*
* @return The live data with the device name.
*/
public MutableLiveData<String> getDeviceName() {
return deviceName;
}
/**
* Returns the live data with the status for the device name.
*
* @return The live data with the status for the device name.
*/
public MutableLiveData<FormStatus> getDeviceNameStatus() {
return deviceNameStatus;
}
/**
* The live data with the longitude.
*
* @return The live data with the longitude.
*/
public MutableLiveData<String> getLongitude() {
return longitude;
}
/**
* The live data with the longitude status.
*
* @return The live data with the longitude status.
*/
public MutableLiveData<FormStatus> getLongitudeStatus() {
return longitudeStatus;
}
/**
* The live data with the latitude.
*
* @return The live data with the latitude.
*/
public MutableLiveData<String> getLatitude() {
return latitude;
}
/**
* The live data with the latitude status.
*
* @return The live data with the latitude status.
*/
public MutableLiveData<FormStatus> getLatitudeStatus() {
return latitudeStatus;
}
/**
* The live data with the gps state.
*
* @return The live data with the gps state.
*/
public MutableLiveData<Boolean> getGpsRegistered() {
return gpsRegistered;
}
/**
* The live data with the switch state.
*
* @return The live data with the switch state.
*/
public MutableLiveData<Boolean> getManualPosition() {
return manualPosition;
}
/**
* Returns the enabled state of the gps button.
*
* @return The enabled state of the gps button.
*/
public MutableLiveData<Boolean> getGpsEnabled() {
return gpsEnabled;
}
/**
* Returns the live data with the final validity
* state of the form.
*
* @return The live data with the form validity.
*/
public MutableLiveData<Boolean> getValid() {
return valid;
}
}
@@ -18,6 +18,19 @@ import com.mowesta.android.feign.model.WeatherCondition;
*/
public class SummaryViewModel extends CustomizeViewModel {
/**
* A click listener for the summary view model.
*/
public interface OnSummarySelectedListener {
/**
* Called when the summary is selected.
*
* @param model The model with the summary.
*/
void onSummarySelected(SummaryViewModel model);
}
/**
* The minimum values.
*/
@@ -127,6 +140,29 @@ public class SummaryViewModel extends CustomizeViewModel {
updateSubtitle();
}
/**
* Returns the first condition contained in the data or null.
*
* @return The first condition or null.
*/
@Nullable
public WeatherCondition getFirstCondition() {
if (conditions == null || conditions.length < 1) return null;
return conditions[0];
}
/**
* Returns the last condition contained in the data or null.
*
* @return The last condition contained in the data.
*/
@Nullable
public WeatherCondition getLastCondition() {
if (conditions == null || conditions.length < 1) return null;
return conditions[conditions.length - 1];
}
/**
* Determines whether the min and max values are set.
*
@@ -1,5 +1,7 @@
package com.mowesta.android.app.repository;
import android.content.Context;
import android.os.Build;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -111,7 +113,7 @@ public class DeviceRepository extends Repository {
});
}
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);
FileStoreObserver<String> handleObserver = createHandleObserver(application.getContext());
r.device.setValue(device == null ? deviceObserver.loadValue() : device);
r.handle.setValue(handle == null ? handleObserver.loadValue(): handle);
r.device.observeForever(deviceObserver);
@@ -119,6 +121,29 @@ public class DeviceRepository extends Repository {
return r;
}
/**
* Creates a handle observer based on the sdk version.
*
* @param context The context.
* @return The observer.
*/
private FileStoreObserver<String> createHandleObserver(@NonNull Context context) {
FileStoreObserver<String> clearText = new FileStoreObserver<String>(context, String.class, "handle_clear.json", false);
FileStoreObserver<String> cipherText = new FileStoreObserver<String>(context, String.class, "handle.json", true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// encryption support is provided at 23
return clearText;
} else {
if (! cipherText.isAvailable() && clearText.isAvailable()) {
// perform migration after OS upgrade to 23
cipherText.onChanged(clearText.loadValue());
clearText.onChanged(null);
}
return cipherText;
}
}
}
/**
@@ -131,6 +131,15 @@ public class FileStoreObserver<T> implements Observer<T> {
}
}
/**
* Determines whether the file is available.
*
* @return True, if the file is available, otherwise false.
*/
public boolean isAvailable() {
return getFile().exists();
}
/**
* Attempts to load the data from the file and
* returns it.
@@ -1,6 +1,8 @@
package com.mowesta.android.app.repository;
import android.content.Context;
import android.os.Build;
import android.os.FileObserver;
import android.util.Log;
import androidx.annotation.NonNull;
@@ -117,7 +119,7 @@ public class UserRepository extends Repository {
});
}
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);
FileStoreObserver<UserCredentials> credentialsObserver = createCredentialObserver(application.getContext());
r.user.setValue(user == null ? userObserver.loadValue() : user);
r.credentials.setValue(credentials == null ? credentialsObserver.loadValue(): credentials);
r.user.observeForever(userObserver);
@@ -125,6 +127,30 @@ public class UserRepository extends Repository {
r.init();
return r;
}
/**
* Creates a credential observer based on the sdk version.
*
* @param context The context.
* @return The observer.
*/
private FileStoreObserver<UserCredentials> createCredentialObserver(@NonNull Context context) {
FileStoreObserver<UserCredentials> clearText = new FileStoreObserver<>(context, UserCredentials.class, "credentials_clear.json", false);
FileStoreObserver<UserCredentials> cipherText = new FileStoreObserver<>(context, UserCredentials.class, "credentials.json", true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// encryption support is provided at 23
return clearText;
} else {
if (! cipherText.isAvailable() && clearText.isAvailable()) {
// perform migration after OS upgrade to 23
cipherText.onChanged(clearText.loadValue());
clearText.onChanged(null);
}
return cipherText;
}
}
}
/**
@@ -0,0 +1,126 @@
package com.mowesta.android.app.util;
/**
* A helper class to compute the scale.
*/
public class ContentScaler {
public enum ScaleMode {
/** Content is stretched to fit the content onto the screen. */
FIT,
/** Content is stretched to fill the complete screen. */
FILL
};
/**
* The content width.
*/
private double contentWidth;
/**
* The content height.
*/
private double contentHeight;
/**
* The screen height.
*/
private double screenHeigth;
/**
* The screen width.
*/
private double screenWidth;
/**
* The scale mode.
*/
private ScaleMode mode = ScaleMode.FIT;
/**
* Sets the mode to compute.
*
* @param mode The mode to compute.
*/
public void setMode(ScaleMode mode) {
if (mode != null) {
this.mode = mode;
}
}
/**
* Computes the scaling factor.
*
* @return The scaling factor.
*/
public double getScale() {
double x = screenWidth / contentWidth;
double y = screenHeigth / contentHeight;
return mode == ScaleMode.FIT ? Math.min(x, y) : Math.max(x, y);
}
/**
* Returns the scale mode.
*
* @return The scale mode.
*/
public ScaleMode getMode() {
return mode;
}
/**
* Sets the screen dimensions.
*
* @param width The width.
* @param height The height.
*/
public void setScreen(double width, double height) {
this.screenHeigth = height;
this.screenWidth = width;
}
/**
* Returns the screen height.
*
* @return The screen height.
*/
public double getScreenHeigth() {
return screenHeigth;
}
/**
* Returns the screen width.
*
* @return The screen width.
*/
public double getScreenWidth() {
return screenWidth;
}
/**
* Sets the content dimensions.
*
* @param width The width.
* @param height The height.
*/
public void setContent(double width, double height) {
this.contentWidth = width;
this.contentHeight = height;
}
/**
* Returns the content height.
*
* @return The content height.
*/
public double getContentHeight() {
return contentHeight;
}
/**
* Returns the content width.
*
* @return The content width.
*/
public double getContentWidth() {
return contentWidth;
}
}
@@ -3,11 +3,12 @@ package com.mowesta.android.app.util;
import android.content.Context;
import android.graphics.Paint;
import androidx.core.content.ContextCompat;
import com.locoslab.android.leafless.MapOptions;
import com.locoslab.android.leafless.MapPoint;
import com.locoslab.android.leafless.MapView;
import com.locoslab.android.leafless.icon.Icon;
import com.locoslab.android.leafless.icon.IconImage;
import com.locoslab.android.leafless.icon.IconOptions;
import com.locoslab.android.leafless.marker.Marker;
import com.locoslab.android.leafless.marker.MarkerOptions;
@@ -24,7 +25,6 @@ import org.geojson.LngLatAlt;
import org.geojson.MultiPolygon;
import org.geojson.Polygon;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
@@ -108,11 +108,11 @@ public class MapViewUtil {
List<Polyline> result = new ArrayList<>();
PolylineOptions options = new PolylineOptions();
options.linePaint = new Paint();
options.linePaint.setColor(context.getColor(R.color.colorPrimary));
options.linePaint.setColor(ContextCompat.getColor(context, R.color.primary));
options.linePaint.setStrokeWidth(3);
options.linePaint.setStyle(Paint.Style.STROKE);
options.fillPaint = new Paint();
options.fillPaint.setColor(context.getColor(R.color.colorAccent));
options.fillPaint.setColor(ContextCompat.getColor(context, R.color.accent));
options.fillPaint.setAlpha(88);
options.fillPaint.setStyle(Paint.Style.FILL);
for (List<LngLatAlt> ring: rings) {
@@ -0,0 +1,97 @@
package com.mowesta.android.app.util;
import androidx.annotation.Nullable;
import com.locoslab.library.geometry.wgs.Coordinate;
import com.locoslab.library.geometry.wgs.Coordinates;
/**
* A util class to compute the relative position of a coordinate
* in a mercator projected region.
*
* @author Marcus
*/
public class MercatorPositioner {
/**
* The min latitude and longitude
*/
private Coordinate min = new Coordinate();
/**
* The max latitude and longitude.
*/
private Coordinate max = new Coordinate();
/**
* The position to place the marker.
*/
private Coordinate position = new Coordinate();
/**
* The relative x position or null, if the bounds
* are not valid.
*
* @return The relative position in x or null.
*/
public @Nullable Double getRelativeX() {
if (!isValid()) return null;
double minX = Coordinates.SPHERICAL.getX(min);
double maxX = Coordinates.SPHERICAL.getX(max);
double x = Coordinates.SPHERICAL.getX(position);
return (x - minX) / (maxX - minX);
}
/**
* The relative position in y or null, if the bounds
* are not valid.
*
* @return The relative position in y or null.
*/
public @Nullable Double getRelativeY() {
if (!isValid()) return null;
double minY = Coordinates.SPHERICAL.getY(min);
double maxY = Coordinates.SPHERICAL.getY(max);
double y = Coordinates.SPHERICAL.getY(position);
return (y - maxY) / (minY - maxY);
}
/**
* Determines whether the bounds are valid.
*
* @return True if the bounds are valid.
*/
public boolean isValid() {
return min != null && max != null && position != null &&
min.getLatitude() < max.getLatitude() && min.getLongitude() < max.getLongitude();
}
/**
* Sets the bounds of the positioner using 2 coordinates..
*
* @param longitude1 The longitude 1.
* @param latitude1 The latitude 1.
* @param longitude2 The longitude 2.
* @param latitude2 The latitude 2.
*/
public void setBounds(double longitude1, double latitude1, double longitude2, double latitude2) {
min.setLatitude(Math.min(latitude1, latitude2));
min.setLongitude(Math.min(longitude1, longitude2));
max.setLatitude(Math.max(latitude1, latitude2));
max.setLongitude(Math.max(longitude1, longitude2));
}
/**
* Sets the position.
*
* @param longitude The longitude.
* @param latitude The latitude.
*/
public void setPosition(double longitude, double latitude) {
position = new Coordinate(longitude, latitude);
}
}
@@ -7,6 +7,9 @@ import android.os.Build;
import androidx.annotation.NonNull;
import androidx.core.content.PermissionChecker;
import java.util.ArrayList;
import java.util.List;
/**
* A utility class to handle permissions.
*
@@ -27,6 +30,26 @@ public class PermissionUtil {
return hasPermissions;
}
/**
* Computes the permissions that have not been granted but are required.
*
* @param context The context.
* @return The permissions that have not been granted yet.
*/
public static String[] getNonGrantedPermissions(@NonNull Context context) {
List<String> nonGranted = new ArrayList<>();
for (String permission: getPermissions(context)) {
if (PermissionChecker.checkSelfPermission(context, permission) != PermissionChecker.PERMISSION_GRANTED) {
nonGranted.add(permission);
}
}
String[] result = new String[nonGranted.size()];
for (int i = nonGranted.size() - 1; i >= 0; i--) {
result[i] = nonGranted.get(i);
}
return result;
}
/**
* Returns the permissions that we should have.
*
@@ -2,6 +2,11 @@ package com.mowesta.android.app.util;
import android.content.Context;
import android.content.res.Configuration;
import android.util.DisplayMetrics;
import android.view.Display;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
/**
* Utility to detect tablets running in landscape mode.
@@ -42,4 +47,25 @@ public class TabletUtil {
return isLandscape(context) && isTablet(context);
}
/**
* Returns the screen width in dp.
*
* @param context The context.
* @return The screen width in dp.
*/
public static float getScreenWidthDp(Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return displayMetrics.widthPixels / displayMetrics.density;
}
/**
* Configures a grid layout such that the items have at least the configured size.
*
* @param view The view.
* @param itemWidthDp The item width in dp.
*/
public static void setGridLayout(RecyclerView view, int itemWidthDp) {
int cols = Math.max(1, (int)(getScreenWidthDp(view.getContext()) / itemWidthDp));
view.setLayoutManager(new GridLayoutManager(view.getContext(), cols));
}
}
@@ -1,9 +1,18 @@
package com.mowesta.android.app.util;
import android.content.Context;
import android.content.res.Resources;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.os.ConfigurationCompat;
import com.mowesta.android.app.R;
import com.mowesta.android.feign.model.WeatherCondition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
@@ -49,20 +58,25 @@ public class TimeUtils {
/**
* Returns the resource id of the "special" day.
*
* @param context The context.
* @param time The time.
* @return The day name.
*/
public int getDayName(long time) {
public String getDayName(Context context, long time) {
c.setTimeInMillis(time);
update(temp1);
if (equals(temp1, yesterday)) {
return R.string.date_yesterday;
return context.getString(R.string.date_yesterday);
} else if (equals(temp1, today)) {
return R.string.date_today;
return context.getString(R.string.date_today);
} else if (equals(temp1, tomorrow)) {
return R.string.date_tomorrow;
return context.getString(R.string.date_tomorrow);
} else {
return 0;
c.setTimeInMillis(time);
SimpleDateFormat sdf = new SimpleDateFormat("EEEE",
ConfigurationCompat.getLocales(context.getResources().getConfiguration()).get(0));
sdf.setCalendar(c);
return sdf.format(new Date(time));
}
}
@@ -1,42 +1,26 @@
package com.mowesta.android.app.view;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.locoslab.library.geometry.wgs.Coordinate;
import com.locoslab.library.geometry.wgs.Coordinates;
import com.locoslab.library.geometry.wgs.SphericalProjection;
import com.mowesta.android.app.R;
/**
* A view that displays the location marker on top of
* the video view.
* A view that draws a circle at a configurable x and y coordinate.
*
* @author Marcus
*/
public class MarkerView extends View {
/**
* The min latitude and longitude
*/
private Coordinate min = new Coordinate();
/**
* The max latitude and longitude.
*/
private Coordinate max = new Coordinate();
/**
* The position to place the marker.
*/
private Coordinate position;
/**
* The paint used to draw the marker.
*/
@@ -47,14 +31,36 @@ public class MarkerView extends View {
*/
private float radius;
/**
* The outer stroke width.
*/
private float outerStroke;
/**
* The outer color.
*/
private int outerColor;
/**
* The inner stroke width.
*/
private float innerStroke;
/**
* The inner color.
*/
private int innerColor;
/**
* The point where to draw the circle.
*/
private float px;
/**
* The point where to draw the circle.
*/
private float py;
/**
* Creates a new view.
*
@@ -96,6 +102,7 @@ public class MarkerView extends View {
* @param defStyleAttr The styles.
* @param defStyleRes The styles.
*/
@TargetApi(21)
public MarkerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
@@ -109,8 +116,8 @@ public class MarkerView extends View {
private void init(Context context) {
paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
innerColor = context.getColor(R.color.colorAccent);
outerColor = context.getColor(R.color.colorPrimary);
innerColor = ContextCompat.getColor(context, R.color.accent);
outerColor = ContextCompat.getColor(context, R.color.primary);
float density = context.getResources().getSystem().getDisplayMetrics().density;
radius = 8 * density;
innerStroke = 1.5f * density;
@@ -120,51 +127,41 @@ public class MarkerView extends View {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isValid()) {
double minX = Coordinates.SPHERICAL.getX(min);
double minY = Coordinates.SPHERICAL.getY(min);
double maxX = Coordinates.SPHERICAL.getX(max);
double maxY = Coordinates.SPHERICAL.getY(max);
double x = Coordinates.SPHERICAL.getX(position);
double y = Coordinates.SPHERICAL.getY(position);
double px = (x - minX) / (maxX - minX);
double py = (y - maxY) / (minY - maxY);
paint.setColor(outerColor);
paint.setStrokeWidth(outerStroke);
canvas.drawCircle((float)(getWidth() * px), (float)(getHeight() * py), radius, paint);
paint.setColor(innerColor);
paint.setStrokeWidth(innerStroke);
canvas.drawCircle((float)(getWidth() * px), (float)(getHeight() * py), radius, paint);
}
paint.setColor(outerColor);
paint.setStrokeWidth(outerStroke);
canvas.drawCircle(px, py, radius, paint);
paint.setColor(innerColor);
paint.setStrokeWidth(innerStroke);
canvas.drawCircle(px, py, radius, paint);
}
private boolean isValid() {
return min != null && max != null && position != null &&
min.getLatitude() < max.getLatitude() && min.getLongitude() < max.getLongitude();
}
public void setRadius(float radius) {
this.radius = radius;
}
public void setBounds(double longitude1, double latitude1, double longitude2, double latitude2) {
min.setLatitude(Math.min(latitude1, latitude2));
min.setLongitude(Math.min(longitude1, longitude2));
max.setLatitude(Math.max(latitude1, latitude2));
max.setLongitude(Math.max(longitude1, longitude2));
/**
* Sets the point to draw the marker.
*
* @param px The x coordinate in pixels.
* @param py The y coordinate in pixels.
*/
public void setP(float px, float py) {
this.px = px;
this.py = py;
invalidate();
}
public void setPosition(double longitude, double latitude) {
position = new Coordinate(longitude, latitude);
invalidate();
/**
* Returns the x coordinate of the point where to draw the circle.
*
* @return The y coordinate.
*/
public float getPx() {
return px;
}
public void clearPosition() {
this.position = null;
invalidate();
/**
* Returns the y coordinate of the point where to draw the circle.
*
* @return The y coordinate.
*/
public float getPy() {
return py;
}
}
@@ -2,17 +2,21 @@ package com.mowesta.android.app.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.DrawFilter;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.view.Gravity;
import androidx.appcompat.widget.AppCompatTextView;
import com.google.android.material.textview.MaterialTextView;
/**
* A text view that draws vertical text.
*
* @author Marcus
*/
public class VerticalTextView extends AppCompatTextView {
public class VerticalTextView extends MaterialTextView {
/**
* The drawing direction.
@@ -73,14 +77,23 @@ public class VerticalTextView extends AppCompatTextView {
@Override
protected void onDraw(Canvas canvas) {
TextPaint textPaint = getPaint();
textPaint.setColor( getCurrentTextColor() );
textPaint.drawableState = getDrawableState();
canvas.save();
if (topDown) {
canvas.translate(getWidth(), 0);
canvas.rotate(90);
} else {
canvas.translate(0, getHeight());
canvas.rotate(-90);
canvas.translate( 0, getHeight() );
canvas.rotate( -90 );
}
canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop());
getLayout().draw(canvas);
canvas.translate( getCompoundPaddingLeft(),
getExtendedPaddingTop() );
getLayout().draw( canvas );
canvas.setDrawFilter(new DrawFilter() {
});
canvas.restore();
}
}
@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:state_enabled="true"
app:state_lifted="false"
app:state_liftable="true">
<objectAnimator
android:duration="1"
android:propertyName="elevation"
android:valueTo="8dp"
android:valueType="floatType"/>
</item>
<item android:state_enabled="true">
<objectAnimator
android:duration="1"
android:propertyName="elevation"
android:valueTo="8dp"
android:valueType="floatType"/>
</item>
<item>
<objectAnimator
android:duration="1"
android:propertyName="elevation"
android:valueTo="8dp"
android:valueType="floatType"/>
</item>
</selector>
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/accent">
<item
android:id="@android:id/mask"
android:gravity="center">
<shape android:shape="rectangle">
<solid android:color="@android:color/white"/>
</shape>
</item>
</ripple>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/accent">
<item
android:id="@android:id/mask"
android:gravity="center">
<shape android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners
android:bottomRightRadius="4dp"
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp"/>
</shape>
</item>
</ripple>
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:gradientRadius="100%p"
android:centerX="0.2"
android:gradientRadius="150%p"
android:centerX="0.8"
android:centerY="1"
android:endColor="#00695C"
android:startColor="#ABBDD1"
android:startColor="#CBCDD1"
android:type="radial" />
</shape>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners
android:bottomRightRadius="4dp"
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp"/>
</shape>
@@ -1,4 +1,4 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/colorPrimary"/>
<solid android:color="@color/primary"/>
</shape>
@@ -1,4 +1,4 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/colorAccent"/>
<solid android:color="@color/accent"/>
</shape>
@@ -5,6 +5,6 @@
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:fillColor="#000000"
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>
@@ -5,6 +5,6 @@
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:fillColor="#000000"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z"/>
</vector>
@@ -1,4 +1,4 @@
<vector android:height="24dp" android:tint="#000000"
<vector android:height="24dp" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -5,6 +5,6 @@
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:fillColor="#000000"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10h5v-2h-5c-4.34,0 -8,-3.66 -8,-8s3.66,-8 8,-8 8,3.66 8,8v1.43c0,0.79 -0.71,1.57 -1.5,1.57s-1.5,-0.78 -1.5,-1.57L17,12c0,-2.76 -2.24,-5 -5,-5s-5,2.24 -5,5 2.24,5 5,5c1.38,0 2.64,-0.56 3.54,-1.47 0.65,0.89 1.77,1.47 2.96,1.47 1.97,0 3.5,-1.6 3.5,-3.57L22,12c0,-5.52 -4.48,-10 -10,-10zM12,15c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3z"/>
</vector>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -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="M19,12h-2v3h-3v2h5v-5zM7,9h3L10,7L5,7v5h2L7,9zM21,3L3,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2L23,5c0,-1.1 -0.9,-2 -2,-2zM21,19.01L3,19.01L3,4.99h18v14.02z"/>
</vector>
@@ -1,15 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="56.7532dp"
android:height="56.7532dp"
android:tint="#FFFFFF"
android:tint="?attr/colorControlNormal"
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:fillColor="#000000"
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:fillColor="#000000"
android:fillType="nonZero"/>
</vector>
@@ -5,6 +5,6 @@
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:fillColor="#000000"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,4 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
@@ -1,15 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="56.7532dp"
android:height="56.7532dp"
android:tint="#FFFFFF"
android:tint="?attr/colorControlNormal"
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:fillColor="#000000"
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:fillColor="#000000"
android:fillType="nonZero"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#000000" android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
</vector>
@@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#B0000000" android:pathData="M16.5,3c-1.74,0 -3.41,0.81 -4.5,2.09C10.91,3.81 9.24,3 7.5,3 4.42,3 2,5.42 2,8.5c0,3.78 3.4,6.86 8.55,11.54L12,21.35l1.45,-1.32C18.6,15.36 22,12.28 22,8.5 22,5.42 19.58,3 16.5,3zM12.1,18.55l-0.1,0.1 -0.1,-0.1C7.14,14.24 4,11.39 4,8.5 4,6.5 5.5,5 7.5,5c1.54,0 3.04,0.99 3.57,2.36h1.87C13.46,5.99 14.96,5 16.5,5c2,0 3.5,1.5 3.5,3.5 0,2.89 -3.14,5.74 -7.9,10.05z"/>
</vector>
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#B0000000" android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
</vector>
@@ -1,5 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:tint="?attr/colorControlNormal"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#B0000000" android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z"/>
</vector>
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#B0000000" android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
</vector>
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#000000" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</vector>
@@ -1,5 +0,0 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#B0000000" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</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="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM17,13L7,13v-2h10v2z"/>
</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="M7,11v2h10v-2L7,11zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
</vector>
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -1,6 +1,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
@@ -5,6 +5,6 @@
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:fillColor="#000000"
android:pathData="M4,15h16v-2L4,13v2zM4,19h16v-2L4,17v2zM4,11h16L20,9L4,9v2zM4,5v2h16L20,5L4,5z"/>
</vector>
@@ -1,5 +0,0 @@
<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>
@@ -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="M15,3l2.3,2.3l-2.89,2.87l1.42,1.42L18.7,6.7L21,9V3H15zM3,9l2.3,-2.3l2.87,2.89l1.42,-1.42L6.7,5.3L9,3H3V9zM9,21l-2.3,-2.3l2.89,-2.87l-1.42,-1.42L5.3,17.3L3,15v6H9zM21,15l-2.3,2.3l-2.87,-2.89l-1.42,1.42l2.89,2.87L15,21h6V15z"/>
</vector>
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorAccent">
<item
android:id="@android:id/mask"
android:gravity="center">
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@android:color/white"/>
<solid android:color="@color/accent" />
</shape>
</item>
</ripple>
<item android:state_focused="true">
<shape android:shape="rectangle">
<stroke android:color="@color/accentTransparent" />
</shape>
</item>
<item android:drawable="@android:color/transparent" />
</selector>
@@ -1,16 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/colorAccent">
<item
android:id="@android:id/mask"
android:gravity="center">
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@android:color/white"/>
<corners
android:bottomRightRadius="4dp"
android:bottomLeftRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp"/>
<solid android:color="@color/accent" />
</shape>
</item>
</ripple>
<item android:state_focused="true">
<shape android:shape="rectangle">
<stroke android:color="@color/accentTransparent" />
</shape>
</item>
<item android:drawable="@android:color/transparent" />
</selector>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/colorAccent" />
<item android:state_checked="true" android:color="@color/accent" />
<item android:state_checked="false" android:color="@color/white"/>
</selector>
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="210dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:itemTextAppearance="?attr/textAppearanceBody1"
app:headerLayout="@layout/view_drawer_header"
app:menu="@menu/menu_drawer"/>
<FrameLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/navigation_drawer"
android:name="androidx.navigation.fragment.NavHostFragment"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_drawer" />
<include layout="@layout/layout_logobar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<include layout="@layout/view_progress" />
</FrameLayout>
</LinearLayout>
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<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" />
<variable name="conditionListener" type="com.mowesta.android.app.model.ConditionViewModel.OnConditionSelectedListener" />
</data>
<androidx.core.widget.NestedScrollView
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_margin="@dimen/space_medium"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/view_city_detail"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
app:model="@{model}"
app:stationListener="@{stationListener}" />
<Space
android:layout_width="@dimen/space_medium"
android:layout_height="0dp"/>
<include
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
layout="@layout/view_condition"
app:listener="@{conditionListener}"
app:model="@{condition}" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</layout>
@@ -16,7 +16,8 @@
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/header"
android:background="@color/colorAccent"
android:background="@color/accent"
tools:targetApi="21"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@@ -28,7 +29,7 @@
android:layout_width="48dp"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:src="@drawable/ic_view_headline_black_24dp"/>
app:srcCompat="@drawable/ic_view_headline_normal_24"/>
<TextView
android:layout_weight="1"
android:layout_marginStart="@dimen/space_medium"
@@ -46,7 +47,7 @@
android:layout_height="wrap_content"
android:onClick="@{ () -> closeListener.run() }"
style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
android:src="@drawable/ic_baseline_close_24" />
app:srcCompat="@drawable/ic_close_normal_24" />
</LinearLayout>
@@ -17,7 +17,8 @@
android:layout_height="400dp">
<LinearLayout
android:id="@+id/header"
android:background="@color/colorAccent"
android:background="@color/accent"
tools:targetApi="21"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@@ -45,7 +46,7 @@
android:layout_height="wrap_content"
android:onClick="@{ () -> closeListener.run() }"
style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
android:src="@drawable/ic_baseline_close_24" />
app:srcCompat="@drawable/ic_close_normal_24" />
</LinearLayout>
@@ -143,7 +144,7 @@
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/colorGray"/>
android:background="@color/separator"/>
<LinearLayout

Some files were not shown because too many files have changed in this diff Show More