some code formatting
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
				
			|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
 | 
					<menu xmlns:android="http://schemas.android.com/apk/res/android" >
 | 
				
			||||||
    <item android:id="@+id/reload_button"
 | 
						<item android:id="@+id/reload_button"
 | 
				
			||||||
        android:orderInCategory="100"
 | 
							android:orderInCategory="100"
 | 
				
			||||||
        android:showAsAction="never"
 | 
							android:showAsAction="never"
 | 
				
			||||||
        android:title="@string/reload"></item>
 | 
							android:title="@string/reload"></item>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</menu>
 | 
					</menu>
 | 
				
			||||||
@@ -15,26 +15,26 @@ import android.widget.Toast;
 | 
				
			|||||||
public class IITC_Mobile extends Activity {
 | 
					public class IITC_Mobile extends Activity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private IITC_WebView iitc_view;
 | 
						private IITC_WebView iitc_view;
 | 
				
			||||||
    private boolean back_button_pressed = false;
 | 
						private boolean back_button_pressed = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
						@Override
 | 
				
			||||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
						protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
        super.onCreate(savedInstanceState);
 | 
							super.onCreate(savedInstanceState);
 | 
				
			||||||
        setContentView(R.layout.activity_main);
 | 
							setContentView(R.layout.activity_main);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // we do not want to reload our page every time we switch orientations...
 | 
							// we do not want to reload our page every time we switch orientations...
 | 
				
			||||||
        // so restore state if activity was already created
 | 
							// so restore state if activity was already created
 | 
				
			||||||
        if(savedInstanceState != null) {
 | 
							if(savedInstanceState != null) {
 | 
				
			||||||
        	((IITC_WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);
 | 
								((IITC_WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
        else {
 | 
							else {
 | 
				
			||||||
	        // load new iitc web view with ingress intel page
 | 
								// load new iitc web view with ingress intel page
 | 
				
			||||||
	        iitc_view= (IITC_WebView) findViewById(R.id.webview);
 | 
								iitc_view= (IITC_WebView) findViewById(R.id.webview);
 | 
				
			||||||
	        iitc_view.setWebChromeClient(new WebChromeClient());
 | 
								iitc_view.setWebChromeClient(new WebChromeClient());
 | 
				
			||||||
	        iitc_view.loadUrl("https://www.ingress.com/intel");
 | 
								iitc_view.loadUrl("https://www.ingress.com/intel");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	        // listen to touches (think we need this)
 | 
								// listen to touches (think we need this)
 | 
				
			||||||
	        iitc_view.setOnTouchListener(new OnTouchListener() {
 | 
								iitc_view.setOnTouchListener(new OnTouchListener() {
 | 
				
			||||||
				@Override
 | 
									@Override
 | 
				
			||||||
				public boolean onTouch(View v, MotionEvent event) {
 | 
									public boolean onTouch(View v, MotionEvent event) {
 | 
				
			||||||
					back_button_pressed = false;
 | 
										back_button_pressed = false;
 | 
				
			||||||
@@ -43,50 +43,49 @@ public class IITC_Mobile extends Activity {
 | 
				
			|||||||
					return false;
 | 
										return false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
        }
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
						// save instance state to avoid reloading on orientation change
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						protected void onSaveInstanceState(Bundle outState) {
 | 
				
			||||||
 | 
							iitc_view.saveState(outState);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // save instance state to avoid reloading on orientation change
 | 
						// we want a self defined behavior on resume
 | 
				
			||||||
    @Override
 | 
						@Override
 | 
				
			||||||
    protected void onSaveInstanceState(Bundle outState) {
 | 
						protected void onResume() {
 | 
				
			||||||
    	iitc_view.saveState(outState);
 | 
							super.onResume();
 | 
				
			||||||
    }
 | 
							this.back_button_pressed = false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // we want a self defined behavior on resume
 | 
						// we want a self defined behavior for the back button
 | 
				
			||||||
    @Override
 | 
						@Override
 | 
				
			||||||
    protected void onResume() {
 | 
						public void onBackPressed() {
 | 
				
			||||||
        super.onResume();
 | 
							if (this.back_button_pressed) {
 | 
				
			||||||
        this.back_button_pressed = false;
 | 
								super.onBackPressed();
 | 
				
			||||||
    }
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							this.back_button_pressed = true;
 | 
				
			||||||
 | 
							Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // we want a self defined behavior for the back button
 | 
						@Override
 | 
				
			||||||
    @Override
 | 
						public boolean onCreateOptionsMenu(Menu menu) {
 | 
				
			||||||
    public void onBackPressed() {
 | 
							// Inflate the menu; this adds items to the action bar if it is present.
 | 
				
			||||||
        if (this.back_button_pressed) {
 | 
							getMenuInflater().inflate(R.menu.main, menu);
 | 
				
			||||||
            super.onBackPressed();
 | 
							return true;
 | 
				
			||||||
            return;
 | 
						}
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        this.back_button_pressed = true;
 | 
					 | 
				
			||||||
        Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
						@Override
 | 
				
			||||||
    public boolean onCreateOptionsMenu(Menu menu) {
 | 
						public boolean onOptionsItemSelected(MenuItem item) {
 | 
				
			||||||
        // Inflate the menu; this adds items to the action bar if it is present.
 | 
							// Handle item selection
 | 
				
			||||||
        getMenuInflater().inflate(R.menu.main, menu);
 | 
							switch (item.getItemId()) {
 | 
				
			||||||
        return true;
 | 
							case R.id.reload_button:
 | 
				
			||||||
    }
 | 
								iitc_view.reload();
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
    @Override
 | 
							default:
 | 
				
			||||||
    public boolean onOptionsItemSelected(MenuItem item) {
 | 
								return super.onOptionsItemSelected(item);
 | 
				
			||||||
        // Handle item selection
 | 
							}
 | 
				
			||||||
        switch (item.getItemId()) {
 | 
						}
 | 
				
			||||||
        case R.id.reload_button:
 | 
					 | 
				
			||||||
            iitc_view.reload();
 | 
					 | 
				
			||||||
            return true;
 | 
					 | 
				
			||||||
        default:
 | 
					 | 
				
			||||||
            return super.onOptionsItemSelected(item);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,12 +25,12 @@ public class IITC_WebViewClient extends WebViewClient {
 | 
				
			|||||||
			CookieManager cm = CookieManager.getInstance();
 | 
								CookieManager cm = CookieManager.getInstance();
 | 
				
			||||||
			final String cookie = cm.getCookie("https://www.ingress.com/intel");
 | 
								final String cookie = cm.getCookie("https://www.ingress.com/intel");
 | 
				
			||||||
			if(cookie != null) {
 | 
								if(cookie != null) {
 | 
				
			||||||
		        web.loadUrl("javascript: (function() { "
 | 
									web.loadUrl("javascript: (function() { "
 | 
				
			||||||
		                + "var script=document.createElement('script');"
 | 
											+ "var script=document.createElement('script');"
 | 
				
			||||||
		                + "script.type='text/javascript';"
 | 
											+ "script.type='text/javascript';"
 | 
				
			||||||
		                + "script.src='https://iitcserv.appspot.com/iitc-nightly/iitc-nightly-latest.user.js';"
 | 
											+ "script.src='https://iitcserv.appspot.com/iitc-nightly/iitc-nightly-latest.user.js';"
 | 
				
			||||||
		                + "document.getElementsByTagName('head').item(0).appendChild(script);"
 | 
											+ "document.getElementsByTagName('head').item(0).appendChild(script);"
 | 
				
			||||||
		                + "})()");
 | 
											+ "})()");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user