Search in sources :

Example 1 with LabeledSeekBar

use of com.android.settings.widget.LabeledSeekBar in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PreviewSeekBarPreferenceFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = super.onCreateView(inflater, container, savedInstanceState);
    final ViewGroup listContainer = (ViewGroup) root.findViewById(android.R.id.list_container);
    listContainer.removeAllViews();
    final View content = inflater.inflate(mActivityLayoutResId, listContainer, false);
    listContainer.addView(content);
    mLabel = (TextView) content.findViewById(R.id.current_label);
    // The maximum SeekBar value always needs to be non-zero. If there's
    // only one available value, we'll handle this by disabling the
    // seek bar.
    final int max = Math.max(1, mEntries.length - 1);
    final LabeledSeekBar seekBar = (LabeledSeekBar) content.findViewById(R.id.seek_bar);
    seekBar.setLabels(mEntries);
    seekBar.setMax(max);
    seekBar.setProgress(mInitialIndex);
    seekBar.setOnSeekBarChangeListener(new onPreviewSeekBarChangeListener());
    mSmaller = content.findViewById(R.id.smaller);
    mSmaller.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress > 0) {
                seekBar.setProgress(progress - 1, true);
            }
        }
    });
    mLarger = content.findViewById(R.id.larger);
    mLarger.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress < seekBar.getMax()) {
                seekBar.setProgress(progress + 1, true);
            }
        }
    });
    if (mEntries.length == 1) {
        // The larger and smaller buttons will be disabled when we call
        // setPreviewLayer() later in this method.
        seekBar.setEnabled(false);
    }
    final Context context = getContext();
    final Configuration origConfig = context.getResources().getConfiguration();
    final boolean isLayoutRtl = origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    Configuration[] configurations = new Configuration[mEntries.length];
    for (int i = 0; i < mEntries.length; ++i) {
        configurations[i] = createConfig(origConfig, i);
    }
    mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
    mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, mPreviewSampleResIds, configurations);
    mPreviewPager.setAdapter(mPreviewPagerAdapter);
    mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0);
    mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener);
    mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator);
    if (mPreviewSampleResIds.length > 1) {
        mPageIndicator.setViewPager(mPreviewPager);
        mPageIndicator.setVisibility(View.VISIBLE);
        mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener);
    } else {
        mPageIndicator.setVisibility(View.GONE);
    }
    setPreviewLayer(mInitialIndex, false);
    return root;
}
Also used : Context(android.content.Context) LabeledSeekBar(com.android.settings.widget.LabeledSeekBar) Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View)

Example 2 with LabeledSeekBar

use of com.android.settings.widget.LabeledSeekBar in project android_packages_apps_Settings by omnirom.

the class PreviewSeekBarPreferenceFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = super.onCreateView(inflater, container, savedInstanceState);
    final ViewGroup listContainer = (ViewGroup) root.findViewById(android.R.id.list_container);
    listContainer.removeAllViews();
    final View content = inflater.inflate(mActivityLayoutResId, listContainer, false);
    listContainer.addView(content);
    mLabel = (TextView) content.findViewById(R.id.current_label);
    // The maximum SeekBar value always needs to be non-zero. If there's
    // only one available value, we'll handle this by disabling the
    // seek bar.
    final int max = Math.max(1, mEntries.length - 1);
    final LabeledSeekBar seekBar = (LabeledSeekBar) content.findViewById(R.id.seek_bar);
    seekBar.setLabels(mEntries);
    seekBar.setMax(max);
    seekBar.setProgress(mInitialIndex);
    seekBar.setOnSeekBarChangeListener(new onPreviewSeekBarChangeListener());
    mSmaller = content.findViewById(R.id.smaller);
    mSmaller.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress > 0) {
                seekBar.setProgress(progress - 1, true);
            }
        }
    });
    mLarger = content.findViewById(R.id.larger);
    mLarger.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress < seekBar.getMax()) {
                seekBar.setProgress(progress + 1, true);
            }
        }
    });
    if (mEntries.length == 1) {
        // The larger and smaller buttons will be disabled when we call
        // setPreviewLayer() later in this method.
        seekBar.setEnabled(false);
    }
    final Context context = getContext();
    final Configuration origConfig = context.getResources().getConfiguration();
    final boolean isLayoutRtl = origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    Configuration[] configurations = new Configuration[mEntries.length];
    for (int i = 0; i < mEntries.length; ++i) {
        configurations[i] = createConfig(origConfig, i);
    }
    mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
    mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, mPreviewSampleResIds, configurations);
    mPreviewPager.setAdapter(mPreviewPagerAdapter);
    mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0);
    mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener);
    mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator);
    if (mPreviewSampleResIds.length > 1) {
        mPageIndicator.setViewPager(mPreviewPager);
        mPageIndicator.setVisibility(View.VISIBLE);
        mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener);
    } else {
        mPageIndicator.setVisibility(View.GONE);
    }
    setPreviewLayer(mInitialIndex, false);
    return root;
}
Also used : Context(android.content.Context) LabeledSeekBar(com.android.settings.widget.LabeledSeekBar) Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View)

Example 3 with LabeledSeekBar

use of com.android.settings.widget.LabeledSeekBar in project android_packages_apps_Settings by LineageOS.

the class PreviewSeekBarPreferenceFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = super.onCreateView(inflater, container, savedInstanceState);
    final ViewGroup listContainer = (ViewGroup) root.findViewById(android.R.id.list_container);
    listContainer.removeAllViews();
    final View content = inflater.inflate(mActivityLayoutResId, listContainer, false);
    listContainer.addView(content);
    mLabel = (TextView) content.findViewById(R.id.current_label);
    // The maximum SeekBar value always needs to be non-zero. If there's
    // only one available value, we'll handle this by disabling the
    // seek bar.
    final int max = Math.max(1, mEntries.length - 1);
    final LabeledSeekBar seekBar = (LabeledSeekBar) content.findViewById(R.id.seek_bar);
    seekBar.setLabels(mEntries);
    seekBar.setMax(max);
    seekBar.setProgress(mInitialIndex);
    seekBar.setOnSeekBarChangeListener(new onPreviewSeekBarChangeListener());
    mSmaller = content.findViewById(R.id.smaller);
    mSmaller.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress > 0) {
                seekBar.setProgress(progress - 1, true);
            }
        }
    });
    mLarger = content.findViewById(R.id.larger);
    mLarger.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress < seekBar.getMax()) {
                seekBar.setProgress(progress + 1, true);
            }
        }
    });
    if (mEntries.length == 1) {
        // The larger and smaller buttons will be disabled when we call
        // setPreviewLayer() later in this method.
        seekBar.setEnabled(false);
    }
    final Context context = getContext();
    final Configuration origConfig = context.getResources().getConfiguration();
    final boolean isLayoutRtl = origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    Configuration[] configurations = new Configuration[mEntries.length];
    for (int i = 0; i < mEntries.length; ++i) {
        configurations[i] = createConfig(origConfig, i);
    }
    mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
    mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, mPreviewSampleResIds, configurations);
    mPreviewPager.setAdapter(mPreviewPagerAdapter);
    mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0);
    mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener);
    mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator);
    if (mPreviewSampleResIds.length > 1) {
        mPageIndicator.setViewPager(mPreviewPager);
        mPageIndicator.setVisibility(View.VISIBLE);
        mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener);
    } else {
        mPageIndicator.setVisibility(View.GONE);
    }
    setPreviewLayer(mInitialIndex, false);
    return root;
}
Also used : Context(android.content.Context) LabeledSeekBar(com.android.settings.widget.LabeledSeekBar) Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View)

Example 4 with LabeledSeekBar

use of com.android.settings.widget.LabeledSeekBar in project android_packages_apps_Settings by DirtyUnicorns.

the class PreviewSeekBarPreferenceFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = super.onCreateView(inflater, container, savedInstanceState);
    final ViewGroup listContainer = (ViewGroup) root.findViewById(android.R.id.list_container);
    listContainer.removeAllViews();
    final View content = inflater.inflate(mActivityLayoutResId, listContainer, false);
    listContainer.addView(content);
    mLabel = (TextView) content.findViewById(R.id.current_label);
    // The maximum SeekBar value always needs to be non-zero. If there's
    // only one available value, we'll handle this by disabling the
    // seek bar.
    final int max = Math.max(1, mEntries.length - 1);
    final LabeledSeekBar seekBar = (LabeledSeekBar) content.findViewById(R.id.seek_bar);
    seekBar.setLabels(mEntries);
    seekBar.setMax(max);
    seekBar.setProgress(mInitialIndex);
    seekBar.setOnSeekBarChangeListener(new onPreviewSeekBarChangeListener());
    mSmaller = content.findViewById(R.id.smaller);
    mSmaller.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress > 0) {
                seekBar.setProgress(progress - 1, true);
            }
        }
    });
    mLarger = content.findViewById(R.id.larger);
    mLarger.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress < seekBar.getMax()) {
                seekBar.setProgress(progress + 1, true);
            }
        }
    });
    if (mEntries.length == 1) {
        // The larger and smaller buttons will be disabled when we call
        // setPreviewLayer() later in this method.
        seekBar.setEnabled(false);
    }
    final Context context = getContext();
    final Configuration origConfig = context.getResources().getConfiguration();
    final boolean isLayoutRtl = origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    Configuration[] configurations = new Configuration[mEntries.length];
    for (int i = 0; i < mEntries.length; ++i) {
        configurations[i] = createConfig(origConfig, i);
    }
    mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
    mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, mPreviewSampleResIds, configurations);
    mPreviewPager.setAdapter(mPreviewPagerAdapter);
    mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0);
    mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener);
    mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator);
    if (mPreviewSampleResIds.length > 1) {
        mPageIndicator.setViewPager(mPreviewPager);
        mPageIndicator.setVisibility(View.VISIBLE);
        mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener);
    } else {
        mPageIndicator.setVisibility(View.GONE);
    }
    setPreviewLayer(mInitialIndex, false);
    return root;
}
Also used : Context(android.content.Context) LabeledSeekBar(com.android.settings.widget.LabeledSeekBar) Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View)

