Search in sources :

Example 1 with MaterialTextView

use of com.google.android.material.textview.MaterialTextView in project Android by CatimaLoyalty.

the class UCropWrapper method onPostCreate.

@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    boolean darkMode = Utils.isDarkModeEnabled(this);
    // setup status bar to look like the rest of the app
    if (Build.VERSION.SDK_INT >= 23) {
        getWindow().getDecorView().setSystemUiVisibility(darkMode ? 0 : View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    } else {
        // icons are always white back then
        if (!darkMode) {
            getWindow().setStatusBarColor(ColorUtils.compositeColors(Color.argb(127, 0, 0, 0), getWindow().getStatusBarColor()));
        }
    }
    // find and check views that we wish to color modify
    // for when we update ucrop or switch to another cropper
    View check = findViewById(com.yalantis.ucrop.R.id.wrapper_controls);
    if (check instanceof FrameLayout) {
        FrameLayout controls = (FrameLayout) check;
        check = findViewById(com.yalantis.ucrop.R.id.wrapper_states);
        if (check instanceof LinearLayout) {
            LinearLayout states = (LinearLayout) check;
            for (int i = 0; i < controls.getChildCount(); i++) {
                check = controls.getChildAt(i);
                if (check instanceof AppCompatImageView) {
                    AppCompatImageView controlsBackgroundImage = (AppCompatImageView) check;
                    // everything gathered and are as expected, now perform color patching
                    Utils.patchColors(this);
                    int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface, ContextCompat.getColor(this, R.color.md_theme_light_surface));
                    int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface, ContextCompat.getColor(this, R.color.md_theme_light_onSurface));
                    Drawable controlsBackgroundImageDrawable = controlsBackgroundImage.getBackground();
                    controlsBackgroundImageDrawable.mutate();
                    controlsBackgroundImageDrawable.setTint(darkMode ? colorOnSurface : colorSurface);
                    controlsBackgroundImage.setBackgroundDrawable(controlsBackgroundImageDrawable);
                    states.setBackgroundColor(darkMode ? colorSurface : colorOnSurface);
                    break;
                }
            }
        }
    }
    // change toolbar font
    check = findViewById(com.yalantis.ucrop.R.id.toolbar_title);
    if (check instanceof MaterialTextView) {
        MaterialTextView toolbarTextview = (MaterialTextView) check;
        Intent intent = getIntent();
        int style = intent.getIntExtra(UCROP_TOOLBAR_TYPEFACE_STYLE, -1);
        if (style != -1) {
            toolbarTextview.setTypeface(Typeface.defaultFromStyle(style));
        }
    }
}
Also used : MaterialTextView(com.google.android.material.textview.MaterialTextView) FrameLayout(android.widget.FrameLayout) Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) MaterialTextView(com.google.android.material.textview.MaterialTextView) View(android.view.View) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) LinearLayout(android.widget.LinearLayout)

Example 2 with MaterialTextView

use of com.google.android.material.textview.MaterialTextView in project edx-app-android by openedx.

the class CourseOutlineAdapter method getCardView.

public View getCardView(View view) {
    final MaterialTextView courseTextName = view.findViewById(R.id.course_detail_name);
    final MaterialTextView courseTextDetails = view.findViewById(R.id.course_detail_extras);
    final AppCompatImageView headerImageView = view.findViewById(R.id.header_image_view);
    final View upgradeBtn = view.findViewById(R.id.layout_upgrade_btn);
    final MaterialButton upgradeBtnText = upgradeBtn.findViewById(R.id.btn_upgrade);
    ((ShimmerFrameLayout) upgradeBtn).hideShimmer();
    upgradeBtn.setVisibility(courseData.getMode().equalsIgnoreCase(EnrollmentMode.AUDIT.toString()) ? View.VISIBLE : View.GONE);
    upgradeBtnText.setOnClickListener(view1 -> CourseModalDialogFragment.newInstance(environment.getConfig().getPlatformName(), courseData.getCourseId(), courseData.getCourse().getName(), courseData.getCourse().getPrice(), courseData.getCourse().isSelfPaced()).show(((AppCompatActivity) context).getSupportFragmentManager(), CourseModalDialogFragment.TAG));
    upgradeBtnText.setText(R.string.value_prop_course_card_message);
    // Full course name should appear on the course's dashboard screen.
    courseTextName.setEllipsize(null);
    courseTextName.setSingleLine(false);
    final String headerImageUrl = courseData.getCourse().getCourse_image(environment.getConfig().getApiHostURL());
    Glide.with(context).load(headerImageUrl).placeholder(R.drawable.placeholder_course_card_image).transform(new TopAnchorFillWidthTransformation()).into(headerImageView);
    courseTextName.setText(courseData.getCourse().getName());
    courseTextDetails.setText(CourseCardUtils.getFormattedDate(context, courseData));
    return view;
}
Also used : MaterialTextView(com.google.android.material.textview.MaterialTextView) TopAnchorFillWidthTransformation(org.edx.mobile.util.images.TopAnchorFillWidthTransformation) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) MaterialTextView(com.google.android.material.textview.MaterialTextView) TextView(android.widget.TextView) MaterialButton(com.google.android.material.button.MaterialButton) ShimmerFrameLayout(com.facebook.shimmer.ShimmerFrameLayout)

Example 3 with MaterialTextView

use of com.google.android.material.textview.MaterialTextView in project a-medic-log by rh-id.

the class MedicineItemSV method createView.

