Merge pull request #11268 from osmandapp/fix_osmand_live_p1

Fix OsmAnd Live
This commit is contained in:
Vitaliy 2021-03-29 23:17:13 +03:00 committed by GitHub
commit d4882a4591
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 957 additions and 1848 deletions

View file

@ -1,5 +1,4 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -10,40 +9,7 @@
android:id="@+id/app_bar" android:id="@+id/app_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:background="?attr/pstsTabBackground"
android:minHeight="@dimen/dashboard_map_toolbar"
android:theme="?attr/toolbar_theme"
app:contentInsetEnd="0dp"
app:contentInsetLeft="@dimen/settings_divider_margin_start"
app:contentInsetRight="0dp"
app:contentInsetStart="@dimen/settings_divider_margin_start">
<ImageButton
android:id="@+id/toolbar_action"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="end"
android:layout_marginTop="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding"
android:background="@null"
android:contentDescription="@string/shared_string_help"
tools:src="@drawable/ic_action_help" />
</androidx.appcompat.widget.Toolbar>
<include layout="@layout/preference_toolbar_switch" />
<include layout="@layout/list_item_import" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh" android:id="@+id/swipe_refresh"
@ -54,13 +20,15 @@
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clipToPadding="false"
android:divider="@null" android:divider="@null"
android:drawSelectorOnTop="true" android:drawSelectorOnTop="true"
android:footerDividersEnabled="false" android:footerDividersEnabled="false"
android:groupIndicator="@null" android:groupIndicator="@null"
android:headerDividersEnabled="false" android:headerDividersEnabled="false"
android:orientation="vertical" android:orientation="vertical"
tools:context=".liveupdates.LiveUpdatesFragmentNew" /> android:paddingBottom="@dimen/bottom_sheet_list_item_height"
tools:context=".liveupdates.LiveUpdatesFragment" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

View file

@ -84,12 +84,12 @@
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/compound_button" android:id="@+id/compound_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:focusable="false" android:focusable="false"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
tools:checked="true" /> tools:checked="true" />
</LinearLayout> </LinearLayout>

View file

@ -29,13 +29,14 @@
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<TextView <net.osmand.plus.widgets.TextViewEx
android:id="@+id/title" android:id="@+id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/osm_live" android:text="@string/osm_live"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" /> android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<TextView <TextView
android:id="@+id/description" android:id="@+id/description"
@ -70,14 +71,15 @@
android:paddingEnd="@dimen/content_padding_half" android:paddingEnd="@dimen/content_padding_half"
android:paddingRight="@dimen/content_padding_half"> android:paddingRight="@dimen/content_padding_half">
<TextView <net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:letterSpacing="@dimen/description_letter_spacing" android:letterSpacing="@dimen/description_letter_spacing"
android:text="@string/get_it" android:text="@string/get_it"
android:textColor="?attr/colorPrimary" android:textColor="?attr/colorPrimary"
android:textSize="@dimen/default_desc_text_size" /> android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/additional_button_icon" android:id="@+id/additional_button_icon"

View file

@ -12,6 +12,7 @@
--> -->
<string name="update_all_maps_added">Update all maps added to %1$s?</string>
<string name="release_4_0_beta"> <string name="release_4_0_beta">
• OsmAnd Live updates moved to \"Downloads > Updates\"\n\n • OsmAnd Live updates moved to \"Downloads > Updates\"\n\n
• Tracks now could be colorizing by altitude, speed, or slope.\n\n • Tracks now could be colorizing by altitude, speed, or slope.\n\n

View file

@ -38,8 +38,9 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.liveupdates.LiveUpdatesClearDialogFragment.RefreshLiveUpdates; import net.osmand.plus.liveupdates.LiveUpdatesClearBottomSheet.RefreshLiveUpdates;
import net.osmand.plus.liveupdates.LiveUpdatesFragmentNew; import net.osmand.plus.liveupdates.LiveUpdatesFragment;
import net.osmand.plus.liveupdates.LiveUpdatesHelper.LiveUpdateListener;
import net.osmand.plus.liveupdates.LoadLiveMapsTask; import net.osmand.plus.liveupdates.LoadLiveMapsTask;
import net.osmand.plus.liveupdates.LoadLiveMapsTask.LocalIndexInfoAdapter; import net.osmand.plus.liveupdates.LoadLiveMapsTask.LocalIndexInfoAdapter;
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType; import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogType;
@ -58,10 +59,10 @@ import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import static net.osmand.plus.liveupdates.LiveUpdatesFragmentNew.showUpdateDialog; import static net.osmand.plus.liveupdates.LiveUpdatesFragment.showUpdateDialog;
import static net.osmand.plus.liveupdates.LiveUpdatesFragmentNew.updateCountEnabled; import static net.osmand.plus.liveupdates.LiveUpdatesFragment.updateCountEnabled;
public class UpdatesIndexFragment extends OsmAndListFragment implements DownloadEvents, RefreshLiveUpdates { public class UpdatesIndexFragment extends OsmAndListFragment implements DownloadEvents, RefreshLiveUpdates, LiveUpdateListener {
private static final int RELOAD_ID = 5; private static final int RELOAD_ID = 5;
private UpdateIndexAdapter listAdapter; private UpdateIndexAdapter listAdapter;
private String errorMessage; private String errorMessage;
@ -236,7 +237,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
DownloadActivity activity = getMyActivity(); DownloadActivity activity = getMyActivity();
if (activity != null) { if (activity != null) {
if (!listAdapter.isShowOsmLivePurchaseBanner()) { if (!listAdapter.isShowOsmLivePurchaseBanner()) {
LiveUpdatesFragmentNew.showInstance(activity.getSupportFragmentManager(), this); LiveUpdatesFragment.showInstance(activity.getSupportFragmentManager(), this);
} }
} }
} else { } else {
@ -397,8 +398,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (!listAdapter.isShowOsmLivePurchaseBanner()) { if (!listAdapter.isShowOsmLivePurchaseBanner()) {
showUpdateDialog(getActivity(), getMyApplication().getSettings(), showUpdateDialog(getActivity(), getFragmentManager(), UpdatesIndexFragment.this);
listAdapter.mapsList, listAdapter.countEnabled, null);
} }
} }
}); });
@ -416,9 +416,17 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
} }
} }
@Override
public void processFinish() {
}
@Override
public List<LocalIndexInfo> getMapsToUpdate() {
return LiveUpdatesFragment.getMapsToUpdate(listAdapter.mapsList, settings);
}
@ColorRes @ColorRes
public static int getDefaultIconColorId(boolean nightMode) { public static int getDefaultIconColorId(boolean nightMode) {
return nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; return nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
} }
} }

View file

@ -32,7 +32,8 @@ public class LiveUpdatesAlarmReceiver extends BroadcastReceiver {
final OsmandSettings settings = application.getSettings(); final OsmandSettings settings = application.getSettings();
if (!preferenceDownloadViaWiFi(localIndexInfoFile, settings).get() || wifi.isWifiEnabled()) { if (!preferenceDownloadViaWiFi(localIndexInfoFile, settings).get() || wifi.isWifiEnabled()) {
new PerformLiveUpdateAsyncTask(context, localIndexInfoFile, false, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fileName); new PerformLiveUpdateAsyncTask(context, localIndexInfoFile, false)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fileName);
} else { } else {
PerformLiveUpdateAsyncTask.tryRescheduleDownload(context, settings, localIndexInfoFile); PerformLiveUpdateAsyncTask.tryRescheduleDownload(context, settings, localIndexInfoFile);
} }

View file

