Android Open Source - Pimp_my_Z1 Card Double Seek Bar






From Project

Back to project page Pimp_my_Z1.

License

The source code is released under:

GNU General Public License

If you think the Android project Pimp_my_Z1 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**   Copyright (C) 2013  Louis Teboul (a.k.a Androguide)
 *//from  w ww  .j a  v  a2  s.com
 *    admin@pimpmyrom.org  || louisteboul@gmail.com
 *    http://pimpmyrom.org || http://androguide.fr
 *    71 quai Clmenceau, 69300 Caluire-et-Cuire, FRANCE.
 *
 *     This program is free software; you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation; either version 2 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License along
 *      with this program; if not, write to the Free Software Foundation, Inc.,
 *      51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 **/

package com.androguide.honamicontrol.cards;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.view.ActionMode;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;

import com.androguide.honamicontrol.R;
import com.androguide.honamicontrol.helpers.Helpers;
import com.androguide.honamicontrol.soundcontrol.SoundControlInterface;
import com.fima.cardsui.objects.Card;

public class CardDoubleSeekBar extends Card implements SoundControlInterface {

    private SharedPreferences prefs, soundPrefs, bootPrefs;
    private Boolean isLinked = true;
    private String location;

    public CardDoubleSeekBar(String title, String desc, String color, String unit, String prop, int seekBarMax, int seekBarProgress, int seekBarProgress2, ActionBarActivity fa, ActionMode.Callback callback) {
        super(title, desc, color, unit, prop, seekBarMax, seekBarProgress, seekBarProgress2, fa, callback);
        location = prop;
    }

    @Override
    public View getCardContent(Context context) {
        final View v = LayoutInflater.from(context).inflate(R.layout.card_double_seekbar, null);

        assert v != null;
        final TextView valueLeft = (TextView) v.findViewById(R.id.unit_left);
        final TextView valueRight = (TextView) v.findViewById(R.id.unit_right);
        final TextView titleView = (TextView) v.findViewById(R.id.title);
        titleView.setText(title);
        titleView.setTextColor(Color.parseColor(color));
        ((TextView) v.findViewById(R.id.desc)).setText(desc);

        final SeekBar seekBarLeft = (SeekBar) v.findViewById(R.id.seek_left);
        final SeekBar seekBarRight = (SeekBar) v.findViewById(R.id.seek_right);

        seekBarLeft.setMax(40);
        seekBarRight.setMax(40);
        seekBarLeft.setProgress(seekBarProgress);
        seekBarRight.setProgress(seekBarProgress2);

        valueLeft.setText(seekBarProgress - 30 + unit);
        valueRight.setText(seekBarProgress2 - 30 + unit);

        prefs = fa.getSharedPreferences(prop.replaceAll("/", "_"), 0);
        soundPrefs = fa.getSharedPreferences("SOUND_CONTROL", 0);
        bootPrefs = fa.getSharedPreferences("BOOT_PREFS", 0);
        isLinked = soundPrefs.getBoolean("LINKED", true);

        seekBarLeft.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                seekBarProgress = i;
                valueLeft.setText(i - 30 + unit);
                if (isLinked) {
                    seekBarProgress2 = i;
                    seekBarRight.setProgress(i);
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int toApplyLeft = getSCInt(seekBarProgress);
                int toApplyRight = getSCInt(seekBarProgress2);
                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + " && "
                                + "busybox echo " + toApplyLeft + " " + toApplyRight + " "
                                + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > " + location + " && "
                                + "busybox echo 1 > " + FAUX_SC_LOCKED
                );

                int scProgress = seekBar.getProgress() - 30;
                if (scProgress < 0)
                    scProgress += 256;
                prefs.edit().putInt("VALUE_LEFT", scProgress).commit();
            }
        });

        seekBarRight.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                seekBarProgress2 = i;
                valueRight.setText(i - 30 + unit);
                if (isLinked) {
                    seekBarProgress = i;
                    seekBarLeft.setProgress(i);
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                int toApplyLeft = getSCInt(seekBarProgress);
                int toApplyRight = getSCInt(seekBarProgress2);
                Helpers.CMDProcessorWrapper.runSuCommand("busybox echo 0 > " + FAUX_SC_LOCKED + " && "
                                + "busybox echo " + toApplyLeft + " " + toApplyRight + " "
                                + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight) + " > " + location + " && "
                                + "busybox echo 1 > " + FAUX_SC_LOCKED
                );
                bootPrefs.edit().putString(
                        prop.replaceAll("/", "_"), toApplyLeft + " " + toApplyRight + " " + Helpers.getSoundCountrolBitRepresentation(toApplyLeft, toApplyRight)
                ).commit();

                int scProgress = seekBar.getProgress() - 30;
                if (scProgress < 0)
                    scProgress += 256;
                prefs.edit().putInt("VALUE_RIGHT", scProgress).commit();
            }
        });

        return v;
    }

    public int getCardContentId() {
        return R.layout.card_double_seekbar;
    }

    public int getSCInt(int seekbarInt) {
        seekbarInt -= 30;
        if (seekbarInt < 0)
            seekbarInt += 256;
        return seekbarInt;
    }

    @Override
    public boolean convert(View convertCardView) {
        return true;
    }
}




