Search in sources :

Example 1 with ViewTarget

use of com.github.amlcurran.showcaseview.targets.ViewTarget in project k-9 by k9mail.

the class HighlightDialogFragment method highlightViewInBackground.

protected void highlightViewInBackground() {
    if (!getArguments().containsKey(ARG_HIGHLIGHT_VIEW)) {
        return;
    }
    Activity activity = getActivity();
    if (activity == null) {
        throw new IllegalStateException("fragment must be attached to set highlight!");
    }
    boolean alreadyShowing = showcaseView != null && showcaseView.isShowing();
    if (alreadyShowing) {
        return;
    }
    int highlightedView = getArguments().getInt(ARG_HIGHLIGHT_VIEW);
    showcaseView = new Builder(activity).setTarget(new ViewTarget(highlightedView, activity)).hideOnTouchOutside().blockAllTouches().withMaterialShowcase().setStyle(R.style.ShowcaseTheme).build();
    showcaseView.hideButton();
}
Also used : Builder(com.github.amlcurran.showcaseview.ShowcaseView.Builder) Activity(android.app.Activity) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget)

Example 2 with ViewTarget

use of com.github.amlcurran.showcaseview.targets.ViewTarget in project ShowcaseView by amlcurran.

the class ActionItemsSampleActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_action_items);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    try {
        ViewTarget navigationButtonViewTarget = ViewTargets.navigationButtonViewTarget(toolbar);
        new ShowcaseView.Builder(this).withMaterialShowcase().setTarget(navigationButtonViewTarget).setStyle(R.style.CustomShowcaseTheme2).setContentText("Here's how to highlight items on a toolbar").build().show();
    } catch (ViewTargets.MissingViewException e) {
        e.printStackTrace();
    }
}
Also used : ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) Toolbar(android.support.v7.widget.Toolbar)

Example 3 with ViewTarget

use of com.github.amlcurran.showcaseview.targets.ViewTarget in project ShowcaseView by amlcurran.

the class CustomTextActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom_text);
    TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    paint.setTextSize(getResources().getDimension(R.dimen.abc_text_size_body_1_material));
    paint.setStrikeThruText(true);
    paint.setColor(Color.RED);
    paint.setTypeface(Typeface.createFromAsset(getAssets(), "RobotoSlab-Regular.ttf"));
    TextPaint title = new TextPaint(Paint.ANTI_ALIAS_FLAG);
    title.setTextSize(getResources().getDimension(R.dimen.abc_text_size_headline_material));
    title.setUnderlineText(true);
    title.setColor(Color.YELLOW);
    title.setTypeface(Typeface.createFromAsset(getAssets(), "RobotoSlab-Regular.ttf"));
    ShowcaseView showcaseView = new ShowcaseView.Builder(this).withNewStyleShowcase().setTarget(new ViewTarget(R.id.imageView, this)).setContentTextPaint(paint).setContentTitle(R.string.custom_text_painting_title).setContentText(R.string.custom_text_painting_text).setContentTitlePaint(title).build();
    showcaseView.setDetailTextAlignment(Layout.Alignment.ALIGN_CENTER);
    showcaseView.setTitleTextAlignment(Layout.Alignment.ALIGN_CENTER);
    showcaseView.forceTextPosition(ShowcaseView.BELOW_SHOWCASE);
}
Also used : ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) TextPaint(android.text.TextPaint)

Example 4 with ViewTarget

use of com.github.amlcurran.showcaseview.targets.ViewTarget in project ShowcaseView by amlcurran.

the class MemoryManagementTesting method showcase.

private void showcase() {
    new ShowcaseView.Builder(this).withMaterialShowcase().setContentText(String.format("Showing %1$d", currentShowcase)).setTarget(new ViewTarget(R.id.buttonBlocked, this)).setShowcaseEventListener(new SimpleShowcaseEventListener() {

        @Override
        public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
            currentShowcase++;
            showcase();
        }
    }).build();
}
Also used : SimpleShowcaseEventListener(com.github.amlcurran.showcaseview.SimpleShowcaseEventListener) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView)

Example 5 with ViewTarget

use of com.github.amlcurran.showcaseview.targets.ViewTarget in project MusicDNA by harjot-oberai.

the class EqualizerFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    backBtn = (ImageView) view.findViewById(R.id.equalizer_back_btn);
    backBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    fragTitle = (TextView) view.findViewById(R.id.equalizer_fragment_title);
    if (SplashActivity.tf4 != null)
        fragTitle.setTypeface(SplashActivity.tf4);
    equalizerSwitch = (SwitchCompat) view.findViewById(R.id.equalizer_switch);
    equalizerSwitch.setChecked(HomeActivity.isEqualizerEnabled);
    equalizerSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mCallback.onCheckChanged(isChecked);
        }
    });
    spinnerDropDownIcon = (ImageView) view.findViewById(R.id.spinner_dropdown_icon);
    spinnerDropDownIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            presetSpinner.performClick();
        }
    });
    presetSpinner = (Spinner) view.findViewById(R.id.equalizer_preset_spinner);
    equalizerBlocker = (FrameLayout) view.findViewById(R.id.equalizerBlocker);
    if (HomeActivity.isEqualizerEnabled) {
        equalizerBlocker.setVisibility(View.GONE);
    } else {
        equalizerBlocker.setVisibility(View.VISIBLE);
    }
    chart = (LineChartView) view.findViewById(R.id.lineChart);
    paint = new Paint();
    dataset = new LineSet();
    bassController = (AnalogController) view.findViewById(R.id.controllerBass);
    reverbController = (AnalogController) view.findViewById(R.id.controller3D);
    bassController.setLabel("BASS");
    reverbController.setLabel("3D");
    bassController.circlePaint2.setColor(HomeActivity.themeColor);
    bassController.linePaint.setColor(HomeActivity.themeColor);
    bassController.invalidate();
    reverbController.circlePaint2.setColor(HomeActivity.themeColor);
    bassController.linePaint.setColor(HomeActivity.themeColor);
    reverbController.invalidate();
    if (!HomeActivity.isEqualizerReloaded) {
        int x = 0;
        if (PlayerFragment.bassBoost != null) {
            try {
                x = ((PlayerFragment.bassBoost.getRoundedStrength() * 19) / 1000);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (PlayerFragment.presetReverb != null) {
            try {
                y = (PlayerFragment.presetReverb.getPreset() * 19) / 6;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (x == 0) {
            bassController.setProgress(1);
        } else {
            bassController.setProgress(x);
        }
        if (y == 0) {
            reverbController.setProgress(1);
        } else {
            reverbController.setProgress(y);
        }
    } else {
        int x = ((HomeActivity.bassStrength * 19) / 1000);
        y = (HomeActivity.reverbPreset * 19) / 6;
        if (x == 0) {
            bassController.setProgress(1);
        } else {
            bassController.setProgress(x);
        }
        if (y == 0) {
            reverbController.setProgress(1);
        } else {
            reverbController.setProgress(y);
        }
    }
    bassController.setOnProgressChangedListener(new AnalogController.onProgressChangedListener() {

        @Override
        public void onProgressChanged(int progress) {
            HomeActivity.bassStrength = (short) (((float) 1000 / 19) * (progress));
            try {
                PlayerFragment.bassBoost.setStrength(HomeActivity.bassStrength);
                HomeActivity.equalizerModel.setBassStrength(HomeActivity.bassStrength);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    reverbController.setOnProgressChangedListener(new AnalogController.onProgressChangedListener() {

        @Override
        public void onProgressChanged(int progress) {
            HomeActivity.reverbPreset = (short) ((progress * 6) / 19);
            HomeActivity.equalizerModel.setReverbPreset(HomeActivity.reverbPreset);
            try {
                PlayerFragment.presetReverb.setPreset(HomeActivity.reverbPreset);
            } catch (Exception e) {
                e.printStackTrace();
            }
            y = progress;
        }
    });
    mLinearLayout = (LinearLayout) view.findViewById(R.id.equalizerContainer);
    TextView equalizerHeading = new TextView(getContext());
    equalizerHeading.setText("Equalizer");
    equalizerHeading.setTextSize(20);
    equalizerHeading.setGravity(Gravity.CENTER_HORIZONTAL);
    numberOfFrequencyBands = 5;
    points = new float[numberOfFrequencyBands];
    final short lowerEqualizerBandLevel = PlayerFragment.mEqualizer.getBandLevelRange()[0];
    final short upperEqualizerBandLevel = PlayerFragment.mEqualizer.getBandLevelRange()[1];
    for (short i = 0; i < numberOfFrequencyBands; i++) {
        final short equalizerBandIndex = i;
        final TextView frequencyHeaderTextView = new TextView(getContext());
        frequencyHeaderTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        frequencyHeaderTextView.setGravity(Gravity.CENTER_HORIZONTAL);
        frequencyHeaderTextView.setTextColor(Color.parseColor("#FFFFFF"));
        frequencyHeaderTextView.setText((PlayerFragment.mEqualizer.getCenterFreq(equalizerBandIndex) / 1000) + "Hz");
        LinearLayout seekBarRowLayout = new LinearLayout(getContext());
        seekBarRowLayout.setOrientation(LinearLayout.VERTICAL);
        TextView lowerEqualizerBandLevelTextView = new TextView(getContext());
        lowerEqualizerBandLevelTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
        lowerEqualizerBandLevelTextView.setTextColor(Color.parseColor("#FFFFFF"));
        lowerEqualizerBandLevelTextView.setText((lowerEqualizerBandLevel / 100) + "dB");
        TextView upperEqualizerBandLevelTextView = new TextView(getContext());
        lowerEqualizerBandLevelTextView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        upperEqualizerBandLevelTextView.setTextColor(Color.parseColor("#FFFFFF"));
        upperEqualizerBandLevelTextView.setText((upperEqualizerBandLevel / 100) + "dB");
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.weight = 1;
        SeekBar seekBar = new SeekBar(getContext());
        TextView textView = new TextView(getContext());
        switch(i) {
            case 0:
                seekBar = (SeekBar) view.findViewById(R.id.seekBar1);
                textView = (TextView) view.findViewById(R.id.textView1);
                break;
            case 1:
                seekBar = (SeekBar) view.findViewById(R.id.seekBar2);
                textView = (TextView) view.findViewById(R.id.textView2);
                break;
            case 2:
                seekBar = (SeekBar) view.findViewById(R.id.seekBar3);
                textView = (TextView) view.findViewById(R.id.textView3);
                break;
            case 3:
                seekBar = (SeekBar) view.findViewById(R.id.seekBar4);
                textView = (TextView) view.findViewById(R.id.textView4);
                break;
            case 4:
                seekBar = (SeekBar) view.findViewById(R.id.seekBar5);
                textView = (TextView) view.findViewById(R.id.textView5);
                break;
        }
        seekBarFinal[i] = seekBar;
        seekBar.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(Color.DKGRAY, PorterDuff.Mode.SRC_IN));
        seekBar.getThumb().setColorFilter(new PorterDuffColorFilter(HomeActivity.themeColor, PorterDuff.Mode.SRC_IN));
        seekBar.setId(i);
        //            seekBar.setLayoutParams(layoutParams);
        seekBar.setMax(upperEqualizerBandLevel - lowerEqualizerBandLevel);
        textView.setText(frequencyHeaderTextView.getText());
        textView.setTextColor(Color.WHITE);
        textView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
        if (HomeActivity.isEqualizerReloaded) {
            points[i] = HomeActivity.seekbarpos[i] - lowerEqualizerBandLevel;
            dataset.addPoint(frequencyHeaderTextView.getText().toString(), points[i]);
            seekBar.setProgress(HomeActivity.seekbarpos[i] - lowerEqualizerBandLevel);
        } else {
            points[i] = PlayerFragment.mEqualizer.getBandLevel(equalizerBandIndex) - lowerEqualizerBandLevel;
            dataset.addPoint(frequencyHeaderTextView.getText().toString(), points[i]);
            seekBar.setProgress(PlayerFragment.mEqualizer.getBandLevel(equalizerBandIndex) - lowerEqualizerBandLevel);
            HomeActivity.seekbarpos[i] = PlayerFragment.mEqualizer.getBandLevel(equalizerBandIndex);
            HomeActivity.isEqualizerReloaded = true;
        }
        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                PlayerFragment.mEqualizer.setBandLevel(equalizerBandIndex, (short) (progress + lowerEqualizerBandLevel));
                points[seekBar.getId()] = PlayerFragment.mEqualizer.getBandLevel(equalizerBandIndex) - lowerEqualizerBandLevel;
                HomeActivity.seekbarpos[seekBar.getId()] = (progress + lowerEqualizerBandLevel);
                HomeActivity.equalizerModel.getSeekbarpos()[seekBar.getId()] = (progress + lowerEqualizerBandLevel);
                dataset.updateValues(points);
                chart.notifyDataUpdate();
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                presetSpinner.setSelection(0);
                HomeActivity.presetPos = 0;
                HomeActivity.equalizerModel.setPresetPos(0);
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
    }
    equalizeSound();
    paint.setColor(Color.parseColor("#555555"));
    paint.setStrokeWidth((float) (1.10 * HomeActivity.ratio));
    dataset.setColor(HomeActivity.themeColor);
    dataset.setSmooth(true);
    dataset.setThickness(5);
    chart.setXAxis(false);
    chart.setYAxis(false);
    chart.setYLabels(AxisRenderer.LabelPosition.NONE);
    chart.setXLabels(AxisRenderer.LabelPosition.NONE);
    chart.setGrid(ChartView.GridType.NONE, 7, 10, paint);
    chart.setAxisBorderValues(-300, 3300);
    chart.addData(dataset);
    chart.show();
    Button mEndButton = new Button(getContext());
    mEndButton.setBackgroundColor(HomeActivity.themeColor);
    mEndButton.setTextColor(Color.WHITE);
    showCase = new ShowcaseView.Builder(getActivity()).blockAllTouches().singleShot(4).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(HomeActivity.tp).setTarget(new ViewTarget(R.id.showcase_view_equalizer, getActivity())).setContentTitle("Presets").setContentText("Use one of the available presets").build();
    showCase.setButtonText("Next");
    showCase.setButtonPosition(HomeActivity.lps);
    showCase.overrideButtonClick(new View.OnClickListener() {

        int count1 = 0;

        @Override
        public void onClick(View v) {
            count1++;
            switch(count1) {
                case 1:
                    showCase.setTarget(new ViewTarget(R.id.equalizerContainer, getActivity()));
                    showCase.setContentTitle("Equalizer Controls");
                    showCase.setContentText("Use the seekbars to control the Individual frequencies");
                    showCase.setButtonPosition(HomeActivity.lps);
                    showCase.setButtonText("Next");
                    break;
                case 2:
                    showCase.setTarget(new ViewTarget(R.id.controllerBass, getActivity()));
                    showCase.setContentTitle("Bass and Reverb");
                    showCase.setContentText("Use these controls to control Bass and Reverb");
                    showCase.setButtonPosition(HomeActivity.lps);
                    showCase.setButtonText("Done");
                    break;
                case 3:
                    showCase.hide();
                    break;
            }
        }
    });
}
Also used : PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) TextView(android.widget.TextView) SeekBar(android.widget.SeekBar) ViewGroup(android.view.ViewGroup) Paint(android.graphics.Paint) ImageView(android.widget.ImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) ChartView(com.db.chart.view.ChartView) TextView(android.widget.TextView) LineChartView(com.db.chart.view.LineChartView) LineSet(com.db.chart.model.LineSet) Paint(android.graphics.Paint) AnalogController(com.sdsmdg.harjot.MusicDNA.customviews.AnalogController) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) CompoundButton(android.widget.CompoundButton) LinearLayout(android.widget.LinearLayout)

Aggregations

ViewTarget (com.github.amlcurran.showcaseview.targets.ViewTarget)16 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)11 View (android.view.View)7 Button (android.widget.Button)7 TextView (android.widget.TextView)6 RecyclerView (android.support.v7.widget.RecyclerView)5 ImageView (android.widget.ImageView)5 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 RelativeLayout (android.widget.RelativeLayout)4 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)4 Handler (android.os.Handler)3 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)3 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)2 FloatingActionButton (android.support.design.widget.FloatingActionButton)2 TextPaint (android.text.TextPaint)2 MenuItem (android.view.MenuItem)2 AdapterView (android.widget.AdapterView)2 SeekBar (android.widget.SeekBar)2 ImageLoader (com.sdsmdg.harjot.MusicDNA.imageloader.ImageLoader)2