Skip to content

Instantly share code, notes, and snippets.

@moskowite
Created February 14, 2012 22:27
Show Gist options
  • Select an option

  • Save moskowite/1831067 to your computer and use it in GitHub Desktop.

Select an option

Save moskowite/1831067 to your computer and use it in GitHub Desktop.
package com.android.systemui.statusbar.powercontrols;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.net.Uri;
import android.net.wimax.WimaxHelper;
import android.os.Handler;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.view.ViewGroup;
import com.android.systemui.R;
import com.android.systemui.statusbar.powercontrols.AutoRotationSettingButton;
import com.android.systemui.statusbar.powercontrols.BluetoothSettingButton;
import com.android.systemui.statusbar.powercontrols.GpsSettingButton;
import com.android.systemui.statusbar.powercontrols.LteDataSettingButton;
import com.android.systemui.statusbar.powercontrols.MobileDataSettingButton;
import com.android.systemui.statusbar.powercontrols.SoundSettingButton;
import com.android.systemui.statusbar.powercontrols.WifiSettingButton;
import java.util.ArrayList;
import java.util.HashMap;
public class PowerControlsView extends FrameLayout {
protected static final String TAG = "PowerControlsView";
//setup different toggles
private AutoRotationSettingButton mRotateButton;
private BluetoothSettingButton mBluetoothButton;
private GpsSettingButton mGPSButton;
private LteDataSettingButton mLTEButton;
private MobileDataSettingButton mDataButton;
private SoundSettingButton mSoundButton;
private WifiSettingButton mWifiButton;
//set int for the toggles
private static final int ROTATE = 1;
private static final int BLUETOOTH = 2;
private static final int GPS = 3;
private static final int LTE = 4;
private static final int DATA = 5;
private static final int SOUND = 6;
private static final int WIFI = 7;
//toggle choice crossover from gummy settings
private int[] mToggleArray = { mToggle1,
mToggle2,
mToggle3,
mToggle4,
mToggle5,
mToggle6 };
//will impliment a scrollview later for more than 6 icons
private HorizontalScrollView mScrollView;
//view needs to be setup to switch views between imageviews
protected View mView;
public PowerControlsView(Context paramContext, AttributeSet paramAttributeSet) {
super(paramContext, paramAttributeSet);
mToggleArray[0] = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_ONE, ROTATE);
mToggleArray[1] = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_TWO, BLUETOOTH);
mToggleArray[2] = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_THREE, GPS);
mToggleArray[3] = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_FOUR, LTE);
mToggleArray[4] = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_FIVE, DATA);
mToggleArray[5] = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_SIX, SOUND);
mToggleArray[6] = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_SEVEN, WIFI);
buildToggles();
}
public void buildToggles() {
for(int i = 0; i < mToggleArray.length(); i++){
Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_ONE, WIFI);
if(mToggleArray[i] != null){
toggleType(mToggleArray[i]);
}
}
}
public void toggleType(int type) {
switch (type)
case WIFI:
mWifiButton = new WifiSettingButton();
break;
case BLUETOOTH:
mBluetoothButton = new BluetoothSettingButton();
break;
case GPS:
mGPSButton = new GpsSettingButton ();
break;
case LTE:
mLTEButton = new LteDataSettingButton();
break;
case DATA:
mDataButton = new MobileDataSettingButton();
break;
case SOUND:
mSoundButton = new SoundSettingButton();
break;
case ROTATE:
mRotateButton = new AutoRotationSettingButton();
break;
}
protected void onFinishInflate() {
super.onFinishInflate();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment