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,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/fragment_follow_up"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listTaskRv"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

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,529 @@
package com.adins.mss.svy.assignment;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.appcompat.widget.Toolbar;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.checkin.CheckInManager;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.timeline.MapsViewer;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.base.util.LocaleHelper;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.UserHelp.UserHelp;
import com.adins.mss.foundation.dialog.DialogManager;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.foundation.image.Utils;
import com.adins.mss.foundation.location.UpdateMenuIcon;
import com.adins.mss.svy.R;
import com.adins.mss.svy.reassignment.JsonRequestDetailOrder;
import com.adins.mss.svy.reassignment.JsonResponseServer;
import com.adins.mss.svy.reassignment.JsonResponseServer.ResponseServer;
import com.adins.mss.svy.tool.ImageThumbnail;
import com.adins.mss.svy.tool.getImageTask;
import com.google.firebase.analytics.FirebaseAnalytics;
import org.acra.ACRA;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.adins.mss.constant.Global.SHOW_USERHELP_DELAY_DEFAULT;
public class OrderAssignmentResult extends AppCompatActivity implements OnClickListener{
String nomorOrder;
TableLayout detailTable;
Button btnLookupCMO;
Button btnSubmit;
TextView form_name;
ScrollView scrollView;
int taskType;
String flag;
String uuid_task_h;
String formName;
TextView txtCMO;
EditText txtNotes;
CardView lookupCMOLayout;
Map<ImageThumbnail, String> thumbnailMapping = new HashMap<>();
List<ResponseServer> list;
String assignId;
public static ImageThumbnail targetThumbnail = null;
public boolean isSoftKeyboardDisplayed = false;
private FirebaseAnalytics screenName;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(com.adins.mss.base.R.menu.main_menu, menu);
mainMenu = menu;
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
updateMenuIcon();
if(Global.ENABLE_USER_HELP &&
(Global.userHelpGuide.get(OrderAssignmentResult.this.getClass().getSimpleName())!=null) ||
Global.userHelpDummyGuide.get(OrderAssignmentResult.this.getClass().getSimpleName()) != null){
menu.findItem(com.adins.mss.base.R.id.mnGuide).setVisible(true);
}
return super.onPrepareOptionsMenu(menu);
}
private static Menu mainMenu;
public static void updateMenuIcon() {
UpdateMenuIcon uItem = new UpdateMenuIcon();
uItem.updateGPSIcon(mainMenu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == com.adins.mss.base.R.id.mnGPS && Global.LTM != null) {
if (Global.LTM.getIsConnected()) {
Global.LTM.removeLocationListener();
Global.LTM.connectLocationClient();
} else {
CheckInManager.startGPSTracking(getApplicationContext());
}
Animation a = AnimationUtils.loadAnimation(this, com.adins.mss.base.R.anim.gps_rotate);
findViewById(com.adins.mss.base.R.id.mnGPS).startAnimation(a);
}
if(id==R.id.mnGuide && !Global.BACKPRESS_RESTRICTION){
UserHelp.reloadUserHelp(getApplicationContext(), OrderAssignmentResult.this);
scrollView.scrollTo(0, findViewById(R.id.Bottomlayout).getBottom());
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
UserHelp.showAllUserHelp(OrderAssignmentResult.this, OrderAssignmentResult.this.getClass().getSimpleName());
}
}, SHOW_USERHELP_DELAY_DEFAULT);
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_survey_assignment_result_activity);
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
nomorOrder = getIntent().getExtras().getString(Global.BUND_KEY_ORDERNO);
taskType = getIntent().getExtras().getInt(Global.BUND_KEY_TASK_TYPE);
uuid_task_h = getIntent().getExtras().getString(Global.BUND_KEY_UUID_TASKH);
formName = getIntent().getExtras().getString(Global.BUND_KEY_FORM_NAME);
flag = flagParamForType(taskType);
scrollView = findViewById(R.id.scrollView);
screenName = FirebaseAnalytics.getInstance(this);
Toolbar toolbar = (Toolbar) findViewById(com.adins.mss.base.R.id.toolbar);
toolbar.setTitleTextColor(getResources().getColor(com.adins.mss.base.R.color.fontColorWhite));
toolbar.setTitle(getString(R.string.title_mn_surveyassign));
setSupportActionBar(toolbar);
switch (taskType) {
case Global.TASK_ORDER_ASSIGNMENT:
toolbar.setTitle(getString(R.string.title_mn_surveyassign));
break;
case Global.TASK_ORDER_REASSIGNMENT:
toolbar.setTitle(getString(R.string.title_mn_surveyreassign));
break;
default:
break;
}
initialize();
new GetRequestDataDetail(this,nomorOrder, flag).execute();
}
@Override
protected void onResume() {
super.onResume();
//Set Firebase screen name
screenName.setCurrentScreen(this, getString(R.string.screen_name_survey_assignment_result), null);
}
@Override
protected void attachBaseContext(Context newBase) {
Context context = newBase;
Locale locale;
try{
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
context = LocaleHelper.wrap(newBase, locale);
} catch (Exception e) {
locale = new Locale(LocaleHelper.ENGLSIH);
context = LocaleHelper.wrap(newBase, locale);
} finally {
super.attachBaseContext(context);
}
}
private String flagParamForType(int taskType2) {
switch (taskType) {
case Global.TASK_ORDER_ASSIGNMENT:
return "assign";
case Global.TASK_ORDER_REASSIGNMENT:
return "reassign";
default:
return "";
}
}
protected void initialize() {
detailTable = (TableLayout)findViewById(R.id.orderDetailTable);
btnLookupCMO = (Button)findViewById(R.id.btnLookupCMO);
btnSubmit = (Button)findViewById(R.id.btnSubmit);
form_name = (TextView)findViewById(R.id.formName);
txtCMO = (TextView)findViewById(R.id.txtCMO);
txtNotes = (EditText)findViewById(R.id.txtNotes);
txtNotes.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
isSoftKeyboardDisplayed = true;
txtNotes.requestFocus();
txtNotes.setFocusable(true);
txtNotes.setFocusableInTouchMode(true);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(v, 0);
return false;
}
});
btnSubmit.requestFocus();
btnSubmit.setFocusable(true);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
View v = getCurrentFocus();
boolean ret = super.dispatchTouchEvent(event);
if (v instanceof EditText) {
View w = getCurrentFocus();
int scrcoords[] = new int[2];
w.getLocationOnScreen(scrcoords);
float x = event.getRawX() + w.getLeft() - scrcoords[0];
float y = event.getRawY() + w.getTop() - scrcoords[1];
if (event.getAction() == MotionEvent.ACTION_UP
&& (x < w.getLeft() || x >= w.getRight() || y < w.getTop() || y > w
.getBottom())) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromInputMethod(v.getWindowToken(), 0);
isSoftKeyboardDisplayed = false;
}
}
return ret;
}
@Override
public void onBackPressed(){
if (isSoftKeyboardDisplayed) {
isSoftKeyboardDisplayed = false;
}else{
if(!Global.BACKPRESS_RESTRICTION) {
super.onBackPressed();
}
}
}
public class GetRequestDataDetail extends AsyncTask<Void, Void, String> {
private ProgressDialog progressDialog;
private WeakReference<Activity> activity;
private String flag;
private String nomorOrder;
public GetRequestDataDetail(Activity activity,String nomorOrder, String flag) {
this.activity = new WeakReference<>(activity);
this.nomorOrder = nomorOrder;
this.flag = flag;
}
@Override
protected void onPreExecute() {
progressDialog = ProgressDialog.show(OrderAssignmentResult.this,
"", getString(R.string.progressWait), true);
}
@Override
protected String doInBackground(Void... params) {
String result = null;
JsonRequestDetailOrder request = new JsonRequestDetailOrder();
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
request.setUuid_task_h(uuid_task_h);
String json = GsonHelper.toJson(request);
String url = GlobalData.getSharedGlobalData().getURL_GET_DETAIL_ORDER();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(activity.get(), encrypt, decrypt);
HttpConnectionResult serverResult = null;
try {
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
if(serverResult.isOK())
result = serverResult.getResult();
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
try {
progressDialog.dismiss();
} catch (Exception ex) {
FireCrash.log(e);
}
}
return result;
}
@Override
protected void onPostExecute(String result){
if (progressDialog.isShowing()){
try {
progressDialog.dismiss();
} catch (Exception e) { FireCrash.log(e);
}
}
if("".equals(result)){
NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(getApplicationContext());
dialogBuilder.withTitle(getString(R.string.info_capital))
.withMessage(getString(R.string.msgNoDetail))
.show();
}else if (null != result){
loadDataDetailFromServer(result);
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
scrollView.scrollTo(0, findViewById(R.id.Bottomlayout).getBottom());
UserHelp.showAllUserHelp(OrderAssignmentResult.this,OrderAssignmentResult.this.getClass().getSimpleName());
}
}, SHOW_USERHELP_DELAY_DEFAULT);
}
}
private void loadDataDetailFromServer(String result){
int no =1;
LayoutParams lpSpace =new LayoutParams(WRAP_CONTENT, MATCH_PARENT);
LayoutParams lpQuestion =new LayoutParams(MATCH_PARENT, MATCH_PARENT,0.3f);
LayoutParams lpImage =new LayoutParams(MATCH_PARENT, MATCH_PARENT, 0.4f);
LayoutParams lpNo =new LayoutParams(WRAP_CONTENT, MATCH_PARENT);
try {
JsonResponseServer resultOrder = GsonHelper.fromJson(result, JsonResponseServer.class);
form_name.setText("Form : "+formName);
list = resultOrder.getListResponseServer();
for(ResponseServer responseServer : list){
String question = responseServer.getKey();
final String answer = responseServer.getValue();
String flag = responseServer.getFlag();
LinearLayout row = new LinearLayout(this);
row.setOrientation(LinearLayout.HORIZONTAL);
row.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1.0f));
TextView lblNo = new TextView(this);
lblNo.setText(no+ ". ");
lblNo.setGravity(Gravity.LEFT);
lblNo.setLayoutParams(lpNo);
row.addView(lblNo);
TextView lblQuestion = new TextView(this);
lblQuestion.setText(question);
lblQuestion.setLayoutParams(lpQuestion);
row.addView(lblQuestion);
TextView lblSpace = new TextView(this);
lblSpace.setText(" : ");
lblSpace.setLayoutParams(lpSpace);
row.addView(lblSpace);
if(flag.equals(Global.FLAG_FOR_IMAGE) || flag.equals(Global.FLAG_FOR_IMAGE_WITH_GPS)) {
final ImageThumbnail thumb = new ImageThumbnail(this, 100, 100);
thumb.setOnClickListener(this);
if (flag.equals(Global.FLAG_FOR_IMAGE_WITH_GPS)) {
thumb.setLayoutParams(lpImage);
} else {
thumb.setLayoutParams(lpQuestion);
}
thumbnailMapping.put(thumb, answer);
row.addView(thumb);
if (flag.equals(Global.FLAG_FOR_IMAGE_WITH_GPS)) {
final ImageThumbnail thumbLoc = new ImageThumbnail(this, 100, 100);
thumbLoc.setImageResource(R.drawable.ic_absent);
thumbLoc.setLayoutParams(lpImage);
row.addView(thumbLoc);
thumbLoc.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
String[] value = Tool.split(answer, ",");
if (value.length > 2) {
String lat = value[1];
String lng = value[2];
Intent intent = new Intent(getApplicationContext(), MapsViewer.class);
intent.putExtra("latitude", lat);
intent.putExtra("longitude", lng);
startActivity(intent);
}
} catch (Exception e) {
FireCrash.log(e);
}
}
});
}
}else if(flag.equals(Global.FLAG_FOR_LOCATION)){
final ImageThumbnail thumb = new ImageThumbnail(this, 90, 90);
thumb.setImageResource(R.drawable.ic_absent);
thumb.setOnClickListener(this);
thumb.setLayoutParams(lpQuestion);
thumbnailMapping.put(thumb, answer);
row.addView(thumb);
}else{
TextView lblAnswer = new TextView(this);
lblAnswer.setText(answer);
lblAnswer.setLayoutParams(lpQuestion);
row.addView(lblAnswer);
}
detailTable.addView(row);
no++;
}
} catch (Exception e) { FireCrash.log(e);
}
}
public void doSubmit(View view){
if(assignId != null && assignId.length()>0){
String notes = txtNotes.getText().toString();
if (notes.length() == 0 && notes.equals("")) {
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.notes_required),
Toast.LENGTH_LONG).show();
} else {
SubmitAssignTask task = new SubmitAssignTask(this, notes, uuid_task_h, assignId, flag);
task.execute();
}
}else{
Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.select_cmo),
Toast.LENGTH_LONG).show();
}
}
public void doLookupCMO(View view){
Intent intent = new Intent(this, LookupAssignment.class);
Bundle extras = new Bundle();
extras.putString(Global.BUND_KEY_TASK, flag);
extras.putString(Global.BUND_KEY_UUID_TASKH, uuid_task_h);
intent.putExtras(extras);
startActivityForResult(intent, Global.REQUEST_CODE_LOOKUP);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Global.REQUEST_CODE_LOOKUP){ //it's the one we request from the beginning
String value = data.getStringExtra(Global.BUND_KEY_ASSIGNEE_VALUE);
assignId = data.getStringExtra(Global.BUND_KEY_ASSIGNEE_ID);
String job = data.getStringExtra(Global.BUND_KEY_ASSIGNEE_JOB);
btnLookupCMO.setText(job+" - "+value);
}
}
@Override
public void onClick(View v) {
ImageThumbnail imgThumbnail = null;
try {
imgThumbnail = (ImageThumbnail) v;
if (imgThumbnail.getResultImg() != null){
try {
Bitmap image = Utils.byteToBitmap(imgThumbnail.getResultImg());
DialogManager.showImageDialog(this, image);
} catch (Exception e) {
FireCrash.log(e);
}
}
else{
String fieldKey = thumbnailMapping.get(v);
String[] value = Tool.split(fieldKey, ",");
if (value.length == 1) {
if (nomorOrder != null && !"".equals(nomorOrder)){
targetThumbnail = (ImageThumbnail)v; //store thumbnail for further reference after connection finish
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair(Global.BUND_KEY_UUID_TASKH, uuid_task_h));
params.add(new BasicNameValuePair(Global.BUND_KEY_QUESTIONID, fieldKey));
new getImageTask(this,params).execute();
}
else{
Toast.makeText(this, "ERROR: path not received", Toast.LENGTH_SHORT).show();
}
} else if (value.length > 2) {
String img = value[0];
if (nomorOrder != null && !"".equals(nomorOrder)){
targetThumbnail = (ImageThumbnail)v; //store thumbnail for further reference after connection finish
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair(Global.BUND_KEY_UUID_TASKH, uuid_task_h));
params.add(new BasicNameValuePair(Global.BUND_KEY_QUESTIONID, img));
new getImageTask(this,params).execute();
}
else{
Toast.makeText(this, "ERROR: path not received", Toast.LENGTH_SHORT).show();
}
} else {
String lat = value[0];
String lng = value[1];
Intent intent = new Intent(this, MapsViewer.class);
intent.putExtra("latitude", lat);
intent.putExtra("longitude", lng);
startActivity(intent);
}
}
} catch (Exception e) { FireCrash.log(e);
}
}
}

