Skip to content

Commit

Permalink
fix: auto brightness range
Browse files Browse the repository at this point in the history
  • Loading branch information
MonwF committed Jul 21, 2022
1 parent 383e1bf commit 65fff24
Show file tree
Hide file tree
Showing 8 changed files with 1,818 additions and 1,873 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public void handleLoadPackage(final LoadPackageParam lpparam) {
if (mPrefs.getBoolean("system_notifafterunlock")) System.ShowNotificationsAfterUnlockHook(lpparam);
if (mPrefs.getBoolean("system_notifrowmenu")) System.NotificationRowMenuHook(lpparam);
if (mPrefs.getBoolean("system_compactnotif")) System.CompactNotificationsHook(lpparam);
if (mPrefs.getBoolean("system_removecleaner")) System.HideMemoryCleanHook(lpparam, false);
// if (mPrefs.getBoolean("system_removecleaner")) System.HideMemoryCleanHook(lpparam, false);
if (mPrefs.getBoolean("system_removedismiss")) System.HideDismissViewHook(lpparam);
if (mPrefs.getBoolean("controls_nonavbar")) Controls.HideNavBarHook(lpparam);
if (mPrefs.getBoolean("controls_imebackalticon")) Controls.ImeBackAltIconHook(lpparam);
Expand Down
3,368 changes: 1,672 additions & 1,696 deletions app/src/main/java/name/mikanoshi/customiuizer/mods/Launcher.java

Large diffs are not rendered by default.

243 changes: 101 additions & 142 deletions app/src/main/java/name/mikanoshi/customiuizer/mods/System.java

Large diffs are not rendered by default.

60 changes: 37 additions & 23 deletions app/src/main/java/name/mikanoshi/customiuizer/utils/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -1993,39 +1993,53 @@ public static Bitmap fastBlur(Bitmap sentBitmap, int radius) {
return bitmap;
}

private static float norm(float f, float f2, float f3) {
return (f3 - f) / (f2 - f);
public static int constrain(int amount, int low, int high) {
return amount < low ? low : (amount > high ? high : amount);
}

private static float lerp(float f, float f2, float f3) {
return ((f2 - f) * f3) + f;
public static float constrain(float amount, float low, float high) {
return amount < low ? low : (amount > high ? high : amount);
}
public static float lerp(float start, float stop, float amount) {
return start + (stop - start) * amount;
}
public static float lerp(int start, int stop, float amount) {
return lerp((float) start, (float) stop, amount);
}

/**
* Returns the interpolation scalar (s) that satisfies the equation: {@code value = }{@link
* #lerp}{@code (a, b, s)}
*
* <p>If {@code a == b}, then this function will return 0.
*/
public static float lerpInv(float a, float b, float value) {
return a != b ? ((value - a) / (b - a)) : 0.0f;
}
/** Returns the single argument constrained between [0.0, 1.0]. */
public static float saturate(float value) {
return constrain(value, 0.0f, 1.0f);
}
/** Returns the saturated (constrained between [0, 1]) result of {@link #lerpInv}. */
public static float lerpInvSat(float a, float b, float value) {
return saturate(lerpInv(a, b, value));
}
public static float norm(float start, float stop, float value) {
return (value - start) / (stop - start);
}
private static float sq(float f) {
return f * f;
}

public static float exp(float f) {
return (float)Math.exp(f);
}

public static float sqrt(float f) {
return (float)Math.sqrt(f);
}

public static float log(float f) {
return (float)Math.log(f);
}

public static int convertGammaToLinear(int val, int min, int max) {
float norm = norm(0.0f, (float)max, (float) val);
val = Math.round(lerp((float) min, (float) max, (norm <= 0.2f ? sq(norm / 0.2f) : exp((norm - 0.221f) / 0.314f) + 0.06f) / 12.0f));
return Math.min(val, max);
}

public static int convertLinearToGamma(int val, int min, int max) {
float norm = norm((float) min, (float)max, (float)val) * 12.0f;
return Math.round(lerp(0.0f, (float)max, norm <= 1.0f ? sqrt(norm) * 0.2f : (log(norm - 0.06f) * 0.314f) + 0.221f));
public static final float convertGammaToLinearFloat(float i, int max, float f, float f2) {
float norm = norm(0.0f, max, i);
float R = 0.4f;
float A = 0.2146f;
float B = 0.2847f;
float C = 0.4719f;
return lerp(f, f2, constrain(norm <= R ? sq(norm / R) : exp((norm - C) / A) + B, 0.0f, 12.0f) / 12.0f);
}

}
2 changes: 0 additions & 2 deletions app/src/main/res/values-ru-rRU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,6 @@
<string name="system_autobrightness_summ">Задаёт минимальное и максимальное значение яркости в автоматическом режиме</string>
<string name="system_minbrightness_title">Минимальная автояркость</string>
<string name="system_maxbrightness_title">Максимальная автояркость</string>
<string name="system_autobrightness_hlg_title">Всегда использовать нелинейную шкалу</string>
<string name="system_autobrightness_hlg_summ">Включить, если проценты яркости в моде не совпадают с реальными процентами на Android версиях ниже 9</string>
<string name="system_audiosilencer_title">Аудио глушитель</string>
<string name="system_audiosilencer_summ">Позволяет заглушить любой уникально опознаваемый звук</string>
<string name="system_audiosilencer_last_title">Обновить список</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@
<string name="system_autobrightness_summ">定义自动亮度的最小值和最大值</string>
<string name="system_minbrightness_title">自动亮度最小值</string>
<string name="system_maxbrightness_title">最大自动亮度</string>
<string name="system_autobrightness_hlg_title">始终使用非线性缩放</string>
<string name="system_autobrightness_hlg_summ">在低于Android 9版本上启用模块中的亮度百分比是否不匹配真实值</string>
<string name="system_audiosilencer_title">消音器</string>
<string name="system_audiosilencer_summ">静音可被唯一识别的声音</string>
<string name="system_audiosilencer_last_title">刷新列表</string>
Expand Down Expand Up @@ -1049,4 +1047,6 @@
<string name="system_notifrowmenu_forceclose">强制关闭</string>
<string name="restart_systemui">重启系统界面</string>
<string name="various_allow_untrusted_touch_title">允许不受信任的触摸操作</string>
<string name="launcher_nozoomanim_title">去除启动动画</string>
<string name="launcher_nozoomanim_summ">app启动、关闭时不缩放图标</string>
</resources>
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@
<string name="system_autobrightness_summ">Define minimum and maximum auto brightness values</string>
<string name="system_minbrightness_title">Minimum auto brightness</string>
<string name="system_maxbrightness_title">Maximum auto brightness</string>
<string name="system_autobrightness_hlg_title">Always use non-linear scale</string>
<string name="system_autobrightness_hlg_summ">Enable if brightness percentages in mod do not match real ones on Android versions below 9</string>
<string name="system_audiosilencer_title">Audio silencer</string>
<string name="system_audiosilencer_summ">Mute any sound that can be uniquely identified</string>
<string name="system_audiosilencer_last_title">Refresh list</string>
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/xml/prefs_system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,6 @@
miuizer:stepValue="1"
miuizer:format="%d dp" />

<name.mikanoshi.customiuizer.prefs.CheckBoxPreferenceEx
android:key="pref_key_system_drawer_clockseconds"
android:title="@string/system_clockseconds_title"
android:defaultValue="false" />

<name.mikanoshi.customiuizer.prefs.ListPreferenceEx
android:key="pref_key_system_inactivebrightness"
android:title="@string/system_inactivebrightness_title"
Expand All @@ -497,6 +492,11 @@
android:defaultValue="1"
miuizer:valueAsSummary="true" />

<name.mikanoshi.customiuizer.prefs.CheckBoxPreferenceEx
android:key="pref_key_system_drawer_clockseconds"
android:title="@string/system_clockseconds_title"
android:defaultValue="false" />

<name.mikanoshi.customiuizer.prefs.PreferenceEx
android:key="pref_key_system_popupnotif_cat"
android:summary="@string/system_popupnotif_summ"
Expand Down

0 comments on commit 65fff24

Please sign in to comment.