diff --git a/app/build.gradle b/app/build.gradle index 3e0842f9..ff1111da 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,5 @@ -def final VERSION_CODE = 6 -def final VERSION_NAME = '1.0.0-beta1' +def final VERSION_CODE = 7 +def final VERSION_NAME = '1.0.0-beta2' apply plugin: 'com.android.application' apply plugin: 'kotlin-android' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c8af2841..832a037e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,7 +26,7 @@ tools:replace="android:allowBackup"> @@ -41,34 +41,39 @@ - + + + ) -> Unit) diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/ConversationsStorageImpl.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/ConversationsStorageImpl.kt similarity index 88% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/ConversationsStorageImpl.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/ConversationsStorageImpl.kt index eb42b31a..61a1d7d5 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/ConversationsStorageImpl.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/ConversationsStorageImpl.kt @@ -1,9 +1,9 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model import android.content.Context import android.os.Handler -import com.glodanif.bluetoothchat.database.Storage -import com.glodanif.bluetoothchat.entity.Conversation +import com.glodanif.bluetoothchat.data.database.Storage +import com.glodanif.bluetoothchat.data.entity.Conversation import kotlin.concurrent.thread class ConversationsStorageImpl(context: Context) : ConversationsStorage { diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/FileExtractor.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/FileExtractor.kt similarity index 72% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/FileExtractor.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/FileExtractor.kt index 439157e5..b4931ceb 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/FileExtractor.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/FileExtractor.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model import android.net.Uri diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/MessagesStorage.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/MessagesStorage.kt similarity index 67% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/MessagesStorage.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/MessagesStorage.kt index 9b4405f2..ef432dd7 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/MessagesStorage.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/MessagesStorage.kt @@ -1,6 +1,6 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model -import com.glodanif.bluetoothchat.entity.ChatMessage +import com.glodanif.bluetoothchat.data.entity.ChatMessage interface MessagesStorage { diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/MessagesStorageImpl.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/MessagesStorageImpl.kt similarity index 77% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/MessagesStorageImpl.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/MessagesStorageImpl.kt index a2f48909..51b7f3f8 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/MessagesStorageImpl.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/MessagesStorageImpl.kt @@ -1,10 +1,10 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model import android.content.Context import android.os.Handler -import com.glodanif.bluetoothchat.database.Storage -import com.glodanif.bluetoothchat.database.MessagesDao -import com.glodanif.bluetoothchat.entity.ChatMessage +import com.glodanif.bluetoothchat.data.database.Storage +import com.glodanif.bluetoothchat.data.database.MessagesDao +import com.glodanif.bluetoothchat.data.entity.ChatMessage import kotlin.concurrent.thread class MessagesStorageImpl(val context: Context) : MessagesStorage { diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnConnectionListener.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnConnectionListener.kt similarity index 81% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnConnectionListener.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnConnectionListener.kt index c0437142..23177a0b 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnConnectionListener.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnConnectionListener.kt @@ -1,7 +1,7 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model import android.bluetooth.BluetoothDevice -import com.glodanif.bluetoothchat.entity.Conversation +import com.glodanif.bluetoothchat.data.entity.Conversation interface OnConnectionListener { fun onConnecting() diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnMessageListener.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnMessageListener.kt similarity index 69% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnMessageListener.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnMessageListener.kt index 2312a39a..c678e396 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnMessageListener.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnMessageListener.kt @@ -1,6 +1,6 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model -import com.glodanif.bluetoothchat.entity.ChatMessage +import com.glodanif.bluetoothchat.data.entity.ChatMessage interface OnMessageListener { fun onMessageReceived(message: ChatMessage) diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnPrepareListener.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnPrepareListener.kt similarity index 60% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnPrepareListener.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnPrepareListener.kt index f25d797e..32516f0a 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/OnPrepareListener.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/OnPrepareListener.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model interface OnPrepareListener { fun onPrepared() diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/Preferences.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/Preferences.kt similarity index 56% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/Preferences.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/Preferences.kt index 714e7a27..165ca2cb 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/Preferences.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/Preferences.kt @@ -1,6 +1,6 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model -import com.glodanif.bluetoothchat.util.NotificationSettings +import com.glodanif.bluetoothchat.ui.util.NotificationSettings interface Preferences { fun isSoundEnabled(): Boolean diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/SettingsManager.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SettingsManager.kt similarity index 83% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/SettingsManager.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SettingsManager.kt index aa1bce2b..158c77d8 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/SettingsManager.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SettingsManager.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model import android.support.annotation.ColorInt diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/SettingsManagerImpl.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SettingsManagerImpl.kt similarity index 94% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/SettingsManagerImpl.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SettingsManagerImpl.kt index 0ad1d125..712c1fa2 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/SettingsManagerImpl.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SettingsManagerImpl.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model import android.content.Context import android.graphics.Color diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/SimpleConnectionListener.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SimpleConnectionListener.kt similarity index 86% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/SimpleConnectionListener.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SimpleConnectionListener.kt index 7c82ec1e..232148c0 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/SimpleConnectionListener.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/SimpleConnectionListener.kt @@ -1,7 +1,7 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model import android.bluetooth.BluetoothDevice -import com.glodanif.bluetoothchat.entity.Conversation +import com.glodanif.bluetoothchat.data.entity.Conversation abstract class SimpleConnectionListener : OnConnectionListener { diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/UserPreferences.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/UserPreferences.kt similarity index 86% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/model/UserPreferences.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/UserPreferences.kt index e891dfaa..53989e3b 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/model/UserPreferences.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/model/UserPreferences.kt @@ -1,8 +1,8 @@ -package com.glodanif.bluetoothchat.model +package com.glodanif.bluetoothchat.data.model import android.content.Context import android.preference.PreferenceManager -import com.glodanif.bluetoothchat.util.NotificationSettings +import com.glodanif.bluetoothchat.ui.util.NotificationSettings class UserPreferences(context: Context): Preferences { diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/service/BluetoothConnectionService.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/service/BluetoothConnectionService.kt similarity index 96% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/service/BluetoothConnectionService.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/data/service/BluetoothConnectionService.kt index 83f19bc1..25600d9c 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/service/BluetoothConnectionService.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/data/service/BluetoothConnectionService.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.service +package com.glodanif.bluetoothchat.data.service import android.app.Service import android.bluetooth.BluetoothAdapter @@ -17,16 +17,16 @@ import android.util.Log import com.glodanif.bluetoothchat.BuildConfig import com.glodanif.bluetoothchat.ChatApplication import com.glodanif.bluetoothchat.R -import com.glodanif.bluetoothchat.database.Storage -import com.glodanif.bluetoothchat.database.ChatDatabase -import com.glodanif.bluetoothchat.entity.ChatMessage -import com.glodanif.bluetoothchat.entity.Conversation -import com.glodanif.bluetoothchat.entity.Message -import com.glodanif.bluetoothchat.model.* -import com.glodanif.bluetoothchat.view.NotificationView -import com.glodanif.bluetoothchat.view.NotificationViewImpl -import com.glodanif.bluetoothchat.widget.ShortcutManager -import com.glodanif.bluetoothchat.widget.ShortcutManagerImpl +import com.glodanif.bluetoothchat.data.database.Storage +import com.glodanif.bluetoothchat.data.database.ChatDatabase +import com.glodanif.bluetoothchat.data.entity.ChatMessage +import com.glodanif.bluetoothchat.data.entity.Conversation +import com.glodanif.bluetoothchat.data.entity.Message +import com.glodanif.bluetoothchat.data.model.* +import com.glodanif.bluetoothchat.ui.view.NotificationView +import com.glodanif.bluetoothchat.ui.view.NotificationViewImpl +import com.glodanif.bluetoothchat.ui.widget.ShortcutManager +import com.glodanif.bluetoothchat.ui.widget.ShortcutManagerImpl import java.io.IOException import java.io.InputStream import java.io.OutputStream diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/extension/Extensions.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/extension/Extensions.kt index 1ad5fdc6..04791cc3 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/extension/Extensions.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/extension/Extensions.kt @@ -13,14 +13,11 @@ import android.graphics.drawable.Drawable import android.opengl.ETC1.getHeight import android.opengl.ETC1.getWidth - - fun Date.getRelativeTime(context: Context): String { val resources = context.resources - val VIEW_FORMAT: DateFormat = - SimpleDateFormat(context.getString(R.string.general__time_format), Locale.ENGLISH) + val VIEW_FORMAT = SimpleDateFormat(context.getString(R.string.general__time_format), Locale.ENGLISH) val SECOND_MILLIS = 1000 val MINUTE_MILLIS = 60 * SECOND_MILLIS val HOUR_MILLIS = 60 * MINUTE_MILLIS diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ChatActivity.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ChatActivity.kt similarity index 90% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ChatActivity.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ChatActivity.kt index 6c85b055..a701d7d5 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ChatActivity.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ChatActivity.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.activity +package com.glodanif.bluetoothchat.ui.activity import android.app.Activity import android.app.AlertDialog @@ -7,6 +7,7 @@ import android.app.Service import android.bluetooth.BluetoothAdapter import android.content.Context import android.content.Intent +import android.net.Uri import android.os.Bundle import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.RecyclerView @@ -17,20 +18,18 @@ import android.widget.EditText import android.widget.ImageButton import android.widget.Toast import com.glodanif.bluetoothchat.R -import com.glodanif.bluetoothchat.adapter.ChatAdapter -import com.glodanif.bluetoothchat.entity.ChatMessage -import com.glodanif.bluetoothchat.entity.Conversation -import com.glodanif.bluetoothchat.model.* -import com.glodanif.bluetoothchat.presenter.ChatPresenter -import com.glodanif.bluetoothchat.view.ChatView -import com.glodanif.bluetoothchat.view.NotificationView -import com.glodanif.bluetoothchat.widget.ActionView +import com.glodanif.bluetoothchat.ui.adapter.ChatAdapter +import com.glodanif.bluetoothchat.data.entity.ChatMessage +import com.glodanif.bluetoothchat.data.entity.Conversation +import com.glodanif.bluetoothchat.data.model.* +import com.glodanif.bluetoothchat.ui.presenter.ChatPresenter +import com.glodanif.bluetoothchat.ui.view.ChatView +import com.glodanif.bluetoothchat.ui.view.NotificationView +import com.glodanif.bluetoothchat.ui.widget.ActionView import java.util.* class ChatActivity : SkeletonActivity(), ChatView { - private val REQUEST_ENABLE_BLUETOOTH = 101 - private lateinit var presenter: ChatPresenter private val connectionModel: BluetoothConnector = BluetoothConnectorImpl(this) private val scanModel: BluetoothScanner = BluetoothScannerImpl(this) @@ -71,6 +70,10 @@ class ChatActivity : SkeletonActivity(), ChatView { toolbar?.subtitle = getString(R.string.chat__not_connected) presenter = ChatPresenter(deviceAddress.toString(), this, scanModel, connectionModel, conversationModel, storageModel) + + if (intent.action == Intent.ACTION_SEND) { + messageField.setText(intent.data.toString().trim()) + } } override fun onStart() { @@ -293,12 +296,22 @@ class ChatActivity : SkeletonActivity(), ChatView { companion object { - val EXTRA_ADDRESS = "extra.address" + private const val REQUEST_ENABLE_BLUETOOTH = 101 + + const val EXTRA_ADDRESS = "extra.address" fun start(context: Context, address: String) { val intent: Intent = Intent(context, ChatActivity::class.java) .putExtra(EXTRA_ADDRESS, address) context.startActivity(intent) } + + fun start(context: Context, address: String, message: String) { + val intent: Intent = Intent(context, ChatActivity::class.java) + .setAction(Intent.ACTION_SEND) + .setData(Uri.parse(message)) + .putExtra(EXTRA_ADDRESS, address) + context.startActivity(intent) + } } } diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ContactChooserActivity.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ContactChooserActivity.kt new file mode 100644 index 00000000..c177243a --- /dev/null +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ContactChooserActivity.kt @@ -0,0 +1,71 @@ +package com.glodanif.bluetoothchat.ui.activity + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import android.support.v7.widget.LinearLayoutManager +import android.support.v7.widget.RecyclerView +import android.view.View +import android.widget.TextView +import com.glodanif.bluetoothchat.R +import com.glodanif.bluetoothchat.ui.adapter.ContactsAdapter +import com.glodanif.bluetoothchat.ui.viewmodel.ContactViewModel +import com.glodanif.bluetoothchat.data.model.ConversationsStorageImpl +import com.glodanif.bluetoothchat.ui.presenter.ContactChooserPresenter +import com.glodanif.bluetoothchat.ui.view.ContactChooserView + +class ContactChooserActivity : SkeletonActivity(), ContactChooserView { + + private lateinit var presenter: ContactChooserPresenter + private val storage = ConversationsStorageImpl(this) + + private lateinit var contactsList: RecyclerView + private lateinit var noContactsLabel: TextView + + private val adapter: ContactsAdapter = ContactsAdapter() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_contact_chooser, ActivityType.CHILD_ACTIVITY) + + contactsList = findViewById(R.id.rv_contacts) + noContactsLabel = findViewById(R.id.tv_no_contacts) + + contactsList.layoutManager = LinearLayoutManager(this) + contactsList.adapter = adapter + + val message = intent.getStringExtra(EXTRA_MESSAGE) + adapter.clickListener = { + ChatActivity.start(this, it.address, message) + finish() + } + + presenter = ContactChooserPresenter(this, storage) + } + + override fun onStart() { + super.onStart() + presenter.loadContacts() + } + + override fun showContacts(contacts: List) { + adapter.conversations = ArrayList(contacts) + adapter.notifyDataSetChanged() + } + + override fun showNoContacts() { + noContactsLabel.visibility = View.VISIBLE + contactsList.visibility = View.GONE + } + + companion object { + + const val EXTRA_MESSAGE = "extra.message" + + fun start(context: Context, message: String) { + val intent = Intent(context, ContactChooserActivity::class.java) + .putExtra(EXTRA_MESSAGE, message) + context.startActivity(intent) + } + } +} diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ConversationsActivity.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ConversationsActivity.kt similarity index 88% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ConversationsActivity.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ConversationsActivity.kt index cdd15203..6372031f 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ConversationsActivity.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ConversationsActivity.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.activity +package com.glodanif.bluetoothchat.ui.activity import android.app.Activity import android.app.AlertDialog @@ -16,20 +16,20 @@ import android.widget.Button import android.widget.ImageView import com.amulyakhare.textdrawable.TextDrawable import com.glodanif.bluetoothchat.R -import com.glodanif.bluetoothchat.adapter.ConversationsAdapter -import com.glodanif.bluetoothchat.entity.Conversation +import com.glodanif.bluetoothchat.ui.adapter.ConversationsAdapter +import com.glodanif.bluetoothchat.data.entity.Conversation import com.glodanif.bluetoothchat.extension.getFirstLetter -import com.glodanif.bluetoothchat.model.BluetoothConnectorImpl -import com.glodanif.bluetoothchat.model.ConversationsStorageImpl -import com.glodanif.bluetoothchat.model.SettingsManager -import com.glodanif.bluetoothchat.model.SettingsManagerImpl -import com.glodanif.bluetoothchat.presenter.ConversationsPresenter -import com.glodanif.bluetoothchat.view.ConversationsView -import com.glodanif.bluetoothchat.view.NotificationView -import com.glodanif.bluetoothchat.widget.ActionView -import com.glodanif.bluetoothchat.widget.SettingsPopup -import com.glodanif.bluetoothchat.widget.ShortcutManager -import com.glodanif.bluetoothchat.widget.ShortcutManagerImpl +import com.glodanif.bluetoothchat.data.model.BluetoothConnectorImpl +import com.glodanif.bluetoothchat.data.model.ConversationsStorageImpl +import com.glodanif.bluetoothchat.data.model.SettingsManager +import com.glodanif.bluetoothchat.data.model.SettingsManagerImpl +import com.glodanif.bluetoothchat.ui.presenter.ConversationsPresenter +import com.glodanif.bluetoothchat.ui.view.ConversationsView +import com.glodanif.bluetoothchat.ui.view.NotificationView +import com.glodanif.bluetoothchat.ui.widget.ActionView +import com.glodanif.bluetoothchat.ui.widget.SettingsPopup +import com.glodanif.bluetoothchat.ui.widget.ShortcutManager +import com.glodanif.bluetoothchat.ui.widget.ShortcutManagerImpl import java.util.* class ConversationsActivity : SkeletonActivity(), ConversationsView { @@ -63,7 +63,7 @@ class ConversationsActivity : SkeletonActivity(), ConversationsView { shortcutsManager = ShortcutManagerImpl(this) presenter = ConversationsPresenter(this, connection, storage, settings) - actions = findViewById(R.id.av_actions) + actions = findViewById(R.id.av_actions) userAvatar = findViewById(R.id.iv_avatar) conversationsList = findViewById(R.id.rv_conversations) @@ -94,6 +94,12 @@ class ConversationsActivity : SkeletonActivity(), ConversationsView { optionsButton.setOnClickListener { v -> settingsPopup.show(v) } + + if (intent.action == Intent.ACTION_SEND) { + ContactChooserActivity.start(this, intent.getStringExtra(Intent.EXTRA_TEXT)) + } + + ShortcutManagerImpl(this).addSearchShortcut() } private fun showContextMenu(conversation: Conversation, isCurrent: Boolean) { @@ -146,6 +152,7 @@ class ConversationsActivity : SkeletonActivity(), ConversationsView { override fun onStart() { super.onStart() isStarted = true + presenter.prepareConnection() presenter.loadUserProfile() } diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ProfileActivity.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ProfileActivity.kt similarity index 84% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ProfileActivity.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ProfileActivity.kt index a290a6aa..632f0b5c 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ProfileActivity.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ProfileActivity.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.activity +package com.glodanif.bluetoothchat.ui.activity import android.content.Context import android.content.Intent @@ -12,12 +12,12 @@ import android.widget.ImageView import android.widget.TextView import com.amulyakhare.textdrawable.TextDrawable import com.glodanif.bluetoothchat.R -import com.glodanif.bluetoothchat.model.SettingsManager -import com.glodanif.bluetoothchat.model.SettingsManagerImpl -import com.glodanif.bluetoothchat.presenter.ProfilePresenter -import com.glodanif.bluetoothchat.util.SimpleTextWatcher -import com.glodanif.bluetoothchat.view.ProfileView -import com.glodanif.bluetoothchat.widget.ShortcutManagerImpl +import com.glodanif.bluetoothchat.data.model.SettingsManager +import com.glodanif.bluetoothchat.data.model.SettingsManagerImpl +import com.glodanif.bluetoothchat.ui.presenter.ProfilePresenter +import com.glodanif.bluetoothchat.ui.util.SimpleTextWatcher +import com.glodanif.bluetoothchat.ui.view.ProfileView +import com.glodanif.bluetoothchat.ui.widget.ShortcutManagerImpl import me.priyesh.chroma.ChromaDialog import me.priyesh.chroma.ColorMode import me.priyesh.chroma.ColorSelectListener @@ -95,8 +95,15 @@ class ProfileActivity : SkeletonActivity(), ProfileView { } override fun redirectToConversations() { + if (!editMode) { - ConversationsActivity.start(this) + + val intent = Intent(this, ConversationsActivity::class.java) + if (getIntent().action == Intent.ACTION_SEND) { + intent.action = Intent.ACTION_SEND + intent.putExtra(Intent.EXTRA_TEXT, getIntent().getStringExtra(Intent.EXTRA_TEXT)) + } + startActivity(intent) } finish() } @@ -109,10 +116,6 @@ class ProfileActivity : SkeletonActivity(), ProfileView { nameField.error = getString(R.string.profile__validation_error) } - override fun addSearchShortcut() { - ShortcutManagerImpl(this).addSearchShortcut() - } - private val textWatcher = object : SimpleTextWatcher() { override fun afterTextChanged(text: String) { nameField.error = null diff --git a/app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ScanActivity.kt b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ScanActivity.kt similarity index 92% rename from app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ScanActivity.kt rename to app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ScanActivity.kt index 6ba92c8f..00924409 100644 --- a/app/src/main/kotlin/com/glodanif/bluetoothchat/activity/ScanActivity.kt +++ b/app/src/main/kotlin/com/glodanif/bluetoothchat/ui/activity/ScanActivity.kt @@ -1,4 +1,4 @@ -package com.glodanif.bluetoothchat.activity +package com.glodanif.bluetoothchat.ui.activity import android.Manifest import android.app.Activity @@ -18,13 +18,13 @@ import android.support.v7.widget.RecyclerView import android.view.View import android.widget.* import com.glodanif.bluetoothchat.R -import com.glodanif.bluetoothchat.adapter.DevicesAdapter -import com.glodanif.bluetoothchat.model.ApkExtractor -import com.glodanif.bluetoothchat.model.BluetoothConnectorImpl -import com.glodanif.bluetoothchat.model.BluetoothScannerImpl -import com.glodanif.bluetoothchat.presenter.ScanPresenter -import com.glodanif.bluetoothchat.view.ScanView -import com.glodanif.bluetoothchat.widget.ExpiringProgressBar +import com.glodanif.bluetoothchat.ui.adapter.DevicesAdapter +import com.glodanif.bluetoothchat.data.model.ApkExtractor +import com.glodanif.bluetoothchat.data.model.BluetoothConnectorImpl +import com.glodanif.bluetoothchat.data.model.BluetoothScannerImpl +import com.glodanif.bluetoothchat.ui.presenter.ScanPresenter +import com.glodanif.bluetoothchat.ui.view.ScanView +import com.glodanif.bluetoothchat.ui.widget.ExpiringProgressBar class ScanActivity : SkeletonActivity(), ScanView { @@ -64,14 +64,14 @@ class ScanActivity : SkeletonActivity(), ScanView { listHolder = findViewById(R.id.cl_list) progress = findViewById(R.id.fl_progress) - infoLabel = findViewById(R.id.tv_info) - discoveryLabel = findViewById(R.id.tv_discovery_label) - progressBar = findViewById(R.id.epb_progress) + infoLabel = findViewById(R.id.tv_info) + discoveryLabel = findViewById(R.id.tv_discovery_label) + progressBar = findViewById(R.id.epb_progress) - makeDiscoverableButton = findViewById