1 |
package dk.thoerup.ekllauncher;
|
2 |
|
3 |
import android.app.Activity;
|
4 |
import android.webkit.GeolocationPermissions.Callback;
|
5 |
import android.webkit.WebChromeClient;
|
6 |
import android.webkit.WebStorage.QuotaUpdater;
|
7 |
import android.webkit.WebView;
|
8 |
|
9 |
class EKLChromeClient extends WebChromeClient {
|
10 |
|
11 |
private Activity activity;
|
12 |
|
13 |
public EKLChromeClient(Activity activity) {
|
14 |
this.activity = activity;
|
15 |
|
16 |
}
|
17 |
|
18 |
@Override
|
19 |
public void onReachedMaxAppCacheSize(long spaceNeeded, long totalUsedQuota, QuotaUpdater quotaUpdater) {
|
20 |
quotaUpdater.updateQuota(totalUsedQuota + 4096);
|
21 |
}
|
22 |
|
23 |
|
24 |
|
25 |
public void onProgressChanged(WebView view, int progress) {
|
26 |
// Activities and WebViews measure progress with different scales.
|
27 |
// The progress meter will automatically disappear when we reach 100%
|
28 |
activity.setProgress(progress * 100);
|
29 |
}
|
30 |
|
31 |
|
32 |
@Override
|
33 |
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize, long totalUsedQuota, QuotaUpdater quotaUpdater) {
|
34 |
quotaUpdater.updateQuota(estimatedSize); // altid giv tilladelse til større db quota
|
35 |
}
|
36 |
|
37 |
|
38 |
@Override
|
39 |
public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
|
40 |
callback.invoke(origin, true, true); //altid give tilladelse til geo location
|
41 |
}
|
42 |
/*
|
43 |
@Override
|
44 |
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
|
45 |
|
46 |
return super.onJsAlert(view, url, message, result);
|
47 |
}
|
48 |
|
49 |
@Override
|
50 |
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
|
51 |
Toast.makeText(EKLLauncherActivity.this, "Oh no! " + message, Toast.LENGTH_SHORT).show();
|
52 |
return super.onJsConfirm(view, url, message, result);
|
53 |
}
|
54 |
|
55 |
@Override
|
56 |
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
|
57 |
String msg = message.trim().toLowerCase();
|
58 |
|
59 |
if (msg.equals("ekl identifikation mangler")) {
|
60 |
if (device != null && device.equals("")==false) {
|
61 |
result.confirm(device);
|
62 |
|
63 |
timeoutHandler.sendEmptyMessageDelayed(1, 500); //efter pdaID er sendt til app'en skal vi genindlæse siden for at tvinge den til at hente data
|
64 |
return true;
|
65 |
} else {
|
66 |
//Hvis vi ikke kunne aflæse device, spørg user via en custom Input Dialog
|
67 |
//Dialogen kan kun tage imod tal &
|
68 |
//når at vi får en confirm på den tvinger vi ud i en reload af siden
|
69 |
|
70 |
AlertDialog.Builder alert = new AlertDialog.Builder(EKLLauncherActivity.this);
|
71 |
|
72 |
//alert.setTitle("Title");
|
73 |
alert.setMessage(message);
|
74 |
|
75 |
// Set an EditText view to get user input
|
76 |
final EditText input = new EditText(EKLLauncherActivity.this);
|
77 |
input.setInputType(InputType.TYPE_CLASS_NUMBER);
|
78 |
alert.setView(input);
|
79 |
|
80 |
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
81 |
public void onClick(DialogInterface dialog, int whichButton) {
|
82 |
result.confirm(input.getText().toString());
|
83 |
timeoutHandler.sendEmptyMessageDelayed(1, 500);
|
84 |
}
|
85 |
});
|
86 |
alert.show();
|
87 |
|
88 |
return true;
|
89 |
|
90 |
}
|
91 |
} else {
|
92 |
return super.onJsPrompt(view, url, message, defaultValue, result);
|
93 |
}
|
94 |
}*/
|
95 |
}
|