Search in sources :

Example 1 with BlankForm

use of org.odk.collect.android.formmanagement.BlankFormsListViewModel.BlankForm in project collect by opendatakit.

the class AndroidShortcutsActivity method onCreate.

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    DaggerUtils.getComponent(this).inject(this);
    BlankFormsListViewModel blankFormsListViewModel = new ViewModelProvider(this, blankFormsListViewModelFactory).get(BlankFormsListViewModel.class);
    List<BlankForm> forms = blankFormsListViewModel.getForms();
    showFormListDialog(forms);
}
Also used : BlankForm(org.odk.collect.android.formmanagement.BlankFormsListViewModel.BlankForm) BlankFormsListViewModel(org.odk.collect.android.formmanagement.BlankFormsListViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 2 with BlankForm

use of org.odk.collect.android.formmanagement.BlankFormsListViewModel.BlankForm in project collect by opendatakit.

the class AndroidShortcutsActivity method showFormListDialog.

private void showFormListDialog(List<BlankForm> forms) {
    new MaterialAlertDialogBuilder(this).setTitle(R.string.select_odk_shortcut).setItems(forms.stream().map(BlankForm::getName).toArray(String[]::new), (dialog, item) -> {
        AnalyticsUtils.logServerEvent(AnalyticsEvents.CREATE_SHORTCUT, settingsProvider.getUnprotectedSettings());
        Intent intent = getShortcutIntent(forms, item);
        setResult(RESULT_OK, intent);
        finish();
    }).setOnCancelListener(dialog -> {
        setResult(RESULT_CANCELED);
        finish();
    }).create().show();
}
Also used : BlankFormsListViewModel(org.odk.collect.android.formmanagement.BlankFormsListViewModel) Bundle(android.os.Bundle) Parcelable(android.os.Parcelable) SettingsProvider(org.odk.collect.settings.SettingsProvider) ViewModelProvider(androidx.lifecycle.ViewModelProvider) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Intent(android.content.Intent) AnalyticsEvents(org.odk.collect.android.analytics.AnalyticsEvents) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) Inject(javax.inject.Inject) DaggerUtils(org.odk.collect.android.injection.DaggerUtils) List(java.util.List) AnalyticsUtils(org.odk.collect.android.analytics.AnalyticsUtils) R(org.odk.collect.android.R) BlankForm(org.odk.collect.android.formmanagement.BlankFormsListViewModel.BlankForm) NotNull(org.jetbrains.annotations.NotNull) Intent(android.content.Intent) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder)

Aggregations

ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 BlankFormsListViewModel (org.odk.collect.android.formmanagement.BlankFormsListViewModel)2 BlankForm (org.odk.collect.android.formmanagement.BlankFormsListViewModel.BlankForm)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Parcelable (android.os.Parcelable)1 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)1 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)1 List (java.util.List)1 Inject (javax.inject.Inject)1 NotNull (org.jetbrains.annotations.NotNull)1 R (org.odk.collect.android.R)1 AnalyticsEvents (org.odk.collect.android.analytics.AnalyticsEvents)1 AnalyticsUtils (org.odk.collect.android.analytics.AnalyticsUtils)1 DaggerUtils (org.odk.collect.android.injection.DaggerUtils)1 SettingsProvider (org.odk.collect.settings.SettingsProvider)1