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,118 @@
package com.adins.mss.base.dynamictheme;
import android.content.Context;
import com.adins.mss.base.GlobalData;
import com.adins.mss.dao.Theme;
import com.adins.mss.foundation.db.dataaccess.ThemeDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
/**
* Created by intishar.fa on 04/09/2018.
*/
public class DynamicTheme {
private String uuidTheme;
@SerializedName("version")
private int version;
private String applicationType;
@SerializedName("items")
private List<ThemeItem> themeItemList;
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public List<ThemeItem> getThemeItemList() {
return themeItemList;
}
public void setThemeItemList(List<ThemeItem> themeItemList) {
this.themeItemList = themeItemList;
}
public String getUuidTheme() {
return uuidTheme;
}
public void setUuidTheme(String uuidTheme) {
this.uuidTheme = uuidTheme;
}
public String getApplicationType() {
return applicationType;
}
public void setApplicationType(String applicationType) {
this.applicationType = applicationType;
}
public DynamicTheme(){}
public DynamicTheme(Theme theme,List<com.adins.mss.dao.ThemeItem> themeList){//used after get list of theme from saved theme on local db
if(themeList != null && themeList.size() > 0){
themeItemList = new ArrayList<>();
this.uuidTheme = theme.getUuid_theme();
this.version = Integer.parseInt(theme.getVersion());
this.applicationType = theme.getApplication_type();
//set theme item list
for (com.adins.mss.dao.ThemeItem themeitem :themeList) {
if(themeitem!=null){
ThemeItem tempThemeItem = new ThemeItem();
tempThemeItem.setItem_id(themeitem.getUuid_theme_item());
tempThemeItem.setItemName(themeitem.getTheme_item());
tempThemeItem.setValue(themeitem.getValue());
themeItemList.add(tempThemeItem);
}
}
}
}
public static Theme toThemeDao(Context context,DynamicTheme dynamicTheme){//used after get dynamictheme object from server to create obj
if(dynamicTheme == null)
return null;
else {
String version = String.valueOf(dynamicTheme.getVersion());
Theme theme = new Theme();
String uuidTheme = null;
//check uuid from saved theme
List<Theme> savedThemes = ThemeDataAccess.getThemeByApplicationType(context,
GlobalData.getSharedGlobalData().getApplication());
if(savedThemes != null && savedThemes.size() > 0){
uuidTheme = savedThemes.get(0).getUuid_theme();
}
else {
uuidTheme = Tool.getUUID();//new theme
}
theme.setUuid_theme(uuidTheme);
theme.setApplication_type(GlobalData.getSharedGlobalData().getApplication());
theme.setVersion(version);
return theme;
}
}
public static List<com.adins.mss.dao.ThemeItem> toThemeItemList(Context context,String uuidTheme,List<ThemeItem> themeItemList){
List<com.adins.mss.dao.ThemeItem> themeItemListDb = new ArrayList<>();
for (ThemeItem item:themeItemList) {
if(item == null)
continue;
com.adins.mss.dao.ThemeItem temp = new com.adins.mss.dao.ThemeItem();
temp.setUuid_theme_item(Tool.getUUID());
temp.setUuid_theme(uuidTheme);
temp.setTheme_item(item.getItemName());
temp.setValue(item.getValue());
themeItemListDb.add(temp);
}
return themeItemListDb;
}
}

