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,49 @@
<?xml version="1.0" encoding="utf-8"?>
<com.adins.mss.foundation.questiongenerator.form.QuestionView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/questionValidationLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:textAppearance="?android:attr/textAppearanceSmall"
android:weightSum="1">
<TextView
android:id="@+id/questionValidationLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0. label" />
<EditText
android:id="@+id/questionValidationAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.1"
android:hint="Nomor Telepon"
android:inputType="phone"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@drawable/edit_text_selector"
android:textColorHint="@color/shadowColor" />
<Button
android:id="@+id/btnCheckValidation"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="0.1"
android:background="@drawable/button_background"
android:text="Check"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/fontColorWhite" />
</LinearLayout>
</com.adins.mss.foundation.questiongenerator.form.QuestionView>

View file

@ -0,0 +1,23 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Crop.DoneCancelBar">
<FrameLayout
android:id="@+id/btn_cancel"
style="@style/Crop.ActionButton">
<TextView style="@style/Crop.ActionButtonText.Cancel" />
</FrameLayout>
<FrameLayout
android:id="@+id/btn_rotate"
android:visibility="gone"
style="@style/Crop.ActionButton">
<TextView style="@style/Crop.ActionButtonText.Rotate" />
</FrameLayout>
<FrameLayout
android:id="@+id/btn_done"
style="@style/Crop.ActionButton">
<TextView style="@style/Crop.ActionButtonText.Done" />
</FrameLayout>
</LinearLayout>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/fontColor"
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
</vector>

View file