Java Source Code List

com.androguide.honamicontrol.MainActivity.java
com.androguide.honamicontrol.PresentationActivity.java
com.androguide.honamicontrol.SettingsActivity.java
com.androguide.honamicontrol.bootservice.BootHelper.java
com.androguide.honamicontrol.bootservice.BootReceiver.java
com.androguide.honamicontrol.cards.CardDoubleSeekBarPA.java
com.androguide.honamicontrol.cards.CardDoubleSeekBar.java
com.androguide.honamicontrol.cards.CardImageLocal.java
com.androguide.honamicontrol.cards.CardSeekBarGeneric.java
com.androguide.honamicontrol.cards.CardSeekBarReadahead.java
com.androguide.honamicontrol.cards.CardSeekBarSC.java
com.androguide.honamicontrol.cards.CardSeekBarSysctl.java
com.androguide.honamicontrol.cards.CardSeekBarVibrator.java
com.androguide.honamicontrol.cards.CardSeekBar.java
com.androguide.honamicontrol.cards.CardSpinnerSchedMCDisabled.java
com.androguide.honamicontrol.cards.CardSpinnerSchedMC.java
com.androguide.honamicontrol.cards.CardSpinnerVoltage.java
com.androguide.honamicontrol.cards.CardSpinner.java
com.androguide.honamicontrol.cards.CardSwitchDisabled.java
com.androguide.honamicontrol.cards.CardSwitchPlugin.java
com.androguide.honamicontrol.cards.CardTopImageLocal.java
com.androguide.honamicontrol.fragments.CardsFragment.java
com.androguide.honamicontrol.fragments.HelpFragment.java
com.androguide.honamicontrol.fragments.WelcomeFragment.java
com.androguide.honamicontrol.helpers.CPUHelper.java
com.androguide.honamicontrol.helpers.FileHelper.java
com.androguide.honamicontrol.helpers.Helpers.java
com.androguide.honamicontrol.helpers.NegativeSeekBar.java
com.androguide.honamicontrol.helpers.ShellInterface.java
com.androguide.honamicontrol.helpers.SystemPropertiesReflection.java
com.androguide.honamicontrol.helpers.CMDProcessor.AbstractAsyncSuCMDProcessor.java
com.androguide.honamicontrol.helpers.CMDProcessor.CMDProcessor.java
com.androguide.honamicontrol.helpers.CMDProcessor.ChildProcess.java
com.androguide.honamicontrol.helpers.CMDProcessor.CommandResult.java
com.androguide.honamicontrol.helpers.CMDProcessor.Constants.java
com.androguide.honamicontrol.helpers.CMDProcessor.Shell.java
com.androguide.honamicontrol.kernel.KernelFragment.java
com.androguide.honamicontrol.kernel.colorcontrol.ColorControlActivity.java
com.androguide.honamicontrol.kernel.colorcontrol.ColorControlInterface.java
com.androguide.honamicontrol.kernel.cpucontrol.CPUActivity.java
com.androguide.honamicontrol.kernel.cpucontrol.CPUFragment.java
com.androguide.honamicontrol.kernel.cpucontrol.CPUInterface.java
com.androguide.honamicontrol.kernel.cpucontrol.GovernorDialog.java
com.androguide.honamicontrol.kernel.gpucontrol.GPUActivity.java
com.androguide.honamicontrol.kernel.gpucontrol.GPUInterface.java
com.androguide.honamicontrol.kernel.iotweaks.IOTweaksActivity.java
com.androguide.honamicontrol.kernel.iotweaks.IOTweaksInterface.java
com.androguide.honamicontrol.kernel.memory.MemoryManagementActivity.java
com.androguide.honamicontrol.kernel.memory.MemoryManagementInterface.java
com.androguide.honamicontrol.kernel.misc.MiscActivity.java
com.androguide.honamicontrol.kernel.misc.MiscInterface.java
com.androguide.honamicontrol.kernel.powermanagement.PowerManagementActivity.java
com.androguide.honamicontrol.kernel.powermanagement.PowerManagementInterface.java
com.androguide.honamicontrol.kernel.voltagecontrol.VoltageActivity.java
com.androguide.honamicontrol.kernel.voltagecontrol.VoltageInterface.java
com.androguide.honamicontrol.profiles.BalancedProfile.java
com.androguide.honamicontrol.profiles.BatteryMaxProfile.java
com.androguide.honamicontrol.profiles.BatteryProfile.java
com.androguide.honamicontrol.profiles.BenchmarkProfile.java
com.androguide.honamicontrol.profiles.PerformanceProfile.java
com.androguide.honamicontrol.profiles.ProfileEnabler.java
com.androguide.honamicontrol.profiles.Profile.java
com.androguide.honamicontrol.soundcontrol.SoundControlActivity.java
com.androguide.honamicontrol.soundcontrol.SoundControlFragment.java
com.androguide.honamicontrol.soundcontrol.SoundControlInterface.java
com.androguide.honamicontrol.soundcontrol.SoundFragment.java
com.androguide.honamicontrol.touchscreen.TouchScreenFragment.java
com.androguide.honamicontrol.touchscreen.TouchScreenInterface.java
com.astuetz.viewpager.extensions.PagerSlidingTabStrip.java
com.echo.holographlibrary.BarGraph.java
com.echo.holographlibrary.Bar.java
com.echo.holographlibrary.LineGraph.java
com.echo.holographlibrary.LinePoint.java
com.echo.holographlibrary.Line.java
com.echo.holographlibrary.PieGraph.java
com.echo.holographlibrary.PieSlice.java
com.fima.cardsui.StackAdapter.java
com.fima.cardsui.SwipeDismissTouchListener.java
com.fima.cardsui.Utils.java
com.fima.cardsui.objects.AbstractCard.java
com.fima.cardsui.objects.CardStack.java
com.fima.cardsui.objects.Card.java
com.fima.cardsui.views.CardCategory.java
com.fima.cardsui.views.CardDownload.java
com.fima.cardsui.views.CardEditText.java
com.fima.cardsui.views.CardEdit.java
com.fima.cardsui.views.CardImage.java
com.fima.cardsui.views.CardPresentation.java
com.fima.cardsui.views.CardSeekBar.java
com.fima.cardsui.views.CardSpinner.java
com.fima.cardsui.views.CardTextStripe.java
com.fima.cardsui.views.CardText.java
com.fima.cardsui.views.CardTopImage.java
com.fima.cardsui.views.CardUI.java
com.fima.cardsui.views.QuickReturnListView.java