Commit d6028ddc authored by Nastuzzi Samy's avatar Nastuzzi Samy

First commit

parent c9ac11ef
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables"> <option name="myNullables">
<value> <value>
<list size="4"> <list size="5">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> <item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list> </list>
</value> </value>
</option> </option>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/jessy.iml" filepath="$PROJECT_DIR$/jessy.iml" /> <module fileurl="file://$PROJECT_DIR$/tx.iml" filepath="$PROJECT_DIR$/tx.iml" />
</modules> </modules>
</component> </component>
</project> </project>
\ No newline at end of file
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
signingConfigs {
config {
keyAlias 'jessy'
keyPassword 'payutc'
storeFile file('D:/cloud/Git/jessy/app/simde.jks')
storePassword 'simde-utc'
}
}
compileSdkVersion 26 compileSdkVersion 26
buildToolsVersion '26.0.2' buildToolsVersion '27.0.3'
defaultConfig { defaultConfig {
applicationId "fr.utc.simde.jessy" applicationId "fr.utc.flexin"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 26 targetSdkVersion 26
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
...@@ -22,11 +14,9 @@ android { ...@@ -22,11 +14,9 @@ android {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile '/root' proguardFile '/root'
signingConfig signingConfigs.config
} }
debug { debug {
proguardFile '/root' proguardFile '/root'
signingConfig signingConfigs.config
} }
} }
packagingOptions { packagingOptions {
......
<?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.flexin"
android:versionCode="47" android:versionCode="1"
android:versionName="0.12.4"> android:versionName="0.1.0">
<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" />
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:launchMode="singleInstance" android:launchMode="singleInstance"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name="fr.utc.simde.jessy.MainActivity" <activity android:name="fr.utc.flexin.MainActivity"
android:configChanges="orientation" android:configChanges="orientation"
android:screenOrientation="portrait"> android:screenOrientation="portrait">
...@@ -31,22 +31,10 @@ ...@@ -31,22 +31,10 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name="fr.utc.simde.jessy.FoundationsOptionsActivity" <activity android:name="fr.utc.flexin.ReaderActivity"
android:configChanges="orientation" android:configChanges="orientation"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.BuyerInfoActivity" <activity android:name="fr.utc.flexin.MaterialActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.CardManagementActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.SellActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.EditActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.APIActivity"
android:configChanges="orientation" android:configChanges="orientation"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
</application> </application>
......
package fr.utc.flexin;
import android.Manifest;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v4.app.ActivityCompat;
import fr.utc.flexin.tools.Config;
import fr.utc.flexin.tools.Dialog;
import fr.utc.flexin.tools.FlexinAPI;
/**
* Created by Samy on 26/10/2017.
*/
public abstract class BaseActivity extends InternetActivity {
private static final String LOG_TAG = "_BaseActivity";
protected static FlexinAPI flexinAPI;
protected static Config config;
protected static Dialog dialog;
protected static SharedPreferences sharedPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= 24) {
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
}
this.flexinAPI = new FlexinAPI(this);
this.dialog = new Dialog(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
dialog.dismiss();
}
protected void disconnect() {
flexinAPI.disconnect();
}
protected void unregister(final Activity activity) {
disconnect();
dialog.errorDialog(activity, getString(R.string.key_registration), getString(R.string.key_remove_temp));
}
protected void fatal(final Activity activity, final String title, final String message) {
dialog.fatalDialog(activity, title, message, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
unregister(activity);
restartApp(activity);
}
});
}
protected void restartApp(final Activity activity) {
startMainActivity(activity);
}
protected void startMainActivity(final Activity activity) {
disconnect();
Intent intent = new Intent(activity, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
finish();
activity.startActivity(intent);
}
protected void startAPIActivity(final Activity activity) {
if (haveCameraPermission())
startActivity(new Intent(activity, ReaderActivity.class));
else
dialog.errorDialog(BaseActivity.this, getString(R.string.qrcode), getString(R.string.need_camera_permission));
}
protected boolean haveStoragePermission() {
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
return true;
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
return false;
}
}
else
return true;
}
protected boolean haveCameraPermission() {
if (Build.VERSION.SDK_INT >= 23) {
if (checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
return true;
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 1);
return false;
}
}
else
return true;
}
}
package fr.utc.simde.jessy; package fr.utc.flexin;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
...@@ -8,7 +8,6 @@ import android.content.IntentFilter; ...@@ -8,7 +8,6 @@ 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;
/** /**
......
package fr.utc.flexin;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.Toast;
import fr.utc.flexin.tools.Config;
/**
* Created by Samy on 24/10/2017.
*/
public class MainActivity extends BaseActivity {
private static final String LOG_TAG = "_MainActivity";
private boolean casConnexionDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
findViewById(R.id.button_username).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startAPIActivity(MainActivity.this);
}
});*/
launch();
}
@Override
public void onRestart() {
super.onRestart();
disconnect();
}
@Override
protected void onDestroy() {
super.onDestroy();
disconnect();
}
@Override
protected void onIdentification(final String badgeId) {
if (!dialog.isShowing()) {
dialog.startLoading(MainActivity.this, getString(R.string.badge_dialog), getString(R.string.badge_recognization));
new Thread(new Runnable() {
@Override
public void run() {
try {
flexinAPI.loginBadge(badgeId);
runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.stopLoading();
startAPIActivity(MainActivity.this);
}
});
} catch (final Exception e) {
Log.e(LOG_TAG, "error: " + e.getMessage());
runOnUiThread(new Runnable() {
@Override
public void run() {
if (flexinAPI.getRequest().getResponseCode() == 404)
dialog.errorDialog(MainActivity.this, getString(R.string.badge_dialog), getString(R.string.badge_error_not_recognized));
else
dialog.errorDialog(MainActivity.this, getString(R.string.badge_dialog), e.getMessage());
}
});
}
}
}).start();
}
}
@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
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (Integer.parseInt(android.os.Build.VERSION.SDK) > 5 && keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
onBackPressed();
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onBackPressed() {
Intent setIntent = new Intent(Intent.ACTION_MAIN);
setIntent.addCategory(Intent.CATEGORY_HOME);
setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(setIntent);
}
@Override
protected void unregister(final Activity activity) {
super.unregister(activity);
}
protected void launch() {
sharedPreferences = getSharedPreferences("flexin", Activity.MODE_PRIVATE);
config = new Config(sharedPreferences);
}
}
package fr.utc.flexin;
import android.os.Bundle;
import fr.utc.flexin.adapters.OptionsAdapter;
/**
* Created by Samy on 18/11/2017.
*/
public class MaterialActivity extends BaseActivity {
private static final String LOG_TAG = "_MaterialActivity";
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.material_activity);
}
}
package fr.utc.simde.jessy; package fr.utc.flexin;
import android.app.Activity; import android.app.Activity;
import android.app.PendingIntent; import android.app.PendingIntent;
......
package fr.utc.flexin;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.zxing.Result;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import fr.utc.flexin.adapters.OptionsAdapter;
import fr.utc.flexin.responses.CategoryResponse;
import fr.utc.flexin.responses.InfrastructureResponse;
import fr.utc.flexin.responses.UserResponse;
import fr.utc.flexin.views.ZXingCustomScannerView;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
import static android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK;
/**
* Created by Samy on 18/11/2017.
*/
public class ReaderActivity extends BaseActivity implements ZXingScannerView.ResultHandler {
private static final String LOG_TAG = "_ReaderActivity";
protected TextView scannerText;
protected ZXingCustomScannerView scannerView;
protected Button scannerButton;
protected Runnable buttonRunnable;
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reader_activity);
this.scannerText = findViewById(R.id.scanner_text);
this.scannerView = findViewById(R.id.scanner);
this.scannerButton = findViewById(R.id.scanner_button);
this.scannerView.setResultHandler(ReaderActivity.this);
this.scannerView.startCamera(CAMERA_FACING_BACK);
this.scannerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (buttonRunnable == null) {
try {
openMenu();
} catch (Exception e) {
e.printStackTrace();
}
}
else {
Runnable toRun = buttonRunnable;
buttonRunnable = null;
toRun.run();
}
}
});
defDialog();
}
@Override
public void onStart() {
super.onStart();
defDialog();
this.scannerView.setResultHandler(this);
this.scannerView.startCamera();
}
@Override
public void onResume() {
super.onResume();
defDialog();
if (!dialog.isShowing())
resumeReading();
}
@Override
public void onStop() {
super.onStop();
this.scannerView.stopCameraPreview();
this.scannerView.stopCamera();
}
@Override
public void onIdentification(final String badgeId) {
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ReaderActivity.this);
alertDialogBuilder
.setTitle(R.string.nfc_reading)
.setMessage(R.string.nfc_not_recognized)
.setCancelable(false)
.setNegativeButton(R.string.ok,null)
.setNeutralButton(R.string.add, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
createNewMaterial("badgeId", badgeId);
}
}
);
dialog.createDialog(alertDialogBuilder);
}
@Override
protected void enableInternetDialog(final Context context) {
Toast.makeText(context, R.string.internet_not_available, Toast.LENGTH_SHORT).show();
dialog.infoDialog(ReaderActivity.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(ReaderActivity.this);
}
});
}
protected void defDialog() {
this.dialog.attachOnOpen(new Runnable() {
@Override
public void run() {
pauseReading();
}
});
this.dialog.attachOnClose(new Runnable() {
@Override
public void run() {
resumeReading();
}
});
}
protected void openMenu() {
List<String> options = Arrays.asList(getResources().getStringArray(R.array.options));
dialog.createMenu(
ReaderActivity.this,
"Menu",
options,
new Runnable() {
@Override
public void run() {
switch (dialog.getOptionSelected()) {
case 0:
//openMaterialMenu();
break;
case 1:
openCategoryMenu();
break;
case 2:
openInfrastructureMenu();
break;