Skip to content

Commit

Permalink
Header Image: Add option to hide in landscape
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed May 2, 2023
1 parent d2eab87 commit 0c6b204
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_ALPHA;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_HEIGHT;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_LANDSCAPE_SWITCH;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_SWITCH;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_ZOOMTOFIT;

Expand Down Expand Up @@ -114,6 +115,13 @@ public void onStopTrackingTouch(SeekBar seekBar) {
enable_zoom_to_fit.setOnCheckedChangeListener((buttonView, isChecked) -> {
RPrefs.putBoolean(HEADER_IMAGE_ZOOMTOFIT, isChecked);
});

// Header image hide in landscape
@SuppressLint("UseSwitchCompatOrMaterialCode") Switch enable_hide_image_landscape = findViewById(R.id.enable_hide_image_landscape);
enable_hide_image_landscape.setChecked(RPrefs.getBoolean(HEADER_IMAGE_LANDSCAPE_SWITCH, true));
enable_hide_image_landscape.setOnCheckedChangeListener((buttonView, isChecked) -> {
RPrefs.putBoolean(HEADER_IMAGE_LANDSCAPE_SWITCH, isChecked);
});
}

public void browseHeaderImage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.drdisagree.iconify.common.Const.SYSTEMUI_PACKAGE;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_ALPHA;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_HEIGHT;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_LANDSCAPE_SWITCH;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_SWITCH;
import static com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_ZOOMTOFIT;
import static com.drdisagree.iconify.config.XPrefs.Xprefs;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class HeaderImage extends ModPack implements IXposedHookLoadPackage {
int imageHeight = 140;
int headerImageAlpha = 100;
boolean zoomToFit = false;
boolean hideLandscapeHeaderImage = true;
private Object lpparamCustom = null;
LinearLayout mQsHeaderLayout = null;
ImageView mQsHeaderImageView = null;
Expand All @@ -64,8 +66,9 @@ public void updatePrefs(String... Key) {
headerImageAlpha = Xprefs.getInt(HEADER_IMAGE_ALPHA, 100);
imageHeight = Xprefs.getInt(HEADER_IMAGE_HEIGHT, 140);
zoomToFit = Xprefs.getBoolean(HEADER_IMAGE_ZOOMTOFIT, false);
hideLandscapeHeaderImage = Xprefs.getBoolean(HEADER_IMAGE_LANDSCAPE_SWITCH, true);

if (Key.length > 0 && (Objects.equals(Key[0], HEADER_IMAGE_SWITCH) || Objects.equals(Key[0], HEADER_IMAGE_ALPHA) || Objects.equals(Key[0], HEADER_IMAGE_HEIGHT) || Objects.equals(Key[0], HEADER_IMAGE_ZOOMTOFIT))) {
if (Key.length > 0 && (Objects.equals(Key[0], HEADER_IMAGE_SWITCH) || Objects.equals(Key[0], HEADER_IMAGE_LANDSCAPE_SWITCH) || Objects.equals(Key[0], HEADER_IMAGE_ALPHA) || Objects.equals(Key[0], HEADER_IMAGE_HEIGHT) || Objects.equals(Key[0], HEADER_IMAGE_ZOOMTOFIT))) {
if (lpparamCustom != null) {
callMethod(lpparamCustom, "updateResources");
}
Expand Down Expand Up @@ -123,7 +126,9 @@ private void updateQSHeaderImage() {
mQsHeaderLayout.setVisibility(View.VISIBLE);
mQsHeaderLayout.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, imageHeight, mContext.getResources().getDisplayMetrics());
} else {
mQsHeaderLayout.setVisibility(View.GONE);
if (hideLandscapeHeaderImage) {
mQsHeaderLayout.setVisibility(View.GONE);
}
}
}

Expand Down
46 changes: 45 additions & 1 deletion app/src/main/res/layout/activity_xposed_header_image.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/container_bottom"
android:background="@drawable/container_mid"
android:orientation="horizontal"
android:paddingStart="@dimen/container_paddingSide"
android:paddingTop="@dimen/container_padding"
Expand Down Expand Up @@ -200,6 +200,50 @@
tools:ignore="UseSwitchCompatOrMaterialXml" />

</LinearLayout>

<View style="@style/dividerTransparent" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/container_bottom"
android:orientation="horizontal"
android:paddingStart="@dimen/container_paddingSide"
android:paddingTop="@dimen/container_padding"
android:paddingEnd="@dimen/container_paddingSide"
android:paddingBottom="@dimen/container_padding">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start|center"
android:layout_marginEnd="@dimen/container_padding"
android:layout_weight="1.0"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/header_image_hide_in_landscape_title"
android:textColor="@color/textColorPrimary"
android:textSize="@dimen/cont_title_size"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/header_image_hide_in_landscape_desc"
android:textColor="@color/textColorSecondary"
android:textSize="@dimen/cont_desc_size" />

</LinearLayout>

<Switch
android:id="@+id/enable_hide_image_landscape"
style="@style/customSwitch"
tools:ignore="UseSwitchCompatOrMaterialXml" />

</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
Expand Down

0 comments on commit 0c6b204

Please sign in to comment.