add project adins

This commit is contained in:
Alfrid Sanjaya Leo Putra 2024-07-25 14:44:22 +07:00
commit f8f85d679d
5299 changed files with 625430 additions and 0 deletions

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="-500%"
android:toXDelta="0%"
android:duration="1000" />
</set>

View file

@ -0,0 +1,103 @@
package com.adins.mss.foundation.camera;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Camera.Parameters;
import android.widget.ImageView;
import android.widget.Toast;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.util.ByteFormatter;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.LocationInfo;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.location.LocationTrackingManager;
import com.adins.mss.foundation.questiongenerator.QuestionBean;
import java.util.Date;
public class FormCamera extends Camera {
private QuestionBean questionInFocus;
private ImageView thumbInFocus;
public FormCamera(Context context, Activity activity,
android.hardware.Camera camera, Parameters params, QuestionBean questionInFocus) {
super(context, activity, camera, params);
this.questionInFocus = questionInFocus;
thumbInFocus = new ImageView(context);
}
@Override
protected void processImage(byte[] dataPicWithExif, LocationInfo locationInfo) {
// delegate
this.imageCallBack.onPictureTaken(dataPicWithExif, locationInfo);
LocationTrackingManager ltm = Global.LTM;
saveImage(dataPicWithExif);
boolean getGPS = true;
boolean isGeoTagged = Global.AT_IMAGE_W_LOCATION.equals(questionInFocus.getAnswer_type());
boolean isGeoTaggedGPSOnly = Global.AT_IMAGE_W_GPS_ONLY.equals(questionInFocus.getAnswer_type());
//Glen 7 Oct 2014, create timestamp, copy logic from MSMTOW, as default value if not using location
try {
long date = (new Date()).getTime();
getQuestionInFocus().setLovId(String.valueOf(date));
} catch (Exception e) {
FireCrash.log(e);
getQuestionInFocus().setLovId("0");
}
if (isGeoTagged && ltm != null) {
LocationInfo locInfo = ltm.getCurrentLocation(Global.FLAG_LOCATION_CAMERA);
getQuestionInFocus().setAnswer(locationInfoToSubmitString(locInfo));
}
if (isGeoTaggedGPSOnly && ltm != null) {
LocationInfo locInfo = ltm.getCurrentLocation(Global.FLAG_LOCATION_CAMERA);
//Glen 7 Oct 2014, add timestamp
if (Double.parseDouble(locInfo.getLatitude()) == 0.0 || Double.parseDouble(locInfo.getLongitude()) == 0.0) {
if (getQuestionInFocus().isMandatory() || getQuestionInFocus().isRelevantMandatory()) {
String[] msg = {"Can't get GPS location"};
String alert2 = Tool.implode(msg, "\n");
Toast.makeText(getContext(), alert2, Toast.LENGTH_LONG).show();
saveImage(null);
getGPS = false;
}
} else {
getQuestionInFocus().setAnswer(locationInfoToSubmitString(locInfo));
}
}
// set thumbnail
if (thumbInFocus != null && getGPS) {
Bitmap bm = BitmapFactory.decodeByteArray(dataPicWithExif, 0, dataPicWithExif.length);
int[] res = Tool.getThumbnailResolution(bm.getWidth(), bm.getHeight());
Bitmap thumbnail = Bitmap.createScaledBitmap(bm, res[0], res[1], true);
setThumb(thumbnail);
//Glen 21 Oct 2014, format byte
long size = getQuestionInFocus().getImgAnswer().length;
String formattedSize = ByteFormatter.formatByteSize(size);
setTxtDetail(" " + bm.getWidth() + " x " + bm.getHeight() + ". Size " + formattedSize);
questionInFocus = null;
}
}
private QuestionBean getQuestionInFocus() {
return questionInFocus;
}
private void setThumb(Bitmap bitmap) {
thumbInFocus.setImageBitmap(bitmap);
}
private void saveImage(byte[] imgAnswer) {
questionInFocus.setImgAnswer(imgAnswer);
}
}

View file

@ -0,0 +1,182 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loginLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg_grayscale"
android:orientation="vertical"
android:visibility="visible">
<include
android:id="@+id/include1"
layout="@layout/footer"/>
<!-- <CheckBox -->
<!-- android:id="@+id/cbShowPassword" -->
<!-- android:layout_width="wrap_content" -->
<!-- android:layout_height="wrap_content" -->
<!-- android:layout_below="@+id/relativeLayout2" -->
<!-- android:text="Show Password" -->
<!-- android:textAppearance="?android:attr/textAppearanceSmall" -->
<!-- android:textColor="@color/tv_darker" -->
<!-- android:visibility="visible" /> -->
<!-- <Button -->
<!-- android:id="@+id/btnLogin" -->
<!-- android:layout_width="fill_parent" -->
<!-- android:layout_height="wrap_content" -->
<!-- android:layout_below="@+id/cbShowPassword" -->
<!-- android:layout_centerHorizontal="true" -->
<!-- android:layout_weight="1" -->
<!-- android:background="@drawable/button_background" -->
<!-- android:text="@string/btnLogin" -->
<!-- android:textColor="#ffffff" /> -->
<CheckBox
android:id="@+id/cbShowPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeLayout2"
android:text="@string/lblShowPassword"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/tv_darker"
android:visibility="visible"/>
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/include1"
android:layout_below="@+id/profilePicture">
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="20dp">
<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtUserId"
android:layout_below="@+id/txtUserId"
android:layout_marginTop="7dp"
android:gravity="center_horizontal"
android:text="@string/lblLoginPassword"
android:textColor="#000000"
android:visibility="gone"/>
<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtPassword"
android:layout_alignParentTop="true"
android:layout_marginBottom="7dp"
android:gravity="center_horizontal"
android:text="@string/login_desc"
android:textColor="#001135"/>
<TextView
android:id="@+id/contentComment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtPassword"
android:layout_alignParentTop="true"
android:gravity="center_horizontal"
android:text="@string/lblLoginId"
android:textColor="#000000"
android:visibility="gone"/>
<EditText
android:id="@+id/txtPassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2"
android:layout_marginTop="7dp"
android:drawableLeft="@drawable/ms_lock_icon_black"
android:ems="10"
android:hint="@string/lblLoginPassword"
android:inputType="textPassword"
android:textColor="@color/tv_darker"
android:textColorHint="@color/tv_darker"/>
<EditText
android:id="@+id/txtUserId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txtPassword"
android:layout_below="@+id/textView3"
android:drawableLeft="@drawable/ms_user_icon_black"
android:ems="10"
android:hint="@string/lblLoginId"
android:singleLine="true"
android:textColor="@color/tv_darker"
android:textColorHint="@color/tv_darker"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtUserId"
android:background="@color/tv_normal"
android:orientation="vertical"
android:visibility="gone">
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/include1"
android:layout_alignParentRight="true"
android:weightSum="1"
android:layout_marginTop="15dp"
android:layout_below="@+id/cbShowPassword">
<Button
android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/btnLogin"
android:textColor="#ffffff"
android:visibility="visible"/>
<Button
android:id="@+id/btnExit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:background="@drawable/button_background"
android:text="@string/btnExit"
android:textColor="#ffffff"
android:visibility="visible"/>
</LinearLayout>
<CheckBox
android:id="@+id/cbRememberMe2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/include1"
android:layout_below="@+id/relativeLayout2"
android:text="@string/lblRememberMe"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/tv_darker"
android:visibility="visible"/>
<ImageView
android:id="@+id/profilePicture"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"
android:src="@drawable/dummy"/>
</RelativeLayout>

View file

