diff --git a/build.gradle b/build.gradle index ba4affe65..1212dc3b1 100644 --- a/build.gradle +++ b/build.gradle @@ -2,13 +2,13 @@ buildscript { repositories { - jcenter() + mavenCentral() maven { url "https://plugins.gradle.org/m2/" } google() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.0' + classpath 'com.android.tools.build:gradle:4.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -20,16 +20,17 @@ allprojects { projectVersionCode = 515 projectVersionName = '4.1.6' - globalCompileSdkVersion = 29 - globalBuildToolsVersion = "29.0.3" + globalCompileSdkVersion = 30 + globalBuildToolsVersion = "30.0.3" globalMinSdkVersion = 16 - globalTargetSdkVersion = 29 + globalTargetSdkVersion = 30 } repositories { mavenLocal() - jcenter() + jcenter()// exoplayer and glide-transformations still using jcenter + mavenCentral() maven { url "https://jitpack.io" } google() } @@ -38,12 +39,12 @@ allprojects { subprojects { buildscript { ext { - kotlinVersion = '1.3.72' + kotlinVersion = '1.4.31' sharedVersions = [ Kotlin : "${kotlinVersion}", LoganSquare : '1.3.7', - Jackson : '2.11.1', + Jackson : '2.12.1', ParcelablePlease : '1.0.2', ExportablePreferences: '0.9.7', diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 21e622da6..c86a4b44f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Mon Mar 01 10:46:00 CST 2021 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip diff --git a/twidere.component.nyan/build.gradle b/twidere.component.nyan/build.gradle index 13f584512..33e43faa4 100644 --- a/twidere.component.nyan/build.gradle +++ b/twidere.component.nyan/build.gradle @@ -38,5 +38,5 @@ android { } dependencies { - implementation 'androidx.core:core:1.3.0' + implementation 'androidx.core:core:1.3.2' } diff --git a/twidere/build.gradle b/twidere/build.gradle index e63e8dd14..b4e496e07 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -175,8 +175,8 @@ ext { libVersions = [ Kovenant : '3.3.0', Mime4J : '0.7.2', - Dagger : '2.28.1', - Exoplayer : '2.11.7', + Dagger : '2.32', + Exoplayer : '2.13.2', Glide : '4.11.0', MediaViewerLibrary: '0.9.23', Stetho : '1.5.1', @@ -197,20 +197,18 @@ dependencies { /** Android support **/ implementation 'androidx.annotation:annotation:1.1.0' - implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' + implementation 'androidx.appcompat:appcompat:1.3.0-beta01' implementation 'androidx.browser:browser:1.2.0' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'androidx.core:core:1.3.0' - implementation 'androidx.core:core-ktx:1.3.0' - implementation 'androidx.drawerlayout:drawerlayout:1.1.0-alpha01' - implementation 'androidx.exifinterface:exifinterface:1.2.0' + implementation 'androidx.core:core-ktx:1.3.2' + implementation 'androidx.drawerlayout:drawerlayout:1.1.1' + implementation 'androidx.exifinterface:exifinterface:1.3.1' implementation 'androidx.legacy:legacy-support-core-ui:1.0.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.palette:palette-ktx:1.0.0' - implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.preference:preference-ktx:1.1.1' implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.android.material:material:1.3.0' /** Third-party dependencies **/ @@ -236,7 +234,7 @@ dependencies { implementation "com.hannesdorfmann.parcelableplease:annotation:${sharedVersions['ParcelablePlease']}" kapt "com.hannesdorfmann.parcelableplease:processor:${sharedVersions['ParcelablePlease']}" implementation 'com.squareup.okhttp3:okhttp:3.12.12' - implementation 'com.squareup.okio:okio:2.6.0' + implementation 'com.squareup.okio:okio:2.9.0' implementation 'com.lnikkila:extendedtouchview:0.1.1' implementation "com.google.dagger:dagger:${libVersions['Dagger']}" kapt "com.google.dagger:dagger-compiler:${libVersions['Dagger']}" @@ -244,8 +242,8 @@ dependencies { implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.0' implementation 'net.ypresto.androidtranscoder:android-transcoder:0.3.0' implementation 'org.jsoup:jsoup:1.13.1' - implementation "com.google.android.exoplayer:exoplayer-core:${libVersions['Exoplayer']}" - implementation "com.google.android.exoplayer:exoplayer-ui:${libVersions['Exoplayer']}" + implementation "com.google.android.exoplayer:exoplayer:${libVersions['Exoplayer']}" +// implementation "com.google.android.exoplayer:exoplayer-ui:${libVersions['Exoplayer']}" implementation "com.google.android.exoplayer:extension-okhttp:${libVersions['Exoplayer']}" implementation "com.github.bumptech.glide:glide:${libVersions['Glide']}" implementation "com.github.bumptech.glide:okhttp3-integration:${libVersions['Glide']}@aar" @@ -287,7 +285,8 @@ dependencies { /** Flavor dependencies **/ fdroidImplementation 'org.osmdroid:osmdroid-android:5.6.5' - fdroidImplementation 'ch.acra:acra:4.11' + fdroidImplementation 'ch.acra:acra-mail:5.7.0' + fdroidImplementation 'ch.acra:acra-dialog:5.7.0' if (enableGoogleVariant) { // START Non-FOSS component @@ -308,7 +307,7 @@ dependencies { debugImplementation "com.facebook.stetho:stetho:${libVersions['Stetho']}" debugImplementation "com.facebook.stetho:stetho-okhttp3:${libVersions['Stetho']}" debugImplementation 'com.github.mariotaku:StethoBeanShellREPL:0.5' - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.3' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6' debugImplementation('com.jayway.jsonpath:json-path:2.4.0') { exclude group: 'net.minidev', module: 'json-smart' } @@ -317,10 +316,10 @@ dependencies { /** Testing **/ - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.annotation:annotation:1.1.0' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test:rules:1.2.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.2' + androidTestImplementation 'androidx.test:rules:1.3.0' // https://g.co/androidstudio/app-test-app-conflict androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.2' } diff --git a/twidere/src/fdroid/kotlin/org/mariotaku/twidere/activity/CrashReportDialogActivity.kt b/twidere/src/fdroid/kotlin/org/mariotaku/twidere/activity/CrashReportDialogActivity.kt index f67f98272..aa2fe4510 100644 --- a/twidere/src/fdroid/kotlin/org/mariotaku/twidere/activity/CrashReportDialogActivity.kt +++ b/twidere/src/fdroid/kotlin/org/mariotaku/twidere/activity/CrashReportDialogActivity.kt @@ -38,15 +38,4 @@ class CrashReportDialogActivity : CrashReportDialog() { view.setPadding(padding, padding, padding, padding) return view } - - override fun getMainView(): View { - val text = TextView(this) - TextViewCompat.setTextAppearance(text, android.R.style.TextAppearance_DeviceDefault_Medium) - val dialogTextId = this.config.resDialogText() - if (dialogTextId != 0) { - text.text = this.getText(dialogTextId) - } - return text - } - } diff --git a/twidere/src/fdroid/kotlin/org/mariotaku/twidere/util/ACRAAnalyzer.kt b/twidere/src/fdroid/kotlin/org/mariotaku/twidere/util/ACRAAnalyzer.kt index 27e9353d5..4b83daaf7 100644 --- a/twidere/src/fdroid/kotlin/org/mariotaku/twidere/util/ACRAAnalyzer.kt +++ b/twidere/src/fdroid/kotlin/org/mariotaku/twidere/util/ACRAAnalyzer.kt @@ -27,8 +27,10 @@ import android.app.Application import android.content.SharedPreferences import android.os.Build import org.acra.ACRA -import org.acra.ReportingInteractionMode -import org.acra.config.ConfigurationBuilder +import org.acra.config.CoreConfigurationBuilder +import org.acra.config.DialogConfigurationBuilder +import org.acra.config.MailSenderConfigurationBuilder +import org.acra.data.StringFormat import org.mariotaku.kpreferences.get import org.mariotaku.ktextension.addOnAccountsUpdatedListenerSafe import org.mariotaku.twidere.BuildConfig @@ -40,6 +42,7 @@ import org.mariotaku.twidere.constant.themeBackgroundAlphaKey import org.mariotaku.twidere.constant.themeBackgroundOptionKey import org.mariotaku.twidere.constant.themeKey + /** * Created by mariotaku on 2017/5/8. */ @@ -56,14 +59,17 @@ class ACRAAnalyzer : Analyzer() { } override fun init(application: Application) { - val config = ConfigurationBuilder(application) - .setReportingInteractionMode(ReportingInteractionMode.DIALOG) - .setResDialogText(R.string.message_app_crashed) - .setResDialogTheme(R.style.Theme_Twidere_NoDisplay_DayNight) + val builder = CoreConfigurationBuilder(application) + builder.setBuildConfigClass(BuildConfig::class.java).setReportFormat(StringFormat.JSON) + builder.getPluginConfigurationBuilder(DialogConfigurationBuilder::class.java) + .setResText(R.string.message_app_crashed) + .setResTheme(R.style.Theme_Twidere_NoDisplay_DayNight) .setReportDialogClass(CrashReportDialogActivity::class.java) + .setEnabled(true) + builder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder::class.java) .setMailTo(TWIDERE_PROJECT_EMAIL) - .build() - ACRA.init(application, config) + .setEnabled(true) + ACRA.init(application, builder) val reporter = ACRA.getErrorReporter() reporter.putCustomData("debug", BuildConfig.DEBUG.toString()) reporter.putCustomData("build.brand", Build.BRAND) diff --git a/twidere/src/main/kotlin/org/mariotaku/ktextension/IntentExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/ktextension/IntentExtensions.kt index 24fd51edc..728b8e9f4 100644 --- a/twidere/src/main/kotlin/org/mariotaku/ktextension/IntentExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/ktextension/IntentExtensions.kt @@ -23,7 +23,7 @@ import android.content.Intent import android.os.Parcelable inline fun Intent.getTypedArrayExtra(key: String): Array { - val extra = getParcelableArrayExtra(key) + val extra = getParcelableArrayExtra(key) ?: emptyArray() return Array(extra.size) { extra[it] as T } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt index bf7e02247..12a0c476e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BaseActivity.kt @@ -196,9 +196,10 @@ open class BaseActivity : ChameleonActivity(), IBaseActivity, IThe private set override fun getSystemWindowInsets(caller: Fragment, insets: Rect): Boolean { - if (systemWindowsInsets == null) return false - insets.set(systemWindowsInsets) - return true + return systemWindowsInsets?.let { + insets.set(it) + true + } ?: false } override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BrowserSignInActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BrowserSignInActivity.kt index 98359f2d5..eb78a336f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BrowserSignInActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/BrowserSignInActivity.kt @@ -70,7 +70,7 @@ class BrowserSignInActivity : BaseActivity() { setSupportMultipleWindows(true) } - webView.loadUrl(intent.dataString) + intent.dataString?.let { webView.loadUrl(it) } } override fun onDestroy() { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt index d0d557e1f..0bfa3f573 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ComposeActivity.kt @@ -124,6 +124,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener // Utility classes @Inject lateinit var extractor: Extractor + @Inject lateinit var locationManager: LocationManager @@ -362,7 +363,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener statusShortenerUsed = !ComponentPickerPreference.isNoneValue(kPreferences[statusShortenerKey]) if (kPreferences[attachLocationKey]) { if (checkAnySelfPermissionsGranted(AndroidPermission.ACCESS_COARSE_LOCATION, - AndroidPermission.ACCESS_FINE_LOCATION)) { + AndroidPermission.ACCESS_FINE_LOCATION)) { try { startLocationUpdateIfEnabled() } catch (e: SecurityException) { @@ -379,8 +380,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener saveAccountSelection() saveVisibility() try { - if (locationListener != null) { - locationManager.removeUpdates(locationListener) + locationListener?.let { + locationManager.removeUpdates(it) locationListener = null } } catch (ignore: SecurityException) { @@ -397,8 +398,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener if (resultCode == Activity.RESULT_OK && data != null) { val src = MediaPickerActivity.getMediaUris(data) TaskStarter.execute(AddMediaTask(this, src, null, - copySrc = false, - deleteSrc = false + copySrc = false, + deleteSrc = false )) val extras = data.getBundleExtra(MediaPickerActivity.EXTRA_EXTRAS) if (extras?.getBoolean(EXTRA_IS_POSSIBLY_SENSITIVE) == true) { @@ -417,9 +418,9 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener REQUEST_EXTENSION_COMPOSE -> { if (resultCode == Activity.RESULT_OK && data != null) { // The latter two is for compatibility - val text = data.getCharSequenceExtra(Intent.EXTRA_TEXT) ?: - data.getStringExtra(EXTRA_TEXT) ?: - data.getStringExtra(EXTRA_APPEND_TEXT) + val text = data.getCharSequenceExtra(Intent.EXTRA_TEXT) + ?: data.getStringExtra(EXTRA_TEXT) + ?: data.getStringExtra(EXTRA_APPEND_TEXT) val isReplaceMode = data.getBooleanExtra(EXTRA_IS_REPLACE_MODE, data.getStringExtra(EXTRA_APPEND_TEXT) == null) if (text != null) { @@ -433,12 +434,12 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener updateTextCount() } - val src = MediaPickerActivity.getMediaUris(data)?.takeIf(Array::isNotEmpty) ?: - data.getParcelableExtra(EXTRA_IMAGE_URI)?.let { arrayOf(it) } + val src = MediaPickerActivity.getMediaUris(data)?.takeIf(Array::isNotEmpty) + ?: data.getParcelableExtra(EXTRA_IMAGE_URI)?.let { arrayOf(it) } if (src != null) { TaskStarter.execute(AddMediaTask(this, src, null, - copySrc = false, - deleteSrc = false + copySrc = false, + deleteSrc = false )) } } @@ -618,7 +619,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener when (ev.actionMasked) { MotionEvent.ACTION_DOWN -> { if (isAccountSelectorVisible && !TwidereViewUtils.hitView(ev, accountSelectorButton)) { - val layoutManager = accountSelector.layoutManager ?: return super.dispatchTouchEvent(ev) + val layoutManager = accountSelector.layoutManager + ?: return super.dispatchTouchEvent(ev) val clickedItem = (0 until layoutManager.childCount).any { val child = layoutManager.getChildAt(it) child != null && TwidereViewUtils.hitView(ev, child) @@ -786,8 +788,10 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener requestOrUpdateLocation() } else if (locationListener != null) { try { - locationManager.removeUpdates(locationListener) - locationListener = null + locationListener?.let { + locationManager.removeUpdates(it) + locationListener = null + } } catch (e: SecurityException) { //Ignore } @@ -1090,20 +1094,20 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener if (intent == null) return false val action = intent.action val hasVisibility = intent.hasExtra(EXTRA_VISIBILITY) - val hasAccountKeys: Boolean - when { + val hasAccountKeys: Boolean = when { intent.hasExtra(EXTRA_ACCOUNT_KEYS) -> { val accountKeys = intent.getTypedArrayExtra(EXTRA_ACCOUNT_KEYS) accountsAdapter.selectedAccountKeys = accountKeys - hasAccountKeys = true + true } intent.hasExtra(EXTRA_ACCOUNT_KEY) -> { - val accountKey = intent.getParcelableExtra(EXTRA_ACCOUNT_KEY) - accountsAdapter.selectedAccountKeys = arrayOf(accountKey) - hasAccountKeys = true + intent.getParcelableExtra(EXTRA_ACCOUNT_KEY)?.let { + accountsAdapter.selectedAccountKeys = arrayOf(it) + true + } ?: false } else -> { - hasAccountKeys = false + false } } when (action) { @@ -1114,8 +1118,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener if (stream != null) { val src = stream.toTypedArray() TaskStarter.execute(AddMediaTask(this, src, null, - copySrc = true, - deleteSrc = false + copySrc = true, + deleteSrc = false )) } } @@ -1126,8 +1130,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener if (data != null) { val src = arrayOf(data) TaskStarter.execute(AddMediaTask(this, src, null, - copySrc = true, - deleteSrc = false + copySrc = true, + deleteSrc = false )) } } @@ -1246,7 +1250,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener } private fun handleReplyMultipleIntent(screenNames: Array?, accountKey: UserKey?, - inReplyToStatus: ParcelableStatus?): Boolean { + inReplyToStatus: ParcelableStatus?): Boolean { if (screenNames == null || screenNames.isEmpty() || accountKey == null || inReplyToStatus == null) return false val myScreenName = DataStoreUtils.getAccountScreenName(this, accountKey) ?: return false @@ -1444,8 +1448,9 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener val provider = locationManager.getBestProvider(criteria, true) if (provider != null) { locationLabel.setText(R.string.getting_location) - locationListener = ComposeLocationListener(this) - locationManager.requestLocationUpdates(provider, 0, 0f, locationListener) + locationListener = ComposeLocationListener(this).also { + locationManager.requestLocationUpdates(provider, 0, 0f, it) + } val location = locationManager.getCachedLocation() if (location != null) { locationListener?.onLocationChanged(location) @@ -1716,7 +1721,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener } private fun getTwitterReplyTextAndMentions(text: String = editText.text?.toString().orEmpty(), - accounts: Array = accountsAdapter.selectedAccounts): ReplyTextAndMentions? { + accounts: Array = accountsAdapter.selectedAccounts): ReplyTextAndMentions? { val inReplyTo = inReplyToStatus ?: return null if (!ignoreMentions) return null val account = accounts.singleOrNull() ?: return null @@ -1841,8 +1846,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener editText.customSelectionActionModeCallback = this editText.imageInputListener = { contentInfo -> val task = AddMediaTask(this, arrayOf(contentInfo.contentUri), null, - copySrc = true, - deleteSrc = false + copySrc = true, + deleteSrc = false ) task.callback = { contentInfo.releasePermission() @@ -2083,11 +2088,11 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener } private class AddMediaTask(activity: ComposeActivity, sources: Array, types: IntArray?, - copySrc: Boolean, deleteSrc: Boolean) : AbsAddMediaTask<((List?) -> Unit)?>( + copySrc: Boolean, deleteSrc: Boolean) : AbsAddMediaTask<((List?) -> Unit)?>( activity, sources, types, copySrc, deleteSrc) { override fun afterExecute(callback: ((List?) -> Unit)?, - result: List?) { + result: List?) { callback?.invoke(result) val activity = context as? ComposeActivity ?: return activity.setProgressVisible(false) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/FragmentContentActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/FragmentContentActivity.kt index bba0c1141..cc563af91 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/FragmentContentActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/FragmentContentActivity.kt @@ -11,11 +11,14 @@ class FragmentContentActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) title = intent.getStringExtra(EXTRA_TITLE) - val fragment = Fragment.instantiate(this, intent.getStringExtra(EXTRA_FRAGMENT), + intent.getStringExtra(EXTRA_FRAGMENT)?.let { + Fragment.instantiate(this, it, intent.getBundleExtra(EXTRA_FRAGMENT_ARGUMENTS)) - val ft = supportFragmentManager.beginTransaction() - ft.replace(android.R.id.content, fragment) - ft.commit() + }?.let { fragment -> + val ft = supportFragmentManager.beginTransaction() + ft.replace(android.R.id.content, fragment) + ft.commit() + } } companion object { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt index 9211b48de..716310a1e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/HomeActivity.kt @@ -732,7 +732,9 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp } else { Utils.getDefaultAccountKey(this) } - IntentUtils.openSearch(this, accountKey, query) + if (query != null) { + IntentUtils.openSearch(this, accountKey, query) + } return -1 } val refreshOnStart = preferences.getBoolean(SharedPreferenceConstants.KEY_REFRESH_ON_START, false) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ImageCropperActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ImageCropperActivity.kt index c092e3d62..0fd3e170a 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ImageCropperActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/ImageCropperActivity.kt @@ -41,18 +41,18 @@ class ImageCropperActivity : BaseActivity(), CropImageView.OnSetImageUriComplete /** * Persist URI image to crop URI if specific permissions are required */ - private val cropImageUri: Uri get() = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_SOURCE) + private val cropImageUri: Uri? get() = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_SOURCE) /** * the options that were set for the crop image */ - private val options: CropImageOptions get() = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_OPTIONS) + private val options: CropImageOptions? get() = intent.getParcelableExtra(CropImage.CROP_IMAGE_EXTRA_OPTIONS) /** * Get Android uri to save the cropped image into.

* Use the given in options or create a temp file. */ - private val outputUri: Uri get() = options.outputUri + private val outputUri: Uri? get() = options?.outputUri @SuppressLint("NewApi") public override fun onCreate(savedInstanceState: Bundle?) { @@ -107,11 +107,13 @@ class ImageCropperActivity : BaseActivity(), CropImageView.OnSetImageUriComplete override fun onSetImageUriComplete(view: CropImageView, uri: Uri, error: Exception?) { if (error == null) { - if (options.initialCropWindowRectangle != null) { - cropImageView.cropRect = options.initialCropWindowRectangle - } - if (options.initialRotation > -1) { - cropImageView.rotatedDegrees = options.initialRotation + options?.let { options -> + if (options.initialCropWindowRectangle != null) { + cropImageView.cropRect = options.initialCropWindowRectangle + } + if (options.initialRotation > -1) { + cropImageView.rotatedDegrees = options.initialRotation + } } } else { setResult(null, error, 1) @@ -128,16 +130,18 @@ class ImageCropperActivity : BaseActivity(), CropImageView.OnSetImageUriComplete * Execute crop image and save the result to output uri. */ private fun cropImage() { - if (options.noOutputImage) { - setResult(null, null, 1) - } else { - val outputUri = outputUri - cropImageView.saveCroppedImageAsync(outputUri, - options.outputCompressFormat, - options.outputCompressQuality, - options.outputRequestWidth, - options.outputRequestHeight, - options.outputRequestSizeOptions) + options?.let { options -> + if (options.noOutputImage) { + setResult(null, null, 1) + } else { + val outputUri = outputUri + cropImageView.saveCroppedImageAsync(outputUri, + options.outputCompressFormat, + options.outputCompressQuality, + options.outputRequestWidth, + options.outputRequestHeight, + options.outputRequestSizeOptions) + } } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/KeyboardShortcutPreferenceCompatActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/KeyboardShortcutPreferenceCompatActivity.kt index 40c2d645e..76835f5d2 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/KeyboardShortcutPreferenceCompatActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/KeyboardShortcutPreferenceCompatActivity.kt @@ -111,7 +111,7 @@ class KeyboardShortcutPreferenceCompatActivity : BaseActivity(), OnClickListener return true } - private val contextTag: String + private val contextTag: String? get() = intent.getStringExtra(EXTRA_CONTEXT_TAG) private val keyAction: String? diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt index 45df854f6..339c8b716 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/SignInActivity.kt @@ -174,7 +174,9 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, when (requestCode) { REQUEST_EDIT_API -> { if (resultCode == Activity.RESULT_OK && data != null) { - apiConfig = data.getParcelableExtra(EXTRA_API_CONFIG) + data.getParcelableExtra(EXTRA_API_CONFIG)?.let { + apiConfig = it + } updateSignInType() } setSignInButton() @@ -193,7 +195,9 @@ class SignInActivity : BaseActivity(), OnClickListener, TextWatcher, val clientId = extras.getString(EXTRA_CLIENT_ID)!! val clientSecret = extras.getString(EXTRA_CLIENT_SECRET)!! - finishMastodonBrowserLogin(host, clientId, clientSecret, code) + if (code != null) { + finishMastodonBrowserLogin(host, clientId, clientSecret, code) + } } } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/UserListSelectorActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/UserListSelectorActivity.kt index d557a6de3..d3ecf9673 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/UserListSelectorActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/UserListSelectorActivity.kt @@ -137,7 +137,7 @@ class UserListSelectorActivity : BaseActivity(), when (requestCode) { REQUEST_SELECT_USER -> { if (resultCode == Activity.RESULT_OK && data != null) { - val user = data.getParcelableExtra(EXTRA_USER) + val user = data.getParcelableExtra(EXTRA_USER) ?: return loadUserLists(accountKey!!, user.key) } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/content/AbsStatusDialogActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/content/AbsStatusDialogActivity.kt index 1353c4a9a..41cdb97f9 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/content/AbsStatusDialogActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/content/AbsStatusDialogActivity.kt @@ -74,7 +74,9 @@ abstract class AbsStatusDialogActivity : BaseActivity() { return } val accountKey = data.getParcelableExtra(EXTRA_ACCOUNT_KEY) - showDialogFragment(accountKey, statusId, status) + if (accountKey != null) { + showDialogFragment(accountKey, statusId, status) + } return } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/premium/AbsExtraFeaturePurchaseActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/premium/AbsExtraFeaturePurchaseActivity.kt index 8736d063c..103c91a0f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/premium/AbsExtraFeaturePurchaseActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/premium/AbsExtraFeaturePurchaseActivity.kt @@ -11,7 +11,7 @@ import org.mariotaku.twidere.model.premium.PurchaseResult */ abstract class AbsExtraFeaturePurchaseActivity : BaseActivity() { - protected val requestingFeature: String get() = intent.getStringExtra(EXTRA_REQUESTING_FEATURE) + protected val requestingFeature: String? get() = intent.getStringExtra(EXTRA_REQUESTING_FEATURE) protected fun finishWithError(code: Int) { setResult(code) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/shortcut/AbsUserListRelatedShortcutCreatorActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/shortcut/AbsUserListRelatedShortcutCreatorActivity.kt index 6c281ea4b..b9fcd336c 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/shortcut/AbsUserListRelatedShortcutCreatorActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/shortcut/AbsUserListRelatedShortcutCreatorActivity.kt @@ -44,8 +44,10 @@ abstract class AbsUserListRelatedShortcutCreatorActivity : AbsShortcutCreatorAct } val list = data.getParcelableExtra(EXTRA_USER_LIST) val extras = data.getBundleExtra(EXTRA_EXTRAS) - val accountKey = extras.getParcelable(EXTRA_ACCOUNT_KEY) - onUserListSelected(accountKey, list) + val accountKey = extras?.getParcelable(EXTRA_ACCOUNT_KEY) + if (list != null) { + onUserListSelected(accountKey, list) + } } else -> { super.onActivityResult(requestCode, resultCode, data) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/shortcut/AbsUserRelatedShortcutCreatorActivity.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/shortcut/AbsUserRelatedShortcutCreatorActivity.kt index 0ddf72034..b6beec23f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/activity/shortcut/AbsUserRelatedShortcutCreatorActivity.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/activity/shortcut/AbsUserRelatedShortcutCreatorActivity.kt @@ -44,8 +44,10 @@ abstract class AbsUserRelatedShortcutCreatorActivity : AbsShortcutCreatorActivit } val user = data.getParcelableExtra(EXTRA_USER) val extras = data.getBundleExtra(EXTRA_EXTRAS) - val accountKey = extras.getParcelable(EXTRA_ACCOUNT_KEY) - onUserSelected(accountKey, user) + val accountKey = extras?.getParcelable(EXTRA_ACCOUNT_KEY) + if (user != null) { + onUserSelected(accountKey, user) + } } else -> { super.onActivityResult(requestCode, resultCode, data) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/app/TwidereApplication.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/app/TwidereApplication.kt index dae74fce7..bd67395d9 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/app/TwidereApplication.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/app/TwidereApplication.kt @@ -176,7 +176,7 @@ class TwidereApplication : Application(), OnSharedPreferenceChangeListener { }, updateImmediately = true) } - override fun onConfigurationChanged(newConfig: Configuration?) { + override fun onConfigurationChanged(newConfig: Configuration) { applyLanguageSettings() super.onConfigurationChanged(newConfig) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/ConnectivityManagerExtensions.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/ConnectivityManagerExtensions.kt index 243518b4e..f0f6df01b 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/extension/ConnectivityManagerExtensions.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/extension/ConnectivityManagerExtensions.kt @@ -32,7 +32,7 @@ val ConnectivityManager.activateNetworkCompat: Network? return activeNetwork } val activeInfo = activeNetworkInfo ?: return null - return allNetworks.firstOrNull { activeInfo.same(getNetworkInfo(it)) } + return allNetworks.firstOrNull { getNetworkInfo(it)?.let { it1 -> activeInfo.same(it1) } == true } } private fun NetworkInfo.same(another: NetworkInfo) = type == another.type && subtype == another.subtype \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt index e63c0ca4c..095f207e4 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsManagerFragment.kt @@ -95,7 +95,7 @@ class AccountsManagerFragment : BaseFragment(), LoaderManager.LoaderCallbacks
  • (EXTRA_USER) + val user = data.getParcelableExtra(EXTRA_USER) ?: return twitter.addUserListMembersAsync(userList.account_key, userList.id, user) return } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/FilteredUsersFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/FilteredUsersFragment.kt index 68e544a0e..c8fc179c2 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/FilteredUsersFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/filter/FilteredUsersFragment.kt @@ -64,7 +64,7 @@ class FilteredUsersFragment : BaseFiltersFragment() { when (requestCode) { REQUEST_SELECT_USER -> { if (resultCode != FragmentActivity.RESULT_OK || data == null) return - val user = data.getParcelableExtra(EXTRA_USER) + val user = data.getParcelableExtra(EXTRA_USER) ?: return executeAfterFragmentResumed { fragment -> AddUserFilterDialogFragment.show(fragment.childFragmentManager, user) } @@ -92,7 +92,7 @@ class FilteredUsersFragment : BaseFiltersFragment() { } REQUEST_EXPORT_MUTES_SELECT_ACCOUNT -> { if (resultCode != FragmentActivity.RESULT_OK || data == null) return - val accountKey = data.getParcelableExtra(EXTRA_ACCOUNT_KEY) + val accountKey = data.getParcelableExtra(EXTRA_ACCOUNT_KEY) ?: return val userKeys = data.getBundleExtra(EXTRA_EXTRAS)?.getNullableTypedArray(EXTRA_ITEMS) ?: return exportToMutedUsers(accountKey, userKeys) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExternalBrowserPageFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExternalBrowserPageFragment.kt index 365d8de26..5ce6dc2eb 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExternalBrowserPageFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/media/ExternalBrowserPageFragment.kt @@ -45,7 +45,10 @@ class ExternalBrowserPageFragment : MediaViewerFragment() { webSettings.javaScriptEnabled = true webSettings.loadsImagesAutomatically = true val media = arguments?.getParcelable(EXTRA_MEDIA) ?: throw NullPointerException() - webView.loadUrl(if (TextUtils.isEmpty(media.media_url)) media.url else media.media_url) + val target = if (TextUtils.isEmpty(media.media_url)) media.url else media.media_url + target?.let { + webView.loadUrl(it) + } webViewContainer.setAspectRatioSource(VideoPageFragment.MediaAspectRatioSource(media, this)) } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageConversationInfoFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageConversationInfoFragment.kt index a9b77eefd..4834740e0 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageConversationInfoFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageConversationInfoFragment.kt @@ -188,8 +188,9 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment, when (requestCode) { REQUEST_CONVERSATION_ADD_USER -> { if (resultCode == Activity.RESULT_OK && data != null) { - val user = data.getParcelableExtra(EXTRA_USER) - performAddParticipant(user) + data.getParcelableExtra(EXTRA_USER)?.let { user -> + performAddParticipant(user) + } } } REQUEST_PICK_MEDIA -> { @@ -299,7 +300,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment, ProgressDialogFragment.show(childFragmentManager, "leave_conversation_progress") val weakThis = WeakReference(this) val task = DestroyConversationTask(requireContext(), accountKey, conversationId) - task.callback = callback@ { succeed -> + task.callback = callback@{ succeed -> val f = weakThis.get() ?: return@callback f.dismissDialogThen("leave_conversation_progress") { if (succeed) { @@ -315,7 +316,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment, ProgressDialogFragment.show(childFragmentManager, "clear_messages_progress") val weakThis = WeakReference(this) val task = ClearMessagesTask(requireContext(), accountKey, conversationId) - task.callback = callback@ { succeed -> + task.callback = callback@{ succeed -> val f = weakThis.get() ?: return@callback f.dismissDialogThen("clear_messages_progress") { if (succeed) { @@ -343,7 +344,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment, ProgressDialogFragment.show(childFragmentManager, "set_notifications_disabled_progress") val weakThis = WeakReference(this) val task = SetConversationNotificationDisabledTask(requireContext(), accountKey, conversationId, disabled) - task.callback = callback@ { _ -> + task.callback = callback@{ _ -> val f = weakThis.get() ?: return@callback f.dismissDialogThen("set_notifications_disabled_progress") { LoaderManager.getInstance(this).restartLoader(0, null, this) @@ -378,7 +379,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment, private fun performSetConversationName(name: String) { val conversationId = this.conversationId - performUpdateInfo("set_name_progress", updateAction = updateAction@ { fragment, account, microBlog -> + performUpdateInfo("set_name_progress", updateAction = updateAction@{ fragment, account, microBlog -> val context = fragment.context when (account.type) { AccountType.TWITTER -> { @@ -395,7 +396,7 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment, private fun performSetConversationAvatar(uri: Uri?) { val conversationId = this.conversationId - performUpdateInfo("set_avatar_progress", updateAction = updateAction@ { fragment, account, microBlog -> + performUpdateInfo("set_avatar_progress", updateAction = updateAction@{ fragment, account, microBlog -> val context = fragment.context when (account.type) { AccountType.TWITTER -> { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesEntriesFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesEntriesFragment.kt index 00b667480..6cd25f4b8 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesEntriesFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessagesEntriesFragment.kt @@ -105,7 +105,7 @@ class MessagesEntriesFragment : AbsContentListRecyclerViewFragment { if (resultCode != Activity.RESULT_OK) return - val accountKey = data!!.getParcelableExtra(EXTRA_ACCOUNT_KEY) + val accountKey = data?.getParcelableExtra(EXTRA_ACCOUNT_KEY) ?: return startActivity(IntentUtils.newMessageConversation(accountKey)) } else -> { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/menu/AccountActionProvider.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/menu/AccountActionProvider.kt index e76314cff..e485663fb 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/menu/AccountActionProvider.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/menu/AccountActionProvider.kt @@ -38,9 +38,10 @@ class AccountActionProvider( for (i in 0 until subMenu.size()) { val item = subMenu.getItem(i) val intent = item.intent - val account: AccountDetails = intent.getParcelableExtra(EXTRA_ACCOUNT) - if (it.contains(account.key)) { - item.isChecked = true + intent.getParcelableExtra(EXTRA_ACCOUNT)?.let { account -> + if (it.contains(account.key)) { + item.isChecked = true + } } } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/model/analyzer/PurchaseFinished.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/model/analyzer/PurchaseFinished.kt index 3275735fd..2488a0cd0 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/model/analyzer/PurchaseFinished.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/model/analyzer/PurchaseFinished.kt @@ -19,7 +19,7 @@ data class PurchaseFinished(val productName: String) : Analyzer.Event { const val NAME_EXTRA_FEATURES = "Enhanced Features" fun create(data: Intent): PurchaseFinished { - val purchaseResult: PurchaseResult = data.getParcelableExtra(EXTRA_PURCHASE_RESULT) + val purchaseResult: PurchaseResult = data.getParcelableExtra(EXTRA_PURCHASE_RESULT)!! val result = PurchaseFinished(purchaseResult.feature) result.price = purchaseResult.price result.currency = purchaseResult.currency diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/TrendsLocationExtraConfiguration.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/TrendsLocationExtraConfiguration.kt index a2ca60f8b..74f425dd9 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/TrendsLocationExtraConfiguration.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/TrendsLocationExtraConfiguration.kt @@ -65,8 +65,9 @@ open class TrendsLocationExtraConfiguration( when (requestCode) { 1 -> { if (resultCode == Activity.RESULT_OK && data != null) { - val location = data.getParcelableExtra(EXTRA_LOCATION) - value = Place(location.woeid, location.name) + data.getParcelableExtra(EXTRA_LOCATION)?.let { location -> + value = Place(location.woeid, location.name) + } } } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/UserExtraConfiguration.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/UserExtraConfiguration.kt index f643e47c0..9833a0096 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/UserExtraConfiguration.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/UserExtraConfiguration.kt @@ -62,11 +62,12 @@ class UserExtraConfiguration(key: String) : TabConfiguration.ExtraConfiguration( when (requestCode) { 1 -> { if (resultCode == Activity.RESULT_OK && data != null) { - val user: ParcelableUser = data.getParcelableExtra(EXTRA_USER) - viewHolder.displayUser(user) - viewHolder.itemView.visibility = View.VISIBLE - hintView.visibility = View.GONE - this.value = user + data.getParcelableExtra(EXTRA_USER)?.let { user -> + viewHolder.displayUser(user) + viewHolder.itemView.visibility = View.VISIBLE + hintView.visibility = View.GONE + this.value = user + } } } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/UserListExtraConfiguration.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/UserListExtraConfiguration.kt index f614a6261..e6e8fa880 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/UserListExtraConfiguration.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/model/tab/conf/UserListExtraConfiguration.kt @@ -63,12 +63,13 @@ class UserListExtraConfiguration(key: String) : TabConfiguration.ExtraConfigurat when (requestCode) { 1 -> { if (resultCode == Activity.RESULT_OK) { - val userList: ParcelableUserList = data!!.getParcelableExtra(EXTRA_USER_LIST) - viewHolder.display(userList) - viewHolder.itemView.visibility = View.VISIBLE - hintView.visibility = View.GONE + data?.getParcelableExtra(EXTRA_USER_LIST)?.let { userList -> + viewHolder.display(userList) + viewHolder.itemView.visibility = View.VISIBLE + hintView.visibility = View.GONE - this.value = userList + this.value = userList + } } } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/util/MultiSelectEventHandler.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/util/MultiSelectEventHandler.kt index bb3568b53..d3cd6c459 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/util/MultiSelectEventHandler.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/util/MultiSelectEventHandler.kt @@ -158,7 +158,7 @@ class MultiSelectEventHandler( if (item.groupId == AccountActionProvider.MENU_GROUP) { val intent = item.intent if (intent == null || !intent.hasExtra(EXTRA_ACCOUNT)) return false - val account: AccountDetails = intent.getParcelableExtra(EXTRA_ACCOUNT) + val account: AccountDetails = intent.getParcelableExtra(EXTRA_ACCOUNT) ?: return false multiSelectManager.accountKey = account.key accountActionProvider?.selectedAccountKeys = arrayOf(account.key) mode.invalidate() diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/LollipopFixedWebView.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/LollipopFixedWebView.kt index a4eb62c19..ca5a9cc14 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/LollipopFixedWebView.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/LollipopFixedWebView.kt @@ -14,12 +14,13 @@ private fun Context.fixForLollipop(): Context { class LollipopFixWebView: WebView { - constructor(context: Context?) : super(context?.fixForLollipop()) - constructor(context: Context?, attrs: AttributeSet?) : super(context?.fixForLollipop(), attrs) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context?.fixForLollipop(), attrs, defStyleAttr) - @TargetApi(Build.VERSION_CODES.LOLLIPOP) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context?.fixForLollipop(), attrs, defStyleAttr, defStyleRes) - constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, privateBrowsing: Boolean) : super(context?.fixForLollipop(), attrs, defStyleAttr, privateBrowsing) + constructor(context: Context) : super(context.fixForLollipop()) + constructor(context: Context, attrs: AttributeSet?) : super(context.fixForLollipop(), attrs) + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( + context.fixForLollipop(), + attrs, + defStyleAttr + ) init { isFocusable = true diff --git a/twidere/src/main/res/layout/layout_media_viewer_exo_player_view.xml b/twidere/src/main/res/layout/layout_media_viewer_exo_player_view.xml index c2b1abf89..1c4b61d66 100644 --- a/twidere/src/main/res/layout/layout_media_viewer_exo_player_view.xml +++ b/twidere/src/main/res/layout/layout_media_viewer_exo_player_view.xml @@ -25,7 +25,7 @@ android:layout_height="match_parent" android:layout_centerInParent="true"> -