Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e683e978 authored by Roman Birg's avatar Roman Birg
Browse files

Settings: profiles: fix volume streams override behavior



Before we would always assume to override the stream, but that is not
always the case. Add a checkbox to turn the override on and off.

Change-Id: Ic1a58d59a9e514d4c2ccf376191ac7989bbead26
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent af8ddc61
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -14,8 +14,21 @@
     limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical"
              android:gravity="center_horizontal">

    <CheckBox
            android:id="@+id/checkbox"
            android:text="@string/profile_volume_override_checkbox_label"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="20dip" />

    <SeekBar android:id="@+id/seekbar"
             android:layout_width="match_parent"
              android:layout_height="match_parent">
             android:layout_height="wrap_content"
             android:padding="20dip" />

</LinearLayout>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@
    <string name="connection_state_disabled">Disable</string>
    <string name="connection_state_enabled">Enable</string>
    <string name="volume_override_summary">Set to %1$s/%2$s</string>
    <string name="volume_override_summary_no_override">Do not override</string>
    <string name="profile_volume_override_checkbox_label">Override volume</string>

    <!-- Menu item for managing profiles -->
    <string name="profile_profiles_manage">Profiles</string>
+17 −4
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SeekBar;
@@ -479,10 +481,22 @@ public class SetupActionsFragment extends SettingsPreferenceFragment

        final AudioManager am = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
        final LayoutInflater inflater = LayoutInflater.from(getActivity());
        final View view = inflater.inflate(com.android.internal.R.layout.seekbar_dialog, null);
        final SeekBar seekBar = (SeekBar) view.findViewById(com.android.internal.R.id.seekbar);
        final View view = inflater.inflate(R.layout.dialog_profiles_volume_override, null);
        final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
        final CheckBox override = (CheckBox) view.findViewById(R.id.checkbox);
        override.setChecked(streamSettings.isOverride());
        override.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                streamSettings.setOverride(isChecked);
                seekBar.setEnabled(isChecked);

        view.findViewById(android.R.id.icon).setVisibility(View.GONE);
                mProfile.setStreamSettings(streamSettings);
                mAdapter.notifyDataSetChanged();
                updateProfile();
            }
        });
        seekBar.setEnabled(streamSettings.isOverride());
        seekBar.setMax(am.getStreamMaxVolume(streamId));
        seekBar.setProgress(streamSettings.getValue());
        builder.setView(view);
@@ -490,7 +504,6 @@ public class SetupActionsFragment extends SettingsPreferenceFragment
            @Override
            public void onClick(DialogInterface dialog, int which) {
                int value = seekBar.getProgress();
                streamSettings.setOverride(true);
                streamSettings.setValue(value);
                mProfile.setStreamSettings(streamSettings);
                mAdapter.notifyDataSetChanged();
+6 −2
Original line number Diff line number Diff line
@@ -64,8 +64,12 @@ public class VolumeStreamItem implements Item {
        TextView desc = (TextView) view.findViewById(R.id.summary);
        int denominator = mStreamSettings.getValue();
        int numerator = am.getStreamMaxVolume(mStreamId);
        if (mStreamSettings.isOverride()) {
            desc.setText(context.getResources().getString(R.string.volume_override_summary,
                    denominator, numerator));
        } else {
            desc.setText(context.getString(R.string.volume_override_summary_no_override));
        }

        return view;
    }