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,191 @@
package com.adins.mss.foundation.security;
import android.annotation.TargetApi;
import android.os.Build;
import android.text.format.DateFormat;
import com.adins.mss.base.crashlytics.FireCrash;
import org.acra.ACRA;
import org.bouncycastle.crypto.InvalidCipherTextException;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.util.encoders.Base64;
import org.bouncycastle.util.encoders.Hex;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Calendar;
//import net.rim.device.api.util.Arrays;
public class SAKFormatter {
/**
* Static method to decipher a string ciphered with SAKFormatter
*
* @param receivedData SAK ciphered string to be deciphered
* @return SAK deciphered string
*/
public static String decipherData(String receivedData) {
String result = null;
AESKeyGenerator AESKeygen = new AESKeyGenerator();
if (receivedData != null && receivedData.length() > 0) {
// Decoding Base64 BouncyCrypto menjadi Hex Value
byte[] istr = decodebase64(receivedData);
// Parser byte format dalam Hex Value
// SHA1Hex + CipherDataHex + AESKeyHex
byte[] SHA1ByteHex = new byte[40];
byte[] AESKeyByteHex = new byte[64];
int datasize = istr.length - (40 + 64);
byte[] cipherdataByteHex = new byte[datasize];
if (istr.length > 40) {
System.arraycopy(istr, 0, SHA1ByteHex, 0, SHA1ByteHex.length);
System.arraycopy(istr, datasize + 40, AESKeyByteHex, 0,
AESKeyByteHex.length);
System.arraycopy(istr, 40, cipherdataByteHex, 0,
cipherdataByteHex.length);
}
// Decoding hex dari semua HexValue
byte[] AESKeyOri = Hex.decode(AESKeyByteHex);
byte[] cipherdata = Hex.decode(cipherdataByteHex);
// process Decrypt AES256
AESManager Aes_Mgr = new AESManager();
KeyParameter AesKey256 = AESKeygen.generateNewAESKey(AESKeyOri);
try {
byte[] dec = Aes_Mgr.decryptAES256(cipherdata, AesKey256);
result = new String(dec);
// if (Global.IS_DEV) System.out.println("hasil:" + result);
} catch (InvalidCipherTextException e) {
e.printStackTrace();
}
boolean IsSha1 = isValidSha1(SHA1ByteHex, result);
if (IsSha1) {
return result;
} else {
ACRA.getErrorReporter().putCustomData("dataSources", receivedData);
ACRA.getErrorReporter().putCustomData("errorDecryptData", result);
ACRA.getErrorReporter().putCustomData("errorDecryptDataTime", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
ACRA.getErrorReporter().handleSilentException(new Exception("Error: This Data been Hijacked !!!, kena exception saat Decrypt Data : " + result));
return "Error: This Data been Hijacked !!!";
}
}
return result;
}
/**
* @param sendingData
* @return
*/
public static byte[] cipherData(String sendingData) {
byte[] result = null;
SHA1KeyGenerator shakeygen = new SHA1KeyGenerator();
byte[] sha1keybyte = null;
byte[] sha1key = null;
AESKeyGenerator aeskeygen = new AESKeyGenerator();
byte[] seeds = aeskeygen.generateNewSeeds();
// byte[]seed64 = Hex.decode("b4242668e4862eebe34fd7f97d0c93b59cf66d1a0a42b6ff2812de315134d4f2");
// if (Global.IS_DEV) System.out.println(new String(seed64));
// byte[] seeds = seed64;
KeyParameter aesKey256 = aeskeygen.generateNewAESKey(seeds);
AESManager aesmg = new AESManager();
// if (Global.IS_DEV) System.out.println(SendingData);
try {
// if (Global.IS_DEV) System.out.println("2."+SendingData);
byte[] cipher = aesmg.encryptAES256(sendingData.getBytes(), aesKey256);
byte[] hexcipherbyte = Hex.encode(cipher);
byte[] decryptcipher = aesmg.decryptAES256(cipher, aesKey256);
// if (Global.IS_DEV) System.out.println("deCipher: " + new String(decryptcipher));
String ciphertext = new String(decryptcipher);
sha1keybyte = ciphertext.getBytes();
sha1key = shakeygen.generateSHA1(sha1keybyte);
String datatosend = new String(Hex.encode(sha1key))
+ new String(hexcipherbyte) + new String(Hex.encode(seeds));
byte[] senddataenc = decodebase64(datatosend);
byte[] backdecode = encodebase64(senddataenc);
result = encodebase64(backdecode);
// if (Global.IS_DEV) System.out.println("hasiL:"+new String(result));
} catch (InvalidCipherTextException e) {
e.printStackTrace();
}
return result;
}
public static byte[] encodebase64(byte[] datatoencoded) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
Base64.encode(datatoencoded, 0, datatoencoded.length, out);
} catch (IOException e) {
}
byte[] base64bytes = out.toByteArray();
return base64bytes;
}
//Glen new return type
public static String encodebase64ToString(byte[] datatoencoded) {
byte[] base64bytes = encodebase64(datatoencoded);
String result = new String(base64bytes);
return result;
}
public static byte[] decodebase64(String data) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
Base64.decode(data, out);
} catch (IOException e) {
}
byte[] base64bytes = out.toByteArray();
return base64bytes;
}
//Glen new param
public static byte[] decodebase64(byte[] data) {
byte[] result = null;
try {
result = Base64.decode(data);
} catch (Exception e) {
FireCrash.log(e);
}
return result;
}
public static boolean isValidSha1(byte[] Sha1HexSource, String SourceSha1) {
boolean result = false;
if(SourceSha1 == null)
return result;
byte[] SourceByte = SourceSha1.getBytes(Charset.forName("UTF-8"));
SHA1KeyGenerator shakeygen = new SHA1KeyGenerator();
byte[] SourceSha1Byte = shakeygen.generateSHA1(SourceByte);
byte[] SourceSha1HexByte = Hex.encode(SourceSha1Byte);
if (Sha1HexSource.length != SourceSha1HexByte.length)
return false;
if (new String(Sha1HexSource).equals(new String(SourceSha1HexByte, Charset.forName("UTF-8")))) {
result = true;
}
return result;
}
}

