com.heinrichreimersoftware.materialintro.R Java Examples

The following examples show how to use com.heinrichreimersoftware.materialintro.R. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntroActivity.java    From Puff-Android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (fullscreen && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setSystemUiFlags(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, true);
        setFullscreenFlags(fullscreen);
    }

    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM)) {
        position = savedInstanceState.getInt(KEY_CURRENT_ITEM, position);
    }

    setContentView(R.layout.activity_intro);
    findViews();
}
 
Example #2
Source File: IntroActivity.java    From Puff-Android with MIT License 6 votes vote down vote up
private void updateTaskDescription() {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        String title = getTitle().toString();
        Drawable iconDrawable = getApplicationInfo().loadIcon(getPackageManager());
        Bitmap icon = iconDrawable instanceof BitmapDrawable ? ((BitmapDrawable) iconDrawable).getBitmap() : null;
        int colorPrimary;
        if (position < getCount()) {
            try {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(position));
            } catch (Resources.NotFoundException e) {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackground(position));
            }
        }
        else {
            TypedValue typedValue = new TypedValue();
            TypedArray a = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimary});
            colorPrimary = a.getColor(0, 0);
            a.recycle();
        }
        colorPrimary = ColorUtils.setAlphaComponent(colorPrimary, 0xFF);

        setTaskDescription(new ActivityManager.TaskDescription(title, icon, colorPrimary));
    }
}
 
Example #3
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 6 votes vote down vote up
private void updateButtonNextPosition() {
    float realPosition = position + positionOffset;
    float yOffset = getResources().getDimensionPixelSize(R.dimen.mi_y_offset);

    if (realPosition < adapter.getCount() - 2) {
        //Reset
        buttonNext.setTranslationY(0);
    }
    else if (realPosition < adapter.getCount() - 1) {
        //Reset finish button, hide next icon
        if (buttonNextFunction == BUTTON_NEXT_FUNCTION_NEXT_FINISH) {
            buttonNext.setTranslationY(0);
        }
        else {
            buttonNext.setTranslationY(positionOffset * yOffset);
        }
    }
    else if (realPosition >= adapter.getCount() - 1) {
        //Hide finish icon, keep next icon hidden
        if (buttonNextFunction == BUTTON_NEXT_FUNCTION_NEXT_FINISH) {
            buttonNext.setTranslationY(positionOffset * yOffset);
        } else {
            buttonNext.setTranslationY(-yOffset);
        }
    }
}
 
Example #4
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 6 votes vote down vote up
private void updateTaskDescription() {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        String title = getTitle().toString();
        Drawable iconDrawable = getApplicationInfo().loadIcon(getPackageManager());
        Bitmap icon = iconDrawable instanceof BitmapDrawable ? ((BitmapDrawable) iconDrawable).getBitmap() : null;
        int colorPrimary;
        if (position < getCount()) {
            try {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(position));
            } catch (Resources.NotFoundException e) {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackground(position));
            }
        }
        else {
            TypedValue typedValue = new TypedValue();
            TypedArray a = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimary});
            colorPrimary = a.getColor(0, 0);
            a.recycle();
        }
        colorPrimary = ColorUtils.setAlphaComponent(colorPrimary, 0xFF);

        setTaskDescription(new ActivityManager.TaskDescription(title, icon, colorPrimary));
    }
}
 
Example #5
Source File: IntroActivity.java    From material-intro with MIT License 6 votes vote down vote up
private void updateButtonNextPosition() {
    float realPosition = position + positionOffset;
    float yOffset = getResources().getDimensionPixelSize(R.dimen.mi_y_offset);

    if (realPosition < adapter.getCount() - 2) {
        //Reset
        miButtonNext.setTranslationY(0);
    } else if (realPosition < adapter.getCount() - 1) {
        //Reset finish button, hide next icon
        if (buttonNextFunction == BUTTON_NEXT_FUNCTION_NEXT_FINISH) {
            miButtonNext.setTranslationY(0);
        } else {
            miButtonNext.setTranslationY(positionOffset * yOffset);
        }
    } else if (realPosition >= adapter.getCount() - 1) {
        //Hide finish icon, keep next icon hidden
        if (buttonNextFunction == BUTTON_NEXT_FUNCTION_NEXT_FINISH) {
            miButtonNext.setTranslationY(positionOffset * yOffset);
        } else {
            miButtonNext.setTranslationY(-yOffset);
        }
    }
}
 
Example #6
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    pageScrollInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.accelerate_decelerate);
    pageScrollDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(KEY_CURRENT_ITEM)) {
            position = savedInstanceState.getInt(KEY_CURRENT_ITEM, position);
        }
        if (savedInstanceState.containsKey(KEY_FULLSCREEN)) {
            fullscreen = savedInstanceState.getBoolean(KEY_FULLSCREEN, fullscreen);
        }
        if (savedInstanceState.containsKey(KEY_BUTTON_CTA_VISIBLE)) {
            buttonCtaVisible = savedInstanceState.getBoolean(KEY_BUTTON_CTA_VISIBLE, buttonCtaVisible);
        }
    }

    if (fullscreen) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setSystemUiFlags(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, true);
            updateFullscreen();
        }
        else {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    setContentView(R.layout.activity_intro);
    findViews();
}
 
Example #7
Source File: InkPageIndicator.java    From Puff-Android with MIT License 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap,
            DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    int unselectedColor = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    int selectedColor = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColor);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColor);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now – reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #8
Source File: IntroActivity.java    From Puff-Android with MIT License 5 votes vote down vote up
private void updateButtonNextDrawable() {
    float offset = 0;
    if (finishEnabled && position + positionOffset >= adapter.getCount() - 2) {
        offset = Math.min(position + positionOffset - adapter.getCount() + 2, 1);
    }

    if (offset <= 0) {
        buttonNext.setImageResource(R.drawable.ic_next);
        buttonNext.getBackground().setAlpha(50);
    } else {
        buttonNext.setImageResource(offset > 0 ? R.drawable.ic_finish : R.drawable.ic_next);
        buttonNext.getBackground().mutate().setAlpha(50);

    }
}
 
Example #9
Source File: IntroActivity.java    From Puff-Android with MIT License 5 votes vote down vote up
private void updateButtonSkipDrawable() {
    if (skipEnabled) {
        buttonSkip.setImageResource(R.drawable.ic_skip);
    } else {
        buttonSkip.setImageResource(R.drawable.ic_previous);
        buttonSkip.getBackground().setAlpha(50);
    }
}
 
Example #10
Source File: SimpleSlide.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getButtonCtaLabel() {
    updatePermissions();
    if (permissions == null) {
        return buttonCtaLabel;
    }
    Context context = fragment.getContext();
    if (context != null)
        return context.getResources().getQuantityText(
                R.plurals.mi_label_grant_permission, permissions.length);
    return null;
}
 
Example #11
Source File: InkPageIndicator.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap,
            DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now – reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #12
Source File: InkPageIndicator.java    From material-intro with MIT License 5 votes vote down vote up
public InkPageIndicator(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final int density = (int) context.getResources().getDisplayMetrics().density;

    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.InkPageIndicator, defStyle, 0);

    dotDiameter = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotDiameter,
            DEFAULT_DOT_SIZE * density);
    dotRadius = dotDiameter / 2;
    halfDotRadius = dotRadius / 2;
    gap = a.getDimensionPixelSize(R.styleable.InkPageIndicator_dotGap,
            DEFAULT_GAP * density);
    animDuration = (long) a.getInteger(R.styleable.InkPageIndicator_animationDuration,
            DEFAULT_ANIM_DURATION);
    animHalfDuration = animDuration / 2;
    unselectedColour = a.getColor(R.styleable.InkPageIndicator_pageIndicatorColor,
            DEFAULT_UNSELECTED_COLOUR);
    selectedColour = a.getColor(R.styleable.InkPageIndicator_currentPageIndicatorColor,
            DEFAULT_SELECTED_COLOUR);

    a.recycle();

    unselectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    unselectedPaint.setColor(unselectedColour);
    selectedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    selectedPaint.setColor(selectedColour);
    interpolator = AnimUtils.getFastOutSlowInInterpolator(context);

    // create paths & rect now – reuse & rewind later
    combinedUnselectedPath = new Path();
    unselectedDotPath = new Path();
    unselectedDotLeftPath = new Path();
    unselectedDotRightPath = new Path();
    rectF = new RectF();

    addOnAttachStateChangeListener(this);
}
 
