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,278 @@
package com.adins.mss.dao;
import android.database.Cursor;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
import de.greenrobot.dao.database.Database;
import de.greenrobot.dao.database.DatabaseStatement;
import com.adins.mss.dao.Lookup;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "MS_LOOKUP".
*/
public class LookupDao extends AbstractDao<Lookup, String> {
public static final String TABLENAME = "MS_LOOKUP";
/**
* Properties of entity Lookup.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Uuid_lookup = new Property(0, String.class, "uuid_lookup", true, "UUID_LOOKUP");
public final static Property Option_id = new Property(1, String.class, "option_id", false, "OPTION_ID");
public final static Property Code = new Property(2, String.class, "code", false, "CODE");
public final static Property Value = new Property(3, String.class, "value", false, "VALUE");
public final static Property Filter1 = new Property(4, String.class, "filter1", false, "FILTER1");
public final static Property Filter2 = new Property(5, String.class, "filter2", false, "FILTER2");
public final static Property Filter3 = new Property(6, String.class, "filter3", false, "FILTER3");
public final static Property Filter4 = new Property(7, String.class, "filter4", false, "FILTER4");
public final static Property Filter5 = new Property(8, String.class, "filter5", false, "FILTER5");
public final static Property Sequence = new Property(9, Integer.class, "sequence", false, "SEQUENCE");
public final static Property Usr_crt = new Property(10, String.class, "usr_crt", false, "USR_CRT");
public final static Property Dtm_crt = new Property(11, java.util.Date.class, "dtm_crt", false, "DTM_CRT");
public final static Property Usr_upd = new Property(12, String.class, "usr_upd", false, "USR_UPD");
public final static Property Dtm_upd = new Property(13, java.util.Date.class, "dtm_upd", false, "DTM_UPD");
public final static Property Uuid_question_set = new Property(14, String.class, "uuid_question_set", false, "UUID_QUESTION_SET");
public final static Property Lov_group = new Property(15, String.class, "lov_group", false, "LOV_GROUP");
public final static Property Is_active = new Property(16, String.class, "is_active", false, "IS_ACTIVE");
public final static Property Is_deleted = new Property(17, String.class, "is_deleted", false, "IS_DELETED");
public final static Property Flag_hardsync = new Property(18, String.class, "flag_hardsync", false, "FLAG_HARDSYNC");
};
public LookupDao(DaoConfig config) {
super(config);
}
public LookupDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"MS_LOOKUP\" (" + //
"\"UUID_LOOKUP\" TEXT PRIMARY KEY NOT NULL ," + // 0: uuid_lookup
"\"OPTION_ID\" TEXT," + // 1: option_id
"\"CODE\" TEXT," + // 2: code
"\"VALUE\" TEXT," + // 3: value
"\"FILTER1\" TEXT," + // 4: filter1
"\"FILTER2\" TEXT," + // 5: filter2
"\"FILTER3\" TEXT," + // 6: filter3
"\"FILTER4\" TEXT," + // 7: filter4
"\"FILTER5\" TEXT," + // 8: filter5
"\"SEQUENCE\" INTEGER," + // 9: sequence
"\"USR_CRT\" TEXT," + // 10: usr_crt
"\"DTM_CRT\" INTEGER," + // 11: dtm_crt
"\"USR_UPD\" TEXT," + // 12: usr_upd
"\"DTM_UPD\" INTEGER," + // 13: dtm_upd
"\"UUID_QUESTION_SET\" TEXT," + // 14: uuid_question_set
"\"LOV_GROUP\" TEXT," + // 15: lov_group
"\"IS_ACTIVE\" TEXT," + // 16: is_active
"\"IS_DELETED\" TEXT," + // 17: is_deleted
"\"FLAG_HARDSYNC\" TEXT);"); // 18: flag_hardsync
// Add Indexes
db.execSQL("CREATE INDEX " + constraint + "IDX_MS_LOOKUP_LOV_GROUP_FILTER1_FILTER2_FILTER3_FILTER4_FILTER5_IS_ACTIVE_IS_DELETED ON MS_LOOKUP" +
" (\"LOV_GROUP\",\"FILTER1\",\"FILTER2\",\"FILTER3\",\"FILTER4\",\"FILTER5\",\"IS_ACTIVE\",\"IS_DELETED\");");
db.execSQL("CREATE INDEX " + constraint + "IDX_MS_LOOKUP_CODE_LOV_GROUP_IS_ACTIVE_IS_DELETED ON MS_LOOKUP" +
" (\"CODE\",\"LOV_GROUP\",\"IS_ACTIVE\",\"IS_DELETED\");");
db.execSQL("CREATE INDEX " + constraint + "IDX_MS_LOOKUP_LOV_GROUP_FILTER1_FILTER2_FILTER3_FILTER4_IS_ACTIVE_IS_DELETED ON MS_LOOKUP" +
" (\"LOV_GROUP\",\"FILTER1\",\"FILTER2\",\"FILTER3\",\"FILTER4\",\"IS_ACTIVE\",\"IS_DELETED\");");
db.execSQL("CREATE INDEX " + constraint + "IDX_MS_LOOKUP_LOV_GROUP_FILTER1_FILTER2_FILTER3_IS_ACTIVE_IS_DELETED ON MS_LOOKUP" +
" (\"LOV_GROUP\",\"FILTER1\",\"FILTER2\",\"FILTER3\",\"IS_ACTIVE\",\"IS_DELETED\");");
db.execSQL("CREATE INDEX " + constraint + "IDX_MS_LOOKUP_LOV_GROUP_FILTER1_FILTER2_IS_ACTIVE_IS_DELETED ON MS_LOOKUP" +
" (\"LOV_GROUP\",\"FILTER1\",\"FILTER2\",\"IS_ACTIVE\",\"IS_DELETED\");");
db.execSQL("CREATE INDEX " + constraint + "IDX_MS_LOOKUP_LOV_GROUP_FILTER1_IS_ACTIVE_IS_DELETED ON MS_LOOKUP" +
" (\"LOV_GROUP\",\"FILTER1\",\"IS_ACTIVE\",\"IS_DELETED\");");
db.execSQL("CREATE INDEX " + constraint + "IDX_MS_LOOKUP_LOV_GROUP_IS_ACTIVE_IS_DELETED ON MS_LOOKUP" +
" (\"LOV_GROUP\",\"IS_ACTIVE\",\"IS_DELETED\");");
}
/** Drops the underlying database table. */
public static void dropTable(Database db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"MS_LOOKUP\"";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(DatabaseStatement stmt, Lookup entity) {
stmt.clearBindings();
stmt.bindString(1, entity.getUuid_lookup());
String option_id = entity.getOption_id();
if (option_id != null) {
stmt.bindString(2, option_id);
}
String code = entity.getCode();
if (code != null) {
stmt.bindString(3, code);
}
String value = entity.getValue();
if (value != null) {
stmt.bindString(4, value);
}
String filter1 = entity.getFilter1();
if (filter1 != null) {
stmt.bindString(5, filter1);
}
String filter2 = entity.getFilter2();
if (filter2 != null) {
stmt.bindString(6, filter2);
}
String filter3 = entity.getFilter3();
if (filter3 != null) {
stmt.bindString(7, filter3);
}
String filter4 = entity.getFilter4();
if (filter4 != null) {
stmt.bindString(8, filter4);
}
String filter5 = entity.getFilter5();
if (filter5 != null) {
stmt.bindString(9, filter5);
}
Integer sequence = entity.getSequence();
if (sequence != null) {
stmt.bindLong(10, sequence);
}
String usr_crt = entity.getUsr_crt();
if (usr_crt != null) {
stmt.bindString(11, usr_crt);
}
java.util.Date dtm_crt = entity.getDtm_crt();
if (dtm_crt != null) {
stmt.bindLong(12, dtm_crt.getTime());
}
String usr_upd = entity.getUsr_upd();
if (usr_upd != null) {
stmt.bindString(13, usr_upd);
}
java.util.Date dtm_upd = entity.getDtm_upd();
if (dtm_upd != null) {
stmt.bindLong(14, dtm_upd.getTime());
}
String uuid_question_set = entity.getUuid_question_set();
if (uuid_question_set != null) {
stmt.bindString(15, uuid_question_set);
}
String lov_group = entity.getLov_group();
if (lov_group != null) {
stmt.bindString(16, lov_group);
}
String is_active = entity.getIs_active();
if (is_active != null) {
stmt.bindString(17, is_active);
}
String is_deleted = entity.getIs_deleted();
if (is_deleted != null) {
stmt.bindString(18, is_deleted);
}
String flag_hardsync = entity.getFlag_hardsync();
if (flag_hardsync != null) {
stmt.bindString(19, flag_hardsync);
}
}
/** @inheritdoc */
@Override
public String readKey(Cursor cursor, int offset) {
return cursor.getString(offset + 0);
}
/** @inheritdoc */
@Override
public Lookup readEntity(Cursor cursor, int offset) {
Lookup entity = new Lookup( //
cursor.getString(offset + 0), // uuid_lookup
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // option_id
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // code
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // value
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // filter1
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // filter2
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // filter3
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // filter4
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // filter5
cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9), // sequence
cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // usr_crt
cursor.isNull(offset + 11) ? null : new java.util.Date(cursor.getLong(offset + 11)), // dtm_crt
cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // usr_upd
cursor.isNull(offset + 13) ? null : new java.util.Date(cursor.getLong(offset + 13)), // dtm_upd
cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // uuid_question_set
cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // lov_group
cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // is_active
cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // is_deleted
cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18) // flag_hardsync
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, Lookup entity, int offset) {
entity.setUuid_lookup(cursor.getString(offset + 0));
entity.setOption_id(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setValue(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setFilter1(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setFilter2(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
entity.setFilter3(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
entity.setFilter4(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
entity.setFilter5(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
entity.setSequence(cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9));
entity.setUsr_crt(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
entity.setDtm_crt(cursor.isNull(offset + 11) ? null : new java.util.Date(cursor.getLong(offset + 11)));
entity.setUsr_upd(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
entity.setDtm_upd(cursor.isNull(offset + 13) ? null : new java.util.Date(cursor.getLong(offset + 13)));
entity.setUuid_question_set(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
entity.setLov_group(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
entity.setIs_active(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
entity.setIs_deleted(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
entity.setFlag_hardsync(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
}
/** @inheritdoc */
@Override
protected String updateKeyAfterInsert(Lookup entity, long rowId) {
return entity.getUuid_lookup();
}
/** @inheritdoc */
@Override
public String getKey(Lookup entity) {
if(entity != null) {
return entity.getUuid_lookup();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
}

View file

@ -0,0 +1,53 @@
/*
* Copyright 2010 Emmanuel Astier & 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;
/**
* Defines the different user interaction modes for ACRA.
* <ul>
* <li>SILENT: No interaction, reports are sent silently and a "Force close"
* dialog terminates the app.</li>
* <li>TOAST: A simple Toast is triggered when the application crashes, the
* Force close dialog is not displayed.</li>
* <li>NOTIFICATION: A status bar notification is triggered when the application
* crashes, the Force close dialog is not displayed. When the user selects the
* notification, a dialog is displayed asking him if he is ok to send a report</li>
* </ul>
*/
public enum ReportingInteractionMode {
/**
* No interaction, reports are sent silently and a "Force close" dialog
* terminates the app.
*/
SILENT,
/**
* A status bar notification is triggered when the application crashes, the
* Force close dialog is not displayed. When the user selects the
* notification, a dialog is displayed asking him if he is ok to send a
* report.
*/
NOTIFICATION,
/**
* A simple Toast is triggered when the application crashes, the Force close
* dialog is not displayed.
*/
TOAST,
/**
* Direct dialog: a report confirmation dialog is displayed right after the crash.
* Will replace {@link #NOTIFICATION} mode.
*/
DIALOG
}

View file

@ -0,0 +1,299 @@
package com.adins.libs.nineoldandroids.view;
import android.view.View;
import android.view.animation.Interpolator;
import com.adins.libs.nineoldandroids.animation.Animator.AnimatorListener;
import java.lang.ref.WeakReference;
class ViewPropertyAnimatorICS extends ViewPropertyAnimator {
/**
* A value to be returned when the WeakReference holding the native implementation
* returns <code>null</code>
*/
private final static long RETURN_WHEN_NULL = -1L;
/**
* A WeakReference holding the native implementation of ViewPropertyAnimator
*/
private final WeakReference<android.view.ViewPropertyAnimator> mNative;
ViewPropertyAnimatorICS(View view) {
mNative = new WeakReference<android.view.ViewPropertyAnimator>(view.animate());
}
@Override
public ViewPropertyAnimator setDuration(long duration) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.setDuration(duration);
}
return this;
}
@Override
public long getDuration() {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
return n.getDuration();
}
return RETURN_WHEN_NULL;
}
@Override
public ViewPropertyAnimator setStartDelay(long startDelay) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.setStartDelay(startDelay);
}
return this;
}
@Override
public long getStartDelay() {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
return n.getStartDelay();
}
return RETURN_WHEN_NULL;
}
@Override
public ViewPropertyAnimator setInterpolator(Interpolator interpolator) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.setInterpolator(interpolator);
}
return this;
}
@Override
public ViewPropertyAnimator setListener(final AnimatorListener listener) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
if (listener == null) {
n.setListener(null);
} else {
n.setListener(new android.animation.Animator.AnimatorListener() {
@Override
public void onAnimationStart(android.animation.Animator animation) {
listener.onAnimationStart(null);
}
@Override
public void onAnimationRepeat(android.animation.Animator animation) {
listener.onAnimationRepeat(null);
}
@Override
public void onAnimationEnd(android.animation.Animator animation) {
listener.onAnimationEnd(null);
}
@Override
public void onAnimationCancel(android.animation.Animator animation) {
listener.onAnimationCancel(null);
}
});
}
}
return this;
}
@Override
public void start() {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.start();
}
}
@Override
public void cancel() {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.cancel();
}
}
@Override
public ViewPropertyAnimator x(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.x(value);
}
return this;
}
@Override
public ViewPropertyAnimator xBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.xBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator y(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.y(value);
}
return this;
}
@Override
public ViewPropertyAnimator yBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.yBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator rotation(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.rotation(value);
}
return this;
}
@Override
public ViewPropertyAnimator rotationBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.rotationBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator rotationX(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.rotationX(value);
}
return this;
}
@Override
public ViewPropertyAnimator rotationXBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.rotationXBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator rotationY(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.rotationY(value);
}
return this;
}
@Override
public ViewPropertyAnimator rotationYBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.rotationYBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator translationX(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.translationX(value);
}
return this;
}
@Override
public ViewPropertyAnimator translationXBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.translationXBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator translationY(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.translationY(value);
}
return this;
}
@Override
public ViewPropertyAnimator translationYBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.translationYBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator scaleX(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.scaleX(value);
}
return this;
}
@Override
public ViewPropertyAnimator scaleXBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.scaleXBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator scaleY(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.scaleY(value);
}
return this;
}
@Override
public ViewPropertyAnimator scaleYBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.scaleYBy(value);
}
return this;
}
@Override
public ViewPropertyAnimator alpha(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.alpha(value);
}
return this;
}
@Override
public ViewPropertyAnimator alphaBy(float value) {
android.view.ViewPropertyAnimator n = mNative.get();
if (n != null) {
n.alphaBy(value);
}
return this;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

View file

@ -0,0 +1,86 @@
/*
* Copyright 2013, Edmodo, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License.
* You may obtain a copy of the License in the LICENSE file, or at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package com.edmodo.cropper.cropwindow.handle;
import android.graphics.Rect;
import com.edmodo.cropper.cropwindow.edge.Edge;
import com.edmodo.cropper.util.AspectRatioUtil;
/**
* Handle helper class to handle horizontal handles (i.e. top and bottom
* handles).
*/
class HorizontalHandleHelper extends HandleHelper {
// Member Variables ////////////////////////////////////////////////////////
private Edge mEdge;
// Constructor /////////////////////////////////////////////////////////////
HorizontalHandleHelper(Edge edge) {
super(edge, null);
mEdge = edge;
}
// HandleHelper Methods ////////////////////////////////////////////////////
@Override
void updateCropWindow(float x,
float y,
float targetAspectRatio,
Rect imageRect,
float snapRadius) {
// Adjust this Edge accordingly.
mEdge.adjustCoordinate(x, y, imageRect, snapRadius, targetAspectRatio);
float left = Edge.LEFT.getCoordinate();
float top = Edge.TOP.getCoordinate();
float right = Edge.RIGHT.getCoordinate();
float bottom = Edge.BOTTOM.getCoordinate();
// After this Edge is moved, our crop window is now out of proportion.
final float targetWidth = AspectRatioUtil.calculateWidth(top, bottom, targetAspectRatio);
final float currentWidth = right - left;
// Adjust the crop window so that it maintains the given aspect ratio by
// moving the adjacent edges symmetrically in or out.
final float difference = targetWidth - currentWidth;
final float halfDifference = difference / 2;
left -= halfDifference;
right += halfDifference;
Edge.LEFT.setCoordinate(left);
Edge.RIGHT.setCoordinate(right);
// Check if we have gone out of bounds on the sides, and fix.
if (Edge.LEFT.isOutsideMargin(imageRect, snapRadius) && !mEdge.isNewRectangleOutOfBounds(Edge.LEFT,
imageRect,
targetAspectRatio)) {
final float offset = Edge.LEFT.snapToRect(imageRect);
Edge.RIGHT.offset(-offset);
mEdge.adjustCoordinate(targetAspectRatio);
}
if (Edge.RIGHT.isOutsideMargin(imageRect, snapRadius) && !mEdge.isNewRectangleOutOfBounds(Edge.RIGHT,
imageRect,
targetAspectRatio)) {
final float offset = Edge.RIGHT.snapToRect(imageRect);
Edge.LEFT.offset(-offset);
mEdge.adjustCoordinate(targetAspectRatio);
}
}
}

View file

@ -0,0 +1,562 @@
package com.adins.mss.base;
import android.Manifest;
import android.app.Activity;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Environment;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.TaskD;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import static com.services.NotificationThread.getNotificationIcon;
import static java.lang.Thread.NORM_PRIORITY;
class BackupFormat {
@SerializedName("taskH")
private TaskH taskH;
@SerializedName("taskDList")
private List<TaskD> taskDList;
public TaskH getTaskH() {
return taskH;
}
public void setTaskH(TaskH taskH) {
this.taskH = taskH;
}
public List<TaskD> getTaskDList() {
return taskDList;
}
public void setTaskDList(List<TaskD> taskDList) {
this.taskDList = taskDList;
}
}
public class Backup {
private final Context context;
private File dir;
private static final String ENCRYPTION_ALGORITHM = "AES/ECB/PKCS5Padding";
private static final String ENCRYPTION_KEY = "8]6eUcL'b4}xhqC~";
public static List<String> updatingTask = new ArrayList<>();
public Backup(Context context) {
this.context = context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
// Request permission if not granted
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
return;
}
}
PackageInfo pInfo;
String appName = "";
try {
pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
appName = pInfo.packageName+"."+BuildConfig.BUILD_TYPE+"/";
} catch (PackageManager.NameNotFoundException e) {
if(Global.IS_DEV)
e.printStackTrace();
}
String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MssLocal/" + appName + GlobalData.getSharedGlobalData().getUser().getLogin_id();
// String filePath = context.getExternalFilesDir(null) + "/MssLocal/" + appName + GlobalData.getSharedGlobalData().getUser().getLogin_id();
// String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath() + "/MssLocal/" + appName + GlobalData.getSharedGlobalData().getUser().getUuid_user();
this.dir = new File(filePath);
// Ensure the directory exists
if (!dir.exists()) {
dir.mkdirs();
}
// Debugging output to check the directory
Log.d("Backup", "External storage state: " + Environment.getExternalStorageState());
Log.d("Backup", "Directory path: " + dir.getAbsolutePath());
Log.d("Backup", "Directory exists: " + dir.exists());
Log.d("Backup", "Directory readable: " + dir.canRead());
Log.d("Backup", "Directory writable: " + dir.canWrite());
Log.d("Backup", "Available space: " + dir.getFreeSpace());
}
private void showNotifBackup(String aggrNo, String content) {
String title;
if(!aggrNo.isEmpty()) {
title = "Task Backup - " + aggrNo;
} else {
title = "Task Backup";
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "backup_channel");
builder.setSmallIcon(getNotificationIcon());
builder.setContentTitle(title);
builder.setContentText(content);
builder.setPriority(NORM_PRIORITY);
NotificationCompat.BigTextStyle inboxStyle =
new NotificationCompat.BigTextStyle();
// Sets a title for the Inbox in expanded layoutInflater
inboxStyle.setBigContentTitle(title);
inboxStyle.bigText(content);
inboxStyle.setSummaryText(context.getString(com.adins.mss.base.R.string.click_to_open));
builder.setDefaults(android.app.Notification.DEFAULT_ALL);
builder.setStyle(inboxStyle);
builder.setAutoCancel(true);
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
String channelId = "backup_channel";
NotificationChannel channel = new NotificationChannel(
channelId,
title,
NotificationManager.IMPORTANCE_HIGH);
mNotificationManager.createNotificationChannel(channel);
builder.setChannelId(channelId);
}
mNotificationManager.notify(1, builder.build());
}
public byte[] encrypt(String backupData) {
try {
SecretKey secretKey = getSecretKey();
Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
byte[] ciphertextBytes = backupData.getBytes("UTF-8");
return cipher.doFinal(ciphertextBytes);
} catch (Exception e) {
e.printStackTrace();
return null;
} catch (Error err) {
err.printStackTrace();
return null;
}
}
public String decrypt(InputStream encryptedStream) {
try {
SecretKey secretKey = getSecretKey();
Cipher cipher = Cipher.getInstance(ENCRYPTION_ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, secretKey);
CipherInputStream cipherInputStream = new CipherInputStream(encryptedStream, cipher);
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = cipherInputStream.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
return new String(output.toByteArray(), "UTF-8");
} catch (Exception e) {
e.printStackTrace();
return null;
} catch (Error err) {
err.printStackTrace();
return null;
}
}
private SecretKey getSecretKey() throws NoSuchAlgorithmException {
byte[] keyBytes = ENCRYPTION_KEY.getBytes();
SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, ENCRYPTION_ALGORITHM);
return secretKeySpec;
}
public BackupFormat getCurrentLocal(String uuidTaskH) {
if (dir.exists()) {
try {
File backupData = new File(dir, uuidTaskH);
FileInputStream inputStream = new FileInputStream(backupData);
String jsonBackup = decrypt(inputStream);
if (jsonBackup != null) {
Type type = new TypeToken<BackupFormat>() {}.getType();
return new Gson().fromJson(jsonBackup, type);
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
} catch (Error err){
err.printStackTrace();
return null;
}
} else {
return null;
}
}
public void removeTask(List<TaskH> taskHList) {
if(null != taskHList && taskHList.size() > 0) {
new RemoveTask(taskHList).execute();
}
}
private int removeBackup(List<TaskH> taskHList, int attempt) {
int deletedCount = 0;
if (taskHList.size() > 0 && attempt <= 10) {
List<TaskH> tempTaskH = new ArrayList<>(taskHList);
for (TaskH taskH : tempTaskH) {
File file = new File(dir, taskH.getTask_id());
if (!updatingTask.contains(taskH.getUuid_task_h())) {
if (file.exists()) {
if (file.delete()) {
taskHList.remove(taskH);
deletedCount++;
} else{
taskHList.remove(taskH);
}
} else {
taskHList.remove(taskH);
}
}
}
if (taskHList.size() > 0) {
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
deletedCount += removeBackup(taskHList, attempt + 1);
}
}
return deletedCount;
}
private class RemoveTask extends AsyncTask<Void, Void, Integer> {
List<TaskH> taskHList;
private RemoveTask(List<TaskH> taskHList) {
this.taskHList = taskHList;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
if (taskHList.size() == 1) {
showNotifBackup(taskHList.get(0).getTask_id(), context.getString(R.string.delete_backup_progress));
} else if (taskHList.size() > 1) {
showNotifBackup("", context.getString(R.string.delete_backup_progress));
}
}
@Override
protected Integer doInBackground(Void... voids) {
try {
return removeBackup(new ArrayList<>(taskHList), 1);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
@Override
protected void onPostExecute(Integer integer) {
super.onPostExecute(integer);
if(integer > 0) {
if(taskHList.size() == 1) {
showNotifBackup(taskHList.get(0).getTask_id(), context.getString(R.string.delete_backup_success));
} else if(taskHList.size() > 1) {
if(taskHList.size() == integer) {
showNotifBackup("", context.getString(R.string.delete_backup_success));
} else {
showNotifBackup("", context.getString(R.string.delete_backup_half_failed));
}
}
} else {
if(taskHList.size() == 1) {
showNotifBackup(taskHList.get(0).getTask_id(), context.getString(R.string.delete_backup_failed));
} else if(taskHList.size() > 1) {
showNotifBackup("", context.getString(R.string.delete_backup_failed));
}
}
}
}
public void performBackup(TaskH taskH) {
if(Thread.currentThread() != Looper.getMainLooper().getThread()) {
//called from non main thread
if (null != taskH) {
performBackups(taskH);
}
} else {
//called from main thread
if (null != taskH) {
new PerformBackupTask(taskH).execute();
}
}
}
private void performBackups(TaskH taskH) {
updatingTask.add(taskH.getUuid_task_h());
showNotifBackup(taskH.getTask_id(), context.getString(R.string.update_backup_progress));
BackupFormat backupFormat = new BackupFormat();
boolean isSuccess = false;
try {
List<TaskD> taskDList = TaskDDataAccess.getListByTaskH(context, taskH.getUuid_task_h());
backupFormat.setTaskH(taskH);
backupFormat.setTaskDList(taskDList);
Gson gsonBackupFormat = new Gson();
byte[] encryptedJson = encrypt(gsonBackupFormat.toJson(backupFormat));
FileOutputStream outputStream = null;
try {
if(!dir.exists()) {
dir.mkdirs();
}
long requiredSpace = encryptedJson.length;
long availableSpace = dir.getFreeSpace();
if (requiredSpace < availableSpace) {
File file = new File(dir, taskH.getTask_id());
outputStream = new FileOutputStream(file);
outputStream.write(encryptedJson);
outputStream.close();
isSuccess = true;
}
} catch (IOException e) {
e.printStackTrace();
isSuccess = false;
} finally {
assert outputStream != null;
outputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
isSuccess = false;
}
if(isSuccess) {
showNotifBackup(taskH.getTask_id(), context.getString(R.string.update_backup_success));
} else {
showNotifBackup(taskH.getTask_id(), context.getString(R.string.update_backup_failed));
}
updatingTask.remove(taskH.getUuid_task_h());
}
private class PerformBackupTask extends AsyncTask<Void, Void, Boolean> {
BackupFormat backupFormat;
ProgressDialog progressDialog;
TaskH taskH;
private PerformBackupTask(TaskH taskH) {
this.taskH = taskH;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
try {
progressDialog = ProgressDialog.show(context,
"", context.getString(R.string.progressWait), true);
} catch (Exception e) {
e.printStackTrace();
}
updatingTask.add(taskH.getUuid_task_h());
showNotifBackup(taskH.getTask_id(), context.getString(R.string.update_backup_progress));
backupFormat = new BackupFormat();
}
@Override
protected Boolean doInBackground(Void... voids) {
if(!dir.exists()) {
dir.mkdirs();
}
backupFormat = new BackupFormat();
try {
List<TaskD> taskDList = TaskDDataAccess.getListByTaskH(context, taskH.getUuid_task_h());
backupFormat.setTaskH(taskH);
backupFormat.setTaskDList(taskDList);
Gson gsonBackupFormat = new Gson();
byte[] encryptedJson = encrypt(gsonBackupFormat.toJson(backupFormat));
FileOutputStream outputStream = null;
try {
long requiredSpace = encryptedJson.length;
long availableSpace = dir.getFreeSpace();
if (requiredSpace > availableSpace) {
return false;
}
File file = new File(dir, taskH.getTask_id());
outputStream = new FileOutputStream(file);
outputStream.write(encryptedJson);
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
assert outputStream != null;
outputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
if (null != progressDialog && progressDialog.isShowing()){
try {
progressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
updatingTask.remove(taskH.getUuid_task_h());
if(aBoolean) {
showNotifBackup(taskH.getTask_id(), context.getString(R.string.update_backup_success));
} else {
showNotifBackup(taskH.getTask_id(), context.getString(R.string.update_backup_failed));
}
}
}
public void performRestore() {
RetrieveBackupTask retrieveBackup = new RetrieveBackupTask();
retrieveBackup.execute();
}
private class RetrieveBackupTask extends AsyncTask<Void, Void, Integer> {
ProgressDialog progressDialog;
BackupFormat backupFormat;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(context,
"", context.getString(R.string.progressWait), true);
showNotifBackup("", context.getString(R.string.restore_backup_progress));
}
@Override
protected Integer doInBackground(Void... voids) {
String uuidTaskHList[] = dir.list();
int restoredTask = 0;
if(null != uuidTaskHList && uuidTaskHList.length > 0) {
for (int i = 0; i < uuidTaskHList.length; i++) {
backupFormat = getCurrentLocal(uuidTaskHList[i]);
if (backupFormat == null) {
continue;
}
try {
TaskHDataAccess.addOrReplace(context, backupFormat.getTaskH());
TaskDDataAccess.addOrReplace(context, backupFormat.getTaskDList());
restoredTask++;
} catch (Exception e) {
e.printStackTrace();
}
}
}
return restoredTask;
}
@Override
protected void onPostExecute(Integer integer) {
super.onPostExecute(integer);
if (null != progressDialog && progressDialog.isShowing()){
try {
progressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
if(integer == 0) {
showNotifBackup("", context.getString(R.string.restore_backup_failed));
} else {
showNotifBackup("", context.getString(R.string.restore_backup_success) + integer);
}
}
}
}

View file

@ -0,0 +1,60 @@
package com.adins.mss.base.ktpValidation;
import com.adins.mss.foundation.http.MssResponseType;
import com.google.gson.annotations.SerializedName;
import java.util.Map;
public class JsonResponseKtpValidation extends MssResponseType {
@SerializedName("result")
public String result;
@SerializedName("message")
public String message;
@SerializedName("custName")
public String custName;
@SerializedName("custAddr")
public String custAddr;
@SerializedName("mapValue")
public Map<String, Object> mapValue;
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getCustName() {
return custName;
}
public void setCustName(String custName) {
this.custName = custName;
}
public String getCustAddr() {
return custAddr;
}
public void setCustAddr(String custAddr) {
this.custAddr = custAddr;
}
public Map<String, Object> getMapValue() {
return mapValue;
}
public void setMapValue(Map<String, Object> mapValue) {
this.mapValue = mapValue;
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/crop__tile"
android:tileMode="repeat" />