-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathStartupActivity.java
42 lines (32 loc) · 1.11 KB
/
StartupActivity.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
package org.medicmobile.webapp.mobile;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import static org.medicmobile.webapp.mobile.MedicLog.trace;
import static org.medicmobile.webapp.mobile.Utils.createUseragentFrom;
import static org.medicmobile.webapp.mobile.Utils.startAppActivityChain;
public class StartupActivity extends Activity {
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
trace(this, "onCreate()");
configureAndStartNextActivity();
}
private void configureAndStartNextActivity() {
configureHttpUseragent();
if (hasEnoughFreeSpace()) {
startAppActivityChain(this);
return;
}
Intent intent = new Intent(this, FreeSpaceWarningActivity.class);
startActivity(intent);
finish();
}
private boolean hasEnoughFreeSpace() {
long freeSpace = getFilesDir().getFreeSpace();
return freeSpace > FreeSpaceWarningActivity.MINIMUM_SPACE;
}
private void configureHttpUseragent() {
String current = System.getProperty("http.agent");
System.setProperty("http.agent", createUseragentFrom(current));
}
}