Example #13
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
@Nullable
private Pair<CharSequence, ? extends View.OnClickListener> getButtonCta(int position) {
    if (position < getCount() && getSlide(position) instanceof ButtonCtaSlide) {
        ButtonCtaSlide slide = (ButtonCtaSlide) getSlide(position);
        if (slide.getButtonCtaClickListener() != null &&
                (slide.getButtonCtaLabel() != null || slide.getButtonCtaLabelRes() != 0)) {
            if (slide.getButtonCtaLabel() != null) {
                return Pair.create(slide.getButtonCtaLabel(),
                        slide.getButtonCtaClickListener());
            } else {
                return Pair.create((CharSequence) getString(slide.getButtonCtaLabelRes()),
                        slide.getButtonCtaClickListener());
            }
        }
    }
    if (buttonCtaVisible) {
        if (buttonCtaLabelRes != 0) {
            return Pair.create((CharSequence) getString(buttonCtaLabelRes),
                    new ButtonCtaClickListener());
        }
        if (!TextUtils.isEmpty(buttonCtaLabel)) {
            return Pair.create(buttonCtaLabel, new ButtonCtaClickListener());
        }
        else {
            return Pair.create((CharSequence) getString(R.string.mi_label_button_cta),
                    new ButtonCtaClickListener());
        }
    }
    return null;
}
 
Example #14
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
private void updatePagerIndicatorPosition() {
    float realPosition = position + positionOffset;
    float yOffset = getResources().getDimensionPixelSize(R.dimen.mi_y_offset);

    if (realPosition < adapter.getCount() - 1) {
        //Reset
        pagerIndicator.setTranslationY(0);
    }
    else {
        //Hide CTA button
        pagerIndicator.setTranslationY(positionOffset * yOffset);
    }
}
 
Example #15
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
private void updateButtonBackDrawable() {
    if (buttonBackFunction == BUTTON_BACK_FUNCTION_SKIP) {
        buttonBack.setImageResource(R.drawable.ic_skip);
    } else {
        buttonBack.setImageResource(R.drawable.ic_previous);
    }
}
 
Example #16
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
public void setButtonBackFunction(@ButtonBackFunction int buttonBackFunction) {
    this.buttonBackFunction = buttonBackFunction;
    switch (buttonBackFunction) {
        case BUTTON_BACK_FUNCTION_BACK:
            CheatSheet.setup(buttonBack, R.string.mi_content_description_back);
            break;
        case BUTTON_BACK_FUNCTION_SKIP:
            CheatSheet.setup(buttonBack, R.string.mi_content_description_skip);
            break;
    }
    updateButtonBackDrawable();
    updateButtonBackPosition();
}
 
Example #17
Source File: IntroActivity.java    From Prodigal with Apache License 2.0 5 votes vote down vote up
public void setButtonNextFunction(@ButtonNextFunction int buttonNextFunction) {
    this.buttonNextFunction = buttonNextFunction;
    switch (buttonNextFunction) {
        case BUTTON_NEXT_FUNCTION_NEXT_FINISH:
            CheatSheet.setup(buttonNext, R.string.mi_content_description_next_finish);
            break;
        case BUTTON_NEXT_FUNCTION_NEXT:
            CheatSheet.setup(buttonNext, R.string.mi_content_description_next);
            break;
    }
    updateButtonNextDrawable();
    updateButtonNextPosition();
}
 
Example #18
Source File: SimpleSlide.java    From material-intro with MIT License 5 votes vote down vote up
@Override
public CharSequence getButtonCtaLabel() {
    updatePermissions();
    if (permissions == null) {
        return buttonCtaLabel;
    }
    Context context = fragment.getContext();
    if (context != null)
        return context.getResources().getQuantityText(
                R.plurals.mi_label_grant_permission, permissions.length);
    return null;
}
 