@ -0,0 +1,83 @@
package com.adins.mss.base.util;
import com.adins.mss.constant.Global;
public class PagingHelper {
private int page = 1;
private int totalPage;
private int pageSize;
private int start;
private int end;
private int totalRecord;
public PagingHelper() {
this.pageSize = Global.ROW_PER_PAGE;
}
public PagingHelper(int rowPerPage) {
this.pageSize = rowPerPage;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getStart() {
this.start = (page - 1) * pageSize + 1;
return start;
}
public int getEnd() {
this.end = this.start + pageSize - 1;
this.end = (this.end > totalRecord) ? totalRecord : this.end;
return end;
}
public void setTotalRecord(int totalRecord) {
this.totalRecord = totalRecord;
this.totalPage = (int) Math.ceil((double) totalRecord / this.pageSize);
}
/* NAVIGATE */
public void next() {
page++;
page = (page > totalPage) ? totalPage : page;
}
public void previous() {
page--;
page = (page < 1) ? 1 : page;
}
//Glen 9 Sept 2014, new navigation function
public void goTo(int page) {
if (page < 1) {
this.page = 1;
} else if (page > totalPage) {
this.page = totalPage;
} else {
this.page = page;
}
}
}

View file

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/card_margin"
android:background="?android:selectableItemBackground"
app:cardCornerRadius="5dp"
app:cardElevation="@dimen/card_shadow">
<LinearLayout
android:id="@+id/menu_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/fontColorWhite"
android:paddingTop="10dp"
android:paddingBottom="15dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="90dp"
android:layout_height="70dp"
android:layout_gravity="center_horizontal">
<ImageView
android:id="@+id/itemIcon"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
app:srcCompat="@drawable/menu_newtask" />
<TextView
android:id="@+id/counter"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:text="0"
android:textColor="@color/fontColorWhite"
android:textSize="7dp"
android:gravity="center"
android:elevation="5dp"
android:background="@drawable/counter_bg"
android:visibility="gone"/>
</RelativeLayout>
<TextView
android:id="@+id/itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="11dp"
android:textAlignment="center"
android:layout_marginTop="10dp"
android:text="Item Menu"/>
</LinearLayout>
</androidx.cardview.widget.CardView>

View file

@ -0,0 +1,55 @@
package com.adins.mss.base.log;
import com.adins.mss.dao.PrintResult;
import java.util.List;
public abstract class AbstractPrintManager {
public static String PRINT_ANSWER = "002";
protected boolean connected = false;
protected String valueSeparator = ":";
protected char blank = ' ';
protected int labelStart = 0;
protected int separatorStart = 0;
protected int valueStart = 0;
protected List<PrintResult> list;
public AbstractPrintManager(List<PrintResult> list) {
if (list == null)
throw new IllegalArgumentException("Print list can not be null!");
this.list = list;
int longestLabel = 1;
for (PrintResult bean : list) {
if (PRINT_ANSWER.equals(bean.getPrint_type_id())) {
String label = bean.getLabel();
if (label != null) {
int len = label.length();
longestLabel = (len > longestLabel) ? len : longestLabel;
}
}
}
this.separatorStart = longestLabel + 1;
this.valueStart = longestLabel + 3;
}
public void setValueSeparator(String valueSeparator) {
this.valueSeparator = valueSeparator;
}
public boolean isConnected() {
return connected;
}
public abstract boolean connect() throws Exception;
public abstract boolean disconnect() throws Exception;
public abstract boolean print() throws Exception;
// bong Oct 28th, 2014 - adding code from fif
public abstract boolean printSato() throws Exception;
public abstract boolean printZebra() throws Exception;
}

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Spinner
android:id="@+id/sn_rv_numbers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/dropdown_background"/>
<Button
android:id="@+id/bt_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="5dp"
android:text="@string/btnSend"
android:background="@drawable/button_background"
android:textColor="@color/fontColorWhite"/>
</RelativeLayout>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:startColor="#f06a4d"
android:endColor="#ab2002"
android:angle="90" />
<corners
android:radius="0dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,555 @@
package com.adins.mss.foundation.db.dataaccess;
import android.content.Context;
import android.database.Cursor;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.DaoSession;
import com.adins.mss.dao.Lookup;
import com.adins.mss.dao.LookupDao;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.db.DaoOpenHelper;
import java.util.ArrayList;
import java.util.List;
import de.greenrobot.dao.query.QueryBuilder;
public class LookupDataAccess {
/**
* use to generate dao session that you can access modelDao
*
* @param context --> context from activity
* @return
*/
protected static DaoSession getDaoSession(Context context) {
return DaoOpenHelper.getDaoSession(context);
}
/**
* get lookupDao dao and you can access the DB
*
* @param context
* @return
*/
protected static LookupDao getLookupDao(Context context) {
return getDaoSession(context).getLookupDao();
}
/**
* Clear session, close db and set daoOpenHelper to null
*/
public static void closeAll() {
DaoOpenHelper.closeAll();
}
/**
* add lookup as entity
*
* @param context
* @param lookup
*/
public static void add(Context context, Lookup lookup) {
getLookupDao(context).insertInTx(lookup);
getDaoSession(context).clear();
}
/**
* add lookup as list entity
*
* @param context
* @param lookupList
*/
public static void add(Context context, List<Lookup> lookupList) {
getLookupDao(context).insertInTx(lookupList);
getDaoSession(context).clear();
}
/**
* delete all content in table.
*
* @param context
*/
public static void clean(Context context) {
getLookupDao(context).deleteAll();
getDaoSession(context).clear();
}
/**
* @param lookup
* @param context
*/
public static void delete(Context context, Lookup lookup) {
getLookupDao(context).delete(lookup);
getDaoSession(context).clear();
}
/**
* delete all record by keyQuestionSet
*
* @param context
*/
public static void delete(Context context, String keyQuestionSet) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Uuid_question_set.eq(keyQuestionSet));
qb.build();
getLookupDao(context).deleteInTx(qb.list());
getDaoSession(context).clear();
}
public static void deleteByLovGroup(Context context, String lovGroup) {
// QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
// qb.where(LookupDao.Properties.Lov_group.eq(lovGroup));
List<String> submittedRv = new ArrayList<>();
List<TaskH> taskFailed = TaskHDataAccess.getAllTaskInFailedSubmitted(context);
if (null != taskFailed && taskFailed.size() > 0) {
for (TaskH taskH : taskFailed) {
submittedRv.add(taskH.getRv_number());
}
}
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.eq(lovGroup),
LookupDao.Properties.Code.notIn(submittedRv));
qb.build();
getLookupDao(context).deleteInTx(qb.list());
getDaoSession(context).clear();
}
/**
* @param lookup
* @param context
*/
public static void update(Context context, Lookup lookup) {
getLookupDao(context).updateInTx(lookup);
getDaoSession(context).clear();
}
public static void addOrUpdateAll(final Context context, final List<Lookup> lookup) {
getLookupDao(context).insertOrReplaceInTx(lookup);
getDaoSession(context).clear();
}
/**
* select * from table where uuid_question_set = param
*
* @param context
* @param keyQuestionSet
* @return
*/
public static List<Lookup> getAll(Context context, String keyQuestionSet) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Uuid_question_set.eq(keyQuestionSet));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByLovGroup(Context context, String lov_group) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByLovGroupTextWithSuggestion(Context context, String lov_group, String dynamicFilter) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.eq(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Value.like("%"+dynamicFilter + "%"));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilter(Context context, String lov_group, String filter1) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Filter1.like(filter1));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilter(Context context, String lov_group, String filter1, String filter2) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Filter1.like(filter1),
LookupDao.Properties.Filter2.like(filter2));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilter(Context context, String lov_group, String filter1, String filter2, String filter3) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Filter1.like(filter1),
LookupDao.Properties.Filter2.like(filter2),
LookupDao.Properties.Filter3.like(filter3));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilter(Context context, String lov_group, String filter1, String filter2, String filter3, String filter4) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Filter1.like(filter1),
LookupDao.Properties.Filter2.like(filter2),
LookupDao.Properties.Filter3.like(filter3),
LookupDao.Properties.Filter4.like(filter4));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilter(Context context, String lov_group, String filter1, String filter2, String filter3, String filter4, String filter5) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Filter1.like(filter1),
LookupDao.Properties.Filter2.like(filter2),
LookupDao.Properties.Filter3.like(filter3),
LookupDao.Properties.Filter4.like(filter4),
LookupDao.Properties.Filter5.like(filter5));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilterTextWithSuggestion(Context context, String lov_group, String filter1, String dynamicFilter) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.eq(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Value.like(dynamicFilter + "%"));
if (filter1.contains("%")) {
if (filter1.length() > 1)
qb.where(LookupDao.Properties.Filter1.like("%" + filter1 + "%"));
} else {
qb.where(LookupDao.Properties.Filter1.like(filter1));
}
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilterTextWithSuggestion(Context context, String lov_group, String filter1, String filter2, String dynamicFilter) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.eq(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Value.like(dynamicFilter + "%"));
if (filter1.contains("%")) {
if (filter1.length() > 1)
qb.where(LookupDao.Properties.Filter1.like("%" + filter1 + "%"));
} else {
qb.where(LookupDao.Properties.Filter1.eq(filter1));
}
if (filter2.contains("%")) {
if (filter2.length() > 1)
qb.where(LookupDao.Properties.Filter2.like("%" + filter2 + "%"));
} else {
qb.where(LookupDao.Properties.Filter2.eq(filter2));
}
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilterTextWithSuggestion(Context context, String lov_group, String filter1, String filter2, String filter3, String dynamicFilter) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.eq(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Value.like(dynamicFilter + "%"));
if (filter1.contains("%")) {
if (filter1.length() > 1)
qb.where(LookupDao.Properties.Filter1.like("%" + filter1 + "%"));
} else {
qb.where(LookupDao.Properties.Filter1.eq(filter1));
}
if (filter2.contains("%")) {
if (filter2.length() > 1)
qb.where(LookupDao.Properties.Filter2.like("%" + filter2 + "%"));
} else {
qb.where(LookupDao.Properties.Filter2.eq(filter2));
}
if (filter3.contains("%")) {
if (filter3.length() > 1)
qb.where(LookupDao.Properties.Filter3.like("%" + filter3 + "%"));
} else {
qb.where(LookupDao.Properties.Filter3.eq(filter3));
}
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilterTextWithSuggestion(Context context, String lov_group, String filter1, String filter2, String filter3, String filter4, String dynamicFilter) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.eq(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Value.like(dynamicFilter + "%"));
if (filter1.contains("%")) {
if (filter1.length() > 1)
qb.where(LookupDao.Properties.Filter1.like("%" + filter1 + "%"));
} else {
qb.where(LookupDao.Properties.Filter1.eq(filter1));
}
if (filter2.contains("%")) {
if (filter2.length() > 1)
qb.where(LookupDao.Properties.Filter2.like("%" + filter2 + "%"));
} else {
qb.where(LookupDao.Properties.Filter2.eq(filter2));
}
if (filter3.contains("%")) {
if (filter3.length() > 1)
qb.where(LookupDao.Properties.Filter3.like("%" + filter3 + "%"));
} else {
qb.where(LookupDao.Properties.Filter3.eq(filter3));
}
if (filter4.contains("%")) {
if (filter4.length() > 1)
qb.where(LookupDao.Properties.Filter4.like("%" + filter4 + "%"));
} else {
qb.where(LookupDao.Properties.Filter4.eq(filter4));
}
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static List<Lookup> getAllByFilterTextWithSuggestion(Context context, String lov_group, String filter1, String filter2, String filter3, String filter4, String filter5, String dynamicFilter) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.eq(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Value.like(dynamicFilter + "%"));
if (filter1.contains("%")) {
if (filter1.length() > 1)
qb.where(LookupDao.Properties.Filter1.like("%" + filter1 + "%"));
} else {
qb.where(LookupDao.Properties.Filter1.eq(filter1));
}
if (filter2.contains("%")) {
if (filter2.length() > 1)
qb.where(LookupDao.Properties.Filter2.like("%" + filter2 + "%"));
} else {
qb.where(LookupDao.Properties.Filter2.eq(filter2));
}
if (filter3.contains("%")) {
if (filter3.length() > 1)
qb.where(LookupDao.Properties.Filter3.like("%" + filter3 + "%"));
} else {
qb.where(LookupDao.Properties.Filter3.eq(filter3));
}
if (filter4.contains("%")) {
if (filter4.length() > 1)
qb.where(LookupDao.Properties.Filter4.like("%" + filter4 + "%"));
} else {
qb.where(LookupDao.Properties.Filter4.eq(filter4));
}
if (filter5.contains("%")) {
if (filter5.length() > 1)
qb.where(LookupDao.Properties.Filter5.like("%" + filter5 + "%"));
} else {
qb.where(LookupDao.Properties.Filter5.eq(filter5));
}
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
public static Lookup getOne(Context context, String uuidLookup,
String lov_group) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Uuid_lookup.eq(uuidLookup));
qb.limit(1);
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
public static Lookup getOneByCode(Context context, String uuidLookup,
String code) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Code.like(code),
LookupDao.Properties.Uuid_lookup.eq(uuidLookup));
qb.limit(1);
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
public static Lookup getOneByCodeAndlovGroup(Context context, String lov_group,
String code) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Code.like(code),
LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING));
qb.limit(1);
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
public static Lookup getOneByValueAndlovGroup(Context context, String lov_group,
String value) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Value.like(value),
LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING));
qb.limit(1);
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
/**
* select lookup per
*
* @param context
* @return
*/
public static Lookup getOne(Context context, String uuidLookup) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(
LookupDao.Properties.Uuid_lookup.eq(uuidLookup));
qb.limit(1);
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
public static Lookup getOneByLovGroup(Context context, String lov_group) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(
LookupDao.Properties.Lov_group.like(lov_group));
qb.limit(1);
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
/**
* add or replace data taskH
*
* @param context
*/
public static void addOrReplace(Context context, Lookup lookup) {
Lookup nlookup = getOne(context, lookup.getUuid_lookup(), lookup.getLov_group());
if (nlookup != null) {
delete(context, nlookup);
}
add(context, lookup);
}
public static void updateToActive(Context context, String uuid_lookup) {
Lookup lookup = getOne(context, uuid_lookup);
if(lookup != null){
lookup.setIs_active(Global.TRUE_STRING);
getLookupDao(context).insertOrReplaceInTx(lookup);
}
}
public static List<String> getAllCode(Context context, String lov_group) {
List<String> result = new ArrayList<>();
String SQL_DISTINCT_ENAME = "SELECT " + LookupDao.Properties.Code.columnName +
" FROM " + LookupDao.TABLENAME + " WHERE " + LookupDao.Properties.Lov_group.columnName + "='" +
lov_group + "'";
Cursor c = getLookupDao(context).getDatabase().rawQuery(SQL_DISTINCT_ENAME, null);
if (c.moveToFirst()) {
do {
result.add(c.getString(0));
} while (c.moveToNext());
}
c.close();
return result;
}
public static List<String> getAllCodeByFilter(Context context, String lov_group, String filter, int limit) {
List<String> result = new ArrayList<>();
String SQL_DISTINCT_ENAME = "SELECT " + LookupDao.Properties.Code.columnName +
" FROM " + LookupDao.TABLENAME + " WHERE " + LookupDao.Properties.Lov_group.columnName + "='" +
lov_group + "' AND " +
LookupDao.Properties.Is_deleted.columnName + "='" + Global.FALSE_STRING + "' AND " +
LookupDao.Properties.Is_active.columnName + "='" + Global.TRUE_STRING + "' AND " +
LookupDao.Properties.Code.columnName + " LIKE '" + filter + "%' ORDER BY " +
LookupDao.Properties.Code.columnName +
" ASC LIMIT " + limit;
Cursor c = getLookupDao(context).getDatabase().rawQuery(SQL_DISTINCT_ENAME, null);
if (c.moveToFirst()) {
do {
result.add(c.getString(0));
} while (c.moveToNext());
}
c.close();
return result;
}
public static List<Lookup> getAllByLovGroupWithFilter(Context context, String lov_group, String filter, int limit) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lov_group),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING),
LookupDao.Properties.Value.like(filter + "%"));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.limit(limit);
qb.build();
return qb.list();
}
public static Lookup getOneLastUpdByLovGroup(Context context, String lov_group) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(
LookupDao.Properties.Lov_group.eq(lov_group));
qb.orderDesc(LookupDao.Properties.Dtm_upd);
qb.limit(1);
qb.build();
if (qb.list().isEmpty())
return null;
return qb.list().get(0);
}
public static List<Lookup> getAllByLovGroup(Context context, String lovGroup, String branchId, String schemeFlag) {
QueryBuilder<Lookup> qb = getLookupDao(context).queryBuilder();
qb.where(LookupDao.Properties.Lov_group.like(lovGroup),
LookupDao.Properties.Filter1.eq(branchId),
LookupDao.Properties.Filter2.eq(schemeFlag),
LookupDao.Properties.Is_deleted.eq(Global.FALSE_STRING),
LookupDao.Properties.Is_active.eq(Global.TRUE_STRING));
qb.orderAsc(LookupDao.Properties.Sequence);
qb.build();
return qb.list();
}
}

View file

@ -0,0 +1,65 @@
package com.adins.mss.coll;
import com.adins.mss.foundation.formatter.Formatter;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.digests.SHA256Digest;
import org.bouncycastle.crypto.macs.HMac;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.util.encoders.Hex;
import org.junit.Test;
import java.util.Date;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
@Test
public void checkSignature() throws Exception {
String keys = "0000000000000000";
String text = "190320191338010820135747mokasale";
Digest digest = new SHA256Digest();
HMac hMac = new HMac(digest);
hMac.init(new KeyParameter(keys.getBytes()));
hMac.update(text.getBytes(), 0, text.getBytes().length);
byte[] result = new byte[digest.getDigestSize()];
hMac.doFinal(result, 0);
String signature = new String(Hex.encode(result));
System.out.println(signature);
}
@Test
public void dateTimeTest() {
String dateTime = Formatter.formatDate(new Date(), "ddMMyyyyHHmmss");
System.out.println(dateTime);
}
@Test
public void testDataResult() {
String result = "00000001|000000000002|DEBIT|553210**********5437|EXPDATE : 08/17|SWIPE|SALE|000003|000004|06Mar2012|10:52:58|123456789012|12345|5,000|";
String[] data = result.split("\\|");
String terminalId = data[0];
String merchantId = data[1];
String cardType = data[2];
String cardNumber = data[3];
String expireDate = data[4];
String entryMode = data[5];
String trxType = data[6];
String batchId = data[7];
String traceId = data[8];
String dateTrx = data[9];
String timeTrx = data[10];
String reference = data[11];
String approvalId = data[12];
String totalAmount= data[13];
}
}