@Override
protected View createView(Activity activity, ViewGroup container) {
    View rootLayout = activity.getLayoutInflater().inflate(R.layout.item_medicine, container, false);
    rootLayout.setOnClickListener(this);
    TextView nameText = rootLayout.findViewById(R.id.text_name);
    TextView descriptionText = rootLayout.findViewById(R.id.text_description);
    TextView lastIntakeText = rootLayout.findViewById(R.id.text_last_intake);
    Button editButton = rootLayout.findViewById(R.id.button_edit);
    editButton.setOnClickListener(this);
    Button deleteButton = rootLayout.findViewById(R.id.button_delete);
    deleteButton.setOnClickListener(this);
    Button moreAction = rootLayout.findViewById(R.id.button_more_action);
    moreAction.setOnClickListener(this);
    GridLayout containerReminder = rootLayout.findViewById(R.id.container_reminder);
    mRxDisposer.add("createView_onMedicineStateChanged", mMedicineStateSubject.getSubject().debounce(16, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(medicineState -> {
        nameText.setText(medicineState.getMedicineName());
        descriptionText.setText(medicineState.getMedicineDescription());
        if (medicineState.getMedicineId() != null) {
            moreAction.setVisibility(View.VISIBLE);
        } else {
            moreAction.setVisibility(View.GONE);
        }
        queryLastMedicineIntake(medicineState.getMedicineId());
        containerReminder.removeAllViews();
        ArrayList<MedicineReminder> medicineReminders = medicineState.getMedicineReminderList();
        if (medicineReminders != null && !medicineReminders.isEmpty()) {
            containerReminder.setVisibility(View.VISIBLE);
            for (MedicineReminder medicineReminder : medicineReminders) {
                MaterialTextView materialTextView = new MaterialTextView(activity);
                materialTextView.setText(mTimeFormat.format(medicineReminder.startDateTime));
                GridLayout.LayoutParams params = new GridLayout.LayoutParams();
                params.width = GridLayout.LayoutParams.WRAP_CONTENT;
                params.height = GridLayout.LayoutParams.WRAP_CONTENT;
                params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1.0f);
                materialTextView.setLayoutParams(params);
                materialTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
                int tintColor = activity.getResources().getColor(R.color.daynight_black_white);
                Drawable icon;
                if (medicineReminder.reminderEnabled) {
                    icon = AppCompatResources.getDrawable(activity, R.drawable.ic_timer_black);
                } else {
                    icon = AppCompatResources.getDrawable(activity, R.drawable.ic_timer_off_black);
                }
                icon = DrawableCompat.wrap(icon);
                DrawableCompat.setTint(icon, tintColor);
                materialTextView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
                containerReminder.addView(materialTextView);
            }
        } else {
            containerReminder.setVisibility(View.GONE);
        }
    }));
    mRxDisposer.add("createView_onLastMedicineIntakeChanged", mLastMedicineIntakeSubject.getSubject().debounce(100, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(medicineIntakeOpt -> {
        if (medicineIntakeOpt.isPresent()) {
            Date takenDateTime = medicineIntakeOpt.get().takenDateTime;
            lastIntakeText.setText(mDateTimeFormat.format(takenDateTime));
            lastIntakeText.setVisibility(View.VISIBLE);
        } else {
            lastIntakeText.setText(null);
            lastIntakeText.setVisibility(View.GONE);
        }
    }));
    mRxDisposer.add("createView_onMedicineIntakeAdded", mMedicineIntakeChangeNotifier.getAddedMedicineIntake().observeOn(Schedulers.from(mExecutorService)).subscribe(medicineIntake -> {
        if (medicineIntake.medicineId != null && medicineIntake.medicineId.equals(mMedicineStateSubject.getValue().getMedicineId())) {
            queryLastMedicineIntake(medicineIntake.medicineId);
        }
    }));
    mRxDisposer.add("createView_onMedicineIntakeUpdated", mMedicineIntakeChangeNotifier.getUpdatedMedicineIntake().observeOn(Schedulers.from(mExecutorService)).subscribe(updateMedicineIntakeEvent -> {
        MedicineIntake medicineIntake = updateMedicineIntakeEvent.getAfter();
        if (medicineIntake.medicineId != null && medicineIntake.medicineId.equals(mMedicineStateSubject.getValue().getMedicineId())) {
            queryLastMedicineIntake(medicineIntake.medicineId);
        }
    }));
    mRxDisposer.add("createView_onMedicineIntakeDeleted", mMedicineIntakeChangeNotifier.getDeletedMedicineIntake().observeOn(Schedulers.from(mExecutorService)).subscribe(medicineIntake -> {
        if (medicineIntake.medicineId != null && medicineIntake.medicineId.equals(mMedicineStateSubject.getValue().getMedicineId())) {
            queryLastMedicineIntake(medicineIntake.medicineId);
        }
    }));
    return rootLayout;
}
Also used : AppCompatResources(androidx.appcompat.content.res.AppCompatResources) Date(java.util.Date) MedicineIntake(m.co.rh.id.a_medic_log.base.entity.MedicineIntake) SimpleDateFormat(java.text.SimpleDateFormat) DrawableCompat(androidx.core.graphics.drawable.DrawableCompat) Drawable(android.graphics.drawable.Drawable) MedicineIntakeChangeNotifier(m.co.rh.id.a_medic_log.app.provider.notifier.MedicineIntakeChangeNotifier) MedicineReminder(m.co.rh.id.a_medic_log.base.entity.MedicineReminder) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Schedulers(io.reactivex.rxjava3.schedulers.Schedulers) View(android.view.View) Button(android.widget.Button) GridLayout(androidx.gridlayout.widget.GridLayout) QueryMedicineCmd(m.co.rh.id.a_medic_log.app.provider.command.QueryMedicineCmd) DateFormat(java.text.DateFormat) ExecutorService(java.util.concurrent.ExecutorService) OptionalBehaviorSubject(m.co.rh.id.a_medic_log.base.rx.OptionalBehaviorSubject) SerialBehaviorSubject(m.co.rh.id.a_medic_log.base.rx.SerialBehaviorSubject) StatefulView(m.co.rh.id.anavigator.StatefulView) Provider(m.co.rh.id.aprovider.Provider) MedicineState(m.co.rh.id.a_medic_log.base.state.MedicineState) ViewGroup(android.view.ViewGroup) PopupMenu(androidx.appcompat.widget.PopupMenu) TimeUnit(java.util.concurrent.TimeUnit) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) MaterialTextView(com.google.android.material.textview.MaterialTextView) TextView(android.widget.TextView) StatefulViewProvider(m.co.rh.id.a_medic_log.app.provider.StatefulViewProvider) RequireComponent(m.co.rh.id.anavigator.component.RequireComponent) TypedValue(android.util.TypedValue) RxDisposer(m.co.rh.id.a_medic_log.app.rx.RxDisposer) R(m.co.rh.id.a_medic_log.R) Activity(android.app.Activity) MaterialTextView(com.google.android.material.textview.MaterialTextView) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) View(android.view.View) StatefulView(m.co.rh.id.anavigator.StatefulView) MaterialTextView(com.google.android.material.textview.MaterialTextView) TextView(android.widget.TextView) Date(java.util.Date) GridLayout(androidx.gridlayout.widget.GridLayout) Button(android.widget.Button) MedicineIntake(m.co.rh.id.a_medic_log.base.entity.MedicineIntake) MaterialTextView(com.google.android.material.textview.MaterialTextView) TextView(android.widget.TextView) MedicineReminder(m.co.rh.id.a_medic_log.base.entity.MedicineReminder)

Example 4 with MaterialTextView

use of com.google.android.material.textview.MaterialTextView in project edx-app-android by edx.

the class CourseOutlineAdapter method getCardView.

public View getCardView(View view) {
    final MaterialTextView courseTextName = view.findViewById(R.id.course_detail_name);
    final MaterialTextView courseTextDetails = view.findViewById(R.id.course_detail_extras);
    final AppCompatImageView headerImageView = view.findViewById(R.id.header_image_view);
    final View upgradeBtn = view.findViewById(R.id.layout_upgrade_btn);
    final MaterialButton upgradeBtnText = upgradeBtn.findViewById(R.id.btn_upgrade);
    ((ShimmerFrameLayout) upgradeBtn).hideShimmer();
    upgradeBtn.setVisibility(courseData.getMode().equalsIgnoreCase(EnrollmentMode.AUDIT.toString()) ? View.VISIBLE : View.GONE);
    upgradeBtnText.setOnClickListener(view1 -> CourseModalDialogFragment.newInstance(environment.getConfig().getPlatformName(), courseData.getCourseId(), courseData.getCourse().getName(), courseData.getCourse().getPrice(), courseData.getCourse().isSelfPaced()).show(((AppCompatActivity) context).getSupportFragmentManager(), CourseModalDialogFragment.TAG));
    upgradeBtnText.setText(R.string.value_prop_course_card_message);
    // Full course name should appear on the course's dashboard screen.
    courseTextName.setEllipsize(null);
    courseTextName.setSingleLine(false);
    final String headerImageUrl = courseData.getCourse().getCourse_image(environment.getConfig().getApiHostURL());
    Glide.with(context).load(headerImageUrl).placeholder(R.drawable.placeholder_course_card_image).transform(new TopAnchorFillWidthTransformation()).into(headerImageView);
    courseTextName.setText(courseData.getCourse().getName());
    courseTextDetails.setText(CourseCardUtils.getFormattedDate(context, courseData));
    return view;
}
Also used : MaterialTextView(com.google.android.material.textview.MaterialTextView) TopAnchorFillWidthTransformation(org.edx.mobile.util.images.TopAnchorFillWidthTransformation) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) AppCompatImageView(androidx.appcompat.widget.AppCompatImageView) View(android.view.View) MaterialTextView(com.google.android.material.textview.MaterialTextView) TextView(android.widget.TextView) MaterialButton(com.google.android.material.button.MaterialButton) ShimmerFrameLayout(com.facebook.shimmer.ShimmerFrameLayout)

Aggregations

View (android.view.View)4 MaterialTextView (com.google.android.material.textview.MaterialTextView)4 TextView (android.widget.TextView)3 AppCompatImageView (androidx.appcompat.widget.AppCompatImageView)3 Drawable (android.graphics.drawable.Drawable)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 ShimmerFrameLayout (com.facebook.shimmer.ShimmerFrameLayout)2 MaterialButton (com.google.android.material.button.MaterialButton)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 TypedValue (android.util.TypedValue)1 MenuItem (android.view.MenuItem)1 ViewGroup (android.view.ViewGroup)1 Button (android.widget.Button)1 FrameLayout (android.widget.FrameLayout)1 LinearLayout (android.widget.LinearLayout)1 AppCompatResources (androidx.appcompat.content.res.AppCompatResources)1 PopupMenu (androidx.appcompat.widget.PopupMenu)1 DrawableCompat (androidx.core.graphics.drawable.DrawableCompat)1 GridLayout (androidx.gridlayout.widget.GridLayout)1