forked from upstream-mirrors/quik
Reorganize presentation package
This commit is contained in:
+8
-8
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation
|
||||
package presentation.common
|
||||
|
||||
import android.annotation.TargetApi
|
||||
import android.arch.lifecycle.ViewModel
|
||||
@@ -28,13 +28,13 @@ import android.os.Build
|
||||
import android.provider.Settings
|
||||
import android.provider.Telephony
|
||||
import common.util.NotificationManager
|
||||
import presentation.compose.ComposeActivity
|
||||
import presentation.compose.ComposeViewModel
|
||||
import presentation.main.MainViewModel
|
||||
import presentation.settings.SettingsActivity
|
||||
import presentation.settings.SettingsViewModel
|
||||
import presentation.setup.SetupActivity
|
||||
import presentation.setup.SetupViewModel
|
||||
import presentation.feature.compose.ComposeActivity
|
||||
import presentation.feature.compose.ComposeViewModel
|
||||
import presentation.feature.main.MainViewModel
|
||||
import presentation.feature.settings.SettingsActivity
|
||||
import presentation.feature.settings.SettingsViewModel
|
||||
import presentation.feature.setup.SetupActivity
|
||||
import presentation.feature.setup.SetupViewModel
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@@ -25,7 +25,7 @@ import android.support.v7.app.AppCompatActivity
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import common.util.Colors
|
||||
import presentation.Navigator
|
||||
import presentation.common.Navigator
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.Observables
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
|
||||
@@ -32,7 +32,7 @@ import common.util.Colors
|
||||
import common.util.GlideApp
|
||||
import common.util.extensions.setTint
|
||||
import data.model.Contact
|
||||
import presentation.Navigator
|
||||
import presentation.common.Navigator
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import kotlinx.android.synthetic.main.avatar_view.view.*
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.res.ColorStateList
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import data.model.Contact
|
||||
import data.model.Message
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import data.model.Contact
|
||||
import data.model.Message
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import android.content.Context
|
||||
import com.moez.QKSMS.R
|
||||
@@ -30,7 +30,7 @@ import data.model.Conversation
|
||||
import data.repository.ContactRepository
|
||||
import data.repository.MessageRepository
|
||||
import interactor.*
|
||||
import presentation.Navigator
|
||||
import presentation.common.Navigator
|
||||
import presentation.common.base.QkViewModel
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import android.app.Activity
|
||||
import android.graphics.Rect
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.compose
|
||||
package presentation.feature.compose
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.main
|
||||
package presentation.feature.conversations
|
||||
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.support.v7.widget.helper.ItemTouchHelper
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.main
|
||||
package presentation.feature.conversations
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.RecyclerView
|
||||
@@ -31,7 +31,7 @@ import data.model.Contact
|
||||
import data.model.InboxItem
|
||||
import data.model.PhoneNumber
|
||||
import data.repository.MessageRepository
|
||||
import presentation.Navigator
|
||||
import presentation.common.Navigator
|
||||
import presentation.common.base.FlowableAdapter
|
||||
import presentation.common.base.QkViewHolder
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
+4
-2
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.main
|
||||
package presentation.feature.main
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.Intent
|
||||
@@ -48,9 +48,11 @@ import io.reactivex.subjects.Subject
|
||||
import kotlinx.android.synthetic.main.drawer_view.*
|
||||
import kotlinx.android.synthetic.main.main_activity.*
|
||||
import kotlinx.android.synthetic.main.toolbar_search.*
|
||||
import presentation.Navigator
|
||||
import presentation.common.Navigator
|
||||
import presentation.common.MenuItemAdapter
|
||||
import presentation.common.base.QkActivity
|
||||
import presentation.feature.conversations.ConversationItemTouchCallback
|
||||
import presentation.feature.conversations.ConversationsAdapter
|
||||
import javax.inject.Inject
|
||||
|
||||
class MainActivity : QkActivity<MainViewModel>(), MainView {
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.main
|
||||
package presentation.feature.main
|
||||
|
||||
import data.model.InboxItem
|
||||
import data.model.MenuItem
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.main
|
||||
package presentation.feature.main
|
||||
|
||||
import presentation.common.base.QkView
|
||||
import io.reactivex.Observable
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.main
|
||||
package presentation.feature.main
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
@@ -34,7 +34,7 @@ import io.reactivex.Observable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.rxkotlin.withLatestFrom
|
||||
import io.realm.Realm
|
||||
import presentation.Navigator
|
||||
import presentation.common.Navigator
|
||||
import presentation.common.base.QkViewModel
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.settings
|
||||
package presentation.feature.settings
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.app.ProgressDialog
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.settings
|
||||
package presentation.feature.settings
|
||||
|
||||
data class SettingsState(
|
||||
val selectingTheme: Boolean = false,
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.settings
|
||||
package presentation.feature.settings
|
||||
|
||||
import presentation.common.base.QkView
|
||||
import presentation.common.widget.PreferenceView
|
||||
+2
-2
@@ -16,14 +16,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.settings
|
||||
package presentation.feature.settings
|
||||
|
||||
import android.content.Context
|
||||
import com.moez.QKSMS.R
|
||||
import common.di.appComponent
|
||||
import common.util.Preferences
|
||||
import interactor.FullSync
|
||||
import presentation.Navigator
|
||||
import presentation.common.Navigator
|
||||
import presentation.common.base.QkViewModel
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import timber.log.Timber
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.settings
|
||||
package presentation.feature.settings
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.setup
|
||||
package presentation.feature.setup
|
||||
|
||||
import android.Manifest
|
||||
import android.os.Bundle
|
||||
@@ -24,7 +24,7 @@ import android.support.v4.app.ActivityCompat
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.moez.QKSMS.R
|
||||
import common.di.appComponent
|
||||
import presentation.Navigator
|
||||
import presentation.common.Navigator
|
||||
import presentation.common.base.QkActivity
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
+1
-1
@@ -16,6 +16,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.setup
|
||||
package presentation.feature.setup
|
||||
|
||||
class SetupState
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.setup
|
||||
package presentation.feature.setup
|
||||
|
||||
import presentation.common.base.QkView
|
||||
import io.reactivex.Observable
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.setup
|
||||
package presentation.feature.setup
|
||||
|
||||
import android.content.Context
|
||||
import android.provider.Telephony
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.provider.Telephony
|
||||
import android.support.annotation.RequiresApi
|
||||
import common.di.appComponent
|
||||
import common.util.Preferences
|
||||
import interactor.PartialSync
|
||||
import javax.inject.Inject
|
||||
|
||||
class DefaultSmsChangedReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var partialSync: PartialSync
|
||||
@Inject lateinit var prefs: Preferences
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
appComponent.inject(this)
|
||||
|
||||
val isDefaultSmsApp = intent.getBooleanExtra(Telephony.Sms.Intents.EXTRA_IS_DEFAULT_SMS_APP, false)
|
||||
prefs.defaultSms.set(isDefaultSmsApp)
|
||||
|
||||
if (isDefaultSmsApp) {
|
||||
val pendingResult = goAsync()
|
||||
partialSync.execute(Unit, { pendingResult.finish() })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import common.di.appComponent
|
||||
import interactor.MarkRead
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkReadReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var markRead: MarkRead
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
appComponent.inject(this)
|
||||
|
||||
val threadId = intent.getLongExtra("threadId", 0)
|
||||
markRead.execute(threadId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import common.di.appComponent
|
||||
import interactor.MarkSeen
|
||||
import javax.inject.Inject
|
||||
|
||||
class MarkSeenReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var markSeen: MarkSeen
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
appComponent.inject(this)
|
||||
|
||||
val threadId = intent.getLongExtra("threadId", 0)
|
||||
markSeen.execute(threadId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.receiver
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import common.di.appComponent
|
||||
import interactor.MarkDelivered
|
||||
import interactor.MarkDeliveryFailed
|
||||
import javax.inject.Inject
|
||||
|
||||
class MessageDeliveredReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var markDelivered: MarkDelivered
|
||||
@Inject lateinit var markDeliveryFailed: MarkDeliveryFailed
|
||||
|
||||
init {
|
||||
appComponent.inject(this)
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
val id = intent.getLongExtra("id", 0L)
|
||||
|
||||
when (resultCode) {
|
||||
// TODO notify about delivery
|
||||
Activity.RESULT_OK -> {
|
||||
val pendingResult = goAsync()
|
||||
markDelivered.execute(id) { pendingResult.finish() }
|
||||
}
|
||||
|
||||
// TODO notify about delivery failure
|
||||
Activity.RESULT_CANCELED -> {
|
||||
val pendingResult = goAsync()
|
||||
markDeliveryFailed.execute(MarkDeliveryFailed.Params(id, resultCode)) { pendingResult.finish() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.receiver
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.telephony.SmsManager
|
||||
import common.di.appComponent
|
||||
import interactor.MarkFailed
|
||||
import interactor.MarkSent
|
||||
import javax.inject.Inject
|
||||
|
||||
class MessageSentReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var markSent: MarkSent
|
||||
@Inject lateinit var markFailed: MarkFailed
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
appComponent.inject(this)
|
||||
|
||||
val id = intent.getLongExtra("id", 0L)
|
||||
|
||||
when (resultCode) {
|
||||
Activity.RESULT_OK -> {
|
||||
val pendingResult = goAsync()
|
||||
markSent.execute(id) { pendingResult.finish() }
|
||||
}
|
||||
|
||||
SmsManager.RESULT_ERROR_GENERIC_FAILURE,
|
||||
SmsManager.RESULT_ERROR_NO_SERVICE,
|
||||
SmsManager.RESULT_ERROR_NULL_PDU,
|
||||
SmsManager.RESULT_ERROR_RADIO_OFF -> {
|
||||
val pendingResult = goAsync()
|
||||
markFailed.execute(MarkFailed.Params(id, resultCode)) { pendingResult.finish() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.provider.Telephony
|
||||
import com.google.android.mms.ContentType
|
||||
import com.google.android.mms.pdu.GenericPdu
|
||||
import com.google.android.mms.pdu.NotificationInd
|
||||
import com.google.android.mms.pdu.PduHeaders
|
||||
import com.google.android.mms.pdu.PduParser
|
||||
import timber.log.Timber
|
||||
|
||||
class MmsReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION == intent.action && ContentType.MMS_MESSAGE == intent.type) {
|
||||
val data = intent.getByteArrayExtra("data")
|
||||
val parser = PduParser(data)
|
||||
var pdu: GenericPdu? = null
|
||||
|
||||
try {
|
||||
pdu = parser.parse()
|
||||
} catch (e: RuntimeException) {
|
||||
Timber.e("Invalid MMS WAP push", e)
|
||||
}
|
||||
|
||||
if (pdu == null) {
|
||||
Timber.e("Invalid WAP push data")
|
||||
return
|
||||
}
|
||||
|
||||
when (pdu.messageType) {
|
||||
PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND -> {
|
||||
val notificationInd = pdu as NotificationInd
|
||||
val location = String(notificationInd.contentLocation)
|
||||
Timber.v("Received MMS notification: " + location)
|
||||
}
|
||||
|
||||
PduHeaders.MESSAGE_TYPE_DELIVERY_IND -> {
|
||||
Timber.v("Received delivery report")
|
||||
}
|
||||
|
||||
PduHeaders.MESSAGE_TYPE_READ_ORIG_IND -> {
|
||||
Timber.v("Received read report")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.support.v4.app.RemoteInput
|
||||
import common.di.appComponent
|
||||
import interactor.MarkRead
|
||||
import interactor.SendMessage
|
||||
import javax.inject.Inject
|
||||
|
||||
class RemoteMessagingReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var sendMessage: SendMessage
|
||||
@Inject lateinit var markRead: MarkRead
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
appComponent.inject(this)
|
||||
|
||||
val remoteInput = RemoteInput.getResultsFromIntent(intent)
|
||||
val bundle = intent.extras
|
||||
if (remoteInput != null && bundle != null) {
|
||||
val address = bundle.getString("address")
|
||||
val threadId = bundle.getLong("threadId")
|
||||
val body = remoteInput.getCharSequence("body").toString()
|
||||
markRead.execute(threadId)
|
||||
sendMessage.execute(SendMessage.Params(threadId, address, body))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.receiver
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.provider.Telephony.Sms
|
||||
import common.di.appComponent
|
||||
import interactor.ReceiveMessage
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class SmsReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var receiveMessage: ReceiveMessage
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
Timber.v("Received SMS: $intent")
|
||||
appComponent.inject(this)
|
||||
|
||||
val messages = Sms.Intents.getMessagesFromIntent(intent)
|
||||
messages?.takeIf { it.isNotEmpty() }?.let { messages ->
|
||||
val address = messages[0].displayOriginatingAddress
|
||||
val time = messages[0].timestampMillis
|
||||
val body: String = messages
|
||||
.map { message -> message.displayMessageBody }
|
||||
.reduce { body, new -> body + new }
|
||||
|
||||
val pendingResult = goAsync()
|
||||
receiveMessage.execute(ReceiveMessage.Params(address, body, time), { pendingResult.finish() })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Moez Bhatti <moez.bhatti@gmail.com>
|
||||
*
|
||||
* This file is part of QKSMS.
|
||||
*
|
||||
* QKSMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* QKSMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package presentation.service
|
||||
|
||||
import android.app.IntentService
|
||||
import android.content.Intent
|
||||
|
||||
class HeadlessSmsSendService : IntentService("HeadlessSmsSendService") {
|
||||
|
||||
override fun onHandleIntent(p0: Intent?) {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user