Commit 13ac4e1b authored by rahadi's avatar rahadi

Code cleanup, deleted vsen module

parent 77d04c4e
......@@ -52,7 +52,7 @@ def getVersionName = { ->
}
return stdout.toString().trim()
} catch (ignored) {
return null;
return null
}
}
......@@ -118,6 +118,7 @@ android {
}
dexOptions {
javaMaxHeapSize '2048M'
preDexLibraries = false
}
productFlavors {
}
......
......@@ -62,6 +62,8 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
pageIndicatorParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
pageIndicatorParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
pageIndicatorParams.leftMargin = 10;
pageIndicator.setLayoutParams(pageIndicatorParams);
pageIndicator.setPadding(15, 15, 15, 15);
......@@ -103,6 +105,9 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
// R.style.Widget_AppCompat_Button_Borderless), null, 0);
ImageView prevButton = new ImageView(getContext(), null, 0);
LinearLayout.LayoutParams prevButtonParams = new LinearLayout.LayoutParams(sizeForButtons, sizeForButtons);
prevButtonParams.rightMargin = 10;
prevButton.setLayoutParams(prevButtonParams);
prevButton.setId(R.id.footer_view_prev_button);
......@@ -120,6 +125,9 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
// R.style.Widget_AppCompat_Button_Borderless), null, 0);
ImageView nextButton = new ImageView(getContext(), null, 0);
LinearLayout.LayoutParams nextButtonParams = new LinearLayout.LayoutParams(sizeForButtons, sizeForButtons);
nextButtonParams.leftMargin = 10;
nextButton.setLayoutParams(nextButtonParams);
nextButton.setId(R.id.footer_view_next_button);
......@@ -143,6 +151,8 @@ public class TableFooterView extends RelativeLayout implements View.OnClickListe
addButtonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
addButtonParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
addButtonParams.rightMargin = 10;
addButton.setLayoutParams(addButtonParams);
addButton.setPadding(15, 15, 15, 15);
......
......@@ -79,8 +79,9 @@ public class SplashScreenActivity extends AppCompatActivity {
startActivity(new Intent(this, CapiMainActivity.class));
// startActivity(new Intent(this, BSActivity.class));
} else {
startActivity(new Intent(this, CapiMainActivity.class));
// startActivity(new Intent(this, CapiLoginActivity.class));
startActivity(new Intent(this, ListingInstanceActivity.class));
// startActivity(new Intent(this, ListingInstanceActivity.class));
}
finish();
}
......
......@@ -9,7 +9,8 @@ import android.widget.Toolbar;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ac.stis.capi.BuildConfig;
import id.ac.stis.capi.BuildConfig;
import id.ac.stis.capi.R;
import id.ac.stis.capi.odk.preferences.AboutPreferencesActivity;
import id.ac.stis.capi.odk.preferences.PreferencesActivity;
......
......@@ -7,11 +7,12 @@ import android.preference.Preference;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ac.stis.capi.BuildConfig;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import id.ac.stis.capi.BuildConfig;
import static junit.framework.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
......
......@@ -7,7 +7,8 @@ import android.preference.PreferenceManager;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ac.stis.capi.BuildConfig;
import id.ac.stis.capi.BuildConfig;
import id.ac.stis.capi.odk.application.Collect;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
......
......@@ -27,7 +27,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.internal.util.reflection.Whitebox;
import org.ac.stis.capi.BuildConfig;
import id.ac.stis.capi.BuildConfig;
import id.ac.stis.capi.odk.widgets.DateTimeWidget;
import id.ac.stis.capi.odk.widgets.DateWidget;
import id.ac.stis.capi.odk.widgets.TimeWidget;
......
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" />
<provider
android:name=".providers.GenerateProvider"
android:authorities="com.rahadi.vsen.providers.generate"
android:enabled="true"
android:exported="true" />
<activity
android:name=".activities.VsenPreferenceActivity"
android:theme="@style/VsenAppTheme" />
</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.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();
if (menuId == android.R.id.home) {
onBackPressed();
} else if (menuId == R.id.sync_menu_item) {
}
return true;
}
private void loadData() {
dsrtModelList = new DsrtDao().getDsrtListFromCursor(new DsrtDao().getDsrtCursor(null,
DsrtProviderAPI.Columns.BS_UUID + "=?", new String[]{bsUuid}, null));
dsrtAdapter.setDsrtModelList(dsrtModelList);
dsrtAdapter.notifyDataSetChanged();
}
public abstract void onDsrtActionButtonClick(View v, DsrtModel model, String mode, boolean isPml);
}
package com.rahadi.vsen.activities;
import android.database.Cursor;
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 com.rahadi.vsen.R;
import com.rahadi.vsen.adapters.DsrtMinAdapter;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.daos.BlokSensusDao;
import com.rahadi.vsen.daos.DsrtDao;
import com.rahadi.vsen.daos.DsrtMinDao;
import com.rahadi.vsen.daos.RutaDao;
import com.rahadi.vsen.listeners.OnGenerateCompletedListener;
import com.rahadi.vsen.models.DsrtMinModel;
import com.rahadi.vsen.models.RutaModel;
import com.rahadi.vsen.providers.BSProviderAPI;
import com.rahadi.vsen.providers.DsrtProviderAPI;
import com.rahadi.vsen.providers.RutaProviderAPI;
import com.rahadi.vsen.views.ExtendedRecyclerView;
import java.util.ArrayList;
import java.util.List;
public abstract class DsrtMinImpActivity extends AppCompatActivity implements OnGenerateCompletedListener {
public static final String KEY_BS_UUID = "bs_uuid";
public static final String KEY_BS_NKS = "bs_nks";
private String bsUuid, bsNks;
private DsrtMinAdapter dsrtAdapter;
private List<RutaModel> rutaModelList;
private View emptyView;
private ExtendedRecyclerView dsrtList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dsrt_min);
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 DsrtMinAdapter(this, rutaModelList);
loadData();
dsrtList.setEmptyView(emptyView);
dsrtList.setAdapter(dsrtAdapter);
}
@Override
public void onBackPressed() {
// super.onBackPressed();
finish();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
String selection = BSProviderAPI.Columns.ID_PCL + "=?";
if (Vsen.getInstance().getUserSession().getPrivilege() == VsenAPI.PRIVILEGE_PML) {
selection = BSProviderAPI.Columns.ID_PML + "=?";
}
String[] selectionArgs = new String[]{Vsen.getInstance().getUserSession().getIdUser()};
String[] projection = new String[]{BSProviderAPI.Columns.STATUS_GENERATE};
int statusGenerate = 0;
Cursor d = new BlokSensusDao().getBlokSensusCursor(projection, selection, selectionArgs, null);
if (d != null) {
if (d.moveToFirst()) {
statusGenerate = d.getInt(d.getColumnIndex(BSProviderAPI.Columns.STATUS_GENERATE));
}
d.close();
}
if (Vsen.getInstance().getUserSession().getPrivilege() == VsenAPI.PRIVILEGE_PCL) {
if (statusGenerate == 0) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.vsen_dsrt_min_menu, menu);
return true;
}
}
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int menuId = item.getItemId();
if (menuId == android.R.id.home) {
onBackPressed();
} else if (menuId == R.id.generate_menu_item) {
onGenerateMenuClicked();
}
return true;
}
private void loadData() {
rutaModelList = new ArrayList<>();
List<DsrtMinModel> dsrtModelList = new DsrtMinDao().getDsrtListFromCursor(new DsrtDao().getDsrtCursor(null,
DsrtProviderAPI.Columns.BS_UUID + "=?", new String[]{bsUuid}, null));
for (DsrtMinModel m : dsrtModelList) {
Cursor c = new RutaDao().getRutaCursor(null, RutaProviderAPI.Columns.UUID + "=?",
new String[]{m.getRutaUuid()}, null);
RutaModel r = new RutaDao().getSingleRutaFromCursor(c);
if (r != null) {
rutaModelList.add(r);
}
}
dsrtAdapter.setRutaModelList(rutaModelList);
dsrtAdapter.notifyDataSetChanged();
}
public String getBsUuid() {
return bsUuid;
}
public String getBsNks() {
return bsNks;
}
public abstract void onGenerateMenuClicked();
}
package com.rahadi.vsen.activities;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.rahadi.vsen.R;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.contexts.VsenAPI;
import com.rahadi.vsen.fragments.CatatanFragment;
import com.rahadi.vsen.fragments.KirimFragment;
import com.rahadi.vsen.fragments.ListRutaFragment;
import com.rahadi.vsen.listeners.OnEditRutaSavedListener;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.models.UserModel;
import com.rahadi.vsen.providers.BSProviderAPI;
import com.rahadi.vsen.tasks.BSSynchronizationTask;
import com.rahadi.vsen.views.LoadingView;