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,49 @@
package com.adins.mss.coll.dummy;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.adins.mss.coll.closingtask.ClosingTaskItem;
public class ClosingTaskDummyAdapter extends BaseAdapter {
private static ClosingTaskDummyAdapter instance;
public ClosingTaskDummyAdapter() {
}
public static ClosingTaskDummyAdapter getInstance() {
if (instance == null) {
instance = new ClosingTaskDummyAdapter();
}
return instance;
}
@Override
public int getCount() {
return 1;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ClosingTaskItem item;
if (convertView == null) {
item = new ClosingTaskItem(parent.getContext());
} else {
item = (ClosingTaskItem) convertView;
}
return item;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

@ -0,0 +1,425 @@
package com.adins.mss.foundation.camera;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.PictureCallback;
import android.hardware.Camera.ShutterCallback;
import android.media.ExifInterface;
import android.util.Log;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.LocationInfo;
import com.adins.mss.foundation.camerainapp.helper.Logger;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.image.ImageManipulation;
import com.adins.mss.foundation.location.LocationTrackingManager;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
/**
* @author bong.rk
*/
public class Camera {
private static final String SUBMIT_DELIMITER = ",";
private static final String TAG = "Camera";
public static String BUND_KEY_IMAGE_BYTE = "BUND_KEY_IMAGE_BYTE";
private static Context context;
ExifInterface exif;
/**
*
*/
ShutterCallback shutterCallback = new ShutterCallback() {
@Override
public void onShutter() {
//EMPTY
}
};
/**
*
*/
PictureCallback rawCallback = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, android.hardware.Camera camera) {
//EMPTY
}
};
/**
* autofocus camera
*/
AutoFocusCallback autoFocusTouch = new AutoFocusCallback() {
public void onAutoFocus(boolean success, android.hardware.Camera camera) {
if (!success) {
String[] msg = {"Autofocus not available"};
String alert = Tool.implode(msg, "\n");
Toast.makeText(getContext(), alert, Toast.LENGTH_SHORT).show();
}
}
};
ImageCallBack imageCallBack;
private Activity activity;
/**
* Handle return from camera.takepicture
*/
PictureCallback jpegCallback = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, android.hardware.Camera camera) {
resizeImage(data, 0, 240, 320, 70);
LocationTrackingManager ltm = Global.LTM;
try {
getPicWithExif(data, ltm.getCurrentLocation(Global.FLAG_LOCATION_CAMERA));
} catch (Exception e) {
FireCrash.log(e);
getPicWithExif(data, null);
}
getActivity().finish();
}
};
private android.hardware.Camera camera;
/**
* autofocus to capture image
*/
AutoFocusCallback autoFocusCallback = new AutoFocusCallback() {
public void onAutoFocus(boolean success, android.hardware.Camera camera) {
if (!success) {
String[] msg = {"Autofocus not avaiable"};
String alert = Tool.implode(msg, "\n");
Toast.makeText(getContext(), alert, Toast.LENGTH_SHORT).show();
}
if (Global.IS_DEV) Log.i(TAG, "autofocus :" + success);
getCamera().takePicture(shutterCallback, rawCallback, jpegCallback);
}
};
private Parameters params;
private TextView txtDetailInFocus;
/**
* create camera object for getting these functionalities
*
* @param context - application context from activity class
* @param activity - activity class
* @param camera - initialized camera from android.hardware.Camera
* @param params - parameter setting from camera
*/
public Camera(Context context, Activity activity, android.hardware.Camera camera,
Parameters params
) {
Camera.context = context;
this.camera = camera;
this.params = params;
this.activity = activity;
txtDetailInFocus = new TextView(context);
}
/**
* Check if this device has a camera
*/
public static boolean checkCameraHardware(Context context) {
// this device has a camera
// no camera on this device
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
}
/**
* This method is used to resize image with a custom size by user
* <br>Suggested to use fit size according to size of device screen
*
* @param img
* @param rotate - integer as degree
* @param actualWidth
* @param actualHeight
* @param jpegQuality - integer as perceint
* @return
*/
public static byte[] resizeImage(byte[] img, int rotate, int actualWidth, int actualHeight, int jpegQuality) {
if (Global.IS_DEV) Log.i(TAG, "image quality : " + jpegQuality);
Bitmap bm = BitmapFactory.decodeByteArray(img, 0, img.length);
Bitmap bmp = Bitmap.createScaledBitmap(bm, actualWidth, actualHeight, true);
//rotate image if potraid
if (rotate != 0) {
Matrix mat = new Matrix();
mat.preRotate(rotate);// /in degree
// Bitmap
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(),
bmp.getHeight(), mat, true);
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, jpegQuality, stream);
return stream.toByteArray();
}
public static byte[] resizeImageWithWatermark(byte[] img, int rotate, int actualWidth, int actualHeight, int jpegQuality, Activity activity) {
if (Global.IS_DEV) Log.i(TAG, "image quality : " + jpegQuality);
Bitmap bm = BitmapFactory.decodeByteArray(img, 0, img.length);
Bitmap bmp = Bitmap.createScaledBitmap(bm, actualWidth, actualHeight, true);
//rotate image if potraid
if (rotate != 0) {
Matrix mat = new Matrix();
mat.preRotate(rotate);// /in degree
// Bitmap
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(),
bmp.getHeight(), mat, true);
}
//untuk nambah watermark
Bitmap bmpFinal = ImageManipulation.waterMark(bmp, activity.getString(R.string.watermark), Color.WHITE, 80, 32, false);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmpFinal.compress(Bitmap.CompressFormat.JPEG, jpegQuality, stream);
try {
if (bm != null && !bm.isRecycled()) {
bm.recycle();
}
if (bmp != null && !bmp.isRecycled()) {
bmp.recycle();
}
if (bmpFinal != null && !bmpFinal.isRecycled()) {
bmpFinal.recycle();
}
} catch (Exception e) {
FireCrash.log(e);
}
return stream.toByteArray();
}
public static Context getContext() {
return context;
}
public boolean checkSupportedAutoFocus() {
boolean isSupported = false;
List<String> focusMode = params.getSupportedFocusModes();
if (focusMode.contains(Parameters.FOCUS_MODE_AUTO)) {
isSupported = true;
}
return isSupported;
}
public void setAutoFocus() {
if (checkSupportedAutoFocus())
this.params.setFocusMode(Parameters.FOCUS_MODE_AUTO);
}
public void startFaceDetection() {
// Try starting Face Detection
// start face detection only *after* preview has started
if (params.getMaxNumDetectedFaces() > 0) {
// camera supports face detection, so can start it:
getCamera().startFaceDetection();
}
}
/**
* Set parameter camera to turn auto flash
*/
public void setFlashAuto() {
this.params.setFlashMode(Parameters.FLASH_MODE_AUTO);
}
/**
* Set parameter camera to turn auto flash and change backgroundResource spinner
*/
public void setFlashAuto(Spinner spinner, int iconFlash) {
spinner.setBackgroundResource(iconFlash);
this.params.setFlashMode(Parameters.FLASH_MODE_AUTO);
}
/**
* Set parameter camera to turn on flash
*/
public void setFlashOn() {
this.params.setFlashMode(Parameters.FLASH_MODE_ON);
}
/**
* Set parameter camera to turn on flash and change backgroundResource spinner
*/
public void setFlashOn(Spinner spinner, int iconFlash) {
spinner.setBackgroundResource(iconFlash);
this.params.setFlashMode(Parameters.FLASH_MODE_ON);
}
/**
* Set parameter camera to turn off flash
*/
public void setFlashOff() {
this.params.setFlashMode(Parameters.FLASH_MODE_OFF);
}
/**
* Set parameter camera to turn off flash and change backgroundResource spinner
*/
public void setFlashOff(Spinner spinner, int iconFlash) {
spinner.setBackgroundResource(iconFlash);
this.params.setFlashMode(Parameters.FLASH_MODE_OFF);
}
/**
* @param locationInfo
* @return
*/
public String locationInfoToSubmitString(LocationInfo locationInfo) {
StringBuilder sb = new StringBuilder();
sb.append(locationInfo.getLatitude()).append(SUBMIT_DELIMITER)
.append(locationInfo.getLongitude()).append(SUBMIT_DELIMITER)
.append(locationInfo.getCid()).append(SUBMIT_DELIMITER)
.append(locationInfo.getMcc()).append(SUBMIT_DELIMITER)
.append(locationInfo.getMnc()).append(SUBMIT_DELIMITER)
.append(locationInfo.getLac()).append(SUBMIT_DELIMITER)
.append(locationInfo.getAccuracy());
return sb.toString();
}
public TextView getTxtDetail() {
return txtDetailInFocus;
}
public void setTxtDetail(String textContent) {
txtDetailInFocus.setText(textContent);
}
/**
* This method is used to get image with set exif to the image
*
* @param data - captured image byte
* @param locationInfo - location listener to get location in order to get longitude and latitude
* @return byte - image with exif in byte
*/
private byte[] getPicWithExif(byte[] data, LocationInfo locationInfo) {
// prepare for creating file into local storage
File photo = new File(context.getExternalFilesDir(null)+ "tempImage.jpeg");
if (photo.exists()) {
boolean result = photo.delete();
if(!result){
Toast.makeText(context, "Failed to delete file", Toast.LENGTH_SHORT).show();
}
}
try (FileOutputStream fos = new FileOutputStream(photo.getPath())){
fos.write(data);
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
if (locationInfo != null) {
double latitude = Double.parseDouble(locationInfo.getLatitude());
double longitude = Double.parseDouble(locationInfo.getLongitude());
try {
exif = new ExifInterface(photo.getPath());
int num1Lat = (int) Math.floor(latitude);
int num2Lat = (int) Math.floor((latitude - num1Lat) * 60);
double num3Lat = (latitude - ((double) num1Lat + ((double) num2Lat / 60))) * 3600000;
int num1Lon = (int) Math.floor(longitude);
int num2Lon = (int) Math.floor((longitude - num1Lon) * 60);
double num3Lon = (longitude - ((double) num1Lon + ((double) num2Lon / 60))) * 3600000;
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, num1Lat + "/1," + num2Lat + "/1," + num3Lat + "/1000");
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, num1Lon + "/1," + num2Lon + "/1," + num3Lon + "/1000");
if (latitude > 0) {
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, "N");
} else {
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, "S");
}
if (longitude > 0) {
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, "E");
} else {
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, "W");
}
exif.saveAttributes();
} catch (IOException e) {
Logger.e("PictureActivity", e.getLocalizedMessage());
}
}
// get byte of pictWithExif
Logger.e("photo length", photo.length() + "");
byte[] dataPicWithExif = new byte[(int) photo.length()];
try( BufferedInputStream buf = new BufferedInputStream(new FileInputStream(photo));) {
buf.read(dataPicWithExif, 0, dataPicWithExif.length);
} catch (Exception e) {
FireCrash.log(e);
}
//delete photo from local
boolean result = photo.delete();
if(!result){
Toast.makeText(context, "Failed to delete file", Toast.LENGTH_SHORT).show();
}
//delegate
processImage(dataPicWithExif, locationInfo);
return dataPicWithExif;
}
protected void processImage(byte[] dataPicWithExif, LocationInfo locationInfo) {
// delegate
this.imageCallBack.onPictureTaken(dataPicWithExif, locationInfo);
}
/**
* This method is to capture image
* <br>It calls method to process captured image
* <br>In this framework, that method will call back interface onPictureTaken to activity
*
* @param imageCallBack - interface to be called back and receive image with exif and location
*/
public void getPicture(ImageCallBack imageCallBack) {
this.imageCallBack = imageCallBack;
this.camera.setParameters(this.params);
this.camera.takePicture(shutterCallback, rawCallback, jpegCallback);
}
public android.hardware.Camera getCamera() {
return camera;
}
public Parameters getParams() {
return params;
}
public void setParams(Parameters params) {
this.params = params;
}
public Activity getActivity() {
return activity;
}
}

