mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,246 @@
|
|||
package com.adins.mss.base.tasklog;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.NewMainActivity;
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.todolist.form.OnTaskListClickListener;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.Lookup;
|
||||
import com.adins.mss.dao.Scheme;
|
||||
import com.adins.mss.dao.TaskD;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.LookupDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.SchemeDataAccess;
|
||||
import com.adins.mss.foundation.db.dataaccess.TaskDDataAccess;
|
||||
import com.adins.mss.foundation.formatter.Formatter;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by olivia.dg on 3/16/2018.
|
||||
*/
|
||||
|
||||
public class NewTaskLogAdapter extends RecyclerView.Adapter<NewTaskLogAdapter.TaskLogViewHolder> {
|
||||
|
||||
private static boolean isLog = false;
|
||||
private static Context context;
|
||||
private List<TaskH> objects;
|
||||
private final OnTaskListClickListener mListener;
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public NewTaskLogAdapter(Context context, List<TaskH> objects, boolean isLog, OnTaskListClickListener listener) {
|
||||
this.context = context;
|
||||
this.objects = objects;
|
||||
this.isLog = isLog;
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
static class TaskLogViewHolder extends RecyclerView.ViewHolder {
|
||||
final View mView;
|
||||
TextView txtName;
|
||||
TextView txtTime;
|
||||
TextView txtScheme;
|
||||
TextView txtCollResult;
|
||||
ImageView logIcon;
|
||||
ImageView imgPrint;
|
||||
|
||||
public TaskLogViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mView = itemView;
|
||||
txtName = (TextView) itemView.findViewById(R.id.taskName);
|
||||
txtTime = (TextView) itemView.findViewById(R.id.txtTime);
|
||||
txtScheme = (TextView) itemView.findViewById(R.id.taskForm);
|
||||
txtCollResult = (TextView) itemView.findViewById(R.id.taskCollResult);
|
||||
logIcon = (ImageView) itemView.findViewById(R.id.logIcon);
|
||||
imgPrint = (ImageView) itemView.findViewById(R.id.imgPrint);
|
||||
}
|
||||
|
||||
public void bind(TaskH task) {
|
||||
String taskId = task.getTask_id();
|
||||
String custName = task.getCustomer_name();
|
||||
String formId = "";
|
||||
if (task.getScheme() != null)
|
||||
formId = task.getScheme().getForm_id();
|
||||
Date dTime = task.getSubmit_date();
|
||||
String sTime = "";
|
||||
try {
|
||||
sTime = Formatter.formatDate(dTime, Global.DATE_TIME_STR_FORMAT);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
try {
|
||||
sTime = Formatter.formatDate(task.getDtm_crt(), Global.DATE_TIME_STR_FORMAT);
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
}
|
||||
|
||||
txtName.setText(custName);
|
||||
|
||||
if (taskId != null) {
|
||||
if (taskId.contains("belum di-mapping")) {
|
||||
txtScheme.setText(taskId);
|
||||
txtTime.setVisibility(View.GONE);
|
||||
} else {
|
||||
txtScheme.setText(formId);
|
||||
txtTime.setVisibility(View.VISIBLE);
|
||||
txtTime.setText(sTime);
|
||||
}
|
||||
}
|
||||
|
||||
// olivia : UPDATE - icon priority ditampilkan untuk log
|
||||
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
|
||||
// if (isLog) {
|
||||
logIcon.setVisibility(View.VISIBLE);
|
||||
if (Global.APPLICATION_SURVEY.equalsIgnoreCase(application) && (NewMainActivity.mnSurveyApproval != null || NewMainActivity.mnSurveyVerif != null
|
||||
|| NewMainActivity.mnVerifByBranch != null || NewMainActivity.mnApprovalByBranch != null)) {
|
||||
if (task.getIs_prepocessed() != null && task.getIs_prepocessed().equals(Global.FORM_TYPE_VERIFICATION)) {
|
||||
logIcon.setImageResource(R.drawable.task_verification);
|
||||
} else if (task.getIs_prepocessed() != null && task.getIs_prepocessed().equals(Global.FORM_TYPE_APPROVAL)) {
|
||||
logIcon.setImageResource(R.drawable.task_approval);
|
||||
} else {
|
||||
}
|
||||
} else if (task.getPriority() != null) {
|
||||
if (task.getPriority().equalsIgnoreCase("HIGH")) {
|
||||
logIcon.setImageResource(R.drawable.task_highpriority);
|
||||
} else if (task.getPriority().equalsIgnoreCase("NORMAL") || task.getPriority().equalsIgnoreCase("MEDIUM")) {
|
||||
logIcon.setImageResource(R.drawable.task_normalpriority);
|
||||
} else {
|
||||
logIcon.setImageResource(R.drawable.task_lowpriority);
|
||||
}
|
||||
} else
|
||||
logIcon.setImageResource(R.drawable.task_new);
|
||||
// } else {
|
||||
// logIcon.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
if (Global.APPLICATION_COLLECTION.equalsIgnoreCase(application)) {
|
||||
// olivia : tambahan menampilkan collection result di log
|
||||
TaskD taskdCollResult = TaskDDataAccess.getOneFromTaskDWithTag(context, task.getUuid_task_h(), Global.TAG_COLLECTION_RESULT);
|
||||
if (taskdCollResult != null) {
|
||||
Lookup lookup = LookupDataAccess.getOneByCode(context, taskdCollResult.getUuid_lookup(), taskdCollResult.getLov());
|
||||
if (lookup != null) {
|
||||
TaskD taskdTotalBayar = TaskDDataAccess.getOneFromTaskDWithTag(context, task.getUuid_task_h(), Global.TAG_TOTAL);
|
||||
TaskD tasdPTP = TaskDDataAccess.getOneFromTaskDWithTag(context, task.getUuid_task_h(), Global.TAG_PTP);
|
||||
txtCollResult.setVisibility(View.VISIBLE);
|
||||
if (taskdTotalBayar != null) {
|
||||
txtCollResult.setText(lookup.getValue() + " - " + taskdTotalBayar.getText_answer());
|
||||
} else if (tasdPTP != null) {
|
||||
String ptpDate = "";
|
||||
if (!tasdPTP.getText_answer().contains("/")) {
|
||||
String format = Global.DATE_STR_FORMAT_GSON;
|
||||
Date date = null;
|
||||
try {
|
||||
date = Formatter.parseDate(tasdPTP.getText_answer(), format);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ptpDate = Formatter.formatDate(date, Global.DATE_STR_FORMAT);
|
||||
} else {
|
||||
ptpDate = tasdPTP.getText_answer();
|
||||
}
|
||||
txtCollResult.setText(lookup.getValue() + " - " + ptpDate);
|
||||
} else {
|
||||
txtCollResult.setText(lookup.getValue());
|
||||
}
|
||||
} else {
|
||||
txtCollResult.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
txtCollResult.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// olivia : menampilkan icon print untuk task yang melakukan pembayaran namun belum diprint untuk collection
|
||||
Scheme scheme = SchemeDataAccess.getOne(context, task.getUuid_scheme());
|
||||
if (scheme != null && "1".equals(scheme.getIs_printable())) {
|
||||
boolean isRVinFront = GeneralParameterDataAccess.isRvInFrontEnable(context, task.getUuid_user());
|
||||
if (!isRVinFront) {
|
||||
if (!"".equals(task.getRv_number()) && task.getRv_number() != null) {
|
||||
imgPrint.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (task.getPrint_count() != 0 && task.getPrint_count() != null) {
|
||||
imgPrint.setVisibility(View.GONE);
|
||||
}
|
||||
else {
|
||||
List<TaskD> taskDs = TaskDDataAccess.getAll(context, task.getUuid_task_h(), TaskDDataAccess.ALL_TASK);
|
||||
if (taskDs != null && taskDs.size() > 0) {
|
||||
boolean isTaskPaid = TaskDDataAccess.isTaskPaid(context, task.getUuid_user(), task.getUuid_task_h());
|
||||
if (!isTaskPaid) {
|
||||
imgPrint.setVisibility(View.GONE);
|
||||
} else {
|
||||
imgPrint.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
imgPrint.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
imgPrint.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
imgPrint.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
imgPrint.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskLogViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_log_item, parent, false);
|
||||
TaskLogViewHolder viewHolder = new TaskLogViewHolder(v);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final TaskLogViewHolder holder, final int position) {
|
||||
holder.bind(objects.get(position));
|
||||
holder.mView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (null != mListener) {
|
||||
mListener.onItemClickListener(objects.get(position), position);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (objects != null)
|
||||
return objects.size();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<TaskH> getObjects() {
|
||||
return objects;
|
||||
}
|
||||
|
||||
public void setObjects(List<TaskH> objectList) {
|
||||
this.objects.clear();
|
||||
if (objectList != null) {
|
||||
if (objectList.size() > 0) {
|
||||
for (TaskH task : objectList) {
|
||||
this.objects.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="define_int_MobileOrder">year;owner</string>
|
||||
<string name="library_MobileOrder_author">AdIns</string>
|
||||
<string name="library_MobileOrder_authorWebsite">http://ad-ins.com/</string>
|
||||
<string name="library_MobileOrder_libraryName">LeadIn v2.0</string>
|
||||
<string name="library_MobileOrder_libraryDescription">
|
||||
Mobile Order have never been easier. You can capture mobile market research anytime, on any device, even offline.
|
||||
Request a free demo and learn more.
|
||||
</string>
|
||||
<string name="library_MobileOrder_libraryVersion">1.0.0</string>
|
||||
<string name="library_MobileOrder_libraryWebsite">https://ad-ins.com/MobileOrder</string>
|
||||
<string name="library_MobileOrder_licenseId">apache_2_0</string>
|
||||
<string name="library_MobileOrder_isOpenSource">true</string>
|
||||
<string name="library_MobileOrder_repositoryLink">https://ad-ins.com/MobileOrder</string>
|
||||
<!-- Custom variables section -->
|
||||
<string name="library_MobileOrder_owner">PT. Adicipta Dinamika Inovasi</string>
|
||||
<string name="library_MobileOrder_year">2015</string>
|
||||
</resources>
|
|
@ -0,0 +1,391 @@
|
|||
package com.adins.mss.foundation.camerainapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.ImageFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.Camera;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.foundation.camerainapp.helper.CamParaUtil;
|
||||
import com.adins.mss.foundation.camerainapp.helper.DisplayUtil;
|
||||
import com.adins.mss.foundation.camerainapp.helper.ExifUtil;
|
||||
import com.adins.mss.foundation.camerainapp.helper.FileUtil;
|
||||
import com.adins.mss.foundation.camerainapp.helper.MovementDetector;
|
||||
import com.adins.mss.foundation.image.Utils;
|
||||
import com.adins.mss.logger.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by angga.permadi on 7/26/2016.
|
||||
*/
|
||||
public class CameraPresenter implements CameraContract.Presenter {
|
||||
|
||||
public static final int BACK_CAMERA = 0;
|
||||
public static final int FRONT_CAMERA = 1;
|
||||
Camera.ShutterCallback mShutterCallback = new Camera.ShutterCallback() {
|
||||
public void onShutter() {
|
||||
Logger.i(this, "myShutterCallback:onShutter...");
|
||||
}
|
||||
};
|
||||
Camera.PictureCallback mRawCallback = new Camera.PictureCallback() {
|
||||
public void onPictureTaken(byte[] data, Camera camera) {
|
||||
Logger.i(this, "myRawCallback:onPictureTaken...");
|
||||
|
||||
}
|
||||
};
|
||||
private CameraContract.View mView;
|
||||
private Camera mCamera;
|
||||
private Camera.Parameters mParams;
|
||||
private boolean isPreviewing = false;
|
||||
Camera.PictureCallback mJpegPictureCallback = new Camera.PictureCallback() {
|
||||
public void onPictureTaken(byte[] data, Camera camera) {
|
||||
Logger.i(this, "myJpegCallback:onPictureTaken...");
|
||||
|
||||
isPreviewing = false;
|
||||
mView.reviewMode(data);
|
||||
mView.onTakePicture(true);
|
||||
}
|
||||
};
|
||||
private boolean isAutoFocus = false;
|
||||
private int cameraMode;
|
||||
private String flashMode;
|
||||
private int rotation = -1;
|
||||
private boolean needBorder;
|
||||
|
||||
public CameraPresenter(CameraContract.View mView) {
|
||||
this.mView = mView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
mView.initializeViews();
|
||||
addMovementListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
stopCamera();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openCamera() {
|
||||
this.openCamera(cameraMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openCamera(int mode) {
|
||||
this.cameraMode = mode;
|
||||
int cameraId = mode;
|
||||
|
||||
if (cameraMode != BACK_CAMERA) {
|
||||
cameraId = CamParaUtil.getInstance().findFrontFacingCamera();
|
||||
}
|
||||
|
||||
try {
|
||||
this.isPreviewing = false;
|
||||
|
||||
if (mCamera != null) {
|
||||
mCamera.release();
|
||||
}
|
||||
mCamera = Camera.open(cameraId);
|
||||
mView.cameraHasOpened();
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPreview(SurfaceHolder holder, int width, int height, int quality) {
|
||||
Logger.i(this, "doStartPreview...");
|
||||
if (isPreviewing) {
|
||||
mCamera.stopPreview();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mCamera != null) {
|
||||
mParams = mCamera.getParameters();
|
||||
mParams.setPictureFormat(ImageFormat.JPEG);
|
||||
CamParaUtil.getInstance().printSupportPictureSize(mParams);
|
||||
CamParaUtil.getInstance().printSupportPreviewSize(mParams);
|
||||
|
||||
Camera.Size pictureSize = CamParaUtil.getInstance().
|
||||
getPropPictureSize(mParams.getSupportedPictureSizes(), width, height);
|
||||
mParams.setPictureSize(pictureSize.width, pictureSize.height);
|
||||
Camera.Size previewSize = CamParaUtil.getInstance().
|
||||
getPropPreviewSize(mParams.getSupportedPreviewSizes(), pictureSize.width, pictureSize.height);
|
||||
mParams.setPreviewSize(previewSize.width, previewSize.height);
|
||||
mParams.setJpegQuality(quality);
|
||||
if(needBorder)
|
||||
mParams.setRotation(90);
|
||||
|
||||
mCamera.setDisplayOrientation(90);
|
||||
|
||||
CamParaUtil.getInstance().printSupportFocusMode(mParams);
|
||||
List<String> focusModes = mParams.getSupportedFocusModes();
|
||||
if (focusModes.contains("continuous-picture")) {
|
||||
mParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||
}
|
||||
final List<String> supportedFlashMode = mParams.getSupportedFlashModes();
|
||||
if (supportedFlashMode != null && supportedFlashMode.size() != 0) {
|
||||
supportedFlashMode.remove(Camera.Parameters.FLASH_MODE_RED_EYE);
|
||||
supportedFlashMode.remove(Camera.Parameters.FLASH_MODE_TORCH);
|
||||
if (flashMode == null) flashMode = supportedFlashMode.get(0);
|
||||
|
||||
if (cameraMode == BACK_CAMERA) {
|
||||
mParams.setFlashMode(flashMode);
|
||||
}
|
||||
}
|
||||
|
||||
mCamera.setParameters(mParams);
|
||||
|
||||
try {
|
||||
mCamera.setPreviewDisplay(holder);
|
||||
mCamera.startPreview();
|
||||
isPreviewing = true;
|
||||
} catch (IOException e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mParams = mCamera.getParameters();
|
||||
Logger.i(this, "PreviewSize--With = " + mParams.getPreviewSize().width
|
||||
+ "Height = " + mParams.getPreviewSize().height);
|
||||
Logger.i(this, "PictureSize--With = " + mParams.getPictureSize().width
|
||||
+ "Height = " + mParams.getPictureSize().height);
|
||||
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
mView.onCameraPreview(mParams.getPreviewSize().width, mParams.getPreviewSize().height);
|
||||
mView.setSupportCameraParams(true, supportedFlashMode);
|
||||
mView.cameraMode(cameraMode, flashMode);
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumePreview() {
|
||||
if (mCamera != null) {
|
||||
mCamera.startPreview();
|
||||
isPreviewing = true;
|
||||
mView.cameraMode(cameraMode, flashMode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pausePreview() {
|
||||
if (mCamera != null) {
|
||||
mCamera.stopPreview();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopCamera() {
|
||||
if (mCamera != null) {
|
||||
mCamera.setPreviewCallback(null);
|
||||
mCamera.stopPreview();
|
||||
isPreviewing = false;
|
||||
mCamera.release();
|
||||
mCamera = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takePicture() {
|
||||
if (isPreviewing && (mCamera != null)) {
|
||||
mCamera.takePicture(mShutterCallback, mRawCallback, mJpegPictureCallback);
|
||||
mView.onTakePicture(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autoFocus(final MotionEvent event, CameraSurfaceView view) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) return; // deprecated
|
||||
if (!isPreviewing || cameraMode == Camera.CameraInfo.CAMERA_FACING_FRONT) return;
|
||||
|
||||
if (mCamera != null && mParams != null) {
|
||||
mCamera.cancelAutoFocus();
|
||||
Rect focusRect = DisplayUtil.calculateFocusArea(event.getX(), event.getY(),
|
||||
view.getWidth(), view.getHeight());
|
||||
|
||||
if (!mParams.getFocusMode().equals(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||
List<String> focusModes = mParams.getSupportedFocusModes();
|
||||
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||
mParams.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
|
||||
}
|
||||
}
|
||||
if (mParams.getMaxNumFocusAreas() > 0) {
|
||||
List<Camera.Area> mylist = new ArrayList<>();
|
||||
mylist.add(new Camera.Area(focusRect, 1000));
|
||||
mParams.setFocusAreas(mylist);
|
||||
}
|
||||
|
||||
try {
|
||||
mCamera.setParameters(mParams);
|
||||
mCamera.autoFocus(new Camera.AutoFocusCallback() {
|
||||
@Override
|
||||
public void onAutoFocus(boolean success, Camera camera) {
|
||||
if (!mCamera.getParameters().getFocusMode().equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
|
||||
isAutoFocus = false;
|
||||
AutoFocusItem.FocusMode mode = success ? AutoFocusItem.FocusMode.FOCUS_SUCCESS :
|
||||
AutoFocusItem.FocusMode.FOCUS_FAILED;
|
||||
mView.onAutoFocus(mode, event);
|
||||
}
|
||||
}
|
||||
});
|
||||
mView.onAutoFocus(AutoFocusItem.FocusMode.START_FOCUS, event);
|
||||
isAutoFocus = true;
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePicture(byte[] data) {
|
||||
Activity activity = ((Activity) mView.getContext());
|
||||
if (data != null) {
|
||||
try {
|
||||
Bitmap b = Utils.byteToBitmap(data);
|
||||
|
||||
Uri path = null;
|
||||
if (b != null) {
|
||||
File file = FileUtil.bitmapToFileConverter(activity, b);
|
||||
ExifUtil.setRotationToFileExif(file, ExifUtil.getOrientation(data));
|
||||
|
||||
path = Uri.fromFile(file);
|
||||
b.recycle();
|
||||
}
|
||||
|
||||
Intent intent = new Intent();
|
||||
if (path == null) {
|
||||
activity.setResult(Activity.RESULT_OK, intent);
|
||||
activity.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
intent.putExtra(CameraActivity.PICTURE_URI, path.toString());
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(CameraActivity.PICTURE_URI, path.toString());
|
||||
intent.putExtras(bundle);
|
||||
activity.setResult(Activity.RESULT_OK, intent);
|
||||
activity.finish();
|
||||
} catch (OutOfMemoryError | Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(activity, R.string.faild_save_image, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraModeChange(int mode) {
|
||||
if (mode == cameraMode) return;
|
||||
|
||||
this.cameraMode = mode;
|
||||
openCamera(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlashModeChange(String flashMode) {
|
||||
this.flashMode = flashMode;
|
||||
|
||||
if (mCamera == null || mParams == null) return;
|
||||
mParams.setFlashMode(flashMode);
|
||||
mCamera.setParameters(mParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOrientationChanged(int arg0) {
|
||||
try {
|
||||
Camera.CameraInfo info = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(cameraMode, info);
|
||||
arg0 = (arg0 + 45) / 90 * 90;
|
||||
int currentRotation;
|
||||
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
|
||||
currentRotation = (info.orientation - arg0 + 360) % 360;
|
||||
} else { // back-facing camera
|
||||
currentRotation = (info.orientation + arg0) % 360;
|
||||
}
|
||||
|
||||
if (rotation != currentRotation) {
|
||||
rotation = currentRotation;
|
||||
if (mParams != null && mCamera != null) {
|
||||
if (rotation >= 360) rotation %= 360;
|
||||
if (!needBorder) {
|
||||
mParams.setRotation(rotation);
|
||||
mCamera.setParameters(mParams);
|
||||
}
|
||||
}
|
||||
mView.onOrientationChanged(arg0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
if (!isPreviewing) {
|
||||
resumePreview();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addMovementListener() {
|
||||
MovementDetector.getInstance().addListener(new MovementDetector.Listener() {
|
||||
@Override
|
||||
public void onMotionDetected(SensorEvent event, float acceleration) {
|
||||
if (!isPreviewing || isAutoFocus || cameraMode == Camera.CameraInfo.CAMERA_FACING_FRONT)
|
||||
return;
|
||||
|
||||
if (!mCamera.getParameters().getFocusMode().equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
|
||||
List<String> focusModes = mParams.getSupportedFocusModes();
|
||||
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
|
||||
mParams.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
|
||||
}
|
||||
if (mParams.getMaxNumFocusAreas() > 0) {
|
||||
mParams.setFocusAreas(null);
|
||||
}
|
||||
mCamera.setParameters(mParams);
|
||||
|
||||
mView.onAutoFocus(AutoFocusItem.FocusMode.FOCUS_CONTINUOUS, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isNeedBorder() {
|
||||
return needBorder;
|
||||
}
|
||||
|
||||
public void setNeedBorder(boolean needBorder) {
|
||||
this.needBorder = needBorder;
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,10 @@
|
|||
package com.adins.mss.coll.api;
|
||||
|
||||
/**
|
||||
* Created by adityapurwa on 11/03/15.
|
||||
*/
|
||||
public interface SynchronizationCallback {
|
||||
void onSuccess();
|
||||
|
||||
void onFailed();
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/bgColor">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"
|
||||
android:background="@drawable/header"
|
||||
app:titleTextAppearance="?android:attr/textAppearanceSmall"
|
||||
app:popupTheme="@style/AppTheme" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardElevation="@dimen/card_shadow"
|
||||
android:layout_margin="@dimen/card_margin"
|
||||
android:layout_below="@id/toolbar"
|
||||
app:contentPadding="10dp"
|
||||
app:cardCornerRadius="5dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="Encrypt and Decrypt Options"
|
||||
android:id="@+id/textView14"
|
||||
android:textColor="@color/gradient_end"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Switch
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/textView14"
|
||||
android:layout_alignLeft="@id/textView14"
|
||||
android:text="Encrypt Connection"
|
||||
android:id="@+id/switchEncrypt"
|
||||
android:textColor="@color/fontColor"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:checked="false"
|
||||
android:paddingTop="5dp" />
|
||||
<Switch
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/switchEncrypt"
|
||||
android:layout_alignLeft="@id/switchEncrypt"
|
||||
android:text="Decrypt Connection"
|
||||
android:id="@+id/switchDecrypt"
|
||||
android:textColor="@color/fontColor"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:checked="false"
|
||||
android:paddingTop="5dp" />
|
||||
</RelativeLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardElevation="@dimen/card_shadow"
|
||||
android:layout_margin="@dimen/card_margin"
|
||||
android:layout_below="@id/cardView1"
|
||||
app:contentPadding="10dp"
|
||||
app:cardCornerRadius="5dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="Access Token Options"
|
||||
android:textColor="@color/gradient_end"
|
||||
android:textStyle="bold"
|
||||
android:id="@+id/textView11" />
|
||||
|
||||
<Switch
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/textView11"
|
||||
android:text="Using Access Token"
|
||||
android:textColor="@color/fontColor"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:id="@+id/switchAccessToken"
|
||||
android:checked="false"
|
||||
android:paddingTop="5dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layoutClientId"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/switchAccessToken">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="Client ID : "
|
||||
android:textColor="@color/fontColor"
|
||||
android:id="@+id/txtClientId" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:id="@+id/edtClientId"
|
||||
android:padding="10dp"
|
||||
android:textColor="@color/fontColor"/>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/cardView3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardElevation="@dimen/card_shadow"
|
||||
android:layout_margin="@dimen/card_margin"
|
||||
android:layout_below="@id/cardView2"
|
||||
app:contentPadding="10dp"
|
||||
app:cardCornerRadius="5dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="Developer Options"
|
||||
android:id="@+id/textView15"
|
||||
android:textColor="@color/gradient_end"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<Switch
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/textView15"
|
||||
android:layout_alignLeft="@id/textView15"
|
||||
android:text="Ignore Developer Validation"
|
||||
android:id="@+id/switchDevMode"
|
||||
android:textColor="@color/fontColor"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:checked="false"
|
||||
android:paddingTop="5dp" />
|
||||
</RelativeLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/btnSave"
|
||||
android:id="@+id/btnSave"
|
||||
android:background="@drawable/button_background"
|
||||
android:layout_margin="5dp"
|
||||
android:textColor="@color/fontColorWhite"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
Loading…
Add table
Add a link
Reference in a new issue