From 7e2a2d9ea312979f7ffa766e7e3d34d0b2e797a7 Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Wed, 27 Jun 2018 11:06:24 +0300 Subject: [PATCH] Get rid of unnecessary companion objects --- .../net/osmand/telegram/TelegramSettings.kt | 31 +++++++++---------- .../telegram/helpers/ShareLocationHelper.kt | 6 ++-- .../telegram/helpers/ShowLocationHelper.kt | 6 ++-- .../notifications/LocationNotification.kt | 6 ++-- .../osmand/telegram/ui/LiveNowTabFragment.kt | 8 ++--- .../net/osmand/telegram/ui/MainActivity.kt | 19 +++++------- .../telegram/ui/MyLocationTabFragment.kt | 6 ++-- 7 files changed, 33 insertions(+), 49 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt index 4686d0f214..4c63eb0646 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt @@ -4,25 +4,22 @@ import android.content.Context import net.osmand.telegram.utils.OsmandFormatter.MetricsConstants import net.osmand.telegram.utils.OsmandFormatter.SpeedConstants +private const val SETTINGS_NAME = "osmand_telegram_settings" + +private const val SHARE_LOCATION_CHATS_KEY = "share_location_chats" +private const val SHOW_ON_MAP_CHATS_KEY = "show_on_map_chats" + +private const val METRICS_CONSTANTS_KEY = "metrics_constants" +private const val SPEED_CONSTANTS_KEY = "speed_constants" + +private const val SEND_MY_LOCATION_INTERVAL_KEY = "send_my_location_interval" +private const val SEND_MY_LOCATION_INTERVAL_DEFAULT = 5L * 1000 // 5 seconds + +private const val USER_LOCATION_EXPIRE_TIME_KEY = "user_location_expire_time" +private const val USER_LOCATION_EXPIRE_TIME_DEFAULT = 15L * 60 * 1000 // 15 minutes + class TelegramSettings(private val app: TelegramApplication) { - companion object { - - private const val SETTINGS_NAME = "osmand_telegram_settings" - - private const val SHARE_LOCATION_CHATS_KEY = "share_location_chats" - private const val SHOW_ON_MAP_CHATS_KEY = "show_on_map_chats" - - private const val METRICS_CONSTANTS_KEY = "metrics_constants" - private const val SPEED_CONSTANTS_KEY = "speed_constants" - - private const val SEND_MY_LOCATION_INTERVAL_KEY = "send_my_location_interval" - private const val SEND_MY_LOCATION_INTERVAL_DEFAULT = 5L * 1000 // 5 seconds - - private const val USER_LOCATION_EXPIRE_TIME_KEY = "user_location_expire_time" - private const val USER_LOCATION_EXPIRE_TIME_DEFAULT = 15L * 60 * 1000 // 15 minutes - } - private var shareLocationChats: Set = emptySet() private var showOnMapChats: Set = emptySet() diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt index 196d32bf04..adb8014dd1 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShareLocationHelper.kt @@ -4,11 +4,9 @@ import net.osmand.Location import net.osmand.telegram.TelegramApplication import net.osmand.telegram.notifications.TelegramNotification.NotificationType -class ShareLocationHelper(private val app: TelegramApplication) { +private const val MAX_LOCATION_MESSAGE_LIVE_PERIOD_SEC = 60 * 60 * 24 - 1 // day - companion object { - const val MAX_LOCATION_MESSAGE_LIVE_PERIOD_SEC = 60 * 60 * 24 - 1 // day - } +class ShareLocationHelper(private val app: TelegramApplication) { var sharingLocation: Boolean = false private set diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt index a7cf97d251..9ce01fad86 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt @@ -11,11 +11,9 @@ import net.osmand.telegram.utils.AndroidUtils import org.drinkless.td.libcore.telegram.TdApi import java.io.File -class ShowLocationHelper(private val app: TelegramApplication) { +private const val MAP_LAYER_ID = "telegram_layer" - companion object { - private const val MAP_LAYER_ID = "telegram_layer" - } +class ShowLocationHelper(private val app: TelegramApplication) { private val telegramHelper = app.telegramHelper private val osmandHelper = app.osmandHelper diff --git a/OsmAnd-telegram/src/net/osmand/telegram/notifications/LocationNotification.kt b/OsmAnd-telegram/src/net/osmand/telegram/notifications/LocationNotification.kt index a891f10a2e..1ee4fa2997 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/notifications/LocationNotification.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/notifications/LocationNotification.kt @@ -7,11 +7,9 @@ import net.osmand.telegram.TelegramApplication import net.osmand.telegram.utils.OsmandFormatter import net.osmand.util.Algorithms -class LocationNotification(app: TelegramApplication) : TelegramNotification(app, GROUP_NAME) { +private const val GROUP_NAME = "share_location" - companion object { - const val GROUP_NAME = "share_location" - } +class LocationNotification(app: TelegramApplication) : TelegramNotification(app, GROUP_NAME) { override val type: TelegramNotification.NotificationType get() = TelegramNotification.NotificationType.LOCATION diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/LiveNowTabFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/LiveNowTabFragment.kt index e6d160afeb..afe038bfa4 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/LiveNowTabFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/LiveNowTabFragment.kt @@ -19,12 +19,10 @@ import net.osmand.telegram.helpers.TelegramHelper.TelegramAuthorizationState import net.osmand.telegram.helpers.TelegramHelper.TelegramListener import org.drinkless.td.libcore.telegram.TdApi -class LiveNowTabFragment : Fragment(), TelegramListener { +private const val CHAT_VIEW_TYPE = 0 +private const val CONTACT_VIEW_TYPE = 1 - companion object { - private const val CHAT_VIEW_TYPE = 0 - private const val CONTACT_VIEW_TYPE = 1 - } +class LiveNowTabFragment : Fragment(), TelegramListener { private val app: TelegramApplication get() = activity?.application as TelegramApplication diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt index ee15e67941..2870d095d1 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt @@ -26,20 +26,17 @@ import net.osmand.telegram.utils.AndroidUtils import org.drinkless.td.libcore.telegram.TdApi import java.lang.ref.WeakReference +private const val PERMISSION_REQUEST_LOCATION = 1 + +private const val LOGIN_MENU_ID = 0 +private const val LOGOUT_MENU_ID = 1 +private const val PROGRESS_MENU_ID = 2 + +private const val MY_LOCATION_TAB_POS = 0 +private const val LIVE_NOW_TAB_POS = 1 class MainActivity : AppCompatActivity(), TelegramListener { - companion object { - private const val PERMISSION_REQUEST_LOCATION = 1 - - private const val LOGIN_MENU_ID = 0 - private const val LOGOUT_MENU_ID = 1 - private const val PROGRESS_MENU_ID = 2 - - private const val MY_LOCATION_TAB_POS = 0 - private const val LIVE_NOW_TAB_POS = 1 - } - private val log = PlatformUtil.getLog(TelegramHelper::class.java) private var telegramAuthorizationRequestHandler: TelegramAuthorizationRequestHandler? = null diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt index d608bdb1c5..3dcaa1f52e 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt @@ -20,11 +20,9 @@ import net.osmand.telegram.helpers.TelegramHelper.TelegramListener import net.osmand.telegram.ui.MyLocationTabFragment.MyLocationListAdapter.ChatViewHolder import org.drinkless.td.libcore.telegram.TdApi -class MyLocationTabFragment : Fragment(), TelegramListener { +private const val SELECTED_CHATS_KEY = "selected_chats" - companion object { - private const val SELECTED_CHATS_KEY = "selected_chats" - } +class MyLocationTabFragment : Fragment(), TelegramListener { private var textMarginSmall: Int = 0 private var textMarginBig: Int = 0