Skip to content

Commit

Permalink
Bug fixes, beta 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Nov 24, 2017
1 parent b13ee44 commit bfb30a1
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 97 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ android {
applicationId "io.github.feelfreelinux.wykopmobilny"
minSdkVersion 17
targetSdkVersion 26
versionCode 8
versionName "0.2.3"
versionCode 9
versionName "0.3.0"

def credentialsPropertiesFile = rootProject.file("credentials.properties")
def credentialsProperties = new Properties()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ class ApiSignInterceptor(val userManagerApi: UserManagerApi) : Interceptor {
val encodeUrl : String = when(request.body()) {
is FormBody -> {
val formBody = request.body() as FormBody
val paramList = (0 until formBody.size())
var paramList = (0 until formBody.size())
.filter { !formBody.value(it).isNullOrEmpty() }
.sortedWith(compareBy({ formBody.name(it) }))
.mapTo(ArrayList<String>()) { formBody.value(it) }
.reversed() // apiv2 accepts these items in reversed order, wtf
.toList()
if (customHeaders.contains(REMOVE_USERKEY_HEADER)) paramList = paramList.reversed()

APP_SECRET + url+ paramList.joinToString(",")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ class WykopSuggestionsAdapter(context: Context, private val textViewResourceId:
if (typedText.isNotEmpty()) {
if (!typedText.matches(".*([ \\t]).*".toRegex())) {
if (typedText.length >= 2) {
val suggestions = suggestApi.getUserSuggestions(typedText)
var suggestions = suggestApi.getUserSuggestions(typedText)
.blockingGet()
mData.addAll(suggestions.subList(0, 7).map { WykopSuggestion(it, null, text.substringBeforeLast("@") + "@${it.nick}") })
suggestions = if (suggestions.size > 7) suggestions.subList(0, 7) else suggestions
mData.addAll(suggestions.map { WykopSuggestion(it, null, text.substringBeforeLast("@") + "@${it.nick}") })
}
}
}
Expand All @@ -61,9 +62,10 @@ class WykopSuggestionsAdapter(context: Context, private val textViewResourceId:
if (typedText.isNotEmpty()) {
if (!typedText.matches(".*([ \\t]).*".toRegex())) {
if (typedText.length >= 2) {
val suggestions = suggestApi.getTagSuggestions(typedText)
var suggestions = suggestApi.getTagSuggestions(typedText)
.blockingGet()
mData.addAll(suggestions.subList(0, 7).map { WykopSuggestion(null, it, text.substringBeforeLast("#") + it.tag) })
suggestions = if (suggestions.size > 7) suggestions.subList(0, 7) else suggestions
mData.addAll(suggestions.map { WykopSuggestion(null, it, text.substringBeforeLast("#") + it.tag) })
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ interface NavigatorApi {
}

class Navigator : NavigatorApi {
companion object {
val STARTED_FROM_NOTIFIATIONS_CODE = 228
}

override fun openMainActivity(context: Activity, targetFragment: String?) {
context.startActivity(NavigationActivity.getIntent(context, targetFragment)
.apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.github.feelfreelinux.wykopmobilny.base.BaseActivity
import io.github.feelfreelinux.wykopmobilny.base.BaseNavigationFragment
import io.github.feelfreelinux.wykopmobilny.base.BaseNavigationView
import io.github.feelfreelinux.wykopmobilny.ui.dialogs.AppExitConfirmationDialog
import io.github.feelfreelinux.wykopmobilny.ui.modules.Navigator
import io.github.feelfreelinux.wykopmobilny.ui.modules.NavigatorApi
import io.github.feelfreelinux.wykopmobilny.ui.modules.loginscreen.LoginScreenActivity
import io.github.feelfreelinux.wykopmobilny.ui.modules.mikroblog.feed.hot.HotFragment
Expand All @@ -31,10 +32,9 @@ import io.github.feelfreelinux.wykopmobilny.ui.modules.pm.conversationslist.Conv
import io.github.feelfreelinux.wykopmobilny.ui.modules.settings.SettingsActivity
import io.github.feelfreelinux.wykopmobilny.utils.SettingsPreferencesApi
import io.github.feelfreelinux.wykopmobilny.utils.isVisible
import io.github.feelfreelinux.wykopmobilny.utils.printout
import kotlinx.android.synthetic.main.activity_navigation.*
import kotlinx.android.synthetic.main.activity_navigation.view.*
import kotlinx.android.synthetic.main.drawer_header_view_layout.view.*
import kotlinx.android.synthetic.main.navigation_header.*
import kotlinx.android.synthetic.main.navigation_header.view.*
import kotlinx.android.synthetic.main.toolbar.*
import javax.inject.Inject
Expand Down Expand Up @@ -112,6 +112,7 @@ class NavigationActivity : BaseActivity(), MainNavigationView, NavigationView.On
// Schedules notification service
WykopNotificationsJob.schedule(settingsApi)
}
navHeader.view_container.startListeningForUpdates()

toolbar.tag = toolbar.overflowIcon // We want to save original overflow icon drawable into memory.
setupNavigation()
Expand Down Expand Up @@ -144,12 +145,15 @@ class NavigationActivity : BaseActivity(), MainNavigationView, NavigationView.On
override fun onResume() {
super.onResume()
presenter.subscribe(this)
navHeader.view_container.startListeningForUpdates()
}

override fun onPause() {
super.onPause()
presenter.unsubscribe()
}

override fun onDestroy() {
super.onDestroy()
navHeader.view_container.stopListeningForUpdates()
}

Expand All @@ -165,6 +169,7 @@ class NavigationActivity : BaseActivity(), MainNavigationView, NavigationView.On
findItem(R.id.login).isVisible = !value
findItem(R.id.logout).isVisible = value
}
navHeader.view_container.isVisible = value
navHeader.view_container.apply {
nav_notifications_tag.setOnClickListener {
openFragment(HashTagsNotificationsListFragment.newInstance())
Expand Down Expand Up @@ -228,9 +233,13 @@ class NavigationActivity : BaseActivity(), MainNavigationView, NavigationView.On
}
}

Navigator.STARTED_FROM_NOTIFIATIONS_CODE -> {
view_container.startListeningForUpdates()
}

else -> {
if (resultCode == SettingsActivity.THEME_CHANGED_RESULT) {
// restartActivity()
restartActivity()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class EntryActivity : BaseActivity(), EntryDetailView, InputToolbarListener, Swi

// Prepare InputToolbar
inputToolbar.inputToolbarListener = this
inputToolbar.setFloatingImageView(floatingImageView)

swiperefresh.setOnRefreshListener(this)
entryFragmentData = supportFragmentManager.getDataFragmentInstance(EXTRA_FRAGMENT_KEY + entryId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ class TagActivity : BaseActivity() {
supportFragmentManager.beginTransaction().replace(R.id.contentView,
TagEntriesFragment.newInstance(entryTag)).commit()
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) finish()
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class WykopNotificationsJob : Job(), WykopNotificationsJobView {
val intent = wykopLinkHandler.getLinkIntent(context, notification.url!!)

val pendingIntent = if (intent != null) {
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
intent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
PendingIntent.getActivity(context, 0, intent, 0)

} else {
Expand All @@ -79,7 +79,7 @@ class WykopNotificationsJob : Job(), WykopNotificationsJobView {
override fun showNotificationsCount(count: Int) {
// Create intent
val intent = NavigationActivity.getIntent(context, NavigationActivity.TARGET_NOTIFICATIONS)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
intent.flags = (Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)

// Show Notification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class BaseNotificationsListFragment : BaseFragment(), NotificationsList
notification.new = false
notificationAdapter.notifyDataSetChanged()
notification.url?.let {
linkHandler.handleUrl(activity, notification.url)
linkHandler.handleUrl(activity, notification.url, true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import io.github.feelfreelinux.wykopmobilny.ui.modules.input.BaseInputActivity
import io.github.feelfreelinux.wykopmobilny.ui.widgets.InputToolbarListener
import io.github.feelfreelinux.wykopmobilny.utils.isVisible
import io.github.feelfreelinux.wykopmobilny.utils.prepare
import io.github.feelfreelinux.wykopmobilny.utils.printout
import io.github.feelfreelinux.wykopmobilny.utils.toPrettyDate
import kotlinx.android.synthetic.main.activity_conversation.*
import kotlinx.android.synthetic.main.activity_conversation.view.*
Expand Down Expand Up @@ -53,7 +54,6 @@ class ConversationActivity : BaseActivity(), ConversationView, InputToolbarListe
supportActionBar?.title = "Rozmowa z $user"
swiperefresh.setOnRefreshListener { presenter.loadConversation() }
inputToolbar.setCustomHint(getString(R.string.reply))
inputToolbar.setFloatingImageView(floatingImageView)

presenter.subscribe(this)
presenter.user = user
Expand All @@ -79,6 +79,7 @@ class ConversationActivity : BaseActivity(), ConversationView, InputToolbarListe
loadingView.isVisible = false
swiperefresh.isRefreshing = false
receiver = conversation.receiver
printout("HMM?")
toolbar.apply {
subtitle = conversation.messages.last().date.toPrettyDate()
avatarview.setAuthor(conversation.receiver)
Expand All @@ -94,6 +95,16 @@ class ConversationActivity : BaseActivity(), ConversationView, InputToolbarListe
recyclerView.invalidate()
}

override fun onResume() {
super.onResume()
presenter.subscribe(this)
}

override fun onDestroy() {
super.onDestroy()
presenter.unsubscribe()
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> onBackPressed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ class InputToolbar : ConstraintLayout, MarkdownToolbarListener {

var inputToolbarListener : InputToolbarListener? = null

fun setFloatingImageView(floatingImageView: FloatingImageView) {
markdownToolbar.floatingImageView = floatingImageView
}


init {
WykopApp.uiInjector.inject(this)
val typedValue = TypedValue()
Expand All @@ -73,6 +68,7 @@ class InputToolbar : ConstraintLayout, MarkdownToolbarListener {
View.inflate(context, R.layout.input_toolbar, this)

markdownToolbar.markdownListener = this
markdownToolbar.floatingImageView = floatingImageView

// Setup listeners
show_markdown_menu.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.github.feelfreelinux.wykopmobilny.ui.widgets.drawerheaderview
import io.github.feelfreelinux.wykopmobilny.api.notifications.NotificationsApi
import io.github.feelfreelinux.wykopmobilny.base.BasePresenter
import io.github.feelfreelinux.wykopmobilny.models.pojo.apiv2.models.NotificationsCountResponse
import io.github.feelfreelinux.wykopmobilny.utils.printout
import io.github.feelfreelinux.wykopmobilny.utils.rx.SubscriptionHelperApi
import io.reactivex.Observable
import io.reactivex.Single
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@ class DrawerHeaderWidget : ConstraintLayout, DrawerHeaderView {
}
}

override fun onDetachedFromWindow() {
presenter.unsubscribe()
super.onDetachedFromWindow()
}

override fun onAttachedToWindow() {
super.onAttachedToWindow()
presenter.subscribe(this)
checkIsUserLoggedIn()
}

override val isConnectedToInternet : Boolean
get() = context.isConnectedToInternet()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.github.feelfreelinux.wykopmobilny.utils.wykop_link_handler
import android.app.Activity
import android.content.Context
import android.content.Intent
import io.github.feelfreelinux.wykopmobilny.ui.modules.Navigator
import io.github.feelfreelinux.wykopmobilny.ui.modules.NavigatorApi
import io.github.feelfreelinux.wykopmobilny.ui.modules.mikroblog.entry.EntryActivity
import io.github.feelfreelinux.wykopmobilny.ui.modules.mikroblog.feed.tag.TagActivity
Expand All @@ -13,7 +14,7 @@ import io.github.feelfreelinux.wykopmobilny.utils.wykop_link_handler.linkparser.
import io.github.feelfreelinux.wykopmobilny.utils.wykop_link_handler.linkparser.TagLinkParser

interface WykopLinkHandlerApi {
fun handleUrl(context: Activity, url: String)
fun handleUrl(context: Activity, url: String, refreshNotifications : Boolean = false)
fun getLinkIntent(context: Context, url: String): Intent?
}

Expand All @@ -27,11 +28,11 @@ class WykopLinkHandler(private val navigatorApi: NavigatorApi) : WykopLinkHandle
const val DELIMITER = "/"
}

override fun handleUrl(context: Activity, url: String) {
override fun handleUrl(context: Activity, url: String, refreshNotifications: Boolean) {
when (url.first()) {
PROFILE_PREFIX -> handleProfile(url)
TAG_PREFIX -> handleTag(context, url)
else -> handleLink(context, url)
else -> handleLink(context, url, refreshNotifications)
}
}

Expand All @@ -43,10 +44,11 @@ class WykopLinkHandler(private val navigatorApi: NavigatorApi) : WykopLinkHandle
navigatorApi.openTagActivity(context, tag.removePrefix(TAG_PREFIX.toString()))
}

private fun handleLink(context: Activity, url: String) {
private fun handleLink(context: Activity, url: String, refreshNotifications : Boolean) {
val intent = getLinkIntent(context, url)
if (intent != null) {
context.startActivity(intent)
if (refreshNotifications) context.startActivityForResult(intent, Navigator.STARTED_FROM_NOTIFIATIONS_CODE)
else context.startActivity(intent)
} else {
context.openBrowser(url)
}
Expand Down
10 changes: 1 addition & 9 deletions app/src/main/res/layout/activity_conversation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/floatingImageView"/>

<io.github.feelfreelinux.wykopmobilny.ui.widgets.FloatingImageView
android:id="@+id/floatingImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
app:layout_constraintBottom_toTopOf="parent"/>

</android.support.constraint.ConstraintLayout>
9 changes: 0 additions & 9 deletions app/src/main/res/layout/activity_entry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@
android:clipToPadding="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/floatingImageView"/>

<io.github.feelfreelinux.wykopmobilny.ui.widgets.FloatingImageView
android:id="@+id/floatingImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>

</android.support.constraint.ConstraintLayout>

0 comments on commit bfb30a1

Please sign in to comment.