diff --git a/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml b/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml index 3585975ea1..a02db4164b 100644 --- a/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml +++ b/OsmAnd-telegram/res/layout/fragement_settings_dialog.xml @@ -2,6 +2,7 @@ + android:orientation="vertical" + android:paddingBottom="@dimen/list_view_bottom_padding"> @@ -99,6 +101,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd-telegram/res/layout/item_with_desc_and_right_value.xml b/OsmAnd-telegram/res/layout/item_with_desc_and_right_value.xml index 9c8b5df48e..7262dc7b93 100644 --- a/OsmAnd-telegram/res/layout/item_with_desc_and_right_value.xml +++ b/OsmAnd-telegram/res/layout/item_with_desc_and_right_value.xml @@ -5,7 +5,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="@dimen/list_item_bottom_margin" android:background="?attr/selectableItemBackground" android:paddingLeft="@dimen/content_padding_standard" android:paddingRight="@dimen/content_padding_standard" @@ -17,6 +16,7 @@ android:layout_height="wrap_content" android:layout_marginEnd="@dimen/content_padding_big" android:layout_marginRight="@dimen/content_padding_big" + android:layout_marginTop="@dimen/image_button_padding" tools:src="@drawable/ic_action_live_now" tools:tint="@color/icon_light"/> @@ -33,16 +33,20 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="?android:textColorPrimary" - android:textSize="@dimen/title_text_size" + android:textSize="@dimen/list_item_title_text_size" + app:firstBaselineToTopHeight="25sp" app:typeface="@string/font_roboto_regular" tools:text="Some title"/> - diff --git a/OsmAnd-telegram/res/layout/item_with_rb_and_btn.xml b/OsmAnd-telegram/res/layout/item_with_rb_and_btn.xml index c8e9d78ce8..8ee2876883 100644 --- a/OsmAnd-telegram/res/layout/item_with_rb_and_btn.xml +++ b/OsmAnd-telegram/res/layout/item_with_rb_and_btn.xml @@ -4,7 +4,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="@dimen/list_item_height" android:layout_marginBottom="@dimen/list_item_bottom_margin" android:background="?attr/selectableItemBackground" android:gravity="center_vertical" @@ -29,14 +29,18 @@ android:layout_marginRight="@dimen/content_padding_standard" android:layout_weight="1" android:textColor="?android:textColorPrimary" - android:textSize="@dimen/title_text_size" + android:textSize="@dimen/list_item_title_text_size" app:typeface="@string/font_roboto_regular" tools:text="Some title"/> + android:layout_height="wrap_content" + android:background="@null" + android:clickable="false" + android:focusable="false" + android:saveEnabled="false"/> + How to disconnect OsmAnd Location Sharing from Telegram + Connected account + Account OsmAnd connect Hide contacts that are not updated their location after the specified period of time. Location history diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt index d46b89d99a..e2b63b19a4 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt @@ -11,13 +11,12 @@ import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.ArrayAdapter -import android.widget.ImageView -import android.widget.TextView -import android.widget.Toast +import android.widget.* import net.osmand.telegram.R import net.osmand.telegram.TelegramApplication import net.osmand.telegram.helpers.OsmandAidlHelper +import net.osmand.telegram.helpers.TelegramHelper +import net.osmand.telegram.helpers.TelegramUiHelper import net.osmand.telegram.utils.AndroidUtils import net.osmand.telegram.utils.OsmandFormatter @@ -66,13 +65,62 @@ class SettingsDialogFragment : DialogFragment() { container = mainView.findViewById(R.id.osmand_connect_container) for (appConn in AppConnect.values()) { + val pack = appConn.appPackage + val installed = AndroidUtils.isAppInstalled(context!!, pack) inflater.inflate(R.layout.item_with_rb_and_btn, container, false).apply { - findViewById(R.id.icon).setImageDrawable(uiUtils.getThemedIcon(appConn.iconId)) + findViewById(R.id.icon).setImageDrawable(uiUtils.getIcon(appConn.iconId)) findViewById(R.id.title).text = appConn.title - // FIXME + if (installed) { + findViewById(R.id.primary_btn).visibility = View.GONE + findViewById(R.id.radio_button).visibility = View.VISIBLE + setOnClickListener { + // FIXME + updateSelectedAppConn() + } + } else { + findViewById(R.id.radio_button).visibility = View.GONE + findViewById(R.id.primary_btn).apply { + setText(R.string.shared_string_install) + setOnClickListener { + context?.also { ctx -> + startActivity(AndroidUtils.getPlayMarketIntent(ctx, pack)) + } + } + } + setOnClickListener(null) + isClickable = false + } + tag = pack container.addView(this) } } + updateSelectedAppConn() + + val user = telegramHelper.getCurrentUser() + if (user != null) { + TelegramUiHelper.setupPhoto( + app, + mainView.findViewById(R.id.user_icon), + telegramHelper.getUserPhotoPath(user), + R.drawable.img_user_picture, + false + ) + mainView.findViewById(R.id.username).text = TelegramUiHelper.getUserName(user) + } else { + mainView.findViewById(R.id.user_row).visibility = View.GONE + } + + mainView.findViewById(R.id.logout_btn).setOnClickListener { + logoutTelegram() + dismiss() + } + + mainView.findViewById(R.id.help_icon) + .setImageDrawable(uiUtils.getActiveIcon(R.drawable.ic_action_share_location)) + mainView.findViewById(R.id.help_row).setOnClickListener { + // FIXME + Toast.makeText(context, "Logout help", Toast.LENGTH_SHORT).show() + } return mainView } @@ -95,6 +143,24 @@ class SettingsDialogFragment : DialogFragment() { } } + private fun updateSelectedAppConn() { + view?.findViewById(R.id.osmand_connect_container)?.apply { + for (i in 0..childCount) { + getChildAt(i).apply { + // FIXME + } + } + } + } + + private fun logoutTelegram(silent: Boolean = false) { + if (telegramHelper.getTelegramAuthorizationState() == TelegramHelper.TelegramAuthorizationState.READY) { + telegramHelper.logout() + } else if (!silent) { + Toast.makeText(context, R.string.not_logged_in, Toast.LENGTH_SHORT).show() + } + } + // FIXME private inner class SendMyLocPref : DurationPref( R.drawable.ic_action_share_location, @@ -163,12 +229,12 @@ class SettingsDialogFragment : DialogFragment() { val appPackage: String ) { OSMAND_PLUS( - R.drawable.ic_action_osmand_plus, + R.drawable.ic_logo_osmand_plus, "OsmAnd+", OsmandAidlHelper.OSMAND_PLUS_PACKAGE_NAME ), OSMAND_FREE( - R.drawable.ic_action_osmand_free, + R.drawable.ic_logo_osmand_free, "OsmAnd", OsmandAidlHelper.OSMAND_FREE_PACKAGE_NAME )