Commit a425f0af authored by Christian Dresen's avatar Christian Dresen
Browse files

no message

parent 3638bdcd
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
......@@ -5,7 +5,7 @@
<GradleProjectSettings>
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.2.1" />
<option name="gradleHome" value="C:\Program Files\Android\Android Studio\gradle\gradle-2.8" />
<option name="gradleJvm" value="1.7" />
<option name="modules">
<set>
......
......@@ -3,6 +3,30 @@
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<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" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
......@@ -13,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
......@@ -8,7 +8,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
......
......@@ -12,10 +12,12 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<afterSyncTasks>
<task>generateDebugAndroidTestSources</task>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
......@@ -24,7 +26,7 @@
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<exclude-output />
......@@ -34,13 +36,13 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......@@ -63,43 +65,41 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="scribe-codepath-0.0.3" level="project" />
<orderEntry type="library" exported="" name="httpclient-android-4.3.5.1" level="project" />
<orderEntry type="library" exported="" name="activeandroid-3.0" level="project" />
<orderEntry type="library" exported="" name="jackson-core-2.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="spring-android-rest-template-1.0.1.RELEASE" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="gson-1.7.2" level="project" />
<orderEntry type="library" exported="" name="codepath-utils" level="project" />
<orderEntry type="library" exported="" name="okio-1.9.0" level="project" />
<orderEntry type="library" exported="" name="retrofit-2.0.0-beta2" level="project" />
<orderEntry type="library" exported="" name="converter-gson-2.0.0-beta2" level="project" />
<orderEntry type="library" exported="" name="jackson-databind-2.0.1" level="project" />
<orderEntry type="library" exported="" name="httpclient-android-4.3.5.1" level="project" />
<orderEntry type="library" exported="" name="jackson-annotations-2.0.1" level="project" />
<orderEntry type="library" exported="" name="spring-android-rest-template-1.0.1.RELEASE" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.7.5" level="project" />
<orderEntry type="library" exported="" name="antlr4-runtime-4.5.3" level="project" />
<orderEntry type="library" exported="" name="gson-2.7" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="spring-android-core-1.0.1.RELEASE" level="project" />
<orderEntry type="library" exported="" name="codepath-utils" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="jackson-core-2.0.1" level="project" />
</component>
</module>
\ No newline at end of file
......@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '23.0.0 rc2'
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "ms.itsecteam.warpdrink"
......@@ -32,7 +32,12 @@ dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.0.1'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.google.code.gson:gson:1.7.2'
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile group: 'com.squareup.retrofit' , name: 'retrofit' , version: '2.0.0-beta2'
compile group: 'com.squareup.retrofit' , name: 'converter-gson' , version: '2.0.0-beta2'
compile group: 'com.google.code.gson' , name: 'gson' , version: '2.7'
compile group: 'com.squareup.okio' , name: 'okio' , version: '1.9.0'
compile group: 'com.squareup.okhttp', name: 'okhttp', version: '2.7.5'
compile group: 'org.antlr', name: 'antlr4-runtime', version: '4.5.3'
}
......@@ -2,12 +2,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ms.itsecteam.warpdrink" >
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.NFC" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:name="ms.itsecteam.warpdrink.WarpDrinkApplication"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme">
<meta-data android:name="AA_DB_NAME" android:value="warpdrink_data.db" />
......@@ -19,12 +25,19 @@
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateVisible"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
</intent-filter>
</activity>
</application>
......
package ms.itsecteam.warpdrink;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.DialogInterface;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.content.IntentFilter;
import android.nfc.NfcAdapter;
import android.nfc.tech.NfcF;
import android.os.Bundle;
import android.view.KeyEvent;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import java.util.List;
import ms.itsecteam.warpdrink.data.objects.User;
import ms.itsecteam.warpdrink.data.models.local.User;
import ms.itsecteam.warpdrink.dialogs.NewUserDialog;
import ms.itsecteam.warpdrink.dialogs.SettingsDialog;
import ms.itsecteam.warpdrink.manager.DataManager;
import ms.itsecteam.warpdrink.manager.MainManager;
import ms.itsecteam.warpdrink.manager.UiManager;
import ms.itsecteam.warpdrink.orderList.Order;
public class MainActivity extends ActionBarActivity implements View.OnClickListener { // implements View.OnClickListener, View.OnKeyListener, AdapterView.OnItemClickListener, DialogInterface.OnClickListener {
private User currentUser;
private List<User> users;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private MainManager manager;
private NfcAdapter nfcAdapter;
private PendingIntent mPendingIntent;
private IntentFilter[] mIntentFilters;
private String[][] mNFCTechLists;
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
return true;
}
......@@ -40,15 +45,53 @@ public class MainActivity extends ActionBarActivity implements View.OnClickListe
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
setContentView(R.layout.activity_main);
this.manager = MainManager.getInstance();
this.manager.init(this);
this.nfcAdapter = NfcAdapter.getDefaultAdapter(this);
this.mPendingIntent = PendingIntent.getActivity(this, 0,
new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
IntentFilter ndefIntent = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
try {
this.mIntentFilters = new IntentFilter[] { ndefIntent };
} catch (Exception e) {
Log.e("TagDispatch", e.toString());
}
mNFCTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
public void onResume() {
super.onResume();
if (nfcAdapter != null) {
nfcAdapter.enableForegroundDispatch(this, mPendingIntent, mIntentFilters, mNFCTechLists);
}
}
@Override
public void onPause() {
super.onPause();
if (nfcAdapter != null)
nfcAdapter.disableForegroundDispatch(this);
}
protected void onNewIntent(Intent intent) {
String card_id = byteArrayToHex(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID));
DataManager.getInstance().setLastCardId(card_id);
if(this.manager.getCurrentUser() == null) {
User u = User.getByCardId(card_id);
this.manager.setCurrentUser(u);
}
}
public static String byteArrayToHex(byte[] a) {
StringBuilder sb = new StringBuilder(a.length * 2);
for(byte b: a)
sb.append(String.format("%02x", b & 0xff));
return sb.toString();
}
public void onClick(View v) {
......@@ -63,6 +106,21 @@ public class MainActivity extends ActionBarActivity implements View.OnClickListe
case R.id.action_new_user:
new NewUserDialog().show();
break;
case R.id.action_learn_card_id:
if (this.manager.getCurrentUser() != null){
new AlertDialog.Builder(this)
.setTitle(this.getResources().getString(R.string.confirm_payment_title))
.setMessage("Bitte die Karte vorhalten und nach dem Ton auf ok drücken.")
.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
MainManager.getInstance().saveCardId();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
} else {
Toast.makeText(this, "Bitte User auswählen", Toast.LENGTH_LONG).show();
}
default:
break;
}
......@@ -79,7 +137,7 @@ public class MainActivity extends ActionBarActivity implements View.OnClickListe
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction()==KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
if(this.atxvAdapter.getCount() == 1) {
setCurrentUser(DatabaseManager.getInstance().remoteGetUser(((User) this.atxvAdapter.getItem(0)).getUserid()));
setCurrentUser(SQLiteService.getInstance().remoteGetUser(((User) this.atxvAdapter.getItem(0)).getUserid()));
this.atxvName.setText(this.atxvAdapter.getItem(0).toString());
this.atxvName.dismissDropDown();
}
......@@ -90,7 +148,7 @@ public class MainActivity extends ActionBarActivity implements View.OnClickListe
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
setCurrentUser(DatabaseManager.getInstance().remoteGetUser(((User) this.atxvAdapter.getItem(position)).getUserid()));
setCurrentUser(SQLiteService.getInstance().remoteGetUser(((User) this.atxvAdapter.getItem(position)).getUserid()));
}
@Override
......
package ms.itsecteam.warpdrink;
import android.util.Log;
import com.activeandroid.ActiveAndroid;
import ms.itsecteam.warpdrink.manager.MainManager;
/**
* Created by Chris on 26.06.2015.
*/
public class WarpDrinkApplication extends com.activeandroid.app.Application {
@Override
public void onCreate() {
super.onCreate();
Log.d("DATABASE", "INIT");
ActiveAndroid.initialize(this);
}
......
package ms.itsecteam.warpdrink.data;
import java.util.List;
import ms.itsecteam.warpdrink.data.models.rest.RestProduct;
import ms.itsecteam.warpdrink.data.models.rest.RestUser;
import retrofit.Call;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
import retrofit.http.PUT;
import retrofit.http.Path;
public interface RestService {
@GET("users/{user}")
Call<RestUser> getSingleUser(@Path("user") String userid);
@GET("users/")
Call<List<RestUser>> getAllUser();
@POST("users/")
Call<RestUser> addUser(@Body RestUser user);
@PUT("users/{userid}/")
Call<RestUser> saveUser(@Path("userid") String uid, @Body RestUser user);
@GET("products/")
Call<List<RestProduct>> getAllProducts();
}
\ No newline at end of file
package ms.itsecteam.warpdrink.manager;
package ms.itsecteam.warpdrink.data;
import android.util.Log;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import ms.itsecteam.warpdrink.MainActivity;
import ms.itsecteam.warpdrink.data.objects.Setting;
import ms.itsecteam.warpdrink.data.objects.User;
import ms.itsecteam.warpdrink.data.rest.RestClient;
public class DatabaseManager {
import ms.itsecteam.warpdrink.data.models.local.Product;
import ms.itsecteam.warpdrink.data.models.local.Setting;
import ms.itsecteam.warpdrink.data.models.local.User;
import ms.itsecteam.warpdrink.data.models.rest.RestProduct;
import ms.itsecteam.warpdrink.data.models.rest.RestUser;
private static DatabaseManager instance;
private DatabaseManager() {}
public class SQLiteService {
public static DatabaseManager getInstance () {
if (DatabaseManager.instance == null)
DatabaseManager.instance = new DatabaseManager();
return DatabaseManager.instance;
}
private static SQLiteService instance;
private SQLiteService() {}
public User getUserByName(String name) {
return User.getByName(name);
}
public void refreshUserData(List<User> u) {
User.deleteAll();
if(u == null)
return;
ListIterator<User> ui = u.listIterator();
while(ui.hasNext()) {
ui.next().save();
}
Log.d("App", Arrays.toString(u.toArray()));
public static SQLiteService getInstance () {
if (SQLiteService.instance == null)
SQLiteService.instance = new SQLiteService();
return SQLiteService.instance;
}
......@@ -52,8 +40,29 @@ public class DatabaseManager {
return value;
}
public User remoteGetUser(int userid) {
return RestClient.getInstance().getUser(userid);
public List<User> refreshUserData(List<RestUser> u) {
User.deleteAll();
List<User> ret_val = new ArrayList<>();
for (RestUser anU : u) {
User usr = anU.toLocalUser();
usr.save();
ret_val.add(usr);
}
Log.d("App", Arrays.toString(u.toArray()));
return ret_val;
}
public List<Product> refreshProductData(List<RestProduct> body) {
Product.deleteAll();
List<Product> ret_val = new ArrayList<>();
for (RestProduct anU : body) {
Product prod = anU.toLocalProduct();
prod.save();
ret_val.add(prod);
}
return ret_val;
}
}
package ms.itsecteam.warpdrink.data.models.local;
import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Delete;
import com.activeandroid.query.Select;
import java.util.List;
@Table(name = "Products")
public class Product extends Model {
@Column(name = "pid")
private int pid;
@Column(name = "name")
private String name;
@Column(name = "category")
private String category;
@Column(name = "price")
private float price;
@Column(name = "count")
private int count;
public Product() {
super();
}
public Product(int pid, String name, String category, float price, int count) {
this.pid = pid;
this.name = name;
this.category = category;
this.price = price;
this.count = count;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {