/[projects]/android/EKLLauncher/src/dk/thoerup/ekllauncher/EKLLauncherActivity.java
ViewVC logotype

Diff of /android/EKLLauncher/src/dk/thoerup/ekllauncher/EKLLauncherActivity.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1621 by torben, Fri Oct 21 04:59:27 2011 UTC revision 1625 by torben, Wed Oct 26 12:15:52 2011 UTC
# Line 1  Line 1 
1  package dk.thoerup.ekllauncher;  package dk.thoerup.ekllauncher;
2    
3  import android.app.Activity;  import android.app.Activity;
4    import android.app.AlertDialog;
5  import android.content.Context;  import android.content.Context;
6    import android.content.DialogInterface;
7  import android.content.Intent;  import android.content.Intent;
8    import android.location.LocationManager;
9  import android.net.ConnectivityManager;  import android.net.ConnectivityManager;
10  import android.net.NetworkInfo;  import android.net.NetworkInfo;
11  import android.os.Bundle;  import android.os.Bundle;
# Line 10  import android.os.Handler; Line 13  import android.os.Handler;
13  import android.os.Message;  import android.os.Message;
14  import android.provider.Settings;  import android.provider.Settings;
15  import android.telephony.TelephonyManager;  import android.telephony.TelephonyManager;
16    import android.text.InputType;
17  import android.util.Log;  import android.util.Log;
18  import android.view.Menu;  import android.view.Menu;
19  import android.view.MenuItem;  import android.view.MenuItem;
# Line 22  import android.webkit.WebStorage; Line 26  import android.webkit.WebStorage;
26  import android.webkit.WebStorage.QuotaUpdater;  import android.webkit.WebStorage.QuotaUpdater;
27  import android.webkit.WebView;  import android.webkit.WebView;
28  import android.webkit.WebViewClient;  import android.webkit.WebViewClient;
29  import android.widget.Toast;  import android.widget.EditText;
30    
31  public class EKLLauncherActivity extends Activity {  public class EKLLauncherActivity extends Activity {
32                    
# Line 34  public class EKLLauncherActivity extends Line 38  public class EKLLauncherActivity extends
38                  }                  }
39    
40    
                 @Override  
                 public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg) {  
                         msg("create window");  
                         return super.onCreateWindow(view, dialog, userGesture, resultMsg);  
                 }  
   
41    
42                  public void onProgressChanged(WebView view, int progress) {                  public void onProgressChanged(WebView view, int progress) {
43                          // Activities and WebViews measure progress with different scales.                          // Activities and WebViews measure progress with different scales.
# Line 72  public class EKLLauncherActivity extends Line 70  public class EKLLauncherActivity extends
70                  }*/                  }*/
71    
72                  @Override                  @Override
73                  public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {                  public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
74                          if (message.trim().toLowerCase().equals("pda identifikation mangler")) {                          String msg = message.trim().toLowerCase();
75    
76                            if (msg.equals("pda identifikation mangler")) {
77                                  result.confirm(device);                                  result.confirm(device);
78                                    
79                                  timeoutHandler.sendEmptyMessageDelayed(1, 500); //efter pdaID er sendt til app'en skal vi genindlæse siden for at tvinge den til at hente data                                  timeoutHandler.sendEmptyMessageDelayed(1, 500); //efter pdaID er sendt til app'en skal vi genindlæse siden for at tvinge den til at hente data
80                                  return true;                                  return true;
81                            } else if (msg.startsWith("indtast retur antal")) {
82    
83                                    AlertDialog.Builder alert = new AlertDialog.Builder(EKLLauncherActivity.this);
84    
85                                    //alert.setTitle("Title");
86                                    alert.setMessage(message);
87    
88                                    // Set an EditText view to get user input
89                                    final EditText input = new EditText(EKLLauncherActivity.this);
90                                    input.setInputType(InputType.TYPE_CLASS_NUMBER);
91                                    alert.setView(input);
92    
93                                    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
94                                            public void onClick(DialogInterface dialog, int whichButton) {
95                                                    result.confirm(input.getText().toString());
96                                            }
97                                    });
98                                    alert.show();
99    
100                                    return true;                            
101                          } else {                          } else {
102                                  return super.onJsPrompt(view, url, message, defaultValue, result);                                  return super.onJsPrompt(view, url, message, defaultValue, result);
103                          }                                                                                                }                                                                      
104                  }                  }
105                    
106          }          }
107    
108          class DummyWebViewClient extends WebViewClient {                          class DummyWebViewClient extends WebViewClient {                
# Line 90  public class EKLLauncherActivity extends Line 110  public class EKLLauncherActivity extends
110                    
111          static final String URL = "http://omdeling.info/mobil/ekl/login.php";          static final String URL = "http://omdeling.info/mobil/ekl/login.php";
112                    
113            LocationManager locMgr;
114          ConnectivityManager connMgr;          ConnectivityManager connMgr;
115          TelephonyManager telMgr;          TelephonyManager telMgr;
116          WebView web;          WebView web;
117          String device = "";          String device = "";
118                    
119                    
         public void msg(String m) {  
                 Toast.makeText(EKLLauncherActivity.this, m, Toast.LENGTH_SHORT).show();  
         }  
120                    
121      /** Called when the activity is first created. */      /** Called when the activity is first created. */
122      @Override      @Override
# Line 122  public class EKLLauncherActivity extends Line 140  public class EKLLauncherActivity extends
140                    
141                    
142                    
143                    locMgr = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
144          telMgr = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);          telMgr = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
145          connMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);          connMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
146                    
# Line 134  public class EKLLauncherActivity extends Line 152  public class EKLLauncherActivity extends
152                          device = "";                          device = "";
153          }          }
154                    
155    
156                    
157          setContentView(R.layout.main);          setContentView(R.layout.main);
158          web = (WebView) findViewById(R.id.web);          web = (WebView) findViewById(R.id.web);
# Line 163  public class EKLLauncherActivity extends Line 182  public class EKLLauncherActivity extends
182                    
183          simHandler.sendEmptyMessage(0);          simHandler.sendEmptyMessage(0);
184                    
185            
186            
187            
188            if (!locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER )) {
189                    //Settings.Secure.putString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "network,gps");
190                    
191                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
192                    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)")
193                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
194                    public void onClick(DialogInterface dialog, int id) {
195                            Intent myIntent = new Intent( Settings.ACTION_SECURITY_SETTINGS );
196                        startActivity(myIntent);      
197                    }
198                })
199                .create()
200                .show();      
201            }
202      }      }
203    
204          @Override          @Override

Legend:
Removed from v.1621  
changed lines
  Added in v.1625

  ViewVC Help
Powered by ViewVC 1.1.20