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));
}
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);
}
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;
}
});
}
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;
}
Aggregations