Skip to content

Commit c8aab81

Browse files
committed
Minor fixes
1 parent 7f533b4 commit c8aab81

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ abstract class DataTransferThread(private val socket: BluetoothSocket,
101101

102102
private fun readString(): String? {
103103
return inputStream?.read(buffer)?.let {
104-
String(buffer, 0, it)
104+
try {
105+
String(buffer, 0, it)
106+
} catch (e: StringIndexOutOfBoundsException) {
107+
null
108+
}
105109
}
106110
}
107111

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ class SplashActivity : AppCompatActivity() {
1919
Handler().postDelayed({
2020

2121
val settings = SettingsManagerImpl(this)
22-
val newIntent = Intent(this,
23-
if (settings.getUserName().isEmpty())
24-
ProfileActivity::class.java else ConversationsActivity::class.java)
22+
val nextScreen = if (settings.getUserName().isEmpty())
23+
ProfileActivity::class.java else ConversationsActivity::class.java
24+
val newIntent = Intent(this, nextScreen)
2525

2626
if (intent.action == Intent.ACTION_SEND) {
2727
newIntent.action = Intent.ACTION_SEND
2828
newIntent.type = intent.type
2929
newIntent.putExtra(Intent.EXTRA_TEXT, intent.getStringExtra(Intent.EXTRA_TEXT))
3030
newIntent.putExtra(Intent.EXTRA_STREAM, intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM))
31+
newIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
3132
}
3233

3334
startActivity(newIntent)

0 commit comments

Comments
 (0)