Commit ab1884d7 authored by mahendri.md's avatar mahendri.md

fix error on drawer n login button

parent 06d3876e
......@@ -38,7 +38,6 @@ import java.util.Map;
public class CapiLoginActivity extends AppCompatActivity
implements View.OnClickListener, GetUuidTask.LoginListener {
private TextView serverText;
private Button loginBtn;
private EditText username, password;
private GetUuidTask loginTask;
......@@ -49,7 +48,7 @@ public class CapiLoginActivity extends AppCompatActivity
super.onCreate(savedInstanceState);
setContentView(R.layout.capi_activity_login);
serverText = (TextView) findViewById(R.id.server_config_text);
TextView serverText = (TextView) findViewById(R.id.server_config_text);
loginBtn = (Button) findViewById(R.id.btn_login);
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
......@@ -92,22 +91,32 @@ public class CapiLoginActivity extends AppCompatActivity
}
public void login(final String username, final String password){
//disable login button
loginBtn.setClickable(false);
loginBtn.setText("Proses login");
loginBtn.setBackgroundColor(Color.GRAY);
//create dialog
dialog = new ProgressDialog(this);
dialog.setMessage("Login, mohon tunggu. . .");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
//execute login task
loginTask = new GetUuidTask(this);
loginTask.execute(username, password);
}
@Override
public void loginDone(String result) {
//enable login button
dialog.dismiss();
loginBtn.setClickable(true);
loginBtn.setText("LOGIN");
loginBtn.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
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);
......
......@@ -19,6 +19,7 @@ import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.firebase.messaging.FirebaseMessaging;
import com.mikepenz.materialdrawer.AccountHeader;
......@@ -47,7 +48,13 @@ 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.ModelSurvey;
import org.odk.collect.android.database.ItemsetDbAdapter;
import org.odk.collect.android.listeners.DiskSyncListener;
import org.odk.collect.android.petawbdigital.activities.GeoPointMapboxRevoActivity;
import org.odk.collect.android.petawbdigital.assets.VAR;
import org.odk.collect.android.petawbdigital.externals.AksesDataOdk;
import org.odk.collect.android.petawbdigital.models.BlokSensus;
import org.odk.collect.android.petawbdigital.models.Form;
import org.odk.collect.android.preferences.GeneralSharedPreferences;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.revalidasi.activities.DataDownloadActivity;
......@@ -69,6 +76,7 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
//Identifier
private static final int MENUSURVEY = 4;
private static final int MENU_UPDATE = 5;
private static final int MENU_PETA_WB = 6;
private static final int MENUSETTING = 8;
private static final int MENULOGOUT = 9;
......@@ -201,10 +209,20 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
.withItemAnimator(new DefaultItemAnimator())
.withAccountHeader(accountHeader)
.addDrawerItems(
new PrimaryDrawerItem().withName("Daftar Kuesioner").withIcon(R.drawable.ic_survey).withIdentifier(MENUSURVEY),
new PrimaryDrawerItem().withName("Update Isian").withIcon(R.drawable.ic_assignment_done).withIdentifier(MENU_UPDATE),
new PrimaryDrawerItem()
.withName("Daftar Kuesioner")
.withIcon(R.drawable.ic_survey)
.withIdentifier(MENUSURVEY),
new PrimaryDrawerItem()
.withName("Isian Dikembalikan")
.withIcon(R.drawable.ic_assignment_done)
.withIdentifier(MENU_UPDATE),
new PrimaryDrawerItem()
.withName("Peta WB Digital")
.withIcon(R.drawable.wb_ic_map)
.withIdentifier(MENU_PETA_WB),
new DividerDrawerItem(),
new PrimaryDrawerItem().withName("Pengaturan CAPI").withIcon(R.drawable.ic_setting).withIdentifier(MENUSETTING),
new PrimaryDrawerItem().withName("Pengaturan").withIcon(R.drawable.ic_setting).withIdentifier(MENUSETTING),
new PrimaryDrawerItem().withName("Logout").withIcon(R.drawable.ic_logout).withIdentifier(MENULOGOUT)
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
......@@ -221,6 +239,10 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
startActivity(toDownUpdate);
break;
case MENU_PETA_WB:
showModal();
break;
case MENULOGOUT:
AlertDialog.Builder builder = new AlertDialog.Builder(CapiMainActivity.this);
builder.setMessage("Are you sure to logout?");
......@@ -246,4 +268,83 @@ public class CapiMainActivity extends AppCompatActivity implements DiskSyncListe
result = builder.build();
result.setSelection(MENUSURVEY);
}
private void showModal() {
final ArrayList<BlokSensus> listBs = ItemsetDbAdapter.getInstance(this).getListBlokSensus();
if (listBs!=null&&listBs.size()>0){
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
final String[] idSelectedBs = {""};
idSelectedBs[0] = listBs.get(0).getIdBs();
final String[] namaListBs = new String[listBs.size()];
Log.d(VAR.DEBUG,"size bs : "+listBs.size());
for(int n=0;n<listBs.size();n++){
namaListBs[n] = listBs.get(n).getNamaBs();
}
builder.setTitle("Pilih Blok Sensus");
builder.setSingleChoiceItems(
namaListBs, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
idSelectedBs[0] = listBs.get(i).getIdBs();
}
}
);
builder.setPositiveButton("Lihat", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
AksesDataOdk aksesDataOdk = new AksesDataOdk();
final ArrayList<Form> arform = aksesDataOdk.getKeteranganForm();
String[] items = new String[arform.size()];
for (int i=0; i<arform.size(); i++){
items[i] = arform.get(i).getDisplayName();
}
final int[] kuesselected = {0};
final String[] idKuesioner = {""};
android.app.AlertDialog dialog2 = new android.app.AlertDialog.Builder(CapiMainActivity.this)
.setTitle("Pilih Form Kuesioner")
.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog2, int which2) {
kuesselected[0] = which2;
}
})
.setPositiveButton("Pilih", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog2, int id2) {
idKuesioner[0] = arform.get(kuesselected[0]).getIdForm();
Log.d(VAR.DEBUG, "kuesioner : " + idKuesioner[0]);
Intent intent = new Intent(CapiMainActivity.this,GeoPointMapboxRevoActivity.class);
intent.putExtra("idBs", idSelectedBs[0]);
intent.putExtra("idKuesioner", idKuesioner[0]);
intent.putExtra("question", false);
startActivity(intent);
}
})
.setNegativeButton("Batal", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog2, int id) {
dialog2.dismiss();
}
}).create();
dialog.dismiss();
dialog2.show();
}
});
builder.setNegativeButton("Batal", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
} else {
Toast.makeText(this, "Belum ada data blok sensus", Toast.LENGTH_SHORT).show();
}
}
}
......@@ -269,13 +269,6 @@ public class CapiFormFragment extends Fragment
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_map:
showModal();
break;
case R.id.action_preferences:
startActivity(new Intent(getActivity(), PreferencesActivity.class));
// startActivity(new Intent(getActivity(), CapiInstancePreferences.class));
break;
case R.id.action_sort:
//show dialog sort
showDialogSortOptions();
......@@ -284,91 +277,10 @@ public class CapiFormFragment extends Fragment
Toast.makeText(getContext(), "Refreshing..", Toast.LENGTH_SHORT).show();
onRefresPage();
break;
case R.id.action_setting_map:
startActivity(new Intent(getActivity(), KonfigurasiPeta.class));
break;
}
return super.onOptionsItemSelected(item);
}
private void showModal() {
final ArrayList<BlokSensus> listBs = ItemsetDbAdapter.getInstance(getContext()).getListBlokSensus();
if (listBs!=null&&listBs.size()>0){
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final String[] idSelectedBs = {""};
idSelectedBs[0] = listBs.get(0).getIdBs();
final String[] namaListBs = new String[listBs.size()];
Log.d(VAR.DEBUG,"size bs : "+listBs.size());
for(int n=0;n<listBs.size();n++){
namaListBs[n] = listBs.get(n).getNamaBs();
}
builder.setTitle("Pilih Blok Sensus");
builder.setSingleChoiceItems(
namaListBs, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
idSelectedBs[0] = listBs.get(i).getIdBs();
}
}
);
builder.setPositiveButton("Lihat", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
AksesDataOdk aksesDataOdk = new AksesDataOdk();
final ArrayList<Form> arform = aksesDataOdk.getKeteranganForm();
String[] items = new String[arform.size()];
for (int i=0; i<arform.size(); i++){
items[i] = arform.get(i).getDisplayName();
}
final int[] kuesselected = {0};
final String[] idKuesioner = {""};
android.app.AlertDialog dialog2 = new android.app.AlertDialog.Builder(getActivity())
.setTitle("Pilih Form Kuesioner")
.setSingleChoiceItems(items, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog2, int which2) {
kuesselected[0] = which2;
}
})
.setPositiveButton("Pilih", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog2, int id2) {
idKuesioner[0] = arform.get(kuesselected[0]).getIdForm();
Log.d(VAR.DEBUG, "kuesioner : " + idKuesioner[0]);
Intent intent = new Intent(getActivity(),GeoPointMapboxRevoActivity.class);
intent.putExtra("idBs", idSelectedBs[0]);
intent.putExtra("idKuesioner", idKuesioner[0]);
intent.putExtra("question", false);
startActivity(intent);
}
})
.setNegativeButton("Batal", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog2, int id) {
dialog2.dismiss();
}
}).create();
dialog.dismiss();
dialog2.show();
}
});
builder.setNegativeButton("Batal", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
} else {
Toast.makeText(getActivity(), "Belum ada data blok sensus", Toast.LENGTH_SHORT).show();
}
}
private void showDialogSortOptions() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle("Sort Options");
......@@ -556,6 +468,7 @@ public class CapiFormFragment extends Fragment
* Called when the form list has finished downloading. results will either contain a set of
* <formname, formdetails> tuples, or one tuple of DL.ERROR.MSG and the associated message.
*/
@Override
public void formListDownloadingComplete(HashMap<String, FormDetails> result) {
downloadFormListTask.setDownloaderListener(null);
downloadFormListTask = null;
......
......@@ -21,6 +21,7 @@ import android.widget.Toast;
import org.odk.collect.android.R;
import org.odk.collect.android.capi.ParseXml;
import org.odk.collect.android.dao.FormsDao;
import org.odk.collect.android.petawbdigital.activities.KonfigurasiPeta;
import org.odk.collect.android.preferences.PreferenceKeys;
import org.odk.collect.android.preferences.PreferencesActivity;
import org.odk.collect.android.provider.FormsProviderAPI;
......@@ -34,7 +35,8 @@ public class CapiInstancePreferences extends AppCompatActivity
private LinearLayout primaryHolder;
private LinearLayout secondaryHolder;
private LinearLayout constraintOption;
private LinearLayout advancedSetting;
private TextView advancedSetting;
private TextView petaWbSetting;
private TextView primaryTextSummary, secondaryTextSummary, constraintValue;
private Switch showTableSwitch, showGroupInOneScreenSwitch;
private String formIds = "";
......@@ -62,7 +64,7 @@ public class CapiInstancePreferences extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.collectiva_activity_preferences);
setContentView(R.layout.capi_activity_preferences);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setTitle("Quick Preferences");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
......@@ -74,7 +76,8 @@ public class CapiInstancePreferences extends AppCompatActivity
secondaryTextSummary = (TextView) findViewById(R.id.secondary_text_summary);
showTableSwitch = (Switch) findViewById(R.id.switch_show_table);
showGroupInOneScreenSwitch = (Switch) findViewById(R.id.switch_show_onscreen);
advancedSetting = (LinearLayout) findViewById(R.id.advanced_setting);
advancedSetting = (TextView) findViewById(R.id.advanced_setting);
petaWbSetting = (TextView) findViewById(R.id.wb_peta_setting);
constraintOption = (LinearLayout) findViewById(R.id.constraint_option);
constraintValue = (TextView) findViewById(R.id.constraint_value);
......@@ -91,6 +94,7 @@ public class CapiInstancePreferences extends AppCompatActivity
constraintOption.setOnClickListener(this);
advancedSetting.setOnClickListener(this);
petaWbSetting.setOnClickListener(this);
primaryHolder.setOnClickListener(this);
secondaryHolder.setOnClickListener(this);
showTableSwitch.setOnCheckedChangeListener(this);
......@@ -129,15 +133,25 @@ public class CapiInstancePreferences extends AppCompatActivity
@Override
public void onClick(View v) {
if(v == primaryHolder){
selectPrimaryText();
}else if(v==secondaryHolder){
selectSecondaryText();
}else if(v==constraintOption){
selectConstraintType();
} else if(v==advancedSetting){
// showAdvancedSettingWithPassword();
startActivity(new Intent(CapiInstancePreferences.this, PreferencesActivity.class));
switch (v.getId()){
case R.id.primary_text_holder:
selectPrimaryText();
break;
case R.id.secondary_text_holder:
selectSecondaryText();
break;
case R.id.constraint_option:
selectConstraintType();
break;
case R.id.advanced_setting:
startActivity(new Intent(this, PreferencesActivity.class));
finish();
break;
case R.id.wb_peta_setting:
startActivity(new Intent(this, KonfigurasiPeta.class));
finish();
break;
}
}
......
......@@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#ffffff"
android:fillColor="#FF000000"
android:pathData="M20.5,3l-0.16,0.03L15,5.1 9,3 3.36,4.9c-0.21,0.07 -0.36,0.25 -0.36,0.48V20.5c0,0.28 0.22,0.5 0.5,0.5l0.16,-0.03L9,18.9l6,2.1 5.64,-1.9c0.21,-0.07 0.36,-0.25 0.36,-0.48V3.5c0,-0.28 -0.22,-0.5 -0.5,-0.5zM15,19l-6,-2.11V5l6,2.11V19z"/>
</vector>
......@@ -184,20 +184,32 @@
android:layout_height="0.5dp"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:id="@+id/advanced_setting"
android:clickable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="16dp">
android:orientation="vertical">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:id="@+id/advanced_setting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_vertical_margin"
android:text="Show General Setting"
android:layout_marginRight="16dp"
android:textColor="@color/black"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@android:color/darker_gray"/>
<TextView
android:id="@+id/wb_peta_setting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_vertical_margin"
android:text="Show Peta WB Setting"
android:textColor="@color/black"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
......
......@@ -23,27 +23,13 @@
android:icon="@drawable/ic_sort"
android:orderInCategory="100"
android:title="Filter"
app:showAsAction="ifRoom" />
app:showAsAction="never" />
<item
android:id="@+id/action_refresh"
android:icon="@drawable/ic_menu_refresh"
android:orderInCategory="100"
android:title="Refresh"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_preferences"
android:icon="@drawable/ic_setting"
android:orderInCategory="100"
android:title="General Setting"
app:showAsAction="never" />
<item
android:id="@+id/action_setting_map"
android:icon="@drawable/ic_setting"
android:orderInCategory="100"
android:title="Konfigurasi Peta"
app:showAsAction="never" />
</menu>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment