Skip to content

Commit a06efc6

Browse files
committed
Fixed wrong file start detection
1 parent c89aedf commit a06efc6

File tree

6 files changed

+12
-17
lines changed

6 files changed

+12
-17
lines changed

app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ dependencies {
105105
implementation fileTree(dir: 'libs', include: ['*.jar'])
106106

107107
implementation "com.android.support:appcompat-v7:$SUPPORT_VERSION"
108-
implementation "com.android.support:support-v4:$SUPPORT_VERSION"
109108
implementation "com.android.support:design:$SUPPORT_VERSION"
110109
implementation "com.android.support:recyclerview-v7:$SUPPORT_VERSION"
111110
implementation "com.android.support:cardview-v7:$SUPPORT_VERSION"

app/src/main/kotlin/com/glodanif/bluetoothchat/data/service/TransferEventStrategy.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ class TransferEventStrategy : DataTransferThread.EventsStrategy {
1515

1616
if (message != null && fileStartRegex.containsMatchIn(message)) {
1717

18-
val info = fileStartRegex.replace(message, "")
18+
val messageBody = "6#" + message.substringAfter("6#")
19+
20+
val info = fileStartRegex.replace(messageBody, "")
1921
val uid = try {
20-
message.substring(2).substringBefore("#").toLong()
22+
messageBody.substring(2).substringBefore("#").toLong()
2123
} catch (e: NumberFormatException) {
2224

23-
val exception = NumberFormatException(e.message + " | " + fileStartRegex.find(message)?.value)
25+
//TODO: remove if crash doesn't appear anymore
26+
val exception = NumberFormatException(e.message + " | " + fileStartRegex.find(messageBody)?.value)
2427

2528
if (Fabric.isInitialized()) {
2629
Crashlytics.getInstance().core.logException(exception)
@@ -47,7 +50,7 @@ class TransferEventStrategy : DataTransferThread.EventsStrategy {
4750
null
4851
}
4952

50-
override fun isFileCanceled(message: String?): DataTransferThread.CancelInfo? =
53+
override fun isFileCanceled(message: String?) =
5154

5255
if (message != null && (message.contains("8#0#0#") || message.contains("8#0#1#"))) {
5356
val byPartner = message

app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ScanActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ class ScanActivity : SkeletonActivity(), ScanView {
151151
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BLUETOOTH)
152152
}
153153

154-
override fun showBluetoothIsNotAvailableMessage() {
154+
override fun showBluetoothIsNotAvailableMessage() = doIfStarted {
155155
AlertDialog.Builder(this)
156156
.setMessage(R.string.scan__no_access_to_bluetooth)
157157
.setPositiveButton(R.string.general__ok, { _, _ -> finish() })
158158
.show()
159159
}
160160

161-
override fun showBluetoothEnablingFailed() {
161+
override fun showBluetoothEnablingFailed() = doIfStarted {
162162
AlertDialog.Builder(this)
163163
.setMessage(R.string.scan__bluetooth_disabled)
164164
.setPositiveButton(R.string.general__ok, null)
@@ -195,7 +195,7 @@ class ScanActivity : SkeletonActivity(), ScanView {
195195
scanForDevicesButton.text = getString(R.string.scan__scan_for_devices)
196196
}
197197

198-
override fun showBluetoothDiscoverableFailure() {
198+
override fun showBluetoothDiscoverableFailure() = doIfStarted {
199199
AlertDialog.Builder(this)
200200
.setMessage(R.string.scan__unable_to_make_discoverable)
201201
.setPositiveButton(R.string.general__ok, null)
@@ -280,7 +280,7 @@ class ScanActivity : SkeletonActivity(), ScanView {
280280
.show()
281281
}
282282

283-
override fun showExtractionApkFailureMessage() {
283+
override fun showExtractionApkFailureMessage() = doIfStarted {
284284
AlertDialog.Builder(this)
285285
.setMessage(R.string.scan__unable_to_fetch_apk)
286286
.setPositiveButton(R.string.general__ok, null)

app/src/main/kotlin/com/glodanif/bluetoothchat/ui/adapter/ContactsAdapter.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class ContactsAdapter : RecyclerView.Adapter<ContactsAdapter.ContactViewHolder>(
1515
var clickListener: ((ContactViewModel) -> Unit)? = null
1616
var conversations: ArrayList<ContactViewModel> = ArrayList()
1717

18-
@SuppressLint("SetTextI18n")
1918
override fun onBindViewHolder(holder: ContactViewHolder, position: Int) {
2019

2120
val contact = conversations[position]

app/src/main/kotlin/com/glodanif/bluetoothchat/ui/widget/ExpiringProgressBar.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class ExpiringProgressBar : View {
7676
}
7777

7878
private val tick = object : Runnable {
79+
7980
override fun run() {
8081
if (!isCanceled && timeLeft > 0) {
8182
timeLeft--

app/src/main/kotlin/com/glodanif/bluetoothchat/utils/Extensions.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ fun Animation.onEnd(action: () -> Unit) {
5757
})
5858
}
5959

60-
inline fun <T> MutableSet<T>.safeForEach(action: (T) -> Unit) = this.iterator().let {
61-
62-
while (it.hasNext()) {
63-
action.invoke(it.next())
64-
}
65-
}
66-
6760
fun <T> MutableSet<T>.safeRemove(item: T) = this.iterator().let {
6861

6962
while (it.hasNext()) {

0 commit comments

Comments
 (0)