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

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View file

@ -0,0 +1,94 @@
package com.adins.mss.foundation.broadcast;
import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.R;
import com.adins.mss.base.crashlytics.FireCrash;
import com.adins.mss.base.util.GsonHelper;
import com.adins.mss.base.util.Utility;
import com.adins.mss.constant.Global;
import com.adins.mss.foundation.formatter.Tool;
import com.adins.mss.foundation.http.HttpConnectionResult;
import com.adins.mss.foundation.http.HttpCryptedConnection;
import com.adins.mss.foundation.http.MssResponseType;
import com.google.firebase.perf.FirebasePerformance;
import com.google.firebase.perf.metrics.HttpMetric;
import java.util.List;
public class SubmitSubscribedTopicTask extends AsyncTask<Void, Void, Boolean> {
private Context context;
private String uuidUser;
private List<String> listTopic;
private String errMsg;
public SubmitSubscribedTopicTask(Context context, String uuidUser, List<String> listTopic) {
this.context = context;
this.uuidUser = uuidUser;
this.listTopic = listTopic;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Boolean doInBackground(Void... voids) {
SubmitTopicRequest request = new SubmitTopicRequest();
request.setUuidUser(uuidUser);
request.setSubscribedTopic(listTopic);
String json = GsonHelper.toJson(request);
String url = "";
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
HttpCryptedConnection httpConn = new HttpCryptedConnection(context, encrypt, decrypt);
HttpConnectionResult serverResult = null;
//Firebase Performance Trace HTTP Request
HttpMetric networkMetric =
FirebasePerformance.getInstance().newHttpMetric(url, FirebasePerformance.HttpMethod.POST);
Utility.metricStart(networkMetric, json);
try {
if(!Tool.isInternetconnected(context)){
errMsg = context.getString(R.string.no_internet_connection);
return false;
}
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
Utility.metricStop(networkMetric, serverResult);
if (serverResult == null) {
return false;
}
if(!serverResult.isOK()){
errMsg = serverResult.getResult();
return false;
}
MssResponseType responseType = GsonHelper.fromJson(serverResult.getResult(), MssResponseType.class);
if(responseType.getStatus().getCode() != 0){
errMsg = responseType.getStatus().getMessage();
return false;
}
return true;
} catch (Exception e) {
FireCrash.log(e);
e.printStackTrace();
errMsg = e.getMessage();
return false;
}
}
@Override
protected void onPostExecute(Boolean success) {
super.onPostExecute(success);
}
}

View file

@ -0,0 +1,172 @@
package com.adins.mss.base.commons;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull;
import android.util.Log;
import android.widget.Toast;
import com.adins.mss.base.GlobalData;
import com.adins.mss.base.util.Utility;
import com.adins.mss.constant.Global;
import com.adins.mss.dao.TaskH;
import com.adins.mss.foundation.db.DaoOpenHelper;
import com.adins.mss.foundation.formatter.Formatter;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.OnProgressListener;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import de.greenrobot.dao.database.Database;
public class BackupManager {
public static String ACTION_BACKUP_TASK = "com.adins.mss.ACTION_BACKUP_TASK";
private Context context;
public BackupManager(Context context) {
this.context = context;
}
private void copyAsset(File destination) {
try (InputStream is = this.context.getAssets().open("master");
OutputStream os = new FileOutputStream(destination)) {
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
public void backup(String entity, String params) {
// Initialize Firebase Instance
Database db = DaoOpenHelper.getDb(context);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference reference = storage.getReference("backup");
String loginid = (GlobalData.getSharedGlobalData() != null && GlobalData.getSharedGlobalData().getUser() != null)
? GlobalData.getSharedGlobalData().getUser().getLogin_id() : Build.ID;
String nowaday = Formatter.formatDate(new Date(), Global.DATE_STR_FORMAT_GSON);
StorageReference backup;
File extdb = this.copy(entity);
String constraint = "WHERE 1";
db.execSQL("ATTACH '" + extdb.getPath() + "' AS EXT");
switch (entity) {
case "tasks":
db.execSQL("INSERT INTO EXT.MS_SCHEME SELECT * FROM MS_SCHEME");
db.execSQL("INSERT INTO EXT.MS_QUESTIONSET SELECT * FROM MS_QUESTIONSET");
db.execSQL("INSERT INTO EXT.TR_TASK_H SELECT * FROM TR_TASK_H");
db.execSQL("INSERT INTO EXT.TR_TASK_D SELECT * FROM TR_TASK_D");
break;
case "lov":
String query = "INSERT INTO EXT.MS_LOOKUP SELECT * FROM MS_LOOKUP ";
query = query.concat(constraint);
if (params != null && !params.equals("")) {
query = query.concat(" AND ").concat(params);
}
db.execSQL(query);
break;
case "deposit":
db.execSQL("INSERT INTO EXT.TR_DEPOSITREPORT_D SELECT * FROM TR_DEPOSITREPORT_D");
db.execSQL("INSERT INTO EXT.TR_DEPOSITREPORT_H SELECT * FROM TR_DEPOSITREPORT_H");
db.execSQL("INSERT INTO EXT.TR_TASK_H SELECT * FROM TR_TASK_H");
db.execSQL("INSERT INTO EXT.TR_TASK_D SELECT * FROM TR_TASK_D");
break;
default:
break;
}
db.execSQL("DETACH 'EXT'");
Uri uri= Uri.fromFile(extdb);
backup = reference.child(loginid + "_" + nowaday + "_" + uri.getLastPathSegment());
this.upload(uri, backup);
}
public void backup(String action, TaskH taskH) {
// Initialize Firebase Instance
Database db = DaoOpenHelper.getDb(context);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference reference = storage.getReference("backup");
String serial = Build.SERIAL;
String loginid = (GlobalData.getSharedGlobalData() != null && GlobalData.getSharedGlobalData().getUser() != null)
? GlobalData.getSharedGlobalData().getUser().getLogin_id() : serial;
String nowaday = Formatter.formatDate(new Date(), Global.DATE_STR_FORMAT_GSON);
File extdb;
StorageReference backup;
if (action.equalsIgnoreCase(ACTION_BACKUP_TASK)) {
extdb = this.copy("tasks");
db.execSQL("ATTACH '" + extdb.getPath() + "' AS EXT");
db.execSQL("INSERT INTO EXT.MS_SCHEME SELECT * FROM MS_SCHEME");
db.execSQL("INSERT INTO EXT.MS_QUESTIONSET SELECT * FROM MS_QUESTIONSET");
db.execSQL("INSERT INTO EXT.TR_TASK_H SELECT * FROM TR_TASK_H");
db.execSQL("INSERT INTO EXT.TR_TASK_D SELECT * FROM TR_TASK_D");
db.execSQL("DETACH 'EXT'");
Uri uri= Uri.fromFile(extdb);
backup = reference.child(loginid + "_" + nowaday + "_" + uri.getLastPathSegment() + "_" + taskH.getCustomer_name().replaceAll(" ", "_"));
this.upload(uri, backup);
} else {
this.copy("master");
}
// Check Internal Storage and Report it
Utility.checkInternalStorage(context);
}
private void upload(Uri dataUri, final StorageReference reference) {
UploadTask uploadTask = reference.putFile(dataUri);
uploadTask.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
Log.i("BackupManager","Total Transferred: " + taskSnapshot.getBytesTransferred());
}
});
uploadTask.addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()) {
Log.i("BackupManager","Download link: " + reference.getDownloadUrl().toString());
}
}
});
}
private File copy(String filename) {
File extdb = context.getDatabasePath(filename);
if (extdb.exists()) {
boolean result = extdb.delete();
if(!result){
Toast.makeText(context, "Failed to delete directory", Toast.LENGTH_SHORT).show();
}
}
this.copyAsset(extdb);
return extdb;
}
}

