Skip to content
Snippets Groups Projects
Commit d6b19128 authored by Christian Dresen's avatar Christian Dresen
Browse files

Barcode v1

parent a01588a6
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ android {
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "ms.itsecteam.warpdrink"
applicationId "ms.warpzone.warppay"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
......
......@@ -37,7 +37,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private PendingIntent mPendingIntent;
private IntentFilter[] mIntentFilters;
private String[][] mNFCTechLists;
private String barcode;
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
......@@ -50,10 +50,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
getWindow().addFlags(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
setContentView(R.layout.activity_main);
this.findViewById(R.id.mainLayout).setOnKeyListener(this);
this.manager = MainManager.getInstance();
this.manager.init(this);
this.barcode = "";
this.findViewById(android.R.id.content).setOnKeyListener(this);
this.nfcAdapter = NfcAdapter.getDefaultAdapter(this);
......@@ -66,6 +67,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
Log.e("TagDispatch", e.toString());
}
mNFCTechLists = new String[][] { new String[] { NfcF.class.getName() } };
}
public void onResume() {
......@@ -132,15 +134,27 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_ENTER:
TextView t = (TextView) this.findViewById(R.id.txtCredit);
t.setText("asdasdasd");
return true;
}
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
return false;
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(this.manager.getCurrentUser() != null) {
if (event.getAction() == KeyEvent.ACTION_UP) {
if (KeyEvent.KEYCODE_ENTER == event.getKeyCode()) {
Toast.makeText(this, this.barcode, Toast.LENGTH_LONG).show();
this.barcode = "";
} else {
this.barcode += (char) event.getUnicodeChar();
}
}
}
return super.dispatchKeyEvent(event);
}
/*
@Override
......
......@@ -22,6 +22,10 @@ public class Product extends Model {
@Column(name = "category")
private String category;
@Column(name = "barcode")
private String barcode;
@Column(name = "price")
private float price;
......@@ -81,6 +85,14 @@ public class Product extends Model {
this.count = count;
}
public String getBarcode() {
return barcode;
}
public void setBarcode(String barcode) {
this.barcode = barcode;
}
public static List<Product> getAll() {
return new Select()
.from(Product.class)
......
......@@ -76,6 +76,7 @@ public class DataManager {
this.currentUser.setCredit(this.currentUser.getCredit() - this.totalAmount);
this.currentUser.save();
}
Log.d("USER", String.valueOf(this.currentUser.getCredit()));
this.totalAmount = 0.0;
}
......
package ms.warpzone.warppay.manager;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import android.widget.Toast;
import com.squareup.okhttp.OkHttpClient;
import java.io.IOException;
import java.io.InputStream;
import java.security.Certificate;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.List;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import ms.warpzone.warppay.MainActivity;
import ms.warpzone.warppay.R;
import ms.warpzone.warppay.data.SQLiteService;
......@@ -36,27 +53,62 @@ public class MainManager {
}
private MainManager() {
this.sqLiteService = SQLiteService.getInstance();
this.uiManager = UiManager.getInstance();
this.dataManager = DataManager.getInstance();
this.restService = this.createRestService();
}
private RestService createRestService() {
Retrofit retrofit = new Retrofit.Builder()
//.baseUrl("http://10.0.1.134:8000/api/")
//.baseUrl("https://infra-test.warpzone.ms/api/")
.baseUrl("http://192.168.0.194:8000/api/")
.addConverterFactory(GsonConverterFactory.create())
.build();
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl("https://infra-test.warpzone/api/")
.addConverterFactory(GsonConverterFactory.create());
OkHttpClient okHttp = new OkHttpClient();
try {
okHttp.setSslSocketFactory(getSSLConfig(this.getMainActivity().getBaseContext()).getSocketFactory());
} catch (CertificateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyStoreException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
Retrofit retrofit = builder.client(okHttp).build();
return retrofit.create(RestService.class);
}
private static SSLContext getSSLConfig(Context context) throws CertificateException, IOException,
KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
// Loading CAs from an InputStream
CertificateFactory cf = null;
String password = "e44r4dv9z1d0vwr9erotafxe66114v31jwhjlvttc8qkoa3nrskcj4ml0pwrh8aw";
KeyStore keyStore = KeyStore.getInstance("BKS");
keyStore.load(context.getResources().openRawResource(R.raw.keystore), password.toCharArray());
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
tmf.init(keyStore);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, tmf.getTrustManagers(), null);
return sslContext;
}
public void init(MainActivity mainActivity) {
this.mainActivity = mainActivity;
this.sqLiteService = SQLiteService.getInstance();
this.uiManager = UiManager.getInstance();
this.dataManager = DataManager.getInstance();
this.uiManager.initUi(this.mainActivity);
this.restService = this.createRestService();
this.refreshData();
}
......@@ -82,6 +134,7 @@ public class MainManager {
this.restService.getAllCategories().enqueue(new Callback<List<RestCategory>>() {
@Override
public void onResponse(Response<List<RestCategory>> response, Retrofit retrofit) {
Log.d("HALLO",response.message());
List<Category> categoryList = MainManager.getInstance().sqLiteService.refreshCategoryData(response.body());
if (categoryList != null) {
MainManager.getInstance().uiManager.showCategoryButtons();
......
......@@ -18,6 +18,7 @@ import android.widget.GridLayout;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
......@@ -198,7 +199,7 @@ public class UiManager implements View.OnKeyListener, View.OnClickListener, Adap
this.atxvName.dismissDropDown();
DataManager.getInstance().setIs_guest(false);
}
return true;
return false;
}
}
return false;
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context="ms.warpzone.warppay.MainActivity">
tools:context="ms.warpzone.warppay.MainActivity">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:orientation="vertical"
android:layout_width="464dp"
android:layout_height="361dp">
android:layout_height="361dp"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_row="0"
android:layout_column="1"
android:layout_row="0"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_gravity="center_vertical"
android:text="@string/name"
android:id="@+id/textView2"
android:layout_gravity="center_vertical" />
android:textAppearance="?android:attr/textAppearanceMedium" />
<Space
android:layout_width="20px"
android:layout_height="20px" />
<AutoCompleteTextView
android:id="@+id/atxvName"
android:layout_width="254dp"
android:layout_height="match_parent"
android:id="@+id/atxvName"
android:imeOptions="actionNext"
android:singleLine="true"
android:layout_column="0"
android:layout_columnSpan="1"
android:layout_row="0"
android:layout_column="0" />
android:imeOptions="actionNext"
android:singleLine="true" />
<Space
android:layout_width="8dp"
......@@ -84,14 +90,13 @@
android:layout_row="2" />
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridProducts"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="left"
android:columnCount="4"
android:orientation="horizontal"
android:id="@+id/gridProducts"
android:rowCount="3">
</GridLayout>
android:rowCount="3"></GridLayout>
<Space
android:layout_width="20px"
......@@ -100,9 +105,9 @@
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="363dp">
android:layout_height="363dp"
android:orientation="vertical">
<LinearLayout
......@@ -149,11 +154,11 @@
</LinearLayout>
<ListView
android:id="@+id/lstOrdered"
android:layout_width="wrap_content"
android:layout_height="255dp"
android:id="@+id/lstOrdered"
android:layout_row="2"
android:layout_column="12"
android:layout_row="2"
android:choiceMode="singleChoice" />
<Space
......@@ -161,11 +166,11 @@
android:layout_height="25px" />
<TextView
android:id="@+id/txtSum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/sum"
android:id="@+id/txtSum" />
android:textAppearance="?android:attr/textAppearanceMedium" />
<Space
android:layout_width="wrap_content"
......@@ -179,9 +184,9 @@
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/btnCharge"
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment