1 |
package dk.thoerup.ekllauncher; |
package dk.thoerup.ekllauncher; |
2 |
|
|
3 |
|
import android.annotation.SuppressLint; |
4 |
import android.app.Activity; |
import android.app.Activity; |
5 |
import android.app.AlertDialog; |
import android.app.AlertDialog; |
6 |
import android.content.Context; |
import android.content.Context; |
110 |
class DummyWebViewClient extends WebViewClient { |
class DummyWebViewClient extends WebViewClient { |
111 |
} |
} |
112 |
|
|
113 |
|
static final String LOGTAG = "EklLauncher"; |
114 |
static final String URL = "http://omdeling.info/mobil_gpstrack/ekl/login.php"; |
static final String URL = "http://omdeling.info/mobil_gpstrack/ekl/login.php"; |
115 |
|
|
116 |
LocationManager locMgr; |
LocationManager locMgr; |
124 |
SimHandler simHandler = new SimHandler(); |
SimHandler simHandler = new SimHandler(); |
125 |
|
|
126 |
/** Called when the activity is first created. */ |
/** Called when the activity is first created. */ |
127 |
@Override |
@SuppressLint("SetJavaScriptEnabled") |
128 |
|
@Override |
129 |
public void onCreate(Bundle savedInstanceState) { |
public void onCreate(Bundle savedInstanceState) { |
130 |
super.onCreate(savedInstanceState); |
super.onCreate(savedInstanceState); |
131 |
|
|
132 |
|
Log.e(LOGTAG, "Starting"); |
133 |
|
|
134 |
getWindow().requestFeature(Window.FEATURE_PROGRESS); |
getWindow().requestFeature(Window.FEATURE_PROGRESS); |
135 |
|
|
136 |
|
|
137 |
try { |
try { |
138 |
int airplane = Settings.System.getInt(this.getContentResolver(), Settings.System.AIRPLANE_MODE_ON); |
int airplane = Settings.System.getInt(this.getContentResolver(), Settings.System.AIRPLANE_MODE_ON); |
139 |
|
|
140 |
if (airplane > 0) { |
if (airplane > 0) { |
141 |
Settings.System.putInt(this.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0); |
Settings.System.putInt(this.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0); |
142 |
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); |
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); |
165 |
device = ""; |
device = ""; |
166 |
} |
} |
167 |
|
|
168 |
Toast.makeText(EKLLauncherActivity.this, "Device:"+device, Toast.LENGTH_SHORT).show(); |
Toast.makeText(EKLLauncherActivity.this, "Device: "+device, Toast.LENGTH_SHORT).show(); |
169 |
|
|
170 |
|
|
171 |
|
|
194 |
web.setWebChromeClient(new CustomChromeClient() ); |
web.setWebChromeClient(new CustomChromeClient() ); |
195 |
web.setWebViewClient( new DummyWebViewClient() ); // skal have en webviewclient for at kunne styre ved forlad tur |
web.setWebViewClient( new DummyWebViewClient() ); // skal have en webviewclient for at kunne styre ved forlad tur |
196 |
|
|
197 |
|
//Hvis at tlf rebooter mit i et område uden dækning er det ikke smart at vi skal vente på data |
198 |
simHandler.sendEmptyMessage(0); |
//simHandler.sendEmptyMessage(0); |
199 |
|
web.loadUrl( URL ); |
|
|
|
200 |
|
|
201 |
|
|
202 |
if (!locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER )) { |
if (!locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER )) { |
206 |
builder.setMessage("GPS er slået fra på telefonen!\nSæt et flueben ved GPS i næste vindue og tryk derefter på tilbage knappen (nederst på telefonen)") |
builder.setMessage("GPS er slået fra på telefonen!\nSæt et flueben ved GPS i næste vindue og tryk derefter på tilbage knappen (nederst på telefonen)") |
207 |
.setPositiveButton("OK", new DialogInterface.OnClickListener() { |
.setPositiveButton("OK", new DialogInterface.OnClickListener() { |
208 |
public void onClick(DialogInterface dialog, int id) { |
public void onClick(DialogInterface dialog, int id) { |
209 |
Intent myIntent = new Intent( Settings.ACTION_SECURITY_SETTINGS ); |
Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS ); |
210 |
startActivity(myIntent); |
startActivity(myIntent); |
211 |
} |
} |
212 |
}) |
}) |
213 |
.create() |
.create() |
214 |
.show(); |
.show(); |
215 |
} |
} |
216 |
|
|
217 |
|
} |
218 |
|
|
219 |
|
void showMessage(String msg) { |
220 |
|
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
221 |
|
builder.setMessage(msg) |
222 |
|
.setPositiveButton("OK", new DialogInterface.OnClickListener() { |
223 |
|
public void onClick(DialogInterface dialog, int id) { |
224 |
|
dialog.dismiss(); |
225 |
|
} |
226 |
|
}) |
227 |
|
.create() |
228 |
|
.show(); |
229 |
|
|
230 |
} |
} |
231 |
|
|
232 |
@Override |
@Override |