Search in sources :

Example 1 with ExternalWebPageHelper

use of org.odk.collect.android.utilities.ExternalWebPageHelper in project collect by opendatakit.

the class AboutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about_layout);
    DaggerUtils.getComponent(this).inject(this);
    initToolbar();
    int[][] items = { { R.drawable.ic_outline_website_24, R.string.odk_website, R.string.odk_website_summary }, { R.drawable.ic_outline_forum_24, R.string.odk_forum, R.string.odk_forum_summary }, { R.drawable.ic_outline_share_24, R.string.tell_your_friends, R.string.tell_your_friends_msg }, { R.drawable.ic_outline_rate_review_24, R.string.leave_a_review, R.string.leave_a_review_msg }, { R.drawable.ic_outline_stars_24, R.string.all_open_source_licenses, R.string.all_open_source_licenses_msg } };
    RecyclerView recyclerView = findViewById(R.id.recyclerView);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(new AboutListAdapter(items, this, this));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    websiteTabHelper = new ExternalWebPageHelper();
    forumTabHelper = new ExternalWebPageHelper();
    websiteUri = Uri.parse(getString(R.string.app_url));
    forumUri = Uri.parse(getString(R.string.forum_url));
}
Also used : AboutListAdapter(org.odk.collect.android.adapters.AboutListAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) ExternalWebPageHelper(org.odk.collect.android.utilities.ExternalWebPageHelper)

Example 2 with ExternalWebPageHelper

use of org.odk.collect.android.utilities.ExternalWebPageHelper in project collect by opendatakit.

the class ReferenceLayerPreferenceDialog method addHelpFooter.

private void addHelpFooter(View view) {
    LinearLayout layout = (LinearLayout) view;
    View helpFooter = LayoutInflater.from(requireContext()).inflate(R.layout.reference_layer_help_footer, layout, false);
    helpFooter.findViewById(R.id.help_button).setOnClickListener(v -> {
        new ExternalWebPageHelper().openWebPageInCustomTab(requireActivity(), Uri.parse("https://docs.getodk.org/collect-offline-maps/#transferring-offline-tilesets-to-devices"));
    });
    layout.addView(helpFooter);
}
Also used : View(android.view.View) LinearLayout(android.widget.LinearLayout) ExternalWebPageHelper(org.odk.collect.android.utilities.ExternalWebPageHelper)

Example 3 with ExternalWebPageHelper

use of org.odk.collect.android.utilities.ExternalWebPageHelper in project collect by opendatakit.

the class AudioRecordingControllerFragmentTest method setup.

@Before
public void setup() throws IOException {
    File stubRecording = File.createTempFile("test", ".m4a");
    stubRecording.deleteOnExit();
    audioRecorder = new StubAudioRecorder(stubRecording.getAbsolutePath());
    backgroundAudioViewModel = mock(BackgroundAudioViewModel.class);
    formEntryViewModel = mock(FormEntryViewModel.class);
    hasBackgroundRecording = new MutableNonNullLiveData<>(false);
    when(formEntryViewModel.hasBackgroundRecording()).thenReturn(hasBackgroundRecording);
    isBackgroundRecordingEnabled = new MutableNonNullLiveData<>(false);
    when(backgroundAudioViewModel.isBackgroundRecordingEnabled()).thenReturn(isBackgroundRecordingEnabled);
    externalWebPageHelper = mock(ExternalWebPageHelper.class);
    CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {

        @Override
        public BackgroundAudioViewModel.Factory providesBackgroundAudioViewModelFactory(AudioRecorder audioRecorder, SettingsProvider settingsProvider, PermissionsChecker permissionsChecker, Analytics analytics) {
            return new BackgroundAudioViewModel.Factory(audioRecorder, settingsProvider.getUnprotectedSettings(), permissionsChecker, System::currentTimeMillis) {

                @NonNull
                @Override
                public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
                    return (T) backgroundAudioViewModel;
                }
            };
        }

        @Override
        public FormEntryViewModel.Factory providesFormEntryViewModelFactory(Analytics analytics) {
            return new FormEntryViewModel.Factory(System::currentTimeMillis) {

                @NonNull
                @Override
                public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
                    return (T) formEntryViewModel;
                }
            };
        }

        @Override
        public AudioRecorder providesAudioRecorder(Application application) {
            return audioRecorder;
        }

        @Override
        public ExternalWebPageHelper providesExternalWebPageHelper() {
            return externalWebPageHelper;
        }
    });
}
Also used : StubAudioRecorder(org.odk.collect.audiorecorder.testsupport.StubAudioRecorder) FormEntryViewModel(org.odk.collect.android.formentry.FormEntryViewModel) AppDependencyModule(org.odk.collect.android.injection.config.AppDependencyModule) Analytics(org.odk.collect.analytics.Analytics) SettingsProvider(org.odk.collect.settings.SettingsProvider) NonNull(androidx.annotation.NonNull) StubAudioRecorder(org.odk.collect.audiorecorder.testsupport.StubAudioRecorder) AudioRecorder(org.odk.collect.audiorecorder.recording.AudioRecorder) PermissionsChecker(org.odk.collect.permissions.PermissionsChecker) BackgroundAudioViewModel(org.odk.collect.android.formentry.BackgroundAudioViewModel) File(java.io.File) Application(android.app.Application) ExternalWebPageHelper(org.odk.collect.android.utilities.ExternalWebPageHelper) Before(org.junit.Before)

