// Path: app/src/main/java/com/velli20/tachograph/views/RobotoLightTextView.java
// public class RobotoLightTextView extends AppCompatTextView {
//     private static LruCache<String, Typeface> sTypefaceCache = new LruCache<>(7);
// 
//     private static String[] mTypefacePaths = {"font/Roboto-Bold.ttf", "font/Roboto-Light.ttf", "font/Roboto-LightItalic.ttf",
//             "font/Roboto-Medium.ttf", "font/Roboto-Regular.ttf", "font/Roboto-Thin.ttf", "font/Roboto-Italic.ttf", "AndroidClockMono-Thin.ttf"};
// 
//     public RobotoLightTextView(Context context) {
//         this(context, null, 0);
//     }
// 
//     public RobotoLightTextView(Context context, AttributeSet attrs) {
//         this(context, attrs, 0);
//     }
// 
//     public RobotoLightTextView(Context context, AttributeSet attrs, int defStyle) {
//         super(context, attrs, defStyle);
//         int typeface = 3;
// 
//         if (isInEditMode()) {
//             return;
//         }
//         if (attrs != null) {
//             TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.RobotoText, 0, 0);
// 
//             try {
//                 typeface = a.getInt(R.styleable.RobotoText_style, 4);
//             } finally {
//                 a.recycle();
//             }
//         }
// 
// 
//         setTypeface(getTypeface(getResources(), typeface));
//         setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
// 
//     }
// 
// 
//     public static Typeface getTypeface(Resources res, int typeface) {
//         Typeface roboto = sTypefaceCache.get(mTypefacePaths[typeface]);
// 
//         if (roboto == null) {
//             roboto = Typeface.createFromAsset(res.getAssets(), mTypefacePaths[typeface]);
//             sTypefaceCache.put(mTypefacePaths[typeface], roboto);
//         }
// 
//         return roboto;
//     }
// 
// }


import android.view.View;
import android.view.ViewGroup;
import com.afollestad.materialdialogs.MaterialDialog;
import com.afollestad.materialdialogs.Theme;
import com.velli20.tachograph.R;
import com.velli20.tachograph.views.RobotoLightTextView;
import static android.os.Build.VERSION_CODES.LOLLIPOP;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
                .theme(Theme.DARK)
                .positiveText(getContext().getResources().getString(R.string.action_ok))
                .itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {

                    @Override
                    public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
                        setCurrentValue(which);
                        persistInt(mCurrentValue);
                        notifyDependencyChange(shouldDisableDependents());
                        notifyChanged();
                        return true;
                    }
                }).show();


    }

    public void setCurrentValue(int value) {
        mCurrentValue = value;
    }

    @Override
    protected View onCreateView(ViewGroup parent) {
        setWidgetLayoutResource(R.layout.view_preference_widget_counter);
        return super.onCreateView(parent);
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
// Path: app/src/main/java/com/velli20/tachograph/views/RobotoLightTextView.java
// public class RobotoLightTextView extends AppCompatTextView {
//     private static LruCache<String, Typeface> sTypefaceCache = new LruCache<>(7);
// 
//     private static String[] mTypefacePaths = {"font/Roboto-Bold.ttf", "font/Roboto-Light.ttf", "font/Roboto-LightItalic.ttf",
//             "font/Roboto-Medium.ttf", "font/Roboto-Regular.ttf", "font/Roboto-Thin.ttf", "font/Roboto-Italic.ttf", "AndroidClockMono-Thin.ttf"};
// 
//     public RobotoLightTextView(Context context) {
//         this(context, null, 0);
//     }
// 
//     public RobotoLightTextView(Context context, AttributeSet attrs) {
//         this(context, attrs, 0);
//     }
// 
//     public RobotoLightTextView(Context context, AttributeSet attrs, int defStyle) {
//         super(context, attrs, defStyle);
//         int typeface = 3;
// 
//         if (isInEditMode()) {
//             return;
//         }
//         if (attrs != null) {
//             TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.RobotoText, 0, 0);
// 
//             try {
//                 typeface = a.getInt(R.styleable.RobotoText_style, 4);
//             } finally {
//                 a.recycle();
//             }
//         }
// 
// 
//         setTypeface(getTypeface(getResources(), typeface));
//         setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
// 
//     }
// 
// 
//     public static Typeface getTypeface(Resources res, int typeface) {
//         Typeface roboto = sTypefaceCache.get(mTypefacePaths[typeface]);
// 
//         if (roboto == null) {
//             roboto = Typeface.createFromAsset(res.getAssets(), mTypefacePaths[typeface]);
//             sTypefaceCache.put(mTypefacePaths[typeface], roboto);
//         }
// 
//         return roboto;
//     }
// 
// }


// Path: app/src/main/java/com/velli20/tachograph/preferences/GpsAccuracyPreference.java
import android.view.View;
import android.view.ViewGroup;
import com.afollestad.materialdialogs.MaterialDialog;
import com.afollestad.materialdialogs.Theme;
import com.velli20.tachograph.R;
import com.velli20.tachograph.views.RobotoLightTextView;
import static android.os.Build.VERSION_CODES.LOLLIPOP;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;

                .theme(Theme.DARK)
                .positiveText(getContext().getResources().getString(R.string.action_ok))
                .itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {

                    @Override
                    public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) {
                        setCurrentValue(which);
                        persistInt(mCurrentValue);
                        notifyDependencyChange(shouldDisableDependents());
                        notifyChanged();
                        return true;
                    }
                }).show();


    }

    public void setCurrentValue(int value) {
        mCurrentValue = value;
    }

    @Override
    protected View onCreateView(ViewGroup parent) {
        setWidgetLayoutResource(R.layout.view_preference_widget_counter);
        return super.onCreateView(parent);
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
        RobotoLightTextView text = (RobotoLightTextView) view.findViewById(R.id.widget_counter);