Commit e7f17783 authored by Lucio Maciel's avatar Lucio Maciel

More fixes for 2.5.0 release

parent 7332dc06
...@@ -14,20 +14,18 @@ import kotlinx.android.synthetic.main.message_bottomsheet.* ...@@ -14,20 +14,18 @@ import kotlinx.android.synthetic.main.message_bottomsheet.*
class MessageActionsBottomSheet : BottomSheetDialogFragment() { class MessageActionsBottomSheet : BottomSheetDialogFragment() {
private lateinit var adapter: MessageActionAdapter private val adapter = MessageActionAdapter()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return inflater.inflate(R.layout.message_bottomsheet, container, false) return inflater.inflate(R.layout.message_bottomsheet, container, false)
} }
fun addItems(items: List<MenuItem>, itemClickListener: MenuItem.OnMenuItemClickListener) { fun addItems(items: List<MenuItem>, itemClickListener: MenuItem.OnMenuItemClickListener) {
adapter = MessageActionAdapter()
adapter.addItems(items, ActionItemClickListener(dismissAction = { dismiss() }, adapter.addItems(items, ActionItemClickListener(dismissAction = { dismiss() },
itemClickListener = itemClickListener)) itemClickListener = itemClickListener))
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
bottomsheet_recycler_view.layoutManager = LinearLayoutManager(context) bottomsheet_recycler_view.layoutManager = LinearLayoutManager(context)
bottomsheet_recycler_view.adapter = adapter bottomsheet_recycler_view.adapter = adapter
} }
...@@ -58,6 +56,7 @@ class MessageActionsBottomSheet : BottomSheetDialogFragment() { ...@@ -58,6 +56,7 @@ class MessageActionsBottomSheet : BottomSheetDialogFragment() {
this.itemClickListener = itemClickListener this.itemClickListener = itemClickListener
menuItems.clear() menuItems.clear()
menuItems.addAll(items) menuItems.addAll(items)
notifyDataSetChanged()
} }
} }
......
...@@ -249,7 +249,7 @@ class DatabaseManager(val context: Application, ...@@ -249,7 +249,7 @@ class DatabaseManager(val context: Application,
id = roomId, id = roomId,
subscriptionId = id, subscriptionId = id,
type = type.toString(), type = type.toString(),
name = name, name = name ?: throw NullPointerException(), // this should be filtered on the SDK
fullname = fullName ?: chatRoom.fullname, fullname = fullName ?: chatRoom.fullname,
userId = userId ?: chatRoom.userId, userId = userId ?: chatRoom.userId,
readonly = readonly ?: chatRoom.readonly, readonly = readonly ?: chatRoom.readonly,
...@@ -330,7 +330,7 @@ class DatabaseManager(val context: Application, ...@@ -330,7 +330,7 @@ class DatabaseManager(val context: Application,
id = room.id, id = room.id,
subscriptionId = subscription.id, subscriptionId = subscription.id,
type = room.type.toString(), type = room.type.toString(),
name = room.name ?: subscription.name, name = room.name ?: subscription.name ?: throw NullPointerException(),// this should be filtered on the SDK
fullname = subscription.fullName ?: room.fullName, fullname = subscription.fullName ?: room.fullName,
userId = userId, userId = userId,
ownerId = room.user?.id, ownerId = room.user?.id,
...@@ -436,6 +436,7 @@ private fun String.databaseName(): String { ...@@ -436,6 +436,7 @@ private fun String.databaseName(): String {
val tmp = this.removePrefix("https://") val tmp = this.removePrefix("https://")
.removePrefix("http://") .removePrefix("http://")
.removeTrailingSlash() .removeTrailingSlash()
.replace("/","-")
.replace(".", "_") .replace(".", "_")
return "$tmp.db" return "$tmp.db"
......
...@@ -152,7 +152,7 @@ class MainPresenter @Inject constructor( ...@@ -152,7 +152,7 @@ class MainPresenter @Inject constructor(
} }
fun connect() { fun connect() {
launch { refreshSettingsInteractor.refresh(currentServer) } refreshSettingsInteractor.refreshAsync(currentServer)
manager.connect() manager.connect()
} }
......
...@@ -169,7 +169,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, ...@@ -169,7 +169,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
} }
headerLayout.image_avatar.setOnClickListener { headerLayout.image_avatar.setOnClickListener {
view_navigation.menu.findItem(R.id.action_update_profile).isChecked = true view_navigation.menu.findItem(R.id.action_profile).isChecked = true
presenter.toUserProfile() presenter.toUserProfile()
drawer_layout.closeDrawer(Gravity.START) drawer_layout.closeDrawer(Gravity.START)
} }
...@@ -218,19 +218,20 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, ...@@ -218,19 +218,20 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
private fun setupToolbar() { private fun setupToolbar() {
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp)
toolbar.setNavigationOnClickListener {
openDrawer()
}
} }
private fun setupNavigationView() { fun setupNavigationView() {
view_navigation.setNavigationItemSelectedListener { menuItem -> view_navigation.setNavigationItemSelectedListener { menuItem ->
menuItem.isChecked = true menuItem.isChecked = true
closeDrawer() closeDrawer()
onNavDrawerItemSelected(menuItem) onNavDrawerItemSelected(menuItem)
true true
} }
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp)
toolbar.setNavigationOnClickListener {
openDrawer()
}
} }
private fun onNavDrawerItemSelected(menuItem: MenuItem) { private fun onNavDrawerItemSelected(menuItem: MenuItem) {
......
...@@ -5,7 +5,9 @@ import chat.rocket.android.util.retryIO ...@@ -5,7 +5,9 @@ import chat.rocket.android.util.retryIO
import chat.rocket.core.internal.rest.settings import chat.rocket.core.internal.rest.settings
import kotlinx.coroutines.experimental.CommonPool import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.async import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.withContext import kotlinx.coroutines.experimental.withContext
import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
class RefreshSettingsInteractor @Inject constructor( class RefreshSettingsInteractor @Inject constructor(
...@@ -30,7 +32,8 @@ class RefreshSettingsInteractor @Inject constructor( ...@@ -30,7 +32,8 @@ class RefreshSettingsInteractor @Inject constructor(
suspend fun refresh(server: String) { suspend fun refresh(server: String) {
withContext(CommonPool) { withContext(CommonPool) {
factory.create(server).let { client -> factory.create(server).let { client ->
val settings = retryIO(description = "settings", times = 5) { val settings = retryIO(description = "settings", times = 5,
maxDelay = 5000, initialDelay = 300) {
client.settings(*settingsFilter) client.settings(*settingsFilter)
} }
repository.save(server, settings) repository.save(server, settings)
...@@ -39,11 +42,11 @@ class RefreshSettingsInteractor @Inject constructor( ...@@ -39,11 +42,11 @@ class RefreshSettingsInteractor @Inject constructor(
} }
fun refreshAsync(server: String) { fun refreshAsync(server: String) {
async { launch(CommonPool) {
try { try {
refresh(server) refresh(server)
} catch (ex: Exception) { } catch (ex: Exception) {
ex.printStackTrace() Timber.e(ex, "Error refreshing settings for: $server")
} }
} }
} }
......
...@@ -10,6 +10,7 @@ import android.view.ViewGroup ...@@ -10,6 +10,7 @@ import android.view.ViewGroup
import android.widget.AdapterView import android.widget.AdapterView
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.about.ui.AboutFragment import chat.rocket.android.about.ui.AboutFragment
import chat.rocket.android.main.ui.MainActivity
import chat.rocket.android.settings.password.ui.PasswordActivity import chat.rocket.android.settings.password.ui.PasswordActivity
import chat.rocket.android.settings.presentation.SettingsView import chat.rocket.android.settings.presentation.SettingsView
import chat.rocket.android.util.extensions.addFragmentBackStack import chat.rocket.android.util.extensions.addFragmentBackStack
...@@ -34,6 +35,14 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen ...@@ -34,6 +35,14 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
setupListView() setupListView()
} }
override fun onResume() {
// FIXME - gambiarra ahead. will fix when moving to new androidx Navigation
(activity as? MainActivity)?.let {
it.setupNavigationView()
}
super.onResume()
}
override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { override fun onItemClick(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
when (parent?.getItemAtPosition(position).toString()) { when (parent?.getItemAtPosition(position).toString()) {
resources.getString(R.string.title_password) -> { resources.getString(R.string.title_password) -> {
......
...@@ -6,11 +6,11 @@ import chat.rocket.common.model.Token ...@@ -6,11 +6,11 @@ import chat.rocket.common.model.Token
import timber.log.Timber import timber.log.Timber
fun String.removeTrailingSlash(): String { fun String.removeTrailingSlash(): String {
return if (isNotEmpty() && this[length - 1] == '/') { var removed = this
this.substring(0, length - 1) while (removed.isNotEmpty() && removed[removed.length - 1] == '/') {
} else { removed = removed.substring(0, removed.length - 1)
this
} }
return removed
} }
fun String.sanitize(): String { fun String.sanitize(): String {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment