Skip to content

Commit 0c13176

Browse files
committed
Minor code style changes
1 parent 2ea44e8 commit 0c13176

File tree

14 files changed

+69
-82
lines changed

14 files changed

+69
-82
lines changed

app/build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ android {
1111
compileSdkVersion 28
1212

1313
defaultConfig {
14-
applicationId "com.glodanif.bluetoothchat"
14+
applicationId 'com.glodanif.bluetoothchat'
1515
minSdkVersion 19
1616
targetSdkVersion 28
1717
versionCode VERSION_CODE
1818
versionName VERSION_NAME
1919
vectorDrawables.useSupportLibrary = true
20-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20+
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
2121
kapt {
2222
arguments {
23-
arg("room.schemaLocation", "$projectDir/schemas".toString())
23+
arg('room.schemaLocation', "$projectDir/schemas".toString())
2424
}
2525
}
2626
}
@@ -41,12 +41,12 @@ android {
4141

4242
release {
4343

44-
if (project.hasProperty("bluetoothchat.properties") &&
45-
file(project.property("bluetoothchat.properties")).exists()) {
44+
if (project.hasProperty('bluetoothchat.properties') &&
45+
file(project.property('bluetoothchat.properties')).exists()) {
4646

4747
Properties properties = new Properties()
4848
properties.load(
49-
new FileInputStream(file(project.property("bluetoothchat.properties"))))
49+
new FileInputStream(file(project.property('bluetoothchat.properties'))))
5050

5151
storeFile file(properties['keystore'])
5252
storePassword properties['keystore.password']
@@ -66,7 +66,7 @@ android {
6666
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
6767
applicationIdSuffix '.dev'
6868
versionNameSuffix '-DEV'
69-
buildConfigField "boolean", "AUTORESPONDER", "false"
69+
buildConfigField 'boolean', 'AUTORESPONDER', 'false'
7070
}
7171

7272
autoresponder {
@@ -75,7 +75,7 @@ android {
7575
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
7676
applicationIdSuffix '.ar'
7777
versionNameSuffix '-AR'
78-
buildConfigField "boolean", "AUTORESPONDER", "true"
78+
buildConfigField 'boolean', 'AUTORESPONDER', 'true'
7979
}
8080

8181
release {
@@ -84,7 +84,7 @@ android {
8484
debuggable false
8585
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
8686
signingConfig signingConfigs.release
87-
buildConfigField "boolean", "AUTORESPONDER", "false"
87+
buildConfigField 'boolean', 'AUTORESPONDER', 'false'
8888
}
8989
}
9090

app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/BluetoothScannerImpl.kt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,14 @@ class BluetoothScannerImpl(val context: Context) : BluetoothScanner {
9797
return if (!pairedDevice.isEmpty()) pairedDevice.first() else foundDevices[address]
9898
}
9999

100-
override fun isBluetoothAvailable(): Boolean {
101-
return adapter != null
102-
}
100+
override fun isBluetoothAvailable() = adapter != null
103101

104-
override fun isBluetoothEnabled(): Boolean {
105-
return adapter?.isEnabled ?: false
106-
}
102+
override fun isBluetoothEnabled() = adapter?.isEnabled ?: false
107103

108-
override fun isDiscoverable(): Boolean {
109-
return adapter?.scanMode == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE
110-
}
104+
override fun isDiscoverable() =
105+
adapter?.scanMode == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE
111106

112-
override fun isDiscovering(): Boolean {
113-
return isDiscovering
114-
}
107+
override fun isDiscovering() = isDiscovering
115108

116109
override fun listenDiscoverableStatus() {
117110
isListeningForDiscoverableStatus = true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import java.util.*
4545

4646
class ChatActivity : SkeletonActivity(), ChatView {
4747

48-
private val deviceAddress by argument<String?>(EXTRA_ADDRESS)
48+
private val deviceAddress: String? by argument(EXTRA_ADDRESS)
4949

5050
private val presenter: ChatPresenter by inject {
5151
parametersOf(deviceAddress ?: "", this)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import org.koin.core.parameter.parametersOf
1919

2020
class ContactChooserActivity : SkeletonActivity(), ContactChooserView {
2121

22-
private val message by argument<String?>(EXTRA_MESSAGE)
23-
private val filePath by argument<String?>(EXTRA_FILE_PATH)
22+
private val message: String? by argument(EXTRA_MESSAGE)
23+
private val filePath: String? by argument(EXTRA_FILE_PATH)
2424

2525
private val presenter: ContactChooserPresenter by inject { parametersOf(this) }
2626

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import java.lang.ref.WeakReference
3333

3434
class ImagePreviewActivity : SkeletonActivity(), ImagePreviewView {
3535

36-
private val messageId by argument(EXTRA_MESSAGE_ID, -1L)
37-
private val imagePath by argument<String>(EXTRA_IMAGE_PATH)
38-
private val own by argument(EXTRA_OWN, false)
36+
private val messageId: Long by argument(EXTRA_MESSAGE_ID, -1L)
37+
private val imagePath: String? by argument(EXTRA_IMAGE_PATH)
38+
private val own: Boolean by argument(EXTRA_OWN, false)
3939

4040
private val presenter: ImagePreviewPresenter by inject {
4141
parametersOf(messageId, File(imagePath), this)
@@ -120,11 +120,11 @@ class ImagePreviewActivity : SkeletonActivity(), ImagePreviewView {
120120
override fun onDestroy() {
121121
super.onDestroy()
122122

123-
//Fixes https://issuetracker.google.com/issues/37042900
124123
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
125124
return
126125
}
127126

127+
//Fixes https://issuetracker.google.com/issues/37042900
128128
val transitionManagerClass = TransitionManager::class.java
129129
try {
130130
val runningTransitionsField = transitionManagerClass.getDeclaredField("sRunningTransitions")

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.content.ActivityNotFoundException
44
import android.content.Context
55
import android.content.Intent
66
import android.os.Bundle
7+
import android.provider.Settings
78
import android.support.annotation.ColorInt
89
import android.support.v4.content.ContextCompat
910
import android.view.View
@@ -25,15 +26,14 @@ import org.koin.core.parameter.parametersOf
2526

2627
class ProfileActivity : SkeletonActivity(), ProfileView {
2728

28-
private val editMode by argument(EXTRA_EDIT_MODE, false)
29+
private val editMode: Boolean by argument(EXTRA_EDIT_MODE, false)
2930

3031
private val presenter: ProfilePresenter by inject { parametersOf(this) }
3132

3233
private val nameField: EditText by bind(R.id.et_name)
3334
private val nameLabel: TextView by bind(R.id.tv_name)
3435
private val deviceNameLabel: TextView by bind(R.id.tv_device_name)
3536
private val avatar: ImageView by bind(R.id.iv_avatar)
36-
3737
private val colorPicker: View by bind(R.id.v_color)
3838

3939
override fun onCreate(savedInstanceState: Bundle?) {
@@ -59,7 +59,7 @@ class ProfileActivity : SkeletonActivity(), ProfileView {
5959

6060
deviceNameLabel.setOnClickListener {
6161
val bluetoothSettings = Intent().apply {
62-
action = android.provider.Settings.ACTION_BLUETOOTH_SETTINGS
62+
action = Settings.ACTION_BLUETOOTH_SETTINGS
6363
}
6464
try {
6565
startActivity(bluetoothSettings)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import com.glodanif.bluetoothchat.data.entity.MessageFile
1212
import com.glodanif.bluetoothchat.ui.adapter.ImagesAdapter
1313
import com.glodanif.bluetoothchat.ui.presenter.ReceivedImagesPresenter
1414
import com.glodanif.bluetoothchat.ui.view.ReceivedImagesView
15+
import com.glodanif.bluetoothchat.utils.argument
1516
import com.glodanif.bluetoothchat.utils.bind
1617
import org.koin.android.ext.android.inject
1718
import org.koin.core.parameter.parametersOf
1819

1920
class ReceivedImagesActivity : SkeletonActivity(), ReceivedImagesView {
2021

21-
private var address: String? = null
22+
private val address: String? by argument(EXTRA_ADDRESS)
23+
2224
private val presenter: ReceivedImagesPresenter by inject {
2325
parametersOf(address ?: "", this)
2426
}
@@ -32,8 +34,6 @@ class ReceivedImagesActivity : SkeletonActivity(), ReceivedImagesView {
3234
super.onCreate(savedInstanceState)
3335
setContentView(R.layout.activity_received_images, ActivityType.CHILD_ACTIVITY)
3436

35-
address = intent.getStringExtra(EXTRA_ADDRESS)
36-
3737
imagesGrid.layoutManager = GridLayoutManager(this, calculateNoOfColumns())
3838
imagesGrid.adapter = imagesAdapter
3939

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@ open class SkeletonActivity : AppCompatActivity() {
3636
toolbar = findViewById(R.id.tb_toolbar)
3737
setSupportActionBar(toolbar)
3838

39-
val rootView = findViewById<ViewGroup>(R.id.fl_content_container)
40-
4139
if (type == ActivityType.CHILD_ACTIVITY) {
4240
supportActionBar?.setDisplayHomeAsUpEnabled(true)
4341
supportActionBar?.setDisplayShowHomeEnabled(true)
42+
val rootView = findViewById<ViewGroup>(R.id.fl_content_container)
4443
LayoutInflater.from(this).inflate(layoutId, rootView, true)
4544
}
4645
}
@@ -50,13 +49,13 @@ open class SkeletonActivity : AppCompatActivity() {
5049
return true
5150
}
5251

53-
inline fun doIfStarted(action: () -> Unit) {
52+
protected inline fun doIfStarted(action: () -> Unit) {
5453
if (lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)) {
5554
action.invoke()
5655
}
5756
}
5857

59-
fun openLink(link: String) {
58+
protected fun openLink(link: String) {
6059
val intent = Intent(Intent.ACTION_VIEW).apply {
6160
data = Uri.parse(link)
6261
}
@@ -67,7 +66,7 @@ open class SkeletonActivity : AppCompatActivity() {
6766
}
6867
}
6968

70-
fun hideKeyboard() {
69+
protected fun hideKeyboard() {
7170
val inputManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
7271
currentFocus?.let { view ->
7372
inputManager.hideSoftInputFromWindow(view.windowToken, InputMethodManager.HIDE_NOT_ALWAYS)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import com.glodanif.bluetoothchat.R
1414
class ActionView : FrameLayout {
1515

1616
@SuppressLint("InflateParams")
17-
private var container: View =
18-
LayoutInflater.from(context).inflate(R.layout.view_action, null)
17+
private var container = LayoutInflater.from(context).inflate(R.layout.view_action, null)
1918

2019
constructor(context: Context) : super(context)
2120
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.glodanif.bluetoothchat.ui.widget
22

3+
import android.annotation.SuppressLint
34
import android.content.Context
45
import android.support.design.widget.FloatingActionButton
56
import android.support.v4.view.ViewCompat
@@ -24,6 +25,7 @@ class GoDownButton : FrameLayout {
2425

2526
init {
2627

28+
@SuppressLint("InflateParams")
2729
val root = context.getLayoutInflater().inflate(R.layout.view_go_down_button, null)
2830

2931
goDownButton = root.findViewById(R.id.fab_go_down)

0 commit comments

Comments
 (0)