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,8 @@
package com.adins.mss.base.commons;
/**
* Created by Aditya Purwa on 1/13/2015.
*/
public interface HostedFragment {
public FragmentHost getHost();
}

View file

@ -0,0 +1,231 @@
package com.adins.mss.foundation.location;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.os.Build;
import android.text.format.DateFormat;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.LocationInfo;
import com.adins.mss.dao.User;
import com.adins.mss.logger.Logger;
import com.google.android.gms.location.LocationListener;
import org.acra.ACRA;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
/**
* @author gigin.ginanjar
*/
public class LocationListenerImpl implements LocationListener {
public static Location currentLocation;
private LocationInfo locationInfo = new LocationInfo();
private Context context;
public LocationListenerImpl(Context context) {
this.context = context;
}
@Override
public void onLocationChanged(Location location) {
String application = GlobalData.getSharedGlobalData().getAuditData().getApplication();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && location.isFromMockProvider()) {
if(context != null){
Intent intent = new Intent(context.getString(R.string.action_turn_off_mocklocation));
context.sendBroadcast(intent);
}
return;
}
if (location != null) {
Logger.d("LocationListenerImpl", "" + location.getLatitude() + " , " + location.getLongitude() + " , " + location.getAccuracy());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (!location.isFromMockProvider()) {
currentLocation = location;
LocationTrackingManager ltm = Global.LTM;
Global.FLAG_LOCATION_TYPE = 0; //Tracking
try {
locationInfo = ltm.getCurrentLocation(Global.FLAG_LOCATION_TRACKING);
} catch (Exception e){
FireCrash.log(e);
}
String lat = locationInfo.getLatitude();
String lng = locationInfo.getLongitude();
float accuracy = location.getAccuracy();
if (!String.valueOf(0d).equalsIgnoreCase(lat) && !String.valueOf(0d).equalsIgnoreCase(lng)) {
try {
if (accuracy <= GlobalData.getSharedGlobalData().getMaxAccuracySafely() && !Global.APPLICATION_ORDER.equals(application) && checkFlagTracking()) {
LocationTrackingManager.insertLocationInfoToDB(locationInfo);
}
} catch (Exception e) {
FireCrash.log(e);
}
}
int greenAccuracy = GlobalData.getSharedGlobalData().getGreenAccuracy();
if (greenAccuracy == 0)
greenAccuracy = 50;
int yellowAccuracy = GlobalData.getSharedGlobalData().getYellowAccuracy();
if (yellowAccuracy == 0)
yellowAccuracy = 200;
if (location.getAccuracy() <= greenAccuracy) {
LocationTrackingManager.setLocationStatus(2);
if (!Global.APPLICATION_ORDER.equals(application)) {
checkFlagTracking();
}
} else if (location.getAccuracy() > greenAccuracy && location.getAccuracy() <= yellowAccuracy) {
LocationTrackingManager.setLocationStatus(1);
} else {
LocationTrackingManager.setLocationStatus(0);
}
} else {
LocationTrackingManager.setLocationStatus(0);
}
} else {
currentLocation = location;
LocationTrackingManager ltm = Global.LTM;
Global.FLAG_LOCATION_TYPE = 0; //Tracking
locationInfo = ltm.getCurrentLocation(Global.FLAG_LOCATION_TRACKING);
String lat = locationInfo.getLatitude();
String lng = locationInfo.getLongitude();
float accuracy = location.getAccuracy();
if (!String.valueOf(0d).equalsIgnoreCase(lat) && !String.valueOf(0d).equalsIgnoreCase(lng)) {
try {
if (accuracy <= GlobalData.getSharedGlobalData().getMaxAccuracySafely() && !Global.APPLICATION_ORDER.equals(application) && checkFlagTracking()) {
LocationTrackingManager.insertLocationInfoToDB(locationInfo);
}
} catch (Exception e) {
FireCrash.log(e);
if (!Global.APPLICATION_ORDER.equals(application) && checkFlagTracking()) {
LocationTrackingManager.insertLocationInfoToDB(locationInfo);
}
}
}
int greenAccuracy = GlobalData.getSharedGlobalData().getGreenAccuracy();
if (greenAccuracy == 0)
greenAccuracy = 50;
int yellowAccuracy = GlobalData.getSharedGlobalData().getYellowAccuracy();
if (yellowAccuracy == 0)
yellowAccuracy = 200;
if (location.getAccuracy() <= greenAccuracy) {
LocationTrackingManager.setLocationStatus(2);
if (!Global.APPLICATION_ORDER.equals(application)) {
checkFlagTracking();
}
} else if (location.getAccuracy() > greenAccuracy && location.getAccuracy() <= yellowAccuracy) {
LocationTrackingManager.setLocationStatus(1);
} else {
LocationTrackingManager.setLocationStatus(0);
}
}
} else {
LocationTrackingManager.setLocationStatus(0);
}
Intent locationListener = new Intent(context.getString(R.string.action_location_listener));
context.sendBroadcast(locationListener);
}
/**
* Get Current Location which Good Accuracy
*
* @return <b>Location</b>
*/
public Location getCurrentLocation() {
return currentLocation;
}
public boolean checkFlagTracking() {
try {
User user = GlobalData.getSharedGlobalData().getUser();
String hourFromWebStart, hourFromWeb;
Calendar cal, calStart;
String trackingDays;
List trackingDaysList;
int thisDayInt = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
String thisDay;
thisDayInt -= 1;
thisDay = String.valueOf(thisDayInt);
if (null != user && null != user.getIs_tracking() && user.getIs_tracking().equals("1")) {
trackingDays = user.getTracking_days();
if (null != trackingDays) {
trackingDaysList = Arrays.asList(trackingDays.split(";"));
} else {
return false;
}
hourFromWebStart = user.getStart_time();
calStart = Calendar.getInstance();
if (null != hourFromWebStart) {
String[] hourSplitStart = hourFromWebStart.split(":");
int hourStart = Integer.parseInt(hourSplitStart[0]);
int minuteStart = Integer.parseInt(hourSplitStart[1]);
calStart.set(Calendar.HOUR_OF_DAY, hourStart);
calStart.set(Calendar.MINUTE, minuteStart);
} else {
return false;
}
hourFromWeb = user.getEnd_time();
cal = Calendar.getInstance();
if (null != hourFromWeb) {
String[] hourSplit = hourFromWeb.split(":");
int hour = Integer.parseInt(hourSplit[0]);
int minute = Integer.parseInt(hourSplit[1]);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
} else {
return false;
}
if (trackingDaysList.contains(thisDay)) {
if (Calendar.getInstance().after(calStart) && Calendar.getInstance().before(cal)) {
boolean b = Global.LTM.getIsConnected();
if (!b) {
Global.LTM.connectLocationClient();
}
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
} catch (Exception e) {
FireCrash.log(e);
ACRA.getErrorReporter().putCustomData("LocationListenerImpl", e.getMessage());
ACRA.getErrorReporter().putCustomData("LocationListenerImpl", DateFormat.format("yyyy.MM.dd G \'at\' HH:mm:ss z", Calendar.getInstance().getTime()).toString());
ACRA.getErrorReporter().handleSilentException(new Exception("Exception saat checkFlagTacking"));
}
return false;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
</vector>

View file

@ -0,0 +1,33 @@
package com.adins.mss.foundation.dialog.gitonway.lib.effects;
import android.view.View;
import com.adins.libs.nineoldandroids.animation.ObjectAnimator;
/*
* Copyright 2014 litao
* https://github.com/sd6352051/NiftyDialogEffects
*
* 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.
*/
public class SlideRight extends BaseEffects {
@Override
protected void setupAnimation(View view) {
getAnimatorSet().playTogether(
ObjectAnimator.ofFloat(view, "translationX", 300, 0).setDuration(mDuration),
ObjectAnimator.ofFloat(view, "alpha", 0, 1).setDuration(mDuration * 3 / 2)
);
}
}

View file

@ -0,0 +1,218 @@
package com.adins.mss.foundation.notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.media.AudioManager;
import android.media.RingtoneManager;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationCompat.Builder;
import java.util.Date;
/**
* @author bong.rk
*/
public class Notification {
private static Notification sharedNotification;
public static final String NOTIFICATION_CHANNEL_ID = "10001";
/**
* This one must be set before running showNotification method
*/
private static int defaultIcon;
/**
* Contructor to create object Notification
*/
private Notification() {
}
/**
* create or get sharedNotification as a singleton of this class
*
* @return static sharedNotification
*/
public static Notification getSharedNotification() {
if (sharedNotification == null)
sharedNotification = new Notification();
return sharedNotification;
}
/**
* To get static defaultIcon which has been set
*
* @return defaultIcon - int data type contain value of R.drawable which has been set
*/
private static int getDefaultIcon() {
return defaultIcon;
}
/**
* This defaultIcon must be set in order to make a notification
*
* @param defaultIcon - int data type contain value of R.drawable.
*/
public void setDefaultIcon(int defaultIcon) {
Notification.defaultIcon = defaultIcon;
}
/**
* Create and show notification on notification bar with no vibrate, no sound and no auto cancel notif.
* auto cancel notif is a method to clear notification after it is tapped.
* This method will set vibrate and autocancel to false
*
* @param context - application context from activity class.
* @param notifTitle - a String text to be a title of notification.
* @param message - a String text to be a message of notification.
* @param notifId - int data type as an identifier of a notification.
* <br>The new one will replace the old one if both of identifiers are same.
* <br>
* @param pendingIntent - pending intent of notification to run activity after notification is tapped.
* <br>Pending intent could contain more than one intent i.e. (bacwardintent, resultintent).
*/
public void showNotification(Context context, String notifTitle,
String message, int notifId, PendingIntent pendingIntent) {
showNotification(context, notifTitle, message, notifId, Vibrate.OFF, Tone.OFF, false, pendingIntent);
}
/**
* Create and show notification on notification bar with vibrate, sound and auto cancel notif.
* <br>Auto cancel notif is a method to clear notification after it is tapped.
* <br>
*
* @param context - application context from activity class.
* @param notifTitle - a String text to be a title of notification.
* @param message - a String text to be a message of notification.
* @param notifId - int data type as an identifier of a notification.
* <br>The new one will replace the old one if both of identifiers are same.
* <br>
* @param vibrate - enum Vibrate from this class to set kind of vibration
* @param tone - enum Tone from this class to set kind of sound
* @param autoClearNotif - boolean data type to clear notification automatically after it is tapped .
* @param pendingIntent - pending intent of notification to run activity after notification is tapped.
* <br>Pending intent could contain more than one intent i.e. (bacwardintent, resultintent).
*/
public void showNotification(Context context, String notifTitle,
String message, int notifId, Vibrate vibrate, Tone tone,
boolean autoClearNotif, PendingIntent pendingIntent) {
Builder mBuilder =
new NotificationCompat.Builder(context)
.setContentTitle(notifTitle)
.setContentText(message);
if (pendingIntent != null)
mBuilder.setContentIntent(pendingIntent);
mBuilder.setSmallIcon(getDefaultIcon());
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
switch (vibrate) {
case SHORT: {
// after a 100ms delay, vibrate for 500ms
mBuilder.setVibrate(new long[]{100, 500});
}
break;
case LONG: {
// after a 100ms delay, vibrate for 2000ms
mBuilder.setVibrate(new long[]{100, 2000});
}
break;
case TWICE: {
// after a 100ms delay, vibrate for 200ms, pause for 500 ms and
// then vibrate for 200ms.
mBuilder.setVibrate(new long[]{100, 200, 500, 200});
}
break;
default: {
// no vibration
mBuilder.setVibrate(new long[]{0});
}
break;
}
switch (tone) {
case OFF: {
// mute
mBuilder.setSound(RingtoneManager.getDefaultUri(0));
// notif.sound = Uri.parse("file:///sdcard/notification/ringer.mp3");
// notif.sound = Uri.withAppendedPath(Audio.Media.INTERNAL_CONTENT_URI, "6");
}
break;
case FORCE: {
mBuilder.setDefaults(android.app.Notification.DEFAULT_SOUND);
// enable vibrate and sound
am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
}
break;
default:
mBuilder.setDefaults(android.app.Notification.DEFAULT_SOUND);
break;
}
mBuilder.setWhen(new Date(System.currentTimeMillis()).getTime());
mBuilder.setTicker(message);
mBuilder.setAutoCancel(autoClearNotif);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)
{
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "NOTIFICATION_CHANNEL_NAME", importance);
assert nm != null;
mBuilder.setChannelId(NOTIFICATION_CHANNEL_ID);
nm.createNotificationChannel(notificationChannel);
}
nm.notify(notifId, mBuilder.build());
}
/**
* Clear a notification which has been made - based on notification id
*
* @param context - application context from activity class.
* @param notifId - int data type as an identifier of a notification.
*/
public void clearNotif(Context context, int notifId) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(notifId);
}
/**
* Clear all notifications which have been made
*
* @param context - application context from activity class.
*/
public void clearNotifAll(Context context) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancelAll();
}
/**
* These values will determine kind of vibration the application would make
* Need of permission to make a vibration on the device : Constant Value: "android.permission.VIBRATE"
* <br>OFF = no vibration
* <br>SHORT = short vibration fo 0.5 seconds
* <br>LONG = long vibration for 2 seconds
* <br>TWICE = 2 vibrations @ 0.2 seconds
*
* @author bong.rk
*/
public enum Vibrate {
OFF, SHORT, TWICE, LONG
}
/**
* These values will determine kind of sound the application would make
* <br>OFF - notification will make no sound
* <br>NORMAL - notification will make sound when Sound in the device is enabled
* <br>FORCE - notification will enable Sound and Vibration in the device, Vibration setting is determined by enum Vibrate
*/
public enum Tone {
OFF, NORMAL, FORCE
}
}

