Skip to content

Commit

Permalink
Fixed bug with xiaomi phones
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Nov 26, 2017
1 parent 2c1c3c8 commit 9444086
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 37 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 11
versionName "0.3.1.1"
versionCode 12
versionName "0.3.2"

def credentialsPropertiesFile = rootProject.file("credentials.properties")
def credentialsProperties = new Properties()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import io.github.feelfreelinux.wykopmobilny.ui.dialogs.ExitConfirmationDialog
import io.github.feelfreelinux.wykopmobilny.ui.widgets.markdown_toolbar.MarkdownToolbarListener
import io.github.feelfreelinux.wykopmobilny.ui.modules.notifications.WykopNotificationManagerApi
import io.github.feelfreelinux.wykopmobilny.utils.isVisible
import io.github.feelfreelinux.wykopmobilny.utils.printout
import io.github.feelfreelinux.wykopmobilny.utils.textview.removeHtml
import kotlinx.android.synthetic.main.activity_write_comment.*
import kotlinx.android.synthetic.main.toolbar.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import android.text.TextWatcher
import android.util.TypedValue
import io.github.feelfreelinux.wykopmobilny.api.suggest.SuggestApi
import io.github.feelfreelinux.wykopmobilny.ui.adapters.WykopSuggestionsAdapter
import io.github.feelfreelinux.wykopmobilny.utils.printout


interface InputToolbarListener {
Expand Down Expand Up @@ -88,7 +89,6 @@ class InputToolbar : ConstraintLayout, MarkdownToolbarListener {

body.setAdapter(WykopSuggestionsAdapter(context, R.layout.autosuggest_item, suggestApi))


send.setOnClickListener {
showProgress(true)
val typedInputStream = markdownToolbar.getPhotoTypedInputStream()
Expand Down Expand Up @@ -152,31 +152,4 @@ class InputToolbar : ConstraintLayout, MarkdownToolbarListener {
// Only show if user's logged in
isVisible = userManager.isUserAuthorized()
}

class WykopTextWatcher(val userAction : (String) -> Unit, val tagAction : (String) -> Unit, val notDefined : () -> Unit) : TextWatcher {
override fun afterTextChanged(s: Editable?) {}

override fun beforeTextChanged(s: CharSequence?, p1: Int, p2: Int, p3: Int) {}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
val text = s.toString()
if (text.contains('@')) {
val typedText = text.substringAfterLast('@')
if (typedText.isNotEmpty()) {
if (!typedText.matches(".*([ \\t]).*".toRegex())) {
userAction.invoke(typedText)
} else notDefined()
} else notDefined()
} else notDefined()
if (text.contains('#')) {
val typedText = text.substringAfterLast('#')
if (typedText.isNotEmpty()) {
if (!typedText.matches(".*([ \\t]).*".toRegex())) {
tagAction.invoke(typedText)
}
}
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import io.github.feelfreelinux.wykopmobilny.R
import io.github.feelfreelinux.wykopmobilny.glide.GlideApp
import io.github.feelfreelinux.wykopmobilny.utils.api.CredentialsPreferencesApi
import io.github.feelfreelinux.wykopmobilny.utils.api.parseDate
import org.ocpsoft.prettytime.PrettyTime
import java.util.*
Expand All @@ -27,6 +26,8 @@ import android.text.SpannableStringBuilder





var View.isVisible : Boolean
get() = visibility == View.VISIBLE
set(value) { visibility = if (value) View.VISIBLE else View.GONE }
Expand Down Expand Up @@ -71,12 +72,25 @@ fun ImageView.loadImage(url : String) {
fun String.toPrettyDate() : String = PrettyTime(Locale("pl")).format(parseDate(this))

fun Uri.queryFileName(contentResolver: ContentResolver) : String {
val returnCursor = contentResolver.query(this, null, null, null, null)
val nameIndex = returnCursor?.getColumnIndex(OpenableColumns.DISPLAY_NAME) ?: return ""
returnCursor.moveToFirst()
val name = returnCursor.getString(nameIndex)
returnCursor.close()
return name
var result: String? = null
if (scheme == "content") {
val cursor = contentResolver.query(this, null, null, null, null)
try {
if (cursor != null && cursor.moveToFirst()) {
result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME))
}
} finally {
cursor!!.close()
}
}
if (result == null) {
result = path
val cut = result!!.lastIndexOf('/')
if (cut != -1) {
result = result.substring(cut + 1)
}
}
return result
}

fun Uri.getMimeType(contentResolver: ContentResolver): String {
Expand Down

0 comments on commit 9444086

Please sign in to comment.