View file

@ -0,0 +1,272 @@
<?xml version="1.0" encoding="utf-8"?>
<resources translatable="false">
<string name="define_license_cc30"></string>
<string name="license_cc30_licenseName">Creative Commons 3.0 License</string>
<string name="license_cc30_licenseWebsite">http://creativecommons.org/licenses/by/3.0/legalcode</string>
<string name="license_cc30_licenseShortDescription">
<![CDATA[THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE (\"CCPL\" OR \"LICENSE\"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.<br/><br/>
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
]]>
</string>
<string name="license_cc30_licenseDescription">
<![CDATA[<p><strong>3. License Grant.</strong> Subject to the terms
and conditions of this License, Licensor hereby grants You
a worldwide, royalty-free, non-exclusive, perpetual (for
the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:</p>
<ol type=\"a\">
<li>to Reproduce the Work, to incorporate the Work into
one or more Collections, and to Reproduce the Work as
incorporated in the Collections;</li>
<li>to create and Reproduce Adaptations provided that any
such Adaptation, including any translation in any medium,
takes reasonable steps to clearly label, demarcate or
otherwise identify that changes were made to the original
Work. For example, a translation could be marked \"The
original work was translated from English to Spanish,\" or
a modification could indicate \"The original work has been
modified.\";</li>
<li>to Distribute and Publicly Perform the Work including
as incorporated in Collections; and,</li>
<li>to Distribute and Publicly Perform Adaptations.</li>
<li>
<p>For the avoidance of doubt:</p>
<ol type=\"i\">
<li><strong>Non-waivable Compulsory License
Schemes</strong>. In those jurisdictions in which the
right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the
Licensor reserves the exclusive right to collect such
royalties for any exercise by You of the rights
granted under this License;</li>
<li><strong>Waivable Compulsory License
Schemes</strong>. In those jurisdictions in which the
right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the
Licensor waives the exclusive right to collect such
royalties for any exercise by You of the rights
granted under this License; and,</li>
<li><strong>Voluntary License Schemes</strong>. The
Licensor waives the right to collect royalties,
whether individually or, in the event that the
Licensor is a member of a collecting society that
administers voluntary licensing schemes, via that
society, from any exercise by You of the rights
granted under this License.</li>
</ol>
</li>
</ol>
<p>The above rights may be exercised in all media and
formats whether now known or hereafter devised. The above
rights include the right to make such modifications as are
technically necessary to exercise the rights in other media
and formats. Subject to Section 8(f), all rights not
expressly granted by Licensor are hereby reserved.</p>
<p><strong>4. Restrictions.</strong> The license granted in
Section 3 above is expressly made subject to and limited by
the following restrictions:</p>
<ol type=\"a\">
<li>You may Distribute or Publicly Perform the Work only
under the terms of this License. You must include a copy
of, or the Uniform Resource Identifier (URI) for, this
License with every copy of the Work You Distribute or
Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or
the ability of the recipient of the Work to exercise the
rights granted to that recipient under the terms of the
License. You may not sublicense the Work. You must keep
intact all notices that refer to this License and to the
disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or
Publicly Perform the Work, You may not impose any
effective technological measures on the Work that
restrict the ability of a recipient of the Work from You
to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to
the Work as incorporated in a Collection, but this does
not require the Collection apart from the Work itself to
be made subject to the terms of this License. If You
create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the
Collection any credit as required by Section 4(b), as
requested. If You create an Adaptation, upon notice from
any Licensor You must, to the extent practicable, remove
from the Adaptation any credit as required by Section
4(b), as requested.</li>
<li>If You Distribute, or Publicly Perform the Work or
any Adaptations or Collections, You must, unless a
request has been made pursuant to Section 4(a), keep
intact all copyright notices for the Work and provide,
reasonable to the medium or means You are utilizing: (i)
the name of the Original Author (or pseudonym, if
applicable) if supplied, and/or if the Original Author
and/or Licensor designate another party or parties (e.g.,
a sponsor institute, publishing entity, journal) for
attribution (\"Attribution Parties\") in Licensor\'s
copyright notice, terms of service or by other reasonable
means, the name of such party or parties; (ii) the title
of the Work if supplied; (iii) to the extent reasonably
practicable, the URI, if any, that Licensor specifies to
be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information
for the Work; and (iv) , consistent with Section 3(b), in
the case of an Adaptation, a credit identifying the use
of the Work in the Adaptation (e.g., \"French translation
of the Work by Original Author,\" or \"Screenplay based on
original Work by Original Author\"). The credit required
by this Section 4 (b) may be implemented in any
reasonable manner; provided, however, that in the case of
a Adaptation or Collection, at a minimum such credit will
appear, if a credit for all contributing authors of the
Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the
credits for the other contributing authors. For the
avoidance of doubt, You may only use the credit required
by this Section for the purpose of attribution in the
manner set out above and, by exercising Your rights under
this License, You may not implicitly or explicitly assert
or imply any connection with, sponsorship or endorsement
by the Original Author, Licensor and/or Attribution
Parties, as appropriate, of You or Your use of the Work,
without the separate, express prior written permission of
the Original Author, Licensor and/or Attribution
Parties.</li>
<li>Except as otherwise agreed in writing by the Licensor
or as may be otherwise permitted by applicable law, if
You Reproduce, Distribute or Publicly Perform the Work
either by itself or as part of any Adaptations or
Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work
which would be prejudicial to the Original Author\'s honor
or reputation. Licensor agrees that in those
jurisdictions (e.g. Japan), in which any exercise of the
right granted in Section 3(b) of this License (the right
to make Adaptations) would be deemed to be a distortion,
mutilation, modification or other derogatory action
prejudicial to the Original Author\'s honor and
reputation, the Licensor will waive or not assert, as
appropriate, this Section, to the fullest extent
permitted by the applicable national law, to enable You
to reasonably exercise Your right under Section 3(b) of
this License (right to make Adaptations) but not
otherwise.</li>
</ol>
<p><strong>5. Representations, Warranties and
Disclaimer</strong></p>
<p>UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN
WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO
REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE
WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING,
WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE
ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE
PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE.
SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.</p>
<p><strong>6. Limitation on Liability.</strong> EXCEPT TO
THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL
LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY
SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY
DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK,
EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.</p>
<p><strong>7. Termination</strong></p>
<ol type=\"a\">
<li>This License and the rights granted hereunder will
terminate automatically upon any breach by You of the
terms of this License. Individuals or entities who have
received Adaptations or Collections from You under this
License, however, will not have their licenses terminated
provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7,
and 8 will survive any termination of this License.</li>
<li>Subject to the above terms and conditions, the
license granted here is perpetual (for the duration of
the applicable copyright in the Work). Notwithstanding
the above, Licensor reserves the right to release the
Work under different license terms or to stop
distributing the Work at any time; provided, however that
any such election will not serve to withdraw this License
(or any other license that has been, or is required to
be, granted under the terms of this License), and this
License will continue in full force and effect unless
terminated as stated above.</li>
</ol>
<p><strong>8. Miscellaneous</strong></p>
<ol type=\"a\">
<li>Each time You Distribute or Publicly Perform the Work
or a Collection, the Licensor offers to the recipient a
license to the Work on the same terms and conditions as
the license granted to You under this License.</li>
<li>Each time You Distribute or Publicly Perform an
Adaptation, Licensor offers to the recipient a license to
the original Work on the same terms and conditions as the
license granted to You under this License.</li>
<li>If any provision of this License is invalid or
unenforceable under applicable law, it shall not affect
the validity or enforceability of the remainder of the
terms of this License, and without further action by the
parties to this agreement, such provision shall be
reformed to the minimum extent necessary to make such
provision valid and enforceable.</li>
<li>No term or provision of this License shall be deemed
waived and no breach consented to unless such waiver or
consent shall be in writing and signed by the party to be
charged with such waiver or consent.</li>
<li>This License constitutes the entire agreement between
the parties with respect to the Work licensed here. There
are no understandings, agreements or representations with
respect to the Work not specified here. Licensor shall
not be bound by any additional provisions that may appear
in any communication from You. This License may not be
modified without the mutual written agreement of the
Licensor and You.</li>
<li>The rights granted under, and the subject matter
referenced, in this License were drafted utilizing the
terminology of the Berne Convention for the Protection of
Literary and Artistic Works (as amended on September 28,
1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms
Treaty of 1996 and the Universal Copyright Convention (as
revised on July 24, 1971). These rights and subject
matter take effect in the relevant jurisdiction in which
the License terms are sought to be enforced according to
the corresponding provisions of the implementation of
those treaty provisions in the applicable national law.
If the standard suite of rights granted under applicable
copyright law includes additional rights not granted
under this License, such additional rights are deemed to
be included in the License; this License is not intended
to restrict the license of any rights under applicable
law.</li>
</ol>
]]>
</string>
</resources>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB