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 @@
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<list size="5">
<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="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<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>
</value>
</option>
......
......@@ -3,7 +3,7 @@
<component name="ProjectModuleManager">
<modules>
<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>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
keyAlias 'jessy'
keyPassword 'payutc'
storeFile file('D:/cloud/Git/jessy/app/simde.jks')
storePassword 'simde-utc'
}
}
compileSdkVersion 26
buildToolsVersion '26.0.2'
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "fr.utc.simde.jessy"
applicationId "fr.utc.flexin"
minSdkVersion 21
targetSdkVersion 26
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
......@@ -22,11 +14,9 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile '/root'
signingConfig signingConfigs.config
}
debug {
proguardFile '/root'
signingConfig signingConfigs.config
}
}
packagingOptions {
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.utc.simde.jessy"
android:versionCode="47"
android:versionName="0.12.4">
package="fr.utc.flexin"
android:versionCode="1"
android:versionName="0.1.0">
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.INTERNET" />
......@@ -19,7 +19,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:launchMode="singleInstance"
android:theme="@style/AppTheme">
<activity android:name="fr.utc.simde.jessy.MainActivity"
<activity android:name="fr.utc.flexin.MainActivity"
android:configChanges="orientation"
android:screenOrientation="portrait">
......@@ -31,22 +31,10 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="fr.utc.simde.jessy.FoundationsOptionsActivity"
<activity android:name="fr.utc.flexin.ReaderActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity android:name="fr.utc.simde.jessy.BuyerInfoActivity"
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"
<activity android:name="fr.utc.flexin.MaterialActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" />
</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.Context;
......@@ -8,7 +8,6 @@ import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.v7.app.AlertDialog;
import android.widget.TextView;
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.PendingIntent;
......
This diff is collapsed.
package fr.utc.simde.jessy.adapters;
package fr.utc.flexin.adapters;
import android.app.Activity;
import android.view.LayoutInflater;
......@@ -9,7 +9,7 @@ import android.widget.TextView;
import com.fasterxml.jackson.databind.node.ArrayNode;
import fr.utc.simde.jessy.R;
import fr.utc.flexin.R;
/**
* Created by Samy on 28/10/2017.
......
package fr.utc.flexin.responses;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/**
* Created by Samy on 21/11/2017.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class CategoryResponse {
protected int id;
protected String name;
protected Integer parent_id;
public void setId(int id) { this.id = id; }
public void setName(String name) { this.name = name; }
public void setParentId(Integer id) { this.parent_id = id; }
public int getId() { return this.id; }
public String getName() { return this.name; }
public Integer getParentId() { return this.parent_id; }
}
package fr.utc.flexin.responses;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class InfrastructureResponse {
protected int id;
protected String name;
protected String description;
public void setId(int id) { this.id = id; }
public void setName(String name) { this.name = name; }
public void setDescription(String description) { this.description = description; }
public int getId() { return this.id; }
public String getName() { return this.name; }
public String getDescription() { return this.description; }
}
\ No newline at end of file
package fr.utc.simde.jessy.responses;
package fr.utc.flexin.responses;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......
package fr.utc.flexin.responses;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserResponse {
protected int id;
protected String name;
protected String lastname;
protected String firstname;
protected String email;
protected String phone;
protected String company;
protected String type;
public void setId(int id) { this.id = id; }
public void setName(String name) { this.name = name; }
public void setLastname(String name) { this.lastname = name; }
public void setFirstname(String name) { this.firstname = name; }
public void setEmail(String email) { this.email = email; }
public void setPhone(String phone) { this.phone = phone; }
public void setCompany(String company) { this.company = company; }
public void setType(String type) { this.type = type; }
public int getId() { return this.id; }
public String getName() { return name; }
public String getLastname() { return lastname; }
public String getFirstname() { return firstname; }
public String getEmail() { return email; }
public String getPhone() { return phone; }
public String getCompany() { return company; }
public String getType() { return type; }
}
package fr.utc.simde.jessy.tools;
package fr.utc.flexin.tools;
import android.content.SharedPreferences;
import android.util.Log;
......
package fr.utc.simde.jessy.tools;
package fr.utc.flexin.tools;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import fr.utc.simde.jessy.R;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import java.util.List;
import fr.utc.flexin.R;
import fr.utc.flexin.ReaderActivity;
import fr.utc.flexin.adapters.OptionsAdapter;
import fr.utc.flexin.views.ZXingCustomScannerView;
/**
* Created by Samy on 25/10/2017.
......@@ -22,6 +33,13 @@ public class Dialog {
private static AlertDialog.Builder alertDialogBuilder;
private static ProgressDialog loading;
protected Runnable onOpen;
protected Runnable onClose;
protected List<String> optionList;
protected OptionsAdapter optionsAdapter;
protected int optionSelected;
public Dialog(final Activity activity) {
this.activity = activity;
}
......@@ -39,6 +57,47 @@ public class Dialog {
public Boolean isShowing() { return (this.alertDialog != null && this.alertDialog.isShowing()) || (this.loading != null && this.loading.isShowing()); }
public void attachOnOpen(Runnable onOpen) {
this.onOpen = onOpen;
}
public void attachOnClose(Runnable onClose) {
this.onClose = onClose;
}
public void createMenu(final Activity activity, final String title, final List<String> optionList, final Runnable runnable) {
final View menuView = activity.getLayoutInflater().inflate(R.layout.dialog_list, null);
final ListView optionListView = menuView.findViewById(R.id.list_view);
this.optionList = optionList;
ArrayNode optionListAdded = (ArrayNode) new ObjectMapper().valueToTree(optionList);
try {
this.optionsAdapter = new OptionsAdapter(activity, optionListAdded);
} catch (Exception e) {
e.printStackTrace();
}
optionListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
optionSelected = position;
runnable.run();
}
});
optionListView.setAdapter(this.optionsAdapter);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity);
alertDialogBuilder
.setTitle(title)
.setView(menuView)
.setCancelable(true);
createDialog(alertDialogBuilder);
}
public int getOptionSelected() { return optionSelected; }
public void createDialog() { createDialog((EditText) null); }
public void createDialog(AlertDialog.Builder alertDialogBuilder) { createDialog(alertDialogBuilder, null); }
public void createDialog(AlertDialog.Builder alertDialogBuilder, final EditText input) { this.alertDialogBuilder = alertDialogBuilder; createDialog(input); }
......@@ -46,6 +105,16 @@ public class Dialog {
dismiss();
this.alertDialog = alertDialogBuilder.create();
if (this.onClose != null) {
this.alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
onClose.run();
}
});
}