Commit dda81035 authored by rahadi's avatar rahadi

Added Pemutakhiran Module

parent 2191f420
include ':collect_app', ':slidingmenu'
\ No newline at end of file
include ':collect_app', ':slidingmenu', ':vsen_p'
\ No newline at end of file
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
// applicationId "com.rahadi.vsen"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
// android support dependencies
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'de.hdodenhof:circleimageview:2.1.0'
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.rahadi.vsen;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.rahadi.vsen", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rahadi.vsen">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application>
<provider
android:name=".providers.RutaProvider"
android:authorities="com.rahadi.vsen.providers.ruta"
android:enabled="true"
android:exported="true" />
<provider
android:name=".providers.BSProvider"
android:authorities="com.rahadi.vsen.providers.bloksensus"
android:enabled="true"
android:exported="true" />
<provider
android:name=".providers.CatatanProvider"
android:authorities="com.rahadi.vsen.providers.catatan"
android:enabled="true"
android:exported="true" />
<provider
android:name=".providers.DsrtProvider"
android:authorities="com.rahadi.vsen.providers.dsrt"
android:enabled="true"
android:exported="true" />
<provider
android:name=".providers.DsrtLogProvider"
android:authorities="com.rahadi.vsen.providers.dsrt.log"
android:enabled="true"
android:exported="true" />
</application>
<!--<application-->
<!--android:name=".applications.Vsen"-->
<!--android:allowBackup="true"-->
<!--android:icon="@mipmap/ic_launcher"-->
<!--android:label="@string/app_name"-->
<!--android:roundIcon="@mipmap/ic_launcher_round"-->
<!--android:supportsRtl="true"-->
<!--android:theme="@style/AppTheme">-->
<!--<meta-data-->
<!--android:name="com.google.android.geo.API_KEY"-->
<!--android:value="AIzaSyB0HY0CXNKHELCBLiR7r65yLJa73v6j16c" />-->
<!--<activity android:name=".activitBlokSensusSampleActivityvity">-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->
<!--</activity>-->
<!--<activity android:name=".activitPasswordSampleActivityvity" />-->
<!--<activity android:name=".activitSplashSampleActivityvity" />-->
<!--<activity android:name=".activitLoginSampleActivityvity" />-->
<!--<activity-->
<!--android:name=".activitRutaSampleActivityvity"-->
<!--android:theme="@style/BaseTheme" />-->
<!--<provider-->
<!--android:name=".providers.RutaProvider"-->
<!--android:authorities="com.rahadi.vsen.providers.ruta"-->
<!--android:enabled="true"-->
<!--android:exported="true" />-->
<!--<provider-->
<!--android:name=".providers.BSProvider"-->
<!--android:authorities="com.rahadi.vsen.providers.bloksensus"-->
<!--android:enabled="true"-->
<!--android:exported="true" />-->
<!--<provider-->
<!--android:name=".providers.CatatanProvider"-->
<!--android:authorities="com.rahadi.vsen.providers.catatan"-->
<!--android:enabled="true"-->
<!--android:exported="true" />-->
<!--<provider-->
<!--android:name=".providers.DsrtProvider"-->
<!--android:authorities="com.rahadi.vsen.providers.dsrt"-->
<!--android:enabled="true"-->
<!--android:exported="true" />-->
<!--<provider-->
<!--android:name=".providers.DsrtLogProvider"-->
<!--android:authorities="com.rahadi.vsen.providers.dsrt.log"-->
<!--android:enabled="true"-->
<!--android:exported="true" />-->
<!--<activity android:name=".activitDsrtImpActivityvity"></activity>-->
<!--</application>-->
</manifest>
\ No newline at end of file
package com.rahadi.vsen.activities;
import android.content.Intent;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.rahadi.vsen.R;
import com.rahadi.vsen.adapters.BlokSensusAdapter;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.daos.BlokSensusDao;
import com.rahadi.vsen.listeners.OnLihatRutaClickedListener;
import com.rahadi.vsen.listeners.OnRecyclerItemClickListener;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.models.BlokSensusModel;
import com.rahadi.vsen.models.UserModel;
import com.rahadi.vsen.providers.BSProviderAPI;
import com.rahadi.vsen.samples.RutaSampleActivity;
import com.rahadi.vsen.tasks.BSSynchronizationTask;
import com.rahadi.vsen.views.ExtendedRecyclerView;
import com.rahadi.vsen.views.LoadingView;
import org.json.JSONArray;
import java.util.List;
import timber.log.Timber;
/**
* Created by Rahadi on 27/01/2018.
*/
public abstract class BlokSensusImpActivity extends AppCompatActivity implements OnLihatRutaClickedListener {
public static final int REQUEST_SEND = 1;
public static final int REQUEST_SAMPLING = 2;
public static final String KEY_RESULT_BS = "result_bs";
public static final String KEY_RESULT_BS_UUID = "result_bs_uuid";
public static final int RESULT_SENT = 10;
public static final int RESULT_SAMPLED = 11;
public static final int RESULT_SAMPLING_FAILED = 12;
public static final int RESULT_RECALLED = 13;
protected BlokSensusAdapter blokSensusAdapter;
protected List<BlokSensusModel> blokSensusModels;
protected LoadingView loadingView;
protected ConstraintLayout listContainer;
protected ExtendedRecyclerView blokSensusList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blok_sensus);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
blokSensusList = findViewById(R.id.list_blok_sensus);
loadingView = findViewById(R.id.loading_view);
listContainer = findViewById(R.id.list_container);
blokSensusList.setLayoutManager(new LinearLayoutManager(this));
blokSensusList.setNestedScrollingEnabled(false);
blokSensusAdapter = new BlokSensusAdapter(this, blokSensusModels, this);
blokSensusAdapter.setOnRecyclerItemClickListener(new OnRecyclerItemClickListener() {
@Override
public void onItemClick(View v, int position) {
BlokSensusModel bsm = blokSensusModels.get(position);
if (bsm.getStatus().equalsIgnoreCase(BSProviderAPI.STATUS_SAMPLE_UPLOADED)) {
Class targetClass = BlokSensusImpActivity.this.getDsrtActivityClass();
Intent i = new Intent(BlokSensusImpActivity.this, targetClass);
i.putExtra(DsrtImpActivity.KEY_BS_UUID, bsm.getUuid());
i.putExtra(DsrtImpActivity.KEY_BS_NKS, bsm.getKodeProvinsi() +
bsm.getKodeKabupaten() + bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus());
startActivity(i);
} else {
onLihatRutaClicked(bsm.getUuid(), bsm.getKodeProvinsi() + bsm.getKodeKabupaten() +
bsm.getKodeKecamatan() + bsm.getKodeDesa() + bsm.getBlokSensus(), bsm.getStatus());
}
}
});
loadData();
blokSensusList.setEmptyView(findViewById(R.id.empty_view));
blokSensusList.setAdapter(blokSensusAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.vsen_main_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int menuId = item.getItemId();
if (menuId == R.id.sync_menu_item) {
UserModel userModel = Vsen.getInstance().getUserSession();
new BSSynchronizationTask(loadingView, listContainer).execute(userModel.getIdUser(), userModel.getAuthToken(), new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
loadData();
Timber.d("Adapter Size: %s", blokSensusAdapter.getItemCount());
final Snackbar snackbar = Snackbar.make((findViewById(R.id.blok_sensus_container)),
R.string.sinkronisasi_selesai, Snackbar.LENGTH_LONG);
snackbar.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
snackbar.dismiss();
}
});
snackbar.show();
}
});
}
return true;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
loadData();
Timber.d("Adapter Size: %s", blokSensusAdapter.getItemCount());
if (requestCode == REQUEST_SEND) {
if (resultCode == RESULT_SENT) {
final Snackbar snackbar = Snackbar.make((findViewById(R.id.blok_sensus_container)),
getString(R.string.bs_terkirim_format, data.getStringExtra(KEY_RESULT_BS)),
Snackbar.LENGTH_LONG);
snackbar.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
snackbar.dismiss();
}
});
snackbar.show();
} else if (resultCode == RESULT_RECALLED) {
final Snackbar snackbar = Snackbar.make((findViewById(R.id.blok_sensus_container)),
getString(R.string.bs_dikembalikan_format, data.getStringExtra(KEY_RESULT_BS)),
Snackbar.LENGTH_LONG);
snackbar.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
snackbar.dismiss();
}
});
snackbar.show();
}
}
if (requestCode == REQUEST_SAMPLING) {
if (resultCode == RESULT_SAMPLED) {
final Snackbar snackbar = Snackbar.make((findViewById(R.id.blok_sensus_container)),
getString(R.string.ditarik_sampel_format, data.getStringExtra(KEY_RESULT_BS)),
Snackbar.LENGTH_LONG);
snackbar.setAction("LIHAT SAMPEL", new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(BlokSensusImpActivity.this, DsrtImpActivity.class);
i.putExtra(DsrtImpActivity.KEY_BS_UUID, data.getStringExtra(KEY_RESULT_BS_UUID));
startActivity(i);
snackbar.dismiss();
}
});
snackbar.show();
} else if (resultCode == RESULT_SAMPLING_FAILED) {
final Snackbar snackbar = Snackbar.make((findViewById(R.id.blok_sensus_container)),
getString(R.string.terjadi_kesalahan), Snackbar.LENGTH_LONG);
snackbar.setAction("OK", new View.OnClickListener() {
@Override
public void onClick(View view) {
snackbar.dismiss();
}
});
snackbar.show();
}
}
}
private void loadData() {
blokSensusModels = new BlokSensusDao().getBlokSensusListFromCursor(new BlokSensusDao().getBlokSensusCursor());
blokSensusAdapter.setBlokSensuses(blokSensusModels);
blokSensusAdapter.notifyDataSetChanged();
}
public void onLihatRutaClicked(String bsUuid, String bsNks, String bsStatus) {
Class targetClass = getRutaActivityClass();
Intent i = new Intent(BlokSensusImpActivity.this, targetClass);
i.putExtra(RutaSampleActivity.BS_UUID, bsUuid);
i.putExtra(RutaSampleActivity.BS_NKS, bsNks);
i.putExtra(RutaSampleActivity.BS_STATUS, bsStatus);
if (Vsen.getInstance().getUserSession().getPrivilege() == VsenAPI.PRIVILEGE_PCL) {
startActivityForResult(i, REQUEST_SEND);
} else {
if (bsStatus.equalsIgnoreCase(BSProviderAPI.STATUS_READY)) {
startActivityForResult(i, REQUEST_SAMPLING);
} else {
startActivityForResult(i, REQUEST_SEND);
}
}
}
public abstract Class getDsrtActivityClass();
public abstract Class getRutaActivityClass();
}
package com.rahadi.vsen.activities;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import com.rahadi.vsen.R;
import com.rahadi.vsen.adapters.DsrtAdapter;
import com.rahadi.vsen.daos.DsrtDao;
import com.rahadi.vsen.listeners.OnDsrtActionButtonClickListener;
import com.rahadi.vsen.models.DsrtModel;
import com.rahadi.vsen.providers.DsrtProviderAPI;
import com.rahadi.vsen.views.ExtendedRecyclerView;
import java.util.List;
public abstract class DsrtImpActivity extends AppCompatActivity {
public static final String KEY_BS_UUID = "bs_uuid";
public static final String KEY_BS_NKS = "bs_nks";
private String bsUuid, bsNks;
private DsrtAdapter dsrtAdapter;
private List<DsrtModel> dsrtModelList;
private View emptyView;
private ExtendedRecyclerView dsrtList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dsrt);
bsUuid = getIntent().getStringExtra(KEY_BS_UUID);
bsNks = getIntent().getStringExtra(KEY_BS_NKS);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (bsNks != null) {
getSupportActionBar().setTitle("DSRT. " + bsNks);
}
}
dsrtList = findViewById(R.id.list_dsrt);
emptyView = findViewById(R.id.empty_view);
dsrtList.setLayoutManager(new LinearLayoutManager(this));
dsrtList.setNestedScrollingEnabled(false);
dsrtAdapter = new DsrtAdapter(this, dsrtModelList, new OnDsrtActionButtonClickListener() {
@Override
public void onButtonClick(View view, DsrtModel dsrtModel, String mode, boolean isPml) {
DsrtImpActivity.this.onDsrtActionButtonClick(view, dsrtModel, mode, isPml);
}
});
loadData();
dsrtList.setEmptyView(emptyView);
dsrtList.setAdapter(dsrtAdapter);
}
@Override
public void onBackPressed() {
// super.onBackPressed();
finish();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.vsen_main_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int menuId = item.getItemId();