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) {
......
/*
* Copyright (C) 2011 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package org.odk.collect.android.application;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.multidex.MultiDex;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import com.google.android.gms.analytics.Tracker;
import com.google.firebase.crash.FirebaseCrash;
import org.odk.collect.android.BuildConfig;
import org.odk.collect.android.R;
import org.odk.collect.android.database.ActivityLogger;
import org.odk.collect.android.external.ExternalDataManager;
import org.odk.collect.android.logic.FormController;
import org.odk.collect.android.logic.PropertyManager;
import org.odk.collect.android.preferences.AutoSendPreferenceMigrator;
import org.odk.collect.android.preferences.FormMetadataMigrator;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.utilities.AgingCredentialsProvider;
import org.odk.collect.android.utilities.AuthDialogUtility;
import org.odk.collect.android.utilities.LocaleHelper;
import org.odk.collect.android.utilities.PRNGFixes;
import org.opendatakit.httpclientandroidlib.client.CookieStore;
import org.opendatakit.httpclientandroidlib.client.CredentialsProvider;
import org.opendatakit.httpclientandroidlib.client.protocol.HttpClientContext;
import org.opendatakit.httpclientandroidlib.impl.client.BasicCookieStore;
import org.opendatakit.httpclientandroidlib.protocol.BasicHttpContext;
import org.opendatakit.httpclientandroidlib.protocol.HttpContext;
import java.io.File;
import java.util.Locale;
import timber.log.Timber;
/**
* The Open Data Kit Collect application.
*
* @author carlhartung
* edit Mahendri Dwicahyo
*/
public class Collect extends Application {
// Storage paths
public static final String ODK_ROOT = Environment.getExternalStorageDirectory()
+ File.separator + "capi-stis";
public static final String FORMS_PATH = ODK_ROOT + File.separator + "forms";
public static final String INSTANCES_PATH = ODK_ROOT + File.separator + "instances";
public static final String CACHE_PATH = ODK_ROOT + File.separator + ".cache";
public static final String METADATA_PATH = ODK_ROOT + File.separator + "metadata";
public static final String TMPFILE_PATH = CACHE_PATH + File.separator + "tmp.jpg";
public static final String TMPDRAWFILE_PATH = CACHE_PATH + File.separator + "tmpDraw.jpg";
public static final String LOG_PATH = ODK_ROOT + File.separator + "log";
public static final String DEFAULT_FONTSIZE = "16";
public static final String OFFLINE_LAYERS = ODK_ROOT + File.separator + "layers";
public static final String SETTINGS = ODK_ROOT + File.separator + "settings";
//modif CAPI
public static final String BRIEFCASE_PATH = ODK_ROOT + File.separator + "briefcase";
public static final String INSTANCES_DOWNLOAD_PATH = ODK_ROOT + File.separator + "instances" + File.separator + "from aggregate";
public static final String INSTANCES_SAMPELTERPILIH_PATH = ODK_ROOT + File.separator + "instances" + File.separator + "sampel terpilih";
private static Collect singleton = null;
static {
PRNGFixes.apply();
}
// share all session cookies across all sessions...
private CookieStore cookieStore = new BasicCookieStore();
// retain credentials for 7 minutes...
private CredentialsProvider credsProvider = new AgingCredentialsProvider(7 * 60 * 1000);
public static ActivityLogger activityLogger;
private FormController formController = null;
private ExternalDataManager externalDataManager;
private Tracker tracker;
public static String defaultSysLanguage;
public static Collect getInstance() {
return singleton;
}
public static int getQuestionFontsize() {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(Collect
.getInstance());
String questionFont = settings.getString(PreferenceKeys.KEY_FONT_SIZE,
Collect.DEFAULT_FONTSIZE);
return Integer.valueOf(questionFont);
}
/**
* Creates required directories on the SDCard (or other external storage)
*
* @throws RuntimeException if there is no SDCard or the directory exists as a non directory
*/
public static void createODKDirs() throws RuntimeException {
String cardstatus = Environment.getExternalStorageState();
if (!cardstatus.equals(Environment.MEDIA_MOUNTED)) {
throw new RuntimeException(
Collect.getInstance().getString(R.string.sdcard_unmounted, cardstatus));
}
String[] dirs = {
ODK_ROOT, FORMS_PATH, INSTANCES_PATH, CACHE_PATH, METADATA_PATH, OFFLINE_LAYERS, BRIEFCASE_PATH
};
for (String dirName : dirs) {
File dir = new File(dirName);
if (!dir.exists()) {
if (!dir.mkdirs()) {
throw new RuntimeException("ODK reports :: Cannot create directory: "
+ dirName);
}
} else {
if (!dir.isDirectory()) {
throw new RuntimeException("ODK reports :: " + dirName
+ " exists, but is not a directory");
}
}
}
}
/**
* Predicate that tests whether a directory path might refer to an
* ODK Tables instance data directory (e.g., for media attachments).
*/
public static boolean isODKTablesInstanceDataDirectory(File directory) {
/*
* Special check to prevent deletion of files that
* could be in use by ODK Tables.
*/
String dirPath = directory.getAbsolutePath();
if (dirPath.startsWith(Collect.ODK_ROOT)) {
dirPath = dirPath.substring(Collect.ODK_ROOT.length());
String[] parts = dirPath.split(File.separator);
// [appName, instances, tableId, instanceId ]
if (parts.length == 4 && parts[1].equals("instances")) {
return true;
}
}
return false;
}
public ActivityLogger getActivityLogger() {
return activityLogger;
}
public FormController getFormController() {
return formController;
}
public void setFormController(FormController controller) {
formController = controller;
}
public ExternalDataManager getExternalDataManager() {
return externalDataManager;
}
public void setExternalDataManager(ExternalDataManager externalDataManager) {
this.externalDataManager = externalDataManager;
}
public String getVersionedAppName() {
String versionName = BuildConfig.VERSION_NAME;
versionName = " " + versionName.replaceFirst("-", "\n");
return getString(R.string.app_name) + versionName;
}
public boolean isNetworkAvailable() {
ConnectivityManager manager = (ConnectivityManager) getInstance()
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo currentNetworkInfo = manager.getActiveNetworkInfo();
return currentNetworkInfo != null && currentNetworkInfo.isConnected();
}
/*
Adds support for multidex support library. For more info check out the link below,
https://developer.android.com/studio/build/multidex.html
*/
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
/**
* Construct and return a session context with shared cookieStore and credsProvider so a user
* does not have to re-enter login information.
*/
public synchronized HttpContext getHttpContext() {
// context holds authentication state machine, so it cannot be
// shared across independent activities.
HttpContext localContext = new BasicHttpContext();
localContext.setAttribute(HttpClientContext.COOKIE_STORE, cookieStore);
localContext.setAttribute(HttpClientContext.CREDS_PROVIDER, credsProvider);