@ -31,10 +31,10 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getNameToDisplay;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLatestUpdateAvailable; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLatestUpdateAvailable;
public class LiveUpdatesClearDialogFragment extends MenuBottomSheetDialogFragment { public class LiveUpdatesClearBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = LiveUpdatesClearDialogFragment.class.getSimpleName(); public static final String TAG = LiveUpdatesClearBottomSheet.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(LiveUpdatesClearDialogFragment.class); private static final Log LOG = PlatformUtil.getLog(LiveUpdatesClearBottomSheet.class);
private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name"; private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name";
private OsmandApplication app; private OsmandApplication app;
@ -44,7 +44,7 @@ public class LiveUpdatesClearDialogFragment extends MenuBottomSheetDialogFragmen
public static void showInstance(@NonNull FragmentManager fragmentManager, Fragment target, String fileName) { public static void showInstance(@NonNull FragmentManager fragmentManager, Fragment target, String fileName) {
if (!fragmentManager.isStateSaved()) { if (!fragmentManager.isStateSaved()) {
LiveUpdatesClearDialogFragment fragment = new LiveUpdatesClearDialogFragment(); LiveUpdatesClearBottomSheet fragment = new LiveUpdatesClearBottomSheet();
fragment.setTargetFragment(target, 0); fragment.setTargetFragment(target, 0);
fragment.fileName = fileName; fragment.fileName = fileName;
fragment.show(fragmentManager, TAG); fragment.show(fragmentManager, TAG);

File diff suppressed because it is too large Load diff

View file

@ -1,706 +0,0 @@
package net.osmand.plus.liveupdates;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.ExpandableListView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.SwitchCompat;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import net.osmand.AndroidNetworkUtils;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.CompoundButtonType;
import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.liveupdates.LiveUpdatesClearDialogFragment.RefreshLiveUpdates;
import net.osmand.plus.liveupdates.LiveUpdatesHelper.TimeOfDay;
import net.osmand.plus.liveupdates.LiveUpdatesHelper.UpdateFrequency;
import net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.OnLiveUpdatesForLocalChange;
import net.osmand.plus.liveupdates.LoadLiveMapsTask.LocalIndexInfoAdapter;
import net.osmand.plus.liveupdates.PerformLiveUpdateAsyncTask.LiveUpdateListener;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.lang.ref.WeakReference;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import static net.osmand.AndroidUtils.getSecondaryTextColorId;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.formatShortDateTime;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getNameToDisplay;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceForLocalIndex;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLatestUpdateAvailable;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceTimeOfDayToUpdate;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFrequency;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.runLiveUpdate;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.setAlarmForPendingIntent;
import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.getTertiaryTextColorId;
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getActiveTextColorId;
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getOsmandIconColorId;
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getSecondaryIconColorId;
public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements OnLiveUpdatesForLocalChange {
public static final String URL = "https://osmand.net/api/osmlive_status";
public static final String TAG = LiveUpdatesFragmentNew.class.getSimpleName();
private final static Log LOG = PlatformUtil.getLog(LiveUpdatesFragmentNew.class);
private static final String SUBSCRIPTION_URL = "https://osmand.net/features/subscription";
private OsmandApplication app;
private OsmandSettings settings;
private boolean nightMode;
private View toolbarSwitchContainer;
private ExpandableListView listView;
private TextViewEx descriptionTime;
private LiveMapsAdapter adapter;
private GetLastUpdateDateTask getLastUpdateDateTask;
private LoadLiveMapsTask loadLiveMapsTask;
private final LiveUpdateListener liveUpdateListener = new LiveUpdateListener() {
@Override
public void processFinish() {
adapter.notifyDataSetChanged();
}
};
public static void showInstance(@NonNull FragmentManager fragmentManager, Fragment target) {
if (!fragmentManager.isStateSaved()) {
LiveUpdatesFragmentNew fragment = new LiveUpdatesFragmentNew();
fragment.setTargetFragment(target, 0);
fragment.show(fragmentManager, TAG);
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
settings = getSettings();
nightMode = isNightMode(false);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_live_updates, container, false);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setTitle(R.string.osm_live);
int iconColorResId = nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light;
Drawable icBack = app.getUIUtilities().getIcon(AndroidUtils.getNavigationIconResId(app), iconColorResId);
DrawableCompat.setTint(icBack, ContextCompat.getColor(app, iconColorResId));
toolbar.setNavigationIcon(icBack);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
ImageButton iconHelp = toolbar.findViewById(R.id.toolbar_action);
Drawable helpDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_help, iconColorResId);
iconHelp.setImageDrawable(helpDrawable);
iconHelp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(SUBSCRIPTION_URL));
if (AndroidUtils.isIntentSafe(app, intent)) {
startActivity(intent);
}
}
});
listView = (ExpandableListView) view.findViewById(android.R.id.list);
adapter = new LiveMapsAdapter();
listView.setAdapter(adapter);
expandAllGroups();
View bottomShadowView = inflater.inflate(R.layout.card_bottom_divider, listView, false);
listView.addFooterView(bottomShadowView);
listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app) && settings.IS_LIVE_UPDATES_ON.get()) {
if (getFragmentManager() != null) {
LiveUpdatesSettingsDialogFragmentNew
.showInstance(getFragmentManager(), LiveUpdatesFragmentNew.this,
adapter.getChild(groupPosition, childPosition).getFileName());
}
return true;
} else {
return false;
}
}
});
final SwipeRefreshLayout swipeRefresh = view.findViewById(R.id.swipe_refresh);
int swipeColor = ContextCompat.getColor(app, nightMode ? R.color.osmand_orange_dark : R.color.osmand_orange);
swipeRefresh.setColorSchemeColors(swipeColor);
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (settings.IS_LIVE_UPDATES_ON.get()) {
showUpdateDialog(getActivity(), settings, adapter.mapsList, adapter.countEnabled, liveUpdateListener);
startUpdateDateAsyncTask();
}
swipeRefresh.setRefreshing(false);
}
});
toolbarSwitchContainer = view.findViewById(R.id.toolbar_switch_container);
updateToolbarSwitch(settings.IS_LIVE_UPDATES_ON.get());
View timeContainer = view.findViewById(R.id.item_import_container);
AndroidUtils.setListItemBackground(app, timeContainer, nightMode);
AppCompatImageView descriptionIcon = timeContainer.findViewById(R.id.icon);
Drawable icon = UiUtilities.createTintedDrawable(app, R.drawable.ic_action_time,
ContextCompat.getColor(app, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light));
descriptionIcon.setImageDrawable(icon);
TextViewEx title = timeContainer.findViewById(R.id.title);
AndroidUtils.setTextSecondaryColor(app, title, nightMode);
title.setText(R.string.latest_openstreetmap_update);
title.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_desc_text_size));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
title.setLetterSpacing(AndroidUtils.getFloatValueFromRes(app, R.dimen.description_letter_spacing));
}
descriptionTime = timeContainer.findViewById(R.id.sub_title);
AndroidUtils.setTextPrimaryColor(app, descriptionTime, nightMode);
Typeface typeface = FontCache.getFont(app, getString(R.string.font_roboto_medium));
descriptionTime.setTypeface(typeface);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
descriptionTime.setLetterSpacing(AndroidUtils.getFloatValueFromRes(app, R.dimen.description_letter_spacing));
}
return view;
}
@Override
public void onResume() {
super.onResume();
startUpdateDateAsyncTask();
startLoadLiveMapsAsyncTask();
}
@Override
public void onPause() {
super.onPause();
stopUpdateDateAsyncTask();
stopLoadLiveMapsAsyncTask();
}
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
super.onDismiss(dialog);
Fragment target = getTargetFragment();
if (target instanceof RefreshLiveUpdates) {
((RefreshLiveUpdates) target).onUpdateStates(app);
}
}
private void startUpdateDateAsyncTask() {
getLastUpdateDateTask = new GetLastUpdateDateTask(this);
getLastUpdateDateTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
private void stopUpdateDateAsyncTask() {
if (getLastUpdateDateTask != null) {
getLastUpdateDateTask.cancel(true);
}
}
private void startLoadLiveMapsAsyncTask() {
if (loadLiveMapsTask == null) {
loadLiveMapsTask = new LoadLiveMapsTask(adapter, app);
loadLiveMapsTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
private void stopLoadLiveMapsAsyncTask() {
if (loadLiveMapsTask != null && loadLiveMapsTask.getStatus() == AsyncTask.Status.RUNNING) {
loadLiveMapsTask.cancel(false);
}
}
private void updateToolbarSwitch(final boolean isChecked) {
int switchColor = ContextCompat.getColor(app,
isChecked ? getActiveTextColorId(nightMode) : getSecondaryTextColorId(nightMode));
AndroidUtils.setBackground(toolbarSwitchContainer, new ColorDrawable(switchColor));
SwitchCompat switchView = toolbarSwitchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(isChecked);
UiUtilities.setupCompoundButton(switchView, nightMode, CompoundButtonType.TOOLBAR);
toolbarSwitchContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean visible = !isChecked;
if (visible) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
switchOnLiveUpdates();
updateToolbarSwitch(true);
} else {
app.showToastMessage(getString(R.string.osm_live_ask_for_purchase));
updateToolbarSwitch(false);
}
} else {
settings.IS_LIVE_UPDATES_ON.set(false);
enableLiveUpdates(false);
updateToolbarSwitch(false);
}
updateList();
}
});
TextView title = toolbarSwitchContainer.findViewById(R.id.switchButtonText);
title.setText(isChecked ? R.string.shared_string_enabled : R.string.shared_string_disabled);
}
private void switchOnLiveUpdates() {
settings.IS_LIVE_UPDATES_ON.set(true);
enableLiveUpdates(true);
showUpdateDialog(getMyActivity(), settings, adapter.mapsList, adapter.countEnabled, liveUpdateListener);
startUpdateDateAsyncTask();
}
public static void showUpdateDialog(final Activity context, final OsmandSettings settings,
final ArrayList<LocalIndexInfo> mapsList, int countEnabled,
@Nullable final LiveUpdateListener listener) {
if (!Algorithms.isEmpty(mapsList)) {
if (countEnabled == 1) {
LocalIndexInfo li = mapsList.get(0);
runLiveUpdate(context, li.getFileName(), false, listener);
} else if (countEnabled > 1) {
AlertDialog.Builder bld = new AlertDialog.Builder(context);
bld.setMessage(R.string.update_all_maps_now);
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (LocalIndexInfo li : mapsList) {
CommonPreference<Boolean> localUpdateOn = preferenceForLocalIndex(li.getFileName(), settings);
if (localUpdateOn.get()) {
runLiveUpdate(context, li.getFileName(), false, listener);
}
}
}
});
bld.setNegativeButton(R.string.shared_string_no, null);
bld.show();
}
}
}
private void enableLiveUpdates(boolean enable) {
if (!Algorithms.isEmpty(adapter.mapsList)) {
AlarmManager alarmMgr = (AlarmManager) app.getSystemService(Context.ALARM_SERVICE);
for (LocalIndexInfo li : adapter.mapsList) {
CommonPreference<Boolean> localUpdateOn = preferenceForLocalIndex(li.getFileName(), settings);
if (localUpdateOn.get()) {
String fileName = li.getFileName();
PendingIntent alarmIntent = getPendingIntent(app, fileName);
if (enable) {
final CommonPreference<Integer> updateFrequencyPreference =
preferenceUpdateFrequency(fileName, settings);
final CommonPreference<Integer> timeOfDayPreference =
preferenceTimeOfDayToUpdate(fileName, settings);
UpdateFrequency updateFrequency = UpdateFrequency.values()[updateFrequencyPreference.get()];
TimeOfDay timeOfDayToUpdate = TimeOfDay.values()[timeOfDayPreference.get()];
setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate);
} else {
alarmMgr.cancel(alarmIntent);
}
}
}
}
}
private void expandAllGroups() {
for (int i = 0; i < adapter.getGroupCount(); i++) {
listView.expandGroup(i);
}
}
public static int updateCountEnabled(TextView countView, ArrayList<LocalIndexInfo> mapsList, OsmandSettings settings) {
int countEnabled = 0;
if (countView != null) {
for (LocalIndexInfo map : mapsList) {
CommonPreference<Boolean> preference = preferenceForLocalIndex(map.getFileName(), settings);
if (preference.get()) {
countEnabled++;
}
}
String countText = countEnabled + "/" + mapsList.size();
countView.setText(countText);
}
return countEnabled;
}
protected class LiveMapsAdapter extends OsmandBaseExpandableListAdapter implements LocalIndexInfoAdapter {
private final ArrayList<LocalIndexInfo> mapsList = new ArrayList<>();
private int countEnabled = 0;
private TextViewEx countView;
@Override
public void addData(LocalIndexInfo info) {
mapsList.add(info);
}
@Override
public void clearData() {
mapsList.clear();
}
@Override
public void onDataUpdated() {
sort();
countEnabled = updateCountEnabled(countView, mapsList, settings);
}
public void sort() {
Collections.sort(mapsList);
Collections.sort(mapsList, new Comparator<LocalIndexInfo>() {
@Override
public int compare(LocalIndexInfo o1, LocalIndexInfo o2) {
CommonPreference<Boolean> preference1 = preferenceForLocalIndex(o1.getFileName(), getSettings());
CommonPreference<Boolean> preference2 = preferenceForLocalIndex(o2.getFileName(), getSettings());
return preference2.get().compareTo(preference1.get());
}
});
notifyDataSetInvalidated();
}
@Override
public LocalIndexInfo getChild(int groupPosition, int childPosition) {
return mapsList.get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return groupPosition * 10000 + childPosition; // it would be unusable to have 10000 local indexes
}
@Override
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
convertView = inflater.inflate(R.layout.list_item_triple_row_icon_and_menu, parent, false);
LiveMapsViewHolder viewHolder = new LiveMapsViewHolder(convertView);
convertView.setTag(viewHolder);
viewHolder.bindLocalIndexInfo(getChild(groupPosition, childPosition).getFileName());
return convertView;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
view = inflater.inflate(R.layout.list_group_title_with_right_descr, parent, false);
}
view.setOnClickListener(null);
View topShadowView = view.findViewById(R.id.bottomShadowView);
if (groupPosition == 0) {
topShadowView.setVisibility(View.GONE);
} else {
topShadowView.setVisibility(View.VISIBLE);
}
TextViewEx titleView = ((TextViewEx) view.findViewById(R.id.title));
titleView.setText(getGroup(groupPosition));
countView = ((TextViewEx) view.findViewById(R.id.description));
AndroidUtils.setTextSecondaryColor(app, countView, nightMode);
return view;
}
@Override
public int getChildrenCount(int groupPosition) {
return mapsList.size();
}
@Override
public String getGroup(int groupPosition) {
return getString(R.string.available_maps);
}
@Override
public int getGroupCount() {
return 1;
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
private class LiveMapsViewHolder {
private final ImageView statusIcon;
private final TextView title;
private final TextView subTitle;
private final TextView description;
private final CompoundButton option;
private LiveMapsViewHolder(View view) {
statusIcon = (AppCompatImageView) view.findViewById(R.id.icon);
title = (TextView) view.findViewById(R.id.title);
subTitle = (TextView) view.findViewById(R.id.sub_title);
description = (TextView) view.findViewById(R.id.description);
option = (CompoundButton) view.findViewById(R.id.compound_button);
}
public void bindLocalIndexInfo(@NonNull final String item) {
boolean liveUpdateOn = settings.IS_LIVE_UPDATES_ON.get();
CommonPreference<Boolean> localUpdateOn = preferenceForLocalIndex(item, settings);
// IncrementalChangesManager changesManager = app.getResourceManager().getChangesManager();
option.setChecked(localUpdateOn.get());
if (!liveUpdateOn && localUpdateOn.get()) {
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app, getTertiaryTextColorId(nightMode)), option);
} else {
UiUtilities.setupCompoundButton(option, nightMode, CompoundButtonType.GLOBAL);
}
title.setText(getNameToDisplay(item, app));
AndroidUiHelper.updateVisibility(subTitle, localUpdateOn.get());
if (localUpdateOn.get()) {
int frequencyId = preferenceUpdateFrequency(item, settings).get();
final UpdateFrequency frequency = UpdateFrequency.values()[frequencyId];
String subTitleText = getString(frequency.getLocalizedId());
/*int timeOfDateToUpdateId = preferenceTimeOfDayToUpdate(item, settings).get();
final TimeOfDay timeOfDay = TimeOfDay.values()[timeOfDateToUpdateId];
if (frequency != UpdateFrequency.HOURLY) {
subTitleText += "" + getString(timeOfDay.getLocalizedId());
}*/
subTitle.setText(subTitleText);
subTitle.setTextColor(ContextCompat.getColor(app, liveUpdateOn
? getActiveTextColorId(nightMode) : getSecondaryTextColorId(nightMode)));
Typeface typeface = FontCache.getFont(app, getString(R.string.font_roboto_medium));
subTitle.setTypeface(typeface);
}
Drawable statusDrawable = AppCompatResources.getDrawable(app, R.drawable.ic_map);
int resColorId = !localUpdateOn.get() ? getSecondaryIconColorId(nightMode) :
!liveUpdateOn ? getDefaultIconColorId(nightMode) : getOsmandIconColorId(nightMode);
int statusColor = ContextCompat.getColor(app, resColorId);
if (statusDrawable != null) {
DrawableCompat.setTint(statusDrawable, statusColor);
}
statusIcon.setImageDrawable(statusDrawable);
description.setText(getLastCheckString(item, app));
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
option.setEnabled(liveUpdateOn);
option.setOnCheckedChangeListener(new SwitchCompat.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
onUpdateLocalIndex(item, isChecked, null);
}
});
} else {
option.setEnabled(false);
}
}
}
public static class GetLastUpdateDateTask extends AsyncTask<Void, Void, String> {
private final OsmandApplication app;
private final WeakReference<LiveUpdatesFragmentNew> fragment;
GetLastUpdateDateTask(LiveUpdatesFragmentNew fragment) {
this.fragment = new WeakReference<>(fragment);
app = fragment.getMyApplication();
}
@Override
protected String doInBackground(Void... params) {
try {
return AndroidNetworkUtils.sendRequest(app, URL, null,
"Requesting map updates info...", false, false);
} catch (Exception e) {
LOG.error("Error: " + "Requesting map updates info error", e);
return null;
}
}
@Override
protected void onPostExecute(String response) {
LiveUpdatesFragmentNew f = fragment.get();
if (response != null && f != null) {
TextViewEx descriptionTime = f.descriptionTime;
if (descriptionTime != null) {
SimpleDateFormat source = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
source.setTimeZone(TimeZone.getTimeZone("UTC"));
SimpleDateFormat dest = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
dest.setTimeZone(TimeZone.getDefault());
try {
LOG.debug("response = " + response);
Date parsed = source.parse(response);
if (parsed != null) {
long dateTime = parsed.getTime();
LOG.debug("dateTime = " + dateTime);
descriptionTime.setText(dest.format(parsed));
}
} catch (ParseException e) {
LOG.error(e.getMessage());
}
}
}
}
}
protected static String getLastCheckString(String fileName, OsmandApplication app) {
return getLastCheckString(fileName, app, false);
}
protected static String getLastCheckString(String fileName, OsmandApplication app, boolean lastTimeChecked) {
OsmandSettings settings = app.getSettings();
final long lastUpdate = preferenceLatestUpdateAvailable(fileName, settings).get();
String lastUpdateString = formatShortDateTime(app, lastUpdate);
String description = app.getString(R.string.updated, lastUpdateString);
if (lastTimeChecked) {
final long lastCheck = preferenceLastCheck(fileName, settings).get();
String lastCheckString = formatShortDateTime(app, lastCheck);
if (!lastUpdateString.equals(app.getString(R.string.shared_string_never))) {
description = description.concat("\n" + app.getString(R.string.last_time_checked, lastCheckString));
}
}
return description;
}
@Override
public boolean onUpdateLocalIndex(String fileName, boolean newValue, final Runnable callback) {
int frequencyId = preferenceUpdateFrequency(fileName, settings).get();
int timeOfDateToUpdateId = preferenceTimeOfDayToUpdate(fileName, settings).get();
final AlarmManager alarmManager = (AlarmManager) app.getSystemService(Context.ALARM_SERVICE);
final PendingIntent alarmIntent = getPendingIntent(app, fileName);
final CommonPreference<Boolean> liveUpdatePreference = preferenceForLocalIndex(fileName, settings);
liveUpdatePreference.set(newValue);
if (settings.IS_LIVE_UPDATES_ON.get() && liveUpdatePreference.get()) {
runLiveUpdate(getActivity(), fileName, true, new LiveUpdateListener() {
@Override
public void processFinish() {
runSort();
if (callback != null) {
callback.run();
}
}
});
UpdateFrequency updateFrequency = UpdateFrequency.values()[frequencyId];
TimeOfDay timeOfDayToUpdate = TimeOfDay.values()[timeOfDateToUpdateId];
setAlarmForPendingIntent(alarmIntent, alarmManager, updateFrequency, timeOfDayToUpdate);
} else {
alarmManager.cancel(alarmIntent);
runSort();
}
return true;
}
@Override
public void forceUpdateLocal(String fileName, boolean userRequested, final Runnable callback) {
if (settings.IS_LIVE_UPDATES_ON.get()) {
runLiveUpdate(getActivity(), fileName, userRequested, new LiveUpdateListener() {
@Override
public void processFinish() {
updateList();
if (callback != null) {
callback.run();
}
}
});
}
}
@Override
public void runSort() {
if (adapter != null) {
adapter.onDataUpdated();
}
}
@Override
public void updateList() {
if (adapter != null) {
adapter.notifyDataSetChanged();
}
}
@ColorRes
public static int getDefaultIconColorId(boolean nightMode) {
return nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
}
}

View file

@ -9,9 +9,10 @@ import android.text.format.DateUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.liveupdates.PerformLiveUpdateAsyncTask.LiveUpdateListener; import net.osmand.plus.activities.LocalIndexInfo;
import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -20,6 +21,7 @@ import net.osmand.util.Algorithms;
import java.io.File; import java.io.File;
import java.util.Calendar; import java.util.Calendar;
import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class LiveUpdatesHelper { public class LiveUpdatesHelper {
@ -254,8 +256,27 @@ public class LiveUpdatesHelper {
} }
} }
public static void runLiveUpdate(Context context, final String fileName, boolean userRequested, @Nullable final LiveUpdateListener listener) { public static void runLiveUpdate(Context context, final String fileName, boolean userRequested, @Nullable final Runnable runOnSuccess) {
final String fnExt = Algorithms.getFileNameWithoutExtension(new File(fileName)); final String fnExt = Algorithms.getFileNameWithoutExtension(new File(fileName));
new PerformLiveUpdateAsyncTask(context, fileName, userRequested, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fnExt); PerformLiveUpdateAsyncTask task = new PerformLiveUpdateAsyncTask(context, fileName, userRequested);
task.setRunOnSuccess(runOnSuccess);
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, fnExt);
}
public static void runLiveUpdate(Context context, boolean userRequested, final LiveUpdateListener listener) {
for (LocalIndexInfo mapToUpdate : listener.getMapsToUpdate()) {
runLiveUpdate(context, mapToUpdate.getFileName(), userRequested, new Runnable() {
@Override
public void run() {
listener.processFinish();
}
});
}
}
public interface LiveUpdateListener {
void processFinish();
List<LocalIndexInfo> getMapsToUpdate();
} }
} }

View file

@ -36,7 +36,7 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.liveupdates.LiveUpdatesClearDialogFragment.RefreshLiveUpdates; import net.osmand.plus.liveupdates.LiveUpdatesClearBottomSheet.RefreshLiveUpdates;
import net.osmand.plus.liveupdates.LiveUpdatesHelper.TimeOfDay; import net.osmand.plus.liveupdates.LiveUpdatesHelper.TimeOfDay;
import net.osmand.plus.liveupdates.LiveUpdatesHelper.UpdateFrequency; import net.osmand.plus.liveupdates.LiveUpdatesHelper.UpdateFrequency;
import net.osmand.plus.resources.IncrementalChangesManager; import net.osmand.plus.resources.IncrementalChangesManager;
@ -68,28 +68,30 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFreq
import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView; import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView;
import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView; import static net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView;
public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogFragment implements RefreshLiveUpdates { public class LiveUpdatesSettingsBottomSheet extends MenuBottomSheetDialogFragment implements RefreshLiveUpdates {
public static final String TAG = LiveUpdatesSettingsDialogFragmentNew.class.getSimpleName(); public static final String TAG = LiveUpdatesSettingsBottomSheet.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(LiveUpdatesSettingsDialogFragmentNew.class); private static final Log LOG = PlatformUtil.getLog(LiveUpdatesSettingsBottomSheet.class);
private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name"; private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name";
private OsmandApplication app; private OsmandApplication app;
private OsmandSettings settings; private OsmandSettings settings;
private OnLiveUpdatesForLocalChange onLiveUpdatesForLocalChange;
private BaseBottomSheetItem itemTitle;
private BaseBottomSheetItem itemLastCheck;
private BaseBottomSheetItem itemSwitchLiveUpdate;
private BaseBottomSheetItem itemFrequencyHelpMessage;
private BaseBottomSheetItem itemClear;
private BaseBottomSheetItem itemViaWiFi;
private MultiStateToggleButton frequencyToggleButton; private MultiStateToggleButton frequencyToggleButton;
private MultiStateToggleButton timeOfDayToggleButton; private MultiStateToggleButton timeOfDayToggleButton;
private String fileName; private String fileName;
private int indexLastCheckItem = -1; private OnLiveUpdatesForLocalChange onLiveUpdatesForLocalChange;
private int indexSwitchLiveUpdateItem = -1;
private int indexFrequencyHelpMessageItem = -1;
private int indexClearItem = -1;
private int indexViaWiFiItem = -1;
public static void showInstance(@NonNull FragmentManager fragmentManager, Fragment target, String fileName) { public static void showInstance(@NonNull FragmentManager fragmentManager, Fragment target, String fileName) {
if (!fragmentManager.isStateSaved()) { if (!fragmentManager.isStateSaved()) {
LiveUpdatesSettingsDialogFragmentNew fragment = new LiveUpdatesSettingsDialogFragmentNew(); LiveUpdatesSettingsBottomSheet fragment = new LiveUpdatesSettingsBottomSheet();
fragment.setTargetFragment(target, 0); fragment.setTargetFragment(target, 0);
fragment.fileName = fileName; fragment.fileName = fileName;
fragment.show(fragmentManager, TAG); fragment.show(fragmentManager, TAG);
@ -111,31 +113,33 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
CommonPreference<Boolean> downloadViaWiFiPreference = preferenceDownloadViaWiFi(fileName, settings); CommonPreference<Boolean> downloadViaWiFiPreference = preferenceDownloadViaWiFi(fileName, settings);
CommonPreference<Integer> frequencyPreference = preferenceUpdateFrequency(fileName, settings); CommonPreference<Integer> frequencyPreference = preferenceUpdateFrequency(fileName, settings);
CommonPreference<Integer> timeOfDayPreference = preferenceTimeOfDayToUpdate(fileName, settings); CommonPreference<Integer> timeOfDayPreference = preferenceTimeOfDayToUpdate(fileName, settings);
int dp4 = getDimen(R.dimen.list_item_button_padding);
int dp12 = getDimen(R.dimen.content_padding_small); int dp12 = getDimen(R.dimen.content_padding_small);
int dp16 = getDimen(R.dimen.content_padding); int dp16 = getDimen(R.dimen.content_padding);
int dp40 = getDimen(R.dimen.list_header_height); int dp36 = getDimen(R.dimen.dialog_button_height);
int dp48 = getDimen(R.dimen.context_menu_buttons_bottom_height); int dp48 = getDimen(R.dimen.context_menu_buttons_bottom_height);
items.add(new SimpleBottomSheetItem.Builder() itemTitle = new SimpleBottomSheetItem.Builder()
.setTitle(getNameToDisplay(fileName, app)) .setTitle(getNameToDisplay(fileName, app))
.setTitleColorId(getPrimaryTextColorId(nightMode)) .setTitleColorId(getPrimaryTextColorId(nightMode))
.setLayoutId(R.layout.bottom_sheet_item_title_big) .setLayoutId(R.layout.bottom_sheet_item_title_big)
.create()); .create();
items.add(itemTitle);
items.add(new ShortDescriptionItem.Builder() itemLastCheck = new ShortDescriptionItem.Builder()
.setDescription(getLastCheckString()) .setDescription(getLastCheckString())
.setDescriptionColorId(getSecondaryTextColorId(nightMode)) .setDescriptionColorId(getSecondaryTextColorId(nightMode))
.setDescriptionMaxLines(2) .setDescriptionMaxLines(2)
.setLayoutId(R.layout.bottom_sheet_item_description) .setLayoutId(R.layout.bottom_sheet_item_description)
.create()); .create();
indexLastCheckItem = items.size() - 1; items.add(itemLastCheck);
View itemLiveUpdate = getCustomButtonView(app, null, localUpdatePreference.get(), nightMode); View itemLiveUpdate = getCustomButtonView(app, null, localUpdatePreference.get(), nightMode);
View itemLiveUpdateButton = itemLiveUpdate.findViewById(R.id.button_container); View itemLiveUpdateButton = itemLiveUpdate.findViewById(R.id.button_container);
CompoundButton button = (CompoundButton) itemLiveUpdateButton.findViewById(R.id.compound_button); CompoundButton button = (CompoundButton) itemLiveUpdateButton.findViewById(R.id.compound_button);
UiUtilities.setupCompoundButton(button, nightMode, TOOLBAR); UiUtilities.setupCompoundButton(button, nightMode, TOOLBAR);
itemLiveUpdateButton.setMinimumHeight(getDimen(R.dimen.bottom_sheet_selected_item_title_height)); itemLiveUpdateButton.setMinimumHeight(getDimen(R.dimen.bottom_sheet_selected_item_title_height));
items.add(new BottomSheetItemWithCompoundButton.Builder() itemSwitchLiveUpdate = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(localUpdatePreference.get()) .setChecked(localUpdatePreference.get())
.setTitle(getStateText(localUpdatePreference.get())) .setTitle(getStateText(localUpdatePreference.get()))
.setTitleColorId(getActiveTabTextColorId(nightMode)) .setTitleColorId(getActiveTabTextColorId(nightMode))
@ -143,45 +147,84 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (indexSwitchLiveUpdateItem != -1) { BottomSheetItemWithCompoundButton item = (BottomSheetItemWithCompoundButton) itemSwitchLiveUpdate;
BottomSheetItemWithCompoundButton button = (BottomSheetItemWithCompoundButton) items.get(indexSwitchLiveUpdateItem); boolean checked = item.isChecked();
button.setChecked(!button.isChecked()); item.setChecked(!checked);
if (onLiveUpdatesForLocalChange != null if (onLiveUpdatesForLocalChange != null
&& onLiveUpdatesForLocalChange.onUpdateLocalIndex(fileName, button.isChecked(), new Runnable() { && onLiveUpdatesForLocalChange.onUpdateLocalIndex(fileName, !checked, new Runnable() {
@Override @Override
public void run() { public void run() {
updateLastCheck(); updateLastCheck();
updateFrequencyHelpMessage(); updateFrequencyHelpMessage();
updateFileSize(); updateFileSize();
Fragment target = getTargetFragment();
if (target instanceof LiveUpdatesFragment) {
((LiveUpdatesFragment) target).runSort();
}
} }
})) { })) {
if (indexSwitchLiveUpdateItem != -1 && items.size() > 0) { item.setTitle(getStateText(!checked));
button.setTitle(getStateText(button.isChecked())); updateCustomButtonView(app, null, item.getView(), !checked, nightMode);
updateCustomButtonView(app, null, button.getView(), button.isChecked(), nightMode);
}
CommonPreference<Boolean> localUpdatePreference = preferenceForLocalIndex(fileName, settings); CommonPreference<Boolean> localUpdatePreference = preferenceForLocalIndex(fileName, settings);
frequencyToggleButton.updateView(localUpdatePreference.get()); frequencyToggleButton.updateView(localUpdatePreference.get());
timeOfDayToggleButton.updateView(localUpdatePreference.get()); timeOfDayToggleButton.updateView(localUpdatePreference.get());
setStateViaWiFiButton(localUpdatePreference); setStateViaWiFiButton(localUpdatePreference);
} }
} }
}
}) })
.create();
items.add(itemSwitchLiveUpdate);
Typeface typefaceRegular = FontCache.getRobotoRegular(app);
TextViewEx timeOfDayTitle = (TextViewEx) inflater.inflate(R.layout.bottom_sheet_item_title, null);
timeOfDayTitle.setHeight(dp48);
timeOfDayTitle.setMinimumHeight(dp48);
timeOfDayTitle.setText(R.string.update_time);
timeOfDayTitle.setTypeface(typefaceRegular);
AndroidUtils.setPadding(timeOfDayTitle, timeOfDayTitle.getPaddingLeft(), dp4, timeOfDayTitle.getPaddingRight(), dp4);
AndroidUtils.setTextPrimaryColor(app, timeOfDayTitle, nightMode);
items.add(new BaseBottomSheetItem.Builder()
.setCustomView(timeOfDayTitle)
.create()); .create());
indexSwitchLiveUpdateItem = items.size() - 1;
LinearLayout itemTimeOfDayButtons = (LinearLayout) inflater.inflate(R.layout.custom_radio_buttons, null);
LinearLayout.MarginLayoutParams itemTimeOfDayParams = new LinearLayout.MarginLayoutParams(
LinearLayout.MarginLayoutParams.MATCH_PARENT, LinearLayout.MarginLayoutParams.WRAP_CONTENT);
AndroidUtils.setMargins(itemTimeOfDayParams, dp16, 0, dp16, 0);
itemTimeOfDayButtons.setLayoutParams(itemTimeOfDayParams);
String morning = getString(R.string.morning);
String night = getString(R.string.night);
RadioItem morningButton = new RadioItem(morning);
RadioItem nightButton = new RadioItem(night);
timeOfDayToggleButton = new MultiStateToggleButton(app, itemTimeOfDayButtons, nightMode);
timeOfDayToggleButton.setItems(morningButton, nightButton);
setSelectedRadioItem(timeOfDayToggleButton, timeOfDayPreference.get(), morningButton, nightButton);
timeOfDayToggleButton.updateView(localUpdatePreference.get());
refreshTimeOfDayLayout(frequencyPreference.get(), itemTimeOfDayButtons, timeOfDayTitle);
morningButton.setOnClickListener(getTimeOfDayButtonListener(TimeOfDay.MORNING));
nightButton.setOnClickListener(getTimeOfDayButtonListener(TimeOfDay.NIGHT));
items.add(new BaseBottomSheetItem.Builder()
.setCustomView(itemTimeOfDayButtons)
.create()
);
TextViewEx frequencyTitle = (TextViewEx) inflater.inflate(R.layout.bottom_sheet_item_title, null); TextViewEx frequencyTitle = (TextViewEx) inflater.inflate(R.layout.bottom_sheet_item_title, null);
frequencyTitle.setHeight(dp48); frequencyTitle.setHeight(dp48);
frequencyTitle.setMinimumHeight(dp48); frequencyTitle.setMinimumHeight(dp48);
frequencyTitle.setText(R.string.update_frequency); frequencyTitle.setText(R.string.update_frequency);
AndroidUtils.setPadding(frequencyTitle, frequencyTitle.getPaddingLeft(), 0, frequencyTitle.getPaddingRight(), 0); frequencyTitle.setTypeface(typefaceRegular);
AndroidUtils.setPadding(frequencyTitle, frequencyTitle.getPaddingLeft(), dp4, frequencyTitle.getPaddingRight(), dp4);
AndroidUtils.setTextPrimaryColor(app, frequencyTitle, nightMode); AndroidUtils.setTextPrimaryColor(app, frequencyTitle, nightMode);
items.add(new BaseBottomSheetItem.Builder() items.add(new BaseBottomSheetItem.Builder()
.setCustomView(frequencyTitle) .setCustomView(frequencyTitle)
.create()); .create());
LinearLayout itemFrequencyButtons = (LinearLayout) inflater.inflate(R.layout.custom_radio_buttons, null); LinearLayout itemFrequencyButtons = (LinearLayout) inflater.inflate(R.layout.custom_radio_buttons, null);
LinearLayout.MarginLayoutParams itemFrequencyParams = new LinearLayout.MarginLayoutParams(LinearLayout.MarginLayoutParams.MATCH_PARENT, LinearLayout.MarginLayoutParams.WRAP_CONTENT); LinearLayout.MarginLayoutParams itemFrequencyParams = new LinearLayout.MarginLayoutParams(
LinearLayout.MarginLayoutParams.MATCH_PARENT, LinearLayout.MarginLayoutParams.WRAP_CONTENT);
AndroidUtils.setMargins(itemFrequencyParams, dp16, 0, dp16, dp12); AndroidUtils.setMargins(itemFrequencyParams, dp16, 0, dp16, dp12);
itemFrequencyButtons.setLayoutParams(itemFrequencyParams); itemFrequencyButtons.setLayoutParams(itemFrequencyParams);
@ -200,58 +243,27 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
.setCustomView(itemFrequencyButtons) .setCustomView(itemFrequencyButtons)
.create()); .create());
TextViewEx timeOfDayTitle = (TextViewEx) inflater.inflate(R.layout.bottom_sheet_item_title, null);
timeOfDayTitle.setHeight(dp40);
timeOfDayTitle.setMinimumHeight(dp40);
timeOfDayTitle.setText(R.string.update_time);
AndroidUtils.setPadding(timeOfDayTitle, timeOfDayTitle.getPaddingLeft(), 0, timeOfDayTitle.getPaddingRight(), 0);
AndroidUtils.setTextPrimaryColor(app, timeOfDayTitle, nightMode);
items.add(new BaseBottomSheetItem.Builder()
.setCustomView(timeOfDayTitle)
.create());
LinearLayout itemTimeOfDayButtons = (LinearLayout) inflater.inflate(R.layout.custom_radio_buttons, null);
LinearLayout.MarginLayoutParams itemTimeOfDayParams = new LinearLayout.MarginLayoutParams(LinearLayout.MarginLayoutParams.MATCH_PARENT, LinearLayout.MarginLayoutParams.WRAP_CONTENT);
AndroidUtils.setMargins(itemTimeOfDayParams, dp16, 0, dp16, getDimen(R.dimen.context_menu_padding_margin_medium));
itemTimeOfDayButtons.setLayoutParams(itemTimeOfDayParams);
String morning = getString(R.string.morning);
String night = getString(R.string.night);
RadioItem morningButton = new RadioItem(morning);
RadioItem nightButton = new RadioItem(night);
timeOfDayToggleButton = new MultiStateToggleButton(app, itemTimeOfDayButtons, nightMode);
timeOfDayToggleButton.setItems(morningButton, nightButton);
setSelectedRadioItem(timeOfDayToggleButton, timeOfDayPreference.get(), morningButton, nightButton);
timeOfDayToggleButton.updateView(localUpdatePreference.get());
refreshTimeOfDayLayout(frequencyPreference.get(), itemTimeOfDayButtons, timeOfDayTitle);
hourlyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.HOURLY, itemTimeOfDayButtons, timeOfDayTitle)); hourlyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.HOURLY, itemTimeOfDayButtons, timeOfDayTitle));
dailyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.DAILY, itemTimeOfDayButtons, timeOfDayTitle)); dailyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.DAILY, itemTimeOfDayButtons, timeOfDayTitle));
weeklyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.WEEKLY, itemTimeOfDayButtons, timeOfDayTitle)); weeklyButton.setOnClickListener(getFrequencyButtonListener(UpdateFrequency.WEEKLY, itemTimeOfDayButtons, timeOfDayTitle));
morningButton.setOnClickListener(getTimeOfDayButtonListener(TimeOfDay.MORNING));
nightButton.setOnClickListener(getTimeOfDayButtonListener(TimeOfDay.NIGHT));
items.add(new BaseBottomSheetItem.Builder() itemFrequencyHelpMessage = new ShortDescriptionItem.Builder()
.setCustomView(itemTimeOfDayButtons)
.create()
);
items.add(new ShortDescriptionItem.Builder()
.setDescription(getFrequencyHelpMessage()) .setDescription(getFrequencyHelpMessage())
.setDescriptionColorId(getSecondaryTextColorId(nightMode)) .setDescriptionColorId(getSecondaryTextColorId(nightMode))
.setLayoutId(R.layout.bottom_sheet_item_description) .setLayoutId(R.layout.bottom_sheet_item_description)
.create()); .create();
indexFrequencyHelpMessageItem = items.size() - 1; items.add(itemFrequencyHelpMessage);
LinearLayout itemUpdateNowButton = (LinearLayout) inflater.inflate(R.layout.bottom_sheet_button_with_icon_center, null); LinearLayout itemUpdateNowButton =
(LinearLayout) inflater.inflate(R.layout.bottom_sheet_button_with_icon_center, null);
LinearLayout.MarginLayoutParams itemUpdateNowParams = new LinearLayout.MarginLayoutParams( LinearLayout.MarginLayoutParams itemUpdateNowParams = new LinearLayout.MarginLayoutParams(
LinearLayout.MarginLayoutParams.MATCH_PARENT, getDimen(R.dimen.measurement_tool_button_height)); LinearLayout.MarginLayoutParams.MATCH_PARENT, dp36);
AndroidUtils.setMargins(itemUpdateNowParams, dp12, dp12, dp16, dp12); AndroidUtils.setMargins(itemUpdateNowParams, dp12, 0, dp16, dp12);
itemUpdateNowButton.setLayoutParams(itemUpdateNowParams); itemUpdateNowButton.setLayoutParams(itemUpdateNowParams);
((AppCompatImageView) itemUpdateNowButton.findViewById(R.id.button_icon)).setImageDrawable( ((AppCompatImageView) itemUpdateNowButton.findViewById(R.id.button_icon)).setImageDrawable(
AppCompatResources.getDrawable(app, R.drawable.ic_action_update)); AppCompatResources.getDrawable(app, R.drawable.ic_action_update));
UiUtilities.setupDialogButton(nightMode, itemUpdateNowButton, UiUtilities.DialogButtonType.SECONDARY, getString(R.string.update_now)); UiUtilities.setupDialogButton(nightMode, itemUpdateNowButton, UiUtilities.DialogButtonType.SECONDARY, getString(R.string.update_now));
itemUpdateNowButton.setMinimumHeight(AndroidUtils.dpToPx(app, app.getResources().getDimension(R.dimen.dialog_button_height))); itemUpdateNowButton.setMinimumHeight(AndroidUtils.dpToPx(app, dp36));
items.add(new BaseBottomSheetItem.Builder() items.add(new BaseBottomSheetItem.Builder()
.setCustomView(itemUpdateNowButton) .setCustomView(itemUpdateNowButton)
@ -268,6 +280,10 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
updateLastCheck(); updateLastCheck();
updateFrequencyHelpMessage(); updateFrequencyHelpMessage();
updateFileSize(); updateFileSize();
Fragment target = getTargetFragment();
if (target instanceof LiveUpdatesFragment) {
((LiveUpdatesFragment) target).updateList();
}
} }
}); });
} }
@ -281,8 +297,7 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
int iconDeleteColor = ContextCompat.getColor(app, R.color.color_osm_edit_delete); int iconDeleteColor = ContextCompat.getColor(app, R.color.color_osm_edit_delete);
Drawable iconDelete = AppCompatResources.getDrawable(app, R.drawable.ic_action_delete_dark); Drawable iconDelete = AppCompatResources.getDrawable(app, R.drawable.ic_action_delete_dark);
items.add( itemClear = new BottomSheetItemWithDescription.Builder()
new BottomSheetItemWithDescription.Builder()
.setDescription(getUpdatesSizeStr()) .setDescription(getUpdatesSizeStr())
.setIcon(UiUtilities.tintDrawable(iconDelete, iconDeleteColor)) .setIcon(UiUtilities.tintDrawable(iconDelete, iconDeleteColor))
.setTitle(getString(R.string.updates_size)) .setTitle(getString(R.string.updates_size))
@ -292,21 +307,18 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
public void onClick(View v) { public void onClick(View v) {
if (getUpdatesSize() > 0) { if (getUpdatesSize() > 0) {
if (getFragmentManager() != null) { if (getFragmentManager() != null) {
LiveUpdatesClearDialogFragment LiveUpdatesClearBottomSheet.showInstance(getFragmentManager(),
.showInstance(getFragmentManager(), LiveUpdatesSettingsBottomSheet.this, fileName);
LiveUpdatesSettingsDialogFragmentNew.this, fileName);
} }
} }
} }
}) })
.create() .create();
); items.add(itemClear);
indexClearItem = items.size() - 1;
items.add(createDividerItem()); items.add(createDividerItem());
items.add( itemViaWiFi = new BottomSheetItemWithCompoundButton.Builder()
new BottomSheetItemWithCompoundButton.Builder()
.setChecked(downloadViaWiFiPreference.get()) .setChecked(downloadViaWiFiPreference.get())
.setDescription(getStateText(downloadViaWiFiPreference.get())) .setDescription(getStateText(downloadViaWiFiPreference.get()))
.setIconHidden(true) .setIconHidden(true)
@ -315,17 +327,17 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (preferenceForLocalIndex(fileName, settings).get() && indexViaWiFiItem != -1 && items.size() > 0) { if (preferenceForLocalIndex(fileName, settings).get()) {
BottomSheetItemWithCompoundButton button = (BottomSheetItemWithCompoundButton) items.get(indexViaWiFiItem); BottomSheetItemWithCompoundButton item = (BottomSheetItemWithCompoundButton) itemViaWiFi;
button.setChecked(!button.isChecked()); boolean checked = item.isChecked();
button.setDescription(getStateText(button.isChecked())); item.setChecked(!checked);
preferenceDownloadViaWiFi(fileName, settings).set(button.isChecked()); item.setDescription(getStateText(!checked));
preferenceDownloadViaWiFi(fileName, settings).set(!checked);
} }
} }
}) })
.create() .create();
); items.add(itemViaWiFi);
indexViaWiFiItem = items.size() - 1;
items.add(new DividerSpaceItem(app, getDimen(R.dimen.context_menu_padding_margin_large))); items.add(new DividerSpaceItem(app, getDimen(R.dimen.context_menu_padding_margin_large)));
} }
@ -334,6 +346,24 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, parent, savedInstanceState); View view = super.onCreateView(inflater, parent, savedInstanceState);
int titleHeight = getDimen(R.dimen.bottom_sheet_descr_height);
TextViewEx titleView = (TextViewEx) itemTitle.getView();
titleView.setMinimumHeight(titleHeight);
titleView.getLayoutParams().height = titleHeight;
titleView.setPadding(titleView.getPaddingLeft(), getDimen(R.dimen.content_padding_small),
titleView.getPaddingRight(), getDimen(R.dimen.list_item_button_padding));
int descriptionHeight = getDimen(R.dimen.bottom_sheet_title_height);
TextView descriptionView = (TextView) itemLastCheck.getView();
descriptionView.setMinimumHeight(descriptionHeight);
descriptionView.getLayoutParams().height = descriptionHeight;
int frequencyHelpMessageHeight = getDimen(R.dimen.context_menu_progress_min_height);
TextView frequencyHelpMessageView = (TextView) itemFrequencyHelpMessage.getView();
frequencyHelpMessageView.setMinimumHeight(frequencyHelpMessageHeight);
frequencyHelpMessageView.getLayoutParams().height = frequencyHelpMessageHeight;
CommonPreference<Boolean> localUpdatePreference = preferenceForLocalIndex(fileName, settings); CommonPreference<Boolean> localUpdatePreference = preferenceForLocalIndex(fileName, settings);
setStateViaWiFiButton(localUpdatePreference); setStateViaWiFiButton(localUpdatePreference);
return view; return view;
@ -346,12 +376,12 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
} }
private void setStateViaWiFiButton(CommonPreference<Boolean> localUpdatePreference) { private void setStateViaWiFiButton(CommonPreference<Boolean> localUpdatePreference) {
if (indexViaWiFiItem != -1 && items.size() > 0) { if (itemViaWiFi != null) {
BottomSheetItemWithCompoundButton button = (BottomSheetItemWithCompoundButton) items.get(indexViaWiFiItem); BottomSheetItemWithCompoundButton item = (BottomSheetItemWithCompoundButton) itemViaWiFi;
if (button.getView() != null) { if (item.getView() != null) {
TextView title = button.getView().findViewById(R.id.title); TextView title = item.getView().findViewById(R.id.title);
TextView description = button.getView().findViewById(R.id.description); TextView description = item.getView().findViewById(R.id.description);
CompoundButton compoundButton = button.getView().findViewById(R.id.compound_button); CompoundButton compoundButton = item.getView().findViewById(R.id.compound_button);
if (localUpdatePreference.get()) { if (localUpdatePreference.get()) {
AndroidUtils.setTextPrimaryColor(app, title, nightMode); AndroidUtils.setTextPrimaryColor(app, title, nightMode);
AndroidUtils.setTextSecondaryColor(app, description, nightMode); AndroidUtils.setTextSecondaryColor(app, description, nightMode);
@ -366,23 +396,20 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
} }
private void updateLastCheck() { private void updateLastCheck() {
if (indexLastCheckItem != -1 && items.size() > 0) { if (itemLastCheck != null) {
((BottomSheetItemWithDescription) items.get(indexLastCheckItem)) ((BottomSheetItemWithDescription) itemLastCheck).setDescription(getLastCheckString());
.setDescription(getLastCheckString());
} }
} }
private void updateFrequencyHelpMessage() { private void updateFrequencyHelpMessage() {
if (indexFrequencyHelpMessageItem != -1 && items.size() > 0) { if (itemFrequencyHelpMessage != null) {
((BottomSheetItemWithDescription) items.get(indexFrequencyHelpMessageItem)) ((BottomSheetItemWithDescription) itemFrequencyHelpMessage).setDescription(getFrequencyHelpMessage());
.setDescription(getFrequencyHelpMessage());
} }
} }
private void updateFileSize() { private void updateFileSize() {
if (indexClearItem != -1 && items.size() > 0) { if (itemClear != null) {
((BottomSheetItemWithDescription) items.get(indexClearItem)) ((BottomSheetItemWithDescription) itemClear).setDescription(getUpdatesSizeStr());
.setDescription(getUpdatesSizeStr());
} }
} }
@ -414,7 +441,8 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
CommonPreference<Integer> updateFrequency = preferenceUpdateFrequency(fileName, settings); CommonPreference<Integer> updateFrequency = preferenceUpdateFrequency(fileName, settings);
CommonPreference<Integer> timeOfDayToUpdate = preferenceTimeOfDayToUpdate(fileName, settings); CommonPreference<Integer> timeOfDayToUpdate = preferenceTimeOfDayToUpdate(fileName, settings);
final long lastUpdate = preferenceLatestUpdateAvailable(fileName, settings).get(); final long lastUpdate = preferenceLatestUpdateAvailable(fileName, settings).get();
return formatHelpDateTime(app, UpdateFrequency.values()[updateFrequency.get()], TimeOfDay.values()[timeOfDayToUpdate.get()], lastUpdate); return formatHelpDateTime(app, UpdateFrequency.values()[updateFrequency.get()],
TimeOfDay.values()[timeOfDayToUpdate.get()], lastUpdate);
} }
private long getUpdatesSize() { private long getUpdatesSize() {
@ -433,8 +461,8 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
private BaseBottomSheetItem createDividerItem() { private BaseBottomSheetItem createDividerItem() {
DividerItem dividerItem = new DividerItem(app); DividerItem dividerItem = new DividerItem(app);
int start = app.getResources().getDimensionPixelSize(R.dimen.content_padding); int start = getDimen(R.dimen.content_padding);
int vertical = getResources().getDimensionPixelSize(R.dimen.content_padding_small_half); int vertical = getDimen(R.dimen.content_padding_small_half);
dividerItem.setMargins(start, vertical, 0, vertical); dividerItem.setMargins(start, vertical, 0, vertical);
return dividerItem; return dividerItem;
} }
@ -459,7 +487,8 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
} }
} }
private OnRadioItemClickListener getFrequencyButtonListener(@NonNull final UpdateFrequency type, final View... timeOfDayLayouts) { private OnRadioItemClickListener getFrequencyButtonListener(
@NonNull final UpdateFrequency type, final View... timeOfDayLayouts) {
return new OnRadioItemClickListener() { return new OnRadioItemClickListener() {
@Override @Override
public boolean onRadioItemClick(RadioItem radioItem, View view) { public boolean onRadioItemClick(RadioItem radioItem, View view) {
@ -544,5 +573,4 @@ public class LiveUpdatesSettingsDialogFragmentNew extends MenuBottomSheetDialogF
protected int getDismissButtonTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;
} }
} }

View file

@ -1,288 +0,0 @@
package net.osmand.plus.liveupdates;
import android.app.AlarmManager;
import android.app.Dialog;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.DialogFragment;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.download.AbstractDownloadActivity;
import net.osmand.plus.liveupdates.LiveUpdatesHelper.TimeOfDay;
import net.osmand.plus.liveupdates.LiveUpdatesHelper.UpdateFrequency;
import net.osmand.plus.resources.IncrementalChangesManager;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.io.File;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.DEFAULT_LAST_CHECK;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.formatDateTime;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getNameToDisplay;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceDownloadViaWiFi;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceForLocalIndex;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceTimeOfDayToUpdate;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFrequency;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.runLiveUpdate;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.setAlarmForPendingIntent;
public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
private static final Log LOG = PlatformUtil.getLog(LiveUpdatesSettingsDialogFragment.class);
private static final String LOCAL_INDEX_FILE_NAME = "local_index_file_name";
private TextView sizeTextView;
private String fileName;
private String fileNameWithoutExtension;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
fileName = getArguments().getString(LOCAL_INDEX_FILE_NAME);
assert fileName != null;
View view = LayoutInflater.from(getActivity())
.inflate(R.layout.dialog_live_updates_item_settings, null);
final TextView regionNameTextView = (TextView) view.findViewById(R.id.regionNameTextView);
final TextView lastMapChangeTextView = (TextView) view.findViewById(R.id.lastMapChangeTextView);
final TextView lastUpdateTextView = (TextView) view.findViewById(R.id.lastUpdateTextView);
final SwitchCompat liveUpdatesSwitch = (SwitchCompat) view.findViewById(R.id.toggle_item);
final CheckBox downloadOverWiFiCheckBox = (CheckBox) view.findViewById(R.id.downloadOverWiFiSwitch);
final Spinner updateFrequencySpinner = (Spinner) view.findViewById(R.id.updateFrequencySpinner);
final Spinner updateTimesOfDaySpinner = (Spinner) view.findViewById(R.id.updateTimesOfDaySpinner);
final View updateTimesOfDayLayout = view.findViewById(R.id.updateTimesOfDayLayout);
sizeTextView = (TextView) view.findViewById(R.id.sizeTextView);
regionNameTextView.setText(getNameToDisplay(fileName, getMyActivity().getMyApplication()));
fileNameWithoutExtension = Algorithms.getFileNameWithoutExtension(new File(fileName));
final IncrementalChangesManager changesManager = getMyApplication().getResourceManager().getChangesManager();
final long timestamp = changesManager.getTimestamp(fileNameWithoutExtension);
String lastUpdateDate = formatDateTime(getActivity(), timestamp);
lastMapChangeTextView.setText(getString(R.string.last_map_change, lastUpdateDate));
final long lastCheck = preferenceLastCheck(fileName, getSettings()).get();
CommonPreference<Boolean> preference = preferenceLiveUpdatesOn(fileName,
getSettings());
if (preference.get() && lastCheck != DEFAULT_LAST_CHECK) {
String lastCheckString = formatDateTime(getActivity(), lastCheck);
lastUpdateTextView.setText(getString(R.string.last_update, lastCheckString));
} else {
lastUpdateTextView.setVisibility(View.GONE);
}
final CommonPreference<Boolean> liveUpdatePreference =
preferenceForLocalIndex(fileName, getSettings());
final CommonPreference<Boolean> downloadViaWiFiPreference =
preferenceDownloadViaWiFi(fileName, getSettings());
final CommonPreference<Integer> updateFrequencyPreference =
preferenceUpdateFrequency(fileName, getSettings());
final CommonPreference<Integer> timeOfDayPreference =
preferenceTimeOfDayToUpdate(fileName, getSettings());
downloadOverWiFiCheckBox.setChecked(!liveUpdatePreference.get() || downloadViaWiFiPreference.get());
sizeTextView.setText(getUpdatesSize(getMyActivity(), fileNameWithoutExtension, changesManager));
TimeOfDay[] timeOfDays = TimeOfDay.values();
String[] timeOfDaysStrings = new String[timeOfDays.length];
for (int i = 0; i < timeOfDays.length; i++) {
timeOfDaysStrings[i] = getString(timeOfDays[i].getLocalizedId());
}
updateTimesOfDaySpinner.setAdapter(new ArrayAdapter<>(getActivity(),
R.layout.action_spinner_item, timeOfDaysStrings));
updateTimesOfDaySpinner.setSelection(timeOfDayPreference.get());
UpdateFrequency[] updateFrequencies = UpdateFrequency.values();
String[] updateFrequenciesStrings = new String[updateFrequencies.length];
for (int i = 0; i < updateFrequencies.length; i++) {
updateFrequenciesStrings[i] = getString(updateFrequencies[i].getLocalizedId());
}
refreshTimeOfDayLayout(UpdateFrequency.values()[updateFrequencyPreference.get()],
updateTimesOfDayLayout);
updateFrequencySpinner.setAdapter(new ArrayAdapter<>(getActivity(),
R.layout.action_spinner_item, updateFrequenciesStrings));
updateFrequencySpinner.setSelection(updateFrequencyPreference.get());
updateFrequencySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
refreshTimeOfDayLayout(UpdateFrequency.values()[position], updateTimesOfDayLayout);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
builder.setView(view)
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (liveUpdatePreference.get() != liveUpdatesSwitch.isChecked()) {
liveUpdatePreference.set(liveUpdatesSwitch.isChecked());
if (!liveUpdatesSwitch.isChecked()) {
long updatesSize = changesManager.getUpdatesSize(fileNameWithoutExtension);
if (updatesSize != 0) {
ClearUpdatesDialogFragment.createInstance(fileName)
.show(getParentFragment().getChildFragmentManager(), null);
}
}
}
downloadViaWiFiPreference.set(downloadOverWiFiCheckBox.isChecked());
final int updateFrequencyInt = updateFrequencySpinner.getSelectedItemPosition();
updateFrequencyPreference.set(updateFrequencyInt);
AlarmManager alarmMgr = (AlarmManager) getActivity()
.getSystemService(Context.ALARM_SERVICE);
PendingIntent alarmIntent = getPendingIntent(getActivity(), fileName);
final int timeOfDayInt = updateTimesOfDaySpinner.getSelectedItemPosition();
timeOfDayPreference.set(timeOfDayInt);
if (liveUpdatesSwitch.isChecked() && getSettings().IS_LIVE_UPDATES_ON.get()) {
runLiveUpdate(getActivity(), fileName, false, null);
UpdateFrequency updateFrequency = UpdateFrequency.values()[updateFrequencyInt];
TimeOfDay timeOfDayToUpdate = TimeOfDay.values()[timeOfDayInt];
setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate);
} else {
alarmMgr.cancel(alarmIntent);
}
getLiveUpdatesFragment().notifyLiveUpdatesChanged();
}
})
.setNegativeButton(R.string.shared_string_cancel, null)
.setNeutralButton(R.string.update_now, null);
return builder.create();
}
@Override
public void onResume() {
super.onResume();
final AlertDialog dialog = (AlertDialog) getDialog();
if (dialog != null) {
Button neutralButton = (Button) dialog.getButton(Dialog.BUTTON_NEUTRAL);
neutralButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!getSettings().isInternetConnectionAvailable()) {
getMyApplication().showShortToastMessage(R.string.no_internet_connection);
} else {
runLiveUpdate(getActivity(), fileName, true, null);
final IncrementalChangesManager changesManager = getMyApplication().getResourceManager().getChangesManager();
sizeTextView.setText(getUpdatesSize(getMyActivity(), fileNameWithoutExtension, changesManager));
dialog.dismiss();
}
}
});
}
}
private void refreshTimeOfDayLayout(UpdateFrequency updateFrequency, View updateTimesOfDayLayout) {
switch (updateFrequency) {
case HOURLY:
updateTimesOfDayLayout.setVisibility(View.GONE);
break;
case DAILY:
case WEEKLY:
updateTimesOfDayLayout.setVisibility(View.VISIBLE);
break;
}
}
private static String getUpdatesSize(Context ctx, String fileNameWithoutExtension,
IncrementalChangesManager changesManager) {
long updatesSize = changesManager.getUpdatesSize(fileNameWithoutExtension);
return AndroidUtils.formatSize(ctx, updatesSize);
}
private LiveUpdatesFragment getLiveUpdatesFragment() {
return (LiveUpdatesFragment) getParentFragment();
}
private OsmandSettings getSettings() {
return getMyApplication().getSettings();
}
private OsmandApplication getMyApplication() {
return getMyActivity().getMyApplication();
}
private AbstractDownloadActivity getMyActivity() {
return (AbstractDownloadActivity) this.getActivity();
}
public static LiveUpdatesSettingsDialogFragment createInstance(String fileName) {
LiveUpdatesSettingsDialogFragment fragment = new LiveUpdatesSettingsDialogFragment();
Bundle args = new Bundle();
args.putString(LOCAL_INDEX_FILE_NAME, fileName);
fragment.setArguments(args);
return fragment;
}
public static class ClearUpdatesDialogFragment extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final String localIndexInfo = getArguments().getString(LOCAL_INDEX_FILE_NAME);
assert localIndexInfo != null;
final IncrementalChangesManager changesManager =
getMyApplication().getResourceManager().getChangesManager();
final String fileNameWithoutExtension =
Algorithms.getFileNameWithoutExtension(new File(localIndexInfo));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(
getString(R.string.ltr_or_rtl_combine_via_space,
getString(R.string.clear_updates_proposition_message),
getUpdatesSize(getContext(), fileNameWithoutExtension, changesManager)))
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
changesManager.deleteUpdates(fileNameWithoutExtension);
preferenceLastCheck(localIndexInfo, getMyApplication().getSettings()).resetToDefault();
}
})
.setNegativeButton(R.string.shared_string_cancel, null);
return builder.create();
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
public static ClearUpdatesDialogFragment createInstance(String fileName) {
ClearUpdatesDialogFragment fragment = new ClearUpdatesDialogFragment();
Bundle args = new Bundle();
args.putString(LOCAL_INDEX_FILE_NAME, fileName);
fragment.setArguments(args);
return fragment;
}
}
}

View file

@ -0,0 +1,103 @@
package net.osmand.plus.liveupdates;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import net.osmand.PlatformUtil;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.DialogButtonType;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
import net.osmand.plus.liveupdates.LiveUpdatesHelper.LiveUpdateListener;
import net.osmand.plus.widgets.TextViewEx;
import org.apache.commons.logging.Log;
import static net.osmand.AndroidUtils.getPrimaryTextColorId;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.runLiveUpdate;
public class LiveUpdatesUpdateAllBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = LiveUpdatesUpdateAllBottomSheet.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(LiveUpdatesUpdateAllBottomSheet.class);
private BaseBottomSheetItem itemTitle;
private BaseBottomSheetItem itemDescription;
public static void showInstance(@NonNull FragmentManager fragmentManager, Fragment target) {
if (!fragmentManager.isStateSaved()) {
LiveUpdatesUpdateAllBottomSheet fragment = new LiveUpdatesUpdateAllBottomSheet();
fragment.setTargetFragment(target, 0);
fragment.show(fragmentManager, TAG);
}
}
@Override
public void createMenuItems(Bundle savedInstanceState) {
updateBottomButtons();
itemTitle = new SimpleBottomSheetItem.Builder()
.setTitle(getString(R.string.update_all_maps_now))
.setTitleColorId(getPrimaryTextColorId(nightMode))
.setLayoutId(R.layout.bottom_sheet_item_title)
.create();
items.add(itemTitle);
String osmAndLive = "\"" + getString(R.string.osm_live) + "\"";
itemDescription = new LongDescriptionItem.Builder()
.setDescription(getString(R.string.update_all_maps_added, osmAndLive))
.setDescriptionMaxLines(5)
.setDescriptionColorId(getPrimaryTextColorId(nightMode))
.setLayoutId(R.layout.bottom_sheet_item_description_long)
.create();
items.add(itemDescription);
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, parent, savedInstanceState);
((TextViewEx) itemTitle.getView()).setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_list_text_size));
TextView textDescription = (TextView) itemDescription.getView();
textDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_list_text_size));
textDescription.setMinHeight(getResources().getDimensionPixelSize(R.dimen.context_menu_sub_info_height));
return view;
}
private void updateAll() {
Fragment target = getTargetFragment();
if (target instanceof LiveUpdateListener) {
runLiveUpdate(getActivity(), false, (LiveUpdateListener) target);
}
}
@Override
protected void onRightBottomButtonClick() {
updateAll();
dismiss();
}
@Override
protected int getDismissButtonTextId() {
return R.string.shared_string_cancel;
}
@Override
protected int getRightBottomButtonTextId() {
return R.string.update_now;
}
@Override
protected DialogButtonType getRightBottomButtonType() {
return DialogButtonType.PRIMARY;
}
}

