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,270 @@
package com.adins.mss.foundation.image;
//Class in android.util.Base64 since: API Level 8
/**
* A Base64 encoder/decoder.
* <p>
* <p>
* This class is used to encode and decode data in Base64 format as described in
* RFC 1521.
* <p>
* <p>
* Project home page: <a
* href="http://www.source-code.biz/base64coder/java/">www.
* source-code.biz/base64coder/java</a><br>
* Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland<br>
* Multi-licensed: EPL / LGPL / AL / BSD.
*/
public class Base64 {
// The line separator string of the operating system.
private static final String systemLineSeparator = System.getProperty("line.separator");
// Mapping table from 6-bit nibbles to Base64 characters.
private static char[] map1 = new char[64];
// Mapping table from Base64 characters to 6-bit nibbles.
private static byte[] map2 = new byte[128];
static {
int i = 0;
for (char c = 'A'; c <= 'Z'; c++)
map1[i++] = c;
for (char c = 'a'; c <= 'z'; c++)
map1[i++] = c;
for (char c = '0'; c <= '9'; c++)
map1[i++] = c;
map1[i++] = '+';
map1[i++] = '/';
}
static {
for (int i = 0; i < map2.length; i++)
map2[i] = -1;
for (int i = 0; i < 64; i++)
map2[map1[i]] = (byte) i;
}
// Dummy constructor.
private Base64() {
}
/**
* Encodes a string into Base64 format. No blanks or line breaks are
* inserted.
*
* @param s A String to be encoded.
* @return A String containing the Base64 encoded data.
*/
public static String encodeString(String s) {
return new String(encode(s.getBytes()));
}
/**
* Encodes a byte array into Base 64 format and breaks the output into lines
* of 76 characters. This method is compatible with
* <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
*
* @param in An array containing the data bytes to be encoded.
* @return A String containing the Base64 encoded data, broken into lines.
*/
public static String encodeLines(byte[] in) {
return encodeLines(in, 0, in.length, 76, systemLineSeparator);
}
/**
* Encodes a byte array into Base 64 format and breaks the output into
* lines.
*
* @param in An array containing the data bytes to be encoded.
* @param iOff Offset of the first byte in <code>in</code> to be processed.
* @param iLen Number of bytes to be processed in <code>in</code>, starting
* at <code>iOff</code>.
* @param lineLen Line length for the output data. Should be a multiple of 4.
* @param lineSeparator The line separator to be used to separate the output lines.
* @return A String containing the Base64 encoded data, broken into lines.
*/
public static String encodeLines(byte[] in, int iOff, int iLen,
int lineLen, String lineSeparator) {
int blockLen = (lineLen * 3) / 4;
if (blockLen <= 0)
throw new IllegalArgumentException();
int lines = (iLen + blockLen - 1) / blockLen;
int bufLen = ((iLen + 2) / 3) * 4 + lines * lineSeparator.length();
StringBuilder buf = new StringBuilder(bufLen);
int ip = 0;
while (ip < iLen) {
int l = Math.min(iLen - ip, blockLen);
buf.append(encode(in, iOff + ip, l));
buf.append(lineSeparator);
ip += l;
}
return buf.toString();
}
/**
* Encodes a byte array into Base64 format. No blanks or line breaks are
* inserted in the output.
*
* @param in An array containing the data bytes to be encoded.
* @return A character array containing the Base64 encoded data.
*/
public static char[] encode(byte[] in) {
return encode(in, 0, in.length);
}
/**
* Encodes a byte array into Base64 format. No blanks or line breaks are
* inserted in the output.
*
* @param in An array containing the data bytes to be encoded.
* @param iLen Number of bytes to process in <code>in</code>.
* @return A character array containing the Base64 encoded data.
*/
public static char[] encode(byte[] in, int iLen) {
return encode(in, 0, iLen);
}
/**
* Encodes a byte array into Base64 format. No blanks or line breaks are
* inserted in the output.
*
* @param in An array containing the data bytes to be encoded.
* @param iOff Offset of the first byte in <code>in</code> to be processed.
* @param iLen Number of bytes to process in <code>in</code>, starting at
* <code>iOff</code>.
* @return A character array containing the Base64 encoded data.
*/
public static char[] encode(byte[] in, int iOff, int iLen) {
int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
int oLen = ((iLen + 2) / 3) * 4; // output length including padding
char[] out = new char[oLen];
int ip = iOff;
int iEnd = iOff + iLen;
int op = 0;
while (ip < iEnd) {
int i0 = in[ip++] & 0xff;
int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
int o0 = i0 >>> 2;
int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
int o3 = i2 & 0x3F;
out[op++] = map1[o0];
out[op++] = map1[o1];
out[op] = op < oDataLen ? map1[o2] : '=';
op++;
out[op] = op < oDataLen ? map1[o3] : '=';
op++;
}
return out;
}
/**
* Decodes a string from Base64 format. No blanks or line breaks are allowed
* within the Base64 encoded input data.
*
* @param s A Base64 String to be decoded.
* @return A String containing the decoded data.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static String decodeString(String s) {
return new String(decode(s));
}
/**
* Decodes a byte array from Base64 format and ignores line separators, tabs
* and blanks. CR, LF, Tab and Space characters are ignored in the input
* data. This method is compatible with
* <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
*
* @param s A Base64 String to be decoded.
* @return An array containing the decoded data bytes.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static byte[] decodeLines(String s) {
char[] buf = new char[s.length()];
int p = 0;
for (int ip = 0; ip < s.length(); ip++) {
char c = s.charAt(ip);
if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
buf[p++] = c;
}
return decode(buf, 0, p);
}
/**
* Decodes a byte array from Base64 format. No blanks or line breaks are
* allowed within the Base64 encoded input data.
*
* @param s A Base64 String to be decoded.
* @return An array containing the decoded data bytes.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static byte[] decode(String s) {
return decode(s.toCharArray());
}
/**
* Decodes a byte array from Base64 format. No blanks or line breaks are
* allowed within the Base64 encoded input data.
*
* @param in A character array containing the Base64 encoded data.
* @return An array containing the decoded data bytes.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static byte[] decode(char[] in) {
return decode(in, 0, in.length);
}
/**
* Decodes a byte array from Base64 format. No blanks or line breaks are
* allowed within the Base64 encoded input data.
*
* @param in A character array containing the Base64 encoded data.
* @param iOff Offset of the first character in <code>in</code> to be
* processed.
* @param iLen Number of characters to process in <code>in</code>, starting
* at <code>iOff</code>.
* @return An array containing the decoded data bytes.
* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
*/
public static byte[] decode(char[] in, int iOff, int iLen) {
if (iLen % 4 != 0)
throw new IllegalArgumentException(
"Length of Base64 encoded input string is not a multiple of 4.");
while (iLen > 0 && in[iOff + iLen - 1] == '=')
iLen--;
int oLen = (iLen * 3) / 4;
byte[] out = new byte[oLen];
int ip = iOff;
int iEnd = iOff + iLen;
int op = 0;
while (ip < iEnd) {
int i0 = in[ip++];
int i1 = in[ip++];
int i2 = ip < iEnd ? in[ip++] : 'A';
int i3 = ip < iEnd ? in[ip++] : 'A';
if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
throw new IllegalArgumentException(
"Illegal character in Base64 encoded data.");
int b0 = map2[i0];
int b1 = map2[i1];
int b2 = map2[i2];
int b3 = map2[i3];
if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
throw new IllegalArgumentException(
"Illegal character in Base64 encoded data.");
int o0 = (b0 << 2) | (b1 >>> 4);
int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
int o2 = ((b2 & 3) << 6) | b3;
out[op++] = (byte) o0;
if (op < oLen)
out[op++] = (byte) o1;
if (op < oLen)
out[op++] = (byte) o2;
}
return out;
}
} // end class Base64Coder

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="@+id/txtStatusTaskAcc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="STATUS"
android:padding="3dp"
android:drawableLeft="@drawable/ic_phone_color"
android:drawablePadding="6dp"
android:textColor="@color/fontColorDarkGrey"/>
<TextView
android:id="@+id/txtProductAcc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="PRODUCT"
android:padding="3dp"
android:drawableLeft="@drawable/ic_phone_color"
android:drawablePadding="6dp"
android:textColor="@color/fontColorDarkGrey"/>
<TextView
android:id="@+id/txtDateAcc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_phone_color"
android:drawablePadding="6dp"
android:padding="3dp"
android:text="19-09-1999"
android:textColor="@color/fontColorDarkGrey" />
</LinearLayout>
<ImageView
android:id="@+id/leadHistoryExpandedIndicator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_arrow_drop_down"
android:layout_weight="7"/>
</LinearLayout>

