Merge branch 'unstable' of https://github.com/jsmaniac/2011-m1s2-ter into unstable
This commit is contained in:
commit
ef4b5aaee5
|
@ -11,6 +11,7 @@ import android.webkit.WebView;
|
|||
public class FrontPage extends Activity {
|
||||
|
||||
private WebView webView;
|
||||
private JavaScriptInterface js = null;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
|
@ -22,13 +23,15 @@ public class FrontPage extends Activity {
|
|||
WebSettings webSettings = webView.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
|
||||
webView.addJavascriptInterface(new JavaScriptInterface(this), "Pticlic");
|
||||
js = new JavaScriptInterface(this);
|
||||
js.show("PtiClic", "Démarrage de l'application");
|
||||
webView.addJavascriptInterface(js, "PtiClicAndroid");
|
||||
webView.loadUrl(Constant.SERVER + Constant.SERVER_URL);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
System.exit(0);
|
||||
webView.goBack();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package org.pticlic.js;
|
||||
|
||||
import org.pticlic.Preference;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
|
@ -16,13 +13,16 @@ public class JavaScriptInterface {
|
|||
public JavaScriptInterface(Context c) {
|
||||
mContext = c;
|
||||
}
|
||||
|
||||
/** Permet d'afficher la page des preferences qui est directement
|
||||
* implemente sur le telephone
|
||||
|
||||
/**
|
||||
* Permet de setter une valeur dans les preferences
|
||||
*
|
||||
* @param aName Le nom de la preference
|
||||
* @param aValue La valeur que l'on veux pour la preference
|
||||
*/
|
||||
public void goToPreferences() {
|
||||
mContext.startActivity(new Intent(mContext, Preference.class));
|
||||
public void setPreference(String aName, String aValue) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
prefs.edit().putString(aName, aValue).commit();
|
||||
}
|
||||
|
||||
/** Permet de recupere une des preferences du systeme.
|
||||
|
@ -30,9 +30,9 @@ public class JavaScriptInterface {
|
|||
* @param pref La preference que l'on veux recupere
|
||||
* @return La preference a recupere.
|
||||
*/
|
||||
public String getPreference(String pref) {
|
||||
public String getPreference(String aName) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
return prefs.getString(pref, "");
|
||||
return prefs.getString(aName, "");
|
||||
}
|
||||
|
||||
/** Permet d'afficher une progressbar
|
||||
|
@ -47,8 +47,8 @@ public class JavaScriptInterface {
|
|||
*
|
||||
*/
|
||||
public void dismiss() {
|
||||
if (dialog.isShowing())
|
||||
dialog.dismiss();
|
||||
if (dialog.isShowing())
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
/** Permet de quitter l'application
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.pticlic.model;
|
||||
|
||||
public class Constant {
|
||||
public static final String SERVER_URL = "html5/code/html5/";
|
||||
public static final String SERVER_URL = "unstable/code/serveur/php/jeu.html";
|
||||
public static final String SERVER_AUTH = "SERVER_AUTH";
|
||||
public static final String SERVER = "http://www.pticlic.fr/";
|
||||
|
||||
|
|
|
@ -98,14 +98,27 @@ jss.game = function(w, h, iconSize) {
|
|||
jss.score = function(w, h, iconSize) {
|
||||
};
|
||||
|
||||
// ==== Interface Android
|
||||
var UI = {
|
||||
setPreference: function() {},
|
||||
getPreference: function() {return "";},
|
||||
show: function() {},
|
||||
dismiss: function() {},
|
||||
exit: function() {}
|
||||
};
|
||||
|
||||
if (typeof(PtiClicAndroid) != "undefined") {
|
||||
UI = PtiClicAndroid;
|
||||
}
|
||||
|
||||
// ==== Code métier général
|
||||
$(function() {
|
||||
$(window).resize(jss);
|
||||
jss();
|
||||
frontpage();
|
||||
});
|
||||
|
||||
function ajaxError(x) {
|
||||
UI.dismiss();
|
||||
alert("Erreur fatale. Merci de nous envoyer ce message : "+x.status+" - "+x.statusText+"\n"+x.responseText.substring(0,20)+((x.responseText == '') ? '': '…'));
|
||||
}
|
||||
|
||||
|
@ -115,11 +128,14 @@ function frontpage() {
|
|||
$("#frontpage .frontpage-button.game").click(function(){
|
||||
getGame();
|
||||
});
|
||||
jss();
|
||||
UI.dismiss();
|
||||
}
|
||||
|
||||
// ==== Code métier pour le jeu
|
||||
function getGame() {
|
||||
state="game";
|
||||
UI.show("PtiClic", "Récupération de la partie");
|
||||
$.getJSON("getGame.php?callback=?", {
|
||||
user:"foo",
|
||||
passwd:"bar",
|
||||
|
@ -191,11 +207,13 @@ function uiGame(game) {
|
|||
});
|
||||
|
||||
updateText();
|
||||
UI.dismiss();
|
||||
}
|
||||
|
||||
// ==== Code métier pour les scores
|
||||
function getScore(game) {
|
||||
state="score";
|
||||
UI.show("PtiClic", "Calcul de votre score");
|
||||
$.getJSON("server.php?callback=?", {
|
||||
user: "foo",
|
||||
passwd: "bar",
|
||||
|
@ -230,4 +248,5 @@ function uiScore(game) {
|
|||
.appendTo("#score .scores");
|
||||
jss();
|
||||
});
|
||||
UI.dismiss();
|
||||
}
|
Loading…
Reference in New Issue
Block a user