Skip to content

Commit

Permalink
Update gradle & build tools & library versions && Fix kotlin type pro…
Browse files Browse the repository at this point in the history
…blem
  • Loading branch information
renyuneyun committed Nov 17, 2019
1 parent c125c73 commit f22090b
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -11,7 +11,7 @@ cache:

env:
global:
- COMPILE_SDK_VERSION=28 # Same as `compileSdkVersion` in build.gradle
- COMPILE_SDK_VERSION=29 # Same as `compileSdkVersion` in build.gradle
- EMULATOR_API=22
- BUILD_TOOLS_VERSION=28.0.3 # Same as `buildToolsVersion` in build.gradle
- ABI=armeabi-v7a # ARM ABI v7a by default
Expand Down
14 changes: 7 additions & 7 deletions app/build.gradle
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
compileSdkVersion 29
buildToolsVersion '28.0.3'
defaultConfig {
applicationId 'ryey.easer'
Expand Down Expand Up @@ -52,19 +52,19 @@ android {
}

dependencies {
def acraVersion = '5.1.3'
def acraVersion = '5.3.0'

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':plugin')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.60"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.google.guava:guava:27.1-android'
implementation 'com.orhanobut:logger:2.1.1'
implementation 'com.google.guava:guava:28.1-android'
implementation 'com.orhanobut:logger:2.2.0'
implementation 'org.apmem.tools:layouts:1.10@aar'
implementation 'se.emilsjolander:stickylistheaders:2.7.0'
implementation 'com.github.TellH:RecyclerTreeView:1.2.0'
Expand All @@ -75,7 +75,7 @@ dependencies {
implementation "ch.acra:acra-core:$acraVersion"
implementation "ch.acra:acra-toast:$acraVersion"
testImplementation 'junit:junit:4.12'
testImplementation 'org.json:json:20160810'
testImplementation 'org.json:json:20190722'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
}
}
30 changes: 30 additions & 0 deletions app/src/main/java/ryey/easer/commons/UnexpectedBehaviourError.java
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2016 - 2019 Rui Zhao <renyuneyun@gmail.com>
*
* This file is part of Easer.
*
* Easer 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.
*
* Easer 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 Easer. If not, see <http://www.gnu.org/licenses/>.
*/

package ryey.easer.commons;

