Search in sources :

Example 1 with AccentColorCallback

use of com.waz.zclient.common.controllers.global.AccentColorCallback in project wire-android by wireapp.

the class MarkdownTextView method configureStyleSheet.

/**
 * Configures the style sheet used for rendering.
 */
private void configureStyleSheet() {
    mStyleSheet = new StyleSheet();
    mStyleSheet.setBaseFontColor(getCurrentTextColor());
    mStyleSheet.setBaseFontSize((int) getTextSize());
    mStyleSheet.setCodeColor(ContextUtils.getStyledColor(R.attr.codeColor, context()));
    mStyleSheet.setQuoteColor(ContextUtils.getStyledColor(R.attr.quoteColor, context()));
    mStyleSheet.setQuoteStripeColor(ContextUtils.getStyledColor(R.attr.quoteStripeColor, context()));
    mStyleSheet.setListPrefixColor(ContextUtils.getStyledColor(R.attr.listPrefixColor, context()));
    BaseActivity activity = (BaseActivity) getContext();
    if (activity != null) {
        // update the link color whenever the accent color changes
        activity.injectJava(AccentColorController.class).accentColorForJava(new AccentColorCallback() {

            @Override
            public void color(AccentColor color) {
                mStyleSheet.setLinkColor(color.color());
                setLinkTextColor(color.color());
                refreshLinks();
            }
        }, eventContext());
    }
    // to make links clickable
    mStyleSheet.configureLinkHandler(context());
    setMovementMethod(new LinkTextView.MovementMethod(getContext()));
    setLineSpacing(0f, 1.1f);
}
Also used : AccentColor(com.waz.model.AccentColor) LinkTextView(com.waz.zclient.common.views.LinkTextView) AccentColorController(com.waz.zclient.common.controllers.global.AccentColorController) BaseActivity(com.waz.zclient.BaseActivity) AccentColorCallback(com.waz.zclient.common.controllers.global.AccentColorCallback)

Example 2 with AccentColorCallback

use of com.waz.zclient.common.controllers.global.AccentColorCallback in project wire-android by wireapp.

the class LocationFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isGooglePlayServicesAvailable()) {
        googleApiClient = new GoogleApiClient.Builder(getContext()).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(LocationServices.API).build();
        googleApiClient.connect();
    } else {
        locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    }
    mainHandler = new Handler();
    handlerThread = new HandlerThread("Background handler");
    handlerThread.start();
    backgroundHandler = new Handler(handlerThread.getLooper());
    geocoder = new Geocoder(getContext(), Locale.getDefault());
    zoom = true;
    // retrieve the accent color to be used for the paint
    accentColor = AccentColor.defaultColor().color();
    ((BaseActivity) getContext()).injectJava(AccentColorController.class).accentColorForJava(new AccentColorCallback() {

        @Override
        public void color(AccentColor color) {
            selectedLocationPin.setTextColor(color.color());
            marker = null;
            accentColor = color.color();
        }
    }, EventContext.Implicits$.MODULE$.global());
}
Also used : AccentColor(com.waz.model.AccentColor) GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) HandlerThread(android.os.HandlerThread) AccentColorController(com.waz.zclient.common.controllers.global.AccentColorController) AccentColorCallback(com.waz.zclient.common.controllers.global.AccentColorCallback) Handler(android.os.Handler) Geocoder(android.location.Geocoder)

Example 3 with AccentColorCallback

use of com.waz.zclient.common.controllers.global.AccentColorCallback in project wire-android by wireapp.

the class ConfirmationFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.confirmation_fragment, container, false);
    dialogId = getArguments().getString(OPTIONAL_FIELD_DIALOG_ID);
    confirmationMenu = ViewUtils.getView(view, R.id.cm__confirm_menu);
    confirmationMenu.setHeader(getArguments().getString(FIELD_TITLE));
    confirmationMenu.setText(getArguments().getString(FIELD_MESSAGE));
    confirmationMenu.setPositiveButton(getArguments().getString(FIELD_CONFIRM));
    confirmationMenu.setNegativeButton(getArguments().getString(OPTIONAL_FIELD_CANCEL));
    confirmationMenu.useModalBackground(getArguments().getBoolean(OPTIONAL_FIELD_USE_BLACK_BACKGROUND));
    confirmationMenu.setCallback(new TwoButtonConfirmationCallback() {

        @Override
        public void positiveButtonClicked(boolean checkboxIsSelected) {
            getContainer().onDialogConfirm(dialogId);
        }

        @Override
        public void negativeButtonClicked() {
            getContainer().onDialogCancel(dialogId);
        }

        @Override
        public void onHideAnimationEnd(boolean confirmed, boolean canceled, boolean checkboxIsSelected) {
        }
    });
    // update the button color whenever the accent color changes
    ((BaseActivity) getContext()).injectJava(AccentColorController.class).accentColorForJava(new AccentColorCallback() {

        @Override
        public void color(AccentColor color) {
            confirmationMenu.setButtonColor(color.color());
        }
    }, EventContext.Implicits$.MODULE$.global());
    return view;
}
Also used : AccentColor(com.waz.model.AccentColor) AccentColorController(com.waz.zclient.common.controllers.global.AccentColorController) TwoButtonConfirmationCallback(com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback) AccentColorCallback(com.waz.zclient.common.controllers.global.AccentColorCallback) View(android.view.View)

Aggregations

AccentColor (com.waz.model.AccentColor)3 AccentColorCallback (com.waz.zclient.common.controllers.global.AccentColorCallback)3 AccentColorController (com.waz.zclient.common.controllers.global.AccentColorController)3 Geocoder (android.location.Geocoder)1 Handler (android.os.Handler)1 HandlerThread (android.os.HandlerThread)1 View (android.view.View)1 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1 BaseActivity (com.waz.zclient.BaseActivity)1 LinkTextView (com.waz.zclient.common.views.LinkTextView)1 TwoButtonConfirmationCallback (com.waz.zclient.controllers.confirmation.TwoButtonConfirmationCallback)1