Skip to content

Commit

Permalink
Background Chip: Bring back status icons chip for A13
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed Sep 14, 2023
1 parent e0a8536 commit 384b2c3
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ protected void onCreate(Bundle savedInstanceState) {
updateColorPreview();

// Status icons chip
if (Build.VERSION.SDK_INT >= 33) {
binding.statusiconsChipContainer.setVisibility(View.GONE);
RPrefs.putBoolean(QSPANEL_STATUSICONSBG_SWITCH, false);
}

binding.enableStatusIconsChip.setChecked(RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false));
binding.enableStatusIconsChip.setOnCheckedChangeListener((buttonView, isChecked) -> {
RPrefs.putBoolean(QSPANEL_STATUSICONSBG_SWITCH, isChecked);
new Handler(Looper.getMainLooper()).postDelayed(() -> {
OverlayUtil.enableOverlay("IconifyComponentIXCC.overlay");
SystemUtil.doubleToggleDarkMode();

if (Build.VERSION.SDK_INT >= 33) {
SystemUtil.handleSystemUIRestart();
} else {
SystemUtil.doubleToggleDarkMode();
}
}, SWITCH_ANIMATION_DELAY);
});
binding.statusIconsChip.setOnClickListener(v -> binding.enableStatusIconsChip.toggle());
Expand Down Expand Up @@ -177,7 +177,7 @@ private void addItemStatusIcons(ArrayList<Object[]> pack) {
list.setOnClickListener(v -> {
RPrefs.putInt(CHIP_QSSTATUSICONS_STYLE, finalI);
refreshBackgroundStatusIcons();
if (RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false)) {
if (RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false) && Build.VERSION.SDK_INT < 33) {
new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static com.drdisagree.iconify.common.Preferences.HIDE_LOCKSCREEN_STATUSBAR;
import static com.drdisagree.iconify.common.Preferences.HIDE_STATUS_ICONS_SWITCH;
import static com.drdisagree.iconify.common.Preferences.QSPANEL_HIDE_CARRIER;
import static com.drdisagree.iconify.common.Preferences.QSPANEL_STATUSICONSBG_SWITCH;

import android.annotation.SuppressLint;
import android.os.Build;
Expand Down Expand Up @@ -89,24 +90,34 @@ protected void onCreate(Bundle savedInstanceState) {

// Fixed status icons
if (Build.VERSION.SDK_INT >= 33) {
binding.statusIconsContainer.setVisibility(View.GONE);
binding.enableFixedStatusIconsContainer.setVisibility(View.GONE);
((View) binding.statusIconsSideMarginSeekbar.getParent()).setVisibility(View.GONE);
RPrefs.putBoolean(FIXED_STATUS_ICONS_SWITCH, false);
}

binding.enableFixedStatusIcons.setChecked(RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false));
binding.enableFixedStatusIcons.setOnCheckedChangeListener((buttonView, isChecked) -> {
RPrefs.putBoolean(FIXED_STATUS_ICONS_SWITCH, isChecked);
if (!isChecked) FabricatedUtil.disableOverlay("quickQsOffsetHeight");
else if (RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0) > 32)
FabricatedUtil.buildAndEnableOverlay(FRAMEWORK_PACKAGE, "quickQsOffsetHeight", "dimen", "quick_qs_offset_height", (48 + RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0)) + "dp");
else if (RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8) > 32)
FabricatedUtil.buildAndEnableOverlay(FRAMEWORK_PACKAGE, "quickQsOffsetHeight", "dimen", "quick_qs_offset_height", (48 + RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8)) + "dp");

new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY);
new Handler(Looper.getMainLooper()).postDelayed(() -> {
if (Build.VERSION.SDK_INT >= 33) {
SystemUtil.handleSystemUIRestart();
} else {
SystemUtil.doubleToggleDarkMode();
}
}, SWITCH_ANIMATION_DELAY);
});
binding.enableFixedStatusIconsContainer.setOnClickListener(v -> binding.enableFixedStatusIcons.toggle());

// Status icons top margin
binding.statusIconsTopMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0) + "dp");
binding.statusIconsTopMarginSeekbar.setValue(RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0));
final int[] topMarginStatusIcons = {RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0)};
binding.statusIconsTopMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8) + "dp");
binding.statusIconsTopMarginSeekbar.setValue(RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8));
binding.statusIconsTopMarginSeekbar.setEnabled(Build.VERSION.SDK_INT >= 33 ? RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false) : RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false));
if (Build.VERSION.SDK_INT >= 33) binding.statusIconsTopMarginSeekbar.setValueTo(200);
final int[] topMarginStatusIcons = {RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8)};
binding.statusIconsTopMarginSeekbar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() {
@Override
public void onStartTrackingTouch(@NonNull Slider slider) {
Expand All @@ -117,16 +128,20 @@ public void onStopTrackingTouch(@NonNull Slider slider) {
topMarginStatusIcons[0] = (int) slider.getValue();
binding.statusIconsTopMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + topMarginStatusIcons[0] + "dp");
RPrefs.putInt(FIXED_STATUS_ICONS_TOPMARGIN, topMarginStatusIcons[0]);
if (RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false)) {
FabricatedUtil.buildAndEnableOverlay(FRAMEWORK_PACKAGE, "quickQsOffsetHeight", "dimen", "quick_qs_offset_height", (48 + topMarginStatusIcons[0]) + "dp");
new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY);
if (Build.VERSION.SDK_INT >= 33 ? RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false) : RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false)) {
if (Build.VERSION.SDK_INT < 33) {
FabricatedUtil.buildAndEnableOverlay(FRAMEWORK_PACKAGE, "quickQsOffsetHeight", "dimen", "quick_qs_offset_height", (40 + topMarginStatusIcons[0]) + "dp");

new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY);
}
}
}
});

// Status icons side margin
binding.statusIconsSideMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + RPrefs.getInt(FIXED_STATUS_ICONS_SIDEMARGIN, 0) + "dp");
binding.statusIconsSideMarginSeekbar.setValue(RPrefs.getInt(FIXED_STATUS_ICONS_SIDEMARGIN, 0));
binding.statusIconsSideMarginSeekbar.setEnabled(RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false));
final int[] sideMarginStatusIcons = {RPrefs.getInt(FIXED_STATUS_ICONS_SIDEMARGIN, 0)};
binding.statusIconsSideMarginSeekbar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() {
@Override
Expand All @@ -139,7 +154,13 @@ public void onStopTrackingTouch(@NonNull Slider slider) {
binding.statusIconsSideMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + sideMarginStatusIcons[0] + "dp");
RPrefs.putInt(FIXED_STATUS_ICONS_SIDEMARGIN, sideMarginStatusIcons[0]);
if (RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false)) {
new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY);
new Handler(Looper.getMainLooper()).postDelayed(() -> {
if (Build.VERSION.SDK_INT >= 33) {
SystemUtil.handleSystemUIRestart();
} else {
SystemUtil.doubleToggleDarkMode();
}
}, SWITCH_ANIMATION_DELAY);
}
}
});
Expand Down
Loading

0 comments on commit 384b2c3

Please sign in to comment.