Commits

Anonymous committed 709c415

Use ActionBar for MusicFX, adjust text sizes

b/5447177

Change-Id: If8042879dd0f13d4747a7fbc9247cefa0fa60155

  • Participants
  • Parent commits 1ddd9c9

Comments (0)

Files changed (5)

File AndroidManifest.xml

         <activity
             android:name=".ActivityMusic"
             android:theme="@android:style/Theme.Holo"
-            android:label="@string/app_name">
+            android:label="@string/eq_dialog_title">
             <intent-filter>
                 <action
                     android:name="android.media.action.DISPLAY_AUDIO_EFFECT_CONTROL_PANEL" />

File res/layout-land/music_main.xml

         android:layout_weight="1"
         android:visibility="gone" />
 
-    <RelativeLayout
-        android:id="@+id/mainToggleEffectsLayout"
-        android:layout_width="match_parent"
-        android:layout_height="50dip"
-        android:background="#999"
-        android:gravity="center_vertical"
-        android:paddingRight="4dip">
-        <TextView
-            android:id="@+id/mainToggleEffectsTitleTextView"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginLeft="15dip"
-            android:layout_alignParentLeft="true"
-            android:textAppearance="?android:attr/textAppearanceLarge"
-            android:text="@string/eq_dialog_title" />
-        <Switch
-            android:id="@+id/mainToggleEffectsCheckBox"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentRight="true" />
-    </RelativeLayout>
-
     <FrameLayout
         android:id="@+id/contentSoundEffects"
         android:layout_width="match_parent"

File res/layout/music_main.xml

         android:layout_weight="1"
         android:visibility="gone" />
 
-    <RelativeLayout
-        android:id="@+id/mainToggleEffectsLayout"
-        android:layout_width="match_parent"
-        android:layout_height="50dip"
-        android:background="#999"
-        android:gravity="center_vertical"
-        android:paddingRight="4dip">
-        <TextView
-            android:id="@+id/mainToggleEffectsTitleTextView"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginLeft="15dip"
-            android:layout_alignParentLeft="true"
-            android:textAppearance="?android:attr/textAppearanceLarge"
-            android:text="@string/eq_dialog_title" />
-        <Switch
-            android:id="@+id/mainToggleEffectsCheckBox"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentRight="true" />
-    </RelativeLayout>
-
     <ScrollView
         android:id="@+id/contentSoundEffects"
         android:orientation="vertical"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:textAppearance="?android:attr/textAppearanceLarge"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
                     android:ellipsize="marquee"
                     android:fadingEdge="horizontal"
                     android:text="@string/bass_boost_strength" />
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:layout_weight="1"
-                    android:textAppearance="?android:attr/textAppearanceLarge"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
                     android:ellipsize="marquee"
                     android:fadingEdge="horizontal"
                     android:text="@string/virtualizer_strength" />

File res/values/dimens.xml

 <resources>
     <dimen name="eq_slider_margin">5dip</dimen>
     <dimen name="eq_slider_height">180dip</dimen>
+    <dimen name="action_bar_switch_padding">16dip</dimen>
 </resources>

File src/com/android/musicfx/ActivityMusic.java

 import com.android.musicfx.seekbar.SeekBar;
 import com.android.musicfx.seekbar.SeekBar.OnSeekBarChangeListener;
 
+import android.app.ActionBar;
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.widget.ListView;
 import android.widget.RelativeLayout;
 import android.widget.Spinner;
+import android.widget.Switch;
 import android.widget.TextView;
 import android.widget.Toast;
 
     private int mPRPresetPrevious;
 
     private boolean mIsHeadsetOn = false;
+    private CompoundButton mToggleSwitch;
 
     private StringBuilder mFormatBuilder = new StringBuilder();
     private Formatter mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());
 
         setContentView(R.layout.music_main);
         final ViewGroup viewGroup = (ViewGroup) findViewById(R.id.contentSoundEffects);
-        final View mainToggleView = findViewById(R.id.mainToggleEffectsLayout);
 
         // Fill array with presets from AudioEffects call.
         // allocate a space for 2 extra strings (CI Extreme & User)
             // Set the listener for the main enhancements toggle button.
             // Depending on the state enable the supported effects if they were
             // checked in the setup tab.
-            final CompoundButton toggleEffects = (CompoundButton) findViewById(R.id.mainToggleEffectsCheckBox);
-            toggleEffects.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+            mToggleSwitch = new Switch(this);
+            mToggleSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                 @Override
                 public void onCheckedChanged(final CompoundButton buttonView,
                         final boolean isChecked) {
                 }
             });
 
-            mainToggleView.setVisibility(View.VISIBLE);
-
             // Initialize the Virtualizer elements.
             // Set the SeekBar listener.
             if (mVirtualizerSupported) {
 
         } else {
             viewGroup.setVisibility(View.GONE);
-            mainToggleView.setVisibility(View.GONE);
             ((TextView) findViewById(R.id.noEffectsTextView)).setVisibility(View.VISIBLE);
         }
 
-        // TODO, actually use the action bar
-        getActionBar().hide();
+        ActionBar ab = getActionBar();
+        final int padding = getResources().getDimensionPixelSize(
+                R.dimen.action_bar_switch_padding);
+        mToggleSwitch.setPadding(0,0, padding, 0);
+        ab.setCustomView(mToggleSwitch, new ActionBar.LayoutParams(
+                ActionBar.LayoutParams.WRAP_CONTENT,
+                ActionBar.LayoutParams.WRAP_CONTENT,
+                Gravity.CENTER_VERTICAL | Gravity.RIGHT));
+        ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);
     }
 
     /*
     private void updateUI() {
         final boolean isEnabled = ControlPanelEffect.getParameterBoolean(mContext,
                 mCallingPackageName, mAudioSession, ControlPanelEffect.Key.global_enabled);
-        ((CompoundButton) findViewById(R.id.mainToggleEffectsCheckBox)).setChecked(isEnabled);
+        mToggleSwitch.setChecked(isEnabled);
         setEnabledAllChildren((ViewGroup) findViewById(R.id.contentSoundEffects), isEnabled);
         updateUIHeadset();
 
      * control/events.
      */
     private void updateUIHeadset() {
-        if (((CompoundButton) findViewById(R.id.mainToggleEffectsCheckBox)).isChecked()) {
+        if (mToggleSwitch.isChecked()) {
             ((TextView) findViewById(R.id.vIStrengthText)).setEnabled(mIsHeadsetOn);
             ((SeekBar) findViewById(R.id.vIStrengthSeekBar)).setEnabled(mIsHeadsetOn);
             findViewById(R.id.vILayout).setEnabled(!mIsHeadsetOn);