View file

@ -0,0 +1,41 @@
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_grayscale"/>
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
The drawer is given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->
<ListView
android:id="@+id/left_drawer"
android:paddingTop="?android:attr/actionBarSize"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#dddddd"
android:dividerHeight="1px"
android:background="#001223"/>
<!-- <ListView -->
<!-- android:id="@+id/right_drawer" -->
<!-- android:paddingTop="?android:attr/actionBarSize" -->
<!-- android:layout_width="240dp" -->
<!-- android:layout_height="match_parent" -->
<!-- android:layout_gravity="end" -->
<!-- android:choiceMode="singleChoice" -->
<!-- android:divider="@android:color/transparent" -->
<!-- android:dividerHeight="0dp" -->
<!-- android:background="#111"/> -->
</androidx.drawerlayout.widget.DrawerLayout>

View file

@ -0,0 +1,35 @@
package com.adins.mss.base.dynamicform;
import com.adins.mss.dao.User;
public class UserClone extends User {
public UserClone(User user, boolean useImage) {
this.setUuid_user(user.getUuid_user());
this.setFlag_job(user.getFlag_job());
this.setFullname(user.getFullname());
this.setBranch_id(user.getBranch_id());
this.setBranch_name(user.getBranch_name());
this.setPassword(user.getPassword());
this.setTask_seq(user.getTask_seq());
this.setGoogle_id(user.getGoogle_id());
this.setFacebook_id(user.getFacebook_id());
this.setLogin_id(user.getLogin_id());
this.setFail_count(user.getFail_count());
this.setLast_sync(user.getLast_sync());
this.setBranch_address(user.getBranch_address());
this.setUsr_crt(user.getUsr_crt());
this.setDtm_crt(user.getDtm_crt());
this.setUsr_upd(user.getUsr_upd());
this.setDtm_upd(user.getDtm_upd());
this.setChg_pwd(user.getChg_pwd());
this.setJob_description(user.getJob_description());
this.setPwd_exp(user.getPwd_exp());
this.setDealer_name(user.getDealer_name());
if (useImage) {
this.setImage_cover(user.getImage_cover());
this.setImage_profile(user.getImage_profile());
}
}
}