View file

@ -0,0 +1,162 @@
package org.acra.util;
import android.content.Context;
import android.os.Environment;
import android.os.StatFs;
import android.telephony.TelephonyManager;
import android.util.SparseArray;
import org.acra.ACRA;
import org.acra.ACRAConstants;
import java.io.File;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.text.SimpleDateFormat;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.Locale;
import static org.acra.ACRA.LOG_TAG;
/**
* Responsible for providing base utilities used when constructing the report.
* <p/>
*
* @author William Ferguson
* @since 4.3.0
*/
public final class ReportUtils {
/**
* Calculates the free memory of the device. This is based on an inspection of the filesystem, which in android
* devices is stored in RAM.
*
* @return Number of bytes available.
*/
public static long getAvailableInternalMemorySize() {
final File path = Environment.getDataDirectory();
final StatFs stat = new StatFs(path.getPath());
final long blockSize;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
blockSize = stat.getBlockSizeLong();
} else {
blockSize = stat.getBlockSize();
}
final long availableBlocks;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
availableBlocks = stat.getAvailableBlocksLong();
} else {
availableBlocks = stat.getAvailableBlocks();
}
return availableBlocks * blockSize;
}
/**
* Calculates the total memory of the device. This is based on an inspection of the filesystem, which in android
* devices is stored in RAM.
*
* @return Total number of bytes.
*/
public static long getTotalInternalMemorySize() {
final File path = Environment.getDataDirectory();
final StatFs stat = new StatFs(path.getPath());
final long blockSize;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
blockSize = stat.getBlockSizeLong();
} else {
blockSize = stat.getBlockSize();
}
final long totalBlocks;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
totalBlocks = stat.getBlockCountLong();
} else {
totalBlocks = stat.getBlockCount();
}
return totalBlocks * blockSize;
}
/**
* Returns the DeviceId according to the TelephonyManager.
*
* @param context Context for the application being reported.
* @return Returns the DeviceId according to the TelephonyManager or null if there is no TelephonyManager.
*/
public static String getDeviceId(Context context) {
try {
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return tm.getDeviceId();
} catch (RuntimeException e) {
ACRA.log.w(LOG_TAG, "Couldn't retrieve DeviceId for : " + context.getPackageName(), e);
return null;
}
}
public static String getApplicationFilePath(Context context) {
final File filesDir = context.getFilesDir();
if (filesDir != null) {
return filesDir.getAbsolutePath();
}
ACRA.log.w(LOG_TAG, "Couldn't retrieve ApplicationFilePath for : " + context.getPackageName());
return "Couldn't retrieve ApplicationFilePath";
}
/**
* Utility method used for debugging purposes, writes the content of a SparseArray to a String.
*
* @param sparseArray
* @return "{ key1 => value1, key2 => value2, ...}"
*/
public static String sparseArrayToString(SparseArray<?> sparseArray) {
StringBuilder result = new StringBuilder();
if (sparseArray == null) {
return "null";
}
result.append('{');
for (int i = 0; i < sparseArray.size(); i++) {
result.append(sparseArray.keyAt(i));
result.append(" => ");
if (sparseArray.valueAt(i) == null) {
result.append("null");
} else {
result.append(sparseArray.valueAt(i).toString());
}
if (i < sparseArray.size() - 1) {
result.append(", ");
}
}
result.append('}');
return result.toString();
}
public static String getLocalIpAddress() {
StringBuilder result = new StringBuilder();
boolean first = true;
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
if (!first) {
result.append('\n');
}
result.append(inetAddress.getHostAddress().toString());
first = false;
}
}
}
} catch (SocketException ex) {
ACRA.log.w(LOG_TAG, ex.toString());
}
return result.toString();
}
public static String getTimeString(GregorianCalendar time) {
SimpleDateFormat format = new SimpleDateFormat(ACRAConstants.DATE_TIME_FORMAT_STRING, Locale.ENGLISH);
return format.format(time.getTimeInMillis());
}
}