forked from UriahShaulMandel/BaldPhone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaldPhone.java
79 lines (70 loc) · 2.94 KB
/
BaldPhone.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright 2019 Uriah Shaul Mandel
*
* 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 com.bald.uriah.baldphone;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.bald.uriah.baldphone.activities.UpdatesActivity;
import com.bald.uriah.baldphone.databases.alarms.AlarmScheduler;
import com.bald.uriah.baldphone.databases.reminders.ReminderScheduler;
import com.bald.uriah.baldphone.services.NotificationListenerService;
import com.bald.uriah.baldphone.utils.BaldUncaughtExceptionHandler;
import com.bald.uriah.baldphone.utils.S;
import net.danlew.android.joda.JodaTimeAndroid;
import org.acra.ACRA;
import org.acra.config.CoreConfigurationBuilder;
import org.acra.config.HttpSenderConfigurationBuilder;
import org.acra.data.StringFormat;
import org.acra.sender.HttpSender;
public class BaldPhone extends Application {
private static final String TAG = BaldPhone.class.getSimpleName();
// Application class should not have any fields, http://www.developerphil.com/dont-store-data-in-the-application-object/
@Override
public void onCreate() {
S.logImportant("BaldPhone was started!");
super.onCreate();
JodaTimeAndroid.init(this);
AlarmScheduler.reStartAlarms(this);
ReminderScheduler.reStartReminders(this);
if (BuildConfig.FLAVOR.equals("baldUpdates")) {
UpdatesActivity.removeUpdatesInfo(this);
}
try {
startService(new Intent(this, NotificationListenerService.class));
} catch (Exception e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
}
S.sendVersionInfo(this);
}
@Override
protected void attachBaseContext(final Context base) {
super.attachBaseContext(base);
final CoreConfigurationBuilder builder =
new CoreConfigurationBuilder(this)
.setBuildConfigClass(BuildConfig.class)
.setReportFormat(StringFormat.JSON);
builder.getPluginConfigurationBuilder(HttpSenderConfigurationBuilder.class)
.setUri(getString(R.string.tt_url))
.setHttpMethod(HttpSender.Method.POST)
.setEnabled(true);
ACRA.init(this, builder);
Thread.setDefaultUncaughtExceptionHandler(
new BaldUncaughtExceptionHandler(this, Thread.getDefaultUncaughtExceptionHandler())
);
}
}