View file

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bgColor" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:id="@+id/recapitulationContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:cardCornerRadius="10dp"
app:contentPadding="7dp"
app:cardElevation="@dimen/card_shadow"
android:layout_marginTop="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin"
android:layout_marginBottom="60dp"
app:cardBackgroundColor="@color/fontColorWhite">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/label_recapitulation"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
android:textColor="@color/colorMC"
android:paddingBottom="10dp"/>
<LinearLayout
android:id="@+id/totalLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/lblTotal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/total"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="@color/timelineLine" />
<TextView
android:id="@+id/total"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_gravity="center|end"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
android:textAlignment="textEnd" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/batchIdLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/lblBatchId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:paddingBottom="10dp"
android:text="@string/batch_id"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="@color/timelineLine" />
<TextView
android:id="@+id/batchId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:layout_gravity="center|end"
android:paddingBottom="10dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
android:textAlignment="textEnd" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_centerHorizontal="true"
android:layout_alignBottom="@+id/batchIdLayout"
android:background="@color/timelineLine"
android:layout_marginBottom="5dp"/>
</RelativeLayout>
<ListView
android:id="@+id/listRecapitulationDetail"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>
</androidx.cardview.widget.CardView>
<Button
android:id="@+id/btnTransfer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="5dp"
android:background="@drawable/button_background"
android:text="@string/btnTransfer"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/fontColorWhite" />
</RelativeLayout>
</LinearLayout>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!--<item-->
<!--android:id="@+id/search"-->
<!--app:showAsAction="never"-->
<!--android:title="Search"-->
<!--android:actionLayout="@layout/new_search_layout"-->
<!--android:visible="true"/>-->
<item
android:id="@+id/mnGPS"
app:showAsAction="always"
android:icon="@drawable/location_off"
android:visible="true"
android:enabled="true"
android:title="GPS" />
</menu>

View file

