Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate annotations and improve kotlin dsl configuration. Migrate to kotlin #813

Merged
merged 17 commits into from
Nov 26, 2020
6 changes: 3 additions & 3 deletions .github/workflows/upload-javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
repository: 'ACRA/acra.github.com'
path: 'web'
- name: Generate Javadoc
run: ./gradlew joinedJavadoc --no-daemon
run: ./gradlew dokkaHtmlCollector --no-daemon
working-directory: ./main
- name: Extract version
id: version
Expand All @@ -34,8 +34,8 @@ jobs:
- name: Update Javadoc
run: |
mkdir ./web/javadoc/${{ steps.version.outputs.value }}
cp -a ./main/build/javadoc/. ./web/javadoc/${{ steps.version.outputs.value }}/
echo "- [${{ steps.version.outputs.value }}](${{ steps.version.outputs.value }})" >> ./web/javadoc/index.md
cp -a ./main/build/dokka/htmlCollector/. ./web/javadoc/${{ steps.version.outputs.value }}/
echo "- [${{ steps.version.outputs.value }}](${{ steps.version.outputs.value }}/acra)" >> ./web/javadoc/index.md
ln -sfn "${{ steps.version.outputs.value }}/" ./web/javadoc/latest
- name: Commit files
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* @author F43nd1r
* @since 18.04.18
*/
@Deprecated
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2018
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.acra.scheduler

import android.app.job.JobInfo
import android.content.Context
import android.os.Build
import com.google.auto.service.AutoService
import org.acra.config.ConfigUtils.getPluginConfiguration
import org.acra.config.CoreConfiguration
import org.acra.config.SchedulerConfiguration
import org.acra.plugins.HasConfigPlugin

/**
* Utilizes jobservice to delay report sending
*
* @author F43nd1r
* @since 18.04.18
*/
class AdvancedSenderScheduler private constructor(context: Context, config: CoreConfiguration) : DefaultSenderScheduler(context, config) {
private val schedulerConfiguration: SchedulerConfiguration = getPluginConfiguration(config, SchedulerConfiguration::class.java)
override fun configureJob(job: JobInfo.Builder) {
job.setRequiredNetworkType(schedulerConfiguration.requiresNetworkType)
job.setRequiresCharging(schedulerConfiguration.requiresCharging)
job.setRequiresDeviceIdle(schedulerConfiguration.requiresDeviceIdle)
var constrained = schedulerConfiguration.requiresNetworkType != JobInfo.NETWORK_TYPE_NONE || schedulerConfiguration.requiresCharging || schedulerConfiguration.requiresDeviceIdle
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
job.setRequiresBatteryNotLow(schedulerConfiguration.requiresBatteryNotLow)
constrained = constrained or schedulerConfiguration.requiresBatteryNotLow
}
if (!constrained) {
job.setOverrideDeadline(0)
}
}

@AutoService(SenderSchedulerFactory::class)
class Factory : HasConfigPlugin(SchedulerConfiguration::class.java), SenderSchedulerFactory {
override fun create(context: Context, config: CoreConfiguration): SenderScheduler {
return AdvancedSenderScheduler(context, config)
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2018
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.acra.scheduler

import android.app.job.JobInfo
import android.app.job.JobScheduler
import android.content.ComponentName
import android.content.Context
import android.os.PersistableBundle
import com.google.auto.service.AutoService
import org.acra.builder.LastActivityManager
import org.acra.config.ConfigUtils.getPluginConfiguration
import org.acra.config.CoreConfiguration
import org.acra.config.ReportingAdministrator
import org.acra.config.SchedulerConfiguration
import org.acra.log.debug
import org.acra.log.info
import org.acra.log.warn
import org.acra.plugins.HasConfigPlugin

/**
* @author F43nd1r
* @since 07.05.18
*/
@AutoService(ReportingAdministrator::class)
class RestartingAdministrator : HasConfigPlugin(SchedulerConfiguration::class.java), ReportingAdministrator {
override fun shouldFinishActivity(context: Context, config: CoreConfiguration, lastActivityManager: LastActivityManager): Boolean {
debug { "RestartingAdministrator entry" }
if (getPluginConfiguration(config, SchedulerConfiguration::class.java).restartAfterCrash) {
val activity = lastActivityManager.lastActivity
if (activity != null) {
debug { "Try to schedule last activity (" + activity.javaClass.name + ") for restart" }
try {
val scheduler = (context.getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler)
val extras = PersistableBundle()
extras.putString(EXTRA_LAST_ACTIVITY, activity.javaClass.name)
scheduler.schedule(JobInfo.Builder(1, ComponentName(context, RestartingService::class.java))
.setExtras(extras)
.setOverrideDeadline(100)
.build())
debug { "Successfully scheduled last activity (" + activity.javaClass.name + ") for restart" }
} catch (e: Exception) {
warn(e) { "Failed to schedule last activity for restart" }
}
} else {
info { "Activity restart is enabled but no activity was found. Nothing to do." }
}
}
return true
}

companion object {
const val EXTRA_LAST_ACTIVITY = "lastActivity"
const val EXTRA_ACTIVITY_RESTART_AFTER_CRASH = "restartAfterCrash"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.acra.scheduler

import android.app.Activity
import android.app.job.JobParameters
import android.app.job.JobService
import android.content.Intent
import org.acra.log.debug
import org.acra.log.warn

/**
* @author Lukas
* @since 31.12.2018
*/
class RestartingService : JobService() {
override fun onStartJob(params: JobParameters): Boolean {
val className = params.extras.getString(RestartingAdministrator.EXTRA_LAST_ACTIVITY)
debug { "Restarting activity $className..." }
if (className != null) {
try {
@Suppress("UNCHECKED_CAST") val activityClass = Class.forName(className) as Class<out Activity>
val intent = Intent(this, activityClass)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.putExtra(RestartingAdministrator.EXTRA_ACTIVITY_RESTART_AFTER_CRASH, true)
startActivity(intent)
debug { "$className was successfully restarted" }
} catch (e: ClassNotFoundException) {
warn(e) { "Unable to find activity class$className" }
}
}
return false
}

override fun onStopJob(params: JobParameters): Boolean {
return false
}
}
Loading