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,68 @@
package com.adins.mss.base.commons;
import android.app.Activity;
import android.view.Menu;
/**
* Created by kusnendi.muhamad on 31/07/2017.
*/
public class ViewImpl extends CommonImpl implements ViewInterface, TaskListener {
public Activity activity;
public ViewImpl(Activity activity) {
this.activity = activity;
}
@Override
public void publish() {
}
@Override
public void onCreate() {
//Initialize GPS Setting
checkGPS(true);
}
@Override
public void onResume() {
//Initialize GPS Setting
checkGPS(true);
}
@Override
public void onDestroy() {
}
@Override
public void onCreateOptionsMenu(Menu menu) {
}
@Override
public void onOptionsItemSelected(int id) {
}
@Override
public void onCompleteTask(Object result) {
}
@Override
public void onCancelTask(boolean value) {
}
@Override
public void onLocalData(Object result) {
}
@Override
public void checkGPS(boolean value) {
// if (value) showGPSAlert(activity);
}
}

View file

@ -0,0 +1,227 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bgColor" >
<androidx.cardview.widget.CardView
android:id="@+id/summaryContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:cardCornerRadius="10dp"
app:contentPadding="10dp"
app:cardElevation="@dimen/card_shadow"
android:layout_margin="@dimen/card_margin"
app:cardBackgroundColor="@color/fontColorWhite">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/summary_kunjungan"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
android:textColor="@color/colorMC"
android:paddingBottom="10dp"
android:layout_marginLeft="2dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textAppearance="?android:attr/textAppearanceSmall"
android:paddingBottom="10dp"
android:textStyle="bold"
android:textColor="@color/colorMC"/>
<TextView
android:id="@+id/txtDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dummy_tanggal"
android:textAppearance="?android:attr/textAppearanceSmall"
android:paddingBottom="10dp"
android:textStyle="bold"
android:textColor="@color/colorMC"/>
</LinearLayout>
<LinearLayout
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="horizontal">
<TextView
android:id="@+id/lblCollected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/label_total_collected"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_cash_color"
android:drawablePadding="5dp"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="@color/timelineLine" />
<TextView
android:id="@+id/txtCollected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="@string/dummy_total_collected"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="end"
android:textAlignment="textEnd"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/lblPaid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/label_total_paid"
android:textAppearance="?android:attr/textAppearanceSmall"
android:drawableLeft="@drawable/ic_cash_color"
android:drawablePadding="5dp"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:background="@color/timelineLine" />
<TextView
android:id="@+id/txtPaid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:paddingBottom="5dp"
android:text="@string/dummy_total_paid"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_gravity="end"
android:textAlignment="textEnd"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/detailContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:contentPadding="7dp"
app:cardElevation="@dimen/card_shadow"
android:layout_margin="@dimen/card_margin"
app:cardBackgroundColor="@color/fontColorWhite">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<TableLayout
android:id="@+id/tableSummary"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:gravity="center_horizontal"
android:text="@string/label_agreement_no"
android:textAppearance="?android:attr/textAppearanceSmall"
android:paddingTop="5dp"
android:paddingBottom="5dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/timelineLine" />
<TextView
android:gravity="center_horizontal"
android:text="@string/label_status"
android:textAppearance="?android:attr/textAppearanceSmall"
android:paddingTop="5dp"
android:paddingBottom="5dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/timelineLine" />
<TextView
android:gravity="center_horizontal"
android:text="@string/label_result"
android:textAppearance="?android:attr/textAppearanceSmall"
android:paddingTop="5dp"
android:paddingBottom="5dp" />
</TableRow>
<TableRow>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/timelineLine"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/timelineLine"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/timelineLine"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/timelineLine"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/timelineLine"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="5dp">
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/timelineLine" />
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/timelineLine" />
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
</TableRow>
</TableLayout>
</HorizontalScrollView>
</ScrollView>
</androidx.cardview.widget.CardView>
</LinearLayout>

View file

@ -0,0 +1,362 @@
package com.adins.mss.coll.fragments;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.Keep;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.checkin.CheckInManager;
import com.adins.mss.base.commons.SecondHelper;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.util.LocaleHelper;
import com.adins.mss.coll.R;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.DepositReportD;
import com.adins.mss.dao.DepositReportH;
import com.adins.mss.dao.PrintResult;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.UserHelp.UserHelp;
import com.adins.mss.foundation.db.dataaccess.PrintResultDataAccess;
import com.adins.mss.foundation.db.dataaccess.TaskHDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.image.Utils;
import com.adins.mss.foundation.image.ViewImageActivity;
import com.adins.mss.foundation.location.UpdateMenuIcon;
import com.androidquery.AQuery;
import com.google.firebase.analytics.FirebaseAnalytics;
import org.acra.ACRA;
import java.util.List;
import java.util.Locale;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.adins.mss.constant.Global.SHOW_USERHELP_DELAY_DEFAULT;
public class DepositReportDetailActivity extends AppCompatActivity{
public static DepositReportH report;
protected int total = 0;
List<DepositReportD> reportDs;
String cashierName;
String bankAccount;
// Local Bluetooth adapter
private BluetoothAdapter mBluetoothAdapter = null;
private FirebaseAnalytics screenName;
@Override
public void onBackPressed() {
if(!Global.BACKPRESS_RESTRICTION) {
super.onBackPressed();
try {
this.getFragmentManager().popBackStack();
} catch (Exception e) {
for (int i = 1; i < this.getFragmentManager().getBackStackEntryCount(); i++)
this.getFragmentManager().popBackStack();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(com.adins.mss.base.R.menu.main_menu, menu);
mainMenu = menu;
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
updateMenuIcon(Global.isGPS);
if(Global.ENABLE_USER_HELP &&
(Global.userHelpGuide.get(DepositReportDetailActivity.this.getClass().getSimpleName())!=null) ||
Global.userHelpDummyGuide.get(DepositReportDetailActivity.this.getClass().getSimpleName()) != null){
menu.findItem(com.adins.mss.base.R.id.mnGuide).setVisible(true);
}
return super.onPrepareOptionsMenu(menu);
}
private static Menu mainMenu;
public static void updateMenuIcon(boolean isGPS) {
UpdateMenuIcon uItem = new UpdateMenuIcon();
uItem.updateGPSIcon(mainMenu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == com.adins.mss.base.R.id.mnGPS) {
if (Global.LTM != null) {
if (Global.LTM.getIsConnected()) {
Global.LTM.removeLocationListener();
Global.LTM.connectLocationClient();
} else {
CheckInManager.startGPSTracking(getApplicationContext());
}
Animation a = AnimationUtils.loadAnimation(this, com.adins.mss.base.R.anim.gps_rotate);
findViewById(com.adins.mss.base.R.id.mnGPS).startAnimation(a);
}
}
if(id == com.adins.mss.base.R.id.mnGuide && !Global.BACKPRESS_RESTRICTION){
UserHelp.reloadUserHelp(getApplicationContext(), DepositReportDetailActivity.this);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
UserHelp.showAllUserHelp(DepositReportDetailActivity.this, DepositReportDetailActivity.this.getClass().getSimpleName());
}
}, SHOW_USERHELP_DELAY_DEFAULT);
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.new_activity_deposit_report_detail);
screenName = FirebaseAnalytics.getInstance(this);
Toolbar toolbar = (Toolbar) findViewById(com.adins.mss.base.R.id.toolbar);
toolbar.setTitle(getString(R.string.title_mn_depositreport));
toolbar.setTitleTextColor(getResources().getColor(com.adins.mss.base.R.color.fontColorWhite));
setSupportActionBar(toolbar);
AQuery query = new AQuery(this);
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
cashierName = report.getCashier_name();
bankAccount = report.getBank_account();
reportDs = report.getDepositReportDList();
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
query.id(R.id.txtBatchId).text(report.getBatch_id());
if(cashierName!=null&&cashierName.length()>0){
query.id(R.id.txttransferBy).text("Cashier");
query.id(R.id.txtCashierName).text(cashierName);
query.id(R.id.rowBankName).visibility(View.GONE);
query.id(R.id.rowAccountNumber).visibility(View.GONE);
query.id(R.id.rowEvidenceTransfer).visibility(View.GONE);
}else{
query.id(R.id.txttransferBy).text("Bank");
query.id(R.id.rowCashierName).visibility(View.GONE);
query.id(R.id.txtBankName).text(report.getBank_name());
query.id(R.id.txtAccountNumber).text(report.getBank_account());
query.id(R.id.imgEvidenceTransfer).image(Utils.byteToBitmap(report.getImage())).clicked(this, "ViewImage");
}
ImageButton btnPrintDepReport = (ImageButton)findViewById(R.id.btnPrintDepReport);
btnPrintDepReport.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mBluetoothAdapter.isEnabled()){
mBluetoothAdapter.enable();
Toast.makeText(DepositReportDetailActivity.this, getString(R.string.bluetooth_message), Toast.LENGTH_SHORT).show();
}else{
SecondHelper.PrintParams printParams = new SecondHelper.PrintParams(report.getBatch_id(), null, true, null);
SecondHelper.Companion.doPrint(v.getContext(), printParams);
}
}
});
TableLayout detailTable = (TableLayout)findViewById(R.id.tableLayout1);
LayoutParams lp =new LayoutParams(MATCH_PARENT, MATCH_PARENT,0.25f);
LinearLayout detail = new LinearLayout(this);
detail.setOrientation(LinearLayout.HORIZONTAL);
detail.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1.0f));
TextView lblDetail = new TextView(this);
lblDetail.setText("Detail");
lblDetail.setTextColor(Color.BLACK);
lblDetail.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT,0.25f));
detail.addView(lblDetail);
detailTable.addView(detail);
int total = 0;
for (int i = 0; i < reportDs.size(); i++) {
try {
DepositReportD reportD = reportDs.get(i);
LinearLayout row = new LinearLayout(this);
row.setOrientation(LinearLayout.HORIZONTAL);
row.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1.0f));
String agreement_no = reportD.getAgreement_no();
if(agreement_no == null){
List <PrintResult> pr = PrintResultDataAccess.getAll(getApplicationContext(), report.getBatch_id());
for(PrintResult res:pr){
if("Agreement No".equalsIgnoreCase(res.getLabel()) && null!=res.getValue()){
agreement_no = res.getValue();
}
}
}
TextView lblLabel = new TextView(this);
lblLabel.setText(agreement_no);
lblLabel.setTextColor(Color.BLACK);
lblLabel.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT,0.25f));
row.addView(lblLabel);
TextView lblSpace = new TextView(this);
lblSpace.setText(" : ");
lblSpace.setTextColor(Color.BLACK);
lblSpace.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
row.addView(lblSpace);
try {
TextView lblAnswer = new TextView(this);
lblAnswer.setText(Tool.separateThousand(reportD.getDeposit_amt()));
lblAnswer.setTextColor(Color.BLACK);
lblAnswer.setGravity(Gravity.RIGHT);
lblAnswer.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT,0.25f));
row.addView(lblAnswer, lp);
} catch (Exception e) {
FireCrash.log(e);
}
detailTable.addView(row);
String value = reportD.getDeposit_amt();
if(value==null || value.equals("")) value = "0";
total += Integer.parseInt(value);
} catch (Exception e) {
FireCrash.log(e);
}
}
TextView txtTotal = (TextView) findViewById(R.id.txtTotal);
txtTotal.setText(Tool.separateThousand(total));
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
UserHelp.showAllUserHelp(DepositReportDetailActivity.this,DepositReportDetailActivity.this.getClass().getSimpleName());
}
}, SHOW_USERHELP_DELAY_DEFAULT);
}
@Override
protected void onResume() {
super.onResume();
//Set Firebase screen name
screenName.setCurrentScreen(this, getString(R.string.screen_name_deposit_report_detail), null);
}
@Override
protected void attachBaseContext(Context newBase) {
Context context = newBase;
Locale locale;
try{
locale = new Locale(GlobalData.getSharedGlobalData().getLocale());
context = LocaleHelper.wrap(newBase, locale);
} catch (Exception e) {
locale = new Locale(LocaleHelper.ENGLSIH);
context = LocaleHelper.wrap(newBase, locale);
} finally {
super.attachBaseContext(context);
}
}
@Keep
public void ViewImage(View view){
Global.getSharedGlobal().setIsViewer(true);
Bundle extras = new Bundle();
extras.putByteArray(Global.BUND_KEY_IMAGE_BYTE, report.getImage());
Intent intent = new Intent(this, ViewImageActivity.class);
intent.putExtras(extras);
startActivity(intent);
}
@Keep
private class RecapitulationListAdapter extends ArrayAdapter<DepositReportD> {
private final DepositReportD[] originalItems;
public RecapitulationListAdapter(Context context, DepositReportD[] objects) {
super(context, R.layout.deposit_report_list_recap, objects);
originalItems = objects;
}
@Override
public int getCount() {
return super.getCount() + 1;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
view = LayoutInflater.from(getContext()).inflate(R.layout.deposit_report_list_recap, parent, false);
TextView label = (TextView) view.findViewById(R.id.itemLabel);
TextView value = (TextView) view.findViewById(R.id.itemValue);
TextView agreement= (TextView) view.findViewById(R.id.itemValueAgreement);
if (position == getCount() - 1) {
label.setText("Total");
value.setText(Tool.separateThousand(String.valueOf(sumOfItems())));
} else {
DepositReportD item = getItem(position);
TaskH taskHs= TaskHDataAccess.getOneHeader(getApplicationContext(), item.getUuid_task_h());
String agreement_no = "";
if(taskHs!=null)
agreement_no = taskHs.getAppl_no();
agreement.setText(agreement_no);
value.setText(Tool.separateThousand(item.getDeposit_amt()));
}
return view;
}
private int sumOfItems() {
int sum = 0;
try {
for (DepositReportD item : originalItems) {
String value = item.getDeposit_amt();
if(value==null || value.equals("")) value = "0";
int finalValue = Integer.parseInt(value);
sum += finalValue;
}
} catch (Exception e) {
FireCrash.log(e);
}
total = sum;
return sum;
}
}
}

