Commit f1ca714d authored by Rahadi Jalu's avatar Rahadi Jalu

Merge branch 'vsenp' into 'master'

Vsenp

See merge request capi-susenas/capi-stis!1
parents 7616b8b9 896f7c87
......@@ -2,13 +2,14 @@ apply plugin: 'com.android.application'
apply from: '../config/quality.gradle'
import com.android.ddmlib.DdmPreferences
DdmPreferences.setTimeOut(60000)
ant.condition(property: 'os', value: 'windows') {
os(family: 'windows')
os(family: 'windows')
}
ant.condition(property: 'os', value: 'unix') {
os(family: 'unix')
ant.condition(property: 'os', value: 'unix') {
os(family: 'unix')
}
// Build numbers were manually set until 1067
......@@ -62,13 +63,13 @@ if (secretsFile.exists()) {
}
android {
compileSdkVersion(25)
compileSdkVersion(26)
buildToolsVersion('26.0.2')
defaultConfig {
applicationId('org.odk.collect.android')
minSdkVersion(16)
targetSdkVersion(25)
targetSdkVersion(26)
versionCode LEGACY_BUILD_NUMBER_OFFSET + getMasterCommitCount()
versionName getVersionName()
testInstrumentationRunner('android.support.test.runner.AndroidJUnitRunner')
......@@ -143,15 +144,15 @@ allprojects {
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile group: 'com.android.support', name: 'appcompat-v7', version: '25.3.1'
compile group: 'com.android.support', name: 'design', version: '25.3.1'
compile group: 'com.android.support', name: 'cardview-v7', version: '25.3.1'
compile group: 'com.android.support', name: 'appcompat-v7', version: '26.1.0'
compile group: 'com.android.support', name: 'design', version: '26.1.0'
compile group: 'com.android.support', name: 'cardview-v7', version: '26.1.0'
compile group: 'com.android.support', name: 'multidex', version: '1.0.1'
compile group: 'com.google.android.gms', name: 'play-services-analytics', version: '10.0.1'
compile group: 'com.google.android.gms', name: 'play-services-auth', version: '10.0.1'
compile group: 'com.google.android.gms', name: 'play-services-maps', version: '10.0.1'
compile group: 'com.google.android.gms', name: 'play-services-location', version: '10.0.1'
compile (group: 'com.google.code.gson', name: 'gson', version: '2.6.2' ){
compile(group: 'com.google.code.gson', name: 'gson', version: '2.6.2') {
exclude group: 'org.apache.httpcomponents'
}
compile group: 'com.google.firebase', name: 'firebase-core', version: '10.0.1'
......@@ -166,18 +167,24 @@ dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.4'
compile group: 'net.sf.kxml', name: 'kxml2', version: '2.3.0'
compile group: 'net.sf.opencsv', name: 'opencsv', version: '2.3'
compile (group: 'org.opendatakit', name: 'opendatakit-javarosa', version: '2.6.1') {
compile(group: 'org.opendatakit', name: 'opendatakit-javarosa', version: '2.6.1') {
exclude module: 'joda-time'
}
compile group: 'org.osmdroid', name: 'osmdroid-android', version: '5.6.4'
compile group: 'org.slf4j', name: 'slf4j-android', version: '1.6.1-RC1'
compile group: 'pub.devrel', name: 'easypermissions', version: '0.2.1'
compile(group: 'com.google.api-client', name: 'google-api-client-android', version: '1.22.0') { exclude group: 'org.apache.httpcomponents' }
compile(group: 'com.google.apis', name: 'google-api-services-drive', version: 'v3-rev64-1.22.0') { exclude group: 'org.apache.httpcomponents' }
compile(group: 'com.google.apis', name: 'google-api-services-sheets', version: 'v4-rev463-1.22.0') { exclude group: 'org.apache.httpcomponents' }
compile(group: 'com.google.api-client', name: 'google-api-client-android', version: '1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile(group: 'com.google.apis', name: 'google-api-services-drive', version: 'v3-rev64-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile(group: 'com.google.apis', name: 'google-api-services-sheets', version: 'v4-rev463-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
compile group: 'com.jakewharton.timber', name: 'timber', version: '4.5.1'
compile group: 'com.android.support', name: 'customtabs', version: '25.3.1'
compile group: 'com.android.support', name: 'support-v13', version: '25.3.1'
compile group: 'com.android.support', name: 'customtabs', version: '26.1.0'
compile group: 'com.android.support', name: 'support-v13', version: '26.1.0'
compile group: 'com.google.zxing', name: 'core', version: '3.2.0'
compile group: 'com.journeyapps', name: 'zxing-android-embedded', version: '3.5.0'
compile group: 'net.danlew', name: 'android.joda', version: '2.9.9'
......@@ -202,7 +209,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
androidTestCompile(group: 'com.android.support.test.espresso', name: 'espresso-intents', version: '3.0.1') {
androidTestCompile(group: 'com.android.support.test.espresso', name: 'espresso-intents', version: '3.0.1') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
......@@ -218,10 +225,11 @@ dependencies {
transitive = true
}
compile project(':slidingmenu')
compile project(':vsen_p')
compile 'org.apache.commons:commons-lang3:3.6'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.2'
......
......@@ -40,14 +40,16 @@ the specific language governing permissions and limitations under the License.
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<!-- Get permission for reliable local dispatching on non-Google Play devices. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus"
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature android:name="android.hardware.screen.portrait"
<uses-feature
android:name="android.hardware.screen.portrait"
android:required="false" />
<uses-feature
......@@ -124,8 +126,8 @@ the specific language governing permissions and limitations under the License.
android:taskAffinity="" />
<activity
android:name=".activities.DrawActivity"
android:screenOrientation="landscape"
android:label="@string/app_name" />
android:label="@string/app_name"
android:screenOrientation="landscape" />
<activity
android:name=".activities.OpenSourceLicensesActivity"
android:label="@string/all_open_source_licenses" />
......@@ -137,7 +139,7 @@ the specific language governing permissions and limitations under the License.
<activity
android:name=".activities.InstanceChooserList"
android:label="@string/app_name"
android:theme="@style/AppTheme.WithActionBar" >
android:theme="@style/AppTheme.WithActionBar">
<intent-filter android:scheme="http">
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
......@@ -253,6 +255,7 @@ the specific language governing permissions and limitations under the License.
</activity>
<activity android:name=".activities.CaptureSelfieActivity" />
<activity android:name=".activities.CaptureSelfieActivityNewApi" />
<receiver
android:name=".receivers.NetworkReceiver"
android:enabled="true">
......@@ -293,21 +296,23 @@ the specific language governing permissions and limitations under the License.
android:required="false" />
<activity android:name=".activities.PermissionActivity" />
<!-- tambahan untuk CAPI-STIS -->
<provider
android:authorities="org.odk.collect.android.capi.CapiFileProvider"
android:name=".capi.CapiFileProvider"
android:authorities="org.odk.collect.android.capi.CapiFileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/capi_file_paths" />
</provider>
<activity android:name=".capi.activity.CapiLoginActivity" />
<activity android:name=".capi.activity.CapiMainActivity"
android:launchMode="singleTop"/>
<activity
android:name=".capi.activity.CapiMainActivity"
android:launchMode="singleTop" />
<activity android:name=".capi.activity.CapiInstanceActivity">
<meta-data
android:name="android.app.searchable"
......@@ -322,43 +327,55 @@ the specific language governing permissions and limitations under the License.
<activity
android:name=".petawbdigital.activities.SettingTampilan"
android:label="Pengaturan Tampilan"
android:theme="@style/AppTheme"/>
android:theme="@style/VsenAppTheme" />
<activity
android:name=".petawbdigital.activities.PanduanActivity"
android:label="Penjelasan Fitur"
android:theme="@style/AppTheme"/>
android:theme="@style/VsenAppTheme" />
<activity
android:name=".petawbdigital.activities.ItemPanduanActivity"
android:label="Penjelasan Detail"
android:theme="@style/AppTheme"/>
android:theme="@style/VsenAppTheme" />
<activity
android:name=".petawbdigital.activities.KonfigurasiPeta"
android:label="Konfigurasi Peta"
android:theme="@style/AppTheme"/>
android:theme="@style/VsenAppTheme" />
<activity
android:name=".activities.GeoPointMapboxActivity"
android:label="Get Location"
android:theme="@style/AppTheme.WithCompatActionBar"/>
android:theme="@style/AppTheme.WithCompatActionBar" />
<provider
android:name=".revalidasi.custom.NotifDataProvider"
android:authorities="org.odk.collect.android.provider.odk.notifdata"
android:exported="false" />
<service
android:name=".revalidasi.notifikasi.MyFirebaseMessagingService">
<service android:name=".revalidasi.notifikasi.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name=".revalidasi.notifikasi.MyFirebaseInstanceIDService">
<service android:name=".revalidasi.notifikasi.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<activity android:name=".revalidasi.activities.DataDownloadActivity"
<activity
android:name=".revalidasi.activities.DataDownloadActivity"
android:label="Unduh Isian"
android:parentActivityName=".capi.activity.CapiMainActivity"/>
android:parentActivityName=".capi.activity.CapiMainActivity" />
<activity
android:name=".pemutakhiran.activities.BSActivity"
android:theme="@style/VsenAppTheme" />
<activity
android:name=".pemutakhiran.activities.RutaActivity"
android:theme="@style/VsenAppTheme" />
<activity
android:name=".pemutakhiran.activities.DsrtActivity"
android:theme="@style/VsenAppTheme" />
</application>
......
......@@ -26,7 +26,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.v4.view.ViewConfigurationCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
......@@ -35,7 +34,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
......
......@@ -16,54 +16,28 @@ package org.odk.collect.android.activities;
import android.Manifest;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Window;
import android.widget.Toast;
import org.javarosa.core.services.IPropertyManager;
import org.javarosa.core.services.properties.IPropertyRules;
import org.odk.collect.android.BuildConfig;
import org.odk.collect.android.R;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.capi.preferences.Constants;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences;
import org.odk.collect.android.capi.activity.CapiMainActivity;
import org.odk.collect.android.capi.activity.CapiLoginActivity;
import org.odk.collect.android.database.ActivityLogger;
import org.odk.collect.android.logic.FormController;
import org.odk.collect.android.logic.PropertyManager;
import org.odk.collect.android.capi.activity.CapiMainActivity;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import timber.log.Timber;
import static org.odk.collect.android.preferences.PreferenceKeys.KEY_METADATA_EMAIL;
import static org.odk.collect.android.preferences.PreferenceKeys.KEY_METADATA_PHONENUMBER;
import static org.odk.collect.android.preferences.PreferenceKeys.KEY_METADATA_USERGROUP;
import static org.odk.collect.android.preferences.PreferenceKeys.KEY_METADATA_USERNAME;
/**
* edit Muhammad Tohir
* edit Mahendri Dwicahyo
......@@ -104,6 +78,7 @@ public class SplashScreenActivity extends AppCompatActivity {
if (preferences.getBoolean(PreferenceKeys.KEY_LOGIN_STATUS, false)) {
startActivity(new Intent(this, CapiMainActivity.class));
// startActivity(new Intent(this, BSActivity.class));
} else {
startActivity(new Intent(this, CapiLoginActivity.class));
}
......@@ -112,14 +87,14 @@ public class SplashScreenActivity extends AppCompatActivity {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
switch (requestCode){
switch (requestCode) {
case 1:
boolean allGranted = true;
for (int grantResult : grantResults) {
if (grantResult != PackageManager.PERMISSION_GRANTED) allGranted = false;
}
if(allGranted){
if (allGranted) {
endSplashScreen();
} else {
AlertDialog dialog = new AlertDialog.Builder(this)
......@@ -135,7 +110,7 @@ public class SplashScreenActivity extends AppCompatActivity {
}
private void requestPermission() {
Log.d("DEBUGCOLL","request permission");
Log.d("DEBUGCOLL", "request permission");
ActivityCompat.requestPermissions(this,
new String[]{
Manifest.permission.READ_PHONE_STATE,
......@@ -145,10 +120,10 @@ public class SplashScreenActivity extends AppCompatActivity {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA
},1);
}, 1);
}
private boolean isAllPermissionGranted(){
private boolean isAllPermissionGranted() {
return !(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED ||
......@@ -163,10 +138,10 @@ public class SplashScreenActivity extends AppCompatActivity {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if(isAllPermissionGranted()) endSplashScreen();
if (isAllPermissionGranted()) endSplashScreen();
else requestPermission();
}
},1000);
}, 1000);
}
private void createErrorDialog(String errorMsg, final boolean shouldExit) {
......
package org.odk.collect.android.capi.activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
......@@ -17,20 +14,23 @@ import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.GsonBuilder;
import com.rahadi.vsen.contexts.Vsen;
import com.rahadi.vsen.listeners.OnSynchronizationCompletedListener;
import com.rahadi.vsen.models.UserModel;
import com.rahadi.vsen.tasks.BSSynchronizationTask;
import com.rahadi.vsen.tasks.GetGenerateTask;
import com.rahadi.vsen.tasks.UserRegisterTask;
import org.json.JSONArray;
import org.json.JSONObject;
import org.odk.collect.android.R;
import org.odk.collect.android.application.Collect;
import org.odk.collect.android.capi.preferences.CapiInstancePreferences;
import org.odk.collect.android.capi.Helper;
import org.odk.collect.android.capi.ModelResponse;
import org.odk.collect.android.capi.preferences.Constants;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.preferences.PreferencesActivity;
import org.odk.collect.android.revalidasi.notifikasi.ConfigKey;
import org.odk.collect.android.revalidasi.notifikasi.GetUuidTask;
import org.odk.collect.android.utilities.WebUtils;
import java.util.Map;
import timber.log.Timber;
/**
* @author Mahendri Dwicahyo
......@@ -69,19 +69,20 @@ public class CapiLoginActivity extends AppCompatActivity
@Override
public void onClick(View v) {
switch (v.getId()){
switch (v.getId()) {
case R.id.btn_login:
if(TextUtils.isEmpty(username.getText().toString())){
if (TextUtils.isEmpty(username.getText().toString())) {
Toast.makeText(this, "Username can't be empty", Toast.LENGTH_SHORT).show();
return;
}
if(TextUtils.isEmpty(password.getText().toString())){
Toast.makeText(this, "Pasword can't be empty", Toast.LENGTH_SHORT).show();
if (TextUtils.isEmpty(password.getText().toString())) {
Toast.makeText(this, "Password can't be empty", Toast.LENGTH_SHORT).show();
return;
}
login(username.getText().toString(), password.getText().toString());
// startActivity(new Intent(this, BSActivity.class));
break;
case R.id.server_config_text:
......@@ -110,26 +111,79 @@ public class CapiLoginActivity extends AppCompatActivity
@Override
public void loginDone(String result) {
//enable login button
final String username = (String) GeneralSharedPreferences.getInstance().get(PreferenceKeys.KEY_USERNAME);
final String uuid = (String) GeneralSharedPreferences.getInstance().get(PreferenceKeys.KEY_UNIQUES);
new UserRegisterTask(username, uuid).execute(new OnSynchronizationCompletedListener<JSONObject>() {
@Override
public void onSynchronizationCompleted(JSONObject result) {
UserModel r = new GsonBuilder().create().fromJson(result.toString(), UserModel.class);
Timber.d(r.toString());
Vsen.getInstance().setUserSession(r);
dialog.setMessage("Sinkronisasi Data..");
new BSSynchronizationTask(null, null).execute(username, uuid,
new OnSynchronizationCompletedListener<JSONArray>() {
@Override
public void onSynchronizationCompleted(JSONArray result) {
// TODO: 20/02/2018 RAHADI: dynamize
String formId = "VSEN18K.v2";
new GetGenerateTask(formId).execute(new OnSynchronizationCompletedListener<String>() {
@Override
public void onSynchronizationCompleted(String result) {
onLoginSucceed();
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
@Override
public void onSynchronizationFailed(Exception e) {
Timber.e(e);
onLoginFailed(e.toString());
}
});
}
private void onLoginSucceed() {
dialog.dismiss();
loginBtn.setClickable(true);
loginBtn.setText("LOGIN");
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorAccent));
//process the result
if (ConfigKey.LOGIN_SUCCESS.equals(result)){
GeneralSharedPreferences.getInstance().save(PreferenceKeys.KEY_LOGIN_STATUS, true);
Intent toMain = new Intent(this, CapiMainActivity.class);
startActivity(toMain);
finish();
} else {
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder
.setTitle("Login Gagal")
.setMessage(result)
.setPositiveButton("OK", null)
.create()
.show();
}
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
GeneralSharedPreferences.getInstance().save(PreferenceKeys.KEY_LOGIN_STATUS, true);
// Intent toMain = new Intent(this, BSActivity.class);
Intent toMain = new Intent(this, CapiMainActivity.class);
startActivity(toMain);
finish();
}
private void onLoginFailed(String result) {
dialog.dismiss();
loginBtn.setText("LOGIN");
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
alertBuilder
.setTitle("Login Gagal")
.setMessage(result)
.setPositiveButton("OK", null)
.create()
.show();
}
}
\ No newline at end of file
}
package org.odk.collect.android.pemutakhiran.activities;
import android.os.Bundle;
import com.rahadi.vsen.activities.BSImpActivity;
/**
* Created by Rahadi on 27/01/2018.
*/
public class BSActivity extends BSImpActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public Class getDsrtActivityClass() {
return DsrtActivity.class;
}
@Override
public Class getRutaActivityClass() {
return RutaActivity.class;
}
}
package org.odk.collect.android.pemutakhiran.activities;
import android.app.ProgressDialog;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.Toast;
import com.rahadi.vsen.activities.DsrtMinImpActivity;
import com.rahadi.vsen.daos.RutaDao;