summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java
blob: 9ae96ebf7b88ee1f6b671f61c21dc3f759c5ea7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.mapbox.mapboxsdk.maps.widgets;

import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.IntRange;

import com.mapbox.mapboxsdk.maps.MapView;

public class MyLocationViewSettings {

    private MapView mapView;
    private MyLocationView myLocationView;

    //
    // State
    //

    private boolean enabled;

    //
    // Foreground
    //

    private Drawable foregroundDrawable;
    private Drawable foregroundBearingDrawable;

    @ColorInt
    private int foregroundTintColor;

    //
    // Background
    //

    private Drawable backgroundDrawable;
    private int[] backgroundOffset = new int[4];

    @ColorInt
    private int backgroundTintColor;

    //
    // Accuracy
    //

    private int accuracyAlpha;

    @ColorInt
    private int accuracyTintColor;

    //
    // Padding
    //

    private int[] padding = new int[4];

    public MyLocationViewSettings(MapView mapView, MyLocationView myLocationView) {
        this.mapView = mapView;
        this.myLocationView = myLocationView;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
        myLocationView.setEnabled(enabled);
    }

    public void setForegroundDrawable(Drawable foregroundDrawable, Drawable foregroundBearingDrawable) {
        this.foregroundDrawable = foregroundDrawable;
        this.foregroundBearingDrawable = foregroundBearingDrawable;
        myLocationView.setForegroundDrawables(foregroundDrawable, foregroundBearingDrawable);
    }

    public Drawable getForegroundDrawable() {
        return foregroundDrawable;
    }

    public Drawable getForegroundBearingDrawable() {
        return foregroundBearingDrawable;
    }

    public void setForegroundTintColor(@ColorInt int foregroundTintColor) {
        this.foregroundTintColor = foregroundTintColor;
        myLocationView.setForegroundDrawableTint(foregroundTintColor);
    }

    public int getForegroundTintColor() {
        return foregroundTintColor;
    }

    public void setBackgroundDrawable(Drawable backgroundDrawable, int[] padding) {
        this.backgroundDrawable = backgroundDrawable;
        this.backgroundOffset = padding;
        if (padding != null && padding.length == 4) {
            myLocationView.setShadowDrawable(backgroundDrawable, padding[0], padding[1], padding[2], padding[3]);
        } else {
            myLocationView.setShadowDrawable(backgroundDrawable);
        }
    }

    public Drawable getBackgroundDrawable() {
        return backgroundDrawable;
    }

    public void setBackgroundTintColor(@ColorInt int backgroundTintColor) {
        this.backgroundTintColor = backgroundTintColor;
        myLocationView.setShadowDrawableTint(backgroundTintColor);
    }

    public int getBackgroundTintColor() {
        return backgroundTintColor;
    }

    public int[] getBackgroundOffset() {
        return backgroundOffset;
    }

    public void setPadding(int left, int top, int right, int bottom) {
        padding = new int[]{left, top, right, bottom};
        myLocationView.setContentPadding(padding);
        mapView.invalidateContentPadding();
    }

    public int[] getPadding() {
        return padding;
    }

    public int getAccuracyAlpha() {
        return accuracyAlpha;
    }

    public void setAccuracyAlpha(@IntRange(from = 0, to = 255) int arruracyAlpha) {
        this.accuracyAlpha = arruracyAlpha;
        myLocationView.setAccuracyAlpha(arruracyAlpha);
    }

    public int getAccuracyTintColor() {
        return accuracyTintColor;
    }

    public void setAccuracyTintColor(@ColorInt int accuracyTintColor) {
        this.accuracyTintColor = accuracyTintColor;
        myLocationView.setAccuracyTint(accuracyTintColor);
    }
}