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,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/gradient_end"
android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/gradient_end"
android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
</vector>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/productList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"/>
</LinearLayout>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/fontColorWhite"
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -0,0 +1,130 @@
/*
* Copyright 2013, Edmodo, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License.
* You may obtain a copy of the License in the LICENSE file, or at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package com.edmodo.cropper.util;
import android.graphics.Rect;
/**
* Utility class for handling calculations involving a fixed aspect ratio.
*/
public class AspectRatioUtil {
/**
* Calculates the aspect ratio given a rectangle.
*/
public static float calculateAspectRatio(float left, float top, float right, float bottom) {
final float width = right - left;
final float height = bottom - top;
final float aspectRatio = width / height;
return aspectRatio;
}
/**
* Calculates the aspect ratio given a rectangle.
*/
public static float calculateAspectRatio(Rect rect) {
final float aspectRatio = (float) rect.width() / (float) rect.height();
return aspectRatio;
}
/**
* Calculates the x-coordinate of the left edge given the other sides of the
* rectangle and an aspect ratio.
*/
public static float calculateLeft(float top, float right, float bottom, float targetAspectRatio) {
final float height = bottom - top;
// targetAspectRatio = width / height
// width = targetAspectRatio * height
// right - left = targetAspectRatio * height
final float left = right - (targetAspectRatio * height);
return left;
}
/**
* Calculates the y-coordinate of the top edge given the other sides of the
* rectangle and an aspect ratio.
*/
public static float calculateTop(float left, float right, float bottom, float targetAspectRatio) {
final float width = right - left;
// targetAspectRatio = width / height
// width = targetAspectRatio * height
// height = width / targetAspectRatio
// bottom - top = width / targetAspectRatio
final float top = bottom - (width / targetAspectRatio);
return top;
}
/**
* Calculates the x-coordinate of the right edge given the other sides of
* the rectangle and an aspect ratio.
*/
public static float calculateRight(float left, float top, float bottom, float targetAspectRatio) {
final float height = bottom - top;
// targetAspectRatio = width / height
// width = targetAspectRatio * height
// right - left = targetAspectRatio * height
final float right = (targetAspectRatio * height) + left;
return right;
}
/**
* Calculates the y-coordinate of the bottom edge given the other sides of
* the rectangle and an aspect ratio.
*/
public static float calculateBottom(float left, float top, float right, float targetAspectRatio) {
final float width = right - left;
// targetAspectRatio = width / height
// width = targetAspectRatio * height
// height = width / targetAspectRatio
// bottom - top = width / targetAspectRatio
final float bottom = (width / targetAspectRatio) + top;
return bottom;
}
/**
* Calculates the width of a rectangle given the top and bottom edges and an
* aspect ratio.
*/
public static float calculateWidth(float top, float bottom, float targetAspectRatio) {
final float height = bottom - top;
final float width = targetAspectRatio * height;
return width;
}
/**
* Calculates the height of a rectangle given the left and right edges and
* an aspect ratio.
*/
public static float calculateHeight(float left, float right, float targetAspectRatio) {
final float width = right - left;
final float height = width / targetAspectRatio;
return height;
}
}

View file

@ -0,0 +1,349 @@
package com.adins.mss.base.dynamicform.form.questions.viewholder;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import com.adins.mss.base.AppContext;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.R;
import com.adins.mss.base.dynamicform.Constant;
import com.adins.mss.base.dynamicform.CustomerFragment;
import com.adins.mss.base.dynamicform.DynamicFormActivity;
import com.adins.mss.base.dynamicform.JsonRequestValidationQuestion;
import com.adins.mss.base.dynamicform.JsonResponseValidationQuestion;
import com.adins.mss.base.dynamicform.form.questions.QuestionViewAdapter;
import com.adins.mss.base.util.EventBusHelper;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.GeneralParameter;
import com.adins.mss.dao.QuestionSet;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
import com.adins.mss.foundation.db.dataaccess.QuestionSetDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.AuditDataType;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.foundation.questiongenerator.QuestionBean;
import com.adins.mss.foundation.questiongenerator.form.QuestionView;
import org.acra.ACRA;
import java.util.Date;
import java.util.concurrent.TimeUnit;
/**
* Created by noerhayati.dm on 8/1/2018.
*/
public class ValidationQuestionViewHolder extends RecyclerView.ViewHolder {
public FragmentActivity mActivity;
public QuestionView mView;
public TextView mQuestionLabel;
public EditText mQuestionAnswer;
public Button mButtonValidation;
public QuestionBean bean;
public String resultOtp;
public String resultStatus;
private ProgressDialog progressDialog;
private String tempText;
private String errorMessage;
private Integer maxDefaultRetry = 1;
public ValidationQuestionViewHolder(View itemView, FragmentActivity activity) {
super(itemView);
mActivity = activity;
mView = (QuestionView) itemView.findViewById(R.id.questionValidationLayout);
mQuestionLabel = (TextView) itemView.findViewById(R.id.questionValidationLabel);
mQuestionAnswer = (EditText) itemView.findViewById(R.id.questionValidationAnswer);
mButtonValidation = (Button) itemView.findViewById(R.id.btnCheckValidation);
}
public void bind(final QuestionBean item, int number) {
bean = item;
String questionLabel = number + ". " + bean.getQuestion_label();
String answer = bean.getAnswer();
String btnLabel = AppContext.getAppContext().getString(R.string.btnValidation);
View.OnClickListener clickListener;
mQuestionLabel.setText(questionLabel);
mQuestionAnswer.setSingleLine(true);
mQuestionAnswer.setInputType(InputType.TYPE_CLASS_NUMBER);
if (bean.isRelevanted()) {
mQuestionAnswer.setImeOptions(EditorInfo.IME_ACTION_DONE);
}
if (bean.getIs_mandatory().equals(Global.TRUE_STRING)) {
mQuestionAnswer.setHint(AppContext.getAppContext().getString(R.string.requiredField));
} else {
mQuestionAnswer.setHint("");
}
if (bean.isReadOnly()) {
mQuestionAnswer.setSingleLine(false);
mQuestionAnswer.setCursorVisible(false);
mQuestionAnswer.setEnabled(false);
} else {
mQuestionAnswer.setCursorVisible(true);
mQuestionAnswer.setEnabled(true);
}
if (answer != null && !answer.isEmpty()) {
mQuestionAnswer.setText(answer);
} else {
mQuestionAnswer.setText(null);
}
tempText = bean.getAnswer() != null ? bean.getAnswer() : "";
if (QuestionViewAdapter.IsValidationQuestion(Integer.valueOf(bean.getAnswer_type()))) {
String lastAnswer = mQuestionAnswer.getText().toString().trim();
if (tempText.equals(lastAnswer)) {
bean.setBtnCheckClicked(true);
}
}
mQuestionAnswer.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (bean.isReadOnly()) {
mQuestionAnswer.setKeyListener(null);
mQuestionAnswer.setCursorVisible(false);
}
if (null != bean.getAnswer()) {
tempText = bean.getAnswer().trim();
}
if (null == tempText) {
tempText = "";
}
}
@Override
public void afterTextChanged(Editable s) {
String newText = mQuestionAnswer.getText().toString().trim();
if (bean.isRelevanted()) {
if (!tempText.equals(newText)) {
mView.setChanged(true);
if (tempText.equals(bean.getAnswer())) {
bean.setChange(true);
}
}
}
if (!tempText.equals(newText)) {
bean.setBtnCheckClicked(false);
bean.isRelevanted();
}
if (bean.getIntTextAnswer() != null) {
if (!CustomerFragment.getIsEditable() && bean.getIntTextAnswer().equals(newText)) {
bean.setBtnCheckClicked(true);
}
}
bean.setAnswer(getFinalAnswer());
}
});
clickListener = new View.OnClickListener() {
public void onClick(View v) {
if ("".equals(mQuestionAnswer.getText().toString().trim())) {
Toast.makeText(mActivity, bean.getQuestion_label() + " " + mActivity.getString(R.string.msgRequired), Toast.LENGTH_SHORT).show();
} else {
EventBusHelper.post(bean);
TaskH taskH = DynamicFormActivity.header.getTaskH();
long nextCall = 0;
boolean canCall = false;
GeneralParameter gpInterval = GeneralParameterDataAccess.getOne(mActivity, GlobalData.getSharedGlobalData().getUser().getUuid_user(), Global.GS_INTERVAL_CONNECTION);
long intervalTimer = maxDefaultRetry * new Long(Global.MINUTE);
if (gpInterval != null) {
intervalTimer = Integer.valueOf(gpInterval.getGs_value()) * new Long(Global.SECOND);
}
if (taskH.getPts_date() == null) {
canCall = true;
} else {
long nowDate = new Date().getTime();
long checkDate = taskH.getPts_date().getTime();
long timeDiff = nowDate - checkDate;
if (timeDiff >= intervalTimer) {
canCall = true;
} else {
nextCall = intervalTimer - timeDiff;
}
}
if (canCall) {
bean.setBtnCheckClicked(true);
String number = mQuestionAnswer.getText().toString().trim();
GetValidationQuestion validationTask = new GetValidationQuestion(mActivity, number);
validationTask.execute();
} else {
bean.setBtnCheckClicked(false);
String hmsTot = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(nextCall),
TimeUnit.MILLISECONDS.toMinutes(nextCall) % TimeUnit.HOURS.toMinutes(1),
TimeUnit.MILLISECONDS.toSeconds(nextCall) % TimeUnit.MINUTES.toSeconds(1));
String msgRetryCall = AppContext.getAppContext().getString(R.string.retryCallAgain, hmsTot);
Toast.makeText(mActivity, msgRetryCall, Toast.LENGTH_SHORT).show();
}
}
}
};
mButtonValidation.setText(btnLabel);
mButtonValidation.setOnClickListener(clickListener);
}
public String getFinalAnswer() {
String answer = mQuestionAnswer.getText().toString().trim();
String finalAnswer = answer;
return finalAnswer;
}
private class GetValidationQuestion extends AsyncTask<Void, Void, JsonResponseValidationQuestion> {
public FragmentActivity activity;
private String number;
public GetValidationQuestion(FragmentActivity activity, String number) {
this.activity = activity;
this.number = number;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
String number = mQuestionAnswer.getText().toString().trim();
progressDialog = ProgressDialog.show(mActivity, "", AppContext.getAppContext().getString(R.string.please_wait_misscall, number), true);
progressDialog.show();
}
@Override
protected JsonResponseValidationQuestion doInBackground(Void... params) {
JsonResponseValidationQuestion responseValidationTask = null;
if (Tool.isInternetconnected(activity)) {
JsonRequestValidationQuestion requestValidaton = new JsonRequestValidationQuestion();
AuditDataType auditData = GlobalData.getSharedGlobalData().getAuditData();
requestValidaton.setAudit(auditData);
requestValidaton.addImeiAndroidIdToUnstructured();
requestValidaton.setTaskId(CustomerFragment.header.getTask_id());
requestValidaton.setPhoneNumber(number.replace("+", ""));
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(mActivity, encrypt, decrypt);
String url = GlobalData.getSharedGlobalData().getURL_CHECK_VALIDATIONQUESTION();
HttpConnectionResult serverResult;
try {
String json = GsonHelper.toJson(requestValidaton);
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
if (serverResult != null && serverResult.isOK()) {
try {
responseValidationTask = GsonHelper.fromJson(serverResult.getResult(), JsonResponseValidationQuestion.class);
} catch (Exception e) {
ACRA.getErrorReporter().putCustomData("errorGetMessageFromServer", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorGetMessageFromServer", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat convert json dari server"));
e.printStackTrace();
}
}
} catch (Exception e) {
ACRA.getErrorReporter().putCustomData("errorRequestToServer", e.getMessage());
ACRA.getErrorReporter().putCustomData("errorRequestToServer", Tool.getSystemDateTime().toLocaleString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat request ke server"));
e.printStackTrace();
}
} else {
errorMessage = AppContext.getAppContext().getString(R.string.no_internet_connection);
}
if (responseValidationTask != null) {
if (0 == responseValidationTask.getStatus().getCode() ||
1 == responseValidationTask.getStatus().getCode() ||
2 == responseValidationTask.getStatus().getCode()) {
return responseValidationTask;
} else {
String message = responseValidationTask.getStatus().getMessage();
errorMessage = message;
}
}
return null;
}
@Override
protected void onPostExecute(JsonResponseValidationQuestion results) {
super.onPostExecute(results);
DynamicFormActivity.header.setPts_date(new Date());
TaskHDataAccess.addOrReplace(activity, DynamicFormActivity.header.getTaskH());
if (errorMessage != null) {
if (errorMessage.equals(AppContext.getAppContext().getString(R.string.no_internet_connection).toString())) {
Toast.makeText(mActivity, AppContext.getAppContext().getString(R.string.no_internet_connection).toString(), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(mActivity, errorMessage, Toast.LENGTH_SHORT).show();
}
errorMessage = null;
} else {
if (results != null) {
resultStatus = results.getStatus().getMessage();
resultOtp = results.getOtp();
QuestionSet statusQuestion = QuestionSetDataAccess.getOneQuestionByTag(mActivity, Global.TAG_PHONEVERIF_MESSAGE);
QuestionSet otpQuestion = QuestionSetDataAccess.getOneQuestionByTag(mActivity, Global.TAG_PHONEVERIF_OTP);
if (null != statusQuestion) {
QuestionBean beanStatus = Constant.listOfQuestion.get(statusQuestion.getIdentifier_name());
beanStatus.setAnswer(resultStatus);
bean.setIntTextAnswer(mQuestionAnswer.getText().toString().trim());
}
if (null != otpQuestion) {
QuestionBean beanOtp = Constant.listOfQuestion.get(otpQuestion.getIdentifier_name());
if (resultOtp != null) {
String otp = resultOtp.substring(resultOtp.length() - 4);
beanOtp.setAnswer(otp);
} else {
beanOtp.setAnswer("");
}
}
EventBusHelper.post(results);
}
}
if (progressDialog != null && progressDialog.isShowing()) {
try {
progressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}

View file

@ -0,0 +1,27 @@
package com.adins.mss.odr.products;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.adins.mss.odr.R;
/**
* A simple {@link Fragment} subclass.
*/
public class ProductCreditSimulationFragment extends Fragment {
public ProductCreditSimulationFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_product_credit_simulation, container, false);
}
}

View file

@ -0,0 +1,49 @@
package com.adins.mss.base.dynamicform.form;
import android.content.Context;
import com.adins.mss.foundation.questiongenerator.OptionAnswerBean;
import com.adins.mss.foundation.questiongenerator.QuestionBean;
import java.io.File;
import java.util.List;
/**
* Created by kusnendi.muhamad on 09/08/2017.
*/
public interface DynamicQuestion {
public boolean loadQuestionForm();
public boolean loadQuestionForReview(int targetLastPosition, boolean loadToFinish);
public boolean isQuestVisibleIfRelevant(String relevantExpression, QuestionBean question);
public List<OptionAnswerBean> getOptionsForQuestion(QuestionBean bean, boolean firstRequest);
public List<OptionAnswerBean> GetLookupFromDB(QuestionBean bean, List<String> filters);
public String replaceModifiers(String sourceString);
public void syncRvNumber(final QuestionBean bean);
public void setImageForImageQuestion(String path);
public void setLocationForLocationQuestion();
public void processImageFile(File file);
public void deleteLatestPictureCreate(Context context);
public void removeItem(int position);
public void addItem(QuestionBean bean, int position, boolean fromDraft);
public void changeItem(int position);
public void notifyInsert(int position);
public void removeQuestionLabel(int position);
public String doCalculate(QuestionBean bean);
}