Fix tracker compilation

This commit is contained in:
Vitaliy 2020-12-02 13:04:17 +02:00
parent 10e8ffdfa2
commit ba569bb809
6 changed files with 62 additions and 54 deletions

View file

@ -699,18 +699,20 @@ class TelegramSettings(private val app: TelegramApplication) {
val hiddenChats = mutableSetOf<Long>() val hiddenChats = mutableSetOf<Long>()
val hiddenChatsSet = prefs.getStringSet(HIDDEN_ON_MAP_CHATS_KEY, mutableSetOf()) val hiddenChatsSet = prefs.getStringSet(HIDDEN_ON_MAP_CHATS_KEY, mutableSetOf())
for (chatId in hiddenChatsSet) { hiddenChatsSet?.let {
hiddenChats.add(chatId.toLong()) for (chatId in it) {
hiddenChats.add(chatId.toLong())
}
} }
hiddenOnMapChats = hiddenChats hiddenOnMapChats = hiddenChats
metricsConstants = MetricsConstants.valueOf( metricsConstants = MetricsConstants.valueOf(
prefs.getString(METRICS_CONSTANTS_KEY, MetricsConstants.KILOMETERS_AND_METERS.name) prefs.getString(METRICS_CONSTANTS_KEY, MetricsConstants.KILOMETERS_AND_METERS.name)!!
) )
speedConstants = SpeedConstants.valueOf( speedConstants = SpeedConstants.valueOf(
prefs.getString(SPEED_CONSTANTS_KEY, SpeedConstants.KILOMETERS_PER_HOUR.name) prefs.getString(SPEED_CONSTANTS_KEY, SpeedConstants.KILOMETERS_PER_HOUR.name)!!
) )
utcOffset = prefs.getString(UTC_OFFSET_CONSTANTS_KEY, DataConstants.UTC_FORMAT) utcOffset = prefs.getString(UTC_OFFSET_CONSTANTS_KEY, DataConstants.UTC_FORMAT)!!
try { try {
parseShareChatsInfo(JSONArray(prefs.getString(SHARE_CHATS_INFO_KEY, ""))) parseShareChatsInfo(JSONArray(prefs.getString(SHARE_CHATS_INFO_KEY, "")))
@ -724,7 +726,7 @@ class TelegramSettings(private val app: TelegramApplication) {
log.error(e) log.error(e)
} }
parseShareDevices(prefs.getString(SHARE_DEVICES_KEY, "")) parseShareDevices(prefs.getString(SHARE_DEVICES_KEY, "")!!)
val sendMyLocDef = SEND_MY_LOC_VALUES_SEC[SEND_MY_LOC_DEFAULT_INDEX] val sendMyLocDef = SEND_MY_LOC_VALUES_SEC[SEND_MY_LOC_DEFAULT_INDEX]
sendMyLocInterval = prefs.getLong(SEND_MY_LOC_INTERVAL_KEY, sendMyLocDef) sendMyLocInterval = prefs.getLong(SEND_MY_LOC_INTERVAL_KEY, sendMyLocDef)
@ -733,7 +735,7 @@ class TelegramSettings(private val app: TelegramApplication) {
val locHistoryDef = LOC_HISTORY_VALUES_SEC[LOC_HISTORY_DEFAULT_INDEX] val locHistoryDef = LOC_HISTORY_VALUES_SEC[LOC_HISTORY_DEFAULT_INDEX]
locHistoryTime = prefs.getLong(LOC_HISTORY_TIME_KEY, locHistoryDef) locHistoryTime = prefs.getLong(LOC_HISTORY_TIME_KEY, locHistoryDef)
val shareTypeDef = SHARE_TYPE_VALUES[SHARE_TYPE_DEFAULT_INDEX] val shareTypeDef = SHARE_TYPE_VALUES[SHARE_TYPE_DEFAULT_INDEX]
shareTypeValue = prefs.getString(SHARE_TYPE_KEY, shareTypeDef) shareTypeValue = prefs.getString(SHARE_TYPE_KEY, shareTypeDef)!!
val minLocationDistanceDef = MIN_LOCATION_DISTANCE[MIN_LOCATION_DISTANCE_INDEX] val minLocationDistanceDef = MIN_LOCATION_DISTANCE[MIN_LOCATION_DISTANCE_INDEX]
minLocationDistance = prefs.getFloat(MIN_LOCATION_DISTANCE_KEY, minLocationDistanceDef) minLocationDistance = prefs.getFloat(MIN_LOCATION_DISTANCE_KEY, minLocationDistanceDef)
@ -743,13 +745,13 @@ class TelegramSettings(private val app: TelegramApplication) {
minLocationSpeed = prefs.getFloat(MIN_LOCATION_SPEED_KEY, minLocationSpeedDef) minLocationSpeed = prefs.getFloat(MIN_LOCATION_SPEED_KEY, minLocationSpeedDef)
val currentUserId = app.telegramHelper.getCurrentUserId() val currentUserId = app.telegramHelper.getCurrentUserId()
currentSharingMode = prefs.getString(SHARING_MODE_KEY, if (currentUserId != -1) currentUserId.toString() else "") currentSharingMode = prefs.getString(SHARING_MODE_KEY, if (currentUserId != -1) currentUserId.toString() else "")!!
val defPackage = if (AppConnect.getInstalledApps(app).size == 1) AppConnect.getInstalledApps(app).first().appPackage else "" val defPackage = if (AppConnect.getInstalledApps(app).size == 1) AppConnect.getInstalledApps(app).first().appPackage else ""
appToConnectPackage = prefs.getString(APP_TO_CONNECT_PACKAGE_KEY, defPackage) appToConnectPackage = prefs.getString(APP_TO_CONNECT_PACKAGE_KEY, defPackage)!!
liveNowSortType = LiveNowSortType.valueOf( liveNowSortType = LiveNowSortType.valueOf(
prefs.getString(LIVE_NOW_SORT_TYPE_KEY, LiveNowSortType.SORT_BY_DISTANCE.name) prefs.getString(LIVE_NOW_SORT_TYPE_KEY, LiveNowSortType.SORT_BY_DISTANCE.name)!!
) )
batteryOptimisationAsked = prefs.getBoolean(BATTERY_OPTIMISATION_ASKED,false) batteryOptimisationAsked = prefs.getBoolean(BATTERY_OPTIMISATION_ASKED,false)

View file

@ -295,7 +295,7 @@ class ShowLocationHelper(private val app: TelegramApplication) {
private fun getStatusWidgetIntent(): Intent { private fun getStatusWidgetIntent(): Intent {
val startIntent = app.packageManager.getLaunchIntentForPackage(app.packageName) val startIntent = app.packageManager.getLaunchIntentForPackage(app.packageName)
startIntent.addCategory(Intent.CATEGORY_LAUNCHER) startIntent!!.addCategory(Intent.CATEGORY_LAUNCHER)
startIntent.putExtra(OPEN_MY_LOCATION_TAB_KEY,true) startIntent.putExtra(OPEN_MY_LOCATION_TAB_KEY,true)
return startIntent return startIntent
} }

View file

@ -106,18 +106,20 @@ class SetTimeBottomSheet : DialogFragment() {
} }
private fun selectStartDate() { private fun selectStartDate() {
val dateFromDialog = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth -> context?.let {
startCalendar.set(Calendar.YEAR, year) val dateFromDialog = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
startCalendar.set(Calendar.MONTH, monthOfYear) startCalendar.set(Calendar.YEAR, year)
startCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth) startCalendar.set(Calendar.MONTH, monthOfYear)
updateDateAndTimeButtons() startCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth)
} updateDateAndTimeButtons()
DatePickerDialog( }
context, dateFromDialog, DatePickerDialog(
startCalendar.get(Calendar.YEAR), it, dateFromDialog,
startCalendar.get(Calendar.MONTH), startCalendar.get(Calendar.YEAR),
startCalendar.get(Calendar.DAY_OF_MONTH) startCalendar.get(Calendar.MONTH),
).show() startCalendar.get(Calendar.DAY_OF_MONTH)
).show()
}
} }
private fun selectStartTime() { private fun selectStartTime() {
@ -132,18 +134,20 @@ class SetTimeBottomSheet : DialogFragment() {
} }
private fun selectEndDate() { private fun selectEndDate() {
val dateFromDialog = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth -> context?.let {
endCalendar.set(Calendar.YEAR, year) val dateFromDialog = DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
endCalendar.set(Calendar.MONTH, monthOfYear) endCalendar.set(Calendar.YEAR, year)
endCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth) endCalendar.set(Calendar.MONTH, monthOfYear)
updateDateAndTimeButtons() endCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth)
} updateDateAndTimeButtons()
DatePickerDialog( }
context, dateFromDialog, DatePickerDialog(
endCalendar.get(Calendar.YEAR), it, dateFromDialog,
endCalendar.get(Calendar.MONTH), endCalendar.get(Calendar.YEAR),
endCalendar.get(Calendar.DAY_OF_MONTH) endCalendar.get(Calendar.MONTH),
).show() endCalendar.get(Calendar.DAY_OF_MONTH)
).show()
}
} }
private fun selectEndTime() { private fun selectEndTime() {

View file

@ -53,7 +53,7 @@ class TimelineTabFragment : Fragment() {
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View {
mainView = inflater.inflate(R.layout.fragment_timeline_tab, container, false) mainView = inflater.inflate(R.layout.fragment_timeline_tab, container, false)
val appBarLayout = mainView.findViewById<View>(R.id.app_bar_layout) val appBarLayout = mainView.findViewById<View>(R.id.app_bar_layout)
@ -139,22 +139,24 @@ class TimelineTabFragment : Fragment() {
fun tabClosed() {} fun tabClosed() {}
private fun selectDate() { private fun selectDate() {
val dateSetListener = context?.let {
DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth -> val dateSetListener =
calendar = Calendar.getInstance() DatePickerDialog.OnDateSetListener { _, year, monthOfYear, dayOfMonth ->
calendar.set(Calendar.YEAR, year) calendar = Calendar.getInstance()
calendar.set(Calendar.MONTH, monthOfYear) calendar.set(Calendar.YEAR, year)
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth) calendar.set(Calendar.MONTH, monthOfYear)
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth)
updateList() updateList()
updateDateButton() updateDateButton()
} }
DatePickerDialog( DatePickerDialog(
context, dateSetListener, it, dateSetListener,
calendar.get(Calendar.YEAR), calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH), calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH) calendar.get(Calendar.DAY_OF_MONTH)
).show() ).show()
}
} }
private fun getStartOfDay(calendar: Calendar): Long { private fun getStartOfDay(calendar: Calendar): Long {

View file

@ -32,11 +32,11 @@ class BottomSheetDialog(ctx: Context) : Dialog(ctx, R.style.AppTheme_BottomSheet
super.setContentView(wrapInContainer(layoutResID, null, null)) super.setContentView(wrapInContainer(layoutResID, null, null))
} }
override fun setContentView(view: View?) { override fun setContentView(view: View) {
super.setContentView(wrapInContainer(0, view, null)) super.setContentView(wrapInContainer(0, view, null))
} }
override fun setContentView(view: View?, params: ViewGroup.LayoutParams?) { override fun setContentView(view: View, params: ViewGroup.LayoutParams?) {
super.setContentView(wrapInContainer(0, view, params)) super.setContentView(wrapInContainer(0, view, params))
} }

View file

@ -40,7 +40,7 @@ class TextViewEx : AppCompatTextView {
} }
val typefaceName = resolvedAttrs.getString(R.styleable.TextViewEx_typeface) val typefaceName = resolvedAttrs.getString(R.styleable.TextViewEx_typeface)
val typeface = FontCache.getFont(context, typefaceName) val typeface = FontCache.getFont(context, typefaceName!!)
if (typeface != null) { if (typeface != null) {
val style = getTypeface()?.style ?: 0 val style = getTypeface()?.style ?: 0
setTypeface(typeface, style) setTypeface(typeface, style)