public class UnexpectedBehaviourError extends Exception {
public UnexpectedBehaviourError(String msg) {
super(msg);
}

public UnexpectedBehaviourError(Exception e) {
super(e);
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/ryey/easer/core/EaserStatusWidget.kt
Expand Up @@ -53,7 +53,7 @@ class EaserStatusWidget : AppWidgetProvider() {
if (ACTION_CLICK == intent?.action || EHService.ACTION_STATE_CHANGED == intent?.action) {
val views = createViews(context)
AppWidgetManager.getInstance(context)
.updateAppWidget(ComponentName(context, EaserStatusWidget::class.java), views)
.updateAppWidget(ComponentName(context!!, EaserStatusWidget::class.java), views)
} else {
super.onReceive(context, intent)
}
Expand Down
Expand Up @@ -38,11 +38,11 @@ class RemoteOperationPluginInfo(packageName: String, pluginId: String,
})

constructor(parcel: Parcel) : this(
parcel.readString()!!,
parcel.readString()!!,
parcel.readString()!!,
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readString())
parcel.readString()!!)

override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(packageName)
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/ryey/easer/core/RemotePluginInfo.kt
Expand Up @@ -29,10 +29,10 @@ open class RemotePluginInfo(val packageName: String, val pluginId: String, val p
get() = field ?: "$packageName.EditDataActivity"

constructor(parcel: Parcel) : this(
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readString()!!,
parcel.readString()!!,
parcel.readString()!!,
parcel.readString()!!,
parcel.readString())

override fun writeToParcel(parcel: Parcel, flags: Int) {
Expand Down
85 changes: 43 additions & 42 deletions app/src/main/java/ryey/easer/core/RemotePluginRegistryService.kt
Expand Up @@ -24,12 +24,10 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.*
import android.util.Log
import androidx.collection.ArrayMap
import com.orhanobut.logger.Logger
import ryey.easer.commons.local_skill.operationskill.OperationData
import ryey.easer.core.RemotePluginCommunicationHelper.C
import ryey.easer.plugin.operation.Category
import ryey.easer.remote_plugin.RemoteOperationData
Expand All @@ -49,23 +47,26 @@ class RemotePluginRegistryService : Service() {
override fun onReceive(context: Context, intent: Intent) {
Logger.d("[RemotePluginRegistryService][onReceive] %s", intent)
if (RemotePlugin.ACTION_RESPONSE_PLUGIN_INFO == intent.action) {
val packageName = intent.getStringExtra(RemotePlugin.EXTRA_PACKAGE_NAME)
val pluginId = intent.getStringExtra(RemotePlugin.EXTRA_PLUGIN_ID)
val pluginName = intent.getStringExtra(RemotePlugin.EXTRA_PLUGIN_NAME)
val packageName = intent.getStringExtra(RemotePlugin.EXTRA_PACKAGE_NAME)!!
val pluginId = intent.getStringExtra(RemotePlugin.EXTRA_PLUGIN_ID)!!
val pluginName = intent.getStringExtra(RemotePlugin.EXTRA_PLUGIN_NAME)!!
val activityEditData = intent.getStringExtra(RemotePlugin.EXTRA_ACTIVITY_EDIT_DATA)
val pluginType = intent.getStringExtra(RemotePlugin.EXTRA_PLUGIN_TYPE)
//TODO: More types
assert(pluginType == RemotePlugin.TYPE_OPERATION_PLUGIN)
val categoryString = intent.getStringExtra(RemotePlugin.OperationPlugin.EXTRA_PLUGIN_CATEGORY)
val category = try {
Category.valueOf(categoryString)
if (categoryString != null)
Category.valueOf(categoryString)
else
Category.unknown
} catch (e: RuntimeException) {
Category.unknown
}
val info = RemoteOperationPluginInfo(packageName, pluginId, pluginName, activityEditData, category)
operationPluginInfos.add(info)
} else if (RemotePlugin.OperationPlugin.ACTION_TRIGGER_RESULT == intent.action) {
val jobId: ParcelUuid = intent.getParcelableExtra(RemotePlugin.EXTRA_MESSAGE_ID)
val jobId: ParcelUuid = intent.getParcelableExtra(RemotePlugin.EXTRA_MESSAGE_ID)!!
if (!intent.hasExtra(RemotePlugin.OperationPlugin.EXTRA_SUCCESS)) {
Logger.w("Remote Operation Plugin load Operation returned WITHOUT success value. Using `false` instead.")
}
Expand Down Expand Up @@ -154,41 +155,41 @@ class RemotePluginRegistryService : Service() {
reply.data.putParcelable(C.EXTRA_MESSAGE_ID, jobId)
reply.data.putParcelableArrayList(C.EXTRA_PLUGIN_LIST, ArrayList<RemoteOperationPluginInfo>(service.operationPluginInfos))
rMessenger.send(reply)
} else if (message.what == C.MSG_PARSE_OPERATION_DATA) {
// FIXME: This branch seems not to be necessary nor possible. Remove when adding Event and Condition.
throw IllegalAccessError("This message is not yet in use")
Logger.d("[RemotePluginRegistryService] MSG_PARSE_OPERATION_DATA")
val id = message.data.getString(C.EXTRA_PLUGIN_ID)
val pluginInfo = service.infoForId(id)
val reply = Message.obtain()
reply.what = C.MSG_PARSE_OPERATION_DATA_RESPONSE
if (pluginInfo == null) {
rMessenger.send(reply)
} else {
val data = message.data.getString(C.EXTRA_RAW_DATA)
val receiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(p0: Context?, p1: Intent?) {
if (RemotePlugin.ACTION_RESPONSE_PARSE_DATA == p1?.action) {
val operationData: OperationData = p1.getParcelableExtra(RemotePlugin.EXTRA_DATA)
reply.data.putParcelable(C.EXTRA_PLUGIN_DATA, operationData)
rMessenger.send(reply)
service.unregisterReceiver(this)
}
}
}
val uri: Uri = Uri.parse("re_ser://%d".format(receiver.hashCode()))
val filter = IntentFilter()
filter.addAction(RemotePlugin.ACTION_RESPONSE_PARSE_DATA)
filter.addDataScheme(uri.scheme)
filter.addDataAuthority(uri.authority, null)
filter.addDataPath(uri.path, PatternMatcher.PATTERN_LITERAL)
service.registerReceiver(receiver, filter)
val intent = Intent(RemotePlugin.ACTION_REQUEST_PARSE_DATA)
// intent.data = uri
intent.`package` = pluginInfo.packageName
intent.putExtra(RemotePlugin.EXTRA_DATA, data)
service.sendBroadcast(intent)
}
// } else if (message.what == C.MSG_PARSE_OPERATION_DATA) {
// // FIXME: This branch seems not to be necessary nor possible. Remove when adding Event and Condition.
// throw IllegalAccessError("This message is not yet in use")
// Logger.d("[RemotePluginRegistryService] MSG_PARSE_OPERATION_DATA")
// val id = message.data.getString(C.EXTRA_PLUGIN_ID)
// val pluginInfo = service.infoForId(id)
// val reply = Message.obtain()
// reply.what = C.MSG_PARSE_OPERATION_DATA_RESPONSE
// if (pluginInfo == null) {
// rMessenger.send(reply)
// } else {
// val data = message.data.getString(C.EXTRA_RAW_DATA)
// val receiver: BroadcastReceiver = object : BroadcastReceiver() {
// override fun onReceive(p0: Context?, p1: Intent?) {
// if (RemotePlugin.ACTION_RESPONSE_PARSE_DATA == p1?.action) {
// val operationData: OperationData = p1.getParcelableExtra(RemotePlugin.EXTRA_DATA)
// reply.data.putParcelable(C.EXTRA_PLUGIN_DATA, operationData)
// rMessenger.send(reply)
// service.unregisterReceiver(this)
// }
// }
// }
// val uri: Uri = Uri.parse("re_ser://%d".format(receiver.hashCode()))
// val filter = IntentFilter()
// filter.addAction(RemotePlugin.ACTION_RESPONSE_PARSE_DATA)
// filter.addDataScheme(uri.scheme)
// filter.addDataAuthority(uri.authority, null)
// filter.addDataPath(uri.path, PatternMatcher.PATTERN_LITERAL)
// service.registerReceiver(receiver, filter)
// val intent = Intent(RemotePlugin.ACTION_REQUEST_PARSE_DATA)
//// intent.data = uri
// intent.`package` = pluginInfo.packageName
// intent.putExtra(RemotePlugin.EXTRA_DATA, data)
// service.sendBroadcast(intent)
// }
} else if (message.what == C.MSG_TRIGGER_OPERATION) {
Log.d("RemoPlRegistry", "MSG_TRIGGER_OPERATION")
message.data.classLoader = String::class.java.classLoader
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/ryey/easer/core/ServiceUtils.kt
Expand Up @@ -59,6 +59,7 @@ class ServiceUtils {
builder = NotificationCompat.Builder(service, channelId)
builder.setAutoCancel(true)
} else {
@Suppress("DEPRECATION")
builder = NotificationCompat.Builder(service)
.setPriority(NotificationCompat.PRIORITY_MIN)
}
Expand Down
Expand Up @@ -110,7 +110,7 @@ class ActivityLogService : Service() {

@Synchronized
fun recordProfile(bundle: Bundle) {
val activityLog: ActivityLog = bundle.getParcelable(EXTRA_ACTIVITY_LOG)
val activityLog: ActivityLog = bundle.getParcelable(EXTRA_ACTIVITY_LOG)!!
activityLogList.addLast(activityLog)
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ryey/easer/core/log/ProfileLoadedLog.kt
Expand Up @@ -46,7 +46,7 @@ class ProfileLoadedLog : BasicLog {
}

constructor(parcel: Parcel) : super(parcel) {
profileName = parcel.readString()
profileName = parcel.readString()!!
}

override fun writeToParcel(parcel: Parcel, flags: Int) {
Expand Down
Expand Up @@ -57,15 +57,15 @@ class ScriptSatisfactionLog : BasicLog {
return result
}

override fun writeToParcel(parcel: Parcel, i: Int) {
super.writeToParcel(parcel, i)
override fun writeToParcel(parcel: Parcel, flags: Int) {
super.writeToParcel(parcel, flags)
parcel.writeString(scriptName)
parcel.writeByte(if (satisfaction) 1 else 0)
parcel.writeString(profileName)
}

protected constructor(parcel: Parcel): super(parcel) {
scriptName = parcel.readString()
scriptName = parcel.readString()!!
satisfaction = parcel.readByte() > 0
profileName = parcel.readString()
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ryey/easer/core/log/ServiceLog.kt
Expand Up @@ -51,7 +51,7 @@ class ServiceLog : BasicLog {
}

constructor(parcel: Parcel) : super(parcel) {
serviceName = parcel.readString()
serviceName = parcel.readString()!!
start = parcel.readByte() > 0
}

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/ryey/easer/core/ui/PivotFragment.kt
Expand Up @@ -49,7 +49,7 @@ class PivotFragment: Fragment() {
private val lotusStatusReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val satisfied = intent!!.getBooleanExtra(Lotus.EXTRA_SATISFACTION, false)
val id = intent.getStringExtra(Lotus.EXTRA_SCRIPT_ID)
val id = intent.getStringExtra(Lotus.EXTRA_SCRIPT_ID)!!
updateNodeStatus(id, satisfied)
}
}
Expand Down Expand Up @@ -186,15 +186,15 @@ class PivotFragment: Fragment() {
}

private fun createBasicGraph(): Pair<Graph, Map<String, Node>> {
val scriptDataStorage = ScriptDataStorage(context)
val scriptDataStorage = ScriptDataStorage(context!!)

return convertToGraph(scriptDataStorage.logicGraph, null)
}

private fun createAdvancedGraph(): Pair<Graph, Map<String, Node>> {
val statusMap: Map<String, Boolean> = binder!!.lotusStatusMap()

val scriptDataStorage = ScriptDataStorage(context)
val scriptDataStorage = ScriptDataStorage(context!!)

return convertToGraph(scriptDataStorage.logicGraph, statusMap)
}
Expand Down Expand Up @@ -223,7 +223,7 @@ class PivotFragment: Fragment() {
}

while (queue.isNotEmpty()) {
val logicNode = queue.poll()
val logicNode = queue.poll()!!
val node = nodeMap[logicNode.id]!!
logicNode.script.profileName?.let {
val profileNode = Node(ProfileInfo(it))
Expand Down
Expand Up @@ -48,7 +48,7 @@ class PickPredecessorsDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
val selectedItems = ArrayList<Int>() // Where we track the selected items
val candidates = ScriptDataStorage(activity).list()
val candidates = ScriptDataStorage(it).list()
arguments?.getStringArray(ARG_EXCLUDED)?.let { excludedPredecessors ->
for (excluded in excludedPredecessors) {
candidates.remove(excluded)
Expand Down
Expand Up @@ -25,12 +25,17 @@ import android.content.Intent
import android.content.IntentFilter
import android.telephony.TelephonyManager
import ryey.easer.Utils
import ryey.easer.commons.UnexpectedBehaviourError

internal class CallReceiver(private val callEventHandler: CallEventHandler) : BroadcastReceiver() {

override fun onReceive(context: Context, intent: Intent) {
val state: String = intent.getStringExtra(TelephonyManager.EXTRA_STATE)
val number: String = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)
val state: String = intent.getStringExtra(TelephonyManager.EXTRA_STATE)!!
val number: String = try {
intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER)!!
} catch (e: Error) {
throw UnexpectedBehaviourError("CallReceiver got intent but without TelephonyManager.EXTRA_INCOMING_NUMBER")
}
when (state) {
TelephonyManager.EXTRA_STATE_IDLE -> callEventHandler.onIdle(number)
TelephonyManager.EXTRA_STATE_RINGING -> callEventHandler.onRinging(number)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.40'
ext.kotlin_version = '1.3.50'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down

0 comments on commit f22090b

Please sign in to comment.