@ -0,0 +1,33 @@
package com.adins.mss.foundation.sync.api;
import com.adins.mss.dao.Kompetisi;
import com.adins.mss.foundation.http.MssResponseType;
import com.google.gson.annotations.SerializedName;
import java.util.List;
class BeanResp extends MssResponseType {
@SerializedName("LIST_COMPETITION")
private List<Kompetisi> beanResp;
public List<Kompetisi> getBeanResp() {
return beanResp;
}
public void setBeanResp(List<Kompetisi> beanResp) {
this.beanResp = beanResp;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
@SerializedName("tableName")
private String tableName;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -0,0 +1,262 @@
/*
* Copyright 2010 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.sender;
import android.content.Context;
import android.net.Uri;
import org.acra.ACRA;
import org.acra.ACRAConfiguration;
import org.acra.ACRAConstants;
import org.acra.ReportField;
import org.acra.annotation.ReportsCrashes;
import org.acra.collector.CrashReportData;
import org.acra.util.HttpRequest;
import org.acra.util.JSONReportBuilder.JSONReportException;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import static org.acra.ACRA.LOG_TAG;
/**
* <p>
* The {@link ReportSender} used by ACRA when {@link ReportsCrashes#formUri()}
* has been defined in order to post crash data to a custom server-side data
* collection script. It sends all data in a POST request with parameters named
* with easy to understand names (basically a string conversion of
* {@link ReportField} enum values) or based on your own conversion Map from
* {@link ReportField} values to String.
* </p>
* <p>
* <p>
* To use specific POST parameter names, you can provide your own report fields
* mapping scheme:
* </p>
* <p>
* <pre>
* &#64;ReportsCrashes(...)
* public class myApplication extends Application {
*
* public void onCreate() {
* super.onCreate();
* ACRA.init(this);
* Map&lt;ReportField, String&gt; mapping = new HashMap&lt;ReportField, String&gt;();
* mapping.put(ReportField.APP_VERSION_CODE, &quot;myAppVerCode');
* mapping.put(ReportField.APP_VERSION_NAME, &quot;myAppVerName');
* //...
* mapping.put(ReportField.USER_EMAIL, &quot;userEmail');
* // remove any default report sender
* ErrorReporter.getInstance().removeAllReportSenders();
* // create your own instance with your specific mapping
* ErrorReporter.getInstance().addReportSender(new ReportSender(&quot;http://my.domain.com/reports/receiver.py&quot;, mapping));
* }
* }
* </pre>
*/
public class HttpSender implements ReportSender {
private final Uri mFormUri;
private final Map<ReportField, String> mMapping;
private final Method mMethod;
private final Type mType;
private String mUsername;
private String mPassword;
/**
* <p>
* Create a new HttpSender instance with its destination taken from
* {@link ACRA#getConfig()} dynamically. Configuration changes to the
* formUri are applied automatically.
* </p>
*
* @param method HTTP {@link Method} to be used to send data. Currently only
* {@link Method#POST} and {@link Method#PUT} are available. If
* {@link Method#PUT} is used, the {@link ReportField#REPORT_ID}
* is appended to the formUri to be compliant with RESTful APIs.
* @param type {@link Type} of encoding used to send the report body.
* {@link Type#FORM} is a simple Key/Value pairs list as defined
* by the application/x-www-form-urlencoded mime type.
* @param mapping Applies only to {@link Method#POST} method parameter. If null,
* POST parameters will be named with {@link ReportField} values
* converted to String with .toString(). If not null, POST
* parameters will be named with the result of
* mapping.get(ReportField.SOME_FIELD);
*/
public HttpSender(Method method, Type type, Map<ReportField, String> mapping) {
mMethod = method;
mFormUri = null;
mMapping = mapping;
mType = type;
mUsername = null;
mPassword = null;
}
/**
* <p>
* Create a new HttpPostSender instance with a fixed destination provided as
* a parameter. Configuration changes to the formUri are not applied.
* </p>
*
* @param method HTTP {@link Method} to be used to send data. Currently only
* {@link Method#POST} and {@link Method#PUT} are available. If
* {@link Method#PUT} is used, the {@link ReportField#REPORT_ID}
* is appended to the formUri to be compliant with RESTful APIs.
* @param type {@link Type} of encoding used to send the report body.
* {@link Type#FORM} is a simple Key/Value pairs list as defined
* by the application/x-www-form-urlencoded mime type.
* @param formUri The URL of your server-side crash report collection script.
* @param mapping Applies only to {@link Method#POST} method parameter. If null,
* POST parameters will be named with {@link ReportField} values
* converted to String with .toString(). If not null, POST
* parameters will be named with the result of
* mapping.get(ReportField.SOME_FIELD);
*/
public HttpSender(Method method, Type type, String formUri, Map<ReportField, String> mapping) {
mMethod = method;
mFormUri = Uri.parse(formUri);
mMapping = mapping;
mType = type;
mUsername = null;
mPassword = null;
}
/**
* <p>
* Set credentials for this HttpSender that override (if present) the ones
* set globally.
* </p>
*
* @param username The username to set for HTTP Basic Auth.
* @param password The password to set for HTTP Basic Auth.
*/
@SuppressWarnings("unused")
public void setBasicAuth(String username, String password) {
mUsername = username;
mPassword = password;
}
@Override
public void send(Context context, CrashReportData report) throws ReportSenderException {
try {
URL reportUrl = mFormUri == null ? new URL(ACRA.getConfig().formUri()) : new URL(mFormUri.toString());
ACRA.log.d(LOG_TAG, "Connect to " + reportUrl.toString());
final String login = mUsername != null ? mUsername : ACRAConfiguration.isNull(ACRA.getConfig().formUriBasicAuthLogin()) ? null : ACRA
.getConfig().formUriBasicAuthLogin();
final String password = mPassword != null ? mPassword : ACRAConfiguration.isNull(ACRA.getConfig().formUriBasicAuthPassword()) ? null : ACRA
.getConfig().formUriBasicAuthPassword();
final HttpRequest request = new HttpRequest();
request.setConnectionTimeOut(ACRA.getConfig().connectionTimeout());
request.setSocketTimeOut(ACRA.getConfig().socketTimeout());
request.setMaxNrRetries(ACRA.getConfig().maxNumberOfRequestRetries());
request.setLogin(login);
request.setPassword(password);
request.setHeaders(ACRA.getConfig().getHttpHeaders());
// Generate report body depending on requested type
final String reportAsString;
switch (mType) {
case JSON:
reportAsString = report.toJSON().toString();
break;
case FORM:
default:
final Map<String, String> finalReport = remap(report);
reportAsString = HttpRequest.getParamsAsFormString(finalReport);
break;
}
// Adjust URL depending on method
switch (mMethod) {
case POST:
break;
case PUT:
reportUrl = new URL(reportUrl.toString() + '/' + report.getProperty(ReportField.REPORT_ID));
break;
default:
throw new UnsupportedOperationException("Unknown method: " + mMethod.name());
}
request.send(context, reportUrl, mMethod, reportAsString, mType);
} catch (IOException e) {
throw new ReportSenderException("Error while sending " + ACRA.getConfig().reportType()
+ " report via Http " + mMethod.name(), e);
} catch (JSONReportException e) {
throw new ReportSenderException("Error while sending " + ACRA.getConfig().reportType()
+ " report via Http " + mMethod.name(), e);
}
}
private Map<String, String> remap(Map<ReportField, String> report) {
ReportField[] fields = ACRA.getConfig().customReportContent();
if (fields.length == 0) {
fields = ACRAConstants.DEFAULT_REPORT_FIELDS;
}
final Map<String, String> finalReport = new HashMap<String, String>(report.size());
for (ReportField field : fields) {
if (mMapping == null || mMapping.get(field) == null) {
finalReport.put(field.toString(), report.get(field));
} else {
finalReport.put(mMapping.get(field), report.get(field));
}
}
return finalReport;
}
/**
* Available HTTP methods to send data. Only POST and PUT are currently
* supported.
*/
public enum Method {
POST, PUT
}
/**
* Type of report data encoding, currently supports Html Form encoding and
* JSON.
*/
public enum Type {
/**
* Send data as a www form encoded list of key/values.
*
* @see <a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4">Form content types</a>
*/
FORM {
@Override
public String getContentType() {
return "application/x-www-form-urlencoded";
}
},
/**
* Send data as a structured JSON tree.
*/
JSON {
@Override
public String getContentType() {
return "application/json";
}
};
public abstract String getContentType();
}
}

View file

@ -0,0 +1,216 @@
package com.adins.mss.base.loyalti.sla;
import com.adins.mss.base.GlobalData;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.User;
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class LoyaltiSlaTimeHandler {
private boolean isTracking;
private int[] trackingDays;
private int[] startTimeDigit;
private int[] endTimeDigit;
private long slaTime;
public LoyaltiSlaTimeHandler() {
}
public LoyaltiSlaTimeHandler(int slaTime) {
this.slaTime = (long) slaTime * Global.HOUR;
//parsing tracking info from user properties
User user = GlobalData.getSharedGlobalData().getUser();
if (user == null) {
return;
}
//parse isTracking flag
isTracking = user.getIs_tracking() != null && user.getIs_tracking().equals("1");
//parse track days
String trackDays = user.getTracking_days() != null && !user.getTracking_days().isEmpty() ? user.getTracking_days() : null;
if (trackDays == null) {
return;
}
trackDays = trackDays.trim();
String[] trackDaysSplit = trackDays.split(";");
trackingDays = new int[trackDaysSplit.length];
for (int i = 0; i < trackDaysSplit.length; i++) {
trackingDays[i] = Integer.parseInt(trackDaysSplit[i]);
}
//parse start time
String startTimeStr = user.getStart_time();
startTimeStr = startTimeStr.trim();
String[] startTimePart = startTimeStr.split(":");
startTimeDigit = new int[2];
startTimeDigit[0] = Integer.parseInt(startTimePart[0]);
startTimeDigit[1] = Integer.parseInt(startTimePart[1]);
//parse end time
String endTimeStr = user.getEnd_time();
endTimeStr = endTimeStr.trim();
String[] endTimePart = endTimeStr.split(":");
endTimeDigit = new int[2];
endTimeDigit[0] = Integer.parseInt(endTimePart[0]);
endTimeDigit[1] = Integer.parseInt(endTimePart[1]);
}
public boolean isTracking() {
return isTracking;
}
public void enableTracking(boolean tracking) {
isTracking = tracking;
}
public int[] getTrackingDays() {
return trackingDays;
}
public void setTrackingDays(int[] trackingDays) {
this.trackingDays = trackingDays;
}
public int[] getStartTimeDigit() {
return startTimeDigit;
}
public void setStartTimeDigit(int[] startTimeDigit) {
this.startTimeDigit = startTimeDigit;
}
public int[] getEndTimeDigit() {
return endTimeDigit;
}
public void setEndTimeDigit(int[] endTimeDigit) {
this.endTimeDigit = endTimeDigit;
}
public long getSlaTime() {
return slaTime;
}
public void setSlaTime(long slaTime) {
this.slaTime = slaTime;
}
public String calculateSLATime(Date assignDate, String outputFormat) {
Calendar assignTime = Calendar.getInstance();
assignTime.setTime(assignDate);
Calendar assignTimeClone = (Calendar) assignTime.clone();
long totalSla = slaTime;
SlaTimeResult result = decreaseSLADuration(0, assignTimeClone, totalSla);
return result.getResult(assignTime, outputFormat);
}
public Date calculateSLATime(Date assignDate) {
Calendar assignTime = Calendar.getInstance();
assignTime.setTime(assignDate);
Calendar assignTimeClone = (Calendar) assignTime.clone();
long totalSla = slaTime;
SlaTimeResult result = decreaseSLADuration(0, assignTimeClone, totalSla);
return result.getResult(assignTime);
}
private SlaTimeResult decreaseSLADuration(int dayCounter, Calendar date, long slaDuration) {
long usedDuration = 0;
int day = date.get(Calendar.DAY_OF_WEEK) - 1;
if (needProcessSLA(day)) {
Calendar startTime = (Calendar) date.clone();
startTime.set(Calendar.HOUR_OF_DAY, startTimeDigit[0]);
startTime.set(Calendar.MINUTE, startTimeDigit[1]);
Calendar endTime = (Calendar) date.clone();
endTime.set(Calendar.HOUR_OF_DAY, endTimeDigit[0]);
endTime.set(Calendar.MINUTE, endTimeDigit[1]);
//check is before startTime
if (date.getTimeInMillis() <= startTime.getTimeInMillis()) {
usedDuration = endTime.getTimeInMillis() - startTime.getTimeInMillis();
} else if (date.getTimeInMillis() > startTime.getTimeInMillis() && date.getTimeInMillis() < endTime.getTimeInMillis()) {
usedDuration = endTime.getTimeInMillis() - date.getTimeInMillis();
}
slaDuration -= usedDuration;
if (slaDuration < 0) {
usedDuration = slaDuration + usedDuration;
slaDuration = 0;
}
}
if (slaDuration == 0) {
return new SlaTimeResult(dayCounter, usedDuration);
} else {
dayCounter += 1;
date.set(Calendar.HOUR_OF_DAY, startTimeDigit[0]);
date.set(Calendar.MINUTE, startTimeDigit[1]);
incrementDays(date, 1);
return decreaseSLADuration(dayCounter, date, slaDuration);
}
}
private void incrementDays(Calendar current, int inc) {
current.add(Calendar.DATE, inc);
}
private boolean needProcessSLA(int dayIdx) {
if (!isTracking || trackingDays == null || trackingDays.length == 0) {
return true;
}
for (int i = 0; i < trackingDays.length; i++) {
if (trackingDays[i] == dayIdx) {
return true;
}
}
return false;
}
class SlaTimeResult {
private int dayCounter;
private long usedDuration;
public SlaTimeResult(int dayCounter, long usedDuration) {
this.dayCounter = dayCounter;
this.usedDuration = usedDuration;
}
public String getResult(Calendar assignDate, String outputFormat) {
incrementDays(assignDate, dayCounter);
Calendar startTime = (java.util.Calendar) assignDate.clone();
startTime.set(Calendar.HOUR_OF_DAY, startTimeDigit[0]);
startTime.set(Calendar.MINUTE, startTimeDigit[1]);
if (dayCounter > 0 || (dayCounter == 0 && assignDate.before(startTime))) {
assignDate.set(Calendar.HOUR_OF_DAY, startTimeDigit[0]);
assignDate.set(Calendar.MINUTE, startTimeDigit[1]);
}
assignDate.add(Calendar.MILLISECOND, (int) usedDuration);
SimpleDateFormat dateFormat = new SimpleDateFormat(outputFormat, Locale.getDefault());
return dateFormat.format(assignDate.getTime());
}
public Date getResult(Calendar assignDate) {
incrementDays(assignDate, dayCounter);
if (dayCounter > 0) {
assignDate.set(Calendar.HOUR_OF_DAY, startTimeDigit[0]);
assignDate.set(Calendar.MINUTE, startTimeDigit[1]);
}
assignDate.add(Calendar.MILLISECOND, (int) usedDuration);
return assignDate.getTime();
}
}
}

View file

@ -0,0 +1,691 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\gigin.ginanjar\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
#-injars bin/classes
#-injars libs
##-outjars bin/classes-processed.jar
##-libraryjars "C:\Users\gigin.ginanjar\AppData\Local\Android\sdk/platforms\android-23/android.jar"
#
-dontpreverify
#-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic,!field
-keepattributes Signature
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod
-keep public class * extends android.app.Activity
-keep public class * extends androidx.fragment.app.Fragment
-keep public class * extends androidx.fragment.app.FragmentActivity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends androidx.appcompat.app.AppCompatActivity
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.NewMenuItem);
}
-keepclassmembers class * implements android.os.Parcelable {
static ** CREATOR;
}
#-keepclassmembers class **.R$* {
# public static <fields>;
#}
-keep class com.adins.mss.base.R$* {
public static <fields>;
}
-keepclassmembers class ** {
public static *** parse(***);
}
-keepclassmembers class ** {
public static <fields>;
}
-keep public class com.adins.mss.logger.Logger{
public <methods>;
}
### greenDAO 3
-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
public static java.lang.String TABLENAME;
}
-keep class **$Properties
# If you do not use SQLCipher:
-dontwarn org.greenrobot.greendao.database.**
# If you do not use RxJava:
-dontwarn rx.**
### greenDAO 2
-keepclassmembers class * extends de.greenrobot.dao.AbstractDao {
public static java.lang.String TABLENAME;
}
-keep class **$Properties
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-keepattributes InnerClasses
-dontwarn okio.**
-dontwarn com.androidquery.**
-dontwarn org.apache.commons.jexl2.**
-dontwarn com.fasterxml.uuid.**
-dontwarn org.bouncycastle.**
-dontwarn java.lang.**
-dontwarn fr.castorflex.android.smoothprogressbar.**
-dontwarn lib.gegemobile.**
-dontwarn uk.co.senab.actionbarpulltorefresh.library.**
-dontwarn zj.com.**
-dontwarn org.apache.**
-dontwarn com.pax.**
-dontwarn android.databinding.**
-keep class android.databinding.** { *; }
-keep class androidx.databinding.** { *; }
-keep class * extends androidx.databinding.DataBinderMapper { *; }
-keep class com.adins.mss.base.databinding.** { *; }
#Keep classes that are referenced on the AndroidManifest
-keep public class * extends androidx.appcompat.app.AppCompatActivity
-keep public class * extends com.adins.mss.base.MssFragmentActivity
-keep public class * extends androidx.fragment.app.Fragment
-keep public class * extends androidx.fragment.app.FragmentActivity
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keepclassmembers class * extends androidx.fragment.app.Fragment{
public void *(android.view.View);
}
-keep class com.androidquery.AQuery {
public protected <methods>;
public protected <fields>;
}
-keep class android.** { *; }
-keep class com.google.** { *; }
-keep class com.google.gson.JsonSyntaxException {public protected static *; }
-keep class org.acra.sender.HttpSender {
public protected <methods>;
public protected <fields>;
}
-keep class androidx.fragment.app.FragmentManager{
public protected <methods>;
public protected <fields>;
}
-keep class org.acra.annotation.** {*; }
-keep class org.acra.ReportField {*; }
-keep class org.acra.ReportingInteractionMode {*; }
-keep class org.acra.annotation.ReportsCrashes {public protected static *; }
-keep class org.acra.ErrorReporter {
public protected <methods>;
public protected <fields>;
}
-keep class java.lang.String {
public protected <methods>;
public protected <fields>;
}
-keep public enum org.acra.sender.HttpSender.Type$** {
*;
}
-keep public enum org.acra.sender.HttpSender.Method$** {
*;
}
-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class org.acra.annotation.** {*; }
-keep class org.acra.ReportField {*; }
-keep class org.acra.ReportingInteractionMode {*; }
-keep class org.acra.annotation.ReportsCrashes {public protected static *; }
-keep class org.acra.ErrorReporter {
public protected <methods>;
public protected <fields>;
}
-keep class java.lang.String {
public protected <methods>;
public protected <fields>;
}
-keepclassmembers,allowoptimization enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
#keep class for mss
#-keep class com.adins.foundation.**
-keep class com.adins.mss.dao.** {*;}
-keep class com.adins.mss.constant.** {*;}
-keep class com.adins.mss.base.crashlytics.** {*;}
-keep class com.adins.mss.foundation.** {*;}
-keep class com.adins.mss.foundation.db.dataaccess.** {*;}
-keep class com.adins.mss.base.login.DefaultLoginModel
-keep class com.squareup.okhttp.** {*;}
-keep class com.androidquery.** {*;}
-keep class android.view.animation.** {*;}
-keep class com.adins.mss.base.todolist.todayplanrepository.** {*;}
#Nendi: 17.12.2020
-keep class com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences {*;}
-keepclasseswithmembernames class com.adins.mss.base.commons.SecondHelper
-keep public class com.gadberry.** {*;}
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keep public class com.adins.mss.base.util.Utility{
public <methods>;
}
-keep class com.adins.mss.base.dynamictheme.DynamicTheme{
public <methods>;
}
-keep class com.soundcloud.android.crop.Crop{
public <methods>;
public public <fields>;
}
-keep class com.adins.mss.base.dynamictheme.ThemeLoader{
public <methods>;
public public <fields>;
}
-keep public interface com.adins.mss.base.dynamictheme.ThemeLoader$ColorSetLoaderCallback {*;}
-keep class com.adins.mss.base.dynamictheme.ThemeUtility{
public <methods>;
}
-keep public class com.adins.mss.base.util.EventBusHelper{
public <methods>;
}
-keep public class com.adins.mss.base.util.LocaleHelper{
public <methods>;
}
-keep public class com.adins.mss.base.checkin.CheckInManager{
public <methods>;
}
-keep public class com.adins.mss.base.errorhandler.ErrorMessageHandler{
public <methods>;
}
-keep public class com.adins.mss.base.errorhandler.IShowError{
public <methods>;
}
-keep class net.sqlcipher.** {
*;
}
-keep class com.zebra.** { *; }
-keep interface com.zebra.** { *; }
-keep class com.fasterxml.** { *; }
-keep interface com.fasterxml.** { *; }
-keep interface com.adins.libs.** { *; }
-keep class uk.co.deanwild.materialshowcaseview.** { *; }
-keep interface uk.co.deanwild.materialshowcaseview.** { *; }
-keep class com.adins.mss.base.commons.CommonImpl{
public <methods>;
}
-keep class com.adins.mss.base.tasklog.TaskLogImpl{
public <methods>;
}
-keep class com.adins.mss.base.commons.ViewImpl{
public <methods>;
}
-keep class com.adins.mss.base.commons.TaskListener{
public <methods>;
}
-keep class com.adins.mss.base.depositreport.TaskLogHelper{
public <methods>;
}
-keep class com.adins.mss.base.dynamicform.form.questions.viewholder.ImageQuestionViewHolder{
public <methods>;
}
-keep class com.adins.mss.base.timeline.Constants{
public <methods>;
}
-keep class com.adins.mss.base.dynamicform.TaskDBean{
public <methods>;
}
-keep class org.acra.ACRAConfiguration{
public <methods>;
}
-keep class com.services.ForegroundServiceNotification{
public <methods>;
}
-keep class com.services.SurveyAssignmentThread{
public <methods>;
}
-keep class com.adins.mss.base.commons.BackupManager{
public <methods>;
}
-keep class com.adins.mss.base.mainmenu.NewMenuItem{
public <methods>;
}
-keep class com.adins.mss.base.NewMainActivity{
public static <fields>;
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.AppContext {
public protected <methods>;
public protected <fields>;
}
-keep class org.acra.annotation.ReportsCrashes {
public protected <methods>;
public protected <fields>;
}
-keep class org.acra.ReportField {
public protected <methods>;
public protected <fields>;
}
-keep class org.acra.ReportingInteractionMode {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.GlobalData {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.util.GsonHelper {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.util.ExcludeFromGson{
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.dialog.NiftyDialogBuilder {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.http.HttpConnectionResult {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.http.HttpCryptedConnection {
public protected <methods>;
public protected <fields>;
}
-keep class org.acra.ACRA {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.http.KeyValue {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.http.MssResponseType {
public protected <methods>;
public protected <fields>;
}
-keep class androidx.fragment.app.Fragment {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.dao.TaskH {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.timeline.MapsViewer {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.dialog.DialogManager {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.formatter.Tool {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.image.Utils {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.mainmenu.MainMenuActivity {
public protected <methods>;
public protected <fields>;
}
-keep class androidx.fragment.app.FragmentActivity {
public protected <methods>;
public protected <fields>;
}
-keep class androidx.fragment.app.FragmentTransaction {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.dynamicform.JsonResponseSubmitTask {
public protected <methods>;
public protected <fields>;
}
-keep class com.mikepenz.aboutlibraries.entity.Library {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.dynamicform.CustomerFragment {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.dynamicform.SurveyHeaderBean {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.tasklog.TaskLogArrayAdapter {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.timeline.TimelineManager {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.todolist.ToDoList {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.todolist.form.JsonResponseTaskList {
public protected <methods>;
}
-keep class com.adins.mss.dao.Scheme {
public protected <methods>;
}
-keep class com.adins.mss.dao.User {
public protected <methods>;
}
-keep class com.adins.mss.foundation.db.dataaccess.SchemeDataAccess {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.db.dataaccess.TaskHDataAccess {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.db.dataaccess.TimelineDataAccess {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.db.dataaccess.TimelineTypeDataAccess {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.http.MssRequestType {
public protected <methods>;
}
-keep class com.mikepenz.aboutlibraries.entity.License {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.about.activity.AboutActivity {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.login.DefaultLoginModel {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.LoginActivity {
public protected <methods>;
public protected <fields>;
}
-keep class androidx.core.app.NotificationCompat {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.dynamicform.JsonRequestTaskD {
public protected <methods>;
}
-keep class com.adins.mss.base.dynamicform.JsonResponseTaskD {
public protected <methods>;
}
-keep class com.adins.mss.base.timeline.activity.Timeline_Activity {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.dao.TaskD {
public protected <methods>;
}
-keep class com.adins.mss.foundation.db.dataaccess.GeneralParameterDataAccess {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.db.dataaccess.TaskDDataAccess {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.notification.Notification {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.ChangePasswordFragment {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.mainmenu.MainMenuHelper {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.tasklog.TaskLogImplImpl {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.timeline.MenuAdapter {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.timeline.MenuModel {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.todo.form.GetSchemeTask {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.todolist.form.StatusSectionFragment {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.todolist.form.TaskListTask {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.todolist.form.TaskList_Fragment {
public protected <methods>;
public protected <fields>;
}
-keep class com.services.NotificationThread {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.todo.form.NewTaskActivity {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.todo.form.NewTaskAdapter {
public protected <methods>;
}
-keep class com.adins.mss.base.todolist.DoList {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.SynchronizeActivity {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.formatter.Formatter {
public protected <methods>;
public protected <fields>;
}
-keep class androidx.fragment.app.DialogFragment {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.dynamicform.Constant {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.dynamicform.DynamicFormActivity {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.dynamicform.SendResultActivity {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.base.dynamicform.TaskManager {
public protected <methods>;
public protected <fields>;
}
-keep class com.adins.mss.foundation.questiongenerator.QuestionBean {
public protected <methods>;
public protected <fields>;
}
-keep class com.google.gson.JsonSyntaxException {public protected static *; }
-keep class com.adins.mss.foundation.db.DaoOpenHelper {public protected static *; }
-keep class com.adins.mss.foundation.image.JsonResponseImage {public protected static *; }
-keep class com.adins.mss.svy.models.SurveyorSearchResponse {public protected static *;}
-keep class com.adins.mss.svy.reassignment.JsonResponseServer {
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.dynamicform.form.questions.OnQuestionClickListener{
public protected <methods>;
}
-keep public class com.adins.mss.base.dynamicform.form.questions.viewholder.ExpandableRecyclerView$GroupViewHolder{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.dynamicform.QuestionSetTask{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.libs.nineoldandroids.view.ViewHelper{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.dynamicform.form.questions.viewholder.ExpandableRecyclerView$Adapter{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.dialogfragments.NewTaskDialog{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.todolist.form.OnTaskListClickListener{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.authentication.Authentication{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.todolist.form.TasklistListener{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.dummy.userhelp_dummy.Adapter.NewTaskLogDummyAdapter{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.dynamicform.TaskManager$ApproveTaskOnBackground{
public protected <methods>;
public protected <fields>;
}
-keep public class com.adins.mss.base.dynamicform.TaskManager$VerifTaskOnBackground{
public protected <methods>;
public protected <fields>;
}
#Uncomment if using Serializable
-keepclassmembers class * implements java.io.Serializable {
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-keep class * implements java.io.Serializable {
public protected <fields>;
}
#Keep fields for Gson transactions
-keep public class * extends com.adins.mss.foundation.http.MssRequestType{
<fields>;
<methods>;
}
-keep public class * extends RecyclerView.Adapter{
<fields>;
<methods>;
}
-keep public class * extends com.adins.mss.foundation.http.MssResponseType{
<fields>;
<methods>;
}
-keep public class com.adins.mss.foundation.UserHelp.** {*;}

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<com.adins.mss.foundation.questiongenerator.form.QuestionView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/question_text_button_url_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/question_text_button_url_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0. Label"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<EditText
android:id="@+id/et_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:clickable="false"
android:inputType="none"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@drawable/edit_text_selector"
/>
<Button
android:id="@+id/btn_view"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/button_background"
android:gravity="center"
android:text="@string/btnView"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/fontColorWhite" />
</LinearLayout>
</com.adins.mss.foundation.questiongenerator.form.QuestionView>

View file

@ -0,0 +1,47 @@
package com.adins.mss.base.util;
import android.content.Context;
import com.adins.mss.base.AppContext;
import com.adins.mss.foundation.security.storepreferences.ObscuredSharedPreferences;
/**
* Created by angga.permadi on 8/3/2016.
*/
public class UserSession {
protected static final String PREF_NAME_USER_SESSION = "UserSession";
protected static final String PREF_APP_VERSION = "appVersion";
protected static final int APP_VERSION_DEF = 0;
protected static final String PREF_INVALID_TOKEN = "isInvalidToken";
protected static final boolean IS_INVALID_TOKEN_DEF = false;
private static ObscuredSharedPreferences preferences = ObscuredSharedPreferences.getPrefs(AppContext.getInstance().getApplicationContext()
, PREF_NAME_USER_SESSION, Context.MODE_PRIVATE);
private static ObscuredSharedPreferences.Editor preferencesEditor = preferences.edit();
public static int getAppVersion() {
return preferences.getInt(PREF_APP_VERSION, APP_VERSION_DEF);
}
public static void setAppVersion(int appVersion) {
preferencesEditor.putInt(PREF_APP_VERSION, appVersion).apply();
}
public static boolean needUpdateVersion() {
return getAppVersion() < AppContext.getInstance().getVersionCode();
}
public static boolean isInvalidToken() {
return preferences.getBoolean(PREF_INVALID_TOKEN, IS_INVALID_TOKEN_DEF);
}
public static void setInvalidToken(boolean invalidToken) {
preferencesEditor.putBoolean(PREF_INVALID_TOKEN, invalidToken).apply();
}
public static void clear() {
preferencesEditor.remove(PREF_INVALID_TOKEN).apply();
// clear().apply();
}
}

View file

@ -0,0 +1,511 @@
/*
* Copyright 2013, Edmodo, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License.
* You may obtain a copy of the License in the LICENSE file, or at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package com.edmodo.cropper;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.media.ExifInterface;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.adins.mss.base.R;
import com.edmodo.cropper.cropwindow.CropOverlayView;
import com.edmodo.cropper.cropwindow.edge.Edge;
import com.edmodo.cropper.util.ImageViewUtil;
/**
* Custom view that provides cropping capabilities to an image.
*/
public class CropImageView extends FrameLayout {
// Private Constants ///////////////////////////////////////////////////////
// Sets the default image guidelines to show when resizing
public static final int DEFAULT_GUIDELINES = 1;
// Member Variables ////////////////////////////////////////////////////////
public static final boolean DEFAULT_FIXED_ASPECT_RATIO = false;
public static final int DEFAULT_ASPECT_RATIO_X = 1;
public static final int DEFAULT_ASPECT_RATIO_Y = 1;
private static final Rect EMPTY_RECT = new Rect();
private static final int DEFAULT_IMAGE_RESOURCE = 0;
private static final String DEGREES_ROTATED = "DEGREES_ROTATED";
private ImageView mImageView;
private CropOverlayView mCropOverlayView;
private Bitmap mBitmap;
private int mDegreesRotated = 0;
private int mLayoutWidth;
private int mLayoutHeight;
// Instance variables for customizable attributes
private int mGuidelines = DEFAULT_GUIDELINES;
private boolean mFixAspectRatio = DEFAULT_FIXED_ASPECT_RATIO;
private int mAspectRatioX = DEFAULT_ASPECT_RATIO_X;
private int mAspectRatioY = DEFAULT_ASPECT_RATIO_Y;
private int mImageResource = DEFAULT_IMAGE_RESOURCE;
// Constructors ////////////////////////////////////////////////////////////
public CropImageView(Context context) {
super(context);
init(context);
}
public CropImageView(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CropImageView, 0, 0);
try {
mGuidelines = ta.getInteger(R.styleable.CropImageView_guidelines, DEFAULT_GUIDELINES);
mFixAspectRatio = ta.getBoolean(R.styleable.CropImageView_fixAspectRatio,
DEFAULT_FIXED_ASPECT_RATIO);
mAspectRatioX = ta.getInteger(R.styleable.CropImageView_aspectRatioX, DEFAULT_ASPECT_RATIO_X);
mAspectRatioY = ta.getInteger(R.styleable.CropImageView_aspectRatioY, DEFAULT_ASPECT_RATIO_Y);
mImageResource = ta.getResourceId(R.styleable.CropImageView_imageResource, DEFAULT_IMAGE_RESOURCE);
} finally {
ta.recycle();
}
init(context);
}
// View Methods ////////////////////////////////////////////////////////////
/**
* Determines the specs for the onMeasure function. Calculates the width or height
* depending on the mode.
*
* @param measureSpecMode The mode of the measured width or height.
* @param measureSpecSize The size of the measured width or height.
* @param desiredSize The desired size of the measured width or height.
* @return The final size of the width or height.
*/
private static int getOnMeasureSpec(int measureSpecMode, int measureSpecSize, int desiredSize) {
// Measure Width
int spec;
if (measureSpecMode == MeasureSpec.EXACTLY) {
// Must be this size
spec = measureSpecSize;
} else if (measureSpecMode == MeasureSpec.AT_MOST) {
// Can't be bigger than...; match_parent value
spec = Math.min(desiredSize, measureSpecSize);
} else {
// Be whatever you want; wrap_content
spec = desiredSize;
}
return spec;
}
@Override
public Parcelable onSaveInstanceState() {
final Bundle bundle = new Bundle();
bundle.putParcelable("instanceState", super.onSaveInstanceState());
bundle.putInt(DEGREES_ROTATED, mDegreesRotated);
return bundle;
}
@Override
public void onRestoreInstanceState(Parcelable state) {
if (state instanceof Bundle) {
final Bundle bundle = (Bundle) state;
if (mBitmap != null) {
// Fixes the rotation of the image when orientation changes.
mDegreesRotated = bundle.getInt(DEGREES_ROTATED);
int tempDegrees = mDegreesRotated;
rotateImage(mDegreesRotated);
mDegreesRotated = tempDegrees;
}
super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
} else {
super.onRestoreInstanceState(state);
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if (mBitmap != null) {
final Rect bitmapRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap, this);
mCropOverlayView.setBitmapRect(bitmapRect);
} else {
mCropOverlayView.setBitmapRect(EMPTY_RECT);
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
if (mBitmap != null) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// Bypasses a baffling bug when used within a ScrollView, where
// heightSize is set to 0.
if (heightSize == 0)
heightSize = mBitmap.getHeight();
int desiredWidth;
int desiredHeight;
double viewToBitmapWidthRatio = Double.POSITIVE_INFINITY;
double viewToBitmapHeightRatio = Double.POSITIVE_INFINITY;
// Checks if either width or height needs to be fixed
if (widthSize < mBitmap.getWidth()) {
viewToBitmapWidthRatio = (double) widthSize / (double) mBitmap.getWidth();
}
if (heightSize < mBitmap.getHeight()) {
viewToBitmapHeightRatio = (double) heightSize / (double) mBitmap.getHeight();
}
// If either needs to be fixed, choose smallest ratio and calculate
// from there
if (viewToBitmapWidthRatio != Double.POSITIVE_INFINITY || viewToBitmapHeightRatio != Double.POSITIVE_INFINITY) {
if (viewToBitmapWidthRatio <= viewToBitmapHeightRatio) {
desiredWidth = widthSize;
desiredHeight = (int) (mBitmap.getHeight() * viewToBitmapWidthRatio);
} else {
desiredHeight = heightSize;
desiredWidth = (int) (mBitmap.getWidth() * viewToBitmapHeightRatio);
}
}
// Otherwise, the picture is within frame layout bounds. Desired
// width is
// simply picture size
else {
desiredWidth = mBitmap.getWidth();
desiredHeight = mBitmap.getHeight();
}
int width = getOnMeasureSpec(widthMode, widthSize, desiredWidth);
int height = getOnMeasureSpec(heightMode, heightSize, desiredHeight);
mLayoutWidth = width;
mLayoutHeight = height;
final Rect bitmapRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap.getWidth(),
mBitmap.getHeight(),
mLayoutWidth,
mLayoutHeight);
mCropOverlayView.setBitmapRect(bitmapRect);
// MUST CALL THIS
setMeasuredDimension(mLayoutWidth, mLayoutHeight);
} else {
mCropOverlayView.setBitmapRect(EMPTY_RECT);
setMeasuredDimension(widthSize, heightSize);
}
}
// Public Methods //////////////////////////////////////////////////////////
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (mLayoutWidth > 0 && mLayoutHeight > 0) {
// Gets original parameters, and creates the new parameters
final ViewGroup.LayoutParams origparams = this.getLayoutParams();
origparams.width = mLayoutWidth;
origparams.height = mLayoutHeight;
setLayoutParams(origparams);
}
}
/**
* Returns the integer of the imageResource
*
* @param int the image resource id
*/
public int getImageResource() {
return mImageResource;
}
/**
* Sets a Drawable as the content of the CropImageView.
*
* @param resId the drawable resource ID to set
*/
public void setImageResource(int resId) {
if (resId != 0) {
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resId);
setImageBitmap(bitmap);
}
}
/**
* Sets a Bitmap as the content of the CropImageView.
*
* @param bitmap the Bitmap to set
*/
public void setImageBitmap(Bitmap bitmap) {
mBitmap = bitmap;
mImageView.setImageBitmap(mBitmap);
if (mCropOverlayView != null) {
mCropOverlayView.resetCropOverlayView();
}
}
/**
* Sets a Bitmap and initializes the image rotation according to the EXIT data.
* <p>
* The EXIF can be retrieved by doing the following:
* <code>ExifInterface exif = new ExifInterface(path);</code>
*
* @param bitmap the original bitmap to set; if null, this
* @param exif the EXIF information about this bitmap; may be null
*/
public void setImageBitmap(Bitmap bitmap, ExifInterface exif) {
if (bitmap == null) {
return;
}
if (exif == null) {
setImageBitmap(bitmap);
return;
}
final Matrix matrix = new Matrix();
final int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
int rotate = -1;
switch (orientation) {
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
if (rotate == -1) {
setImageBitmap(bitmap);
} else {
matrix.postRotate(rotate);
final Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap,
0,
0,
bitmap.getWidth(),
bitmap.getHeight(),
matrix,
true);
setImageBitmap(rotatedBitmap);
if (bitmap != null && !bitmap.isRecycled()) {
bitmap.recycle();
bitmap = null;
}
}
}
/**
* Gets the cropped image based on the current crop window.
*
* @return a new Bitmap representing the cropped image
*/
public Bitmap getCroppedImage() {
final Rect displayedImageRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap, mImageView);
// Get the scale factor between the actual Bitmap dimensions and the
// displayed dimensions for width.
final float actualImageWidth = mBitmap.getWidth();
final float displayedImageWidth = displayedImageRect.width();
final float scaleFactorWidth = actualImageWidth / displayedImageWidth;
// Get the scale factor between the actual Bitmap dimensions and the
// displayed dimensions for height.
final float actualImageHeight = mBitmap.getHeight();
final float displayedImageHeight = displayedImageRect.height();
final float scaleFactorHeight = actualImageHeight / displayedImageHeight;
// Get crop window position relative to the displayed image.
final float cropWindowX = Edge.LEFT.getCoordinate() - displayedImageRect.left;
final float cropWindowY = Edge.TOP.getCoordinate() - displayedImageRect.top;
final float cropWindowWidth = Edge.getWidth();
final float cropWindowHeight = Edge.getHeight();
// Scale the crop window position to the actual size of the Bitmap.
final float actualCropX = cropWindowX * scaleFactorWidth;
final float actualCropY = cropWindowY * scaleFactorHeight;
final float actualCropWidth = cropWindowWidth * scaleFactorWidth;
final float actualCropHeight = cropWindowHeight * scaleFactorHeight;
// Crop the subset from the original Bitmap.
final Bitmap croppedBitmap = Bitmap.createBitmap(mBitmap,
(int) actualCropX,
(int) actualCropY,
(int) actualCropWidth,
(int) actualCropHeight);
return croppedBitmap;
}
/**
* Gets the crop window's position relative to the source Bitmap (not the image
* displayed in the CropImageView).
*
* @return a RectF instance containing cropped area boundaries of the source Bitmap
*/
public RectF getActualCropRect() {
final Rect displayedImageRect = ImageViewUtil.getBitmapRectCenterInside(mBitmap, mImageView);
// Get the scale factor between the actual Bitmap dimensions and the
// displayed dimensions for width.
final float actualImageWidth = mBitmap.getWidth();
final float displayedImageWidth = displayedImageRect.width();
final float scaleFactorWidth = actualImageWidth / displayedImageWidth;
// Get the scale factor between the actual Bitmap dimensions and the
// displayed dimensions for height.
final float actualImageHeight = mBitmap.getHeight();
final float displayedImageHeight = displayedImageRect.height();
final float scaleFactorHeight = actualImageHeight / displayedImageHeight;
// Get crop window position relative to the displayed image.
final float displayedCropLeft = Edge.LEFT.getCoordinate() - displayedImageRect.left;
final float displayedCropTop = Edge.TOP.getCoordinate() - displayedImageRect.top;
final float displayedCropWidth = Edge.getWidth();
final float displayedCropHeight = Edge.getHeight();
// Scale the crop window position to the actual size of the Bitmap.
float actualCropLeft = displayedCropLeft * scaleFactorWidth;
float actualCropTop = displayedCropTop * scaleFactorHeight;
float actualCropRight = actualCropLeft + displayedCropWidth * scaleFactorWidth;
float actualCropBottom = actualCropTop + displayedCropHeight * scaleFactorHeight;
// Correct for floating point errors. Crop rect boundaries should not
// exceed the source Bitmap bounds.
actualCropLeft = Math.max(0f, actualCropLeft);
actualCropTop = Math.max(0f, actualCropTop);
actualCropRight = Math.min(mBitmap.getWidth(), actualCropRight);
actualCropBottom = Math.min(mBitmap.getHeight(), actualCropBottom);
final RectF actualCropRect = new RectF(actualCropLeft,
actualCropTop,
actualCropRight,
actualCropBottom);
return actualCropRect;
}
/**
* Sets whether the aspect ratio is fixed or not; true fixes the aspect ratio, while
* false allows it to be changed.
*
* @param fixAspectRatio Boolean that signals whether the aspect ratio should be
* maintained.
*/
public void setFixedAspectRatio(boolean fixAspectRatio) {
mCropOverlayView.setFixedAspectRatio(fixAspectRatio);
}
/**
* Sets the guidelines for the CropOverlayView to be either on, off, or to show when
* resizing the application.
*
* @param guidelines Integer that signals whether the guidelines should be on, off, or
* only showing when resizing.
*/
public void setGuidelines(int guidelines) {
mCropOverlayView.setGuidelines(guidelines);
}
/**
* Sets the both the X and Y values of the aspectRatio.
*
* @param aspectRatioX int that specifies the new X value of the aspect ratio
* @param aspectRatioX int that specifies the new Y value of the aspect ratio
*/
public void setAspectRatio(int aspectRatioX, int aspectRatioY) {
mAspectRatioX = aspectRatioX;
mCropOverlayView.setAspectRatioX(mAspectRatioX);
mAspectRatioY = aspectRatioY;
mCropOverlayView.setAspectRatioY(mAspectRatioY);
}
// Private Methods /////////////////////////////////////////////////////////
/**
* Rotates image by the specified number of degrees clockwise. Cycles from 0 to 360
* degrees.
*
* @param degrees Integer specifying the number of degrees to rotate.
*/
public void rotateImage(int degrees) {
Matrix matrix = new Matrix();
matrix.postRotate(degrees);
mBitmap = Bitmap.createBitmap(mBitmap, 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, true);
setImageBitmap(mBitmap);
mDegreesRotated += degrees;
mDegreesRotated = mDegreesRotated % 360;
}
private void init(Context context) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View v = inflater.inflate(R.layout.crop_image_view, this, true);
mImageView = (ImageView) v.findViewById(R.id.ImageView_image);
setImageResource(mImageResource);
mCropOverlayView = (CropOverlayView) v.findViewById(R.id.CropOverlayView);
mCropOverlayView.setInitialAttributeValues(mGuidelines, mFixAspectRatio, mAspectRatioX, mAspectRatioY);
}
}