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

60 lines
2.3 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>. */
2018-11-24 18:56:12 +01:00
2017-05-05 16:36:04 +02:00
import android.app.Application;
2018-11-24 18:56:12 +01:00
import android.content.SharedPreferences;
import android.os.StrictMode;
2018-11-24 18:56:12 +01:00
2017-05-05 16:36:04 +02:00
import com.evernote.android.job.JobManager;
2018-11-24 18:56:12 +01:00
import com.franmontiel.localechanger.LocaleChanger;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import fr.gouv.etalab.mastodon.helper.Helper;
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-10-08 17:44:43 +02:00
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-11-24 18:56:12 +01:00
try {
List<Locale> SUPPORTED_LOCALES = new ArrayList<>();
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
String defaultLocaleString = sharedpreferences.getString(Helper.SET_DEFAULT_LOCALE, Helper.localeToStringStorage(Locale.getDefault()));
Locale defaultLocale = Helper.restoreLocaleFromString(defaultLocaleString);
SUPPORTED_LOCALES.add(defaultLocale);
LocaleChanger.initialize(getApplicationContext(), SUPPORTED_LOCALES);
}catch (Exception ignored){ignored.printStackTrace();}
2017-05-05 16:36:04 +02:00
}
}