View file

@ -0,0 +1,22 @@
package com.adins.mss.svy.common;
import android.content.Context;
import android.widget.Toast;
import com.adins.mss.svy.R;
/**
* Created by Aditya Purwa on 3/4/2015.
*/
public class Toaster {
public static void error(Context context, Exception ex, String extraReason) {
Toast.makeText(context, context.getString(R.string.error_occure2, ex.getMessage(), extraReason), Toast.LENGTH_LONG)
.show();
}
public static void error(Context context, String extraReason) {
Toast.makeText(context, context.getString(R.string.error_occure1, extraReason), Toast.LENGTH_LONG)
.show();
}
}

View file

@ -0,0 +1,8 @@
package com.adins.mss.base.todolist.form.todaysplan;
import com.adins.mss.dao.TaskH;
public interface OnTaskCheckedListener {
void onTaskChecked(TaskH taskH, int position);
void onTaskUnchecked(TaskH taskH,int position);
}

View file

@ -0,0 +1,573 @@
package com.adins.mss.foundation.questiongenerator;
import android.content.Context;
import android.widget.AutoCompleteTextView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.dynamicform.DynamicFormActivity;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.Holiday;
import com.adins.mss.dao.LocationInfo;
import com.adins.mss.dao.Lookup;
import com.adins.mss.foundation.db.dataaccess.HolidayDataAccess;
import com.adins.mss.foundation.db.dataaccess.LookupDataAccess;
import com.adins.mss.foundation.formatter.Formatter;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.questiongenerator.form.MultiOptionQuestionViewAbstract;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class QuestionViewValidator {
public static final String HOLIDAY_IS_NOT_ALLOWED = "1";
private String msgRequired;
private Context context;
public QuestionViewValidator(String msgRequired, Context context) {
this.msgRequired = msgRequired;
this.context = context;
}
private static boolean regexIsMatch(String s, String pattern) {
try {
Pattern patt = Pattern.compile(pattern);
Matcher matcher = patt.matcher(s);
return matcher.matches();
} catch (RuntimeException e) {
return false;
}
}
public List<String> validateTextQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
EditText text = (EditText) view.getChildAt(1);
String answer = text.getText().toString().trim();
if (Global.AT_CURRENCY.equals(bean.getAnswer_type())) {
if (answer != null && answer.length() > 0) {
String tempAnswer = Tool.deleteAll(answer, ",");
String[] intAnswer = Tool.split(tempAnswer, ".");
if (intAnswer.length > 1) {
if (intAnswer[1].equals("00"))
answer = intAnswer[0];
else {
answer = tempAnswer;
}
} else {
answer = tempAnswer;
}
}
}
bean.setAnswer(answer);
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if ("".equals(answer)) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
String regex = "";
regex = bean.getRegex();
if (regex == null) regex = "";
if (!regex.equals("") && !bean.getAnswer().trim().equals("")) {
if (Global.IS_DEV) System.out.println("!regex.equals" + regex);
if (regexIsMatch(bean.getAnswer(), bean.getRegex())) {
} else {
errMessage.add(bean.getQuestion_label() + " " + "Invalid Input Format");
}
}
return errMessage;
}
//GIgin ~ validasi suggestion question
public List<String> validateTextWithSuggestionQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
AutoCompleteTextView text = (AutoCompleteTextView) view.getChildAt(1);
String tempAnswer = bean.getAnswer() != null ? bean.getAnswer() : "";
String answer = text.getText().toString().trim();
if (!tempAnswer.equals(answer)) {
Lookup lookup = LookupDataAccess.getOneByCodeAndlovGroup(context, bean.getLov_group(), answer);
if (lookup == null) {
errMessage.add(bean.getQuestion_label() + ": " + answer + " " + context.getString(R.string.not_allowed));
}
} else if (!Tool.isInternetconnected(context)) {
Lookup lookup = LookupDataAccess.getOneByCodeAndlovGroup(context, bean.getLov_group(), answer);
if (lookup == null) {
errMessage.add(bean.getQuestion_label() + ": " + answer + " " + context.getString(R.string.not_available));
}
}
bean.setAnswer(answer);
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if ("".equals(answer)) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
String regex = "";
regex = bean.getRegex();
if (regex == null) regex = "";
if (!regex.equals("") && !bean.getAnswer().trim().equals("")) {
if (Global.IS_DEV) System.out.println("!regex.equals" + regex);
if (regexIsMatch(bean.getAnswer(), bean.getRegex())) {
} else {
errMessage.add(bean.getQuestion_label() + " " + "Invalid Input Format");
}
}
return errMessage;
}
public List<String> validateLocationQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
if (DynamicFormActivity.getIsVerified() || DynamicFormActivity.getIsApproval()) {
} else {
LinearLayout row = (LinearLayout) view.getChildAt(2);
TextView text = (TextView) row.getChildAt(0);
String answer = text.getText().toString().trim();
bean.setAnswer(answer);
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if ("".equals(answer)) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
}
return errMessage;
}
public List<String> validateDateTimeQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
LinearLayout row = (LinearLayout) view.getChildAt(1);
TextView text = (TextView) row.getChildAt(0);
String answer = text.getText().toString();
Date date2 = null;
boolean isSet = true;
String answerType = bean.getAnswer_type();
try {
String format = null;
if (Global.AT_DATE.equals(answerType)) {
format = Global.DATE_STR_FORMAT;
date2 = Formatter.parseDate(answer, format);
String finalAnswer = Formatter.formatDate(date2, Global.DATE_STR_FORMAT_GSON);
bean.setAnswer(finalAnswer);
} else if (Global.AT_TIME.equals(answerType)) {
format = Global.TIME_STR_FORMAT;
date2 = Formatter.parseDate(answer, format);
String finalAnswer = Formatter.formatDate(date2, Global.TIME_STR_FORMAT2);
bean.setAnswer(finalAnswer);
} else if (Global.AT_DATE_TIME.equals(answerType)) {
format = Global.DATE_TIME_STR_FORMAT;
date2 = Formatter.parseDate(answer, format);
String finalAnswer = Formatter.formatDate(date2, Global.DATE_STR_FORMAT_GSON);
bean.setAnswer(finalAnswer);
}
} catch (Exception pe) {
isSet = false;
}
//bong 19 mei 15 - validasi holiday
if (bean.getIs_holiday_allowed() != null && !bean.getIs_holiday_allowed().equals(HOLIDAY_IS_NOT_ALLOWED)) { // if it is not allowed on holiday
Date date3 = null;
if (Global.AT_DATE_TIME.equals(answerType)) {
String format2 = Global.DATE_STR_FORMAT;
try {
date3 = Formatter.parseDate(bean.getAnswer(), format2);
} catch (ParseException e) {
e.printStackTrace();
}
} else date3 = date2;
if (date3 != null) {
Holiday hday = HolidayDataAccess.getOneByDate(context, date3);
if (hday != null) {
errMessage.add(bean.getQuestion_label() + " "
+ "can not set on " + hday.getH_desc());
}
}
}
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if (!isSet) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
int txtMaxLength = 0;
// validasi untuk question yg punya maxlength > 0
try {
if (bean.getMax_length() > 0) {
Calendar now = Calendar.getInstance(TimeZone
.getDefault());
Calendar date = Calendar.getInstance(TimeZone
.getDefault());
date.setTime(date2);
long diff = (date.getTime().getTime() - now.getTime()
.getTime());
long diffDay = diff / 86400000;
if (diffDay < 0) {
txtMaxLength = (int) diffDay;
} else if (diffDay > bean.getMax_length()) {
txtMaxLength = (int) diffDay;
} else {
txtMaxLength = bean.getMax_length();
}
} else {
Date today = Tool.getSystemDate();
Calendar now = Calendar.getInstance(TimeZone
.getDefault());
now.setTime(today);
Calendar date = Calendar.getInstance(TimeZone
.getDefault());
date.setTime(date2);
long diff = (date.getTime().getTime() - now.getTime()
.getTime());
long diffDay = diff / 86400000;
if (diffDay > 0) {
txtMaxLength = (int) diffDay;
} else if (diffDay < bean.getMax_length()) {
txtMaxLength = (int) diffDay;
} else {
txtMaxLength = bean.getMax_length();
}
}
if (bean.getMax_length() == -999) {
if (txtMaxLength > 0) {
errMessage.add(bean.getQuestion_label() + " " + context.getString(R.string.date_must_before_today));
}
} else if (bean.getMax_length() < 0) {
if (txtMaxLength > 0) {
errMessage.add(bean.getQuestion_label() + " " + context.getString(R.string.date_must_before_today));
} else if (txtMaxLength < bean.getMax_length()) {
errMessage.add(bean.getQuestion_label() + " " + context.getString(R.string.more_than)
+ " " + txtMaxLength + " " + context.getString(R.string.day) + "!");
}
} else if (bean.getMax_length() > 0) {
if (txtMaxLength < 0) {
errMessage.add(bean.getQuestion_label() + " " + context.getString(R.string.date_must_after_today));
} else if (txtMaxLength > bean.getMax_length()) {
errMessage.add(bean.getQuestion_label() + " " + context.getString(R.string.less_than)
+ " " + bean.getMax_length() + " " + context.getString(R.string.day) + "!");
}
}
} catch (Exception e) {
FireCrash.log(e);
}
return errMessage;
}
//Glen 14 Oct 2014, combine all multiple option question validation and save answer logic
//validateMultipleOptionQuestion need no bean as parameter, MultipleQuestionView already has it
public List<String> validateMultipleOptionQuestion(int idx, MultiOptionQuestionViewAbstract view) {
List<String> errMessage = new ArrayList<>();
//Let the subclass handle the saving method
view.saveSelectedOptionToBean();
QuestionBean bean = view.getQuestionBean();
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if (bean.getSelectedOptionAnswers() == null || bean.getSelectedOptionAnswers().isEmpty()) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
return errMessage;
}
public List<String> validateDropdownQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
Spinner spinner = (Spinner) view.getChildAt(1);
int selected = spinner.getSelectedItemPosition();
List<OptionAnswerBean> listOptions = bean.getOptionAnswers();
int count = 0;
for (OptionAnswerBean optBean : listOptions) {
if (count == selected) {
optBean.setSelected(true);
} else {
optBean.setSelected(false);
}
count++;
}
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if (Tool.getSelectedIndex(listOptions) == -1) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
return errMessage;
}
public List<String> validateDropdownDescQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
Spinner spinner = (Spinner) view.getChildAt(1);
int selected = spinner.getSelectedItemPosition();
List<OptionAnswerBean> listOptions = bean.getOptionAnswers();
int count = 0;
for (OptionAnswerBean optBean : listOptions) {
if (count == selected) {
optBean.setSelected(true);
EditText txt = (EditText) view.getChildAt(2);
String desc = txt.getText().toString();
optBean.setValue(desc);
} else {
optBean.setSelected(false);
optBean.setValue(null);
}
count++;
}
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if (Tool.getSelectedIndex(listOptions) == -1) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
return errMessage;
}
public List<String> validateMultipleQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
List<OptionAnswerBean> listOptions = bean.getOptionAnswers();
int i = 0;
for (OptionAnswerBean optBean : listOptions) {
CheckBox chk = (CheckBox) view.getChildAt(i + 1);
if (chk.isChecked()) {
optBean.setSelected(true);
} else {
optBean.setSelected(false);
}
i++;
}
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if (Tool.getSelectedIndex(listOptions) == -1) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
return errMessage;
}
public List<String> validateMultipleDescQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
List<OptionAnswerBean> listOptions = bean.getOptionAnswers();
int i = 0;
for (OptionAnswerBean optBean : listOptions) {
CheckBox chk = (CheckBox) view.getChildAt((i * 2) + 1);
if (chk.isChecked()) {
optBean.setSelected(true);
EditText txt = (EditText) view.getChildAt((i * 2) + 2);
optBean.setValue(txt.getText().toString());
} else {
optBean.setSelected(false);
optBean.setValue(null);
}
i++;
}
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if (Tool.getSelectedIndex(listOptions) == -1) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
return errMessage;
}
public List<String> validateRadioQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
List<OptionAnswerBean> listOptions = bean.getOptionAnswers();
if (listOptions != null && !listOptions.isEmpty()) {
RadioGroup rdGroup = (RadioGroup) view.getChildAt(1);
int i = 0;
for (OptionAnswerBean optBean : listOptions) {
RadioButton rb = (RadioButton) rdGroup.getChildAt(i);
if (rb.isChecked()) {
optBean.setSelected(true);
} else {
optBean.setSelected(false);
}
i++;
}
}
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if (Tool.getSelectedIndex(listOptions) == -1) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
return errMessage;
}
public List<String> validateRadioDescQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
List<OptionAnswerBean> listOptions = bean.getOptionAnswers();
if (listOptions != null && !listOptions.isEmpty()) {
RadioGroup rdGroup = (RadioGroup) view.getChildAt(1);
int i = 0;
for (OptionAnswerBean optBean : listOptions) {
RadioButton rb = (RadioButton) rdGroup.getChildAt(i);
if (rb.isChecked()) {
optBean.setSelected(true);
} else {
optBean.setSelected(false);
}
i++;
}
int selected = Tool.getSelectedIndex(listOptions);
if (selected != -1) {
EditText desc = (EditText) view.getChildAt(2);
OptionAnswerBean optBean = listOptions.get(selected);
optBean.setValue(desc.getText().toString());
}
}
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
if (Tool.getSelectedIndex(listOptions) == -1) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
return errMessage;
}
public List<String> validateImageQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
if (DynamicFormActivity.getIsVerified() || DynamicFormActivity.getIsApproval()) {
} else {
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
byte[] img = bean.getImgAnswer();
if (img == null || img.length < 1) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
String answerType = bean.getAnswer_type();
if (answerType.equals(Global.AT_IMAGE_W_LOCATION) ||
answerType.equals(Global.AT_IMAGE_W_GPS_ONLY)) {
LocationInfo locationInfo = bean.getLocationInfo();
if (locationInfo != null) {
if (locationInfo.getLatitude().equals("0.0") || locationInfo.getLongitude().equals("0.0")) {
if (answerType.equals((Global.AT_IMAGE_W_GPS_ONLY))) {
errMessage.add(context.getString(R.string.gps_gd_error));
} else {
if (locationInfo.getMcc().equals("0") || locationInfo.getMnc().equals("0")) {
errMessage.add(context.getString(R.string.lbs_gd_error));
}
}
}
} else {
errMessage.add(context.getString(R.string.gps_error));
}
}
}
}
return errMessage;
}
public List<String> validateDrawingDescQuestion(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = new ArrayList<>();
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
byte[] img = bean.getImgAnswer();
if (img == null || img.length < 1) {
errMessage.add(bean.getQuestion_label() + " " + msgRequired);
}
}
return errMessage;
}
public List<String> validateGeneratedQuestionView(QuestionBean bean, int idx, LinearLayout view) {
List<String> errMessage = null;
if (bean.getIs_visible().equals(Global.FALSE_STRING))
return null;
String answerType = bean.getAnswer_type();
if (Global.AT_TEXT.equals(answerType)) {
errMessage = this.validateTextQuestion(bean, idx, view);
} else if (Global.AT_TEXT_MULTILINE.equals(answerType)) {
errMessage = this.validateTextQuestion(bean, idx, view);
} else if (Global.AT_TEXT_WITH_SUGGESTION.equals(answerType)) {
errMessage = this.validateTextWithSuggestionQuestion(bean, idx, view);
} else if (Global.AT_CURRENCY.equals(answerType)) {
errMessage = this.validateTextQuestion(bean, idx, view);
} else if (Global.AT_GPS.equals(answerType)) {
errMessage = this.validateLocationQuestion(bean, idx, view);
} else if (Global.AT_GPS_N_LBS.equals(answerType)) {
errMessage = this.validateLocationQuestion(bean, idx, view);
} else if (Global.AT_LOCATION.equals(answerType)) {
errMessage = this.validateLocationQuestion(bean, idx, view);
} else if (Tool.isOptions(answerType)) {
errMessage = this.validateMultipleOptionQuestion(idx, (MultiOptionQuestionViewAbstract) view);
} else if (Global.AT_NUMERIC.equals(answerType)) {
errMessage = this.validateTextQuestion(bean, idx, view);
} else if (Global.AT_DECIMAL.equals(answerType)) {
errMessage = this.validateTextQuestion(bean, idx, view);
} else if (Global.AT_DATE.equals(answerType)) {
errMessage = this.validateDateTimeQuestion(bean, idx, view);
} else if (Global.AT_TIME.equals(answerType)) {
errMessage = this.validateDateTimeQuestion(bean, idx, view);
} else if (Global.AT_DATE_TIME.equals(answerType)) {
errMessage = this.validateDateTimeQuestion(bean, idx, view);
} else if (Tool.isImage(answerType)) {
errMessage = this.validateImageQuestion(bean, idx, view);
} else if (Global.AT_DRAWING.equals(answerType)) {
errMessage = this.validateDrawingDescQuestion(bean, idx, view);
}
return errMessage;
}
}