Example 4 with ExternalWebPageHelper

use of org.odk.collect.android.utilities.ExternalWebPageHelper in project collect by opendatakit.

the class WidgetFactory method createWidgetFromPrompt.

public QuestionWidget createWidgetFromPrompt(FormEntryPrompt prompt, PermissionsProvider permissionsProvider) {
    String appearance = Appearances.getSanitizedAppearanceHint(prompt);
    QuestionDetails questionDetails = new QuestionDetails(prompt, readOnlyOverride);
    final QuestionWidget questionWidget;
    switch(prompt.getControlType()) {
        case Constants.CONTROL_INPUT:
            switch(prompt.getDataType()) {
                case Constants.DATATYPE_DATE_TIME:
                    questionWidget = new DateTimeWidget(activity, questionDetails, new DateTimeWidgetUtils());
                    break;
                case Constants.DATATYPE_DATE:
                    questionWidget = new DateWidget(activity, questionDetails, new DateTimeWidgetUtils());
                    break;
                case Constants.DATATYPE_TIME:
                    questionWidget = new TimeWidget(activity, questionDetails, new DateTimeWidgetUtils());
                    break;
                case Constants.DATATYPE_DECIMAL:
                    if (appearance.startsWith(Appearances.EX)) {
                        questionWidget = new ExDecimalWidget(activity, questionDetails, waitingForDataRegistry, stringRequester);
                    } else if (appearance.equals(Appearances.BEARING)) {
                        questionWidget = new BearingWidget(activity, questionDetails, waitingForDataRegistry, (SensorManager) activity.getSystemService(Context.SENSOR_SERVICE));
                    } else {
                        questionWidget = new DecimalWidget(activity, questionDetails);
                    }
                    break;
                case Constants.DATATYPE_INTEGER:
                    if (appearance.startsWith(Appearances.EX)) {
                        questionWidget = new ExIntegerWidget(activity, questionDetails, waitingForDataRegistry, stringRequester);
                    } else {
                        questionWidget = new IntegerWidget(activity, questionDetails);
                    }
                    break;
                case Constants.DATATYPE_GEOPOINT:
                    if (hasAppearance(questionDetails.getPrompt(), PLACEMENT_MAP) || hasAppearance(questionDetails.getPrompt(), MAPS)) {
                        questionWidget = new GeoPointMapWidget(activity, questionDetails, waitingForDataRegistry, new ActivityGeoDataRequester(permissionsProvider, activity));
                    } else {
                        questionWidget = new GeoPointWidget(activity, questionDetails, waitingForDataRegistry, new ActivityGeoDataRequester(permissionsProvider, activity));
                    }
                    break;
                case Constants.DATATYPE_GEOSHAPE:
                    questionWidget = new GeoShapeWidget(activity, questionDetails, waitingForDataRegistry, new ActivityGeoDataRequester(permissionsProvider, activity));
                    break;
                case Constants.DATATYPE_GEOTRACE:
                    questionWidget = new GeoTraceWidget(activity, questionDetails, waitingForDataRegistry, MapProvider.getConfigurator(), new ActivityGeoDataRequester(permissionsProvider, activity));
                    break;
                case Constants.DATATYPE_BARCODE:
                    questionWidget = new BarcodeWidget(activity, questionDetails, waitingForDataRegistry, new CameraUtils());
                    break;
                case Constants.DATATYPE_TEXT:
                    String query = prompt.getQuestion().getAdditionalAttribute(null, "query");
                    if (query != null) {
                        questionWidget = getSelectOneWidget(appearance, questionDetails);
                    } else if (appearance.startsWith(Appearances.PRINTER)) {
                        questionWidget = new ExPrinterWidget(activity, questionDetails, waitingForDataRegistry);
                    } else if (appearance.startsWith(Appearances.EX)) {
                        questionWidget = new ExStringWidget(activity, questionDetails, waitingForDataRegistry, stringRequester);
                    } else if (appearance.contains(Appearances.NUMBERS)) {
                        questionWidget = new StringNumberWidget(activity, questionDetails);
                    } else if (appearance.equals(Appearances.URL)) {
                        questionWidget = new UrlWidget(activity, questionDetails, new ExternalWebPageHelper());
                    } else {
                        questionWidget = new StringWidget(activity, questionDetails);
                    }
                    break;
                default:
                    questionWidget = new StringWidget(activity, questionDetails);
                    break;
            }
            break;
        case Constants.CONTROL_FILE_CAPTURE:
            if (appearance.startsWith(Appearances.EX)) {
                questionWidget = new ExArbitraryFileWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry, fileRequester);
            } else {
                questionWidget = new ArbitraryFileWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry);
            }
            break;
        case Constants.CONTROL_IMAGE_CHOOSE:
            if (appearance.equals(Appearances.SIGNATURE)) {
                questionWidget = new SignatureWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry, new StoragePathProvider().getTmpImageFilePath());
            } else if (appearance.contains(Appearances.ANNOTATE)) {
                questionWidget = new AnnotateWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry, new StoragePathProvider().getTmpImageFilePath());
            } else if (appearance.equals(Appearances.DRAW)) {
                questionWidget = new DrawWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry, new StoragePathProvider().getTmpImageFilePath());
            } else if (appearance.startsWith(Appearances.EX)) {
                questionWidget = new ExImageWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry, fileRequester);
            } else {
                questionWidget = new ImageWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry, new StoragePathProvider().getTmpImageFilePath());
            }
            break;
        case Constants.CONTROL_OSM_CAPTURE:
            questionWidget = new OSMWidget(activity, questionDetails, waitingForDataRegistry, IntentLauncherImpl.INSTANCE, Collect.getInstance().getFormController());
            break;
        case Constants.CONTROL_AUDIO_CAPTURE:
            RecordingRequester recordingRequester = recordingRequesterProvider.create(prompt, useExternalRecorder);
            GetContentAudioFileRequester audioFileRequester = new GetContentAudioFileRequester(activity, IntentLauncherImpl.INSTANCE, waitingForDataRegistry, formEntryViewModel);
            if (appearance.startsWith(Appearances.EX)) {
                questionWidget = new ExAudioWidget(activity, questionDetails, questionMediaManager, audioPlayer, waitingForDataRegistry, fileRequester);
            } else {
                questionWidget = new AudioWidget(activity, questionDetails, questionMediaManager, audioPlayer, recordingRequester, audioFileRequester, new AudioRecorderRecordingStatusHandler(audioRecorder, formEntryViewModel, viewLifecycle));
            }
            break;
        case Constants.CONTROL_VIDEO_CAPTURE:
            if (appearance.startsWith(Appearances.EX)) {
                questionWidget = new ExVideoWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry, fileRequester);
            } else {
                questionWidget = new VideoWidget(activity, questionDetails, questionMediaManager, waitingForDataRegistry);
            }
            break;
        case Constants.CONTROL_SELECT_ONE:
            questionWidget = getSelectOneWidget(appearance, questionDetails);
            break;
        case Constants.CONTROL_SELECT_MULTI:
            // considered in each widget by calls to ExternalDataUtil.getSearchXPathExpression.
            if (appearance.contains(Appearances.MINIMAL)) {
                questionWidget = new SelectMultiMinimalWidget(activity, questionDetails, waitingForDataRegistry);
            } else if (appearance.contains(Appearances.LIST_NO_LABEL)) {
                questionWidget = new ListMultiWidget(activity, questionDetails, false);
            } else if (appearance.contains(Appearances.LIST)) {
                questionWidget = new ListMultiWidget(activity, questionDetails, true);
            } else if (appearance.contains(Appearances.LABEL)) {
                questionWidget = new LabelWidget(activity, questionDetails);
            } else if (appearance.contains(Appearances.IMAGE_MAP)) {
                questionWidget = new SelectMultiImageMapWidget(activity, questionDetails);
            } else {
                questionWidget = new SelectMultiWidget(activity, questionDetails);
            }
            break;
        case Constants.CONTROL_RANK:
            questionWidget = new RankingWidget(activity, questionDetails);
            break;
        case Constants.CONTROL_TRIGGER:
            questionWidget = new TriggerWidget(activity, questionDetails);
            break;
        case Constants.CONTROL_RANGE:
            if (appearance.startsWith(Appearances.RATING)) {
                questionWidget = new RatingWidget(activity, questionDetails);
            } else {
                switch(prompt.getDataType()) {
                    case Constants.DATATYPE_INTEGER:
                        if (prompt.getQuestion().getAppearanceAttr() != null && prompt.getQuestion().getAppearanceAttr().contains(PICKER_APPEARANCE)) {
                            questionWidget = new RangePickerIntegerWidget(activity, questionDetails);
                        } else {
                            questionWidget = new RangeIntegerWidget(activity, questionDetails);
                        }
                        break;
                    case Constants.DATATYPE_DECIMAL:
                        if (prompt.getQuestion().getAppearanceAttr() != null && prompt.getQuestion().getAppearanceAttr().contains(PICKER_APPEARANCE)) {
                            questionWidget = new RangePickerDecimalWidget(activity, questionDetails);
                        } else {
                            questionWidget = new RangeDecimalWidget(activity, questionDetails);
                        }
                        break;
                    default:
                        questionWidget = new StringWidget(activity, questionDetails);
                        break;
                }
            }
            break;
        default:
            questionWidget = new StringWidget(activity, questionDetails);
            break;
    }
    return questionWidget;
}
Also used : SelectMultiImageMapWidget(org.odk.collect.android.widgets.items.SelectMultiImageMapWidget) RecordingRequester(org.odk.collect.android.widgets.utilities.RecordingRequester) ExternalWebPageHelper(org.odk.collect.android.utilities.ExternalWebPageHelper) ActivityGeoDataRequester(org.odk.collect.android.widgets.utilities.ActivityGeoDataRequester) ListMultiWidget(org.odk.collect.android.widgets.items.ListMultiWidget) DateTimeWidgetUtils(org.odk.collect.android.widgets.utilities.DateTimeWidgetUtils) SelectMultiWidget(org.odk.collect.android.widgets.items.SelectMultiWidget) QuestionDetails(org.odk.collect.android.formentry.questions.QuestionDetails) RankingWidget(org.odk.collect.android.widgets.items.RankingWidget) AudioRecorderRecordingStatusHandler(org.odk.collect.android.widgets.utilities.AudioRecorderRecordingStatusHandler) GetContentAudioFileRequester(org.odk.collect.android.widgets.utilities.GetContentAudioFileRequester) StoragePathProvider(org.odk.collect.android.storage.StoragePathProvider) CameraUtils(org.odk.collect.android.utilities.CameraUtils) SelectMultiMinimalWidget(org.odk.collect.android.widgets.items.SelectMultiMinimalWidget) LabelWidget(org.odk.collect.android.widgets.items.LabelWidget)

Aggregations

ExternalWebPageHelper (org.odk.collect.android.utilities.ExternalWebPageHelper)4 Application (android.app.Application)1 View (android.view.View)1 LinearLayout (android.widget.LinearLayout)1 NonNull (androidx.annotation.NonNull)1 DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 File (java.io.File)1 Before (org.junit.Before)1 Analytics (org.odk.collect.analytics.Analytics)1 AboutListAdapter (org.odk.collect.android.adapters.AboutListAdapter)1 BackgroundAudioViewModel (org.odk.collect.android.formentry.BackgroundAudioViewModel)1 FormEntryViewModel (org.odk.collect.android.formentry.FormEntryViewModel)1 QuestionDetails (org.odk.collect.android.formentry.questions.QuestionDetails)1 AppDependencyModule (org.odk.collect.android.injection.config.AppDependencyModule)1 StoragePathProvider (org.odk.collect.android.storage.StoragePathProvider)1 CameraUtils (org.odk.collect.android.utilities.CameraUtils)1 LabelWidget (org.odk.collect.android.widgets.items.LabelWidget)1 ListMultiWidget (org.odk.collect.android.widgets.items.ListMultiWidget)1