@ -0,0 +1,358 @@
/*
* 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;
/**
* This class holds a time/value pair for an animation. The Keyframe class is used
* by {@link ValueAnimator} to define the values that the animation target will have over the course
* of the animation. As the time proceeds from one keyframe to the other, the value of the
* target object will animate between the value at the previous keyframe and the value at the
* next keyframe. Each keyframe also holds an optional {@link TimeInterpolator}
* object, which defines the time interpolation over the intervalue preceding the keyframe.
* <p>
* <p>The Keyframe class itself is abstract. The type-specific factory methods will return
* a subclass of Keyframe specific to the type of value being stored. This is done to improve
* performance when dealing with the most common cases (e.g., <code>float</code> and
* <code>int</code> values). Other types will fall into a more general Keyframe class that
* treats its values as Objects. Unless your animation requires dealing with a custom type
* or a data structure that needs to be animated directly (and evaluated using an implementation
* of {@link TypeEvaluator}), you should stick to using float and int as animations using those
* types have lower runtime overhead than other types.</p>
*/
public abstract class Keyframe implements Cloneable {
/**
* The time at which mValue will hold true.
*/
float mFraction;
/**
* The type of the value in this Keyframe. This type is determined at construction time,
* based on the type of the <code>value</code> object passed into the constructor.
*/
Class mValueType;
/**
* Flag to indicate whether this keyframe has a valid value. This flag is used when an
* animation first starts, to populate placeholder keyframes with real values derived
* from the target object.
*/
boolean mHasValue = false;
/**
* The optional time interpolator for the interval preceding this keyframe. A null interpolator
* (the default) results in linear interpolation over the interval.
*/
private /*Time*/ Interpolator mInterpolator = null;
/**
* Constructs a Keyframe object with the given time and value. The time defines the
* time, as a proportion of an overall animation's duration, at which the value will hold true
* for the animation. The value for the animation between keyframes will be calculated as
* an interpolation between the values at those keyframes.
*
* @param fraction The time, expressed as a value between 0 and 1, representing the fraction
* of time elapsed of the overall animation duration.
* @param value The value that the object will animate to as the animation time approaches
* the time in this keyframe, and the the value animated from as the time passes the time in
* this keyframe.
*/
public static Keyframe ofInt(float fraction, int value) {
return new IntKeyframe(fraction, value);
}
/**
* Constructs a Keyframe object with the given time. The value at this time will be derived
* from the target object when the animation first starts (note that this implies that keyframes
* with no initial value must be used as part of an {@link ObjectAnimator}).
* The time defines the
* time, as a proportion of an overall animation's duration, at which the value will hold true
* for the animation. The value for the animation between keyframes will be calculated as
* an interpolation between the values at those keyframes.
*
* @param fraction The time, expressed as a value between 0 and 1, representing the fraction
* of time elapsed of the overall animation duration.
*/
public static Keyframe ofInt(float fraction) {
return new IntKeyframe(fraction);
}
/**
* Constructs a Keyframe object with the given time and value. The time defines the
* time, as a proportion of an overall animation's duration, at which the value will hold true
* for the animation. The value for the animation between keyframes will be calculated as
* an interpolation between the values at those keyframes.
*
* @param fraction The time, expressed as a value between 0 and 1, representing the fraction
* of time elapsed of the overall animation duration.
* @param value The value that the object will animate to as the animation time approaches
* the time in this keyframe, and the the value animated from as the time passes the time in
* this keyframe.
*/
public static Keyframe ofFloat(float fraction, float value) {
return new FloatKeyframe(fraction, value);
}
/**
* Constructs a Keyframe object with the given time. The value at this time will be derived
* from the target object when the animation first starts (note that this implies that keyframes
* with no initial value must be used as part of an {@link ObjectAnimator}).
* The time defines the
* time, as a proportion of an overall animation's duration, at which the value will hold true
* for the animation. The value for the animation between keyframes will be calculated as
* an interpolation between the values at those keyframes.
*
* @param fraction The time, expressed as a value between 0 and 1, representing the fraction
* of time elapsed of the overall animation duration.
*/
public static Keyframe ofFloat(float fraction) {
return new FloatKeyframe(fraction);
}
/**
* Constructs a Keyframe object with the given time and value. The time defines the
* time, as a proportion of an overall animation's duration, at which the value will hold true
* for the animation. The value for the animation between keyframes will be calculated as
* an interpolation between the values at those keyframes.
*
* @param fraction The time, expressed as a value between 0 and 1, representing the fraction
* of time elapsed of the overall animation duration.
* @param value The value that the object will animate to as the animation time approaches
* the time in this keyframe, and the the value animated from as the time passes the time in
* this keyframe.
*/
public static Keyframe ofObject(float fraction, Object value) {
return new ObjectKeyframe(fraction, value);
}
/**
* Constructs a Keyframe object with the given time. The value at this time will be derived
* from the target object when the animation first starts (note that this implies that keyframes
* with no initial value must be used as part of an {@link ObjectAnimator}).
* The time defines the
* time, as a proportion of an overall animation's duration, at which the value will hold true
* for the animation. The value for the animation between keyframes will be calculated as
* an interpolation between the values at those keyframes.
*
* @param fraction The time, expressed as a value between 0 and 1, representing the fraction
* of time elapsed of the overall animation duration.
*/
public static Keyframe ofObject(float fraction) {
return new ObjectKeyframe(fraction, null);
}
/**
* Indicates whether this keyframe has a valid value. This method is called internally when
* an {@link ObjectAnimator} first starts; keyframes without values are assigned values at
* that time by deriving the value for the property from the target object.
*
* @return boolean Whether this object has a value assigned.
*/
public boolean hasValue() {
return mHasValue;
}
/**
* Gets the value for this Keyframe.
*
* @return The value for this Keyframe.
*/
public abstract Object getValue();
/**
* Sets the value for this Keyframe.
*
* @param value value for this Keyframe.
*/
public abstract void setValue(Object value);
/**
* Gets the time for this keyframe, as a fraction of the overall animation duration.
*
* @return The time associated with this keyframe, as a fraction of the overall animation
* duration. This should be a value between 0 and 1.
*/
public float getFraction() {
return mFraction;
}
/**
* Sets the time for this keyframe, as a fraction of the overall animation duration.
*
* @param fraction time associated with this keyframe, as a fraction of the overall animation
* duration. This should be a value between 0 and 1.
*/
public void setFraction(float fraction) {
mFraction = fraction;
}
/**
* Gets the optional interpolator for this Keyframe. A value of <code>null</code> indicates
* that there is no interpolation, which is the same as linear interpolation.
*
* @return The optional interpolator for this Keyframe.
*/
public /*Time*/Interpolator getInterpolator() {
return mInterpolator;
}
/**
* Sets the optional interpolator for this Keyframe. A value of <code>null</code> indicates
* that there is no interpolation, which is the same as linear interpolation.
*
* @return The optional interpolator for this Keyframe.
*/
public void setInterpolator(/*Time*/Interpolator interpolator) {
mInterpolator = interpolator;
}
/**
* Gets the type of keyframe. This information is used by ValueAnimator to determine the type of
* {@link TypeEvaluator} to use when calculating values between keyframes. The type is based
* on the type of Keyframe created.
*
* @return The type of the value stored in the Keyframe.
*/
public Class getType() {
return mValueType;
}
@Override
public abstract Keyframe clone();
/**
* This internal subclass is used for all types which are not int or float.
*/
static class ObjectKeyframe extends Keyframe {
/**
* The value of the animation at the time mFraction.
*/
Object mValue;
ObjectKeyframe(float fraction, Object value) {
mFraction = fraction;
mValue = value;
mHasValue = (value != null);
mValueType = mHasValue ? value.getClass() : Object.class;
}
public Object getValue() {
return mValue;
}
public void setValue(Object value) {
mValue = value;
mHasValue = (value != null);
}
@Override
public ObjectKeyframe clone() {
ObjectKeyframe kfClone = new ObjectKeyframe(getFraction(), mValue);
kfClone.setInterpolator(getInterpolator());
return kfClone;
}
}
/**
* Internal subclass used when the keyframe value is of type int.
*/
static class IntKeyframe extends Keyframe {
/**
* The value of the animation at the time mFraction.
*/
int mValue;
IntKeyframe(float fraction, int value) {
mFraction = fraction;
mValue = value;
mValueType = int.class;
mHasValue = true;
}
IntKeyframe(float fraction) {
mFraction = fraction;
mValueType = int.class;
}
public int getIntValue() {
return mValue;
}
public Object getValue() {
return mValue;
}
public void setValue(Object value) {
if (value != null && value.getClass() == Integer.class) {
mValue = ((Integer) value).intValue();
mHasValue = true;
}
}
@Override
public IntKeyframe clone() {
IntKeyframe kfClone = new IntKeyframe(getFraction(), mValue);
kfClone.setInterpolator(getInterpolator());
return kfClone;
}
}
/**
* Internal subclass used when the keyframe value is of type float.
*/
static class FloatKeyframe extends Keyframe {
/**
* The value of the animation at the time mFraction.
*/
float mValue;
FloatKeyframe(float fraction, float value) {
mFraction = fraction;
mValue = value;
mValueType = float.class;
mHasValue = true;
}
FloatKeyframe(float fraction) {
mFraction = fraction;
mValueType = float.class;
}
public float getFloatValue() {
return mValue;
}
public Object getValue() {
return mValue;
}
public void setValue(Object value) {
if (value != null && value.getClass() == Float.class) {
mValue = ((Float) value).floatValue();
mHasValue = true;
}
}
@Override
public FloatKeyframe clone() {
FloatKeyframe kfClone = new FloatKeyframe(getFraction(), mValue);
kfClone.setInterpolator(getInterpolator());
return kfClone;
}
}
}