View file

@ -0,0 +1,69 @@
package com.adins.mss.base.todo.form;
import com.adins.mss.foundation.http.MssRequestType;
import com.google.gson.annotations.SerializedName;
/**
* @author gigin.ginanjar
*/
public class JsonRequestScheme extends MssRequestType {
/**
* Property task
*/
@SerializedName("task")
String task;
/**
* Property uuid_user
*/
@SerializedName("uuid_user")
String uuid_user;
/**
* Property uuid_scheme
*/
@SerializedName("uuid_scheme")
String uuid_scheme;
/**
* Gets the task
*/
public String getTask() {
return this.task;
}
/**
* Sets the task
*/
public void setTask(String value) {
this.task = value;
}
/**
* Gets the uuid_user
*/
public String getUuid_user() {
return this.uuid_user;
}
/**
* Sets the uuid_user
*/
public void setUuid_user(String value) {
this.uuid_user = value;
}
/**
* Gets the uuid_scheme
*/
public String getUuid_scheme() {
return this.uuid_scheme;
}
/**
* Sets the uuid_scheme
*/
public void setUuid_scheme(String value) {
this.uuid_scheme = value;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -0,0 +1,29 @@
package com.adins.mss.coll.loyalti.pointacquisitionmonthly.contracts;
import com.adins.mss.coll.loyalti.BasePresenter;
import com.adins.mss.coll.loyalti.BaseView;
import com.adins.mss.coll.models.loyaltymodels.GroupPointData;
import com.adins.mss.coll.models.loyaltymodels.LoyaltyPointsRequest;
import com.adins.mss.coll.models.loyaltymodels.PointDetail;
import com.adins.mss.coll.models.loyaltymodels.RankDetail;
import java.util.List;
public interface MonthlyPointContract {
interface View extends BaseView<MonthlyPointContract.Presenter> {
void onDataReceived(float[][] pointDataSet,RankDetail[][] rankDataSet,List<PointDetail> pointDetailsDataSet);
void onGetDataFailed(String message);
}
interface Presenter extends BasePresenter {
void getMonthlyPointsData(LoyaltyPointsRequest reqData);
float getAvgPoint();
int getMaxPoint();
int getTotalPoints();
int getCurrentMonth();
String[] getMonths();
GroupPointData getPointDataAt(int monthIdx);
List<PointDetail> getPointDetails();
List<RankDetail> getRanks();
}
}

View file

@ -0,0 +1,21 @@
package com.adins.mss.coll.models;
import com.adins.mss.foundation.http.MssRequestType;
import com.google.gson.annotations.SerializedName;
public class GuidelineFaqRequest extends MssRequestType {
@SerializedName("uuidGuideline")
String uuidGudeline;
public String getUuidGudeline() {
return uuidGudeline;
}
public void setUuidGudeline(String uuidGudeline) {
this.uuidGudeline = uuidGudeline;
}
}

View file

@ -0,0 +1,63 @@
package com.adins.mss.odr.update;
import com.adins.mss.foundation.http.MssRequestType;
import com.google.gson.annotations.SerializedName;
public class JsonRequestDetailCancelOrder extends MssRequestType{
/** Property flag */
@SerializedName("flag")
String flag;
/** Property nomor_order */
@SerializedName("nomor_order")
String nomor_order;
@SerializedName("uuid_task_h")
String uuid_task_h;
/** Property question_id */
@SerializedName("question_id")
String question_id;
/**
* Gets the uuid_task_h
*/
public String getUuid_task_h() {
return this.uuid_task_h;
}
/**
* Sets the uuid_task_h
*/
public void setUuid_task_h(String value) {
this.uuid_task_h = value;
}
/**
* Gets the flag
*/
public String getFlag() {
return this.flag;
}
/**
* Sets the flag
*/
public void setFlag(String value) {
this.flag = value;
}
/**
* Gets the nomor_order
*/
public String getNomor_order() {
return this.nomor_order;
}
/**
* Sets the nomor_order
*/
public void setNomor_order(String value) {
this.nomor_order = value;
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false"
android:drawable="@drawable/ic_camera_rear" />
<item android:state_checked="true"
android:drawable="@drawable/ic_camera_front" />
</selector>