Get rid of unnecessary companion objects

This commit is contained in:
Alex Sytnyk 2018-06-27 11:06:24 +03:00
parent 23220ea490
commit 7e2a2d9ea3
7 changed files with 33 additions and 49 deletions

View file

@ -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<String> = emptySet()
private var showOnMapChats: Set<String> = emptySet()

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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