View file

@ -0,0 +1,392 @@
package com.adins.mss.base.dialogfragments;
import android.app.ProgressDialog;
import android.graphics.Rect;
import android.os.AsyncTask;
import android.os.Bundle;
import androidx.annotation.Keep;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.NewMainActivity;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.dynamicform.JsonRequestSubmitTask;
import com.adins.mss.base.dynamicform.JsonResponseSubmitTask;
import com.adins.mss.base.timeline.NewTimelineFragment;
import com.adins.mss.base.timeline.TimelineManager;
import com.adins.mss.base.todolist.ToDoList;
import com.adins.mss.base.todolist.form.RescheduleFragment;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.base.util.Utility;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.LocationInfo;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.formatter.Formatter;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.androidquery.AQuery;
import com.github.jjobes.slidedatetimepicker.SlideDateTimeListener;
import com.github.jjobes.slidedatetimepicker.SlideDateTimePicker;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.HttpMetric;
import org.acra.ACRA;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Created by olivia.dg on 10/25/2017.
*/
public class RescheduleDialog extends DialogFragment {
public static final String TASK_RESCHEDULE = "TASK_RESCHEDULE";
protected View view;
protected AQuery query;
private String taskID;
private String pts_date;
private SlideDateTimeListener listener = new SlideDateTimeListener() {
@Override
public void onDateTimeSet(Date date) {
date.setSeconds(0);
SimpleDateFormat mFormatter = new SimpleDateFormat(Global.DATE_TIME_STR_FORMAT);
SimpleDateFormat gsonFormatter = new SimpleDateFormat(Global.DATE_STR_FORMAT_GSON);
String result = mFormatter.format(date);
pts_date = gsonFormatter.format(date);
query.id(R.id.txtDtm).text(result);
}
@Override
public void onDateTimeCancel() {
//EMPTY
}
};
public RescheduleDialog() {
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED",
getClass().getSimpleName());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
taskID = getArguments().getString("taskId");
View view = inflater.inflate(R.layout.new_dialog_reschedule, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getDialog().setCanceledOnTouchOutside(false);
WindowManager.LayoutParams wmlp = getDialog().getWindow().getAttributes();
wmlp.windowAnimations = R.style.DialogAnimation2;
getDialog().getWindow().setAttributes(wmlp);
Rect displayRectangle = new Rect();
Window window = getDialog().getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
view.setMinimumWidth((int) (displayRectangle.width() * 0.9f));
try {
query = new AQuery(view);
query.id(R.id.btnCancel).clicked(this, "cancel_Click");
query.id(R.id.btnReschedule).clicked(this, "reschedule_Click");
query.id(R.id.btnDtm).clicked(this, "dtm_Click");
} catch (Exception e) {
FireCrash.log(e);
}
return view;
}
@Keep
public void cancel_Click(View view) {
dismiss();
}
@Keep
public void reschedule_Click(View view) {
if (query.id(R.id.txtDtm).getText().toString().length() == 0) {
Toast.makeText(getActivity(), getActivity().getString(R.string.select_reschedule_time),
Toast.LENGTH_SHORT).show();
} else {
Date dateSelected = null;
try {
dateSelected = Formatter.parseDate2(pts_date, Global.DATE_STR_FORMAT_GSON);
} catch (ParseException e) {
e.printStackTrace();
}
Date nowtime = Tool.getSystemDate();
Calendar cal = Calendar.getInstance();
cal.setTime(nowtime);
cal.add(Calendar.DATE, 1);
nowtime = cal.getTime();
if (dateSelected != null && dateSelected.before(nowtime)) {
Toast.makeText(getActivity(), getActivity().getString(R.string.date_after_today),
Toast.LENGTH_SHORT).show();
} else {
new SubmitRescheduleTask().execute(taskID, pts_date);
}
}
}
@Keep
public void dtm_Click(View view) {
showDateTimePicker();
}
public void showDateTimePicker() {
Date nowtime = Tool.getSystemDate();
Calendar cal = Calendar.getInstance();
cal.setTime(nowtime);
cal.add(Calendar.DATE, 1);
nowtime = cal.getTime();
new SlideDateTimePicker.Builder(getActivity().getSupportFragmentManager())
.setListener(listener)
.setInitialDate(new Date())
.setMinDate(nowtime)
.setIs24HourTime(true)
.build()
.show();
}
private class SubmitRescheduleTask extends AsyncTask<String, Void, String> {
String taskId;
TaskH taskH;
String size;
String sec;
String ptsDate;
private ProgressDialog progressDialog;
private String errMessage;
@Override
protected String doInBackground(String... params) {
String result = null;
if (Tool.isInternetconnected(getActivity())) {
try {
taskId = params[0];
ptsDate = params[1];
taskH = TaskHDataAccess.getOneTaskHeader(getActivity(), taskID);
SimpleDateFormat formatter = new SimpleDateFormat(Global.DATE_STR_FORMAT_GSON);
Date date = null;
try {
date = formatter.parse(ptsDate);
} catch (ParseException e1) {
e1.printStackTrace();
}
taskH.setPts_date(date);
String uuidScheme = taskH.getUuid_scheme();
String uuidUser = taskH.getUuid_user();
TaskH h = TaskHDataAccess.getOneTaskHeader(getActivity(), taskId);
h.setUser(null);
h.setScheme(null);
h.setUuid_user(uuidUser);
h.setUuid_scheme(uuidScheme);
h.setSubmit_date(Tool.getSystemDateTime());
//olivia 28/11 : set submit location
LocationInfo loc = Global.LTM.getCurrentLocation(Global.FLAG_LOCATION_TRACKING);
if ("null".equalsIgnoreCase(loc.getLatitude())) {
taskH.setLatitude("");
} else {
taskH.setLatitude(loc.getLatitude());
}
if ("null".equalsIgnoreCase(loc.getLongitude())) {
taskH.setLongitude("");
} else {
taskH.setLongitude(loc.getLongitude());
}
JsonRequestSubmitTask task = new JsonRequestSubmitTask();
task.setAudit(GlobalData.getSharedGlobalData().getAuditData());
task.addImeiAndroidIdToUnstructured();
task.setTaskH(h);
task.setTaskD(null);
String json = GsonHelper.toJson(task);
String url = GlobalData.getSharedGlobalData().getURL_SUBMIT_RESCHEDULE();
size = String.valueOf(json.getBytes().length);
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(getActivity(), encrypt, decrypt);
HttpConnectionResult serverResult = null;
Date startTime = Tool.getSystemDateTime();
//Firebase Performance Trace HTTP Request
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(url, FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, json);
try {
serverResult = httpConn.requestToServer(url, json,
Global.DEFAULTCONNECTIONTIMEOUT);
Utility.metricStop(networkMetric, serverResult);
} catch (Exception e) {
FireCrash.log(e);
if(Global.IS_DEV) {
e.printStackTrace();
}
}
if(serverResult == null){
errMessage = "Rescheduling task "
+ taskH.getCustomer_name() + " " + getActivity().getString(R.string.failed);
return result;
}
if (serverResult.isOK()) {
String resultvalue = serverResult.getResult();
JsonResponseSubmitTask responseSubmitTask = GsonHelper.fromJson(
resultvalue, JsonResponseSubmitTask.class);
if (responseSubmitTask.getStatus().getCode() == 0) {
String status = responseSubmitTask.getResult();
Date finishTime = Tool.getSystemDateTime();
long time = finishTime.getTime() - startTime.getTime();
sec = String.valueOf((int) Math.ceil((double) time / 1000));
if (status == null)
status = "Success";
if (status.equalsIgnoreCase("Success")) {
result = status;
if (responseSubmitTask.getTaskId() != null)
taskId = responseSubmitTask.getTaskId();
} else {
result = status;
}
} else {
if (Global.IS_DEV) {
if (responseSubmitTask.getStatus().getMessage() == null)
System.out.println("AutoSendTaskThread server code :"
+ responseSubmitTask.getStatus().getCode());
else
System.out.println("AutoSendTaskThread server code :"
+ responseSubmitTask.getStatus().getCode()
+ ":"
+ responseSubmitTask.getStatus().getCode());
}
result = String.valueOf(responseSubmitTask.getStatus()
.getCode());
}
}
} catch (Exception e) {
FireCrash.log(e);
errMessage = "Rescheduling task "
+ taskH.getCustomer_name() + " " + getActivity().getString(R.string.failed);
}
} else {
errMessage = getString(R.string.no_internet_connection);
}
return result;
}
@Override
protected void onPostExecute(String result) {
if (progressDialog.isShowing()) {
try {
progressDialog.dismiss();
} catch (Exception e) {
FireCrash.log(e);
}
}
if (errMessage != null) {
Toast.makeText(getActivity(), errMessage, Toast.LENGTH_SHORT).show();
} else {
if (result != null && result.equalsIgnoreCase("Success")) {
if (taskId != null && taskId.length() > 0 && !taskId.contains("~")) {
taskH.setStatus(TaskHDataAccess.STATUS_SEND_SENT);
ToDoList.removeSurveyFromList(taskId);
taskH.setSubmit_date(Tool.getSystemDateTime());
taskH.setSubmit_duration(sec);
taskH.setSubmit_size(size);
taskH.setSubmit_result(result);
taskH.setTask_id(taskId);
taskH.setLast_saved_question(1);
taskH.setIs_prepocessed(RescheduleFragment.TASK_RESCHEDULE);
TaskHDataAccess.addOrReplace(getActivity(), taskH);
TimelineManager.insertTimeline(getActivity(), taskH);
String txtResult = getActivity().getString(R.string.reschedule_success, taskH.getCustomer_name());
final NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder
.getInstance(getActivity());
dialogBuilder.withTitle(getActivity().getString(R.string.info_capital)).withMessage(txtResult)
.withButton1Text(getActivity().getString(R.string.btnOk))
.setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View paramView) {
dialogBuilder.dismiss();
dismiss();
Fragment fragment = new NewTimelineFragment();
FragmentTransaction transaction = NewMainActivity.fragmentManager
.beginTransaction();
transaction.setCustomAnimations(
R.anim.fade_in, R.anim.fade_out);
transaction.replace(R.id.content_frame,
fragment);
transaction.addToBackStack(null);
transaction.commit();
}
}).isCancelable(false).show();
}
} else {
if(!GlobalData.isRequireRelogin()) {
String txtResult = "Rescheduling task "
+ taskH.getCustomer_name() + " " + getActivity().getString(R.string.failed);
final NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder
.getInstance(getActivity());
dialogBuilder.withTitle(getActivity().getString(R.string.warning_capital)).withMessage(txtResult)
.withButton1Text(getActivity().getString(R.string.btnClose))
.setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View paramView) {
dialogBuilder.dismiss();
dismiss();
}
}).isCancelable(true).show();
}
}
try {
NewMainActivity.setCounter();
} catch (Exception e) {
FireCrash.log(e);
}
}
}
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(getActivity(), "",
getActivity().getString(R.string.sending_reschedule_progress), true);
}
@Override
protected void onProgressUpdate(Void... values) {
//EMPTY
}
}
}

View file

@ -0,0 +1,118 @@
package com.adins.mss.odr.tool;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.base.util.Utility;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.TaskD;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.odr.R;
import com.adins.mss.odr.model.JsonRequestImage;
import com.adins.mss.odr.update.OrderCancelActivity;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.HttpMetric;
import org.apache.http.NameValuePair;
import java.util.List;
public class getImageTask extends AsyncTask<Void, Void, byte[]> {
private ProgressDialog progressDialog;
private String errMessage = null;
private Activity activity;
static byte[] imagebyte =null;
List<NameValuePair> params;
public getImageTask(Activity activity, List<NameValuePair> params){
this.activity = activity;
this.params = params;
}
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(activity,
"", activity.getString(R.string.progressWait), true);
}
@Override
protected byte[] doInBackground(Void... arg0) {
byte[] imageResult =null;
JsonRequestImage request = new JsonRequestImage();
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
request.setUuid_task_h(params.get(0).getValue());
request.setQuestion_id(params.get(1).getValue());
String json = GsonHelper.toJson(request);
String url = GlobalData.getSharedGlobalData().getURL_GET_IMAGE();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(activity, encrypt, decrypt);
HttpConnectionResult serverResult = null;
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(url, FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, json);
try {
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
Utility.metricStop(networkMetric, serverResult);
} catch (Exception e) {
e.printStackTrace();
}
String result = serverResult.getResult();
JsonResponseImage resultServer = null;
try {
resultServer = GsonHelper.fromJson(result, JsonResponseImage.class);
if(resultServer.getStatus().getCode()==0){
List<TaskD> taskDs = resultServer.getImg();
TaskD d = taskDs.get(0);
imageResult = d.getImage();
}else{
errMessage = resultServer.getStatus().getMessage();
}
} catch (Exception e) {
e.printStackTrace();
errMessage = e.getMessage();
}
return imageResult;
}
@Override
protected void onPostExecute(byte[] result){
if (progressDialog.isShowing()){
try {
progressDialog.dismiss();
} catch (Exception e) {
}
}
if(errMessage!=null){
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(activity);
dialogBuilder.withTitle("ERROR")
.withMessage(errMessage)
.show();
}else{
if(null==result){
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(activity);
dialogBuilder.withTitle("INFO")
.withMessage("Cannot get Image")
.show();
}else{
try {
OrderCancelActivity.targetThumbnail.setResultImg(result);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}

View file

@ -0,0 +1,54 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/buttonLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<TableLayout
android:id="@+id/tableListLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/buttonLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
</TableLayout>
</ScrollView>
<LinearLayout
android:id="@+id/buttonLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="1"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<Button
android:id="@+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_background"
android:textColor="#ffffff"
android:text="@string/cancel_order" />
<Button
android:id="@+id/btnRejectOdr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:visibility="gone"
android:text="@string/btnReject" />
</LinearLayout>
</RelativeLayout>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/gradient_end"></solid>
<corners android:radius="8px"></corners>
<stroke android:width="2dp" android:color="@color/gradient_start"></stroke>
</shape>