Commit 92ec3d6b authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Merge branch 'release/v0.9.4' into develop

parents bbf841e5 c22dc818
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.utc.simde.jessy" package="fr.utc.simde.jessy"
android:versionCode="27" android:versionCode="28"
android:versionName="0.9.3"> android:versionName="0.9.4">
<uses-permission android:name="android.permission.NFC" /> <uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
......
...@@ -164,35 +164,22 @@ public abstract class BaseActivity extends InternetActivity { ...@@ -164,35 +164,22 @@ public abstract class BaseActivity extends InternetActivity {
}.start(); }.start();
} }
protected void restartApp(Activity activity) { protected void restartApp(final Activity activity) {
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
//check if we got the PackageManager Intent mStartActivity = pm.getLaunchIntentForPackage(
if (pm != null) { getPackageName()
//create the intent with the default start activity for your application );
Intent mStartActivity = pm.getLaunchIntentForPackage( mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
getPackageName()
); int mPendingIntentId = 223344;
if (mStartActivity != null) { PendingIntent mPendingIntent = PendingIntent.getActivity(activity, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
//create a pending intent so the application is restarted after System.exit(0) was called. mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
// We use an AlarmManager to call this intent in 100ms
int mPendingIntentId = 223344; System.exit(0);
PendingIntent mPendingIntent = PendingIntent } catch (Exception e) {
.getActivity(activity, mPendingIntentId, mStartActivity, Log.e(LOG_TAG, e.getMessage());
PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
//kill the application
System.exit(0);
} else {
Log.e(LOG_TAG, "Was not able to restart application, mStartActivity null");
}
} else {
Log.e(LOG_TAG, "Was not able to restart application, PM null");
}
} catch (Exception ex) {
Log.e(LOG_TAG, "Was not able to restart application");
} }
} }
......
...@@ -132,6 +132,8 @@ public class FoundationsOptionsActivity extends BaseActivity { ...@@ -132,6 +132,8 @@ public class FoundationsOptionsActivity extends BaseActivity {
keyGingerDialog(); keyGingerDialog();
else if (isOption(position,8)) else if (isOption(position,8))
checkUpdate(); checkUpdate();
else if (isOption(position,9))
creditDialog();
else else
configDialog(); configDialog();
} }
...@@ -190,6 +192,11 @@ public class FoundationsOptionsActivity extends BaseActivity { ...@@ -190,6 +192,11 @@ public class FoundationsOptionsActivity extends BaseActivity {
}); });
} }
protected void creditDialog() {
dialog.infoDialog(FoundationsOptionsActivity.this, getString(R.string.credit), getString(R.string.author));
}
protected void configDialog() { protected void configDialog() {
if (config.getFoundationId() == -1 && config.getOptionList().size() == 0) { if (config.getFoundationId() == -1 && config.getOptionList().size() == 0) {
final View popupView = LayoutInflater.from(FoundationsOptionsActivity.this).inflate(R.layout.dialog_config, null, false); final View popupView = LayoutInflater.from(FoundationsOptionsActivity.this).inflate(R.layout.dialog_config, null, false);
......
...@@ -8,6 +8,7 @@ import android.content.IntentFilter; ...@@ -8,6 +8,7 @@ import android.content.IntentFilter;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
/** /**
...@@ -38,12 +39,12 @@ public abstract class InternetActivity extends NFCActivity { ...@@ -38,12 +39,12 @@ public abstract class InternetActivity extends NFCActivity {
this.internetAlertDialog this.internetAlertDialog
.setTitle(R.string.connection) .setTitle(R.string.connection)
.setMessage(R.string.internet_accessibility) .setMessage(R.string.internet_accessibility)
.setCancelable(true) .setCancelable(false)
.setPositiveButton(R.string.pass, null) .setNegativeButton(R.string.pass, new DialogInterface.OnClickListener() {
.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override @Override
public void onDismiss(final DialogInterface dialog) { public void onClick(DialogInterface dialog, int which) {
internetAlertDialog = null; internetAlertDialog = null;
if (!checkInternet(context)) if (!checkInternet(context))
enableInternetDialog(context); enableInternetDialog(context);
} }
......
...@@ -2,6 +2,7 @@ package fr.utc.simde.jessy; ...@@ -2,6 +2,7 @@ package fr.utc.simde.jessy;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
...@@ -132,6 +133,21 @@ public class MainActivity extends BaseActivity { ...@@ -132,6 +133,21 @@ public class MainActivity extends BaseActivity {
casConnexionDialog = false; casConnexionDialog = false;
} }
@Override
protected void enableInternetDialog(final Context context) {
Toast.makeText(context, R.string.internet_not_available, Toast.LENGTH_SHORT).show();
dialog.infoDialog(MainActivity.this, getString(R.string.connection), getString(R.string.internet_accessibility), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!checkInternet(context))
enableInternetDialog(context);
else
restartApp(MainActivity.this);
}
});
}
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (Integer.parseInt(android.os.Build.VERSION.SDK) > 5 && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (Integer.parseInt(android.os.Build.VERSION.SDK) > 5 && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
......
...@@ -65,17 +65,10 @@ ...@@ -65,17 +65,10 @@
android:id="@+id/text_app_registered" android:id="@+id/text_app_registered"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:gravity="center" android:gravity="center"
android:textStyle="italic" android:textStyle="italic"
android:text="@string/app_not_registred" /> android:text="@string/app_not_connected" />
<TextView
android:id="@+id/text_author"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/author"
android:layout_marginBottom="10dp"
android:gravity="center" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
...@@ -10,5 +10,6 @@ ...@@ -10,5 +10,6 @@
<item>Modifier la clé Nemopay</item> <item>Modifier la clé Nemopay</item>
<item>Modifier la clé Ginger</item> <item>Modifier la clé Ginger</item>
<item>Rechercher une mise à jour</item> <item>Rechercher une mise à jour</item>
<item>Crédits</item>
</string-array> </string-array>
</resources> </resources>
\ No newline at end of file
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<string name="quit">Quitter</string> <string name="quit">Quitter</string>
<string name="app_registred">Appareil enregistré</string> <string name="app_registred">Appareil enregistré</string>
<string name="app_not_registred">Appareil non enregistré</string> <string name="app_not_registred">Appareil non enregistré</string>
<string name="app_not_connected">Appareil non connectée</string>
<string name="username_dialog">Connexion par CAS</string> <string name="username_dialog">Connexion par CAS</string>
<string name="badge_dialog">Connexion par badge</string> <string name="badge_dialog">Connexion par badge</string>
<string name="username">Login</string> <string name="username">Login</string>
...@@ -58,6 +59,7 @@ ...@@ -58,6 +59,7 @@
<string name="type">Type</string> <string name="type">Type</string>
<string name="day_s_">jour(s)</string> <string name="day_s_">jour(s)</string>
<string name="update">Mise à jour</string> <string name="update">Mise à jour</string>
<string name="credit">Crédits</string>
<string name="author">&lt;/&gt; avec ♥ par Samy NASTUZZI</string> <string name="author">&lt;/&gt; avec ♥ par Samy NASTUZZI</string>
<string name="error_unexpected">Une erreur improbable a eu lieu</string> <string name="error_unexpected">Une erreur improbable a eu lieu</string>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment