fedilab-Android-App/app/src/main/java/fr/gouv/etalab/mastodon/activities/MainApplication.java

67 lines
2.9 KiB
Java
Raw Normal View History

2017-05-05 16:36:04 +02:00
package fr.gouv.etalab.mastodon.activities;
/* Copyright 2017 Thomas Schneider
*
2017-07-10 10:33:24 +02:00
* This file is a part of Mastalab
2017-05-05 16:36:04 +02:00
*
* This program 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.
*
2017-07-10 10:33:24 +02:00
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
2017-05-05 16:36:04 +02:00
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
2017-08-04 11:11:27 +02:00
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
2017-05-05 16:36:04 +02:00
* see <http://www.gnu.org/licenses>. */
import android.app.Application;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.StrictMode;
2017-05-05 16:36:04 +02:00
import com.evernote.android.job.JobManager;
2018-08-29 16:15:11 +02:00
import org.acra.ACRA;
import org.acra.BuildConfig;
import org.acra.annotation.AcraDialog;
import org.acra.annotation.AcraMailSender;
2018-08-29 16:15:11 +02:00
import org.acra.config.CoreConfigurationBuilder;
import org.acra.config.LimiterConfigurationBuilder;
import org.acra.config.MailSenderConfigurationBuilder;
import org.acra.data.StringFormat;
import fr.gouv.etalab.mastodon.R;
2017-05-05 16:36:04 +02:00
import fr.gouv.etalab.mastodon.jobs.ApplicationJob;
2017-08-29 16:22:57 +02:00
import fr.gouv.etalab.mastodon.jobs.HomeTimelineSyncJob;
import fr.gouv.etalab.mastodon.jobs.NotificationsSyncJob;
2017-05-05 16:36:04 +02:00
/**
* Created by Thomas on 29/04/2017.
* Main application, jobs are launched here.
2017-05-05 16:36:04 +02:00
*/
2018-08-29 16:15:11 +02:00
@AcraDialog(resText = R.string.crash_title,
2018-08-30 17:49:56 +02:00
resCommentPrompt = R.string.crash_message, resTheme = R.style.AlertDialogDark, resIcon = R.mipmap.ic_launcher)
2017-05-05 16:36:04 +02:00
public class MainApplication extends Application{
@Override
public void onCreate() {
super.onCreate();
JobManager.create(this).addJobCreator(new ApplicationJob());
2017-08-29 16:22:57 +02:00
NotificationsSyncJob.schedule(false);
HomeTimelineSyncJob.schedule(false);
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
2018-08-29 16:15:11 +02:00
CoreConfigurationBuilder ACRABuilder = new CoreConfigurationBuilder(this);
2018-08-30 17:49:56 +02:00
ACRABuilder.setBuildConfigClass(BuildConfig.class).setReportFormat(StringFormat.KEY_VALUE_LIST);
String version = "";
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
version = pInfo.versionName;
} catch (PackageManager.NameNotFoundException ignored) { }
ACRABuilder.getPluginConfigurationBuilder(MailSenderConfigurationBuilder.class).setReportAsFile(false).setMailTo("support@mastalab.app").setSubject(" Crash Report for Mastalab " + version).setEnabled(true);
2018-08-29 16:15:11 +02:00
ACRABuilder.getPluginConfigurationBuilder(LimiterConfigurationBuilder.class).setEnabled(true);
ACRA.init(this, ACRABuilder);
2017-05-05 16:36:04 +02:00
}
}