Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hds
flexin
android-app
Commits
ac1690f1
Commit
ac1690f1
authored
Nov 16, 2017
by
Nastuzzi Samy
Browse files
Merge branch 'release/v0.9.2'
parents
ec6e5985
486bb0be
Changes
5
Hide whitespace changes
Inline
Side-by-side
PayUTC 0.9.
1
.apk
→
PayUTC 0.9.
2
.apk
View file @
ac1690f1
No preview for this file type
app/src/main/AndroidManifest.xml
View file @
ac1690f1
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"fr.utc.simde.jessy"
android:versionCode=
"2
5
"
android:versionName=
"0.9.
1
"
>
android:versionCode=
"2
6
"
android:versionName=
"0.9.
2
"
>
<uses-permission
android:name=
"android.permission.NFC"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
...
...
app/src/main/java/fr/utc/simde/jessy/BaseActivity.java
View file @
ac1690f1
...
...
@@ -2,7 +2,9 @@ package fr.utc.simde.jessy;
import
android.Manifest
;
import
android.app.Activity
;
import
android.app.AlarmManager
;
import
android.app.DownloadManager
;
import
android.app.PendingIntent
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.DialogInterface
;
...
...
@@ -16,6 +18,7 @@ import android.net.Uri;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.os.StrictMode
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v7.app.AlertDialog
;
import
android.util.Log
;
...
...
@@ -63,6 +66,9 @@ public abstract class BaseActivity extends InternetActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
StrictMode
.
VmPolicy
.
Builder
builder
=
new
StrictMode
.
VmPolicy
.
Builder
();
StrictMode
.
setVmPolicy
(
builder
.
build
());
this
.
dialog
=
new
Dialog
(
this
);
}
...
...
@@ -158,6 +164,38 @@ public abstract class BaseActivity extends InternetActivity {
}.
start
();
}
protected
void
restartApp
(
Activity
activity
)
{
try
{
PackageManager
pm
=
getPackageManager
();
//check if we got the PackageManager
if
(
pm
!=
null
)
{
//create the intent with the default start activity for your application
Intent
mStartActivity
=
pm
.
getLaunchIntentForPackage
(
getPackageName
()
);
if
(
mStartActivity
!=
null
)
{
mStartActivity
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
//create a pending intent so the application is restarted after System.exit(0) was called.
// We use an AlarmManager to call this intent in 100ms
int
mPendingIntentId
=
223344
;
PendingIntent
mPendingIntent
=
PendingIntent
.
getActivity
(
activity
,
mPendingIntentId
,
mStartActivity
,
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"
);
}
}
protected
void
startMainActivity
(
final
Activity
activity
)
{
disconnect
();
...
...
@@ -516,6 +554,7 @@ public abstract class BaseActivity extends InternetActivity {
protected
void
setNemopayKey
(
final
String
key
)
{
dialog
.
startLoading
(
BaseActivity
.
this
,
getString
(
R
.
string
.
nemopay_connection
),
getString
(
R
.
string
.
nemopay_authentification
));
new
Thread
()
{
@Override
public
void
run
()
{
...
...
@@ -578,7 +617,8 @@ public abstract class BaseActivity extends InternetActivity {
protected
void
checkUpdate
()
{
checkUpdate
(
true
);
}
protected
void
checkUpdate
(
final
boolean
popupIfNot
)
{
dialog
.
startLoading
(
BaseActivity
.
this
,
getString
(
R
.
string
.
information_collection
),
getString
(
R
.
string
.
check_update
));
final
Dialog
updateDialog
=
new
Dialog
(
BaseActivity
.
this
);
updateDialog
.
startLoading
(
BaseActivity
.
this
,
getString
(
R
.
string
.
information_collection
),
getString
(
R
.
string
.
check_update
));
new
Thread
()
{
@Override
...
...
@@ -593,7 +633,7 @@ public abstract class BaseActivity extends InternetActivity {
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
d
ialog
.
stopLoading
();
updateD
ialog
.
stopLoading
();
final
AlertDialog
.
Builder
alertDialogBuilder
=
new
AlertDialog
.
Builder
(
BaseActivity
.
this
);
alertDialogBuilder
...
...
@@ -602,15 +642,19 @@ public abstract class BaseActivity extends InternetActivity {
.
setCancelable
(
false
)
.
setPositiveButton
(
R
.
string
.
set_update
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialogInterface
,
int
id
)
{
if
(!
update
(
matcher
.
group
(
2
)))
{
dialog
.
stopLoading
();
dialog
.
errorDialog
(
BaseActivity
.
this
,
getString
(
R
.
string
.
update
),
getString
(
R
.
string
.
can_not_update
));
if
(!
haveStoragePermission
())
{
updateDialog
.
stopLoading
();
updateDialog
.
errorDialog
(
BaseActivity
.
this
,
getString
(
R
.
string
.
update
),
getString
(
R
.
string
.
need_storage_permission
));
}
else
if
(!
update
(
matcher
.
group
(
2
)))
{
updateDialog
.
stopLoading
();
updateDialog
.
errorDialog
(
BaseActivity
.
this
,
getString
(
R
.
string
.
update
),
getString
(
R
.
string
.
can_not_update
));
}
}
})
.
setNegativeButton
(
R
.
string
.
cancel
,
null
);
d
ialog
.
createDialog
(
alertDialogBuilder
);
updateD
ialog
.
createDialog
(
alertDialogBuilder
);
}
});
}
...
...
@@ -625,10 +669,10 @@ public abstract class BaseActivity extends InternetActivity {
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
d
ialog
.
stopLoading
();
updateD
ialog
.
stopLoading
();
if
(
popupIfNot
)
d
ialog
.
errorDialog
(
BaseActivity
.
this
,
getString
(
R
.
string
.
update
),
e
.
getMessage
()
+
"\n"
+
getString
(
R
.
string
.
actual_version
)
+
": "
+
BuildConfig
.
VERSION_NAME
);
updateD
ialog
.
errorDialog
(
BaseActivity
.
this
,
getString
(
R
.
string
.
update
),
e
.
getMessage
()
+
"\n"
+
getString
(
R
.
string
.
actual_version
)
+
": "
+
BuildConfig
.
VERSION_NAME
);
}
});
}
...
...
@@ -641,9 +685,6 @@ public abstract class BaseActivity extends InternetActivity {
final
String
url
=
this
.
gitUrl
+
getString
(
R
.
string
.
app_name
)
+
" "
+
version
+
".apk"
;
final
Uri
uri
=
Uri
.
parse
(
"file://"
+
destination
);
if
(!
haveStoragePermission
())
return
false
;
File
file
=
new
File
(
destination
);
if
(
file
.
exists
())
file
.
delete
();
...
...
@@ -664,7 +705,6 @@ public abstract class BaseActivity extends InternetActivity {
startActivity
(
install
);
unregisterReceiver
(
this
);
finish
();
}
};
...
...
app/src/main/java/fr/utc/simde/jessy/MainActivity.java
View file @
ac1690f1
...
...
@@ -473,7 +473,7 @@ public class MainActivity extends BaseActivity {
reloadButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
start
MainActivity
(
MainActivity
.
this
);
re
start
App
(
MainActivity
.
this
);
}
});
...
...
@@ -481,7 +481,7 @@ public class MainActivity extends BaseActivity {
@Override
public
void
onClick
(
View
v
)
{
config
.
reset
();
start
MainActivity
(
MainActivity
.
this
);
re
start
App
(
MainActivity
.
this
);
}
});
...
...
app/src/main/res/values/strings.xml
View file @
ac1690f1
...
...
@@ -158,6 +158,7 @@
<string
name=
"no_update"
>
Aucune mise à jour disponible
</string>
<string
name=
"actual_version"
>
Version actuelle
</string>
<string
name=
"available_version"
>
Version disponible
</string>
<string
name=
"need_storage_permission"
>
Il est nécessaire d\'autoriser l\'application à sauvegarder du contenu dans votre dossier de téléchargements
</string>
<string
name=
"print_mode"
>
Mode d\'affichage
</string>
<string
name=
"filters"
>
Filtres d\'affichage
</string>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment