Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.PowerControls;
- 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;
- //set imageview's for each toggle icon and status
- private ImageView pcIcon1;
- private ImageView pcStatus1;
- private ImageView pcIcon2;
- private ImageView pcStatus2;
- private ImageView pcIcon3;
- private ImageView pcStatus3;
- private ImageView pcIcon4;
- private ImageView pcStatus4;
- private ImageView pcIcon5;
- private ImageView pcStatus5;
- private ImageView pcIcon6;
- private ImageView pcStatus6;
- //set the ids
- protected int idIcon1 = R.id.pc_icon1;
- protected int idStats1 = R.id.pc_status1;
- protected int idIcon2 = R.id.pc_icon2;
- protected int idStats2 = R.id.pc_status2;
- protected int idIcon3 = R.id.pc_icon3;
- protected int idStats3 = R.id.pc_status3;
- protected int idIcon4 = R.id.pc_icon4;
- protected int idStats4 = R.id.pc_status4;
- protected int idIcon5 = R.id.pc_icon5;
- protected int idStats5 = R.id.pc_status5;
- protected int idIcon6 = R.id.pc_icon6;
- protected int idStats6 = R.id.pc_status6;
- //toggle choice crossover from gummy settings
- private int mToggle1 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_ONE, WIFI);
- private int mToggle2 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_TWO, BLUETOOTH);
- private int mToggle3 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_THREE, GPS);
- private int mToggle4 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_FOUR, DATA);
- private int mToggle5 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_FIVE, SOUND);
- private int mToggle6 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_SIX, ROTATE);
- //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;
- //now we begin making our uber leet toggles - just for you rob
- public PowerControlsView(Context paramContext, AttributeSet paramAttributeSet) {
- super(paramContext, paramAttributeSet);
- buildToggles();
- }
- public void buildToggles() {
- updateToggle1(pcIcon1, pcStatus1, idIcon1, idStats1, mToggle1);
- toggleType(mToggle1);
- updateToggle1(pcIcon2, pcStatus2, idIcon2, idStats2, mToggle2);
- toggleType(mToggle2);
- updateToggle1(pcIcon3, pcStatus3, idIcon3, idStats3, mToggle3);
- toggleType(mToggle3);
- updateToggle1(pcIcon4, pcStatus4, idIcon4, idStats4, mToggle4);
- toggleType(mToggle4);
- updateToggle1(pcIcon5, pcStatus5, idIcon5, idStats5, mToggle5);
- toggleType(mToggle5);
- updateToggle1(pcIcon6, pcStatus6, idIcon6, idStats6, mToggle6);
- toggleType(mToggle6);
- }
- 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;
- }
- private void updateToggle(ImageView one, ImageView two, int id1, int id2, int toggle) {
- one = (ImageView) mView.findViewById(id1);
- two = (ImageView) mView.findViewById(id2);
- PowerControls.getStatusIcon(toggle);
- PowerControls.getIcons(toggle);
- one.setImageResource(mIcon);
- two.setImageResource(mStatus);
- }
- protected void onFinishInflate() {
- super.onFinishInflate();
- }
- }
Add Comment
Please, Sign In to add comment