Merge branch 'master' of ssh://github.com/osmandapp/Osmand into RoutePreparation

This commit is contained in:
Chumva 2019-02-13 11:31:39 +02:00
commit 16fde2606e
23 changed files with 655 additions and 823 deletions

View file

@ -68,4 +68,5 @@ public class IndexConstants {
public static final String RENDERERS_DIR = "rendering/"; //$NON-NLS-1$
public static final String ROUTING_XML_FILE= "routing.xml";
public static final String SETTINGS_DIR = "settings/"; //$NON-NLS-1$
public static final String TEMP_DIR = "temp/";
}

View file

@ -352,6 +352,125 @@
</LinearLayout>
<LinearLayout
android:id="@+id/privacy_policy_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/content_padding_standard"
android:visibility="gone"
tools:visibility="gone">
<TextView
android:id="@+id/privacy_policy_telegram_descr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginTop="@dimen/dialog_description_margin"
android:layout_marginRight="@dimen/content_padding_standard"
android:layout_marginBottom="@dimen/content_padding_standard"
android:letterSpacing="@dimen/text_description_letter_spacing"
android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
android:text="@string/privacy_policy_telegram_client"
android:textColor="@color/app_bar_title_light"
android:textSize="@dimen/descr_text_size" />
<TextView
android:id="@+id/privacy_policy_agree"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginTop="@dimen/dialog_description_margin"
android:layout_marginRight="@dimen/content_padding_standard"
android:layout_marginBottom="@dimen/content_padding_standard"
android:letterSpacing="@dimen/text_description_letter_spacing"
android:lineSpacingMultiplier="@dimen/text_description_line_spacing_multiplier"
android:text="@string/privacy_policy_agree"
android:textColor="@color/app_bar_title_light"
android:textSize="@dimen/descr_text_size"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/telegram_privacy_policy_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="@drawable/btn_border_bg"
android:gravity="center_vertical"
android:visibility="visible">
<net.osmand.telegram.ui.views.TextViewEx
android:id="@+id/telegram_privacy_policy_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginTop="10dp"
android:layout_marginRight="@dimen/content_padding_standard"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_description_letter_spacing"
android:text="@string/do_not_have_telegram"
android:textColor="@color/text_bold_highlight"
android:textSize="@dimen/hint_text_size"
android:textStyle="bold" />
<ImageView
android:id="@+id/telegram_privacy_policy_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/content_padding_standard"
android:layout_marginRight="@dimen/content_padding_standard"
android:contentDescription="@string/do_not_have_telegram"
android:scaleType="centerInside"
tools:src="@drawable/ic_arrow_forward"
tools:tint="@color/text_bold_highlight" />
</LinearLayout>
<LinearLayout
android:id="@+id/osmand_privacy_policy_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding_half"
android:background="@drawable/btn_border_bg"
android:gravity="center_vertical"
android:visibility="visible">
<net.osmand.telegram.ui.views.TextViewEx
android:id="@+id/osmand_privacy_policy_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/content_padding_standard"
android:layout_marginTop="10dp"
android:layout_marginRight="@dimen/content_padding_standard"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:letterSpacing="@dimen/text_description_letter_spacing"
android:text="@string/do_not_have_telegram"
android:textColor="@color/text_bold_highlight"
android:textSize="@dimen/hint_text_size"
android:textStyle="bold" />
<ImageView
android:id="@+id/osmand_privacy_policy_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/content_padding_standard"
android:layout_marginRight="@dimen/content_padding_standard"
android:contentDescription="@string/do_not_have_telegram"
android:scaleType="centerInside"
tools:src="@drawable/ic_arrow_forward"
tools:tint="@color/text_bold_highlight" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/progress_layout"
android:layout_width="match_parent"

View file

@ -1,5 +1,8 @@
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<string name="privacy_policy_use_telegram">Мы используем Telegram (messaging app), чтобы соединять людей и чтобы вам было проще общаться с ними.</string>
<string name="privacy_policy_telegram_client">Telegram открытая платформа и OsmAnd Tracker является одним из клиентов. Ваши контакты могут использовать любой другой Telegram client.</string>
<string name="privacy_policy_agree">Нажимая продолжить, вы соглашаетесь с Telegram Privacy Policy и OsmAnd Privacy Policy.</string>
<string name="timeline_description">Включите мониторинг, для сбора данных о перемещении в фоновом режиме.</string>
<string name="last_update_from_telegram">Последнее обновление в Telegram</string>
<string name="device_name">Имя устройства</string>

View file

@ -41,4 +41,6 @@
<color name="sharing_status_icon_error">#ee5622</color>
<color name="sharing_status_icon_success">#78cc5c</color>
<color name="text_bold_highlight">#5959FF</color>
</resources>

View file

@ -1,4 +1,12 @@
<resources>
<string name="shared_string_telegram">Telegram</string>
<string name="privacy_policy_use_telegram">We use a Telegram (messaging app) to connect people and make it easier for you to communicate with them.</string>
<string name="privacy_policy_telegram_client">Telegram open platform and OsmAnd Tracker is one of the customers. Your contacts can use any other Telegram client.</string>
<string name="privacy_policy_agree">By clicking continue you agree to the Telegram Privacy Policy and the OsmAnd Privacy Policy.</string>
<string name="shared_string_accept">Accept</string>
<string name="telegram_privacy_policy">Telegram Privacy Policy</string>
<string name="osmand_privacy_policy">OsmAnd Privacy Policy</string>
<string name="how_it_works">How it works</string>
<string name="received_gps_points">Received GPX points: %1$s</string>
<string name="shared_string_appearance">Appearance</string>
<string name="show_gps_points">Show GPS points</string>

View file

@ -2,17 +2,18 @@ package net.osmand.telegram.ui
import android.app.Dialog
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Rect
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.support.annotation.StringRes
import android.support.v4.app.FragmentManager
import android.support.v4.content.ContextCompat
import android.support.v7.widget.AppCompatImageView
import android.text.Editable
import android.text.Html
import android.text.TextUtils
import android.text.TextWatcher
import android.text.*
import android.text.style.ForegroundColorSpan
import android.text.style.StyleSpan
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
@ -39,7 +40,10 @@ class LoginDialogFragment : BaseDialogFragment() {
private const val LOGIN_DIALOG_TYPE_PARAM_KEY = "login_dialog_type_param"
private const val SHOW_PROGRESS_PARAM_KEY = "show_progress_param"
private const val SHOW_WELCOME_DIALOG_PARAM_KEY = "show_welcome_dialog_param"
private const val PRIVACY_POLICY_AGREED_PARAM_KEY = "privacy_policy_agreed_param"
private const val TELEGRAM_PACKAGE = "org.telegram.messenger"
private const val TELEGRAM_PRIVACY_POLICY = "https://telegram.org/privacy"
private const val OSMAND_PRIVACY_POLICY = "https://osmand.net/help-online/privacy-policy"
private const val SOFT_KEYBOARD_MIN_DETECTION_SIZE = 0.15
var welcomeDialogShown = false
@ -52,7 +56,7 @@ class LoginDialogFragment : BaseDialogFragment() {
showDialog(fragmentManager, welcomeDialog = true)
}
fun showDialog(fragmentManager: FragmentManager, loginDialogType: LoginDialogType? = null, welcomeDialog: Boolean = false) {
fun showDialog(fragmentManager: FragmentManager, loginDialogType: LoginDialogType? = null, welcomeDialog: Boolean = false, privacyPolicyAgreed: Boolean = false) {
try {
/*
@ -70,6 +74,7 @@ class LoginDialogFragment : BaseDialogFragment() {
args.putString(LOGIN_DIALOG_TYPE_PARAM_KEY, loginDialogType.name)
}
args.putBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, welcomeDialog)
args.putBoolean(PRIVACY_POLICY_AGREED_PARAM_KEY, privacyPolicyAgreed)
fragment.arguments = args
fragment.show(fragmentManager, TAG)
} else {
@ -98,6 +103,7 @@ class LoginDialogFragment : BaseDialogFragment() {
private var loginDialogActiveType: LoginDialogType? = null
private var showWelcomeDialog = false
private var privacyPolicyAgreed = false
private var showProgress = false
private var dismissedManually = false
private lateinit var continueButton: Button
@ -112,7 +118,8 @@ class LoginDialogFragment : BaseDialogFragment() {
ENTER_PASSWORD(R.id.enter_password_layout, R.id.password_edit_text,
R.string.enter_password, R.string.password_descr, R.string.enter_password),
GET_TELEGRAM(R.id.get_telegram_layout, 0,
R.string.get_telegram_title, R.string.get_telegram_account_first, 0);
R.string.get_telegram_title, R.string.get_telegram_account_first, 0),
PRIVACY_POLICY(R.id.privacy_policy_layout, 0, R.string.how_it_works, R.string.privacy_policy_use_telegram, 0);
}
override fun onCreate(savedInstanceState: Bundle?) {
@ -129,6 +136,7 @@ class LoginDialogFragment : BaseDialogFragment() {
}
showProgress = args.getBoolean(SHOW_PROGRESS_PARAM_KEY, false)
showWelcomeDialog = args.getBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, false)
privacyPolicyAgreed = args.getBoolean(PRIVACY_POLICY_AGREED_PARAM_KEY, false)
}
val view = inflater.inflate(R.layout.login_dialog, container)
continueButton = view.findViewById(R.id.continue_button)
@ -151,12 +159,13 @@ class LoginDialogFragment : BaseDialogFragment() {
return view
}
private fun transformContinueButton(expanded: Boolean) {
private fun transformContinueButton(expanded: Boolean, acceptMode: Boolean = false) {
val params = continueButton.layoutParams as ViewGroup.MarginLayoutParams
val margin = if (expanded) 16f else 40f
val bottomMargin = if (expanded || acceptMode) 16f else 40f
val width = if (expanded) ViewGroup.LayoutParams.MATCH_PARENT else ViewGroup.LayoutParams.WRAP_CONTENT
params.apply {
setMargins(leftMargin, topMargin, rightMargin, AndroidUtils.dpToPx(context!!, margin))
val horizontalMargin = app.resources.getDimensionPixelSize(if (acceptMode) R.dimen.dialog_welcome_padding_horizontal else R.dimen.content_padding_half)
setMargins(horizontalMargin, topMargin, horizontalMargin, AndroidUtils.dpToPx(context!!, bottomMargin))
this.width = width
}
continueButton.requestLayout()
@ -197,7 +206,10 @@ class LoginDialogFragment : BaseDialogFragment() {
val continueButton = view?.findViewById<Button>(R.id.welcome_continue_button)
continueButton?.setOnClickListener {
showWelcomeDialog = false
if (loginDialogActiveType == null) {
if (!privacyPolicyAgreed) {
loginDialogActiveType = LoginDialogType.PRIVACY_POLICY
showProgress = false
} else if (loginDialogActiveType == null) {
loginDialogActiveType = LoginDialogType.ENTER_PHONE_NUMBER
showProgress = true
}
@ -235,7 +247,10 @@ class LoginDialogFragment : BaseDialogFragment() {
layout.visibility = View.VISIBLE
val editText: ExtendedEditText? = layout.findViewById(t.editorId)
if (editText != null && !showWelcomeDialog) {
editText.setOnEditorActionListener { _, actionId, _ ->
if (loginDialogActiveType == LoginDialogType.ENTER_PHONE_NUMBER) {
editText.setText("+")
}
editText.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
applyAuthParam(t, editText.text.toString())
return@setOnEditorActionListener true
@ -251,10 +266,10 @@ class LoginDialogFragment : BaseDialogFragment() {
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun afterTextChanged(s: Editable) {
changeContinueButtonEnabled(!s.isEmpty())
changeContinueButtonEnabled(s.length > 1)
}
})
changeContinueButtonEnabled(!editText.text.isEmpty())
changeContinueButtonEnabled(editText.text.length > 1)
editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16F)
}
@ -293,6 +308,67 @@ class LoginDialogFragment : BaseDialogFragment() {
getTelegramViewContainer?.visibility = View.GONE
view.findViewById<Button>(R.id.continue_button).visibility = View.VISIBLE
}
val privacyPolicyContainer: LinearLayout? = view.findViewById(R.id.privacy_policy_layout)
if (loginDialogActiveType == LoginDialogType.PRIVACY_POLICY) {
titleView?.setTextColor(ContextCompat.getColor(app, R.color.text_bold_highlight))
val useTelegramDescr = getString(R.string.privacy_policy_use_telegram)
descriptionView?.text = SpannableString(useTelegramDescr).apply {
val telegram = getString(R.string.shared_string_telegram)
val start = useTelegramDescr.indexOf(telegram)
if (start != -1) {
setSpan(ForegroundColorSpan(ContextCompat.getColor(app, R.color.text_bold_highlight)), start, start + telegram.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
setSpan(StyleSpan(android.graphics.Typeface.BOLD), start, start + telegram.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
}
view.findViewById<TextView>(R.id.privacy_policy_agree).apply {
val policyAgreeDescr = getString(R.string.privacy_policy_agree)
text = SpannableString(policyAgreeDescr).apply {
val telegramPrivacyPolicy = getString(R.string.telegram_privacy_policy)
val osmAndPrivacyPolicy = getString(R.string.osmand_privacy_policy)
var start = policyAgreeDescr.indexOf(telegramPrivacyPolicy)
if (start != -1) {
setSpan(ForegroundColorSpan(ContextCompat.getColor(app, R.color.text_bold_highlight)), start, start + telegramPrivacyPolicy.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
start = policyAgreeDescr.indexOf(osmAndPrivacyPolicy)
if (start != -1) {
setSpan(ForegroundColorSpan(ContextCompat.getColor(app, R.color.text_bold_highlight)), start, start + osmAndPrivacyPolicy.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
}
}
view.findViewById<LinearLayout>(R.id.telegram_privacy_policy_btn).apply {
findViewById<TextView>(R.id.telegram_privacy_policy_title).text = getText(R.string.telegram_privacy_policy)
findViewById<ImageView>(R.id.telegram_privacy_policy_icon)?.setImageDrawable(app.uiUtils.getIcon(R.drawable.ic_arrow_forward, R.color.text_bold_highlight))
setOnClickListener {
context?.also {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(TELEGRAM_PRIVACY_POLICY))
if (AndroidUtils.isIntentSafe(context, intent)) {
startActivity(intent)
}
}
}
}
view.findViewById<LinearLayout>(R.id.osmand_privacy_policy_btn).apply {
findViewById<TextView>(R.id.osmand_privacy_policy_title).text = getText(R.string.osmand_privacy_policy)
findViewById<ImageView>(R.id.osmand_privacy_policy_icon)?.setImageDrawable(app.uiUtils.getIcon(R.drawable.ic_arrow_forward, R.color.text_bold_highlight))
setOnClickListener {
context?.also {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(OSMAND_PRIVACY_POLICY))
if (AndroidUtils.isIntentSafe(context, intent)) {
startActivity(intent)
}
}
}
}
view.findViewById<Button>(R.id.continue_button).text = getText(R.string.shared_string_accept)
changeContinueButtonEnabled(true)
transformContinueButton(true, acceptMode = true)
privacyPolicyContainer?.visibility = View.VISIBLE
} else {
privacyPolicyContainer?.visibility = View.GONE
titleView?.setTextColor(ContextCompat.getColor(app, R.color.ctrl_active_light))
view.findViewById<Button>(R.id.continue_button).text = getText(R.string.shared_string_continue)
}
}
}
else -> layout?.visibility = View.GONE
@ -304,21 +380,27 @@ class LoginDialogFragment : BaseDialogFragment() {
progressView?.visibility = View.GONE
}
}
continueButton.isEnabled = !showProgress && continueButton.isEnabled
continueButton.isEnabled = !showProgress && continueButton.isEnabled || loginDialogActiveType == LoginDialogType.PRIVACY_POLICY
if (showProgress) {
continueButton.setOnClickListener(null)
} else {
continueButton.setOnClickListener {
showWelcomeDialog = false
for (t in LoginDialogType.values()) {
val layout: View? = view?.findViewById(t.viewId)
val contains = t == loginDialogActiveType
if (contains && layout != null) {
val editText: ExtendedEditText? = layout.findViewById(t.editorId)
val text = editText?.text.toString()
if (!TextUtils.isEmpty(text) && text.length > 1) {
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
applyAuthParam(t, text)
if (loginDialogActiveType == LoginDialogType.PRIVACY_POLICY) {
this.loginDialogActiveType = LoginDialogType.ENTER_PHONE_NUMBER
privacyPolicyAgreed = true
buildDialog(view)
} else {
for (t in LoginDialogType.values()) {
val layout: View? = view?.findViewById(t.viewId)
val contains = t == loginDialogActiveType
if (contains && layout != null) {
val editText: ExtendedEditText? = layout.findViewById(t.editorId)
val text = editText?.text.toString()
if (!TextUtils.isEmpty(text) && text.length > 1) {
continueButton.setTextColor(ContextCompat.getColor(context!!, R.color.secondary_text_light))
applyAuthParam(t, text)
}
}
}
}
@ -360,6 +442,7 @@ class LoginDialogFragment : BaseDialogFragment() {
}
outState.putBoolean(SHOW_PROGRESS_PARAM_KEY, showProgress)
outState.putBoolean(SHOW_WELCOME_DIALOG_PARAM_KEY, showWelcomeDialog)
outState.putBoolean(PRIVACY_POLICY_AGREED_PARAM_KEY, privacyPolicyAgreed)
}
private fun getMainActivity(): MainActivity? {

View file

@ -78,7 +78,7 @@
</LinearLayout>
<net.osmand.plus.views.controls.DynamicListView
<com.github.ksoichiro.android.observablescrollview.ObservableListView
android:id="@+id/dash_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"

View file

@ -123,13 +123,17 @@
android:text="@string/route_from"
android:textSize="@dimen/default_sub_text_size" />
<Spinner
android:id="@+id/FromSpinner"
<TextView
android:id="@+id/fromText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-8dp"
android:background="@null"
android:textSize="@dimen/default_list_text_size" />
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:gravity="left"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="My position" />
</LinearLayout>
@ -237,11 +241,13 @@
android:id="@+id/ViaView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:gravity="left"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
android:textSize="@dimen/default_list_text_size"
tools:text="Intermediate point"/>
</LinearLayout>
@ -342,13 +348,17 @@
android:text="@string/route_to"
android:textSize="@dimen/default_sub_text_size" />
<Spinner
android:id="@+id/ToSpinner"
<TextView
android:id="@+id/toText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-8dp"
android:background="@null"
android:textSize="@dimen/default_list_text_size" />
android:layout_marginEnd="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding"
android:gravity="left"
android:singleLine="true"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size"
tools:text="Destination"/>
</LinearLayout>
@ -498,7 +508,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="top|fill_horizontal"
tools:foreground="@drawable/bg_contextmenu_shadow">
android:foreground="@drawable/bg_contextmenu_shadow">
<net.osmand.plus.LockableScrollView
android:id="@+id/route_menu_bottom_scroll"
@ -540,7 +550,7 @@
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
android:src="@drawable/bg_contextmenu_shadow" />
</LinearLayout>

View file

@ -524,4 +524,13 @@ public class AndroidUtils {
}
return result;
}
public static void deleteRecursive(File fileOrDir){
if(fileOrDir.isDirectory()) {
for (File child: fileOrDir.listFiles()) {
deleteRecursive(child);
}
}
fileOrDir.delete();
}
}

View file

@ -79,6 +79,7 @@ import net.osmand.aidl.gpx.CreateGpxBitmapParams;
import net.osmand.aidl.tiles.ASqliteDbFile;
import net.osmand.aidl.plugins.PluginParams;
import net.osmand.aidl.tiles.CopyFileParams;
@ -179,4 +180,6 @@ interface IOsmAndAidlInterface {
boolean registerForOsmandInitListener(in IOsmAndAidlCallback callback);
boolean getBitmapForGpx(in CreateGpxBitmapParams file, IOsmAndAidlCallback callback);
int copyFile(in CopyFileParams filePart);
}

View file

@ -1,5 +1,6 @@
package net.osmand.aidl;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.BroadcastReceiver;
@ -44,6 +45,7 @@ import net.osmand.aidl.navdrawer.NavDrawerFooterParams;
import net.osmand.aidl.plugins.PluginParams;
import net.osmand.aidl.search.SearchResult;
import net.osmand.aidl.tiles.ASqliteDbFile;
import net.osmand.aidl.tiles.CopyFileParams;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
@ -98,16 +100,10 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static net.osmand.aidl.OsmandAidlConstants.*;
import static net.osmand.plus.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME;
@ -1661,7 +1657,6 @@ public class OsmandAidlApi {
@Override
public void onFinish(AppInitializer init) {
try {
LOG.debug("AIDL App registerForOsmandInitialization");
callback.onAppInitialized();
} catch (Exception e) {
e.printStackTrace();
@ -1967,6 +1962,96 @@ public class OsmandAidlApi {
gpxAsyncLoaderTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
private Map<String, FileCopyInfo> copyFilesCache = new ConcurrentHashMap<>();
private class FileCopyInfo {
long start;
long lastAccess;
FileOutputStream FileOutputStream;
FileCopyInfo(long start, long lastAccess, FileOutputStream fileOutputStream) {
this.start = start;
this.lastAccess = lastAccess;
FileOutputStream = fileOutputStream;
}
}
int copyFile(final CopyFileParams filePart) {
if (Algorithms.isEmpty(filePart.getFilename()) || filePart.getFilePartData() == null) {
return COPY_FILE_PARAMS_ERROR;
}
if (filePart.getFilename().endsWith(IndexConstants.SQLITE_EXT)) {
return copyFileImpl(filePart,
IndexConstants.TILES_INDEX_DIR);
} else {
return COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR;
}
}
private int copyFileImpl(CopyFileParams fileParams, String destination){
if (fileParams.getFilePartData().length > 256*1024) {
return COPY_FILE_PART_SIZE_LIMIT_ERROR;
}
File file = app.getAppPath(IndexConstants.TEMP_DIR + fileParams.getFilename());
FileOutputStream fos;
String key = fileParams.getFilename();
try {
if (!copyFilesCache.containsKey(key)){
if (fileParams.getActionId() == COPY_FILE_START_FLAG) {
file.delete();
file.getParentFile().mkdirs();
fos = new FileOutputStream(file, true);
fos.write(fileParams.getFilePartData());
copyFilesCache.put(
key, new FileCopyInfo(fileParams.getStartTime(), System.currentTimeMillis(),
fos));
return COPY_FILE_OK_RESPONSE;
} else if (fileParams.getActionId() == COPY_FILE_FINISH_FLAG) {
file.delete();
file.getParentFile().mkdirs();
fos = new FileOutputStream(file, true);
fos.write(fileParams.getFilePartData());
file.renameTo(app.getAppPath(destination + fileParams.getFilename()));
return COPY_FILE_OK_RESPONSE;
} else {
return COPY_FILE_PARAMS_ERROR;
}
} else if (copyFilesCache.containsKey(key)) {
fos = copyFilesCache.get(key).FileOutputStream;
if (fileParams.getActionId() == COPY_FILE_START_FLAG) {
if (copyFilesCache.get(key).lastAccess - copyFilesCache.get(key).start > COPY_FILE_VALID_PAUSE) {
file.delete();
fos.close();
copyFilesCache.remove(key);
file.getParentFile().mkdirs();
fos = new FileOutputStream(file, true);
fos.write(fileParams.getFilePartData());
copyFilesCache.put(key,
new FileCopyInfo(fileParams.getStartTime(), System.currentTimeMillis(), fos));
return COPY_FILE_OK_RESPONSE;
} else {
return COPY_FILE_WRITE_LOCK_ERROR;
}
} else if (fileParams.getActionId() == COPY_FILE_FINISH_FLAG) {
fos.close();
copyFilesCache.remove(key);
file.renameTo(app.getAppPath(destination + fileParams.getFilename()));
return COPY_FILE_OK_RESPONSE;
} else {
copyFilesCache.get(key).lastAccess = System.currentTimeMillis();
fos.write(fileParams.getFilePartData());
return COPY_FILE_OK_RESPONSE;
}
}
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
return COPY_FILE_IO_ERROR;
}
private static class GpxAsyncLoaderTask extends AsyncTask<Void, Void, GPXFile> {
private final OsmandApplication app;

View file

@ -0,0 +1,16 @@
package net.osmand.aidl;
public interface OsmandAidlConstants {
int COPY_FILE_PARAMS_ERROR = -1001;
int COPY_FILE_PART_SIZE_LIMIT_ERROR = -1002;
int COPY_FILE_WRITE_LOCK_ERROR = -1003;
int COPY_FILE_IO_ERROR = -1004;
int COPY_FILE_UNSUPPORTED_FILE_TYPE_ERROR = -1005;
int COPY_FILE_START_FLAG = 1001;
int COPY_FILE_FINISH_FLAG = 1002;
int COPY_FILE_IN_PROGRESS_FLAG = 1000;
long COPY_FILE_VALID_PAUSE = 10000;
int COPY_FILE_OK_RESPONSE = 0;
}

View file

@ -66,6 +66,7 @@ import net.osmand.aidl.plugins.PluginParams;
import net.osmand.aidl.search.SearchParams;
import net.osmand.aidl.search.SearchResult;
import net.osmand.aidl.tiles.ASqliteDbFile;
import net.osmand.aidl.tiles.CopyFileParams;
import net.osmand.plus.OsmandApplication;
import net.osmand.util.Algorithms;
@ -844,5 +845,14 @@ public class OsmandAidlService extends Service {
return false;
}
}
@Override
public int copyFile(CopyFileParams copyFileParams) {
OsmandAidlApi api = getApi("copyFile");
if (api==null) {
return -5;
}
return api.copyFile(copyFileParams);
}
};
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.tiles;
parcelable CopyFileParams;

View file

@ -0,0 +1,82 @@
package net.osmand.aidl.tiles;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Arrays;
public class CopyFileParams implements Parcelable {
private String filename;
private byte[] filePartData;
private long startTime;
private int actionId;
public CopyFileParams(String filename, byte[] filePartData, long startTime, int actionId) {
this.filename = filename;
this.filePartData = filePartData;
this.startTime = startTime;
this.actionId = actionId;
}
public String getFilename() {
return filename;
}
public byte[] getFilePartData() {
return filePartData;
}
public int getActionId() {
return actionId;
}
public long getStartTime() {
return startTime;
}
protected CopyFileParams(Parcel in) {
filename = in.readString();
filePartData = in.createByteArray();
startTime = in.readLong();
actionId = in.readInt();
}
public static final Creator<CopyFileParams> CREATOR = new Creator<CopyFileParams>() {
@Override
public CopyFileParams createFromParcel(Parcel in) {
return new CopyFileParams(in);
}
@Override
public CopyFileParams[] newArray(int size) {
return new CopyFileParams[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public String toString() {
return "CopyFileParams{" +
"filename='" + filename + '\'' +
", filePartData=" + filePartData +
", startTime=" + startTime +
", actionId=" + actionId +
'}';
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(filename);
dest.writeByteArray(filePartData);
dest.writeLong(startTime);
dest.writeInt(actionId);
}
}

View file

@ -26,7 +26,9 @@ import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibilityPlugin;
import net.osmand.aidl.OsmandAidlApi;
@ -170,6 +172,8 @@ public class OsmandApplication extends MultiDexApplication {
externalStorageDirectory = osmandSettings.getInternalAppPath();
}
AndroidUtils.deleteRecursive(this.getAppPath(IndexConstants.TEMP_DIR));
checkPreferredLocale();
appInitializer.onCreateApplication();
// if(!osmandSettings.FOLLOW_THE_ROUTE.get()) {

View file

@ -61,6 +61,7 @@ import net.osmand.plus.mapmarkers.MapMarkersDialogFragment;
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.BaseMapLayer;
@ -943,7 +944,7 @@ public class MapActivityActions implements DialogProvider {
}
public void openIntermediatePointsDialog() {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
WaypointsFragment.showInstance(mapActivity);
}
public void openRoutePreferencesDialog() {

View file

@ -3,6 +3,7 @@ package net.osmand.plus.dashboard;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.PopupMenu;
import android.view.LayoutInflater;
@ -15,19 +16,18 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import java.util.ArrayList;
import java.util.Collections;
@ -70,38 +70,45 @@ public class DashWaypointsFragment extends DashLocationFragment {
}
private void setupWaypoints() {
FragmentActivity activity = getActivity();
View mainView = getView();
WaypointHelper wh = getMyApplication().getWaypointHelper();
List<LocationPointWrapper> allPoints = wh.getAllPoints();
if (allPoints.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
}
((TextView) mainView.findViewById(R.id.fav_text)).setText(getString(R.string.shared_string_waypoints));
((Button) mainView.findViewById(R.id.show_all)).setText(getString(R.string.shared_string_show_all));
((Button) mainView.findViewById(R.id.show_all)).setVisibility(View.VISIBLE);
((Button) mainView.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dashboard.setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getCenterViewCoordinates(v));
if (activity != null && mainView != null) {
WaypointHelper wh = getMyApplication().getWaypointHelper();
List<LocationPointWrapper> allPoints = wh.getAllPoints();
if (allPoints.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;
} else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
}
});
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews();
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for(int i = 0; i < 3 && i < allPoints.size(); i++) {
LocationPointWrapper ps = allPoints.get(i);
View dv = getActivity().getLayoutInflater().inflate(R.layout.divider, null);
favorites.addView(dv);
View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(),
getActivity(), null, null, ps, null, !getMyApplication().getSettings().isLightContent(), true);
favorites.addView(v);
((TextView) mainView.findViewById(R.id.fav_text)).setText(getString(R.string.shared_string_waypoints));
((Button) mainView.findViewById(R.id.show_all)).setText(getString(R.string.shared_string_show_all));
((Button) mainView.findViewById(R.id.show_all)).setVisibility(View.VISIBLE);
((Button) mainView.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentActivity activity = getActivity();
if (activity instanceof MapActivity) {
dashboard.hideDashboard();
WaypointsFragment.showInstance((MapActivity) activity);
}
}
});
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews();
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for (int i = 0; i < 3 && i < allPoints.size(); i++) {
LocationPointWrapper ps = allPoints.get(i);
View dv = activity.getLayoutInflater().inflate(R.layout.divider, null);
favorites.addView(dv);
View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(),
activity, null, null, ps, null, !getMyApplication().getSettings().isLightContent(), true);
favorites.addView(v);
}
this.distances = distances;
}
this.distances = distances;
}
public void setupTargets() {

View file

@ -7,7 +7,6 @@ import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
@ -18,7 +17,6 @@ import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
@ -40,6 +38,7 @@ import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TextView;
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
import com.github.ksoichiro.android.observablescrollview.ScrollState;
@ -48,18 +47,15 @@ import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.ValueHolder;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
@ -71,16 +67,15 @@ import net.osmand.plus.download.DownloadIndexesThread;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointDialogHelper.WaypointDialogHelperCallbacks;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
import net.osmand.plus.mapillary.MapillaryFiltersFragment;
import net.osmand.plus.mapillary.MapillaryPlugin.MapillaryFirstDialogFragment;
import net.osmand.plus.osmedit.OsmNotesMenu;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingParameter;
import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.srtmplugin.ContourLinesMenu;
import net.osmand.plus.srtmplugin.HillshadeMenu;
import net.osmand.plus.srtmplugin.SRTMPlugin;
@ -88,11 +83,6 @@ import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.controls.DynamicListView;
import net.osmand.plus.views.controls.DynamicListViewCallbacks;
import net.osmand.plus.views.controls.StableArrayAdapter;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.DismissCallbacks;
import net.osmand.plus.views.controls.SwipeDismissListViewTouchListener.Undoable;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
import java.lang.ref.WeakReference;
@ -103,10 +93,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicListViewCallbacks,
IRouteInformationListener, WaypointDialogHelperCallbacks {
public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInformationListener {
private static final org.apache.commons.logging.Log LOG =
PlatformUtil.getLog(DashboardOnMap.class);
private static final String TAG = "DashboardOnMap";
@ -142,7 +129,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private ArrayAdapter<?> listAdapter;
private OnItemClickListener listAdapterOnClickListener;
private SwipeDismissListViewTouchListener swipeDismissListener;
private boolean visible = false;
private DashboardType visibleType;
@ -155,7 +141,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private boolean mapLinkedToLocation;
private float mapRotation;
private boolean inLocationUpdate = false;
private DynamicListView listView;
private ObservableListView listView;
private View listBackgroundView;
private Toolbar toolbar;
private View paddingView;
@ -180,8 +166,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
public enum DashboardType {
WAYPOINTS,
WAYPOINTS_FLAT,
CONFIGURE_SCREEN,
CONFIGURE_MAP,
LIST_MENU,
@ -235,7 +219,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
public void createDashboardView() {
baseColor = ContextCompat.getColor(mapActivity, R.color.osmand_orange) & 0x00ffffff;
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
waypointDialogHelper.addHelperCallbacks(this);
landscape = !AndroidUiHelper.isOrientationPortrait(mapActivity);
dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard);
AndroidUtils.addStatusBarPadding21v(mapActivity, dashboardView);
@ -247,122 +230,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
};
toolbar = ((Toolbar) dashboardView.findViewById(R.id.toolbar));
ObservableScrollView scrollView = ((ObservableScrollView) dashboardView.findViewById(R.id.main_scroll));
listView = (DynamicListView) dashboardView.findViewById(R.id.dash_list_view);
listView = (ObservableListView) dashboardView.findViewById(R.id.dash_list_view);
//listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setDrawSelectorOnTop(true);
listView.setDynamicListViewCallbacks(this);
listView.setScrollViewCallbacks(this);
listEmptyTextView = (TextView) dashboardView.findViewById(R.id.emptyTextView);
// Create a ListView-specific touch listener. ListViews are given special treatment because
// by default they handle touches for their list items... i.e. they're in charge of drawing
// the pressed state (the list selector), handling list item clicks, etc.
swipeDismissListener = new SwipeDismissListViewTouchListener(
mapActivity,
listView,
new DismissCallbacks() {
@Override
public boolean canDismiss(int position) {
if (listAdapter instanceof StableArrayAdapter
&& (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT)) {
List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects();
Object obj = listAdapter.getItem(position);
if (obj instanceof LocationPointWrapper) {
LocationPointWrapper w = (LocationPointWrapper) obj;
if (w.getPoint() instanceof TargetPoint) {
return !((TargetPoint) w.getPoint()).start;
}
}
return activeObjects.contains(obj);
}
return false;
}
@Override
public Undoable onDismiss(final int position) {
final Object item;
final StableArrayAdapter stableAdapter;
final int activeObjPos;
if (listAdapter instanceof StableArrayAdapter) {
stableAdapter = (StableArrayAdapter) listAdapter;
item = stableAdapter.getItem(position);
stableAdapter.setNotifyOnChange(false);
stableAdapter.remove(item);
stableAdapter.getObjects().remove(item);
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
stableAdapter.getActiveObjects().remove(item);
stableAdapter.refreshData();
stableAdapter.notifyDataSetChanged();
} else {
item = null;
stableAdapter = null;
activeObjPos = 0;
}
return new Undoable() {
@Override
public void undo() {
if (item != null) {
stableAdapter.setNotifyOnChange(false);
stableAdapter.insert(item, position);
stableAdapter.getObjects().add(position, item);
stableAdapter.getActiveObjects().add(activeObjPos, item);
stableAdapter.refreshData();
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
onItemsSwapped(stableAdapter.getActiveObjects());
}
}
}
@Override
public String getTitle() {
List<Object> activeObjects;
if ((visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT)
&& (getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode())
&& item != null
&& ((activeObjects = stableAdapter.getActiveObjects()).isEmpty() || isContainsOnlyStart(activeObjects))) {
return mapActivity.getResources().getString(R.string.cancel_navigation);
} else {
return null;
}
}
};
}
@Override
public void onHidePopup() {
if (listAdapter instanceof StableArrayAdapter) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
stableAdapter.refreshData();
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
onItemsSwapped(stableAdapter.getActiveObjects());
}
List<Object> activeObjects = stableAdapter.getActiveObjects();
if (activeObjects.isEmpty() || isContainsOnlyStart(activeObjects)) {
hideDashboard();
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
mapActivity.getMapActions().stopNavigationWithoutConfirm();
getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, true);
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
}
}
}
}
private boolean isContainsOnlyStart(List<Object> items) {
if (items.size() == 1) {
Object item = items.get(0);
if (item instanceof LocationPointWrapper) {
LocationPointWrapper w = (LocationPointWrapper) item;
if (w.getPoint() instanceof TargetPoint) {
return ((TargetPoint) w.getPoint()).start;
}
}
}
return false;
}
});
gradientToolbar = ContextCompat.getDrawable(mapActivity, R.drawable.gradient_toolbar).mutate();
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
this.portrait = true;
@ -432,10 +304,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private void updateToolbarActions() {
TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text);
tv.setText("");
boolean waypointsVisible = visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT;
if (waypointsVisible) {
tv.setText(R.string.shared_string_waypoints);
} else if (visibleType == DashboardType.CONFIGURE_MAP) {
if (visibleType == DashboardType.CONFIGURE_MAP) {
tv.setText(R.string.configure_map);
} else if (visibleType == DashboardType.CONFIGURE_SCREEN) {
tv.setText(R.string.layer_map_appearance);
@ -478,24 +347,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
});
if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) {
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
flat.setVisibility(View.VISIBLE);
final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT;
flat.setImageDrawable(iconsCache.getIcon(flatNow ? R.drawable.ic_tree_list_dark
: R.drawable.ic_flat_list_dark));
flat.setContentDescription(mapActivity.getString(flatNow ? R.string.access_tree_list : R.string.drawer));
flat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT,
previousVisibleType, false, AndroidUtils.getCenterViewCoordinates(v));
}
});
}
}
if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) {
settingsButton.setVisibility(View.VISIBLE);
settingsButton.setOnClickListener(new View.OnClickListener() {
@ -607,12 +458,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
button = actionButtons.get(DashboardActionButtonType.MY_LOCATION);
} else if (type == DashboardType.ROUTE_PREFERENCES) {
button = actionButtons.get(DashboardActionButtonType.NAVIGATE);
} else if (type == DashboardType.WAYPOINTS || type == DashboardType.WAYPOINTS_FLAT) {
if (isInRouteOrPlannigMode()) {
button = actionButtons.get(DashboardActionButtonType.NAVIGATE);
} else {
button = actionButtons.get(DashboardActionButtonType.ROUTE);
}
}
if (button != null) {
@ -720,10 +565,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
DashboardOnMap.staticVisible = visible;
DashboardOnMap.staticVisibleType = type;
mapActivity.enableDrawer();
if (swipeDismissListener != null) {
swipeDismissListener.discardUndo();
}
removeMapillaryFiltersFragment();
if (visible) {
@ -825,14 +666,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
// listView.setBackgroundColor(backgroundColor);
listEmptyTextView.setBackgroundColor(backgroundColor);
}
if (visibleType != DashboardType.WAYPOINTS
&& visibleType != DashboardType.CONFIGURE_SCREEN
if (visibleType != DashboardType.CONFIGURE_SCREEN
&& visibleType != DashboardType.CONFIGURE_MAP
&& visibleType != DashboardType.CONTOUR_LINES
&& visibleType != DashboardType.HILLSHADE
&& visibleType != DashboardType.OSM_NOTES) {
listView.setDivider(dividerDrawable);
listView.setDividerHeight(dpToPx(1f));
listView.setDividerHeight(AndroidUtils.dpToPx(mapActivity, 1f));
} else {
listView.setDivider(null);
}
@ -843,60 +683,34 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
private int dpToPx(float dp) {
Resources r = mapActivity.getResources();
return (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics());
}
private void updateListAdapter() {
listEmptyTextView.setVisibility(View.GONE);
listView.setEmptyView(null);
ContextMenuAdapter cm = null;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
StableArrayAdapter listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running,
DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
listAdapter);
setDynamicListItems(listView, listAdapter);
if (visibleType == DashboardType.CONFIGURE_SCREEN) {
cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity);
} else if (visibleType == DashboardType.CONFIGURE_MAP) {
cm = new ConfigureMapMenu().createListAdapter(mapActivity);
} else if (visibleType == DashboardType.LIST_MENU) {
cm = mapActivity.getMapActions().createMainOptionsMenu();
} else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
RoutePreferencesMenu routePreferencesMenu = new RoutePreferencesMenu(mapActivity);
ArrayAdapter<LocalRoutingParameter> listAdapter = routePreferencesMenu.getRoutePreferencesDrawerAdapter(nightMode);
OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
updateListAdapter(listAdapter, listener);
if (listAdapter.getObjects().size() == 0) {
listEmptyTextView.setText(mapActivity.getString(R.string.no_waypoints_found));
if (landscape) {
listView.setEmptyView(listEmptyTextView);
} else {
listEmptyTextView.setVisibility(View.VISIBLE);
}
}
} else {
if (visibleType == DashboardType.CONFIGURE_SCREEN) {
cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity);
} else if (visibleType == DashboardType.CONFIGURE_MAP) {
cm = new ConfigureMapMenu().createListAdapter(mapActivity);
} else if (visibleType == DashboardType.LIST_MENU) {
cm = mapActivity.getMapActions().createMainOptionsMenu();
} else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
RoutePreferencesMenu routePreferencesMenu = new RoutePreferencesMenu(mapActivity);
ArrayAdapter<LocalRoutingParameter> listAdapter = routePreferencesMenu.getRoutePreferencesDrawerAdapter(nightMode);
OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
updateListAdapter(listAdapter, listener);
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY);
} else if (visibleType == DashboardType.OVERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY);
} else if (visibleType == DashboardType.CONTOUR_LINES) {
cm = ContourLinesMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.HILLSHADE) {
cm = HillshadeMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.OSM_NOTES) {
cm = OsmNotesMenu.createListAdapter(mapActivity);
}
if (cm != null) {
updateListAdapter(cm);
}
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY);
} else if (visibleType == DashboardType.OVERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY);
} else if (visibleType == DashboardType.CONTOUR_LINES) {
cm = ContourLinesMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.HILLSHADE) {
cm = HillshadeMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.OSM_NOTES) {
cm = OsmNotesMenu.createListAdapter(mapActivity);
}
if (cm != null) {
updateListAdapter(cm);
}
}
@ -956,12 +770,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
.detach(mapillaryFragment)
.attach(mapillaryFragment)
.commit();
} else if (visibleType == DashboardType.WAYPOINTS
|| visibleType == DashboardType.CONFIGURE_SCREEN
|| force) {
} else if (visibleType == DashboardType.CONFIGURE_SCREEN || force) {
updateListAdapter();
} else if (visibleType == DashboardType.CONFIGURE_MAP
|| visibleType == DashboardType.ROUTE_PREFERENCES) {
} else if (visibleType == DashboardType.CONFIGURE_MAP || visibleType == DashboardType.ROUTE_PREFERENCES) {
int index = listView.getFirstVisiblePosition();
View v = listView.getChildAt(0);
int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
@ -972,14 +783,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
private void setDynamicListItems(DynamicListView listView, StableArrayAdapter listAdapter) {
listView.setItemsList(listAdapter.getObjects());
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
listView.setActiveItemsList(listAdapter.getActiveObjects());
}
}
private OnItemClickListener getOptionsMenuOnClickListener(final ContextMenuAdapter cm,
final ArrayAdapter<ContextMenuItem> listAdapter) {
return new AdapterView.OnItemClickListener() {
@ -1063,8 +866,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}, 4000);
}
public void navigationAction() {
void navigationAction() {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
mapActivity.getMapActions().enterRoutePlanningMode(null, null);
@ -1077,7 +879,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
hideDashboard(animate);
}
// To bounce animate view
private void open(boolean animation, int[] animationCoordinates) {
if (animation) {
@ -1166,7 +967,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
animationCoordinates = null;
}
private void addOrUpdateDashboardFragments() {
OsmandSettings settings = getMyApplication().getSettings();
TransactionBuilder builder =
@ -1192,7 +992,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
return visible;
}
public void onDetach(DashBaseFragment dashBaseFragment) {
void onDetach(DashBaseFragment dashBaseFragment) {
Iterator<WeakReference<DashBaseFragment>> it = fragList.iterator();
while (it.hasNext()) {
WeakReference<DashBaseFragment> wr = it.next();
@ -1202,7 +1002,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
public void updateLocation(final boolean centerChanged, final boolean locationChanged,
final boolean compassChanged) {
if (inLocationUpdate) {
@ -1240,16 +1039,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
dashboardView.requestLayout();
}
public void onMenuPressed() {
if (!isVisible()) {
setDashboardVisibility(true, DashboardType.DASHBOARD);
} else {
hideDashboard();
}
}
public boolean onBackPressed() {
if (isVisible()) {
backPressed();
@ -1258,7 +1047,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
return false;
}
private void backPressed() {
if (previousVisibleType != visibleType && previousVisibleType != null) {
if (visibleType == DashboardType.MAPILLARY) {
@ -1275,11 +1063,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
View currentFocus = mapActivity.getCurrentFocus();
if (currentFocus != null) {
InputMethodManager imm = (InputMethodManager) mapActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
if (imm != null) {
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
}
}
}
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
// Translate list background
@ -1298,8 +1087,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private boolean isActionButtonVisible() {
return visibleType == DashboardType.DASHBOARD
|| visibleType == DashboardType.WAYPOINTS
|| visibleType == DashboardType.WAYPOINTS_FLAT
|| visibleType == DashboardType.LIST_MENU
|| visibleType == DashboardType.ROUTE_PREFERENCES
|| visibleType == DashboardType.CONFIGURE_SCREEN;
@ -1322,7 +1109,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
private void updateTopButton(int scrollY) {
if (actionButton != null && portrait && isActionButtonVisible()) {
double scale = mapActivity.getResources().getDisplayMetrics().density;
int originalPosition = mFlexibleSpaceImageHeight - (int) (80 * scale);
@ -1350,7 +1136,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
private void updateColorOfToolbar(int scrollY) {
if (portrait) {
float sh = mFlexibleSpaceImageHeight - mFlexibleBlurSpaceHeight;
@ -1425,7 +1210,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
public <T extends DashBaseFragment> T getFragmentByClass(Class<T> class1) {
<T extends DashBaseFragment> T getFragmentByClass(Class<T> class1) {
for (WeakReference<DashBaseFragment> f : fragList) {
DashBaseFragment b = f.get();
if (b != null && !b.isDetached() && class1.isInstance(b)) {
@ -1436,26 +1221,26 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
return null;
}
public void blacklistFragmentByTag(String tag) {
void blacklistFragmentByTag(String tag) {
hideFragmentByTag(tag);
getMyApplication().getSettings().registerBooleanPreference(SHOULD_SHOW + tag, true)
.makeGlobal().set(false);
}
public void hideFragmentByTag(String tag) {
void hideFragmentByTag(String tag) {
FragmentManager manager = mapActivity.getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
Fragment frag = manager.findFragmentByTag(tag);
transaction.hide(frag).commit();
}
public void unblacklistFragmentClass(String tag) {
void unblacklistFragmentClass(String tag) {
unhideFragmentByTag(tag);
getMyApplication().getSettings().registerBooleanPreference(SHOULD_SHOW + tag, true)
.makeGlobal().set(true);
}
public void unhideFragmentByTag(String tag) {
void unhideFragmentByTag(String tag) {
FragmentManager manager = mapActivity.getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
Fragment frag = manager.findFragmentByTag(tag);
@ -1470,8 +1255,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
return dashboardView;
}
public static <T> List<T> handleNumberOfRows(List<T> list, OsmandSettings settings,
String rowNumberTag) {
public static <T> void handleNumberOfRows(List<T> list, OsmandSettings settings,
String rowNumberTag) {
int numberOfRows = settings.registerIntPreference(rowNumberTag, 3)
.makeGlobal().get();
if (list.size() > numberOfRows) {
@ -1479,7 +1264,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
list.remove(numberOfRows);
}
}
return list;
}
public static class DefaultShouldShow extends DashFragmentData.ShouldShowFunction {
@ -1489,66 +1273,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
@Override
public void onItemSwapping(int position) {
}
@SuppressWarnings("unchecked")
@Override
public void onItemsSwapped(final List<Object> items) {
getMyApplication().runInUIThread(new Runnable() {
@Override
public void run() {
if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) {
List<TargetPoint> allTargets = new ArrayList<>();
TargetPoint start = null;
if (items != null) {
for (Object obj : items) {
if (obj instanceof LocationPointWrapper) {
LocationPointWrapper p = (LocationPointWrapper) obj;
if (p.getPoint() instanceof TargetPoint) {
TargetPoint t = (TargetPoint) p.getPoint();
if (t.start) {
start = t;
} else {
t.intermediate = true;
}
allTargets.add(t);
}
}
}
if (allTargets.size() > 0) {
allTargets.get(allTargets.size() - 1).intermediate = false;
}
}
TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
if (start != null) {
int startInd = allTargets.indexOf(start);
TargetPoint first = allTargets.remove(0);
if (startInd != 0) {
start.start = false;
start.intermediate = startInd != allTargets.size() - 1;
if (targetPointsHelper.getPointToStart() == null) {
start.getOriginalPointDescription().setName(PointDescription
.getLocationNamePlain(getMyApplication(), start.getLatitude(), start.getLongitude()));
}
first.start = true;
first.intermediate = false;
targetPointsHelper.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()),
false, first.getPointDescription(getMyApplication()));
}
}
targetPointsHelper.reorderAllTargetPoints(allTargets, false);
newRouteIsCalculated(false, new ValueHolder<Boolean>());
targetPointsHelper.updateRouteAndRefresh(true);
}
}
}, 50);
}
@Override
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
reloadAdapter();
showToast.value = false;
}
@ -1559,50 +1285,4 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
@Override
public void routeWasFinished() {
}
@Override
public void onWindowVisibilityChanged(int visibility) {
if (visibility != View.VISIBLE && swipeDismissListener != null) {
swipeDismissListener.discardUndo();
}
}
@Override
public void reloadAdapter() {
if (listAdapter != null && listAdapter instanceof StableArrayAdapter) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
waypointDialogHelper.reloadListAdapter(stableAdapter);
}
setDynamicListItems(listView, stableAdapter);
}
}
private void deleteSwipeItem(int position) {
if (swipeDismissListener != null) {
swipeDismissListener.delete(position);
}
}
@Override
public void deleteWaypoint(int position) {
deleteSwipeItem(position);
}
@Override
public void exchangeWaypoints(int pos1, int pos2) {
if (swipeDismissListener != null) {
swipeDismissListener.discardUndo();
}
if (pos1 != -1 && pos2 != -1) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
Object item1 = stableAdapter.getActiveObjects().get(pos1);
Object item2 = stableAdapter.getActiveObjects().get(pos2);
stableAdapter.getActiveObjects().set(pos1, item2);
stableAdapter.getActiveObjects().set(pos2, item1);
stableAdapter.refreshData();
onItemsSwapped(stableAdapter.getActiveObjects());
}
}
}

View file

@ -47,6 +47,7 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.routepreparationmenu.AddPointBottomSheetDialog;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.views.controls.DynamicListView.DragIcon;
@ -319,108 +320,6 @@ public class WaypointDialogHelper {
return res;
}
public StableArrayAdapter getWaypointsDrawerAdapter(
final boolean edit, final List<LocationPointWrapper> deletedPoints,
final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) {
this.flat = flat;
this.deletedPoints = deletedPoints;
final List<Object> points = getPoints();
List<Object> activePoints = getActivePoints(points);
final WaypointDialogHelper helper = this;
final StableArrayAdapter listAdapter = new StableArrayAdapter(ctx,
R.layout.waypoint_reached, R.id.title, points, activePoints) {
@Override
public void buildDividers() {
dividers = getCustomDividers(ctx, getObjects(), nightMode);
}
@Override
public boolean isEnabled(int position) {
Object obj = getItem(position);
boolean labelView = (obj instanceof Integer);
boolean topDividerView = (obj instanceof Boolean) && ((Boolean) obj);
boolean bottomDividerView = (obj instanceof Boolean) && !((Boolean) obj);
boolean enabled = !labelView && !topDividerView && !bottomDividerView;
if (enabled && obj instanceof RadiusItem) {
int type = ((RadiusItem) obj).type;
enabled = type != WaypointHelper.POI;
}
return enabled;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// User super class to create the View
View v = convertView;
final ArrayAdapter<Object> thisAdapter = this;
Object obj = getItem(position);
boolean labelView = (obj instanceof Integer);
boolean topDividerView = (obj instanceof Boolean) && ((Boolean) obj);
boolean bottomDividerView = (obj instanceof Boolean) && !((Boolean) obj);
if (obj instanceof RadiusItem) {
final int type = ((RadiusItem) obj).type;
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter, nightMode);
//Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} else if (labelView) {
v = createItemForCategory(ctx, (Integer) obj, running, position, thisAdapter, nightMode, helper);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} else if (topDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_top_divider, null);
AndroidUtils.setListBackground(mapActivity, v, nightMode);
} else if (bottomDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_bottom_divider, null);
AndroidUtils.setListBackground(mapActivity, v, nightMode);
} else if (obj instanceof LocationPointWrapper) {
LocationPointWrapper point = (LocationPointWrapper) obj;
v = updateWaypointItemView(edit, deletedPoints, app, ctx, helper, v, point, this,
nightMode, flat);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
}
return v;
}
};
for (Object p : points) {
if (p instanceof LocationPointWrapper) {
LocationPointWrapper w = (LocationPointWrapper) p;
if (w.type == WaypointHelper.TARGETS) {
final TargetPoint t = (TargetPoint) w.point;
if (t.getOriginalPointDescription() != null
&& t.getOriginalPointDescription().isSearchingAddress(mapActivity)) {
GeocodingLookupService.AddressLookupRequest lookupRequest
= new GeocodingLookupService.AddressLookupRequest(t.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
if (!helperCallbacks.isEmpty()) {
for (WaypointDialogHelperCallbacks callback : helperCallbacks) {
callback.reloadAdapter();
}
} else {
reloadListAdapter(listAdapter);
}
//updateRouteInfoMenu(ctx);
}
}, null);
app.getGeocodingLookupService().lookupAddress(lookupRequest);
}
}
}
}
return listAdapter;
}
public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
final OsmandApplication app, final Activity ctx,
final WaypointDialogHelper helper, View v,
@ -1129,42 +1028,20 @@ public class WaypointDialogHelper {
return R.string.shared_string_close;
}
private void openAddPointDialog(MapActivity mapActivity) {
Bundle args = new Bundle();
args.putBoolean(AddPointBottomSheetDialog.TARGET_KEY, false);
args.putBoolean(AddPointBottomSheetDialog.INTERMEDIATE_KEY, true);
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
fragment.setArguments(args);
fragment.setUsedOnMap(false);
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
}
private void onWaypointItemClick(BaseBottomSheetItem[] addWaypointItem) {
final MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
final MapRouteInfoMenu routeMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
final ListPopupWindow popup = new ListPopupWindow(mapActivity);
popup.setAnchorView(addWaypointItem[0].getView());
popup.setDropDownGravity(Gravity.END | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(mapActivity, 48f));
popup.setModal(true);
popup.setAdapter(routeMenu.getIntermediatesPopupAdapter(mapActivity));
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
boolean hideDashboard = false;
if (id == MapRouteInfoMenu.SPINNER_FAV_ID) {
routeMenu.selectFavorite(null, false, true);
} else if (id == MapRouteInfoMenu.SPINNER_MAP_ID) {
hideDashboard = true;
routeMenu.selectOnScreen(false, true);
} else if (id == MapRouteInfoMenu.SPINNER_ADDRESS_ID) {
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.INTERMEDIATE_SELECTION, false);
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_MORE_ID) {
routeMenu.selectMapMarker(-1, false, true);
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_1_ID) {
routeMenu.selectMapMarker(0, false, true);
} else if (id == MapRouteInfoMenu.SPINNER_MAP_MARKER_2_ID) {
routeMenu.selectMapMarker(1, false, true);
}
popup.dismiss();
dismiss();
if (hideDashboard) {
mapActivity.getDashboard().hideDashboard();
}
}
});
popup.show();
openAddPointDialog(mapActivity);
}
}

View file

@ -15,16 +15,13 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatImageView;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import net.osmand.AndroidUtils;
@ -358,14 +355,17 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
public void updateInfo(final View main) {
mainView = main;
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
updateViaView(main);
updateFromSpinner(main);
updateToSpinner(main);
updateApplicationModes(mainView);
updateApplicationModesOptions(main);
updateOptionsButtons(main);
updateStartPointView();
updateWaypointsView();
updateFinishPointView();
updateApplicationModes();
updateApplicationModesOptions();
updateOptionsButtons();
routeCards.clear();
if (isBasicRouteCalculated()) {
GPXUtilities.GPXFile gpx = GPXUtilities.makeGpxFromRoute(routingHelper.getRoute());
if (gpx != null) {
@ -401,11 +401,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
public void updateApplicationModesOptions() {
updateApplicationModesOptions(mainView);
}
private void updateApplicationModesOptions(final View parentView) {
AppCompatImageView foldButtonView = (AppCompatImageView) parentView.findViewById(R.id.fold_button);
AppCompatImageView foldButtonView = (AppCompatImageView) mainView.findViewById(R.id.fold_button);
foldButtonView.setImageResource(currentMenuState == MenuState.HEADER_ONLY ?
R.drawable.ic_action_arrow_up : R.drawable.ic_action_arrow_down);
foldButtonView.setOnClickListener(new View.OnClickListener() {
@ -415,7 +411,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
parentView.findViewById(R.id.app_modes_options).setOnClickListener(new View.OnClickListener() {
mainView.findViewById(R.id.app_modes_options).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
availableProfileDialog();
@ -429,7 +425,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else {
openMenuHeaderOnly();
}
updateApplicationModesOptions(mainView);
updateApplicationModesOptions();
}
private void availableProfileDialog() {
@ -457,7 +453,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
b.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
updateApplicationModes(mainView);
updateApplicationModes();
}
});
b.setView(v);
@ -482,11 +478,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
}
private void updateApplicationModes(final View parentView) {
private void updateApplicationModes() {
final ApplicationMode am = routingHelper.getAppMode();
final Set<ApplicationMode> selected = new HashSet<>();
selected.add(am);
ViewGroup vg = (ViewGroup) parentView.findViewById(R.id.app_modes);
ViewGroup vg = (ViewGroup) mainView.findViewById(R.id.app_modes);
vg.removeAllViews();
View.OnClickListener listener = new View.OnClickListener() {
@Override
@ -495,7 +491,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
ApplicationMode next = selected.iterator().next();
updateApplicationMode(am, next);
}
updateOptionsButtons(mainView);
updateOptionsButtons();
}
};
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(mapActivity.getMyApplication()));
@ -541,7 +537,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
}
private void updateOptionsButtons(final View main) {
private void updateOptionsButtons() {
final boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
final OsmandSettings settings = app.getSettings();
final int colorActive = ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
@ -550,17 +546,17 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
final RoutingOptionsHelper.RouteMenuAppModes mode = routingOptionsHelper.modes.get(applicationMode);
int margin = AndroidUtils.dpToPx(app, 3);
View startButton = main.findViewById(R.id.start_button);
View startButton = mainView.findViewById(R.id.start_button);
if (isRouteCalculated()) {
AndroidUtils.setBackground(app, startButton, nightMode, R.color.active_buttons_and_links_light, R.color.active_buttons_and_links_dark);
int color = nightMode ? R.color.main_font_dark : R.color.card_and_list_background_light;
((TextView) main.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(app, color));
((ImageView) main.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color));
((TextView) mainView.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(app, color));
((ImageView) mainView.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color));
} else {
AndroidUtils.setBackground(app, startButton, nightMode, R.color.activity_background_light, R.color.route_info_cancel_button_color_dark);
int color = R.color.description_font_and_bottom_sheet_icons;
((TextView) main.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(app, color));
((ImageView) main.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color));
((TextView) mainView.findViewById(R.id.start_button_descr)).setTextColor(ContextCompat.getColor(app, color));
((ImageView) mainView.findViewById(R.id.start_icon)).setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, color));
}
startButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -569,7 +565,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
View cancelButton = main.findViewById(R.id.cancel_button);
View cancelButton = mainView.findViewById(R.id.cancel_button);
AndroidUtils.setBackground(app, cancelButton, nightMode, R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -578,9 +574,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
LinearLayout optionsButton = (LinearLayout) main.findViewById(R.id.map_options_route_button);
TextView optionsTitle = (TextView) main.findViewById(R.id.map_options_route_button_title);
ImageView optionsIcon = (ImageView) main.findViewById(R.id.map_options_route_button_icon);
LinearLayout optionsButton = (LinearLayout) mainView.findViewById(R.id.map_options_route_button);
TextView optionsTitle = (TextView) mainView.findViewById(R.id.map_options_route_button_title);
ImageView optionsIcon = (ImageView) mainView.findViewById(R.id.map_options_route_button_icon);
Drawable drawable = app.getUIUtilities().getIcon(R.drawable.map_action_settings, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
Drawable active = app.getUIUtilities().getIcon(R.drawable.map_action_settings, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
@ -599,7 +595,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
scrollView.setVerticalScrollBarEnabled(false);
scrollView.setHorizontalScrollBarEnabled(false);
LinearLayout optionsContainer = (LinearLayout) main.findViewById(R.id.route_options_container);
LinearLayout optionsContainer = (LinearLayout) mainView.findViewById(R.id.route_options_container);
optionsContainer.removeAllViews();
if (mode == null) {
return;
@ -658,7 +654,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
public void onClick(View v) {
app.getPoiFilters().removeSelectedPoiFilter(poiUIFilter);
mapActivity.getMapView().refreshMap();
updateOptionsButtons(mainView);
updateOptionsButtons();
}
});
item.addView(container, newLp);
@ -672,7 +668,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
@Override
public void onClick(View v) {
app.getWaypointHelper().enableWaypointType(WaypointHelper.ALARMS, false);
updateOptionsButtons(mainView);
updateOptionsButtons();
}
});
AndroidUtils.setBackground(app, container, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
@ -686,7 +682,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
@Override
public void onClick(View v) {
app.getWaypointHelper().enableWaypointType(WaypointHelper.FAVORITES, false);
updateOptionsButtons(mainView);
updateOptionsButtons();
}
});
AndroidUtils.setBackground(app, container, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
@ -723,7 +719,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (mode.parameters.size() > 2) {
item.removeView(v);
} else {
updateOptionsButtons(mainView);
updateOptionsButtons();
}
}
});
@ -757,7 +753,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (mode.parameters.size() > 2) {
item.removeView(v);
} else {
updateOptionsButtons(mainView);
updateOptionsButtons();
}
}
});
@ -777,7 +773,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
routingOptionsHelper.showLocalRoutingParameterGroupDialog(group, mapActivity, new RoutingOptionsHelper.OnClickListener() {
@Override
public void onClick() {
updateOptionsButtons(mainView);
updateOptionsButtons();
}
});
}
@ -917,46 +913,33 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
RouteOptionsBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
}
private void clickRouteWaypoints() {
if (getTargets().checkPointToNavigateShort()) {
mapActivity.getMapActions().openIntermediatePointsDialog();
}
}
private void updateViaView(final View parentView) {
private void updateWaypointsView() {
String via = generateViaDescription();
View viaLayout = parentView.findViewById(R.id.ViaLayout);
View viaLayoutDivider = parentView.findViewById(R.id.viaLayoutDivider);
View viaLayout = mainView.findViewById(R.id.ViaLayout);
View viaLayoutDivider = mainView.findViewById(R.id.viaLayoutDivider);
if (via.length() == 0) {
viaLayout.setVisibility(View.GONE);
viaLayoutDivider.setVisibility(View.GONE);
} else {
viaLayout.setVisibility(View.VISIBLE);
viaLayoutDivider.setVisibility(View.VISIBLE);
((TextView) parentView.findViewById(R.id.ViaView)).setText(via);
((TextView) parentView.findViewById(R.id.ViaSubView)).setText(app.getString(R.string.intermediate_destinations, getTargets().getIntermediatePoints().size()));
((TextView) mainView.findViewById(R.id.ViaView)).setText(via);
((TextView) mainView.findViewById(R.id.ViaSubView)).setText(app.getString(R.string.intermediate_destinations, getTargets().getIntermediatePoints().size()));
}
FrameLayout viaButton = (FrameLayout) parentView.findViewById(R.id.via_button);
FrameLayout viaButton = (FrameLayout) mainView.findViewById(R.id.via_button);
viaButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// clickRouteWaypoints();
if (getTargets().checkPointToNavigateShort()) {
WaypointsFragment.showInstance(mapActivity);
}
}
});
ImageView viaIcon = (ImageView) parentView.findViewById(R.id.viaIcon);
ImageView viaIcon = (ImageView) mainView.findViewById(R.id.viaIcon);
viaIcon.setImageDrawable(getIconOrig(R.drawable.list_intermediate));
viaIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clickRouteWaypoints();
}
});
LinearLayout viaButtonContainer = (LinearLayout) parentView.findViewById(R.id.via_button_container);
LinearLayout viaButtonContainer = (LinearLayout) mainView.findViewById(R.id.via_button_container);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, viaButton, nightMode, R.drawable.btn_border_rounded_light, R.drawable.btn_border_rounded_dark);
@ -964,7 +947,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else {
AndroidUtils.setBackground(app, viaButtonContainer, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
}
ImageView viaButtonImageView = (ImageView) parentView.findViewById(R.id.via_button_image_view);
ImageView viaButtonImageView = (ImageView) mainView.findViewById(R.id.via_button_image_view);
Drawable normal = mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_edit_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
@ -975,50 +958,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
viaButtonImageView.setImageDrawable(normal);
}
private void updateToSpinner(final View parentView) {
final Spinner toSpinner = setupToSpinner(parentView);
toSpinner.setClickable(false);
final View toLayout = parentView.findViewById(R.id.ToLayout);
toSpinner.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
event.offsetLocation(AndroidUtils.dpToPx(mapActivity, 48f), 0);
toLayout.onTouchEvent(event);
return true;
}
});
toSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, final long id) {
parentView.post(new Runnable() {
@Override
public void run() {
if (id == SPINNER_FAV_ID) {
selectFavorite(parentView, true, false);
} else if (id == SPINNER_MAP_ID) {
selectOnScreen(true, false);
} else if (id == SPINNER_ADDRESS_ID) {
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.DESTINATION_SELECTION, false);
setupToSpinner(parentView);
} else if (id == SPINNER_MAP_MARKER_MORE_ID) {
selectMapMarker(-1, true, false);
setupToSpinner(parentView);
} else if (id == SPINNER_MAP_MARKER_1_ID) {
selectMapMarker(0, true, false);
} else if (id == SPINNER_MAP_MARKER_2_ID) {
selectMapMarker(1, true, false);
} else if (id == SPINNER_MAP_MARKER_3_ID) {
selectMapMarker(2, true, false);
}
}
});
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
private void updateFinishPointView() {
setupToText(mainView);
final View toLayout = mainView.findViewById(R.id.ToLayout);
toLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -1026,8 +968,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
final FrameLayout toButton = (FrameLayout) parentView.findViewById(R.id.to_button);
final LinearLayout toButtonContainer = (LinearLayout) parentView.findViewById(R.id.to_button_container);
final FrameLayout toButton = (FrameLayout) mainView.findViewById(R.id.to_button);
final LinearLayout toButtonContainer = (LinearLayout) mainView.findViewById(R.id.to_button_container);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, toButton, nightMode, R.drawable.btn_border_rounded_light, R.drawable.btn_border_rounded_dark);
@ -1035,7 +977,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else {
AndroidUtils.setBackground(app, toButtonContainer, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
}
ImageView toButtonImageView = (ImageView) parentView.findViewById(R.id.to_button_image_view);
ImageView toButtonImageView = (ImageView) mainView.findViewById(R.id.to_button_image_view);
Drawable normal = mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_plus, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
@ -1052,7 +994,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
updateToIcon(parentView);
updateToIcon(mainView);
}
private void updateToIcon(View parentView) {
@ -1060,58 +1002,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
toIcon.setImageDrawable(getIconOrig(R.drawable.list_destination));
}
private void updateFromSpinner(final View parentView) {
final TargetPointsHelper targets = getTargets();
final Spinner fromSpinner = setupFromSpinner(parentView);
fromSpinner.setClickable(false);
final View fromLayout = parentView.findViewById(R.id.FromLayout);
fromSpinner.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
event.offsetLocation(AndroidUtils.dpToPx(mapActivity, 48f), 0);
fromLayout.onTouchEvent(event);
return true;
}
});
fromSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, final long id) {
parentView.post(new Runnable() {
@Override
public void run() {
if (id == SPINNER_MY_LOCATION_ID) {
if (targets.getPointToStart() != null) {
targets.clearStartPoint(true);
mapActivity.getMyApplication().getSettings().backupPointToStart();
}
updateFromIcon(parentView);
} else if (id == SPINNER_FAV_ID) {
selectFavorite(parentView, false, false);
} else if (id == SPINNER_MAP_ID) {
selectOnScreen(false, false);
} else if (id == SPINNER_ADDRESS_ID) {
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.START_POINT_SELECTION, false);
setupFromSpinner(parentView);
} else if (id == SPINNER_MAP_MARKER_MORE_ID) {
selectMapMarker(-1, false, false);
setupFromSpinner(parentView);
} else if (id == SPINNER_MAP_MARKER_1_ID) {
selectMapMarker(0, false, false);
} else if (id == SPINNER_MAP_MARKER_2_ID) {
selectMapMarker(1, false, false);
} else if (id == SPINNER_MAP_MARKER_3_ID) {
selectMapMarker(2, false, false);
}
}
});
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
private void updateStartPointView() {
setupFromText(mainView);
final View fromLayout = mainView.findViewById(R.id.FromLayout);
fromLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -1119,8 +1012,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
FrameLayout fromButton = (FrameLayout) parentView.findViewById(R.id.from_button);
final LinearLayout fromButtonContainer = (LinearLayout) parentView.findViewById(R.id.from_button_container);
FrameLayout fromButton = (FrameLayout) mainView.findViewById(R.id.from_button);
final LinearLayout fromButtonContainer = (LinearLayout) mainView.findViewById(R.id.from_button_container);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, fromButton, nightMode, R.drawable.btn_border_rounded_light, R.drawable.btn_border_rounded_dark);
@ -1129,7 +1022,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
AndroidUtils.setBackground(app, fromButtonContainer, nightMode, R.drawable.btn_border_trans_rounded_light, R.drawable.btn_border_trans_rounded_dark);
}
ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.from_button_image_view);
ImageView swapDirectionView = (ImageView) mainView.findViewById(R.id.from_button_image_view);
Drawable normal = mapActivity.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_change_navigation_points, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
if (Build.VERSION.SDK_INT >= 21) {
@ -1162,7 +1055,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
});
updateFromIcon(parentView);
updateFromIcon(mainView);
}
public void updateFromIcon(View parentView) {
@ -1202,9 +1095,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
public void setupSpinners(final boolean target, final boolean intermediate) {
if (!intermediate && mainView != null) {
if (target) {
setupToSpinner(mainView);
setupToText(mainView);
} else {
setupFromSpinner(mainView);
setupFromText(mainView);
}
}
}
@ -1339,24 +1232,12 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
return "";
}
private Spinner setupFromSpinner(View view) {
List<RouteSpinnerRow> fromActions = new ArrayList<>();
fromActions.add(new RouteSpinnerRow(SPINNER_MY_LOCATION_ID, R.drawable.ic_action_get_my_location,
mapActivity.getString(R.string.shared_string_my_location)));
fromActions.add(new RouteSpinnerRow(SPINNER_FAV_ID, R.drawable.ic_action_fav_dark,
mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)));
fromActions.add(new RouteSpinnerRow(SPINNER_MAP_ID, R.drawable.ic_action_marker_dark,
mapActivity.getString(R.string.shared_string_select_on_map)));
fromActions.add(new RouteSpinnerRow(SPINNER_ADDRESS_ID, R.drawable.ic_action_home_dark,
mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)));
private void setupFromText(View view) {
TargetPoint start = getTargets().getPointToStart();
int startPos = -1;
String name = null;
if (start != null) {
String oname = start.getOnlyName().length() > 0 ? start.getOnlyName()
: (mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude()));
startPos = fromActions.size();
fromActions.add(new RouteSpinnerRow(SPINNER_START_ID, R.drawable.ic_action_get_my_location, oname));
name = start.getOnlyName().length() > 0 ? start.getOnlyName() :
(mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude()));
final LatLon latLon = start.point;
final PointDescription pointDescription = start.getOriginalPointDescription();
@ -1374,35 +1255,21 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
}
addMarkersToSpinner(fromActions);
final Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner));
RouteSpinnerArrayAdapter fromAdapter = new RouteSpinnerArrayAdapter(view.getContext());
for (RouteSpinnerRow row : fromActions) {
fromAdapter.add(row);
}
fromSpinner.setAdapter(fromAdapter);
final TextView fromText = ((TextView) view.findViewById(R.id.fromText));
if (start != null) {
fromSpinner.setSelection(startPos);
fromText.setText(name);
} else {
if (mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() == null) {
fromSpinner.setPromptId(R.string.search_poi_location);
}
//fromSpinner.setSelection(0);
fromText.setText(R.string.shared_string_my_location);
}
return fromSpinner;
}
private Spinner setupToSpinner(View view) {
final Spinner toSpinner = ((Spinner) view.findViewById(R.id.ToSpinner));
private void setupToText(View view) {
final TextView toText = ((TextView) view.findViewById(R.id.toText));
final TargetPointsHelper targets = getTargets();
List<RouteSpinnerRow> toActions = new ArrayList<>();
TargetPoint finish = getTargets().getPointToNavigate();
if (finish != null) {
toActions.add(new RouteSpinnerRow(SPINNER_FINISH_ID, R.drawable.ic_action_get_my_location,
getRoutePointDescription(targets.getPointToNavigate().point,
targets.getPointToNavigate().getOnlyName())));
toText.setText(getRoutePointDescription(targets.getPointToNavigate().point,
targets.getPointToNavigate().getOnlyName()));
final LatLon latLon = finish.point;
final PointDescription pointDescription = finish.getOriginalPointDescription();
@ -1420,25 +1287,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
} else {
toSpinner.setPromptId(R.string.route_descr_select_destination);
toActions.add(new RouteSpinnerRow(SPINNER_HINT_ID, R.drawable.ic_action_get_my_location,
mapActivity.getString(R.string.route_descr_select_destination)));
toText.setText(R.string.route_descr_select_destination);
}
toActions.add(new RouteSpinnerRow(SPINNER_FAV_ID, R.drawable.ic_action_fav_dark,
mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)));
toActions.add(new RouteSpinnerRow(SPINNER_MAP_ID, R.drawable.ic_action_marker_dark,
mapActivity.getString(R.string.shared_string_select_on_map)));
toActions.add(new RouteSpinnerRow(SPINNER_ADDRESS_ID, R.drawable.ic_action_home_dark,
mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)));
addMarkersToSpinner(toActions);
RouteSpinnerArrayAdapter toAdapter = new RouteSpinnerArrayAdapter(view.getContext());
for (RouteSpinnerRow row : toActions) {
toAdapter.add(row);
}
toSpinner.setAdapter(toAdapter);
return toSpinner;
}
public RoutePopupListArrayAdapter getIntermediatesPopupAdapter(Context ctx) {

View file

@ -142,13 +142,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
bottomScrollView.setScrollingEnabled(false);
bottomScrollView.setBackgroundColor(getResources().getColor(nightMode ? R.color.activity_background_dark : R.color.activity_background_light));
FrameLayout bottomContainer = (FrameLayout) view.findViewById(R.id.bottom_container);
if (!menu.isRouteCalculated()) {
bottomContainer.setForeground(getContentIcon(R.drawable.bg_contextmenu_shadow));
} else {
bottomContainer.setForeground(null);
}
cardsContainer = (LinearLayout) view.findViewById(R.id.route_menu_cards_container);
buildBottomView();
@ -182,8 +175,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
private boolean slidingUp;
private boolean slidingDown;
private boolean hasMoved;
{
scroller = new OverScroller(getMapActivity());
final ViewConfiguration configuration = ViewConfiguration.get(getMapActivity());
@ -205,7 +196,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
hasMoved = false;
mDownY = event.getRawY();
dy = event.getY();
dyMain = getViewY();
@ -219,7 +209,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
moving = true;
}
if (moving) {
hasMoved = true;
float y = event.getY();
float newY = getViewY() + (y - dy);
if (!portrait && newY > topScreenPosY) {
@ -248,7 +237,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
case MotionEvent.ACTION_UP:
if (moving) {
moving = false;
hasMoved = false;
int currentY = getViewY();
final VelocityTracker velocityTracker = this.velocityTracker;
@ -278,7 +266,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
break;
case MotionEvent.ACTION_CANCEL:
moving = false;
hasMoved = false;
recycleVelocityTracker();
break;
@ -949,13 +936,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
ctx.setupRouteCalculationProgressBar((ProgressBar) mainView.findViewById(R.id.progress_bar));
setupRouteCalculationButtonProgressBar((ProgressBar) view.findViewById(R.id.progress_bar_button));
FrameLayout bottomContainer = (FrameLayout) view.findViewById(R.id.bottom_container);
if (!menu.isRouteCalculated()) {
bottomContainer.setForeground(getContentIcon(R.drawable.bg_contextmenu_shadow));
} else {
bottomContainer.setForeground(null);
}
updateControlButtons();
}

View file

@ -17,7 +17,6 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon;
@ -31,12 +30,12 @@ import net.osmand.plus.OsmandSettings.RulerMode;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.actions.StartGPSStatus;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.routepreparationmenu.WaypointsFragment;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
@ -1004,7 +1003,7 @@ public class MapInfoWidgetsFactory {
all.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS, AndroidUtils.getCenterViewCoordinates(view));
WaypointsFragment.showInstance(map);
}
});
remove.setOnClickListener(new OnClickListener() {