View file

@ -0,0 +1,81 @@
package com.adins.mss.dao;
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_BANKACCOUNTOFBRANCH".
*/
public class BankAccountOfBranch {
/** Not-null value. */
@SerializedName("uuid_bankaccountofbranch")
private String uuid_bankaccountofbranch;
@SerializedName("bank_account_id")
private String bank_account_id;
@SerializedName("bank_account_no")
private String bank_account_no;
@SerializedName("bank_account_name")
private String bank_account_name;
@SerializedName("branch_code")
private String branch_code;
public BankAccountOfBranch() {
}
public BankAccountOfBranch(String uuid_bankaccountofbranch) {
this.uuid_bankaccountofbranch = uuid_bankaccountofbranch;
}
public BankAccountOfBranch(String uuid_bankaccountofbranch, String bank_account_id, String bank_account_no, String bank_account_name, String branch_code) {
this.uuid_bankaccountofbranch = uuid_bankaccountofbranch;
this.bank_account_id = bank_account_id;
this.bank_account_no = bank_account_no;
this.bank_account_name = bank_account_name;
this.branch_code = branch_code;
}
/** Not-null value. */
public String getUuid_bankaccountofbranch() {
return uuid_bankaccountofbranch;
}
/** Not-null value; ensure this value is available before it is saved to the database. */
public void setUuid_bankaccountofbranch(String uuid_bankaccountofbranch) {
this.uuid_bankaccountofbranch = uuid_bankaccountofbranch;
}
public String getBank_account_id() {
return bank_account_id;
}
public void setBank_account_id(String bank_account_id) {
this.bank_account_id = bank_account_id;
}
public String getBank_account_no() {
return bank_account_no;
}
public void setBank_account_no(String bank_account_no) {
this.bank_account_no = bank_account_no;
}
public String getBank_account_name() {
return bank_account_name;
}
public void setBank_account_name(String bank_account_name) {
this.bank_account_name = bank_account_name;
}
public String getBranch_code() {
return branch_code;
}
public void setBranch_code(String branch_code) {
this.branch_code = branch_code;
}
}

