mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
Binary file not shown.
|
@ -0,0 +1,344 @@
|
|||
package com.adins.mss.odr.update;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.TableLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.adins.mss.foundation.dialog.DialogManager;
|
||||
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
import com.adins.mss.foundation.http.HttpConnectionResult;
|
||||
import com.adins.mss.foundation.http.HttpCryptedConnection;
|
||||
import com.adins.mss.foundation.image.ViewImageActivity;
|
||||
import com.adins.mss.odr.R;
|
||||
import com.adins.mss.odr.R.string;
|
||||
import com.adins.mss.odr.tool.ImageThumbnail;
|
||||
import com.adins.mss.odr.tool.getImageTask;
|
||||
import com.adins.mss.odr.update.JsonResponseDetailCancelOrder.ResponseServer;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
import static com.adins.mss.constant.Global.SHOW_USERHELP_DELAY_DEFAULT;
|
||||
|
||||
|
||||
public class OrderCancelActivity extends Activity implements OnClickListener {
|
||||
String nomorOrder;
|
||||
int taskType;
|
||||
String flag;
|
||||
String uuid_task_h;
|
||||
TableLayout detailTable;
|
||||
Button btnCancel;
|
||||
Button btnReject;
|
||||
public static byte[] imageResult=null;
|
||||
Map<ImageThumbnail, String> thumbnailMapping = new HashMap<>();
|
||||
List<ResponseServer> list;
|
||||
public static ImageThumbnail targetThumbnail = null;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.ordercancel_activity);
|
||||
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
|
||||
nomorOrder = getIntent().getExtras().getString(Global.BUND_KEY_ORDERNO);
|
||||
taskType = getIntent().getExtras().getInt(Global.BUND_KEY_TASK_TYPE);
|
||||
uuid_task_h = getIntent().getExtras().getString(Global.BUND_KEY_UUID_TASKH);
|
||||
flag = flagParamForType(taskType);
|
||||
|
||||
initialize();
|
||||
|
||||
new GetRequestDataDetail(nomorOrder, flag).execute();
|
||||
}
|
||||
@Override
|
||||
protected void attachBaseContext(Context newBase) {
|
||||
Context context = newBase;
|
||||
Locale locale;
|
||||
try {
|
||||
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} catch (Exception e) {
|
||||
locale = new Locale(LocaleHelper.ENGLSIH);
|
||||
context = LocaleHelper.wrap(newBase, locale);
|
||||
} finally {
|
||||
super.attachBaseContext(context);
|
||||
}
|
||||
}
|
||||
private void initialize(){
|
||||
detailTable = (TableLayout)findViewById(R.id.tableListLayout);
|
||||
btnCancel = (Button)findViewById(R.id.btnCancel);
|
||||
btnReject = (Button)findViewById(R.id.btnRejectOdr);
|
||||
btnReject.setOnClickListener(this);
|
||||
btnCancel.setOnClickListener(this);
|
||||
}
|
||||
private void loadDataDetailFromServer(String result){
|
||||
|
||||
int no =1;
|
||||
LayoutParams lpSpace =new LayoutParams(WRAP_CONTENT, MATCH_PARENT);
|
||||
LayoutParams lpQuestion =new LayoutParams(MATCH_PARENT, MATCH_PARENT,0.25f);
|
||||
LayoutParams lpNo =new LayoutParams(MATCH_PARENT, MATCH_PARENT,0.38f);
|
||||
try {
|
||||
JsonResponseDetailCancelOrder resultOrder = GsonHelper.fromJson(result, JsonResponseDetailCancelOrder.class);
|
||||
list = resultOrder.getListDetailOrder();
|
||||
for(ResponseServer responseServer : list){
|
||||
String question = responseServer.getKey();
|
||||
String answer = responseServer.getValue();
|
||||
String flag = responseServer.getFlag();
|
||||
|
||||
LinearLayout row = new LinearLayout(this);
|
||||
row.setOrientation(LinearLayout.HORIZONTAL);
|
||||
row.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1.0f));
|
||||
if (no % 2 == 1) {
|
||||
row.setBackgroundResource(R.color.tv_gray_light);
|
||||
}else{
|
||||
row.setBackgroundResource(R.color.tv_gray);
|
||||
}
|
||||
|
||||
TextView lblNo = new TextView(this);
|
||||
lblNo.setText(no+ ". ");
|
||||
lblNo.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
lblNo.setLayoutParams(lpNo);
|
||||
row.addView(lblNo);
|
||||
|
||||
TextView lblQuestion = new TextView(this);
|
||||
lblQuestion.setText(question);
|
||||
lblQuestion.setLayoutParams(lpQuestion);
|
||||
row.addView(lblQuestion);
|
||||
|
||||
TextView lblSpace = new TextView(this);
|
||||
lblSpace.setText(" : ");
|
||||
lblSpace.setLayoutParams(lpSpace);
|
||||
row.addView(lblSpace);
|
||||
if(flag.equals(Global.TRUE_STRING)){
|
||||
int w = 200;
|
||||
int h = 160;
|
||||
int density = getResources().getDisplayMetrics().densityDpi;
|
||||
if(density==DisplayMetrics.DENSITY_LOW){
|
||||
w = 80;
|
||||
h = 50;
|
||||
}else if(density==DisplayMetrics.DENSITY_MEDIUM){
|
||||
w = 120;
|
||||
h = 90;
|
||||
}
|
||||
final ImageThumbnail thumb = new ImageThumbnail(this, w, h);
|
||||
thumb.setOnClickListener(this);
|
||||
thumb.setLayoutParams(lpQuestion);
|
||||
thumbnailMapping.put(thumb, answer);
|
||||
row.addView(thumb);
|
||||
}else{
|
||||
TextView lblAnswer = new TextView(this);
|
||||
lblAnswer.setText(answer);
|
||||
lblAnswer.setLayoutParams(lpQuestion);
|
||||
row.addView(lblAnswer);
|
||||
|
||||
}
|
||||
detailTable.addView(row);
|
||||
no++;
|
||||
}
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserHelp.showAllUserHelp(OrderCancelActivity.this,OrderCancelActivity.this.getClass().getSimpleName());
|
||||
}
|
||||
}, SHOW_USERHELP_DELAY_DEFAULT);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
//=== Generate Flag ===//
|
||||
protected String flagParamForType(int taskType){
|
||||
switch (taskType) {
|
||||
case Global.TASK_ORDER_ASSIGNMENT:
|
||||
return "DOA";
|
||||
case Global.TASK_ORDER_REASSIGNMENT:
|
||||
return "DOR";
|
||||
case Global.TASK_CANCEL_ORDER:
|
||||
return "DCO";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
protected String flagParamForSubmitForType(int taskType){
|
||||
switch (taskType) {
|
||||
case Global.TASK_ORDER_ASSIGNMENT:
|
||||
return "SOA";
|
||||
case Global.TASK_ORDER_REASSIGNMENT:
|
||||
return "SOR";
|
||||
case Global.TASK_CANCEL_ORDER:
|
||||
return "SCO";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if(!Global.BACKPRESS_RESTRICTION) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
private class GetRequestDataDetail extends AsyncTask<Void, Void, String> {
|
||||
private ProgressDialog progressDialog;
|
||||
private String flag;
|
||||
private String nomorOrder;
|
||||
|
||||
public GetRequestDataDetail(String nomorOrder, String flag) {
|
||||
this.nomorOrder = nomorOrder;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progressDialog = ProgressDialog.show(OrderCancelActivity.this,
|
||||
"", getString(R.string.progressWait), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(Void... params) {
|
||||
String result = null;
|
||||
JsonRequestDetailCancelOrder request = new JsonRequestDetailCancelOrder();
|
||||
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
request.setNomor_order(this.nomorOrder);
|
||||
request.setUuid_task_h(uuid_task_h);
|
||||
|
||||
String json = GsonHelper.toJson(request);
|
||||
String url = GlobalData.getSharedGlobalData().getURL_GET_DETAIL_CANCELORDER();
|
||||
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
|
||||
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(getApplicationContext(), encrypt, decrypt);
|
||||
HttpConnectionResult serverResult = null;
|
||||
try {
|
||||
serverResult = httpConn.requestToServer(url, json);
|
||||
result = serverResult.getResult();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception ex) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(String result){
|
||||
if (progressDialog.isShowing()){
|
||||
try {
|
||||
progressDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
if(!GlobalData.isRequireRelogin()) {
|
||||
if ("".equals(result)) {
|
||||
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(getApplicationContext());
|
||||
dialogBuilder.withTitle(getString(string.info_capital))
|
||||
.withMessage(getString(R.string.no_result_from_server))
|
||||
.show();
|
||||
} else {
|
||||
loadDataDetailFromServer(result);
|
||||
}
|
||||
} else{
|
||||
DialogManager.showForceExitAlert(OrderCancelActivity.this, OrderCancelActivity.this.getString(com.adins.mss.base.R.string.msgLogout));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
||||
Global.getSharedGlobal().setIsViewer(false);
|
||||
if(id==R.id.btnCancel){
|
||||
List<NameValuePair> params = new ArrayList<>();
|
||||
params.add(new BasicNameValuePair(Global.BUND_KEY_ORDERNO, nomorOrder));
|
||||
params.add(new BasicNameValuePair(Global.BUND_KEY_TASK, "Cancel"));
|
||||
new CancelOrderTask(this, params).execute();
|
||||
}else if(id==R.id.btnRejectOdr){
|
||||
List<NameValuePair> params = new ArrayList<>();
|
||||
params.add(new BasicNameValuePair(Global.BUND_KEY_ORDERNO, nomorOrder));
|
||||
new RejectOrderTask(this, params).execute();
|
||||
}
|
||||
|
||||
ImageThumbnail imgThumbnail = null;
|
||||
try {
|
||||
imgThumbnail = (ImageThumbnail) v;
|
||||
if(Tool.isInternetconnected(this)){
|
||||
if (imgThumbnail.getResultImg() != null){
|
||||
try {
|
||||
Global.getSharedGlobal().setIsViewer(true);
|
||||
Bundle extras = new Bundle();
|
||||
extras.putByteArray(Global.BUND_KEY_IMAGE_BYTE, imgThumbnail.getResultImg());
|
||||
Intent intent = new Intent(this, ViewImageActivity.class);
|
||||
intent.putExtras(extras);
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String fieldKey = thumbnailMapping.get(v);
|
||||
if (nomorOrder != null && !"".equals(nomorOrder)) {
|
||||
targetThumbnail = (ImageThumbnail) v; //store thumbnail for further reference after connection finish
|
||||
|
||||
List<NameValuePair> params = new ArrayList<>();
|
||||
params.add(new BasicNameValuePair(Global.BUND_KEY_UUID_TASKH, uuid_task_h));
|
||||
params.add(new BasicNameValuePair(Global.BUND_KEY_QUESTIONID, fieldKey));
|
||||
try {
|
||||
new getImageTask(this, params).execute();
|
||||
byte[] result = OrderCancelActivity.imageResult;
|
||||
try {
|
||||
targetThumbnail.setResultImg(result);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.path_no_received), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
} else{
|
||||
Toast.makeText(this, this.getString(com.adins.mss.base.R.string.no_internet_connection), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
<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:background="@drawable/bg_grayscale"
|
||||
tools:context=".SurveyVerificationActionActivity" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:gravity="center"
|
||||
android:weightSum="1" >
|
||||
|
||||
<!-- <Button -->
|
||||
<!-- android:id="@+id/btnCancel" -->
|
||||
<!-- android:layout_width="wrap_content" -->
|
||||
<!-- android:layout_height="wrap_content" -->
|
||||
<!-- android:layout_weight="0.5" -->
|
||||
<!-- android:text="Cancel" /> -->
|
||||
|
||||
|
||||
<!-- <Button -->
|
||||
<!-- android:id="@+id/btnSubmit" -->
|
||||
<!-- android:layout_width="wrap_content" -->
|
||||
<!-- android:layout_height="wrap_content" -->
|
||||
<!-- android:layout_weight="0.5" -->
|
||||
<!-- android:text="Submit" /> -->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnBackLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:orientation="vertical"
|
||||
android:visibility="visible" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnBack"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/circle_button"
|
||||
android:gravity="center"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_back" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="back"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnSendLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.2"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnSend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/circle_button"
|
||||
android:clickable="true"
|
||||
android:gravity="center"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_send" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="send"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignRight="@+id/spinnerAction"
|
||||
android:layout_margin="5dp"
|
||||
android:text="Select Action :" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinnerAction"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/textView2"
|
||||
android:layout_margin="5dp"
|
||||
android:prompt="@string/selectOne" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/linearLayout1"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/spinnerAction" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblSvyList"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Surveyor List :" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/radioAction"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp" >
|
||||
</RadioGroup>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lblNotes"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:text="Notes :" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txtNotes"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:hint="@string/requiredField" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<scale
|
||||
android:fromXScale="0.3" android:toXScale="1.0"
|
||||
android:fromYScale="0.3" android:toYScale="1.0"
|
||||
android:pivotX="0%" android:pivotY="0%"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
<alpha
|
||||
android:interpolator="@android:anim/decelerate_interpolator"
|
||||
android:fromAlpha="0.0" android:toAlpha="1.0"
|
||||
android:duration="@android:integer/config_shortAnimTime"
|
||||
/>
|
||||
</set>
|
|
@ -0,0 +1,50 @@
|
|||
package com.adins.mss.base.util;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.adins.mss.foundation.formatter.Base64;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class GsonHelper {
|
||||
private static Gson gson = new GsonBuilder().setDateFormat("ddMMyyyyHHmmss").registerTypeHierarchyAdapter(byte[].class,
|
||||
new GsonHelper.ByteArrayToBase64TypeAdapter()).setExclusionStrategies(new MssGsonExclusionStrategy()).create();
|
||||
|
||||
public static <T> T fromJson(String json, java.lang.Class<T> classOfT) {
|
||||
if (gson == null) {
|
||||
gson = new GsonBuilder().setDateFormat("ddMMyyyyHHmmss").registerTypeHierarchyAdapter(byte[].class,
|
||||
new GsonHelper.ByteArrayToBase64TypeAdapter()).setExclusionStrategies(new MssGsonExclusionStrategy()).create();
|
||||
}
|
||||
return gson.fromJson(json, classOfT);
|
||||
}
|
||||
|
||||
public static String toJson(Object src) {
|
||||
if (gson == null) {
|
||||
gson = new GsonBuilder().setDateFormat("ddMMyyyyHHmmss").registerTypeHierarchyAdapter(byte[].class,
|
||||
new GsonHelper.ByteArrayToBase64TypeAdapter()).setExclusionStrategies(new MssGsonExclusionStrategy()).create();
|
||||
}
|
||||
return gson.toJson(src);
|
||||
}
|
||||
|
||||
@Keep
|
||||
public static class ByteArrayToBase64TypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> {
|
||||
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
return Base64.decode(json.getAsString());
|
||||
}
|
||||
|
||||
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(new String(Base64.encode(src)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -0,0 +1,303 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttonContainer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:padding="5dp"
|
||||
android:weightSum="1"
|
||||
android:background="@drawable/actionbar_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnBackLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.2"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageButton
|
||||
android:id="@+id/btnBack"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_back"
|
||||
android:gravity="center"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/circle_button"/>
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnBack"
|
||||
android:textSize="10dp"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnSaveLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageButton
|
||||
android:id="@+id/btnSave"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:src="@drawable/ic_save"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/circle_button"/>
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnSave"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnSendLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageButton
|
||||
android:id="@+id/btnSend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:clickable="false"
|
||||
android:src="@drawable/ic_send_off"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/circle_button"/>
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnSend"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnSearchLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ToggleButton
|
||||
android:id="@+id/btnSearchBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:layout_height="32dp"
|
||||
android:gravity="center"
|
||||
android:drawableTop="@drawable/ic_search"
|
||||
android:background="@drawable/circle_button" />
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnSearch"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnVerifiedLayout"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
android:layout_weight="0.2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageButton
|
||||
android:id="@+id/btnVerified"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:clickable="false"
|
||||
android:src="@drawable/ic_approve"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/circle_button"/>
|
||||
<TextView
|
||||
android:id="@+id/textView5"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnVerify"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnRejectLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.2"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageButton
|
||||
android:id="@+id/btnReject"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:src="@drawable/ic_reject"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/circle_button"/>
|
||||
<TextView
|
||||
android:id="@+id/textView6"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnReject"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnApproveLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.2"
|
||||
android:layout_width="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageButton
|
||||
android:id="@+id/btnApprove"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:src="@drawable/ic_approve"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/circle_button"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView7"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnApprove"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="10dp" />
|
||||
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnNextLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageButton
|
||||
android:id="@+id/btnNext"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:src="@drawable/ic_next"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/circle_button"/>
|
||||
<TextView
|
||||
android:id="@+id/textView8"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnNext"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/btnCloseLayout"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="0.2"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<ImageButton
|
||||
android:id="@+id/btnClose"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:src="@drawable/ic_reject"
|
||||
android:scaleType="centerInside"
|
||||
android:background="@drawable/circle_button"/>
|
||||
<TextView
|
||||
android:id="@+id/textView9"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:gravity="center"
|
||||
android:text="@string/btnClose"
|
||||
android:textSize="10dp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollContainer"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/searchLayout"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/questionContainer"
|
||||
android:padding="8dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollContainer2"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/searchLayout"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:visibility="gone"
|
||||
android:layout_alignParentTop="true" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reviewContainer"
|
||||
android:padding="8dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/searchLayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/buttonContainer"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@color/ab_end"
|
||||
android:padding="3dp" >
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/autoCompleteSearch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:background="@drawable/edittext_background"
|
||||
android:layout_toLeftOf="@+id/btnSearch"
|
||||
android:hint="@string/search_question" >
|
||||
</AutoCompleteTextView>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnSearch"
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="42dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/circle_button"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_search" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,76 @@
|
|||
package com.adins.mss.foundation.security;
|
||||
|
||||
import org.bouncycastle.crypto.CipherParameters;
|
||||
import org.bouncycastle.crypto.digests.SHA1Digest;
|
||||
import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator;
|
||||
import org.bouncycastle.crypto.params.KeyParameter;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
//import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator;
|
||||
|
||||
public class AESKeyGenerator {
|
||||
|
||||
private static final SecureRandom sr = new SecureRandom();
|
||||
|
||||
public AESKeyGenerator() {
|
||||
super();
|
||||
}
|
||||
|
||||
public KeyParameter generateNewAESKey(byte[] seeds) {
|
||||
|
||||
// byte[] seeds = sr.generateSeed(32);
|
||||
// if (Global.IS_DEV) System.out.println("key:" + new String(seeds) + " -key Hex:"
|
||||
// + new String(Hex.encode(seeds)));
|
||||
// if (Global.IS_DEV) System.out.println("key length:" + seeds.length);
|
||||
KeyParameter keyParam = new KeyParameter(seeds);
|
||||
return keyParam;
|
||||
}
|
||||
|
||||
public byte[] generateNewSeeds() {
|
||||
byte[] seeds = sr.generateSeed(32);
|
||||
return seeds;
|
||||
}
|
||||
|
||||
public byte[] generateAESKey(String phrase, byte[] salt, int count) {
|
||||
PKCS5S1ParametersGenerator paramGen = new PKCS5S1ParametersGenerator(
|
||||
new SHA1Digest());
|
||||
|
||||
byte[] phraseInBytes = PKCS5S1ParametersGenerator
|
||||
.PKCS5PasswordToBytes(phrase.toCharArray());
|
||||
|
||||
paramGen.init(phraseInBytes, salt, count);
|
||||
|
||||
CipherParameters ciphParams = paramGen.generateDerivedParameters(64);
|
||||
|
||||
KeyParameter keyParams = (KeyParameter) ciphParams;
|
||||
|
||||
byte[] key = keyParams.getKey();
|
||||
|
||||
// String hex = getHexString(key);
|
||||
// if (Global.IS_DEV) System.out.println(phrase);
|
||||
// if (Global.IS_DEV) System.out.println("Got: " + hex);
|
||||
// if (Global.IS_DEV) System.out.println("Got2: " + new String(key));
|
||||
return key;
|
||||
}
|
||||
|
||||
private String getHexString(byte[] hex) {
|
||||
StringBuffer buff = new StringBuffer();
|
||||
|
||||
for (int n = 0; n < hex.length; n++) {
|
||||
byte b = hex[n];
|
||||
int i = b & 0xFF;
|
||||
|
||||
String string = Integer.toHexString(i);
|
||||
|
||||
// Append leading zero if required
|
||||
if (string.length() == 1) {
|
||||
string = "0" + string;
|
||||
}
|
||||
|
||||
buff.append(string);
|
||||
}
|
||||
|
||||
return buff.toString();
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
Loading…
Add table
Add a link
Reference in a new issue