View file

@ -0,0 +1,136 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License 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.adins.libs.nineoldandroids.animation;
import android.view.animation.Interpolator;
import com.adins.libs.nineoldandroids.animation.Keyframe.FloatKeyframe;
import java.util.ArrayList;
/**
* This class holds a collection of FloatKeyframe objects and is called by ValueAnimator to calculate
* values between those keyframes for a given animation. The class internal to the animation
* package because it is an implementation detail of how Keyframes are stored and used.
* <p>
* <p>This type-specific subclass of KeyframeSet, along with the other type-specific subclass for
* int, exists to speed up the getValue() method when there is no custom
* TypeEvaluator set for the animation, so that values can be calculated without autoboxing to the
* Object equivalents of these primitive types.</p>
*/
class FloatKeyframeSet extends KeyframeSet {
private float firstValue;
private float lastValue;
private float deltaValue;
private boolean firstTime = true;
public FloatKeyframeSet(FloatKeyframe... keyframes) {
super(keyframes);
}
@Override
public Object getValue(float fraction) {
return getFloatValue(fraction);
}
@Override
public FloatKeyframeSet clone() {
ArrayList<Keyframe> keyframes = mKeyframes;
int numKeyframes = mKeyframes.size();
FloatKeyframe[] newKeyframes = new FloatKeyframe[numKeyframes];
for (int i = 0; i < numKeyframes; ++i) {
newKeyframes[i] = (FloatKeyframe) keyframes.get(i).clone();
}
FloatKeyframeSet newSet = new FloatKeyframeSet(newKeyframes);
return newSet;
}
public float getFloatValue(float fraction) {
if (mNumKeyframes == 2) {
if (firstTime) {
firstTime = false;
firstValue = ((FloatKeyframe) mKeyframes.get(0)).getFloatValue();
lastValue = ((FloatKeyframe) mKeyframes.get(1)).getFloatValue();
deltaValue = lastValue - firstValue;
}
if (mInterpolator != null) {
fraction = mInterpolator.getInterpolation(fraction);
}
if (mEvaluator == null) {
return firstValue + fraction * deltaValue;
} else {
return ((Number) mEvaluator.evaluate(fraction, firstValue, lastValue)).floatValue();
}
}
if (fraction <= 0f) {
final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0);
final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(1);
float prevValue = prevKeyframe.getFloatValue();
float nextValue = nextKeyframe.getFloatValue();
float prevFraction = prevKeyframe.getFraction();
float nextFraction = nextKeyframe.getFraction();
final /*Time*/ Interpolator interpolator = nextKeyframe.getInterpolator();
if (interpolator != null) {
fraction = interpolator.getInterpolation(fraction);
}
float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
return mEvaluator == null ?
prevValue + intervalFraction * (nextValue - prevValue) :
((Number) mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
floatValue();
} else if (fraction >= 1f) {
final FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 2);
final FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(mNumKeyframes - 1);
float prevValue = prevKeyframe.getFloatValue();
float nextValue = nextKeyframe.getFloatValue();
float prevFraction = prevKeyframe.getFraction();
float nextFraction = nextKeyframe.getFraction();
final /*Time*/ Interpolator interpolator = nextKeyframe.getInterpolator();
if (interpolator != null) {
fraction = interpolator.getInterpolation(fraction);
}
float intervalFraction = (fraction - prevFraction) / (nextFraction - prevFraction);
return mEvaluator == null ?
prevValue + intervalFraction * (nextValue - prevValue) :
((Number) mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
floatValue();
}
FloatKeyframe prevKeyframe = (FloatKeyframe) mKeyframes.get(0);
for (int i = 1; i < mNumKeyframes; ++i) {
FloatKeyframe nextKeyframe = (FloatKeyframe) mKeyframes.get(i);
if (fraction < nextKeyframe.getFraction()) {
final /*Time*/ Interpolator interpolator = nextKeyframe.getInterpolator();
if (interpolator != null) {
fraction = interpolator.getInterpolation(fraction);
}
float intervalFraction = (fraction - prevKeyframe.getFraction()) /
(nextKeyframe.getFraction() - prevKeyframe.getFraction());
float prevValue = prevKeyframe.getFloatValue();
float nextValue = nextKeyframe.getFloatValue();
return mEvaluator == null ?
prevValue + intervalFraction * (nextValue - prevValue) :
((Number) mEvaluator.evaluate(intervalFraction, prevValue, nextValue)).
floatValue();
}
prevKeyframe = nextKeyframe;
}
// shouldn't get here
return ((Number) mKeyframes.get(mNumKeyframes - 1).getValue()).floatValue();
}
}