View file

@ -0,0 +1,320 @@
package com.adins.mss.foundation.camerainapp;
import android.app.Activity;
import android.content.Context;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.OrientationEventListener;
import android.view.SurfaceHolder;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.R;
import com.adins.mss.base.util.LocaleHelper;
import com.adins.mss.foundation.camerainapp.helper.AspectFrameLayout;
import com.adins.mss.foundation.camerainapp.helper.MovementDetector;
import com.androidquery.AQuery;
import com.google.firebase.analytics.FirebaseAnalytics;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
/**
* Created by angga.permadi on 7/26/2016.
*/
public class CameraActivity extends Activity implements CameraContract.View {
public static final String PICTURE_WIDTH = "picture_width";
public static final String PICTURE_HEIGHT = "picture_height";
public static final String PICTURE_QUALITY = "picture_quality";
public static final String PICTURE_URI = "picture_path";
public static final String NEED_BORDER = "need_border";
public static final int PICTURE_WIDHT_DEF = 1024;
public static final int PICTURE_HEIGHT_DEF = 768;
public static final int PICTURE_QUALITY_DEF = 70;
private static final int MAX_CLICK_DURATION = 200;
private AQuery query;
private OrientationEventListener myOrientationEventListener;
private CameraContract.Presenter presenter;
private CameraSurfaceView cameraView;
private ModeCameraItem cameraModeItem;
private ModeReviewItem reviewModeItem;
private AutoFocusItem autoFocusItem;
private int width;
private int height;
private int quality;
private boolean needBorder;
private long startClickTime;
private FirebaseAnalytics screenName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_preview_camera);
screenName = FirebaseAnalytics.getInstance(this);
query = new AQuery(this);
if (getIntent().getExtras() != null) {
width = getIntent().getExtras().getInt(PICTURE_WIDTH);
height = getIntent().getExtras().getInt(PICTURE_HEIGHT);
quality = getIntent().getExtras().getInt(PICTURE_QUALITY);
needBorder = getIntent().getExtras().getBoolean(NEED_BORDER, false);
}
if (width <= 0) width = PICTURE_WIDHT_DEF;
if (height <= 0) height = PICTURE_HEIGHT_DEF;
if (quality <= 0) quality = PICTURE_QUALITY_DEF;
presenter = new CameraPresenter(this);
((CameraPresenter) presenter).setNeedBorder(needBorder);
presenter.start();
}
@Override
protected void onResume() {
super.onResume();
//Set Firebase screen name
screenName.setCurrentScreen(this,getString(R.string.screen_name_camera),null);
Thread openThread = new Thread() {
@Override
public void run() {
try {
sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
presenter.openCamera();
}
};
openThread.start();
MovementDetector.getInstance().start();
}
@Override
protected void onPause() {
presenter.stopCamera();
MovementDetector.getInstance().stop();
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (myOrientationEventListener != null && myOrientationEventListener.canDetectOrientation()) {
myOrientationEventListener.disable();
}
if (presenter != null) {
presenter.destroy();
}
removeAutoFocusIdc();
}
@Override
public void onBackPressed() {
if (presenter != null && presenter.onBackPressed()) {
super.onBackPressed();
}
}
@Override
protected void attachBaseContext(Context newBase) {
Context context = newBase;
Locale locale;
try{
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
context = LocaleHelper.wrap(newBase, locale);
} catch (Exception e) {
locale = new Locale(LocaleHelper.ENGLSIH);
context = LocaleHelper.wrap(newBase, locale);
} finally {
super.attachBaseContext(context);
}
}
@Override
public void initializeViews() {
cameraView = (CameraSurfaceView) query.id(R.id.camera_surfaceview).getView();
cameraView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
startClickTime = Calendar.getInstance().getTimeInMillis();
break;
}
case MotionEvent.ACTION_UP: {
long clickDuration = Calendar.getInstance().getTimeInMillis() - startClickTime;
if (clickDuration < MAX_CLICK_DURATION) {
//click event has occurred
presenter.autoFocus(event, cameraView);
}
break;
}
default:
break;
}
return true;
}
});
FrameLayout content = (FrameLayout) query.id(R.id.camera_border).getView();
View viewR = (View) query.id(R.id.viewRight).getView();
View viewL = (View) query.id(R.id.viewLeft).getView();
View viewU = (View) query.id(R.id.viewUp).getView();
View viewD = (View) query.id(R.id.viewDown).getView();
TextView txtIdCard = (TextView) query.id(R.id.txtIdCard).getView();
if (needBorder) {
content.setVisibility(View.VISIBLE);
viewR.setVisibility(View.VISIBLE);
viewL.setVisibility(View.VISIBLE);
viewU.setVisibility(View.VISIBLE);
viewD.setVisibility(View.VISIBLE);
txtIdCard.setVisibility(View.VISIBLE);
} else {
content.setVisibility(View.GONE);
viewR.setVisibility(View.GONE);
viewL.setVisibility(View.GONE);
viewU.setVisibility(View.GONE);
viewD.setVisibility(View.GONE);
txtIdCard.setVisibility(View.GONE);
}
cameraModeItem = new ModeCameraItem(this);
reviewModeItem = new ModeReviewItem(this);
}
@Override
public void cameraHasOpened() {
SurfaceHolder holder = cameraView.getSurfaceHolder();
presenter.startPreview(holder, width, height, quality);
}
@Override
public void cameraMode(int cameraMode, String flashMode) {
removeAutoFocusIdc();
FrameLayout content = (FrameLayout) query.id(R.id.footer_content).getView();
content.removeAllViews();
cameraModeItem.bind((CameraPresenter) presenter, cameraMode, flashMode);
content.addView(cameraModeItem);
}
@Override
public void onCameraPreview(int width, int height) {
AspectFrameLayout layout = (AspectFrameLayout) query.id(R.id.camera_frame).getView();
layout.setAspectRatio((double) height / width);
}
@Override
public void reviewMode(final byte[] data) {
presenter.pausePreview();
removeAutoFocusIdc();
FrameLayout content = (FrameLayout) query.id(R.id.footer_content).getView();
content.removeAllViews();
reviewModeItem.bind((CameraPresenter) presenter, data);
content.addView(reviewModeItem);
}
@Override
public void setSupportCameraParams(boolean isSupportFrontCamera, List<String> flashMode) {
if (cameraModeItem == null) {
cameraModeItem = new ModeCameraItem(this);
}
cameraModeItem.bind(flashMode);
if (myOrientationEventListener != null) return;
myOrientationEventListener = new OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) {
@Override
public void onOrientationChanged(int arg0) {
presenter.onOrientationChanged(arg0);
}
};
if (myOrientationEventListener.canDetectOrientation()) {
myOrientationEventListener.enable();
}
}
@Override
public void onAutoFocus(AutoFocusItem.FocusMode mode, MotionEvent event) {
RelativeLayout container = (RelativeLayout) query.id(R.id.rl_auto_focus_container).getView();
switch (mode) {
case START_FOCUS:
if (autoFocusItem != null) {
container.removeAllViews();
}
autoFocusItem = new AutoFocusItem(this);
autoFocusItem.bind(AutoFocusItem.FocusMode.START_FOCUS, event.getX(), event.getY());
container.addView(autoFocusItem);
break;
case FOCUS_FAILED:
if (autoFocusItem != null) {
autoFocusItem.bind(AutoFocusItem.FocusMode.FOCUS_FAILED, event.getX(), event.getY());
}
break;
case FOCUS_SUCCESS:
if (autoFocusItem != null) {
autoFocusItem.bind(AutoFocusItem.FocusMode.FOCUS_SUCCESS, event.getX(), event.getY());
}
break;
case FOCUS_CONTINUOUS:
container.removeAllViews();
break;
default:
break;
}
}
@Override
public void onOrientationChanged(int rotation) {
if (cameraModeItem != null) cameraModeItem.orientationChange(rotation);
if (reviewModeItem != null) reviewModeItem.orientationChange(rotation);
}
@Override
public void onTakePicture(boolean safeTakePicture) {
if (cameraModeItem != null) {
cameraModeItem.bind(safeTakePicture);
}
}
@Override
public Context getContext() {
return this;
}
private void removeAutoFocusIdc() {
RelativeLayout container = (RelativeLayout) query.id(R.id.rl_auto_focus_container).getView();
container.removeAllViews();
}
public boolean isNeedBorder() {
return needBorder;
}
public void setNeedBorder(boolean needBorder) {
this.needBorder = needBorder;
}
}