View file

@ -6,7 +6,6 @@ import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import net.osmand.AndroidNetworkUtils; import net.osmand.AndroidNetworkUtils;
import net.osmand.AndroidNetworkUtils.OnRequestResultListener; import net.osmand.AndroidNetworkUtils.OnRequestResultListener;
@ -46,20 +45,18 @@ public class PerformLiveUpdateAsyncTask
@NonNull @NonNull
private final String localIndexFileName; private final String localIndexFileName;
private final boolean userRequested; private final boolean userRequested;
private final LiveUpdateListener listener; private Runnable runOnSuccess;
public interface LiveUpdateListener {
void processFinish();
}
public PerformLiveUpdateAsyncTask(@NonNull Context context, public PerformLiveUpdateAsyncTask(@NonNull Context context,
@NonNull String localIndexFileName, @NonNull String localIndexFileName,
boolean userRequested, boolean userRequested) {
@Nullable LiveUpdateListener listener) {
this.context = context; this.context = context;
this.localIndexFileName = localIndexFileName; this.localIndexFileName = localIndexFileName;
this.userRequested = userRequested; this.userRequested = userRequested;
this.listener = listener; }
public void setRunOnSuccess(Runnable runOnSuccess) {
this.runOnSuccess = runOnSuccess;
} }
@Override @Override
@ -149,9 +146,6 @@ public class PerformLiveUpdateAsyncTask
((DownloadIndexesThread.DownloadEvents) context).downloadInProgress(); ((DownloadIndexesThread.DownloadEvents) context).downloadInProgress();
} }
updateLatestAvailability(application, localIndexFileName); updateLatestAvailability(application, localIndexFileName);
if (listener != null) {
listener.processFinish();
}
} else { } else {
LOG.debug("onPostExecute: Not enough space for updates"); LOG.debug("onPostExecute: Not enough space for updates");
} }
@ -163,9 +157,6 @@ public class PerformLiveUpdateAsyncTask
((DownloadIndexesThread.DownloadEvents) context).downloadInProgress(); ((DownloadIndexesThread.DownloadEvents) context).downloadInProgress();
if (userRequested && context instanceof DownloadActivity) { if (userRequested && context instanceof DownloadActivity) {
updateLatestAvailability(application, localIndexFileName); updateLatestAvailability(application, localIndexFileName);
if (listener != null) {
listener.processFinish();
}
application.showShortToastMessage(R.string.no_updates_available); application.showShortToastMessage(R.string.no_updates_available);
} }
} }
@ -201,7 +192,7 @@ public class PerformLiveUpdateAsyncTask
private void updateLatestAvailability(OsmandApplication app, @NonNull final String localIndexFileName) { private void updateLatestAvailability(OsmandApplication app, @NonNull final String localIndexFileName) {
final OsmandSettings settings = app.getSettings(); final OsmandSettings settings = app.getSettings();
AndroidNetworkUtils.sendRequestAsync( AndroidNetworkUtils.sendRequestAsync(
app, LiveUpdatesFragmentNew.URL, null, "Requesting map updates info...", false, false, new OnRequestResultListener() { app, LiveUpdatesFragment.URL, null, "Requesting map updates info...", false, false, new OnRequestResultListener() {
@Override @Override
public void onResult(String result) { public void onResult(String result) {
if (!Algorithms.isEmpty(result)) { if (!Algorithms.isEmpty(result)) {
@ -213,6 +204,9 @@ public class PerformLiveUpdateAsyncTask
long dateTime = parsed.getTime(); long dateTime = parsed.getTime();
preferenceLatestUpdateAvailable(settings).set(dateTime); preferenceLatestUpdateAvailable(settings).set(dateTime);
preferenceLatestUpdateAvailable(localIndexFileName, settings).set(dateTime); preferenceLatestUpdateAvailable(localIndexFileName, settings).set(dateTime);
if (runOnSuccess != null) {
runOnSuccess.run();
}
} }
} catch (ParseException e) { } catch (ParseException e) {
long dateTime = preferenceLatestUpdateAvailable(settings).get(); long dateTime = preferenceLatestUpdateAvailable(settings).get();

View file

@ -228,12 +228,6 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
} }
String preferredCountry = obj.getString("preferredCountry"); String preferredCountry = obj.getString("preferredCountry");
app.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.set(preferredCountry); app.getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.set(preferredCountry);
Fragment parent = getParentFragment();
if (parent instanceof LiveUpdatesFragment) {
((LiveUpdatesFragment) parent).updateSubscriptionHeader();
}
dismiss(); dismiss();
} else { } else {
app.showToastMessage("Error: " + obj.getString("error")); app.showToastMessage("Error: " + obj.getString("error"));

View file

@ -33,7 +33,7 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.getActivePrimaryColorId; import static net.osmand.plus.liveupdates.LiveUpdatesSettingsBottomSheet.getActivePrimaryColorId;
import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getSecondaryIconColorId; import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getSecondaryIconColorId;
public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {

View file

@ -14,7 +14,6 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.liveupdates.CountrySelectionFragment; import net.osmand.plus.liveupdates.CountrySelectionFragment;
import net.osmand.plus.liveupdates.LiveUpdatesFragment; import net.osmand.plus.liveupdates.LiveUpdatesFragment;
import net.osmand.plus.liveupdates.LiveUpdatesFragmentNew;
import net.osmand.plus.liveupdates.OsmLiveActivity; import net.osmand.plus.liveupdates.OsmLiveActivity;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
@ -71,7 +70,7 @@ public class SubscriptionsCard extends BaseCard {
liveUpdatesContainer.setOnClickListener(new View.OnClickListener() { liveUpdatesContainer.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
LiveUpdatesFragmentNew.showInstance(mapActivity.getSupportFragmentManager(), target); LiveUpdatesFragment.showInstance(mapActivity.getSupportFragmentManager(), target);
} }
}); });

View file

@ -44,7 +44,7 @@ import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static net.osmand.plus.liveupdates.LiveUpdatesFragmentNew.getDefaultIconColorId; import static net.osmand.plus.liveupdates.LiveUpdatesFragment.getDefaultIconColorId;
import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_SPEED; import static net.osmand.plus.myplaces.GPXTabItemType.GPX_TAB_ITEM_SPEED;
public class GpxBlockStatisticsBuilder { public class GpxBlockStatisticsBuilder {