View file

@ -0,0 +1,457 @@
package com.adins.mss.dao;
import com.adins.mss.dao.DaoSession;
import de.greenrobot.dao.DaoException;
import com.adins.mss.base.util.ExcludeFromGson;
import com.google.gson.annotations.SerializedName;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
/**
* Entity mapped to table "MS_QUESTIONSET".
*/
public class QuestionSet {
/** Not-null value. */
@SerializedName("uuid_question_set")
private String uuid_question_set;
@SerializedName("question_group_id")
private String question_group_id;
@SerializedName("question_group_name")
private String question_group_name;
@SerializedName("question_group_order")
private Integer question_group_order;
@SerializedName("question_id")
private String question_id;
@SerializedName("question_label")
private String question_label;
@SerializedName("question_order")
private Integer question_order;
@SerializedName("answer_type")
private String answer_type;
@SerializedName("option_answers")
private String option_answers;
@SerializedName("choice_filter")
private String choice_filter;
@SerializedName("is_mandatory")
private String is_mandatory;
@SerializedName("max_length")
private Integer max_length;
@SerializedName("is_visible")
private String is_visible;
@SerializedName("is_readonly")
private String is_readonly;
@SerializedName("regex")
private String regex;
@SerializedName("relevant_question")
private String relevant_question;
@SerializedName("calculate")
private String calculate;
@SerializedName("constraint_message")
private String constraint_message;
@SerializedName("usr_crt")
private String usr_crt;
@SerializedName("dtm_crt")
private java.util.Date dtm_crt;
@SerializedName("usr_upd")
private String usr_upd;
@SerializedName("dtm_upd")
private java.util.Date dtm_upd;
@SerializedName("identifier_name")
private String identifier_name;
@SerializedName("uuid_scheme")
private String uuid_scheme;
@SerializedName("lov_group")
private String lov_group;
@SerializedName("tag")
private String tag;
@SerializedName("is_holiday_allowed")
private String is_holiday_allowed;
@SerializedName("img_quality")
private String img_quality;
@SerializedName("question_validation")
private String question_validation;
@SerializedName("question_value")
private String question_value;
@SerializedName("validate_err_message")
private String validate_err_message;
@SerializedName("form_version")
private String form_version;
@SerializedName("relevant_mandatory")
private String relevant_mandatory;
/** Used to resolve relations */
private transient DaoSession daoSession;
/** Used for active entity operations. */
private transient QuestionSetDao myDao;
private Scheme scheme;
private String scheme__resolvedKey;
public QuestionSet() {
}
public QuestionSet(String uuid_question_set) {
this.uuid_question_set = uuid_question_set;
}
public QuestionSet(String uuid_question_set, String question_group_id, String question_group_name, Integer question_group_order, String question_id, String question_label, Integer question_order, String answer_type, String option_answers, String choice_filter, String is_mandatory, Integer max_length, String is_visible, String is_readonly, String regex, String relevant_question, String calculate, String constraint_message, String usr_crt, java.util.Date dtm_crt, String usr_upd, java.util.Date dtm_upd, String identifier_name, String uuid_scheme, String lov_group, String tag, String is_holiday_allowed, String img_quality, String question_validation, String question_value, String validate_err_message, String form_version, String relevant_mandatory) {
this.uuid_question_set = uuid_question_set;
this.question_group_id = question_group_id;
this.question_group_name = question_group_name;
this.question_group_order = question_group_order;
this.question_id = question_id;
this.question_label = question_label;
this.question_order = question_order;
this.answer_type = answer_type;
this.option_answers = option_answers;
this.choice_filter = choice_filter;
this.is_mandatory = is_mandatory;
this.max_length = max_length;
this.is_visible = is_visible;
this.is_readonly = is_readonly;
this.regex = regex;
this.relevant_question = relevant_question;
this.calculate = calculate;
this.constraint_message = constraint_message;
this.usr_crt = usr_crt;
this.dtm_crt = dtm_crt;
this.usr_upd = usr_upd;
this.dtm_upd = dtm_upd;
this.identifier_name = identifier_name;
this.uuid_scheme = uuid_scheme;
this.lov_group = lov_group;
this.tag = tag;
this.is_holiday_allowed = is_holiday_allowed;
this.img_quality = img_quality;
this.question_validation = question_validation;
this.question_value = question_value;
this.validate_err_message = validate_err_message;
this.form_version = form_version;
this.relevant_mandatory = relevant_mandatory;
}
/** called by internal mechanisms, do not call yourself. */
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getQuestionSetDao() : null;
}
/** Not-null value. */
public String getUuid_question_set() {
return uuid_question_set;
}
/** Not-null value; ensure this value is available before it is saved to the database. */
public void setUuid_question_set(String uuid_question_set) {
this.uuid_question_set = uuid_question_set;
}
public String getQuestion_group_id() {
return question_group_id;
}
public void setQuestion_group_id(String question_group_id) {
this.question_group_id = question_group_id;
}
public String getQuestion_group_name() {
return question_group_name;
}
public void setQuestion_group_name(String question_group_name) {
this.question_group_name = question_group_name;
}
public Integer getQuestion_group_order() {
return question_group_order;
}
public void setQuestion_group_order(Integer question_group_order) {
this.question_group_order = question_group_order;
}
public String getQuestion_id() {
return question_id;
}
public void setQuestion_id(String question_id) {
this.question_id = question_id;
}
public String getQuestion_label() {
return question_label;
}
public void setQuestion_label(String question_label) {
this.question_label = question_label;
}
public Integer getQuestion_order() {
return question_order;
}
public void setQuestion_order(Integer question_order) {
this.question_order = question_order;
}
public String getAnswer_type() {
return answer_type;
}
public void setAnswer_type(String answer_type) {
this.answer_type = answer_type;
}
public String getOption_answers() {
return option_answers;
}
public void setOption_answers(String option_answers) {
this.option_answers = option_answers;
}
public String getChoice_filter() {
return choice_filter;
}
public void setChoice_filter(String choice_filter) {
this.choice_filter = choice_filter;
}
public String getIs_mandatory() {
return is_mandatory;
}
public void setIs_mandatory(String is_mandatory) {
this.is_mandatory = is_mandatory;
}
public Integer getMax_length() {
return max_length;
}
public void setMax_length(Integer max_length) {
this.max_length = max_length;
}
public String getIs_visible() {
return is_visible;
}
public void setIs_visible(String is_visible) {
this.is_visible = is_visible;
}
public String getIs_readonly() {
return is_readonly;
}
public void setIs_readonly(String is_readonly) {
this.is_readonly = is_readonly;
}
public String getRegex() {
return regex;
}
public void setRegex(String regex) {
this.regex = regex;
}
public String getRelevant_question() {
return relevant_question;
}
public void setRelevant_question(String relevant_question) {
this.relevant_question = relevant_question;
}
public String getCalculate() {
return calculate;
}
public void setCalculate(String calculate) {
this.calculate = calculate;
}
public String getConstraint_message() {
return constraint_message;
}
public void setConstraint_message(String constraint_message) {
this.constraint_message = constraint_message;
}
public String getUsr_crt() {
return usr_crt;
}
public void setUsr_crt(String usr_crt) {
this.usr_crt = usr_crt;
}
public java.util.Date getDtm_crt() {
return dtm_crt;
}
public void setDtm_crt(java.util.Date dtm_crt) {
this.dtm_crt = dtm_crt;
}
public String getUsr_upd() {
return usr_upd;
}
public void setUsr_upd(String usr_upd) {
this.usr_upd = usr_upd;
}
public java.util.Date getDtm_upd() {
return dtm_upd;
}
public void setDtm_upd(java.util.Date dtm_upd) {
this.dtm_upd = dtm_upd;
}
public String getIdentifier_name() {
return identifier_name;
}
public void setIdentifier_name(String identifier_name) {
this.identifier_name = identifier_name;
}
public String getUuid_scheme() {
return uuid_scheme;
}
public void setUuid_scheme(String uuid_scheme) {
this.uuid_scheme = uuid_scheme;
}
public String getLov_group() {
return lov_group;
}
public void setLov_group(String lov_group) {
this.lov_group = lov_group;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
public String getIs_holiday_allowed() {
return is_holiday_allowed;
}
public void setIs_holiday_allowed(String is_holiday_allowed) {
this.is_holiday_allowed = is_holiday_allowed;
}
public String getImg_quality() {
return img_quality;
}
public void setImg_quality(String img_quality) {
this.img_quality = img_quality;
}
public String getQuestion_validation() {
return question_validation;
}
public void setQuestion_validation(String question_validation) {
this.question_validation = question_validation;
}
public String getQuestion_value() {
return question_value;
}
public void setQuestion_value(String question_value) {
this.question_value = question_value;
}
public String getValidate_err_message() {
return validate_err_message;
}
public void setValidate_err_message(String validate_err_message) {
this.validate_err_message = validate_err_message;
}
public String getForm_version() {
return form_version;
}
public void setForm_version(String form_version) {
this.form_version = form_version;
}
public String getRelevant_mandatory() {
return relevant_mandatory;
}
public void setRelevant_mandatory(String relevant_mandatory) {
this.relevant_mandatory = relevant_mandatory;
}
/** To-one relationship, resolved on first access. */
public Scheme getScheme() {
String __key = this.uuid_scheme;
if (scheme__resolvedKey == null || scheme__resolvedKey != __key) {
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
SchemeDao targetDao = daoSession.getSchemeDao();
Scheme schemeNew = targetDao.load(__key);
synchronized (this) {
scheme = schemeNew;
scheme__resolvedKey = __key;
}
}
return scheme;
}
public void setScheme(Scheme scheme) {
synchronized (this) {
this.scheme = scheme;
uuid_scheme = scheme == null ? null : scheme.getUuid_scheme();
scheme__resolvedKey = uuid_scheme;
}
}
/** Convenient call for {@link AbstractDao#delete(Object)}. Entity must attached to an entity context. */
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/** Convenient call for {@link AbstractDao#update(Object)}. Entity must attached to an entity context. */
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** Convenient call for {@link AbstractDao#refresh(Object)}. Entity must attached to an entity context. */
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
}

View file

@ -0,0 +1,122 @@
apply plugin: 'com.android.application'
android {
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds false
abortOnError false
}
// change with your msmkey storeFile
signingConfigs {
msmkey {
keyAlias 'aitmsskey'
keyPassword 'AdIns2020'
storeFile file('keystore2020.jks')
storePassword 'AdIns2020'
}
}
compileSdkVersion 30
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.adins.mss.odr"
minSdkVersion 19
targetSdkVersion 30
versionCode 7898
versionName "3.2.0.0-$versionCode"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
archivesBaseName = "MSSODR-$versionName"
ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
}
dexOptions {
javaMaxHeapSize "5g"
}
dataBinding {
enabled = true
}
buildTypes {
release {
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.msmkey
}
}
flavorDimensions "default"
productFlavors {
product {
applicationId "com.adins.mss.odr"
versionCode 7898
dimension "default"
versionName "3.2.0.0-$versionCode-P"
buildConfigField "boolean", "IS_DEV", "false"
buildConfigField "boolean", "IS_DBENCRYPT", "true"
buildConfigField "boolean", "IS_BYPASSROOT", "false"
buildConfigField "String", "IS_FLAVORS", "\"PRODUCT\""
}
trial {
applicationId "com.adins.mss.odr.trial"
versionCode 7898
dimension "default"
versionName "3.2.0.0-$versionCode-P"
buildConfigField "boolean", "IS_DEV", "false"
buildConfigField "boolean", "IS_DBENCRYPT", "true"
buildConfigField "boolean", "IS_BYPASSROOT", "false"
buildConfigField "String", "IS_FLAVORS", "\"TRIAL\""
}
cloud {
applicationId "com.adins.mss.odr.cloud"
versionCode 7898
dimension "default"
versionName "3.2.0.0-$versionCode-P"
buildConfigField "boolean", "IS_DEV", "false"
buildConfigField "boolean", "IS_DBENCRYPT", "true"
buildConfigField "boolean", "IS_BYPASSROOT", "false"
buildConfigField "String", "IS_FLAVORS", "\"PRODUCT\""
}
clouddev {
applicationId "com.adins.mss.odr.cloud.dev"
versionCode 7250
dimension "default"
versionName "3.2.0.0-$versionCode-D"
buildConfigField "boolean", "IS_DEV", "true"
buildConfigField "boolean", "IS_DBENCRYPT", "false"
buildConfigField "boolean", "IS_BYPASSROOT", "true"
buildConfigField "String", "IS_FLAVORS", "\"DEVELOPER\""
}
cloudtrial {
applicationId "com.adins.mss.odr.cloud.trial"
versionCode 7250
dimension "default"
versionName "3.2.0.0-$versionCode-P"
buildConfigField "boolean", "IS_DEV", "false"
buildConfigField "boolean", "IS_DBENCRYPT", "true"
buildConfigField "boolean", "IS_BYPASSROOT", "false"
buildConfigField "String", "IS_FLAVORS", "\"TRIAL\""
}
}
}
dependencies {
implementation project(':mssbase')
implementation('androidx.appcompat:appcompat:1.0.0')
implementation 'com.google.firebase:firebase-messaging:20.2.4'
implementation 'com.google.firebase:firebase-core:17.5.0'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
implementation 'com.google.firebase:firebase-perf:19.0.8'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'net.zetetic:android-database-sqlcipher:3.5.1'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bgColor">
<androidx.cardview.widget.CardView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_margin="3dp"
android:elevation="5dp">
<RelativeLayout
android:id="@+id/layout_top"
android:layout_width="match_parent"
android:layout_height="250dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.adins.mss.odr.catalogue.imageslider.SliderView
android:id="@+id/sliderView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_indicator"/>
<LinearLayout
android:id="@+id/pagesContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_marginBottom="8dp"
android:gravity="center_horizontal"
android:orientation="horizontal"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/catalogueList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"/>
</LinearLayout>

View file

@ -0,0 +1,510 @@
package com.services;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import androidx.core.app.NotificationCompat;
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.JsonRequestTaskD;
import com.adins.mss.base.dynamicform.JsonResponseTaskD;
import com.adins.mss.base.mainmenu.MainMenuActivity;
import com.adins.mss.base.timeline.TimelineManager;
import com.adins.mss.base.timeline.activity.Timeline_Activity;
import com.adins.mss.base.todolist.ToDoList;
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.Scheme;
import com.adins.mss.dao.TaskD;
import com.adins.mss.dao.TaskH;
import com.adins.mss.dao.Timeline;
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.db.dataaccess.TimelineDataAccess;
import com.adins.mss.foundation.db.dataaccess.TimelineTypeDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.foundation.notification.Notification;
import com.adins.mss.main.MSMApplication;
import com.adins.mss.svy.MSMainMenuActivity;
import com.adins.mss.svy.SurveyApprovalListTask;
import com.adins.mss.svy.models.JsonRequestTaskWithMode;
import com.adins.mss.svy.tool.Constants;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.HttpMetric;
import org.acra.ACRA;
import java.util.ArrayList;
import java.util.List;
//import com.adins.mss.foundation.notification.Notification.Tone;
//import com.adins.mss.foundation.notification.Notification.Vibrate;
public class SurveyApprovalThread extends Thread {
public static final String APPROVALLIST_NOTIFICATION_KEY = "APPROVALLIST_NOTIFICATION_KEY";
public static final String APPROVALBRANCHLIST_NOTIFICATION_KEY = "APPROVALBRANCHLIST_NOTIFICATION_KEY";
private Context context;
private int interval; // in miliseconds
private volatile boolean keepRunning = true;
private volatile boolean isWait = false;
public static long lastAssigmentDate = 0;
String sentStatus = "";
public static List<TaskH> taskHList = new ArrayList<TaskH>();
public static int notifCount = 0;
public String uuidUser ;
public boolean firstNotif = true;
// public Class mss;
public SurveyApprovalThread(Context context) {
// TODO Auto-generated constructor stub
this.context = context;
interval = Global.MINUTE * 10;
try {
uuidUser = GlobalData.getSharedGlobalData().getUser()
.getUuid_user();
if(uuidUser!=null){
if (GeneralParameterDataAccess.getOne(context, uuidUser, "PRM04_F5IN")
.getGs_value() != null
&& !GeneralParameterDataAccess
.getOne(context, uuidUser, "PRM04_F5IN").getGs_value()
.isEmpty()) {
interval = Integer.parseInt(GeneralParameterDataAccess.getOne(
context, uuidUser, "PRM04_F5IN").getGs_value()) * 1000; // from
// milisecond
// to
// second
}
}else{
keepRunning = false;
}
} catch (Exception e) {
FireCrash.log(e);
if(Global.user!=null){
uuidUser = Global.user.getUuid_user();
if(uuidUser!=null){
if (GeneralParameterDataAccess.getOne(context, uuidUser, "PRM04_F5IN")
.getGs_value() != null
&& !GeneralParameterDataAccess
.getOne(context, uuidUser, "PRM04_F5IN").getGs_value()
.isEmpty()) {
interval = Integer.parseInt(GeneralParameterDataAccess.getOne(
context, uuidUser, "PRM04_F5IN").getGs_value()) * 1000; // from
// milisecond
// to
// second
}
}
}else{
keepRunning = false;
}
}
}
@Override
public void run() {
while (keepRunning) {
try {
synchronized (this) {
if (isWait) {
this.wait();
}
}
if (Tool.isInternetconnected(context)) {
if(NewMainActivity.mnSurveyApproval!=null){
notifCount = 0;
taskHList = getServerNewTask(false);
notifCount = taskHList.size();
// save to local
if(taskHList!=null && taskHList.size()>0)
ProcessTaskList(notifCount, taskHList, false);
} else if(NewMainActivity.mnApprovalByBranch !=null){
notifCount = 0;
taskHList = getServerNewTask(true);
notifCount = taskHList.size();
// save to local
if(taskHList!=null &&taskHList.size()>0)
ProcessTaskList(notifCount, taskHList, true);
}
}
// bong 10 apr 15 - Gigin request penjagaan jika PRM F5IN dari
// server = 0
// minimal notif jalan satu kali
if (interval == 0) {
keepRunning = false;
}
/*Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
public void run() {
// UI code goes here
try {
if (MainMenuActivity.mnSVYApproval != null)
MainMenuActivity.mnSVYApproval.setCounter(String.valueOf(Constants.getCounterApprovalTask(context)));
if (MSMainMenuActivity.mnSVYApprovalByBranch != null)
MSMainMenuActivity.mnSVYApprovalByBranch.setCounter(String.valueOf(Constants.getCounterApprovalTaskByBranch(context)));
if (MainMenuActivity.menuAdapter != null)
MainMenuActivity.menuAdapter.notifyDataSetChanged();
if (Timeline_Activity.getTimelineHandler() != null)
Timeline_Activity.getTimelineHandler().sendEmptyMessage(0);
// long taskListCounter = ToDoList.getAllCounter(context);
// if(Timeline_Activity.query!=null)
// Timeline_Activity.query.id(R.id.txtJumlahOutstanding).text(String.valueOf(taskListCounter));
} catch (Exception e) { FireCrash.log(e);
// TODO: handle exception
}
}
});*/
try {
// MainMenuActivity.setDrawerCounter();
NewMainActivity.setCounter();
} catch (Exception e) {
FireCrash.log(e);
// TODO: handle exception
}
sleep(interval);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
private void ProcessTaskList(int notifCount, List<TaskH> taskHList, boolean isBranch) {
// List<String> listUuidTaskH = null;
if (taskHList.size() > 0) {
// listUuidTaskH = new ArrayList<>();
for (TaskH taskH : taskHList) {
// listUuidTaskH.add(taskH.getUuid_task_h());
taskH.setUser(GlobalData.getSharedGlobalData()
.getUser());
taskH.setUuid_user(GlobalData
.getSharedGlobalData().getUser()
.getUuid_user());
taskH.setIs_verification(Global.TRUE_STRING);
if (isBranch)
taskH.setAccess_mode(TaskHDataAccess.ACCESS_MODE_BRANCH);
else
taskH.setAccess_mode(TaskHDataAccess.ACCESS_MODE_USER);
String uuid_timelineType = TimelineTypeDataAccess
.getTimelineTypebyType(context,
Global.TIMELINE_TYPE_APPROVAL)
.getUuid_timeline_type();
boolean wasInTimeline = TimelineDataAccess
.getOneTimelineByTaskH(context,
GlobalData
.getSharedGlobalData()
.getUser()
.getUuid_user(),
taskH.getUuid_task_h(),
uuid_timelineType) != null;
String uuid_scheme = taskH.getUuid_scheme();
Scheme scheme = SchemeDataAccess.getOne(
context, uuid_scheme);
if (scheme != null) {
taskH.setScheme(scheme);
TaskH h = TaskHDataAccess.getOneTaskHeader(
context, taskH.getTask_id());
if (h != null && h.getStatus() != null) {
if (!ToDoList.isOldTask(h)) {
TaskHDataAccess.addOrReplace(
context, taskH);
if (!wasInTimeline)
TimelineManager.insertTimeline(
context, taskH);
} else {
if (h.getAccess_mode() != null && h.getAccess_mode().length() > 0) {
if (!isBranch && h.getAccess_mode()
.equals(TaskHDataAccess.ACCESS_MODE_BRANCH)) {
h.setAccess_mode(TaskHDataAccess.ACCESS_MODE_HYBRID);
TaskHDataAccess
.addOrReplace(
context, h);
} else if (isBranch && h.getAccess_mode()
.equals(TaskHDataAccess.ACCESS_MODE_USER)) {
h.setAccess_mode(TaskHDataAccess.ACCESS_MODE_HYBRID);
TaskHDataAccess
.addOrReplace(
context, h);
}
}
notifCount--;
}
} else {
TaskHDataAccess.addOrReplace(context,
taskH);
if (!wasInTimeline)
TimelineManager.insertTimeline(
context, taskH);
}
// tambahin buat get answer
TaskD d = TaskDDataAccess.getOneByTaskH(context, taskH.getUuid_task_h());
boolean isHaveAnswer = d != null;
if (!isHaveAnswer) {
JsonRequestTaskD request = new JsonRequestTaskD();
request.setAudit(GlobalData.getSharedGlobalData().getAuditData());
request.setuuid_task_h(taskH.getUuid_task_h());
String json = GsonHelper.toJson(request);
String url = GlobalData.getSharedGlobalData().getURL_GET_VERIFICATION();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
HttpConnectionResult serverResult = null;
//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);
e.printStackTrace();
}
if (serverResult.isOK()) {
try {
String result = serverResult.getResult();
JsonResponseTaskD response = GsonHelper.fromJson(result, JsonResponseTaskD.class);
if (response.getStatus().getCode() == 0) {
List<TaskD> taskDs = response.getListTask();
if (taskDs.size() > 0) {
TaskH h2 = TaskHDataAccess.getOneHeader(
context, taskH.getUuid_task_h());
if (h2 != null && h2.getStatus() != null) {
if (!ToDoList.isOldTask(h2)) {
taskH.setScheme(scheme);
taskH.setStatus(TaskHDataAccess.STATUS_TASK_APPROVAL_DOWNLOAD);
TaskHDataAccess.addOrReplace(context, taskH);
for (TaskD taskD : taskDs) {
taskD.setTaskH(taskH);
TaskDDataAccess.addOrReplace(context, taskD);
}
}
} else {
taskH.setScheme(scheme);
taskH.setStatus(TaskHDataAccess.STATUS_TASK_APPROVAL_DOWNLOAD);
TaskHDataAccess.addOrReplace(context, taskH);
for (TaskD taskD : taskDs) {
taskD.setTaskH(taskH);
TaskDDataAccess.addOrReplace(context, taskD);
}
}
}
} else {
if (Global.IS_DEV)
System.out.println(result);
}
} catch (Exception e) {
FireCrash.log(e);
}
}
}
} else {
notifCount--;
}
}
String notifTitle = context.getString(R.string.approval_tasks, notifCount);
String message = context.getString(R.string.approval_tasks_remaining, notifCount);
Intent resultIntent = new Intent(context, MSMApplication.getInstance().getHomeClass());
resultIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
/*Vibrate vibrate = null;
try {
vibrate = Vibrate
.valueOf(GeneralParameterDataAccess.getOne(
context, uuidUser, "PRM14_VIB")
.getGs_value());
} catch (Exception ex) {
vibrate = Vibrate.OFF;
}
Tone tone = null;
try {
tone = Tone.valueOf(GeneralParameterDataAccess
.getOne(context, uuidUser, "PRM15_TON")
.getGs_value());
} catch (Exception ex) {
tone = Tone.OFF;
}*/
// boolean autoClear = true;
// try {
// autoClear = Boolean
// .parseBoolean(GeneralParameterDataAccess
// .getOne(context, uuidUser,
// "PRM16_ACN").getGs_value());
// } catch (Exception ex) {
// // ex.printStackTrace();
// autoClear = true;
// }
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setSmallIcon(NotificationThread.getNotificationIcon());
builder.setContentTitle(notifTitle);
builder.setContentText(message).setNumber(notifCount);
builder.setPriority(NORM_PRIORITY);
// Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
// builder.setSound(alarmSound);
// builder.setVibrate(new long[] { 1000});
// builder.setLights(Color.RED, 3000, 3000);
NotificationCompat.BigTextStyle inboxStyle =
new NotificationCompat.BigTextStyle();
inboxStyle.setBigContentTitle(notifTitle);
if (isBranch) {
inboxStyle.bigText(message + " " + context.getString(R.string.click_to_open_approval_branch));
resultIntent.setAction(APPROVALBRANCHLIST_NOTIFICATION_KEY);
} else {
inboxStyle.bigText(message + " " + context.getString(R.string.click_to_open_approval));
resultIntent.setAction(APPROVALLIST_NOTIFICATION_KEY);
}
builder.setDefaults(android.app.Notification.DEFAULT_ALL);
builder.setStyle(inboxStyle);
builder.setAutoCancel(true);
PendingIntent pendingIntent = PendingIntent
.getActivity(context, 0, resultIntent, 0);
Notification.getSharedNotification().setDefaultIcon(
R.drawable.icon_notif_new);
builder.setContentIntent(pendingIntent);
if (notifCount > 0) {
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(3, builder.build());
notifCount = 0;
}
}
//check for changed task in result(local db) data
List<TaskH> localTaskHs = TaskHDataAccess.getAllApproval(context,GlobalData.getSharedGlobalData().getUser().getUuid_user());
if(localTaskHs != null && localTaskHs.size() > 0){
for (int i= 0; i<localTaskHs.size(); i++) {
boolean taskNotfound = false;
TaskH taskh_local = localTaskHs.get(i);
if(taskh_local == null)
continue;
if(taskHList != null && taskHList.size() > 0){
//delete taskh_local
for(TaskH taskHServer :taskHList){
if(taskHServer != null && taskHServer.getTask_id().equals(taskh_local.getTask_id())){
taskNotfound = true;
break;
}
}
if(!taskNotfound){
taskh_local.setStatus(TaskHDataAccess.STATUS_TASK_CHANGED);
taskh_local.setIs_prepocessed(Global.FORM_TYPE_APPROVAL);
taskh_local.setMessage(context.getString(com.adins.mss.svy.R.string.taskChanged));
TaskHDataAccess.addOrReplace(context,taskh_local);
TimelineManager.insertTimeline(context,taskh_local);
}
}
}
}
// List<TaskH> taskHs = TaskHDataAccess.getAllTaskByStatus(context, GlobalData.getSharedGlobalData().getUser().getUuid_user(), TaskHDataAccess.STATUS_TASK_APPROVAL_DOWNLOAD);
// if (listUuidTaskH != null) {
// if (taskHs != null) {
// for (TaskH h : taskHs) {
// String uuid_task_h = h.getUuid_task_h();
// boolean isSame = false;
// for (String uuid_from_server : listUuidTaskH) {
// if (uuid_task_h.equals(uuid_from_server)) {
// isSame = true;
// break;
// }
// }
// if (!isSame) {
// TaskHDataAccess.deleteWithRelation(context, h);
// }
// }
// }
// }
}
public synchronized void requestWait() {
isWait = true;
}
public synchronized void stopWaiting() {
isWait = false;
synchronized (this) {
this.notifyAll();
}
}
public synchronized void requestStop() {
Notification.getSharedNotification().clearNotifAll(context);
keepRunning = false;
}
public List<TaskH> getServerNewTask(boolean isBranch) {
JsonRequestTaskWithMode requestType = new JsonRequestTaskWithMode();
requestType.setAudit(GlobalData.getSharedGlobalData().getAuditData());
requestType.addImeiAndroidIdToUnstructured();
if(isBranch)
requestType.setMode(SurveyApprovalListTask.KEY_BRANCH);
String json = GsonHelper.toJson(requestType);
String url = GlobalData.getSharedGlobalData().getURL_GET_LIST_APPROVAL();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
HttpConnectionResult serverResult = null;
//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);
e.printStackTrace();
}
sentStatus = serverResult.getResult();
if(Global.IS_DEV)
System.out.println("Here is sent status from notif Approval : " + sentStatus);
// need object to get json reply from server
JsonResponseRetrieveTaskList jrsrtl = new JsonResponseRetrieveTaskList();
jrsrtl = GsonHelper.fromJson(sentStatus, JsonResponseRetrieveTaskList.class);
// new task must be saved to database
if (jrsrtl.getListTaskList() != null)
return jrsrtl.getListTaskList();
else
return new ArrayList<TaskH>();
}
public static List<TaskH> getTaskHList() {
return taskHList;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB