Search in sources :

Example 6 with ThemeUtils

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

the class GoogleMapFragment method updateLocationIndicator.

private void updateLocationIndicator(LatLng loc, double radius) {
    if (map == null) {
        return;
    }
    if (locationCrosshairs == null) {
        locationCrosshairs = map.addMarker(new MarkerOptions().position(loc).icon(getBitmapDescriptor(R.drawable.ic_crosshairs)).anchor(0.5f, // center the crosshairs on the position
        0.5f));
    }
    if (accuracyCircle == null) {
        int stroke = new ThemeUtils(requireContext()).getColorPrimaryDark();
        int fill = getResources().getColor(R.color.color_primary_low_emphasis);
        accuracyCircle = map.addCircle(new CircleOptions().center(loc).radius(radius).strokeWidth(1).strokeColor(stroke).fillColor(fill));
    }
    locationCrosshairs.setPosition(loc);
    accuracyCircle.setCenter(loc);
    accuracyCircle.setRadius(radius);
}
Also used : MarkerOptions(com.google.android.gms.maps.model.MarkerOptions) CircleOptions(com.google.android.gms.maps.model.CircleOptions) ThemeUtils(org.odk.collect.android.utilities.ThemeUtils) MapPoint(org.odk.collect.geo.maps.MapPoint) SuppressLint(android.annotation.SuppressLint)

Example 7 with ThemeUtils

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

the class GoogleAccountsManager method initCredential.

private void initCredential(@NonNull Context context) {
    this.context = context;
    intentChooseAccount = accountPicker.newChooseAccountIntent();
    themeUtils = new ThemeUtils(context);
}
Also used : ThemeUtils(org.odk.collect.android.utilities.ThemeUtils)

Example 8 with ThemeUtils

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

the class ChoicesRecyclerView method enableDivider.

private void enableDivider() {
    DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
    Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.inset_divider_64dp);
    if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        DrawableCompat.setTint(DrawableCompat.wrap(drawable), new ThemeUtils(getContext()).getColorOnSurface());
    }
    divider.setDrawable(drawable);
    addItemDecoration(divider);
}
Also used : Drawable(android.graphics.drawable.Drawable) ThemeUtils(org.odk.collect.android.utilities.ThemeUtils) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration)

Example 9 with ThemeUtils

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

the class ODKView method getDividerView.

private View getDividerView() {
    View divider = new View(getContext());
    divider.setBackgroundResource(new ThemeUtils(getContext()).getDivider());
    divider.setMinimumHeight(3);
    return divider;
}
Also used : ThemeUtils(org.odk.collect.android.utilities.ThemeUtils) View(android.view.View) TextView(android.widget.TextView)

Example 10 with ThemeUtils

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

the class ODKView method highlightWidget.

/**
 * Highlights the question at the given {@link FormIndex} in red for 2.5 seconds, scrolls the
 * view to display that question at the top and gives it focus.
 */
public void highlightWidget(FormIndex formIndex) {
    QuestionWidget qw = getQuestionWidget(formIndex);
    if (qw != null) {
        // postDelayed is needed because otherwise scrolling may not work as expected in case when
        // answers are validated during form finalization.
        new Handler().postDelayed(() -> {
            qw.setFocus(getContext());
            scrollTo(qw);
            ValueAnimator va = new ValueAnimator();
            va.setIntValues(new ThemeUtils(getContext()).getColorError(), getDrawingCacheBackgroundColor());
            va.setEvaluator(new ArgbEvaluator());
            va.addUpdateListener(valueAnimator -> qw.setBackgroundColor((int) valueAnimator.getAnimatedValue()));
            va.setDuration(2500);
            va.start();
        }, 100);
    }
}
Also used : ArgbEvaluator(android.animation.ArgbEvaluator) Handler(android.os.Handler) ThemeUtils(org.odk.collect.android.utilities.ThemeUtils) QuestionWidget(org.odk.collect.android.widgets.QuestionWidget) ValueAnimator(android.animation.ValueAnimator)

Aggregations

ThemeUtils (org.odk.collect.android.utilities.ThemeUtils)12 TextView (android.widget.TextView)3 Bundle (android.os.Bundle)2 View (android.view.View)2 ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 ArgbEvaluator (android.animation.ArgbEvaluator)1 ValueAnimator (android.animation.ValueAnimator)1 SuppressLint (android.annotation.SuppressLint)1 DatePickerDialog (android.app.DatePickerDialog)1 TimePickerDialog (android.app.TimePickerDialog)1 Intent (android.content.Intent)1 Drawable (android.graphics.drawable.Drawable)1 Handler (android.os.Handler)1 OnClickListener (android.view.View.OnClickListener)1 Button (android.widget.Button)1 DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)1 CircleOptions (com.google.android.gms.maps.model.CircleOptions)1 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)1 CurrentProjectViewModel (org.odk.collect.android.activities.viewmodels.CurrentProjectViewModel)1 MainMenuViewModel (org.odk.collect.android.activities.viewmodels.MainMenuViewModel)1