Commits

Luke Plant committed b4bc8e2

Expose versionCode to javascript interface

  • Participants
  • Parent commits e1d6124

Comments (0)

Files changed (1)

File src/net/learnscripture/webviewapp/Dashboard.java

 
 import android.annotation.SuppressLint;
 import android.app.Activity;
+import android.content.ComponentName;
 import android.content.Intent;
+import android.content.pm.PackageInfo;
 import android.graphics.Bitmap;
 import android.net.MailTo;
 import android.net.Uri;
 		});
 		engine.getSettings().setJavaScriptEnabled(true);
 		jsInterface = new JavascriptInterface();
+		try {
+		    ComponentName comp = new ComponentName(this, Dashboard.class);
+		    PackageInfo pinfo = getPackageManager().getPackageInfo(comp.getPackageName(), 0);
+			jsInterface.versionCode = pinfo.versionCode;
+		} catch(android.content.pm.PackageManager.NameNotFoundException e) {
+		}
+		
 		engine.addJavascriptInterface(jsInterface, "androidlearnscripture");
 		engine.loadUrl(BASE_URL);
 	}
 	final class JavascriptInterface {
 		public boolean enablePreferencesMenu = false;
 		public boolean modalIsVisible = false;
+		public int versionCode = 0;
 		
 		public void setEnablePreferencesMenu() {
 			enablePreferencesMenu = true;
 		public void setModalIsVisible(boolean visible) {
 			modalIsVisible = visible;
 		}
+		
+		public int getVersionCode() {
+			return versionCode;
+		}
 	}
 
 }