View file

@ -0,0 +1,6 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

View file

@ -0,0 +1,45 @@
package com.adins.mss.foundation.image;
import android.content.Context;
import android.widget.Toast;
import java.io.File;
public class FileCache {
private File cacheDir;
private Context context;
public FileCache(Context context) {
//Find the dir to save cached images
this.context = context;
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
cacheDir = new File(context.getExternalFilesDir(null), "TempImages");
else
cacheDir = context.getCacheDir();
if (!cacheDir.exists())
cacheDir.mkdirs();
}
public File getFile(String url) {
String filename = String.valueOf(url.hashCode());
return new File(cacheDir, filename);
}
public void clear() {
File[] files = cacheDir.listFiles();
if (files == null)
return;
boolean deleteResult;
for (File f : files){
deleteResult = f.delete();
if(!deleteResult){
Toast.makeText(context, "Failed to delete files", Toast.LENGTH_SHORT).show();
break;
}
}
}
}

View file

@ -0,0 +1,310 @@
package com.adins.mss.base.log;
import android.app.Activity;
import android.content.Context;
import com.adins.mss.base.GlobalData;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.Lookup;
import com.adins.mss.dao.PrintItem;
import com.adins.mss.dao.PrintResult;
import com.adins.mss.dao.QuestionSet;
import com.adins.mss.dao.TaskD;
import com.adins.mss.dao.TaskH;
import com.adins.mss.dao.User;
import com.adins.mss.foundation.db.dataaccess.LookupDataAccess;
import com.adins.mss.foundation.db.dataaccess.PrintItemDataAccess;
import com.adins.mss.foundation.db.dataaccess.QuestionSetDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.db.dataaccess.UserDataAccess;
import com.adins.mss.foundation.formatter.Formatter;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.questiongenerator.OptionAnswerBean;
import com.adins.mss.foundation.questiongenerator.QuestionBean;
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
public class Log {
public static final int SECOND = 1000;
public static final int MINUTE = 60 * SECOND;
public static final int HOUR = 60 * MINUTE;
public static final int DAY = 24 * HOUR;
public static final int IMAGE_ONLY = 1;
public static final int NON_IMAGE_ONLY = 2;
public static final int ALL_TASK = 3;
public static final String AT_LOV = "015";
public static final String AT_LOV_W_FILTER = "016";
private static final int MAXIMUM_SIZE_KEEP = 30;
private static final int MAXIMUM_DAYS_KEEP = 1 * DAY;
/* PRINT ITEM TYPE */
public static String PRINT_NO_ANSWER = "001";
public static String PRINT_ANSWER = "002";
//Glen 9 Aug 2014, new type : timestamp
public static String PRINT_TIMESTAMP = "004";
// bong Oct 28th, 2014 - adding from fif
public static String PRINT_LOGO = "005";
public static String PRINT_USER = "006";
public static String PRINT_LABEL_CENTER = "007";
public static String PRINT_LABEL_CENTER_BOLD = "008";
public static String PRINT_PRINTER_ID = "003";
private static List<TaskH> listTaskH;
private static List<TaskD> listTaskD;
private Context context;
private String userId;
public Log() {
}
public Log(Context context) {
this.context = context;
userId = GlobalData.getSharedGlobalData().getUser().getUuid_user();
if(userId == null){
ObscuredSharedPreferences sharedPref = ObscuredSharedPreferences.getPrefs(context,
"GlobalData", Context.MODE_PRIVATE);
userId = sharedPref.getString("UUID_USER", "");
User user = UserDataAccess.getOne(context,userId);
GlobalData.getSharedGlobalData().setUser(user);
}
}
public List<TaskH> getAllSentTask() {
listTaskH = TaskHDataAccess.getAllSentTask(context, userId);
int listSize = listTaskH.size();
List<TaskH> listTaskHDelete = new ArrayList<>();
if (listSize > 0) {
int flag = MAXIMUM_SIZE_KEEP;
switch (flag) {
case MAXIMUM_DAYS_KEEP:
Date sysdate = Tool.getSystemDateTime();
long batasDel = sysdate.getTime()
- MAXIMUM_DAYS_KEEP;
listTaskHDelete = TaskHDataAccess.getAllDeleteTask(context, userId, String.valueOf(batasDel));
TaskHDataAccess.deleteListWithRelation(context, listTaskHDelete);
break;
case MAXIMUM_SIZE_KEEP:
if (listSize > MAXIMUM_SIZE_KEEP) {
for (int i = MAXIMUM_SIZE_KEEP; i <= listSize; i++) {
listTaskHDelete.add(listTaskH.get(i));
}
TaskHDataAccess.deleteListWithRelation(context, listTaskHDelete);
}
break;
default:
break;
}
}
return TaskHDataAccess.getAllSentTask(context, userId);
}
public List<TaskH> getAllSentTaskWithLimited() {
listTaskH = TaskHDataAccess.getAllSentTask(context, userId);
int listSize = listTaskH.size();
List<TaskH> listTaskHDelete = new ArrayList<>();
if (listSize > 0) {
int MAXIMUM_DATA_KEEP = GlobalData.getSharedGlobalData().getMaxDataInLog();
if (MAXIMUM_DATA_KEEP != 0 && listSize > MAXIMUM_DATA_KEEP) {
for (int i = MAXIMUM_DATA_KEEP; i < listSize; i++) {
listTaskHDelete.add(listTaskH.get(i));
}
TaskHDataAccess
.deleteListWithRelation(context, listTaskHDelete);
}
}
listTaskH = TaskHDataAccess.getAllSentTask(context, userId);
return listTaskH;
}
/**
* This is used to get all task detail from a taskId
*
* @param taskId
* @param withImage - IMAGE_ONLY = 1, NON_IMAGE_ONLY = 2, ALL_TASK = 3
* @return
*/
public List<TaskD> getTaskD(String taskId, int withImage) {
return TaskDDataAccess.getAllByTaskId(context, userId, taskId, withImage);
}
/**
* Get question set of a taskId
*
* @param taskId
* @return
*/
public List<QuestionSet> getListQuestionSet(String taskId) {
TaskH taskH = TaskHDataAccess.getOneTaskHeader(context, taskId);
return QuestionSetDataAccess.getAllByFormVersion(context, taskH.getUuid_scheme(), taskH.getForm_version());
}
/**
* Close this activity
*
* @param activity
*/
public void close(Activity activity) {
activity.finish();
}
/**
* Refresh list of sent task
*/
public void doRefreshListSentTask() {
listTaskH = getAllSentTask();
}
public List<PrintResult> getReadyPrintItem(Context context, String taskId) {
TaskH taskH = TaskHDataAccess.getOneTaskHeader(context, taskId);
List<PrintItem> listPrintItem = PrintItemDataAccess.getAll(context, taskH.getScheme().getUuid_scheme());
List<QuestionSet> listQuestionSet = QuestionSetDataAccess.getAll(context, taskH.getScheme().getUuid_scheme());
List<TaskD> listTaskD = TaskDDataAccess.getAllByTaskId(context, userId, taskId, ALL_TASK);
List<PrintResult> listPrintResult = null;
List<QuestionBean> listQuestionBean = new ArrayList<>();
for (QuestionSet qs : listQuestionSet)
listQuestionBean.add((QuestionBean) qs);
this.matchAnswerToQuestion(listQuestionBean, listTaskD);
listPrintResult = checkNeedToPrint(listPrintItem, listQuestionBean, taskH);
listQuestionBean = loadSelectedOptionForQuestionBean(listQuestionBean);
if (listPrintResult == null || listQuestionBean == null) return Collections.emptyList();
this.matchPrintItemWithAnswer(listPrintResult, listQuestionBean);
return listPrintResult;
}
private List<PrintResult> checkNeedToPrint(List<PrintItem> listPrintItem,
List<QuestionBean> listQuestionBean, TaskH taskH) {
List<PrintResult> result = new ArrayList<>();
for (PrintItem printItem : listPrintItem) {
String qgid = printItem.getQuestion_group_id();
String qid = printItem.getQuestion_id();
boolean shouldSkipPrintItem = false;
String value = "";
for (QuestionBean qBean : listQuestionBean) {
if (qBean.getQuestion_group_id() == qgid && qBean.getQuestion_id() == qid) {
boolean isVisible = true;
value = qBean.getAnswer();
String relevant = qBean.getRelevant_question();
if (relevant != null && relevant.length() > 0) {
isVisible = Tool.isVisibleByRelevant(relevant, qBean, listQuestionBean);
}
shouldSkipPrintItem = isVisible;
break;
}
}
if (!shouldSkipPrintItem) {
PrintResult pr = new PrintResult();
pr.setValue(value);
pr.setLabel(printItem.getPrint_item_label());
pr.setUuid_task_h(taskH.getUuid_task_h());
pr.setPrint_type_id(printItem.getPrint_type_id());
result.add(pr);
}
}
return result;
}
private void matchAnswerToQuestion(List<QuestionBean> listQuestionBean,
List<TaskD> listTaskD) {
if (listQuestionBean == null || listTaskD == null)
return;
// make all question unvisible first
for (QuestionSet questionSet : listQuestionBean)
questionSet.setIs_visible(Global.FALSE_STRING);
for (TaskD taskD : listTaskD) {
String qgid = taskD.getQuestion_group_id();
String qid = taskD.getQuestion_id();
String textAnswer = taskD.getText_answer();
qLoop:
for (QuestionBean qb : listQuestionBean) {
if (qgid == qb.getQuestion_group_id() && qid == qb.getQuestion_id()) {
// make it visible
qb.setIs_visible(Global.TRUE_STRING);
String answerType = qb.getAnswer_type();
if (Tool.isOptions(answerType)) {
String optId;
if (qb.getTag() != null && qb.getTag().equalsIgnoreCase("JOB MH")) {
optId = taskD.getUuid_lookup();
} else {
optId = taskD.getOption_answer_id();
}
for (OptionAnswerBean optBean : qb.getOptionAnswers()) {
if (optId == optBean.getOption_id()) {
optBean.setSelected(true);
break qLoop;
}
}
qb.getSelectedOptionAnswers().add(new OptionAnswerBean("0", "", taskD.getLov()));
qb.setLovCode(taskD.getLov());
} else if (Tool.isImage(answerType)) {
byte[] imgAnswer = taskD.getImage();
qb.setImgAnswer(imgAnswer);
if(taskD.getImage_timestamp() != null)
qb.setImgTimestamp(taskD.getImage_timestamp());
break qLoop;
}
else {
qb.setAnswer(textAnswer);
break qLoop;
}
}
}
}
}
public List<QuestionBean> loadSelectedOptionForQuestionBean(List<QuestionBean> listQuestionBean) {
List<QuestionBean> loadedBeans = new ArrayList<>(listQuestionBean);
for (QuestionBean qb : loadedBeans) {
if (!Tool.isOptions(qb.getAnswer_type())) continue;
List<OptionAnswerBean> optAnsBean = new ArrayList<>();
OptionAnswerBean selectedOption = null;
String lookUpId = qb.getLookupId();
String flatLovCode = qb.getLovCode();
if (flatLovCode == null) continue;
String[] LovCodes = Tool.split(flatLovCode, Global.DELIMETER_DATA);
for (int i = 0; i < LovCodes.length; i++) {
String lovCode = LovCodes[i];
if (lookUpId != null && lovCode != null) {
Lookup lookup = LookupDataAccess.getOneByCode(context, lookUpId, lovCode);
selectedOption = new OptionAnswerBean(lookup);
selectedOption.setSelected(true);
optAnsBean.add(selectedOption);
}
}
qb.setSelectedOptionAnswers(optAnsBean);
}
return loadedBeans;
}
public void matchPrintItemWithAnswer(List<PrintResult> listPrintResult, List<QuestionBean> listQuestionBean) {
if (listPrintResult == null || listQuestionBean == null) return;
for (PrintResult printResult : listPrintResult) {
if (PRINT_ANSWER.equals(printResult.getPrint_type_id())) {
for (QuestionBean qb : listQuestionBean) {
if (qb.getQuestion_label() == printResult.getLabel()) {
printResult.setValue(qb.getAnswer());
break;
}
}
} else if (PRINT_TIMESTAMP.equals(printResult.getPrint_type_id())) {
Date date = new Date();
String dateString = Formatter.formatDate(date, "dd-MM-yyyy hh:mm");
printResult.setValue(dateString);
}
}
}
}

