Guest User

Untitled

a guest
Jun 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.30 KB | None | 0 0
  1. package com.android.systemui.statusbar.powercontrols;
  2.  
  3. import android.content.BroadcastReceiver;
  4. import android.content.ContentResolver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.content.res.Resources;
  9. import android.database.ContentObserver;
  10. import android.net.Uri;
  11. import android.net.wimax.WimaxHelper;
  12. import android.os.Handler;
  13. import android.provider.Settings;
  14. import android.util.AttributeSet;
  15. import android.util.Log;
  16. import android.view.Gravity;
  17. import android.view.LayoutInflater;
  18. import android.view.View;
  19. import android.widget.FrameLayout;
  20. import android.widget.HorizontalScrollView;
  21. import android.widget.LinearLayout;
  22. import android.view.ViewGroup;
  23.  
  24. import com.android.systemui.R;
  25. import com.android.systemui.statusbar.powercontrols.PowerControls;
  26. import com.android.systemui.statusbar.powercontrols.AutoRotationSettingButton;
  27. import com.android.systemui.statusbar.powercontrols.BluetoothSettingButton;
  28. import com.android.systemui.statusbar.powercontrols.GpsSettingButton;
  29. import com.android.systemui.statusbar.powercontrols.LteDataSettingButton;
  30. import com.android.systemui.statusbar.powercontrols.MobileDataSettingButton;
  31. import com.android.systemui.statusbar.powercontrols.SoundSettingButton;
  32. import com.android.systemui.statusbar.powercontrols.WifiSettingButton;
  33.  
  34.  
  35. import java.util.ArrayList;
  36. import java.util.HashMap;
  37.  
  38. public class PowerControlsView extends FrameLayout {
  39.  
  40. protected static final String TAG = "PowerControlsView";
  41.  
  42. //setup different toggles
  43. private AutoRotationSettingButton mRotateButton;
  44. private BluetoothSettingButton mBluetoothButton;
  45. private GpsSettingButton mGPSButton;
  46. private LteDataSettingButton mLTEButton;
  47. private MobileDataSettingButton mDataButton;
  48. private SoundSettingButton mSoundButton;
  49. private WifiSettingButton mWifiButton;
  50.  
  51. //set int for the toggles
  52. private static final int ROTATE = 1;
  53. private static final int BLUETOOTH = 2;
  54. private static final int GPS = 3;
  55. private static final int LTE = 4;
  56. private static final int DATA = 5;
  57. private static final int SOUND = 6;
  58. private static final int WIFI = 7;
  59.  
  60. //set imageview's for each toggle icon and status
  61. private ImageView pcIcon1;
  62. private ImageView pcStatus1;
  63. private ImageView pcIcon2;
  64. private ImageView pcStatus2;
  65. private ImageView pcIcon3;
  66. private ImageView pcStatus3;
  67. private ImageView pcIcon4;
  68. private ImageView pcStatus4;
  69. private ImageView pcIcon5;
  70. private ImageView pcStatus5;
  71. private ImageView pcIcon6;
  72. private ImageView pcStatus6;
  73.  
  74. //set the ids
  75. protected int idIcon1 = R.id.pc_icon1;
  76. protected int idStats1 = R.id.pc_status1;
  77. protected int idIcon2 = R.id.pc_icon2;
  78. protected int idStats2 = R.id.pc_status2;
  79. protected int idIcon3 = R.id.pc_icon3;
  80. protected int idStats3 = R.id.pc_status3;
  81. protected int idIcon4 = R.id.pc_icon4;
  82. protected int idStats4 = R.id.pc_status4;
  83. protected int idIcon5 = R.id.pc_icon5;
  84. protected int idStats5 = R.id.pc_status5;
  85. protected int idIcon6 = R.id.pc_icon6;
  86. protected int idStats6 = R.id.pc_status6;
  87.  
  88. //toggle choice crossover from gummy settings
  89. private int mToggle1 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_ONE, WIFI);
  90. private int mToggle2 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_TWO, BLUETOOTH);
  91. private int mToggle3 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_THREE, GPS);
  92. private int mToggle4 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_FOUR, DATA);
  93. private int mToggle5 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_FIVE, SOUND);
  94. private int mToggle6 = Settings.System.getInt(mContext.getContentResolver(), Settings.System.TOGGLE_SIX, ROTATE);
  95.  
  96. //will impliment a scrollview later for more than 6 icons
  97. private HorizontalScrollView mScrollView;
  98.  
  99. //view needs to be setup to switch views between imageviews
  100. protected View mView;
  101.  
  102. //now we begin making our uber leet toggles - just for you rob
  103. public PowerControlsView(Context paramContext, AttributeSet paramAttributeSet) {
  104. super(paramContext, paramAttributeSet);
  105.  
  106. buildToggles();
  107. }
  108.  
  109. public void buildToggles() {
  110. updateToggle1(pcIcon1, pcStatus1, idIcon1, idStats1, mToggle1);
  111. toggleType(mToggle1);
  112. updateToggle1(pcIcon2, pcStatus2, idIcon2, idStats2, mToggle2);
  113. toggleType(mToggle2);
  114. updateToggle1(pcIcon3, pcStatus3, idIcon3, idStats3, mToggle3);
  115. toggleType(mToggle3);
  116. updateToggle1(pcIcon4, pcStatus4, idIcon4, idStats4, mToggle4);
  117. toggleType(mToggle4);
  118. updateToggle1(pcIcon5, pcStatus5, idIcon5, idStats5, mToggle5);
  119. toggleType(mToggle5);
  120. updateToggle1(pcIcon6, pcStatus6, idIcon6, idStats6, mToggle6);
  121. toggleType(mToggle6);
  122. }
  123.  
  124. public void toggleType(int type) {
  125. switch (type)
  126. case WIFI:
  127. mWifiButton = new WifiSettingButton();
  128. break;
  129. case BLUETOOTH:
  130. mBluetoothButton = new BluetoothSettingButton();
  131. break;
  132. case GPS:
  133. mGPSButton = new GpsSettingButton();
  134. break;
  135. case LTE:
  136. mLTEButton = new LteDataSettingButton();
  137. break;
  138. case DATA:
  139. mDataButton = new MobileDataSettingButton();
  140. break;
  141. case SOUND:
  142. mSoundButton = new SoundSettingButton();
  143. break;
  144. case ROTATE:
  145. mRotateButton = new AutoRotationSettingButton();
  146. break;
  147. }
  148.  
  149. private void updateToggle(ImageView one, ImageView two, int id1, int id2, int toggle) {
  150. one = (ImageView) mView.findViewById(id1);
  151. two = (ImageView) mView.findViewById(id2);
  152. PowerControls.getStatusIcon(toggle);
  153. PowerControls.getIcons(toggle);
  154. one.setImageResource(mIcon);
  155. two.setImageResource(mStatus);
  156. }
  157.  
  158. protected void onFinishInflate() {
  159. super.onFinishInflate();
  160. }
  161. }
Add Comment
Please, Sign In to add comment