Example #19
Source File: IntroActivity.java    From material-intro with MIT License 5 votes vote down vote up
public void setButtonNextFunction(@ButtonNextFunction int buttonNextFunction) {
    this.buttonNextFunction = buttonNextFunction;
    switch (buttonNextFunction) {
        case BUTTON_NEXT_FUNCTION_NEXT_FINISH:
            CheatSheet.setup(miButtonNext, R.string.mi_content_description_next_finish);
            break;
        case BUTTON_NEXT_FUNCTION_NEXT:
            CheatSheet.setup(miButtonNext, R.string.mi_content_description_next);
            break;
    }
    updateButtonNextDrawable();
    updateButtonNextPosition();
}
 
Example #20
Source File: IntroActivity.java    From material-intro with MIT License 5 votes vote down vote up
@SuppressWarnings("unused")
public void setButtonBackFunction(@ButtonBackFunction int buttonBackFunction) {
    this.buttonBackFunction = buttonBackFunction;
    switch (buttonBackFunction) {
        case BUTTON_BACK_FUNCTION_BACK:
            CheatSheet.setup(miButtonBack, R.string.mi_content_description_back);
            break;
        case BUTTON_BACK_FUNCTION_SKIP:
            CheatSheet.setup(miButtonBack, R.string.mi_content_description_skip);
            break;
    }
    updateButtonBackDrawable();
    updateButtonBackPosition();
}
 
Example #21
Source File: IntroActivity.java    From material-intro with MIT License 5 votes vote down vote up
private void updateButtonBackDrawable() {
    if (buttonBackFunction == BUTTON_BACK_FUNCTION_SKIP) {
        miButtonBack.setImageResource(R.drawable.mi_ic_skip);
    } else {
        miButtonBack.setImageResource(R.drawable.mi_ic_previous);
    }
}
 
Example #22
Source File: IntroActivity.java    From material-intro with MIT License 5 votes vote down vote up
private void updatePagerIndicatorPosition() {
    float realPosition = position + positionOffset;
    float yOffset = getResources().getDimensionPixelSize(R.dimen.mi_y_offset);

    if (realPosition < adapter.getCount() - 1) {
        //Reset
        miPagerIndicator.setTranslationY(0);
    } else {
        //Hide CTA button
        miPagerIndicator.setTranslationY(positionOffset * yOffset);
    }
}
 
Example #23
Source File: IntroActivity.java    From material-intro with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    pageScrollInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.accelerate_decelerate);
    pageScrollDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(KEY_CURRENT_ITEM)) {
            position = savedInstanceState.getInt(KEY_CURRENT_ITEM, position);
        }
        if (savedInstanceState.containsKey(KEY_FULLSCREEN)) {
            fullscreen = savedInstanceState.getBoolean(KEY_FULLSCREEN, fullscreen);
        }
        if (savedInstanceState.containsKey(KEY_BUTTON_CTA_VISIBLE)) {
            buttonCtaVisible = savedInstanceState.getBoolean(KEY_BUTTON_CTA_VISIBLE, buttonCtaVisible);
        }
    }

    if (fullscreen) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            setSystemUiFlags(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, true);
            updateFullscreen();
        } else {
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    setContentView(R.layout.mi_activity_intro);
    initViews();
}
 
Example #24
Source File: IntroActivity.java    From material-intro with MIT License 5 votes vote down vote up
private void initViews() {
    // bind views
    miFrame = findViewById(R.id.mi_frame);
    miPager = findViewById(R.id.mi_pager);
    miPagerIndicator = findViewById(R.id.mi_pager_indicator);
    miButtonCta = findViewById(R.id.mi_button_cta);
    miButtonBack = findViewById(R.id.mi_button_back);
    miButtonNext = findViewById(R.id.mi_button_next);

    if (miButtonCta != null) {
        miButtonCta.setInAnimation(this, R.anim.mi_fade_in);
        miButtonCta.setOutAnimation(this, R.anim.mi_fade_out);
    }

    FragmentManager fragmentManager = getSupportFragmentManager();
    adapter = new SlideAdapter(fragmentManager);

    miPager.setAdapter(adapter);
    miPager.addOnPageChangeListener(listener);
    miPager.setCurrentItem(position, false);

    miPagerIndicator.setViewPager(miPager);

    resetButtonNextOnClickListener();
    resetButtonBackOnClickListener();

    CheatSheet.setup(miButtonNext);
    CheatSheet.setup(miButtonBack);
}
 
Example #25
Source File: IntroActivity.java    From material-intro with MIT License 5 votes vote down vote up
@Nullable
private Pair<CharSequence, ? extends View.OnClickListener> getButtonCta(int position) {
    if (position < getCount() && getSlide(position) instanceof ButtonCtaSlide) {
        ButtonCtaSlide slide = (ButtonCtaSlide) getSlide(position);
        if (slide.getButtonCtaClickListener() != null &&
                (slide.getButtonCtaLabel() != null || slide.getButtonCtaLabelRes() != 0)) {
            if (slide.getButtonCtaLabel() != null) {
                return Pair.create(slide.getButtonCtaLabel(),
                        slide.getButtonCtaClickListener());
            } else {
                return Pair.create((CharSequence) getString(slide.getButtonCtaLabelRes()),
                        slide.getButtonCtaClickListener());
            }
        }
    }
    if (buttonCtaVisible) {
        if (buttonCtaLabelRes != 0) {
            return Pair.create((CharSequence) getString(buttonCtaLabelRes),
                    new ButtonCtaClickListener());
        }
        if (!TextUtils.isEmpty(buttonCtaLabel)) {
            return Pair.create(buttonCtaLabel, new ButtonCtaClickListener());
        } else {
            return Pair.create((CharSequence) getString(R.string.mi_label_button_cta),
                    new ButtonCtaClickListener());
        }
    }
    return null;
}
 
Example #26
Source File: IntroActivity.java    From material-intro with MIT License 5 votes vote down vote up
private void updateTaskDescription() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        String title = getTitle().toString();
        Drawable iconDrawable = getApplicationInfo().loadIcon(getPackageManager());
        Bitmap icon = iconDrawable instanceof BitmapDrawable ? ((BitmapDrawable) iconDrawable).getBitmap() : null;
        int colorPrimary;
        if (position < getCount()) {
            try {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackgroundDark(position));
            } catch (Resources.NotFoundException e) {
                colorPrimary = ContextCompat.getColor(IntroActivity.this, getBackground(position));
            }
        } else {
            TypedValue typedValue = new TypedValue();
            TypedArray a = obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorPrimary});
            colorPrimary = a.getColor(0, 0);
            a.recycle();
        }
        colorPrimary = ColorUtils.setAlphaComponent(colorPrimary, 0xFF);

        setTaskDescription(new ActivityManager.TaskDescription(title, icon, colorPrimary));
    }
}
 
Example #27
Source File: ParallaxRelativeLayout.java    From Prodigal with Apache License 2.0 4 votes vote down vote up
public LayoutParams(Context c, AttributeSet attrs) {
    super(c, attrs);
    TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.ParallaxLayout_Layout);
    parallaxFactor = a.getFloat(R.styleable.ParallaxLayout_Layout_layout_parallaxFactor, parallaxFactor);
    a.recycle();
}
 
Example #28
Source File: AnimUtils.java    From Prodigal with Apache License 2.0 4 votes vote down vote up
public static void applyShakeAnimation(Context context, View view) {
    Animation shake;
    shake = AnimationUtils.loadAnimation(context, R.anim.shake);
    view.startAnimation(shake);
}
 
Example #29
Source File: ParallaxLinearLayout.java    From material-intro with MIT License 4 votes vote down vote up
public LayoutParams(Context c, AttributeSet attrs) {
    super(c, attrs);
    TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.ParallaxLayout_Layout);
    parallaxFactor = a.getFloat(R.styleable.ParallaxLayout_Layout_layout_parallaxFactor, parallaxFactor);
    a.recycle();
}
 
Example #30
Source File: ParallaxRelativeLayout.java    From material-intro with MIT License 4 votes vote down vote up
public LayoutParams(Context c, AttributeSet attrs) {
    super(c, attrs);
    TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.ParallaxLayout_Layout);
    parallaxFactor = a.getFloat(R.styleable.ParallaxLayout_Layout_layout_parallaxFactor, parallaxFactor);
    a.recycle();
}