View file

@ -0,0 +1,75 @@
/*
* Copyright 2012 Kevin Gaudin
*
* 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 org.acra.collector;
import android.app.Application;
import android.content.Context;
import org.acra.util.BoundedLinkedList;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Collects the N last lines of a text stream. Use this collector if your
* application handles its own logging system.
*
* @author Kevin Gaudin
*/
class LogFileCollector {
/**
* Private constructor to prevent instantiation.
*/
private LogFileCollector() {
}
;
/**
* Reads the last lines of a custom log file. The file name is assumed as
* located in the {@link Application#getFilesDir()} directory if it does not
* contain any path separator.
*
* @param context
* @param fileName
* @param numberOfLines
* @return
* @throws IOException
*/
public static String collectLogFile(Context context, String fileName, int numberOfLines) throws IOException {
final BoundedLinkedList<String> resultBuffer = new BoundedLinkedList<String>(numberOfLines);
final BufferedReader reader;
if (fileName.contains("/")) {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)), 1024);
} else {
reader = new BufferedReader(new InputStreamReader(context.openFileInput(fileName)), 1024);
}
try {
String line = reader.readLine();
while (line != null) {
resultBuffer.add(line + "\n");
line = reader.readLine();
}
} finally {
CollectorUtil.safeClose(reader);
}
return resultBuffer.toString();
}
}