Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4c9999368 | ||
|
|
b681689f09 | ||
|
|
f8ff826106 | ||
|
|
dfb0469fa6 | ||
|
|
d293bd66ef |
@@ -88,7 +88,7 @@ android {
|
||||
applicationId "com.mowesta.android.app"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 3
|
||||
versionCode 5
|
||||
versionName "${version}"
|
||||
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -17,6 +17,9 @@ 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;
|
||||
@@ -113,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() {
|
||||
|
||||
+138
-8
@@ -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.NavigationRequest.ListType.TIME, i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}));
|
||||
model.getNavigation().observe(getViewLifecycleOwner(), (request) -> {
|
||||
if (request == null) return;
|
||||
if (request.getType() == CityViewModel.NavigationRequest.ListType.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.NavigationRequest.ListType.HOUR, i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}));
|
||||
model.getNavigation().observe(getViewLifecycleOwner(), (request) -> {
|
||||
if (request == null) return;
|
||||
if (request.getType() == CityViewModel.NavigationRequest.ListType.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.NavigationRequest.ListType.DAY, i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}));
|
||||
model.getNavigation().observe(getViewLifecycleOwner(), (request) -> {
|
||||
if (request == null) return;
|
||||
if (request.getType() == CityViewModel.NavigationRequest.ListType.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,15 @@ 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());
|
||||
}
|
||||
});
|
||||
System.out.println("XXXX");
|
||||
NavController cityController = Navigation.findNavController(getActivity(), R.id.navigation_city);
|
||||
binding.setConditionListener(m -> {
|
||||
System.out.println("here");
|
||||
cityController.navigate(R.id.destination_city_forecast);
|
||||
});
|
||||
binding.setLifecycleOwner(getViewLifecycleOwner());
|
||||
return binding.getRoot();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ 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.List;
|
||||
|
||||
@@ -105,6 +106,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, 600);
|
||||
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) {
|
||||
@@ -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) -> {
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
@@ -211,13 +212,7 @@ public class VideoFragment extends Fragment {
|
||||
double hps = video.getFph() / (double)video.getFps();
|
||||
long hours = (long)(secs / hps);
|
||||
long time = video.getTime() + (video.getStart() + hours) * 60 * 60 * 1000;
|
||||
int dayRes = timeUtils.getDayName(time);
|
||||
String day;
|
||||
if (dayRes != 0) {
|
||||
day = getString(dayRes);
|
||||
} else {
|
||||
day = formatter.asDate(time, timezone);
|
||||
}
|
||||
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);
|
||||
@@ -293,6 +288,7 @@ public class VideoFragment extends Fragment {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
if (video != null) {
|
||||
handler.postDelayed(timer, 500);
|
||||
if (model.markerX != null && model.markerY != null) {
|
||||
@@ -307,6 +303,7 @@ public class VideoFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
marker.removeOnLayoutChangeListener(markerListener);
|
||||
handler.removeCallbacks(timer);
|
||||
super.onPause();
|
||||
|
||||
@@ -575,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 {
|
||||
|
||||
@@ -48,6 +48,52 @@ public class CityViewModel extends AbstractPlaceViewModel {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A navigation request caused by a click on a summary.
|
||||
*/
|
||||
public static class NavigationRequest {
|
||||
/** The view types to navigate to. */
|
||||
public enum ListType { DAY, TIME, HOUR }
|
||||
|
||||
/** The list type to navigate to. */
|
||||
private @NonNull ListType 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 ListType type, @NonNull int position) {
|
||||
this.type = type;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list type to navigate to.
|
||||
*
|
||||
* @return The type.
|
||||
*/
|
||||
@NonNull
|
||||
public ListType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position to navigate to.
|
||||
*
|
||||
* @return The position.
|
||||
*/
|
||||
@NonNull
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The current weather condition.
|
||||
*/
|
||||
@@ -108,6 +154,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.
|
||||
*/
|
||||
@@ -186,6 +237,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);
|
||||
@@ -220,6 +272,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 +455,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 +500,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 +511,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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/fragment_recycler"/>
|
||||
<include layout="@layout/fragment_recycler" android:layout_width="match_parent" android:layout_height="match_parent"/>
|
||||
|
||||
<include layout="@layout/view_progress"/>
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<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
|
||||
@@ -15,11 +16,13 @@
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="@dimen/space_medium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include
|
||||
layout="@layout/view_condition"
|
||||
app:listener="@{conditionListener}"
|
||||
app:model="@{condition}" />
|
||||
|
||||
<include layout="@layout/view_city_detail"
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
style="@style/match_parent_limit"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/fragment_recycler" />
|
||||
<include layout="@layout/fragment_recycler" android:layout_height="match_parent" android:layout_width="match_parent"/>
|
||||
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
android:layout_height="0dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
style="@style/match_parent_limit"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/space_medium"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
style="@style/match_parent_limit"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="300dp">
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
app:boxBackgroundColor="@color/accent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:hintTextColor="@color/black"
|
||||
app:hintTextColor="?attr/colorControlNormal"
|
||||
app:endIconMode="clear_text"
|
||||
app:startIconDrawable="@drawable/ic_search_normal_24">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
|
||||
@@ -30,32 +30,31 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/margin_default">
|
||||
android:padding="@dimen/space_medium">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
style="@style/match_parent_limit"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginBottom="6dp">
|
||||
|
||||
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/permission_checkbox_start"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:checked="@={ model.accepted }"
|
||||
tools:targetApi="21"
|
||||
android:buttonTint="@color/primary"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/terms_checkbox_permission"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.1"/>
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:enabled="@{ model.accepted }"
|
||||
android:id="@+id/start_button_continue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="center"
|
||||
style="@style/match_parent_limit"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="@{ () -> continueListener.run() }"
|
||||
android:text="@string/terms_button_accept" />
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap|snapMargins">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/header"
|
||||
android:id="@+id/logo_sun"
|
||||
android:contentDescription="@null"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -7,11 +7,18 @@
|
||||
<variable
|
||||
name="model"
|
||||
type="com.mowesta.android.app.model.ConditionViewModel" />
|
||||
<variable
|
||||
name="listener"
|
||||
type="com.mowesta.android.app.model.ConditionViewModel.OnConditionSelectedListener" />
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:onClick="@{ () -> listener.onConditionSelected(model) }"
|
||||
app:rippleColor="@color/accent"
|
||||
android:visibility="@{ (model.condition == null) ? View.GONE : View.VISIBLE }"
|
||||
app:cardElevation="4dp"
|
||||
android:layout_margin="8dp">
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
tools:text="10.3.2020\n8.30"
|
||||
datetime="@{model}"
|
||||
android:gravity="center|bottom"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
|
||||
android:textAppearance="?attr/textAppearanceCaption"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="100dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@color/black"/>
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/inverse"/>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="36dp"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
favoriteIcon="@{model}"
|
||||
android:contentDescription="@null"
|
||||
android:scaleType="fitCenter"
|
||||
android:layout_width="80dp"
|
||||
android:layout_width="70dp"
|
||||
android:padding="4dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
@@ -64,6 +64,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<Space
|
||||
android:layout_width="@dimen/space_medium"
|
||||
android:layout_height="0dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View android:layout_width="match_parent"
|
||||
@@ -76,7 +79,7 @@
|
||||
favoriteShowCondition="@{model}"
|
||||
android:orientation="horizontal">
|
||||
<com.mowesta.android.app.view.WeatherView
|
||||
android:layout_width="80dp"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:gravity="center"
|
||||
@@ -130,6 +133,9 @@
|
||||
android:textAppearance="?attr/textAppearanceBody1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<Space
|
||||
android:layout_width="@dimen/space_medium"
|
||||
android:layout_height="0dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
@@ -7,11 +7,18 @@
|
||||
<variable
|
||||
name="model"
|
||||
type="com.mowesta.android.app.model.SummaryViewModel" />
|
||||
<variable
|
||||
name="listener"
|
||||
type="com.mowesta.android.app.model.SummaryViewModel.OnSummarySelectedListener" />
|
||||
</data>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:onClick="@{ () -> listener.onSummarySelected(model) }"
|
||||
app:rippleColor="@color/accent"
|
||||
app:cardElevation="4dp"
|
||||
android:layout_margin="8dp">
|
||||
|
||||
@@ -34,7 +41,7 @@
|
||||
weatherIcon="@{model.min}"
|
||||
android:textSize="40dp"/>
|
||||
<com.mowesta.android.app.view.WeatherView
|
||||
android:layout_width="80dp"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
|
||||
@@ -9,10 +9,15 @@
|
||||
name="listener"
|
||||
type="com.mowesta.android.app.model.VideoViewModel.OnVideoSelectedListener" />
|
||||
</data>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<LinearLayout
|
||||
android:layout_margin="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
@@ -37,4 +42,6 @@
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?attr/textAppearanceCaption" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
android:id="@+id/destination_login"
|
||||
android:name="com.mowesta.android.app.fragment.LoginFragment"
|
||||
android:label="@string/navigation_login"
|
||||
android:layout="@layout/fragment_login">
|
||||
tools:layout="@layout/fragment_login">
|
||||
<action
|
||||
android:id="@+id/action_login_collection"
|
||||
app:popUpTo="@id/destination_login"
|
||||
@@ -74,7 +74,7 @@
|
||||
android:id="@+id/destination_collection"
|
||||
android:name="com.mowesta.android.app.fragment.CollectionFragment"
|
||||
android:label="@string/navigation_login"
|
||||
android:layout="@layout/fragment_login">
|
||||
tools:layout="@layout/fragment_login">
|
||||
<action
|
||||
android:id="@+id/action_collection_drawer"
|
||||
app:popUpTo="@id/destination_collection"
|
||||
@@ -117,26 +117,41 @@
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/destination_city"
|
||||
tools:layout="@layout/fragment_city"
|
||||
android:name="com.mowesta.android.app.fragment.CityFragment"
|
||||
android:label="@string/navigation_city"/>
|
||||
<fragment
|
||||
android:id="@+id/destination_country"
|
||||
tools:layout="@layout/fragment_country"
|
||||
android:name="com.mowesta.android.app.fragment.CountryFragment"
|
||||
android:label="@string/navigation_country"/>
|
||||
<fragment
|
||||
android:id="@+id/destination_state"
|
||||
tools:layout="@layout/fragment_state"
|
||||
android:name="com.mowesta.android.app.fragment.StateFragment"
|
||||
android:label="@string/navigation_state"/>
|
||||
<fragment
|
||||
android:id="@+id/destination_station"
|
||||
tools:layout="@layout/fragment_station"
|
||||
android:name="com.mowesta.android.app.fragment.StationFragment"
|
||||
android:label="@string/navigation_station" />
|
||||
<fragment
|
||||
android:id="@+id/destination_device"
|
||||
tools:layout="@layout/fragment_device"
|
||||
android:name="com.mowesta.android.app.fragment.DeviceFragment"
|
||||
android:label="@string/navigation_device" />
|
||||
<fragment
|
||||
android:id="@+id/destination_video"
|
||||
tools:layout="@layout/fragment_video"
|
||||
android:name="com.mowesta.android.app.fragment.VideoFragment" />
|
||||
|
||||
<include app:graph="@navigation/navigation_drawer" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_drawer"
|
||||
app:popUpTo="@id/destination_drawer"
|
||||
app:popUpToInclusive="true"
|
||||
app:enterAnim="@anim/slide_in_right"
|
||||
app:exitAnim="@anim/slide_out_left"
|
||||
app:destination="@id/destination_drawer" />
|
||||
</navigation>
|
||||
@@ -2,26 +2,32 @@
|
||||
<navigation
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/navigation_drawer"
|
||||
app:startDestination="@id/destination_favorites">
|
||||
<fragment
|
||||
android:id="@+id/destination_favorites"
|
||||
tools:layout="@layout/fragment_favorites"
|
||||
android:name="com.mowesta.android.app.fragment.FavoritesFragment"
|
||||
android:label="@string/navigation_favorites" />
|
||||
<fragment
|
||||
android:id="@+id/destination_cities"
|
||||
tools:layout="@layout/fragment_cities"
|
||||
android:name="com.mowesta.android.app.fragment.CitiesFragment"
|
||||
android:label="@string/navigation_cities" />
|
||||
<fragment
|
||||
android:id="@+id/destination_stations"
|
||||
tools:layout="@layout/fragment_stations"
|
||||
android:name="com.mowesta.android.app.fragment.StationsFragment"
|
||||
android:label="@string/navigation_stations" />
|
||||
<fragment
|
||||
android:id="@+id/destination_devices"
|
||||
tools:layout="@layout/fragment_devices"
|
||||
android:name="com.mowesta.android.app.fragment.DevicesFragment"
|
||||
android:label="@string/navigation_devices" />
|
||||
<fragment
|
||||
android:id="@+id/destination_account"
|
||||
tools:layout="@layout/fragment_login"
|
||||
android:name="com.mowesta.android.app.fragment.LoginFragment"
|
||||
android:label="@string/navigation_account" />
|
||||
<fragment
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
<resources>
|
||||
<color name="separator">#555555</color>
|
||||
<color name="bg_search">#333333</color>
|
||||
<color name="inverse">#a0ffffff</color>
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<bool name="dark_mode">true</bool>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="match_parent_limit">
|
||||
<item name="android:layout_width">390dp</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="match_parent_limit">
|
||||
<item name="android:layout_width">510dp</item>
|
||||
</style>
|
||||
</resources>
|
||||
@@ -9,4 +9,5 @@
|
||||
<color name="accentTransparent">#B0f9a825</color>
|
||||
<color name="separator">#eeeeee</color>
|
||||
<color name="bg_search">#fefefe</color>
|
||||
<color name="inverse">#a0000000</color>
|
||||
</resources>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
<string name="format_two_names" translatable="false">%s, %s</string>
|
||||
<string name="format_two_parts" translatable="false">%s | %s</string>
|
||||
|
||||
|
||||
<integer name="terms_version_current">1</integer>
|
||||
<bool name="development_mode_default">false</bool>
|
||||
<bool name="privacy_measure_default">false</bool>
|
||||
@@ -36,6 +37,7 @@
|
||||
<bool name="show_pressure_default">true</bool>
|
||||
<bool name="show_humidity_default">true</bool>
|
||||
|
||||
<bool name="dark_mode">false</bool>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<string name="message_no_browser">Unable to open your web browser.</string>
|
||||
<string name="message_no_permission">The app is missing a required permission.</string>
|
||||
<string name="message_configure_failed">Could not open the app settings.</string>
|
||||
<string name="button_configure">Con-\figure</string>
|
||||
<string name="button_configure">Con-\nfigure</string>
|
||||
|
||||
<!-- video controls -->
|
||||
<string name="button_fit_screen">Match screen</string>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- text styles -->
|
||||
|
||||
|
||||
|
||||
<style name="match_parent_limit">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -132,17 +132,22 @@ public abstract class SdkService extends Service {
|
||||
* A listener that deactivates the service when the upload completes.
|
||||
*/
|
||||
public Observer<Boolean> uploadListener = new Observer<Boolean>() {
|
||||
/** The previous state of the upload. */
|
||||
private boolean initialized = false;
|
||||
@Override
|
||||
public void onChanged(Boolean uploading) {
|
||||
if (currentState == State.IDLE) {
|
||||
if (uploading) {
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_upload);
|
||||
} else {
|
||||
} else if (initialized) {
|
||||
channelManager.updateNotification(R.string.mowesta_sdk_notification_content_idle);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
// shutdown the service, the alarm manager will do the rest
|
||||
Log.d(TAG, "Stopping service and let alarm manager do the rest.");
|
||||
stopSelf();
|
||||
}
|
||||
} else {
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,9 @@ public class MeasureTask extends AsyncTask<Void, Void, Void> {
|
||||
public void execute() {
|
||||
start = SystemClock.elapsedRealtime();
|
||||
readBattery();
|
||||
System.out.println("Battery");
|
||||
readScreen();
|
||||
System.out.println("Screen");
|
||||
// add sensor listeners
|
||||
SensorManager manager = (SensorManager)context.getApplicationContext().getSystemService(Context.SENSOR_SERVICE);
|
||||
if (manager != null) {
|
||||
@@ -147,6 +149,7 @@ public class MeasureTask extends AsyncTask<Void, Void, Void> {
|
||||
registerSensor(manager, Sensor.TYPE_PRESSURE, "SENSOR_PRESSURE");
|
||||
registerSensor(manager, Sensor.TYPE_RELATIVE_HUMIDITY, "SENSOR_HUMIDITY");
|
||||
}
|
||||
System.out.println("Manager");
|
||||
this.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ allprojects {
|
||||
|
||||
// set version for our project
|
||||
group = 'com.mowesta'
|
||||
version = '1.0.1-SNAPSHOT'
|
||||
version = '1.0.5'
|
||||
|
||||
// set versions for our libraries
|
||||
ext {
|
||||
|
||||
Reference in New Issue
Block a user