View file

@ -0,0 +1,48 @@
package com.adins.mss.base.util;
public class NPWPValidation {
private String nomor;
private int factors, digit, kali, round, selisih;
private int hasil = 0;
public NPWPValidation() {
}
public NPWPValidation(String nomor) {
this.setNomor(nomor);
}
public boolean getValidation() {
if (nomor.length() != 15) {
return false;
}
for (int i = 0; i < 8; i++) {
factors = i % 2 == 0 ? 1 : 2;
digit = Integer.parseInt(Character.toString(nomor.charAt(i)));
kali = factors * digit;
if (Integer.toString(kali).length() == 2) {
hasil += Integer.parseInt(Character.toString(Integer.toString(kali).charAt(0))) + Integer.parseInt(Character.toString(Integer.toString(kali).charAt(1)));
} else {
hasil += kali;
}
}
round = (int) Math.ceil((double) hasil / 10) * 10;
selisih = round - hasil;
return selisih == Integer.parseInt(Character.toString(nomor.charAt(8)));
}
public boolean getValidation(String nomor) {
this.nomor = nomor;
return this.getValidation();
}
public String getNomor() {
return nomor;
}
public void setNomor(String nomor) {
this.nomor = nomor;
}
}

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<com.adins.mss.foundation.questiongenerator.form.QuestionView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/questionTextLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/questionTextLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0. Label"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/customerPhoneContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/callPhoneNumber"
android:layout_width="50dp"
android:layout_height="25dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="10dp"
android:background="@drawable/call_button_background"
android:gravity="center"
android:padding="5dp"
android:text="Call"
android:textColor="#ffff"
android:textSize="12sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/questionTextAnswer"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<EditText
android:id="@+id/questionTextAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:imeOptions=""
android:maxLines="1"
android:padding="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@drawable/edit_text_selector"
android:textColorHint="@color/shadowColor"
app:layout_constraintEnd_toStartOf="@+id/callPhoneNumber"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.8">
</EditText>
<Button
android:id="@+id/questionBtnViewPdf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="@string/view_pdf"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/questionTextAnswer"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.adins.mss.foundation.questiongenerator.form.QuestionView>

View file

@ -0,0 +1,146 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="DialogWindowTitle">
<item name="android:textSize">22sp</item>
<item name="android:textColor">@color/text_color</item>
</style>
<style name="dialog_tran" parent="android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:backgroundDimAmount">0.4</item>
</style>
<style name="dialog_untran" parent="dialog_tran">
<item name="android:backgroundDimEnabled">true</item>
</style>
<style name="dialog_btn">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:minHeight">36dp</item>
<item name="android:layout_weight">1</item>
<item name="android:layout_marginBottom">10dp</item>
<item name="android:background">@drawable/btn_selector</item>
<item name="android:textColor">#ffffff</item>
<item name="android:gravity">center</item>
</style>
<style name="my_btn">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">#c0392b</item>
<item name="android:padding">5dp</item>
<item name="android:layout_margin">5dp</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:onClick">dialogShow</item>
<item name="android:textSize">20sp</item>
</style>
<style name="Theme.SmoothProgressBarDefaults" parent="android:Theme">
<item name="spbStyle">@style/SmoothProgressBar</item>
</style>
<style name="SmoothProgressBar" parent="android:Widget.ProgressBar.Horizontal">
<item name="spb_color">@color/spb_default_color</item>
<item name="spb_sections_count">@integer/spb_default_sections_count</item>
<item name="spb_speed">@string/spb_default_speed</item>
<item name="spb_stroke_width">@dimen/spb_default_stroke_width</item>
<item name="spb_stroke_separator_length">@dimen/spb_default_stroke_separator_length</item>
<item name="spb_reversed">@bool/spb_default_reversed</item>
<item name="spb_mirror_mode">@bool/spb_default_mirror_mode</item>
<item name="spb_interpolator">@integer/spb_default_interpolator</item>
<item name="android:minHeight">48dp</item>
<item name="android:maxHeight">48dp</item>
</style>
<!-- Cropping image -->
<style name="Crop"></style>
<style name="Crop.DoneCancelBar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/crop__bar_height</item>
<item name="android:orientation">horizontal</item>
<item name="android:divider">@drawable/crop__divider</item>
<item name="android:showDividers" tools:ignore="NewApi">middle</item>
<item name="android:dividerPadding" tools:ignore="NewApi">12dp</item>
<item name="android:background">@color/crop__button_bar</item>
</style>
<style name="Crop.ActionButton">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:background">@drawable/crop__selectable_background</item>
</style>
<style name="Crop.ActionButtonText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center_vertical</item>
<item name="android:paddingRight">20dp</item> <!-- Offsets left drawable -->
<item name="android:drawablePadding">8dp</item>
<item name="android:textColor">@color/crop__button_text</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">13sp</item>
</style>
<style name="Crop.ActionButtonText.Done">
<item name="android:drawableLeft">@drawable/crop__ic_done</item>
<item name="android:text">@string/crop__done</item>
</style>
<style name="Crop.ActionButtonText.Cancel">
<item name="android:drawableLeft">@drawable/crop__ic_cancel</item>
<item name="android:text">@string/crop__cancel</item>
</style>
<style name="Crop.ActionButtonText.Rotate">
<item name="android:drawableLeft">@drawable/crop__ic_rotate</item>
<item name="android:text">@string/crop__rotate</item>
</style>
<style name="Dialog.NoTitle" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@null</item>
<item name="android:padding">0dp</item>
<item name="android:windowIsFloating">true</item>
</style>
<style name="DialogAnimation">
<item name="android:windowEnterAnimation">@anim/slide_up</item>
<item name="android:windowExitAnimation">@anim/slide_down</item>
</style>
<style name="DialogAnimation2">
<item name="android:windowEnterAnimation">@anim/activity_open_translate</item>
<item name="android:windowExitAnimation">@anim/activity_close_translate</item>
</style>
<style name="TasklistTab" parent="TextAppearance.Design.Tab">
<item name="android:textSize">13sp</item>
<item name="android:background">#ffffff</item>
</style>
</resources>

View file

@ -0,0 +1,632 @@
package com.adins.mss.foundation.location;
import android.Manifest;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationManager;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import androidx.core.content.ContextCompat;
import android.telephony.CellIdentityGsm;
import android.telephony.CellIdentityLte;
import android.telephony.CellIdentityWcdma;
import android.telephony.CellInfo;
import android.telephony.CellInfoGsm;
import android.telephony.CellInfoLte;
import android.telephony.CellInfoWcdma;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.mainmenu.UpdateMenuGPS;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.LocationInfo;
import com.adins.mss.foundation.db.dataaccess.LocationInfoDataAccess;
import com.adins.mss.foundation.formatter.Tool;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.model.LatLng;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @author gigin.ginanjar
*/
public class LocationTrackingManager implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
public static final int DEFAULT_MIN_TIME_CHANGE_LOCATION = 5 * 1000; // milliseconds
public static final int DEFAULT_MIN_DISTANCE_CHANGE_LOCATION = 0; // meters
public static final int MILLISECONDS_PER_SECOND = 1000;
public static final int FAST_INTERVAL_CEILING_IN_MILLISECONDS = 1000;
private static Context context;
private static int status = 0; //0=can't get location; 1= get location not accurate; 2 = get location accurate
private static LocationManager locationManager;
private static LocationInfo locationInfo = new LocationInfo();
private static LocationListenerImpl locationListener;
private static GoogleApiClient mGoogleApiClient;
private boolean isConnected = false;
private TelephonyManager telephonyManager;
private int minTime = -1;
//bong 31 mar 15 - add gpsListener
private int minDistance = -1;
// A request to connect to Location Services
private LocationRequest mLocationRequest;
// Stores the current instantiation of the location client in this object
/**
* Inisialize LocationTrackingManager with Telephony Manager and Location Manager as parameter
*
* @param tm -
* Telephony Manager
* @param lm -
* Location Manager
*/
public LocationTrackingManager(TelephonyManager tm, LocationManager lm, Context context) {
setContextLocation(context);
if (tm == null)
throw new NullPointerException("Could not get telephony service!");
if (lm == null)
throw new NullPointerException("Could not get location service!");
telephonyManager = tm;
setLocationmanager(lm);
setLocationListener(new LocationListenerImpl(context));
//23 Mei 17 add Sync GoogleAPIClient
buildGoogleApiClient();
//bong 31 mar 15 add gpsStatusListener
}
public static Boolean isGpsEnable() {
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
public static GoogleApiClient getGoogleApiClient() {
return mGoogleApiClient;
}
/**
* Gets List of Locations Tracking from Database
*
* @param context
* @return all Location
*/
public static List<LocationInfo> getAllLocationInfoTrackingFromDB(Context context) {
String uuidUser = GlobalData.getSharedGlobalData().getUser().getUuid_user();
return LocationInfoDataAccess.getAllbyType(context, uuidUser, Global.LOCATION_TYPE_TRACKING);
}
/**
* flag for get Location status that use on GPS Indicator
*
* @return <b>0</b> if Location un-Available<br/>
* <b>1</b> if Location Available but not accurate<br/>
* <b>2</b> if Location Available with good accuracy
*/
public static int getLocationStatus() {
return status;
}
/**
* Set Location Status Availability
*
* @param statusLocation <br/><br/><b>0</b> if Location un-Available<br/>
* <b>1</b> if Location Available but not accurate<br/>
* <b>2</b> if Location Available with good accuracy
*/
public static void setLocationStatus(int statusLocation) {
if (statusLocation == 2 || statusLocation == 1) {
Global.isGPS = true;
} else if (statusLocation == 0) {
Global.isGPS = false;
}
status = statusLocation;
}
public static LatLng getLatLng(LocationInfo locationInfo) {
double mLatitude = Double.parseDouble(locationInfo.getLatitude());
double mLongitude = Double.parseDouble(locationInfo.getLongitude());
return new LatLng(mLatitude, mLongitude);
}
/**
* Insert a LocationInfo to Data Base
*
* @param locationInfo
*/
public static void insertLocationInfoToDB(LocationInfo locationInfo) {
LocationInfoDataAccess.add(getContextLocation(), locationInfo);
}
/**
* Insert a LocationInfo to Data Base
*
* @param locationInfo
*/
public static void insertLocationInfoListToDB(List<LocationInfo> locationInfo) {
LocationInfoDataAccess.add(getContextLocation(), locationInfo);
}
public static String toAnswerString(LocationInfo locationInfo) {
StringBuilder sb = new StringBuilder();
sb.append(locationInfo.getLatitude()).append(",")
.append(locationInfo.getLongitude()).append(",")
.append(locationInfo.getCid()).append(",")
.append(locationInfo.getMcc()).append(",")
.append(locationInfo.getMnc()).append(",")
.append(locationInfo.getLac()).append(",")
.append(locationInfo.getAccuracy()).append(",")
.append(locationInfo.getGps_time());
return sb.toString();
}
public static String toAnswerStringShort(LocationInfo locationInfo) {
StringBuilder sb = new StringBuilder();
sb.append(getContextLocation().getString(R.string.lblCoord))
.append(" ")
.append(locationInfo.getLatitude()).append(", ")
.append(locationInfo.getLongitude()).append("\n")
.append(getContextLocation().getString(R.string.lblAcc))
.append(" ")
.append(locationInfo.getAccuracy()).append(" m")
;
return sb.toString();
}
public static int ageMinutes(Location last) {
return (int) (ageMs(last) / (60 * 1000));
}
private static long ageMs(Location last) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
return ageMsApi17(last);
return ageMsApiPre17(last);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static long ageMsApi17(Location last) {
return (SystemClock.elapsedRealtimeNanos() - last
.getElapsedRealtimeNanos()) / 1000000;
}
private static long ageMsApiPre17(Location last) {
return System.currentTimeMillis() - last.getTime();
}
/**
* Creating google api client object
*/
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(getContextLocation())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
mGoogleApiClient.connect();
}
/**
* Begin Location Listener and Request Location Update
*
* @param context - Context
* context of the activity
*/
public void applyLocationListener(Context context) {
setContextLocation(context);
if (this.minTime == -1)
this.minTime = DEFAULT_MIN_TIME_CHANGE_LOCATION;
if (this.minDistance == -1)
this.minDistance = DEFAULT_MIN_DISTANCE_CHANGE_LOCATION;
// Create a new global location parameters object
mLocationRequest = LocationRequest.create();
mLocationRequest.setInterval(minTime);
mLocationRequest.setFastestInterval(minTime);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setSmallestDisplacement(this.minDistance);//if u take this to 300 m so u will get location if u walk by 300 m or more
// devide by 10 to make displacement right and get the right time to update
mLocationRequest.setFastestInterval(FAST_INTERVAL_CEILING_IN_MILLISECONDS);
connectLocationClient();
}
public void connectLocationClient() {
if (!mGoogleApiClient.isConnected() || !mGoogleApiClient.isConnecting())
mGoogleApiClient.connect();
}
public boolean hasConnected() {
return mGoogleApiClient.isConnected();
}
/**
* Stop Periodic Update of Location Tracking
*/
public void removeLocationListener() {
if (mGoogleApiClient.isConnected())
mGoogleApiClient.disconnect();
}
/**
* Gets Local Area Code
*
* @return Local Area Code
*/
public int getLac() {
@SuppressLint("MissingPermission")
GsmCellLocation location = (GsmCellLocation) telephonyManager.getCellLocation();
if (location == null)
return 0;
else
return location.getLac();
}
/**
* Gets Cell ID
*
* @return Cell ID from the Handset
*/
public int getCid() {
@SuppressLint("MissingPermission")
GsmCellLocation location = (GsmCellLocation) telephonyManager.getCellLocation();
if (location == null)
return 0;
else
return location.getCid();
}
/**
* Gets Mobile Country Code
*
* @return Mobile Country Code
*/
public int getMcc() { //Mobile Country Code
String networkOperator = this.telephonyManager.getNetworkOperator();
if (networkOperator == null || "".equals(networkOperator)) {
return 0;
} else {
int val = 0;
try {
val = Integer.parseInt(networkOperator.substring(0, 3));
} catch (NumberFormatException nfe) {
val = 0;
}
return val;
}
}
/**
* Gets Mobile Network Code
*
* @return Mobile Network Code
*/
public int getMnc() { //Mobile Network Code
String networkOperator = this.telephonyManager.getNetworkOperator();
if (networkOperator == null || "".equals(networkOperator)) {
return 0;
} else {
int val = 0;
try {
val = Integer.parseInt(networkOperator.substring(3));
} catch (NumberFormatException nfe) {
val = 0;
}
return val;
}
}
/**
* <p>Set the desired interval for active location updates, in seconds.<br/>
* Set to 5 seconds for mapping applications that are showing your location in real-time<br/>
* By default this is 5 second</p>
*
* @param minTime Minimum time in second
*/
public void setMinimalTimeChangeLocation(int minTime) {
this.minTime = minTime * MILLISECONDS_PER_SECOND; // miliseconds
}
/**
* <p>Set the minimum displacement between location updates in meters.<br/>
* By default this is 0.</p>
*
* @param minDistance
*/
public void setMinimalDistanceChangeLocation(int minDistance) {
this.minDistance = minDistance;
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
setIsConnected(false);
}
@Override
public void onConnected(Bundle arg0) {
startPeriodicUpdates();
setIsConnected(true);
}
@Override
public void onConnectionSuspended(int i) {
setIsConnected(false);
}
private void startPeriodicUpdates() {
try {
if (ContextCompat.checkSelfPermission(getContextLocation(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(getContextLocation(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient, mLocationRequest, locationListener);
} catch (Exception e) {
FireCrash.log(e);
}
}
/**
* Gets Current Location
*
* @return LocationTracking
*/
public LocationInfo getCurrentLocation(int flagLocationType) {
boolean isHasGps = Tool.gpsEnabled(locationManager);
if (isHasGps) {
Location gps = null;
Location locationSaved = null;
try {
if (ContextCompat.checkSelfPermission(getContextLocation(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(getContextLocation(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return null;
}
gps = locationListener.getCurrentLocation();
locationSaved = locationListener.getCurrentLocation();
} 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 (gps != null) {
setLocationStatus(2);
if (gps.getAccuracy() < greenAccuracy) {
locationInfo.setLatitude(String.valueOf(gps.getLatitude()));
locationInfo.setLongitude(String.valueOf(gps.getLongitude()));
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(gps.getTime());
locationInfo.setGps_time(calendar.getTime());
locationInfo.setIs_gps_time(Global.TRUE_STRING);
locationInfo.setAccuracy(Math.round(gps.getAccuracy()));
}
//if Last Location isn't Accurate then get Location from Last Location which good accuracy
else {
if (locationSaved != null) {
if (locationSaved.getAccuracy() <= greenAccuracy) {
LocationTrackingManager.setLocationStatus(2);
} else if (locationSaved.getAccuracy() > greenAccuracy && locationSaved.getAccuracy() <= yellowAccuracy) {
LocationTrackingManager.setLocationStatus(1);
} else {
LocationTrackingManager.setLocationStatus(0);
}
locationInfo.setLatitude(String.valueOf(locationSaved.getLatitude()));
locationInfo.setLongitude(String.valueOf(locationSaved.getLongitude()));
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(locationSaved.getTime());
locationInfo.setGps_time(calendar.getTime());
locationInfo.setIs_gps_time(Global.TRUE_STRING);
locationInfo.setAccuracy(Math.round(locationSaved.getAccuracy()));
} else {
setLocationStatus(0);
locationInfo.setLatitude(String.valueOf(0d));
locationInfo.setLongitude(String.valueOf(0d));
locationInfo.setGps_time(null);
locationInfo.setIs_gps_time(Global.FALSE_STRING);
locationInfo.setAccuracy(0);
}
}
} else {
setLocationStatus(0); //
locationInfo.setGps_time(null);
locationInfo.setIs_gps_time(Global.FALSE_STRING);
locationInfo.setAccuracy(0);
locationInfo.setLatitude(String.valueOf(0d));
locationInfo.setLongitude(String.valueOf(0d));
}
} else {
setLocationStatus(0);
locationInfo.setGps_time(null);
locationInfo.setIs_gps_time(Global.FALSE_STRING);
locationInfo.setAccuracy(0);
locationInfo.setLatitude(String.valueOf(0d));
locationInfo.setLongitude(String.valueOf(0d));
}
String networkOperator = telephonyManager.getNetworkOperator();
if (networkOperator == null || "".equals(networkOperator)) {
locationInfo.setMcc("0");
locationInfo.setMnc("0");
} else {
String mcc = "0";
String mnc = "0";
try {
if (networkOperator != null && networkOperator.length() > 0) {
mcc = networkOperator.substring(0, 3);
mnc = networkOperator.substring(3);
}
if (networkOperator.equalsIgnoreCase("null")) {
mcc = "0";
mnc = "0";
}
locationInfo.setMcc(mcc);
locationInfo.setMnc(mnc);
} catch (NumberFormatException nfe) {
locationInfo.setMcc("0");
locationInfo.setMnc("0");
}
}
GsmCellLocation location = null;
try {
location = (GsmCellLocation) telephonyManager.getCellLocation();
} catch (Exception e) {
FireCrash.log(e);
locationInfo.setCid("0");
locationInfo.setLac("0");
}
if (location == null) {
locationInfo.setCid("0");
locationInfo.setLac("0");
} else {
locationInfo.setCid(String.valueOf(location.getCid()));
locationInfo.setLac(String.valueOf(location.getLac()));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
try {
List<CellInfo> cellInfoList = telephonyManager.getAllCellInfo();
String mCid = null;
String mLac = null;
String mMnc = null;
String mMcc = null;
if (cellInfoList != null) {
for (CellInfo cellInfo : cellInfoList) {
if (cellInfo.isRegistered()) {
if (cellInfo instanceof CellInfoGsm) {
CellInfoGsm infoGsm = (CellInfoGsm) cellInfo;
CellIdentityGsm gsmCellIdentity = infoGsm.getCellIdentity();
if (gsmCellIdentity != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
mCid = String.valueOf(gsmCellIdentity.getCid());
mLac = String.valueOf(gsmCellIdentity.getLac());
mMnc = String.valueOf(gsmCellIdentity.getMnc());
mMcc = String.valueOf(gsmCellIdentity.getMcc());
}
} else if (cellInfo instanceof CellInfoLte) {
CellInfoLte infoLte = (CellInfoLte) cellInfo;
CellIdentityLte lteCellIdentity = infoLte.getCellIdentity();
if (lteCellIdentity != null) {
mMnc = String.valueOf(lteCellIdentity.getMnc());
mMcc = String.valueOf(lteCellIdentity.getMcc());
mLac = String.valueOf(lteCellIdentity.getTac());
mCid = String.valueOf(lteCellIdentity.getCi());
}
} else if (cellInfo instanceof CellInfoWcdma) {
CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
CellIdentityWcdma identityWcdma = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
identityWcdma = cellInfoWcdma.getCellIdentity();
if (identityWcdma != null) {
mCid = String.valueOf(identityWcdma.getCid());
mLac = String.valueOf(identityWcdma.getLac());
mMnc = String.valueOf(identityWcdma.getMnc());
mMcc = String.valueOf(identityWcdma.getMcc());
}
}
}
if (mCid != null && !mCid.equals(String.valueOf(Integer.MAX_VALUE)))
locationInfo.setCid(mCid);
if (mLac != null && !mLac.equals(String.valueOf(Integer.MAX_VALUE)))
locationInfo.setLac(mLac);
if (mMnc != null && !mMnc.equals(String.valueOf(Integer.MAX_VALUE)))
locationInfo.setMnc(mMnc);
if (mMcc != null && !mMcc.equals(String.valueOf(Integer.MAX_VALUE)))
locationInfo.setMcc(mMcc);
}
}
}
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
}
}
Date date = new Date(System.currentTimeMillis());
locationInfo.setHandset_time(date);
locationInfo.setUsr_crt(GlobalData.getSharedGlobalData().getUser().getUuid_user());
locationInfo.setDtm_crt(date);
locationInfo.setUser(GlobalData.getSharedGlobalData().getUser());
switch (flagLocationType) {
case Global.FLAG_LOCATION_TRACKING: // for tracking
locationInfo.setLocation_type(Global.LOCATION_TYPE_TRACKING);
break;
case Global.FLAG_LOCATION_CHECKIN: // for check in
locationInfo.setLocation_type(Global.LOCATION_TYPE_CHECKIN);
break;
case Global.FLAG_LOCATION_CHECKOUT: // for check out
locationInfo.setLocation_type(Global.LOCATION_TYPE_CHECKOUT);
break;
case Global.FLAG_LOCATION_CAMERA: // for check out
locationInfo.setLocation_type(Global.LOCATION_TYPE_CAMERA);
break;
default:
break;
}
locationInfo.setUuid_location_info(Tool.getUUID());
try {
UpdateMenuGPS.SetMenuIcon();
} catch (Exception e) {
FireCrash.log(e);
}
return locationInfo;
}
public void setIsConnected(boolean isConnect){
isConnected = isConnect;
}
public boolean getIsConnected(){
return isConnected;
}
public static void setLocationmanager(LocationManager lm){
locationManager = lm;
}
public LocationManager getLocationManager(){
return locationManager;
}
private static void setLocationListener(LocationListenerImpl lli){
locationListener = lli;
}
public LocationListenerImpl getLocationListener(){
return locationListener;
}
private static void setContextLocation(Context contxt){
context = contxt;
}
public static Context getContextLocation(){
return context;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

View file

@ -0,0 +1,144 @@
package com.adins.mss.odr.other;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.Keep;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.adins.mss.base.timeline.Constants;
import com.adins.mss.foundation.dialog.NiftyDialogBuilder;
import com.adins.mss.foundation.image.CroppingImage;
import com.adins.mss.foundation.image.Utils;
import com.adins.mss.odr.R;
import com.androidquery.AQuery;
import com.soundcloud.android.crop.Crop;
import java.io.File;
public class SettingActivity extends Fragment{
AQuery query;
@Override
public void onAttach(Context activity) {
super.onAttach(activity);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.setting_layout, container, false);
query = new AQuery(view);
query.id(R.id.btnChangeHeader).clicked(this, "changeHeader");
query.id(R.id.btnChangeProfile).clicked(this, "changeProfile");
if(query.id(R.id.profilePicture).getCachedImage(getActivity().getFilesDir()+"/imgProfile")!=null)
query.id(R.id.profilePicture).image(getActivity().getFilesDir()+"/imgProfile", true, true);
else
query.id(R.id.profilePicture).image(R.drawable.profile_image);
if(query.id(R.id.headerPicture).getCachedImage(getActivity().getFilesDir()+"/imgHeader")!=null)
query.id(R.id.headerPicture).image(getActivity().getFilesDir()+"/imgHeader", true, true).height(250);
else
query.id(R.id.headerPicture).image(R.drawable.dummy);
// query.id(R.id.edit_header).clicked(this, "changeHeader");
// query.id(R.id.editProfile).longClicked(this, "changeProfile");
return view;
}
@Keep
public void changeHeader(View view){
Constants.flag_edit=0;
final NiftyDialogBuilder builder = new NiftyDialogBuilder(SettingActivity.this.getActivity());
builder.withButton1Text("Camera");
builder.withButton2Text("Gallery");
builder.setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(v.getContext(), CameraPreviewActivity.class);
cameraIntent.putExtra("EDIT_MODE_IMAGE",0);
startActivityForResult(cameraIntent, 1);
builder.dismiss();
}
});
builder.setButton2Click(new View.OnClickListener() {
@Override
public void onClick(View v) {
Crop.pickImage(getActivity(), SettingActivity.this);
builder.dismiss();
}
});
builder.show();
}
@Keep
public void changeProfile(View view){
Constants.flag_edit=1;
final NiftyDialogBuilder builder = new NiftyDialogBuilder(SettingActivity.this.getActivity());
builder.withButton1Text("Camera");
builder.withButton2Text("Gallery");
builder.setButton1Click(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(v.getContext(), CameraPreviewActivity.class);
cameraIntent.putExtra("EDIT_MODE_IMAGE", 1);
startActivityForResult(cameraIntent, 1);
builder.dismiss();
}
});
builder.setButton2Click(new View.OnClickListener() {
@Override
public void onClick(View v) {
Crop.pickImage(getActivity(), SettingActivity.this);
builder.dismiss();
}
});
builder.show();
}
@Override
public void onResume(){
super.onResume();
if(query.id(R.id.profilePicture).getCachedImage(getActivity().getFilesDir()+"/imgProfile")!=null)
query.id(R.id.profilePicture).image(getActivity().getFilesDir()+"/imgProfile", true, true);
else
query.id(R.id.profilePicture).image(R.drawable.profile_image);
if(query.id(R.id.headerPicture).getCachedImage(getActivity().getFilesDir()+"/imgHeader")!=null)
query.id(R.id.headerPicture).image(getActivity().getFilesDir()+"/imgHeader", true, true).height(250);
else
query.id(R.id.headerPicture).image(R.drawable.dummy);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent result) {
super.onActivityResult(requestCode, resultCode, result);
if (requestCode == Crop.REQUEST_PICK && resultCode == Activity.RESULT_OK) {
if(Constants.flag_edit==0){
CroppingImage.beginCropImgHeader(result.getData(),getActivity(),SettingActivity.this);
}else{
CroppingImage.beginCropImgProfile(result.getData(),getActivity(),SettingActivity.this);
}
} else if(requestCode == Utils.REQUEST_CAMERA) {
if(Constants.flag_edit==0) {
Uri outputUri = Uri.fromFile(new File(getActivity().getFilesDir(), "imgHeader"));
CroppingImage.beginCrop(outputUri, getActivity());
}else{
Uri outputUri = Uri.fromFile(new File(getActivity().getFilesDir(), "imgProfile"));
CroppingImage.beginCrop(outputUri, getActivity());
}
} else if (requestCode == Crop.REQUEST_CROP) {
// Uri imgUri = CroppingImage.handleCrop(resultCode, result, getActivity());
}
}
}

View file

@ -0,0 +1,178 @@
package com.adins.mss.coll.loyalti.pointacquisitionmonthly;
import com.adins.mss.coll.loyalti.pointacquisitionmonthly.contracts.ILoyaltyPointsDataSource;
import com.adins.mss.coll.models.loyaltymodels.GroupPointData;
import com.adins.mss.coll.models.loyaltymodels.LoyaltyPointsRequest;
import com.adins.mss.coll.models.loyaltymodels.RankDetail;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.GeneralParameter;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class MonthlyPointsLogic {
private ILoyaltyPointsDataSource dataSource;
private String competitionStartDate;
private int displayYear;
public MonthlyPointsLogic(ILoyaltyPointsDataSource dataSource, String competitionStartDate, int displayYear) {
this.dataSource = dataSource;
this.competitionStartDate = competitionStartDate;
this.displayYear = displayYear;
}
public MonthlyPointsLogic(ILoyaltyPointsDataSource dataSource) {
this.dataSource = dataSource;
}
public void getMonthlyPointsData(LoyaltyPointsRequest reqData, ILoyaltyPointsDataSource.ReqPointsListener listener){
dataSource.requestPointsData(reqData,listener);
}
public int getTotalPoints(List<GroupPointData> dataSet){
if(dataSet == null)
return 0;
int totalPoints = 0;
int[] totalPerIdx = new int[dataSet.size()];
int _sum = 0;
for(int i=0; i<totalPerIdx.length; i++){
_sum = 0;
for (int stack=0; stack<dataSet.get(i).pointDetails.size(); stack++){
int point = Integer.valueOf(dataSet.get(i).pointDetails.get(stack).point);
_sum += point;
}
totalPerIdx[i] = _sum;
totalPoints += totalPerIdx[i];
}
return totalPoints;
}
public float getAvgPoint(List<GroupPointData> dataSet){
if(dataSet == null)
return 0;
float totalPoints = 0;
int avg = 0;
int[] totalPerIdx = new int[dataSet.size()];
int _sum = 0;
for(int i=0; i<totalPerIdx.length; i++){
_sum = 0;
for (int stack=0; stack<dataSet.get(i).pointDetails.size(); stack++){
int point = Integer.valueOf(dataSet.get(i).pointDetails.get(stack).point);
_sum += point;
}
totalPerIdx[i] = _sum;
totalPoints += totalPerIdx[i];
}
int divideMonths = getTotalMonthsYear();
avg = Math.round(totalPoints/divideMonths);
return avg;
}
private int getTotalMonthsYear(){
Calendar calendar = Calendar.getInstance();
//current date
calendar.setTime(new Date());
int currMonth = calendar.get(Calendar.MONTH);
int currYear = calendar.get(Calendar.YEAR);
int maxMonths = 0;
//tentukan bulan maksimum
if(currYear == displayYear){
//tahun berjalan
maxMonths = currMonth;
}else {
//sudah lewat
calendar.set(Calendar.YEAR,displayYear);
maxMonths = calendar.getActualMaximum(Calendar.MONTH);
}
//competition start date
DateFormat dateFormat = new SimpleDateFormat(Global.DATE_STR_FORMAT1);
Date startCompDate = null;
try {
startCompDate = dateFormat.parse(competitionStartDate);
} catch (ParseException e) {
e.printStackTrace();
}
if(startCompDate == null)
return 1;
calendar.setTime(startCompDate);
int cYear = calendar.get(Calendar.YEAR);
int cMonth = calendar.get(Calendar.MONTH);
//hitung bulan maksimum berdasarkan tanggal kompetisi mulai
if(displayYear == cYear){
maxMonths = (maxMonths - cMonth) + 1;
}
return maxMonths;
}
public int getMaxPoint(List<GroupPointData> dataSet){
if(dataSet == null)
return 0;
int max = 0;
int[] totalPerIdx = new int[dataSet.size()];
int _sum = 0;
for(int i=0; i<totalPerIdx.length; i++){
_sum = 0;
for (int stack=0; stack<dataSet.get(i).pointDetails.size(); stack++){
int point = Integer.valueOf(dataSet.get(i).pointDetails.get(stack).point);
_sum += point;
}
totalPerIdx[i] = _sum;
}
Arrays.sort(totalPerIdx);
max = totalPerIdx[totalPerIdx.length -1];
return max;
}
public List<RankDetail> updateJobName(List<RankDetail> rankDetails){
if(rankDetails == null || rankDetails.size() == 0)
return rankDetails;
List<String> jobNames = new ArrayList<>();
for (RankDetail rank:rankDetails) {
if(rank == null)
continue;
jobNames.add(rank.level);
}
List<GeneralParameter> jobParams = dataSource.getJobsGenParam(jobNames);
if(jobParams.size() == 0)
return rankDetails;
for (RankDetail rank:rankDetails) {
if(rank == null)
continue;
for (GeneralParameter jobParam:jobParams){
if(rank.level.equalsIgnoreCase(jobParam.getGs_value())){
String jobParamCode = jobParam.getGs_code();
if(jobParamCode.equalsIgnoreCase("MC_JOBNATIONAL")){
rank.level = "National";
}
else if(jobParamCode.equalsIgnoreCase("MC_JOBBM")){
rank.level = "Branch";
}
else if(jobParamCode.equalsIgnoreCase("MC_JOBSPV")){
rank.level = "SPV";
}
}
}
}
return rankDetails;
}
}