View file

@ -0,0 +1,38 @@
<?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="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:contentPadding="5dp"
app:cardElevation="5dp"
android:layout_margin="3dp"
app:cardBackgroundColor="@color/fontColorWhite">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_pdf"
android:drawablePadding="5dp" />
<TextView
android:id="@+id/txtDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Desc"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_notes"
android:drawablePadding="5dp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text_spin"
android:singleLine="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:ellipsize="marquee"
android:paddingLeft="50dp"
android:paddingStart="50dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
android:textColor="@color/gradient_end" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -0,0 +1,46 @@
package com.adins.mss.foundation.config;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* @author glen.iglesias
* ConfigFileReader is used to read *.properties file in asset and return Properties object
* <p>NOTE: it only has one static method. Consider refactoring to combine with other useful method
*/
public class ConfigFileReader {
public ConfigFileReader() {
}
/**
* @param context Context of the requested properties file. Use caller's context is the default method.
* @param name Name of the file, without the .properties file type. Example, use "application" if the file name is "application.properties"
* @return Properties object if file successfully read and retrieved, or <b>null</b> if failed
*/
public static Properties propertiesFromFile(Context context, String name) {
Resources resources = context.getResources();
AssetManager assetManager = resources.getAssets();
String fileFullname = name + ".properties";
try(InputStream inputStream = assetManager.open(fileFullname)) {
Properties properties = new Properties();
properties.load(inputStream);
return properties;
} catch (IOException e) {
System.err.println("Failed to open microlog property file");
e.printStackTrace();
}
return null;
}
}

View file

@ -0,0 +1,24 @@
package com.adins.mss.svy.models;
import com.adins.mss.foundation.http.MssRequestType;
import com.google.gson.annotations.SerializedName;
public class JsonGetVerificationActionRequest extends MssRequestType {
/** Property uuid_task_h */
@SerializedName("uuid_task_h")
public String uuid_task_h;
/**
* Gets the uuid_task_h
*/
public String getUuid_task_h() {
return this.uuid_task_h;
}
/**
* Sets the uuid_task_h
*/
public void setUuid_task_h(String value) {
this.uuid_task_h = value;
}
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="2dp" />
<solid android:color="@color/btn_unpress_color" />
</shape>

View file

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:visibility="visible"
android:id="@+id/checkOrderLayout">
<ScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentTop="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:gravity="center_horizontal"
android:id="@+id/searchBy">
<TextView
android:text="@string/lblSearchBy"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000000"
android:layout_marginTop="37dp"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"/>
<Spinner
android:id="@+id/cbSearchBy"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:entries="@array/cbSearcrBy" />
</LinearLayout>
<LinearLayout
android:id="@+id/byDate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
android:gravity="center_horizontal" >
<TextView
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:text="@string/lblStartDate"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000" />
<EditText android:hint="@string/requiredField"
android:id="@+id/txtStartDate"
android:editable="false"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10" />
<TextView
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:text="@string/lblEndDate"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"/>
<EditText android:hint="@string/requiredField"
android:id="@+id/txtEndDate"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:editable="false" />
</LinearLayout>
<LinearLayout
android:id="@+id/byNoOrder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="invisible"
android:gravity="center_horizontal" >
<TextView
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:text="@string/lblNomorOrder"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#000000"/>
<EditText android:id="@+id/txtNomorOrder"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:hint="@string/requiredField" android:maxLength="12"
android:singleLine="true"
android:inputType="number"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:id="@+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:layout_below="@+id/byNoOrder" >
<View android:layout_width="fill_parent"
android:layout_height="20dp"
android:background="@android:color/transparent"/>
<Button
android:id="@+id/btnSearchOrder"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:ems="10"
android:layout_weight="1"
android:text="@string/btnSearchOrder"
android:textColor="#ffffff"
android:layout_marginBottom="37dp">
</Button>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>

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="400" />
</set>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="14dp"
android:height="14dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/gradient_end"
android:pathData="M17,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,7l-4,-4zM12,19c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3zM15,9L5,9L5,5h10v4z"/>
</vector>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:startColor="#8e44ad"
android:endColor="#8e44ad"
android:angle="270" />
<corners
android:radius="0dp" />
<!-- <padding -->
<!-- android:left="10dp" -->
<!-- android:top="10dp" -->
<!-- android:right="10dp" -->
<!-- android:bottom="10dp" /> -->
</shape>
</item>
</selector>

View file

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:contentPadding="7dp"
app:cardElevation="5dp"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
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/lblAccountName"
android:textAppearance="?android:attr/textAppearanceSmall" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_margin="5dp" >
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/spinnerAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:background="@drawable/dropdown_background"
android:padding="5dp"
android:layout_gravity="center_vertical"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_expand_more_24dp"
android:layout_alignRight="@+id/spinnerAccount"
android:layout_alignBottom="@+id/spinnerAccount"
android:layout_alignTop="@+id/spinnerAccount"
android:layout_marginRight="10dp"
android:tint="@color/gradient_end"
android:layout_gravity="center_vertical"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lblProduct"
android:textAppearance="?android:attr/textAppearanceSmall"
android:paddingTop="5dp"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_margin="5dp">
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/spinnerProduct"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:background="@drawable/dropdown_background"
android:padding="5dp"
android:layout_gravity="center_vertical"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_expand_more_24dp"
android:layout_alignRight="@+id/spinnerProduct"
android:layout_alignBottom="@+id/spinnerProduct"
android:layout_alignTop="@+id/spinnerProduct"
android:layout_marginRight="10dp"
android:tint="@color/gradient_end"
android:layout_gravity="center_vertical"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lblStatus"
android:textAppearance="?android:attr/textAppearanceSmall"
android:paddingTop="5dp"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_margin="5dp">
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/spinnerStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:spinnerMode="dropdown"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:background="@drawable/dropdown_background"
android:padding="5dp"
android:layout_gravity="center_vertical"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_expand_more_24dp"
android:layout_alignRight="@+id/spinnerStatus"
android:layout_alignBottom="@+id/spinnerStatus"
android:layout_alignTop="@+id/spinnerStatus"
android:layout_marginRight="10dp"
android:tint="@color/gradient_end"
android:layout_gravity="center_vertical"/>
</RelativeLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</ScrollView>
<Button
android:id="@+id/btnSearch"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="5dp"
android:background="@drawable/button_background"
android:text="@string/btnSearch"
android:textColor="@color/fontColorWhite"
android:layout_alignParentBottom="true"/>
</RelativeLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B