View file

@ -0,0 +1,159 @@
package com.adins.mss.svy;
import android.content.Context;
import com.adins.mss.constant.Global;
import com.mikepenz.aboutlibraries.entity.Library;
import com.mikepenz.aboutlibraries.entity.License;
import java.util.ArrayList;
public class ChangeLog {
public static ArrayList<Library> library = new ArrayList<Library>();
public ChangeLog(Context context) {
String authorLogv2_0_0 = "AdIns";
String appNameLogv2_0_0 = "MSSSVY";
int buildVersion = Global.BUILD_VERSION;
License licenseLogv2_0_0 = new License();
licenseLogv2_0_0.setLicenseName("Apache Version 2.0");
library.add(0, new Library("06/06/2015", appNameLogv2_0_0, context.getString(R.string.changelog_v200),
"2.0.0.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("06/01/2016", appNameLogv2_0_0, context.getString(R.string.changelog_v210),
"2.1.0.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("01/06/2016", appNameLogv2_0_0, context.getString(R.string.changelog_v220),
"2.2.0.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("06/12/2016", appNameLogv2_0_0, context.getString(R.string.changelog_v230),
"2.3.0.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("15/12/2016", appNameLogv2_0_0, context.getString(R.string.changelog_v2310),
"2.3.1.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("19/01/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2320),
"2.3.2.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("07/03/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2330),
"2.3.3.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("04/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2340),
"2.3.4.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("08/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2350),
"2.3.5.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("09/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2360),
"2.3.6.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("12/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2370),
"2.3.7.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("15/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2380),
"2.3.8.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("16/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2390),
"2.3.9.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("17/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23100),
"2.3.10.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("22/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23110),
"2.3.11.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("23/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23120),
"2.3.12.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("24/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23130),
"2.3.13.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("26/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23140),
"2.3.14.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("29/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23150),
"2.3.15.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("30/05/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23160),
"2.3.16.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("02/06/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23170),
"2.3.17.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("06/06/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23180),
"2.3.18.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("07/06/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v23190),
"2.3.19.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("07/07/2017", appNameLogv2_0_0, context.getString(R.string.changelog_v2400),
"2.4.0.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("26/02/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v2500),
"2.5.0.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("22/10/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3000),
"3.0.0.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("19/11/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3001),
"3.0.0.1", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("27/11/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3002),
"3.0.0.2", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("04/12/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3003),
"3.0.0.3", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("07/12/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3004),
"3.0.0.4", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("11/12/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3005),
"3.0.0.5", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("11/12/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3006),
"3.0.0.6", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("12/12/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3007),
"3.0.0.7", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("12/12/2018", appNameLogv2_0_0, context.getString(R.string.changelog_v3008),
"3.0.0.8", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("18/01/2019", appNameLogv2_0_0, context.getString(R.string.changelog_v3009),
"3.0.0.9", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("21/06/2019", appNameLogv2_0_0, context.getString(R.string.changelog_v30013),
"3.0.0.13", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("01/08/2019", appNameLogv2_0_0, context.getString(R.string.changelog_v30017),
"3.0.0.17", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("22/11/2019", appNameLogv2_0_0, context.getString(R.string.changelog_v30032),
"3.0.0.32", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("04/03/2020", appNameLogv2_0_0, context.getString(R.string.changelog_v3110),
"3.1.1.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("04/27/2020", appNameLogv2_0_0, context.getString(R.string.changelog_v3120),
"3.1.2.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("05/27/2020", appNameLogv2_0_0, context.getString(R.string.changelog_v3130),
"3.1.3.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("01/10/2020", appNameLogv2_0_0, context.getString(R.string.changelog_v3140),
"3.1.4.0", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("18/03/2021", appNameLogv2_0_0, context.getString(R.string.changelog_v3201),
"3.2.0.1", licenseLogv2_0_0, buildVersion));
library.add(0, new Library("12/04/2021", appNameLogv2_0_0, context.getString(R.string.changelog_v3202),
"3.2.0.2", licenseLogv2_0_0, buildVersion));
}
public static ArrayList<Library> getChangeLog(Context context) {
library = new ArrayList<Library>();
new ChangeLog(context);
return library;
}
}

View file

@ -0,0 +1,59 @@
package com.adins.mss.coll.dashboardcollection.view;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import com.adins.mss.coll.dashboardcollection.model.CollResultDetail;
import java.util.ArrayList;
import java.util.List;
public class CollResultPagerAdapter extends FragmentStatePagerAdapter {
private int tabCount;
List<PagerDataChangeListener> pagerDataListener = new ArrayList<>();
public interface PagerDataChangeListener{
void onPagerDataChange(int idx,List<CollResultDetail> data);
}
public CollResultPagerAdapter(FragmentManager fm, int tabCount) {
super(fm);
this.tabCount = tabCount;
}
@Override
public Fragment getItem(int i) {
DashboardCollResultDetail fragment = null;
if(pagerDataListener.size() + 1 > tabCount){
fragment = (DashboardCollResultDetail) pagerDataListener.get(i);
}
else {
fragment = new DashboardCollResultDetail();
pagerDataListener.add(fragment);
}
return fragment;
}
@Override
public int getCount() {
return tabCount;
}
@Override
public int getItemPosition(@NonNull Object object) {
return POSITION_NONE;
}
public void setDataToPage(int index, List<CollResultDetail> data){
if(index >= pagerDataListener.size()){
return;
}
pagerDataListener.get(index).onPagerDataChange(index,data);
}
}

View file

@ -0,0 +1,31 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layoutView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_grayscale">
<View android:id="@+id/actionbar"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:background="@drawable/actionbar_background"/>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_marginTop="48dp"
android:id="@+id/swipeRefreshVerification"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp">
<GridView
android:id="@+id/gridVerification"
android:layout_below="@+id/actionbar"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:numColumns="3"
android:padding="5dp"
android:horizontalSpacing="4dp"
android:verticalSpacing="4dp">
</GridView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</RelativeLayout>

View file

@ -0,0 +1,367 @@
package com.adins.mss.odr.marketingreport;
import android.app.DatePickerDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.appcompat.widget.AppCompatSpinner;
import androidx.cardview.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.base.util.Utility;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.foundation.http.KeyValue;
import com.adins.mss.odr.R;
import com.google.firebase.analytics.FirebaseAnalytics;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
/**
* Created by olivia.dg on 11/28/2017.
*/
class DateClickListener implements View.OnClickListener {
private final EditText mTarget;
private final Context mContext;
public DateClickListener(Context context, EditText target) {
mContext = context;
mTarget = target;
}
@Override
public void onClick(View v) {
Calendar cal = Calendar.getInstance();
DatePickerDialog dialog = new DatePickerDialog(mContext, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
mTarget.setText(dayOfMonth + "/" + Tool.appendZeroForDateTime(monthOfYear, true) + "/" + year);
}
}, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
dialog.show();
}
}
public class MarketingReportFragment extends Fragment {
ImageButton buttonSelectDate;
EditText editDate;
AppCompatSpinner spinnerCategory;
private EditText editStartDate;
private EditText editEndDate;
private ImageButton buttonSelectStartDate;
private ImageButton buttonSelectEndDate;
private AppCompatSpinner spinnerMonth;
private Button buttonSearch;
private int activeSearchMode;
private ListView listResult;
private String[] cbSearchBy;
private String[] cbSearchByMonth;
private CardView layout;
private FirebaseAnalytics screenName;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
screenName = FirebaseAnalytics.getInstance(getActivity());
return inflater.inflate(R.layout.fragment_marketing_report, container, false);
}
@Override
public void onDestroyView() {
super.onDestroyView();
Utility.freeMemory();
}
@Override
public void onResume(){
super.onResume();
//Set Firebase screen name
screenName.setCurrentScreen(getActivity(), getString(R.string.screen_name_product_page), null);
getActivity().findViewById(com.adins.mss.base.R.id.search).setVisibility(View.GONE);
getActivity().findViewById(com.adins.mss.base.R.id.spinner).setVisibility(View.GONE);
getActivity().setTitle(getString(com.adins.mss.base.R.string.title_mn_marketingreport));
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
listResult = (ListView) view.findViewById(R.id.resultListView);
layout = (CardView) view.findViewById(R.id.resultLayout);
buttonSelectDate = (ImageButton) view.findViewById(R.id.btnDate);
buttonSelectStartDate = (ImageButton) view.findViewById(R.id.btnStartDate);
buttonSelectEndDate = (ImageButton) view.findViewById(R.id.btnEndDate);
buttonSearch = (Button) view.findViewById(R.id.btnSearchOrder);
editDate = (EditText) view.findViewById(R.id.txtDateDay);
editStartDate = (EditText) view.findViewById(R.id.txtStartDate);
editEndDate = (EditText) view.findViewById(R.id.txtEndDate);
spinnerMonth = (AppCompatSpinner) view.findViewById(R.id.cbSearchByMonth);
spinnerCategory = (AppCompatSpinner) view.findViewById(R.id.cbSearchBy);
cbSearchBy = this.getResources().getStringArray(R.array.cbSearchBy);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.cbSearchBy,
R.layout.spinner_search_layout);
adapter.setDropDownViewResource(R.layout.spinner_style);
spinnerCategory.setAdapter(adapter);
cbSearchByMonth = this.getResources().getStringArray(R.array.cbSearchByMonth);
Calendar monthCalendar = Calendar.getInstance();
int maximumMonth = monthCalendar.get(Calendar.MONTH);
String[] months = getActivity().getResources().getStringArray(R.array.cbSearchByMonth);
ArrayList<String> availableMonths = new ArrayList<String>();
availableMonths.addAll(Arrays.asList(months).subList(0, maximumMonth + 1));
ArrayAdapter<String> monthAdapter = new ArrayAdapter<String>(getActivity(), R.layout.spinner_style2, availableMonths);
monthAdapter.setDropDownViewResource(R.layout.spinner_style);
spinnerMonth.setAdapter(monthAdapter);
spinnerCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
invalidateForm(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
buttonSelectDate.setOnClickListener(new DateClickListener(getActivity(), editDate));
buttonSelectStartDate.setOnClickListener(new DateClickListener(getActivity(), editStartDate));
buttonSelectEndDate.setOnClickListener(new DateClickListener(getActivity(), editEndDate));
buttonSearch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MarketingSearchRequest request = new MarketingSearchRequest();
try {
if (Tool.isInternetconnected(getActivity())) {
executeSearch(request,editDate.getText().toString(), spinnerMonth.getSelectedItemPosition(),editStartDate.getText().toString(), editEndDate.getText().toString());
} else {
NiftyDialogBuilder builder = NiftyDialogBuilder.getInstance(getActivity());
builder.withTitle("INFO")
.withMessage(getString(R.string.no_internet_connection))
.show();
}
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
private void executeSearch(MarketingSearchRequest request, final String date, final int month, final String startDate, final String endDate) throws ParseException, IOException {
new AsyncTask<Void, Void, MarketingSearchResponse>(){
final ProgressDialog progress = new ProgressDialog(getActivity());
String errMessage;
@Override
protected void onPreExecute() {
super.onPreExecute();
progress.setMessage(getActivity().getString(R.string.contact_server));
progress.show();
}
@Override
protected MarketingSearchResponse doInBackground(Void... params) {
try {
MarketingSearchRequest searchRequest = new MarketingSearchRequest();
searchRequest.setUuidUser(GlobalData.getSharedGlobalData().getUser().getUuid_user());
searchRequest.setAudit(GlobalData.getSharedGlobalData().getAuditData());
try {
if (activeSearchMode == 0) {
SimpleDateFormat f = new SimpleDateFormat(Global.DATE_STR_FORMAT);
Date date1 = f.parse(date);
searchRequest.setDate1(date1);
}
if (activeSearchMode == 1) {
SimpleDateFormat f = new SimpleDateFormat(Global.DATE_STR_FORMAT);
Date sDate, eDate;
long sLong = 0;
long eLong = 0;
try {
sDate = f.parse(startDate);
searchRequest.setDate1(sDate);
eDate = f.parse(endDate);
eDate.setHours(23);
eDate.setMinutes(59);
eDate.setSeconds(59);
searchRequest.setDate2(eDate);
sLong = sDate.getTime();
eLong = eDate.getTime();
} catch (ParseException e) {
errMessage = getActivity().getString(R.string.enter_valid_date);
return null;
}
long milisecond = eLong - sLong;
if (milisecond > 604799000) {
errMessage = getActivity().getString(R.string.data_range_not_allowed);
return null;
} else if (milisecond < 0) {
errMessage = getActivity().getString(R.string.input_not_valid);
return null;
}
}
if (activeSearchMode == 2) {
searchRequest.setMonth(String.valueOf(month + 1));
}
} catch (ParseException parseEx) {
errMessage = getActivity().getString(R.string.enter_valid_date);
return null;
}
String json = GsonHelper.toJson(searchRequest);
String url = GlobalData.getSharedGlobalData().getURL_GET_MKTPERFORMANCE();
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(getActivity(), encrypt, decrypt);
HttpConnectionResult serverResult = null;
try {
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
} catch (Exception e) {
e.printStackTrace();
}
MarketingSearchResponse serverResponse = null;
if (serverResult != null && serverResult.isOK()) {
try {
String responseBody = serverResult.getResult();
serverResponse = GsonHelper.fromJson(responseBody, MarketingSearchResponse.class);
} catch (Exception e) {
if(Global.IS_DEV) {
e.printStackTrace();
errMessage=e.getMessage();
}
}
} else {
errMessage = getActivity().getString(R.string.server_down);
}
return serverResponse;
} catch (Exception e) {
errMessage = e.getMessage();
return null;
}
}
@Override
protected void onPostExecute(final MarketingSearchResponse serverResponse) {
super.onPostExecute(serverResponse);
if(getActivity()!=null) {
if (progress != null && progress.isShowing()) {
progress.dismiss();
}
if (errMessage != null) {
Toast.makeText(getActivity(), errMessage, Toast.LENGTH_SHORT).show();
} else if (serverResponse != null && serverResponse.getListKeyValue() != null) {
layout.setVisibility(View.VISIBLE);
MarketingReportFragment.this.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
listResult.setAdapter(new SearchResultListAdapter(getActivity(), serverResponse.getListKeyValue()));
}
});
}
}
}
}.execute();
}
private void invalidateForm(int position) {
switch (position) {
case 0:
showSearchForm(R.id.byDay);
break;
case 1:
showSearchForm(R.id.byEstimatedDate);
break;
case 2:
showSearchForm(R.id.byMonth);
break;
default:
break;
}
this.activeSearchMode = position;
}
private void showSearchForm(int id) {
View byDay = getView().findViewById(R.id.byDay);
View byRange = getView().findViewById(R.id.byEstimatedDate);
View byMonth = getView().findViewById(R.id.byMonth);
byDay.setVisibility(View.GONE);
byRange.setVisibility(View.GONE);
byMonth.setVisibility(View.GONE);
View active = getView().findViewById(id);
active.setVisibility(View.VISIBLE);
}
}
class SearchResultListAdapter extends ArrayAdapter<KeyValue> {
public SearchResultListAdapter(Context context) {
super(context, R.layout.view_surveyor_search_result);
}
public SearchResultListAdapter(Context context, KeyValue[] values) {
super(context, R.layout.view_surveyor_search_result, values);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.view_surveyor_search_result, parent, false);
}
TextView label = (TextView) convertView.findViewById(R.id.taskLabel);
TextView value = (TextView) convertView.findViewById(R.id.taskValue);
KeyValue item = getItem(position);
label.setText(item.getKey());
value.setText(item.getValue());
return convertView;
}
}

View file

@ -0,0 +1,280 @@
/*
* 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.util.SparseArray;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
/**
* Collects data about available codecs on the device through the MediaCodecList
* API introduced in Android 4.1 JellyBean.
*
* @author Kevin Gaudin
*/
public class MediaCodecListCollector {
private static final String COLOR_FORMAT_PREFIX = "COLOR_";
private static final String[] MPEG4_TYPES = {"mp4", "mpeg4", "MP4", "MPEG4"};
private static final String[] AVC_TYPES = {"avc", "h264", "AVC", "H264"};
private static final String[] H263_TYPES = {"h263", "H263"};
private static final String[] AAC_TYPES = {"aac", "AAC"};
private static Class<?> mediaCodecListClass = null;
private static Method getCodecInfoAtMethod = null;
private static Class<?> mediaCodecInfoClass = null;
private static Method getNameMethod = null;
private static Method isEncoderMethod = null;
private static Method getSupportedTypesMethod = null;
private static Method getCapabilitiesForTypeMethod = null;
private static Class<?> codecCapabilitiesClass = null;
private static Field colorFormatsField = null;
private static Field profileLevelsField = null;
private static Field profileField = null;
private static Field levelField = null;
private static SparseArray<String> mColorFormatValues = new SparseArray<String>();
private static SparseArray<String> mAVCLevelValues = new SparseArray<String>();
private static SparseArray<String> mAVCProfileValues = new SparseArray<String>();
private static SparseArray<String> mH263LevelValues = new SparseArray<String>();
private static SparseArray<String> mH263ProfileValues = new SparseArray<String>();
private static SparseArray<String> mMPEG4LevelValues = new SparseArray<String>();
private static SparseArray<String> mMPEG4ProfileValues = new SparseArray<String>();
private static SparseArray<String> mAACProfileValues = new SparseArray<String>();
// static init where nearly all reflection inspection is done.
static {
try {
mediaCodecListClass = Class.forName("android.media.MediaCodecList");
// Get methods to retrieve media codec info
getCodecInfoAtMethod = mediaCodecListClass.getMethod("getCodecInfoAt", int.class);
mediaCodecInfoClass = Class.forName("android.media.MediaCodecInfo");
getNameMethod = mediaCodecInfoClass.getMethod("getName");
isEncoderMethod = mediaCodecInfoClass.getMethod("isEncoder");
getSupportedTypesMethod = mediaCodecInfoClass.getMethod("getSupportedTypes");
getCapabilitiesForTypeMethod = mediaCodecInfoClass.getMethod("getCapabilitiesForType", String.class);
codecCapabilitiesClass = Class.forName("android.media.MediaCodecInfo$CodecCapabilities");
colorFormatsField = codecCapabilitiesClass.getField("colorFormats");
profileLevelsField = codecCapabilitiesClass.getField("profileLevels");
// Retrieve list of possible Color Format
for (Field f : codecCapabilitiesClass.getFields()) {
if (Modifier.isStatic(f.getModifiers()) && Modifier.isFinal(f.getModifiers())
&& f.getName().startsWith(COLOR_FORMAT_PREFIX)) {
mColorFormatValues.put(f.getInt(null), f.getName());
}
}
// Retrieve lists of possible codecs profiles and levels
Class<?> codecProfileLevelClass = Class.forName("android.media.MediaCodecInfo$CodecProfileLevel");
for (Field f : codecProfileLevelClass.getFields()) {
if (Modifier.isStatic(f.getModifiers()) && Modifier.isFinal(f.getModifiers())) {
if (f.getName().startsWith("AVCLevel")) {
mAVCLevelValues.put(f.getInt(null), f.getName());
} else if (f.getName().startsWith("AVCProfile")) {
mAVCProfileValues.put(f.getInt(null), f.getName());
} else if (f.getName().startsWith("H263Level")) {
mH263LevelValues.put(f.getInt(null), f.getName());
} else if (f.getName().startsWith("H263Profile")) {
mH263ProfileValues.put(f.getInt(null), f.getName());
} else if (f.getName().startsWith("MPEG4Level")) {
mMPEG4LevelValues.put(f.getInt(null), f.getName());
} else if (f.getName().startsWith("MPEG4Profile")) {
mMPEG4ProfileValues.put(f.getInt(null), f.getName());
} else if (f.getName().startsWith("AAC")) {
mAACProfileValues.put(f.getInt(null), f.getName());
}
}
}
profileField = codecProfileLevelClass.getField("profile");
levelField = codecProfileLevelClass.getField("level");
} catch (ClassNotFoundException e) {
// NOOP
} catch (NoSuchMethodException e) {
// NOOP
} catch (IllegalArgumentException e) {
// NOOP
} catch (IllegalAccessException e) {
// NOOP
} catch (SecurityException e) {
// NOOP
} catch (NoSuchFieldException e) {
// NOOP
}
}
/**
* Builds a String describing the list of available codecs on the device
* with their capabilities (supported Color Formats, Codec Profiles et
* Levels).
*
* @return The media codecs information
*/
public static String collecMediaCodecList() {
StringBuilder result = new StringBuilder();
if (mediaCodecListClass != null && mediaCodecInfoClass != null) {
try {
// Retrieve list of available media codecs
int codecCount = (Integer) (mediaCodecListClass.getMethod("getCodecCount").invoke(null));
// Go through each available media codec
Object codecInfo = null;
for (int codecIdx = 0; codecIdx < codecCount; codecIdx++) {
result.append("\n");
codecInfo = getCodecInfoAtMethod.invoke(null, codecIdx);
result.append(codecIdx).append(": ").append(getNameMethod.invoke(codecInfo)).append("\n");
result.append("isEncoder: ").append(isEncoderMethod.invoke(codecInfo)).append("\n");
String[] supportedTypes = (String[]) getSupportedTypesMethod.invoke(codecInfo);
result.append("Supported types: ").append(Arrays.toString(supportedTypes)).append("\n");
for (String type : supportedTypes) {
result.append(collectCapabilitiesForType(codecInfo, type));
}
result.append("\n");
}
} catch (NoSuchMethodException e) {
// NOOP
} catch (IllegalAccessException e) {
// NOOP
} catch (InvocationTargetException e) {
// NOOP
}
}
return result.toString();
}
/**
* Retrieve capabilities (ColorFormats and CodecProfileLevels) for a
* specific codec type.
*
* @param codecInfo
* @param type
* @return A string describing the color formats and codec profile levels
* available for a specific codec type.
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
private static String collectCapabilitiesForType(Object codecInfo, String type) throws IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
StringBuilder result = new StringBuilder();
Object codecCapabilities = getCapabilitiesForTypeMethod.invoke(codecInfo, type);
// Color Formats
int[] colorFormats = (int[]) colorFormatsField.get(codecCapabilities);
if (colorFormats.length > 0) {
result.append(type).append(" color formats:");
for (int i = 0; i < colorFormats.length; i++) {
result.append(mColorFormatValues.get(colorFormats[i]));
if (i < colorFormats.length - 1) {
result.append(',');
}
}
result.append("\n");
}
// Profile Levels
Object[] codecProfileLevels = (Object[]) profileLevelsField.get(codecCapabilities);
if (codecProfileLevels.length > 0) {
result.append(type).append(" profile levels:");
for (int i = 0; i < codecProfileLevels.length; i++) {
CodecType codecType = identifyCodecType(codecInfo);
int profileValue = profileField.getInt(codecProfileLevels[i]);
int levelValue = levelField.getInt(codecProfileLevels[i]);
if (codecType == null) {
// Unknown codec
result.append(profileValue).append('-').append(levelValue);
}
switch (codecType) {
case AVC:
result.append(profileValue).append(mAVCProfileValues.get(profileValue)).append('-')
.append(mAVCLevelValues.get(levelValue));
break;
case H263:
result.append(mH263ProfileValues.get(profileValue)).append('-')
.append(mH263LevelValues.get(levelValue));
break;
case MPEG4:
result.append(mMPEG4ProfileValues.get(profileValue)).append('-')
.append(mMPEG4LevelValues.get(levelValue));
break;
case AAC:
result.append(mAACProfileValues.get(profileValue));
break;
default:
break;
}
if (i < codecProfileLevels.length - 1) {
result.append(',');
}
}
result.append("\n");
}
return result.append("\n").toString();
}
/**
* Looks for keywords in the codec name to identify its nature ({@link CodecType}).
*
* @param codecInfo
* @return
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws InvocationTargetException
*/
private static CodecType identifyCodecType(Object codecInfo) throws IllegalArgumentException,
IllegalAccessException, InvocationTargetException {
String name = (String) getNameMethod.invoke(codecInfo);
for (String token : AVC_TYPES) {
if (name.contains(token)) {
return CodecType.AVC;
}
}
for (String token : H263_TYPES) {
if (name.contains(token)) {
return CodecType.H263;
}
}
for (String token : MPEG4_TYPES) {
if (name.contains(token)) {
return CodecType.MPEG4;
}
}
for (String token : AAC_TYPES) {
if (name.contains(token)) {
return CodecType.AAC;
}
}
return null;
}
private enum CodecType {
AVC, H263, MPEG4, AAC
}
}