Commit f0be9a3f authored by Mygod's avatar Mygod

Fix new nullability issues

parent 98ed1f78
......@@ -26,7 +26,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-rc02'
classpath 'com.android.tools.build:gradle:3.4.0-rc03'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.21.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
......
......@@ -30,10 +30,10 @@ import com.github.shadowsocks.utils.signaturesCompat
abstract class ResolvedPlugin(protected val resolveInfo: ResolveInfo) : Plugin() {
protected abstract val metaData: Bundle
override val id: String by lazy { metaData.getString(PluginContract.METADATA_KEY_ID) }
override val id: String by lazy { metaData.getString(PluginContract.METADATA_KEY_ID)!! }
override val label: CharSequence by lazy { resolveInfo.loadLabel(app.packageManager) }
override val icon: Drawable by lazy { resolveInfo.loadIcon(app.packageManager) }
override val defaultConfig: String by lazy { metaData.getString(PluginContract.METADATA_KEY_DEFAULT_CONFIG) }
override val defaultConfig: String? by lazy { metaData.getString(PluginContract.METADATA_KEY_DEFAULT_CONFIG) }
override val packageName: String get() = resolveInfo.resolvePackageName
override val trusted by lazy {
Core.getPackageInfo(packageName).signaturesCompat.any(PluginManager.trustedSignatures::contains)
......
......@@ -264,8 +264,8 @@ class AppManager : AppCompatActivity() {
return true
}
R.id.action_export_clipboard -> {
clipboard.primaryClip = ClipData.newPlainText(Key.individual,
"${DataStore.bypass}\n${DataStore.individual}")
clipboard.setPrimaryClip(ClipData.newPlainText(Key.individual,
"${DataStore.bypass}\n${DataStore.individual}"))
Snackbar.make(list, R.string.action_export_msg, Snackbar.LENGTH_LONG).show()
return true
}
......
......@@ -208,7 +208,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
true
}
R.id.action_export_clipboard -> {
clipboard.primaryClip = ClipData.newPlainText(null, this.item.toString())
clipboard.setPrimaryClip(ClipData.newPlainText(null, this.item.toString()))
true
}
else -> false
......@@ -404,7 +404,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
R.id.action_export_clipboard -> {
val profiles = ProfileManager.getAllProfiles()
(activity as MainActivity).snackbar().setText(if (profiles != null) {
clipboard.primaryClip = ClipData.newPlainText(null, profiles.joinToString("\n"))
clipboard.setPrimaryClip(ClipData.newPlainText(null, profiles.joinToString("\n")))
R.string.action_export_msg
} else R.string.action_export_err).show()
true
......@@ -436,7 +436,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
try {
ProfileManager.createProfilesFromJson(data!!.datas.asSequence().map {
activity.contentResolver.openInputStream(it)
})
}.filterNotNull())
} catch (e: Exception) {
activity.snackbar(e.readableMessage).show()
}
......@@ -446,7 +446,7 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
try {
ProfileManager.createProfilesFromJson(data!!.datas.asSequence().map {
activity.contentResolver.openInputStream(it)
}, true)
}.filterNotNull(), true)
} catch (e: Exception) {
activity.snackbar(e.readableMessage).show()
}
......
......@@ -424,7 +424,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
is URL -> acl.urls.add(it)
}
}
clipboard.primaryClip = ClipData.newPlainText(null, acl.toString())
clipboard.setPrimaryClip(ClipData.newPlainText(null, acl.toString()))
}
override fun onMenuItemClick(item: MenuItem): Boolean = when (item.itemId) {
......
......@@ -49,7 +49,7 @@ import androidx.core.os.bundleOf
*&lt;/manifest&gt;</pre>
*/
abstract class NativePluginProvider : ContentProvider() {
override fun getType(p0: Uri?): String = "application/x-elf"
override fun getType(uri: Uri): String? = "application/x-elf"
override fun onCreate(): Boolean = true
......@@ -61,7 +61,7 @@ abstract class NativePluginProvider : ContentProvider() {
protected abstract fun populateFiles(provider: PathProvider)
override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?,
sortOrder: String?): Cursor {
sortOrder: String?): Cursor? {
check(selection == null && selectionArgs == null && sortOrder == null)
val result = MatrixCursor(projection)
populateFiles(PathProvider(uri, result))
......@@ -78,8 +78,8 @@ abstract class NativePluginProvider : ContentProvider() {
*/
open fun getExecutable(): String = throw UnsupportedOperationException()
abstract fun openFile(uri: Uri?): ParcelFileDescriptor
override fun openFile(uri: Uri?, mode: String?): ParcelFileDescriptor {
abstract fun openFile(uri: Uri): ParcelFileDescriptor
override fun openFile(uri: Uri, mode: String): ParcelFileDescriptor {
check(mode == "r")
return openFile(uri)
}
......@@ -90,8 +90,9 @@ abstract class NativePluginProvider : ContentProvider() {
}
// Methods that should not be used
override fun insert(p0: Uri?, p1: ContentValues?): Uri = throw UnsupportedOperationException()
override fun update(p0: Uri?, p1: ContentValues?, p2: String?, p3: Array<out String>?): Int =
override fun insert(uri: Uri, values: ContentValues?): Uri? = throw UnsupportedOperationException()
override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int =
throw UnsupportedOperationException()
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int =
throw UnsupportedOperationException()
override fun delete(p0: Uri?, p1: String?, p2: Array<out String>?): Int = throw UnsupportedOperationException()
}
......@@ -297,7 +297,7 @@ class MainPreferenceFragment : LeanbackPreferenceFragmentCompat(), ShadowsocksCo
try {
ProfileManager.createProfilesFromJson(data!!.datas.asSequence().map {
context.contentResolver.openInputStream(it)
}, true)
}.filterNotNull(), true)
} catch (e: Exception) {
printLog(e)
Toast.makeText(context, e.readableMessage, Toast.LENGTH_SHORT).show()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment