mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-07-01 05:14:17 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
Binary file not shown.
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/footer" >
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_above="@+id/contentComment"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/contentVersion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textSize="10dp"
|
||||
android:text="@string/appVersion" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="|"
|
||||
android:textSize="10dp"
|
||||
android:visibility="gone" />
|
||||
<TextView
|
||||
android:id="@+id/androidId"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="androidId"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textSize="10dp"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/contentComment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="@string/aboutCopyright" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,147 @@
|
|||
package com.adins.mss.coll.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.checkin.CheckInManager;
|
||||
import com.adins.mss.base.util.LocaleHelper;
|
||||
import com.adins.mss.coll.R;
|
||||
import com.adins.mss.coll.fragments.view.PaymentHistoryView;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.PaymentHistoryD;
|
||||
import com.adins.mss.foundation.UserHelp.UserHelp;
|
||||
import com.adins.mss.foundation.location.UpdateMenuIcon;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
|
||||
import org.acra.ACRA;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.adins.mss.constant.Global.SHOW_USERHELP_DELAY_DEFAULT;
|
||||
|
||||
/**
|
||||
* Created by adityapurwa on 20/03/15.
|
||||
*/
|
||||
public class PaymentHistoryFragment extends AppCompatActivity {
|
||||
public static List<PaymentHistoryD> details;
|
||||
private PaymentHistoryView view;
|
||||
|
||||
private FirebaseAnalytics screenName;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
screenName = FirebaseAnalytics.getInstance(this);
|
||||
setContentView(R.layout.new_fragment_payment_history);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(getString(R.string.title_mn_paymenthistory));
|
||||
toolbar.setTitleTextColor(getResources().getColor(com.adins.mss.base.R.color.fontColorWhite));
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ACRA.getErrorReporter().putCustomData("LAST_CLASS_ACCESSED", getClass().getSimpleName());
|
||||
view = new PaymentHistoryView(this);
|
||||
view.onCreate();
|
||||
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserHelp.showAllUserHelp(PaymentHistoryFragment.this,PaymentHistoryFragment.this.getClass().getSimpleName());
|
||||
}
|
||||
}, SHOW_USERHELP_DELAY_DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if(!Global.BACKPRESS_RESTRICTION) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == com.adins.mss.base.R.id.mnGPS && 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(item.getItemId() == R.id.mnGuide && !Global.BACKPRESS_RESTRICTION){
|
||||
UserHelp.reloadUserHelp(getApplicationContext(), PaymentHistoryFragment.this);
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UserHelp.showAllUserHelp(PaymentHistoryFragment.this, PaymentHistoryFragment.this.getClass().getSimpleName());
|
||||
}
|
||||
}, SHOW_USERHELP_DELAY_DEFAULT);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
@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();
|
||||
|
||||
if(Global.ENABLE_USER_HELP &&
|
||||
(Global.userHelpGuide.get(PaymentHistoryFragment.this.getClass().getSimpleName())!=null) ||
|
||||
Global.userHelpDummyGuide.get(PaymentHistoryFragment.this.getClass().getSimpleName()) != null){
|
||||
menu.findItem(com.adins.mss.base.R.id.mnGuide).setVisible(true);
|
||||
}
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
//Set Firebase screen name
|
||||
screenName.setCurrentScreen(this, getString(R.string.screen_name_payment_history), null);
|
||||
}
|
||||
|
||||
private static Menu mainMenu;
|
||||
|
||||
public static void updateMenuIcon() {
|
||||
UpdateMenuIcon uItem = new UpdateMenuIcon();
|
||||
uItem.updateGPSIcon(mainMenu);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_focused="true" android:drawable="@drawable/form_edittext_focused" />
|
||||
<item android:drawable="@drawable/form_edittext_default" />
|
||||
</selector>
|
|
@ -0,0 +1,53 @@
|
|||
package com.adins.mss.odr.model;
|
||||
|
||||
import com.adins.mss.foundation.http.MssRequestType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by adityapurwa on 11/03/15.
|
||||
*/
|
||||
public class SynchronizeRequestModel extends MssRequestType {
|
||||
@SerializedName("tableName")
|
||||
private String tableName;
|
||||
@SerializedName("dtm_upd")
|
||||
private Date dtm_upd;
|
||||
@SerializedName("list")
|
||||
private List list;
|
||||
@SerializedName("init")
|
||||
private int init;
|
||||
|
||||
public List getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public Date getDtm_upd() {
|
||||
return dtm_upd;
|
||||
}
|
||||
|
||||
public void setDtm_upd(Date dtm_upd) {
|
||||
this.dtm_upd = dtm_upd;
|
||||
}
|
||||
|
||||
public int getInit() {
|
||||
return init;
|
||||
}
|
||||
|
||||
public void setInit(int init) {
|
||||
this.init = init;
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
|
@ -0,0 +1,348 @@
|
|||
package com.adins.mss.foundation.http.net;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.squareup.okhttp.CipherSuite;
|
||||
import com.squareup.okhttp.ConnectionSpec;
|
||||
import com.squareup.okhttp.TlsVersion;
|
||||
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Security;
|
||||
import java.security.UnrecoverableKeyException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSession;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
/**
|
||||
* Created by Aditya Purwa on 2/23/2015.
|
||||
* HTTPs version of HTTPClient.
|
||||
*/
|
||||
public class HttpsClient extends HttpClient {
|
||||
/**
|
||||
* Default keystore name if not specified.
|
||||
*/
|
||||
private static final String DEFAULT_KEYSTORE_NAME = "keystore";
|
||||
|
||||
private KeyStore keystore;
|
||||
/**
|
||||
* Algorithm for the trust manager. Default to RSA
|
||||
*/
|
||||
private String algorithm = "RSA";
|
||||
/**
|
||||
* Protocol for the socket. Default to TLS.
|
||||
*/
|
||||
private String protocol = "TLS";
|
||||
/**
|
||||
* The keystore type. Default to BKS for Android Bouncy Castle provider.
|
||||
*/
|
||||
private String keystoreType = "BKS";
|
||||
|
||||
/**
|
||||
* Mark the client to bypass hostname verification.
|
||||
*/
|
||||
private boolean bypassHostnameVerification = false;
|
||||
|
||||
/**
|
||||
* Mark the client to accept all certificate. THIS COULD BE DANGEROUS.
|
||||
*/
|
||||
private boolean acceptAllCertificate = false;
|
||||
|
||||
/**
|
||||
* Initialize a new instance of secure version of the HTTP client. Call initialize to initialize
|
||||
* the keystore.
|
||||
*
|
||||
* @param context The context for the client.
|
||||
* @param keystoreStream Stream containing the certificate keystore.
|
||||
* @param password Password for the keystore.
|
||||
* @throws java.security.cert.CertificateException
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @throws java.io.IOException
|
||||
* @throws java.security.KeyStoreException
|
||||
*/
|
||||
public HttpsClient(Context context, InputStream keystoreStream, String password) throws CertificateException, NoSuchAlgorithmException, IOException, KeyStoreException, KeyManagementException {
|
||||
super(context);
|
||||
|
||||
KeyStore store = KeyStore.getInstance(getKeystoreType());
|
||||
store.load(keystoreStream, password.toCharArray());
|
||||
this.keystore = store;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new instance of secure version of the HTTP client. Call initialize to initialize
|
||||
* the keystore.
|
||||
* This will use the default keystore specified in DEFAULT_KEYSTORE_NAME.
|
||||
*
|
||||
* @param context The context for the client.
|
||||
* @param password Password for the keystore.
|
||||
* @throws java.io.IOException
|
||||
* @throws java.security.KeyStoreException
|
||||
* @throws java.security.cert.CertificateException
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @throws java.security.KeyManagementException
|
||||
*/
|
||||
public HttpsClient(Context context, String password) throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException, KeyManagementException {
|
||||
this(context, context.getAssets().open(DEFAULT_KEYSTORE_NAME), password);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new instance of secure version of the HTTP client. Call initialize to initialize
|
||||
* the keystore.
|
||||
*
|
||||
* @param context The context for the client.
|
||||
* @param keystore The keystore to use.
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @throws java.security.KeyStoreException
|
||||
* @throws java.security.KeyManagementException
|
||||
*/
|
||||
public HttpsClient(Context context, KeyStore keystore)
|
||||
throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
super(context);
|
||||
|
||||
this.keystore = keystore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a new instance of secure version of the HTTP client. Call initialize to initialize
|
||||
* the keystore. This will use the default keystore trusted by the Android device.
|
||||
*
|
||||
* @param context The context for the client.
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @throws java.security.KeyStoreException
|
||||
* @throws java.security.KeyManagementException
|
||||
*/
|
||||
public HttpsClient(Context context) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public HttpsClient() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the keystore value.
|
||||
*
|
||||
* @return Keystore.
|
||||
*/
|
||||
public KeyStore getKeystore() {
|
||||
return keystore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the keystore value, call to initialize may be required to reset the keystore.
|
||||
*
|
||||
* @param keystore The keystore to use.
|
||||
*/
|
||||
public void setKeystore(KeyStore keystore) {
|
||||
this.keystore = keystore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the keystore. If the keystore is null, it will use Android device keystore.
|
||||
*
|
||||
* @throws java.security.NoSuchAlgorithmException
|
||||
* @throws java.security.KeyStoreException
|
||||
* @throws java.security.KeyManagementException
|
||||
*/
|
||||
public void initialize()
|
||||
throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, UnrecoverableKeyException {
|
||||
SSLContext sslContext = SSLContext.getInstance(getProtocol());
|
||||
|
||||
//Nendi: 2019-08-12 | Add Connection Spec to specify cipherSuite version
|
||||
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)
|
||||
.tlsVersions(TlsVersion.TLS_1_2)
|
||||
.cipherSuites(
|
||||
CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
||||
CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
||||
CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
|
||||
.build();
|
||||
|
||||
client.setConnectionSpecs(Collections.singletonList(spec));
|
||||
//End Add connection spec
|
||||
|
||||
if (isBypassHostnameVerification()) {
|
||||
client.setHostnameVerifier(new HostnameVerifier() {
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
client.setHostnameVerifier(null);
|
||||
}
|
||||
|
||||
if (isAcceptAllCertificate()) {
|
||||
sslContext.init(null, new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
X509Certificate[] acceptedIssuer;
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
acceptedIssuer = chain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||
acceptedIssuer = chain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return acceptedIssuer;
|
||||
}
|
||||
}
|
||||
|
||||
}, new SecureRandom());
|
||||
client.setSslSocketFactory(sslContext.getSocketFactory());
|
||||
} else {
|
||||
if (keystore != null) {
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
//KeyPairGenerator kpgen = KeyPairGenerator.getInstance(algorithm, "BC");
|
||||
|
||||
|
||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm);
|
||||
trustManagerFactory.init(keystore);
|
||||
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException {
|
||||
// not implemented
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
sslContext = SSLContext.getInstance(getProtocol());
|
||||
sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom());
|
||||
// sslContext.init(null, trustAllCerts, new SecureRandom());
|
||||
client.setSslSocketFactory(sslContext.getSocketFactory());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the protocol used by the SSL. Default to TLS.
|
||||
*
|
||||
* @return Protocol.
|
||||
*/
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the protocol used by the SSL.
|
||||
*
|
||||
* @param protocol Protocol to use.
|
||||
*/
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the keystore type used to load the keystore. Default to BKS for Android Bouncy Castle.
|
||||
*
|
||||
* @return Keystore type.
|
||||
*/
|
||||
public String getKeystoreType() {
|
||||
return keystoreType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the keystore type used to load the keystore.
|
||||
*
|
||||
* @param keystoreType Keystore type.
|
||||
*/
|
||||
public void setKeystoreType(String keystoreType) {
|
||||
this.keystoreType = keystoreType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the algorithm used by the trust manager. Default to RSA.
|
||||
*
|
||||
* @return Algorithm used by the trust manager.
|
||||
*/
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the algorithm used by the trust manager.
|
||||
*
|
||||
* @param algorithm Algorithm.
|
||||
*/
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state, whether the HTTPs client will accept all server certificates.
|
||||
* THIS COULD BE DANGEROUS.
|
||||
*
|
||||
* @return True if the client accept all certificates, false otherwise.
|
||||
*/
|
||||
public boolean isAcceptAllCertificate() {
|
||||
return acceptAllCertificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state, whether the HTTPs client will accept all server certificates.
|
||||
* When set to true, the keystore passed will not be used.
|
||||
* May require call to initialize method after set.
|
||||
* THIS COULD BE DANGEROUS.
|
||||
*
|
||||
* @param acceptAllCertificate True to accept all certificates, false otherwise.
|
||||
*/
|
||||
public void setAcceptAllCertificate(boolean acceptAllCertificate) {
|
||||
this.acceptAllCertificate = acceptAllCertificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state, whether the HTTPs client will bypass hostname verification.
|
||||
* THIS COULD BE DANGEROUS.
|
||||
*
|
||||
* @return True if the client will bypass hostname check, false otherwise.
|
||||
*/
|
||||
public boolean isBypassHostnameVerification() {
|
||||
return bypassHostnameVerification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state, whether the HTTPs client will bypass hostname verification.
|
||||
* May require call to initialize method after set.
|
||||
* THIS COULD BE DANGEROUS.
|
||||
*
|
||||
* @param bypassHostnameVerification True if the client will bypass hostname check, false otherwise.
|
||||
*/
|
||||
public void setBypassHostnameVerification(boolean bypassHostnameVerification) {
|
||||
this.bypassHostnameVerification = bypassHostnameVerification;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,369 @@
|
|||
package com.adins.mss.foundation.db.dataaccess;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.DaoSession;
|
||||
import com.adins.mss.dao.Timeline;
|
||||
import com.adins.mss.dao.TimelineDao;
|
||||
import com.adins.mss.dao.TimelineType;
|
||||
import com.adins.mss.foundation.db.DaoOpenHelper;
|
||||
import com.adins.mss.foundation.formatter.Tool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.greenrobot.dao.query.QueryBuilder;
|
||||
import de.greenrobot.dao.query.WhereCondition;
|
||||
|
||||
public class TimelineDataAccess {
|
||||
|
||||
public static final String PRIORITY_HIGH = "High";
|
||||
public static final String PRIORITY_NORMAL = "Normal";
|
||||
|
||||
// private static DaoOpenHelper daoOpenHelper;
|
||||
|
||||
/**
|
||||
* use to generate dao session that you can access modelDao
|
||||
*
|
||||
* @param context --> context from activity
|
||||
* @return
|
||||
*/
|
||||
protected static DaoSession getDaoSession(Context context) {
|
||||
/*if(daoOpenHelper==null){
|
||||
// if(daoOpenHelper.getDaoSession()==null)
|
||||
daoOpenHelper = new DaoOpenHelper(context);
|
||||
}
|
||||
DaoSession daoSeesion = daoOpenHelper.getDaoSession();
|
||||
return daoSeesion;*/
|
||||
return DaoOpenHelper.getDaoSession(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* get timeline dao and you can access the DB
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
protected static TimelineDao getTimelineDao(Context context) {
|
||||
return getDaoSession(context).getTimelineDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear session, close db and set daoOpenHelper to null
|
||||
*/
|
||||
public static void closeAll() {
|
||||
/*if(daoOpenHelper!=null){
|
||||
daoOpenHelper.closeAll();
|
||||
daoOpenHelper = null;
|
||||
}*/
|
||||
DaoOpenHelper.closeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* add timeline as entity
|
||||
*
|
||||
* @param context
|
||||
* @param timeline
|
||||
*/
|
||||
public static void add(Context context, Timeline timeline) {
|
||||
getTimelineDao(context).insertInTx(timeline);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
public static void addOrReplace(Context context, Timeline timeline) {
|
||||
getTimelineDao(context).insertOrReplaceInTx(timeline);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* add timeline as list entity
|
||||
*
|
||||
* @param context
|
||||
* @param timelineList
|
||||
*/
|
||||
public static void add(Context context, List<Timeline> timelineList) {
|
||||
getTimelineDao(context).insertInTx(timelineList);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all content in table.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void clean(Context context) {
|
||||
getTimelineDao(context).deleteAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param timeline
|
||||
*/
|
||||
public static void delete(Context context, Timeline timeline) {
|
||||
getTimelineDao(context).delete(timeline);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* delete all record by user
|
||||
*
|
||||
* @param context
|
||||
* @param uuidUser
|
||||
*/
|
||||
public static void delete(Context context, String uuidUser) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser));
|
||||
qb.build();
|
||||
getTimelineDao(context).deleteInTx(qb.list());
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param timeline
|
||||
*/
|
||||
public static void update(Context context, Timeline timeline) {
|
||||
getTimelineDao(context).update(timeline);
|
||||
getDaoSession(context).clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_user = param
|
||||
*
|
||||
* @param context
|
||||
* @param uuidUser
|
||||
* @return
|
||||
*/
|
||||
public static List<Timeline> getAll(Context context, String uuidUser) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* select * from table where uuid_timeline_type = param3 and uuid_user = param2
|
||||
*
|
||||
* @param context
|
||||
* @param uuidUser
|
||||
* @param keyTimelineType
|
||||
* @return
|
||||
*/
|
||||
public static List<Timeline> getAll(Context context, String uuidUser, String keyTimelineType) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(keyTimelineType));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* select timeline by uuidTimeline
|
||||
*
|
||||
* @param context
|
||||
* @param uuidUser
|
||||
* @param uuidTimeline
|
||||
* @return
|
||||
*/
|
||||
public static Timeline getOneTimeline(Context context, String uuidUser, String uuidTimeline) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_timeline.eq(uuidTimeline));
|
||||
qb.build();
|
||||
if (qb.list().size() == 0)
|
||||
return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
public static Timeline getOneTimelineByTask(Context context, String uuidUser, String timelineType, String uuidTaskH) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_task_h.eq(uuidTaskH));
|
||||
qb.where(new WhereCondition.StringCondition("UUID_TIMELINE_TYPE in (SELECT UUID_TIMELINE_TYPE FROM MS_TIMELINETYPE WHERE " +
|
||||
"TIMELINE_TYPE = '" + timelineType + "')"));
|
||||
qb.build();
|
||||
if (qb.list().size() == 0)
|
||||
return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
|
||||
public static Timeline getOneTimelineByTaskH(Context context, String uuidUser, String uuid_taskh_h, String uuid_timeline_type) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_task_h.eq(uuid_taskh_h),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(uuid_timeline_type));
|
||||
qb.build();
|
||||
if (qb.list().size() == 0)
|
||||
return null;
|
||||
return qb.list().get(qb.list().size()-1);
|
||||
}
|
||||
|
||||
public static List<Timeline> getTimelineByTaskH(Context context, String uuidUser, String uuid_taskh_h, String uuid_timeline_type) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_task_h.eq(uuid_taskh_h),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(uuid_timeline_type));
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static Timeline getOneTimelineByTaskH(Context context, String uuidUser, String uuid_taskh_h) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_task_h.eq(uuid_taskh_h));
|
||||
qb.build();
|
||||
if (qb.list().size() == 0)
|
||||
return null;
|
||||
return qb.list().get(0);
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllWithLimitedDay(Context context,
|
||||
String uuid_user, int range) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuid_user),
|
||||
TimelineDao.Properties.Dtm_crt.ge(Tool.getIncrementDate(range)));
|
||||
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllDeletedTimeline(Context context,
|
||||
String uuid_user, int range) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuid_user),
|
||||
TimelineDao.Properties.Dtm_crt.le(Tool.getIncrementDate(range)));
|
||||
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getTimelineByTask(Context context, String uuidUser, String uuidTaskH) {
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_task_h.eq(uuidTaskH));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
if (qb.list().size() == 0)
|
||||
return null;
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllDeletedTimelineForMH(Context context, String uuid_user, int range) {
|
||||
TimelineType verified = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_VERIFIED);
|
||||
TimelineType approved = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_APPROVED);
|
||||
TimelineType rejected = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_REJECTED);
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuid_user),
|
||||
TimelineDao.Properties.Dtm_crt.le(Tool.getIncrementDate(range)),
|
||||
TimelineDao.Properties.Uuid_timeline_type.in(verified.getUuid_timeline_type(),
|
||||
approved.getUuid_timeline_type(), rejected.getUuid_timeline_type()));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllWithLimitedDayForMH(Context context, String uuid_user, int range) {
|
||||
TimelineType verified = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_VERIFIED);
|
||||
TimelineType approved = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_APPROVED);
|
||||
TimelineType rejected = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_REJECTED);
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuid_user),
|
||||
TimelineDao.Properties.Dtm_crt.ge(Tool.getIncrementDate(range)),
|
||||
TimelineDao.Properties.Uuid_timeline_type.in(verified.getUuid_timeline_type(),
|
||||
approved.getUuid_timeline_type(), rejected.getUuid_timeline_type()));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllTimelineForMH(Context context, String uuidUser) {
|
||||
TimelineType verified = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_VERIFIED);
|
||||
TimelineType approved = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_APPROVED);
|
||||
TimelineType rejected = TimelineTypeDataAccess.getTimelineTypebyType(context, Global.TIMELINE_TYPE_REJECTED);
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_timeline_type.in(verified.getUuid_timeline_type(),
|
||||
approved.getUuid_timeline_type(), rejected.getUuid_timeline_type()));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllDeletedTimelineByType(Context context, String uuid_user, int range, String timelineType) {
|
||||
TimelineType type = TimelineTypeDataAccess.getTimelineTypebyType(context, timelineType);
|
||||
String uuid_timeline_type = type.getUuid_timeline_type();
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuid_user),
|
||||
TimelineDao.Properties.Dtm_crt.le(Tool.getIncrementDate(range)),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(uuid_timeline_type));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllWithLimitedDayByType(Context context, String uuid_user, int range, String timelineType) {
|
||||
TimelineType type = TimelineTypeDataAccess.getTimelineTypebyType(context, timelineType);
|
||||
String uuid_timeline_type = type.getUuid_timeline_type();
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuid_user),
|
||||
TimelineDao.Properties.Dtm_crt.ge(Tool.getIncrementDate(range)),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(uuid_timeline_type));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllTimelineByType(Context context, String uuidUser, String timelineType) {
|
||||
TimelineType type = TimelineTypeDataAccess.getTimelineTypebyType(context, timelineType);
|
||||
String uuid_timeline_type = type.getUuid_timeline_type();
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(uuid_timeline_type));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllDeletedTimelineTask(Context context, String uuid_user, int range, String timelineType, String priority) {
|
||||
TimelineType type = TimelineTypeDataAccess.getTimelineTypebyType(context, timelineType);
|
||||
String uuid_timeline_type = type.getUuid_timeline_type();
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuid_user),
|
||||
TimelineDao.Properties.Dtm_crt.le(Tool.getIncrementDate(range)),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(uuid_timeline_type),
|
||||
TimelineDao.Properties.Priority.eq(priority));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllWithLimitedDayTask(Context context, String uuid_user, int range, String timelineType, String priority) {
|
||||
TimelineType type = TimelineTypeDataAccess.getTimelineTypebyType(context, timelineType);
|
||||
String uuid_timeline_type = type.getUuid_timeline_type();
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuid_user),
|
||||
TimelineDao.Properties.Dtm_crt.ge(Tool.getIncrementDate(range)),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(uuid_timeline_type),
|
||||
TimelineDao.Properties.Priority.eq(priority));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
|
||||
public static List<Timeline> getAllTimelineTask(Context context, String uuidUser, String timelineType, String priority) {
|
||||
TimelineType type = TimelineTypeDataAccess.getTimelineTypebyType(context, timelineType);
|
||||
String uuid_timeline_type = type.getUuid_timeline_type();
|
||||
QueryBuilder<Timeline> qb = getTimelineDao(context).queryBuilder();
|
||||
qb.where(TimelineDao.Properties.Uuid_user.eq(uuidUser),
|
||||
TimelineDao.Properties.Uuid_timeline_type.eq(uuid_timeline_type),
|
||||
TimelineDao.Properties.Priority.eq(priority));
|
||||
qb.orderAsc(TimelineDao.Properties.Dtm_crt);
|
||||
qb.build();
|
||||
return qb.list();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/textReviewLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/tv_white"
|
||||
android:padding="@dimen/padding_medium">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/questionNoLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:paddingRight="@dimen/ptr_progress_bar_stroke_width"
|
||||
android:text="0." />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/questionTextLabel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/questionNoLabel"
|
||||
android:text="label" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/answerLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:layout_below="@+id/questionTextLabel"
|
||||
android:layout_toEndOf="@+id/questionNoLabel"
|
||||
android:layout_toRightOf="@+id/questionNoLabel"
|
||||
android:weightSum="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/questionTextAnswer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/imgLocationAnswer"
|
||||
android:text="answer"
|
||||
android:textAppearance="@android:style/TextAppearance.Small" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgLocationAnswer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/ic_absent" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/line_height"
|
||||
android:layout_below="@+id/answerLayout"
|
||||
android:background="@color/tv_gray" />
|
||||
</RelativeLayout>
|
Loading…
Add table
Add a link
Reference in a new issue