Example 5 with LabeledSeekBar

use of com.android.settings.widget.LabeledSeekBar in project android_packages_apps_Settings by crdroidandroid.

the class PreviewSeekBarPreferenceFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = super.onCreateView(inflater, container, savedInstanceState);
    final ViewGroup listContainer = (ViewGroup) root.findViewById(android.R.id.list_container);
    listContainer.removeAllViews();
    final View content = inflater.inflate(mActivityLayoutResId, listContainer, false);
    listContainer.addView(content);
    mLabel = (TextView) content.findViewById(R.id.current_label);
    // The maximum SeekBar value always needs to be non-zero. If there's
    // only one available value, we'll handle this by disabling the
    // seek bar.
    final int max = Math.max(1, mEntries.length - 1);
    final LabeledSeekBar seekBar = (LabeledSeekBar) content.findViewById(R.id.seek_bar);
    seekBar.setLabels(mEntries);
    seekBar.setMax(max);
    seekBar.setProgress(mInitialIndex);
    seekBar.setOnSeekBarChangeListener(new onPreviewSeekBarChangeListener());
    mSmaller = content.findViewById(R.id.smaller);
    mSmaller.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress > 0) {
                seekBar.setProgress(progress - 1, true);
            }
        }
    });
    mLarger = content.findViewById(R.id.larger);
    mLarger.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final int progress = seekBar.getProgress();
            if (progress < seekBar.getMax()) {
                seekBar.setProgress(progress + 1, true);
            }
        }
    });
    if (mEntries.length == 1) {
        // The larger and smaller buttons will be disabled when we call
        // setPreviewLayer() later in this method.
        seekBar.setEnabled(false);
    }
    final Context context = getContext();
    final Configuration origConfig = context.getResources().getConfiguration();
    final boolean isLayoutRtl = origConfig.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    Configuration[] configurations = new Configuration[mEntries.length];
    for (int i = 0; i < mEntries.length; ++i) {
        configurations[i] = createConfig(origConfig, i);
    }
    mPreviewPager = (ViewPager) content.findViewById(R.id.preview_pager);
    mPreviewPagerAdapter = new PreviewPagerAdapter(context, isLayoutRtl, mPreviewSampleResIds, configurations);
    mPreviewPager.setAdapter(mPreviewPagerAdapter);
    mPreviewPager.setCurrentItem(isLayoutRtl ? mPreviewSampleResIds.length - 1 : 0);
    mPreviewPager.addOnPageChangeListener(mPreviewPageChangeListener);
    mPageIndicator = (DotsPageIndicator) content.findViewById(R.id.page_indicator);
    if (mPreviewSampleResIds.length > 1) {
        mPageIndicator.setViewPager(mPreviewPager);
        mPageIndicator.setVisibility(View.VISIBLE);
        mPageIndicator.setOnPageChangeListener(mPageIndicatorPageChangeListener);
    } else {
        mPageIndicator.setVisibility(View.GONE);
    }
    setPreviewLayer(mInitialIndex, false);
    return root;
}
Also used : Context(android.content.Context) LabeledSeekBar(com.android.settings.widget.LabeledSeekBar) Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Context (android.content.Context)7 Configuration (android.content.res.Configuration)7 View (android.view.View)7 OnClickListener (android.view.View.OnClickListener)7 ViewGroup (android.view.ViewGroup)7 TextView (android.widget.TextView)7 LabeledSeekBar (com.android.settings.widget.LabeledSeekBar)7