Skip to content

Commit

Permalink
Individual zoom setting based on display ID
Browse files Browse the repository at this point in the history
  • Loading branch information
babaric-dev authored Jan 23, 2023
1 parent 2f5a6f7 commit b94aea2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.content.Context;
import android.util.TypedValue;
import android.os.Build;
import android.view.Display;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -151,13 +154,28 @@ public void setFontVariables(Context context) {
MAX_FONTSIZE = sizes[2];
}

private String getDisplayIdAsString() {
Context context = getContext();
Display display;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
display = context.getDisplay();
} else {
display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
}
int d = display.getDisplayId();
if (d == Display.DEFAULT_DISPLAY)
return "";
else
return Integer.toString(d);
}

public int getFontSize() {
int fontSize = SharedPreferenceUtils.getIntStoredAsString(mSharedPreferences, TERMUX_APP.KEY_FONTSIZE, DEFAULT_FONTSIZE);
int fontSize = SharedPreferenceUtils.getIntStoredAsString(mSharedPreferences, TERMUX_APP.KEY_FONTSIZE + getDisplayIdAsString(), DEFAULT_FONTSIZE);
return DataUtils.clamp(fontSize, MIN_FONTSIZE, MAX_FONTSIZE);
}

public void setFontSize(int value) {
SharedPreferenceUtils.setIntStoredAsString(mSharedPreferences, TERMUX_APP.KEY_FONTSIZE, value, false);
SharedPreferenceUtils.setIntStoredAsString(mSharedPreferences, TERMUX_APP.KEY_FONTSIZE + getDisplayIdAsString(), value, false);
}

public void changeFontSize(boolean increase) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.termux.shared.termux.settings.preferences;

import android.content.Context;
import android.os.Build;
import android.view.Display;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -115,13 +118,28 @@ public void setFontVariables(Context context) {
MAX_FONTSIZE = sizes[2];
}

private String getDisplayIdAsString() {
Context context = getContext();
Display display;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
display = context.getDisplay();
} else {
display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
}
int d = display.getDisplayId();
if (d == Display.DEFAULT_DISPLAY)
return "";
else
return Integer.toString(d);
}

public int getFontSize() {
int fontSize = SharedPreferenceUtils.getIntStoredAsString(mSharedPreferences, TERMUX_FLOAT_APP.KEY_FONTSIZE, DEFAULT_FONTSIZE);
int fontSize = SharedPreferenceUtils.getIntStoredAsString(mSharedPreferences, TERMUX_FLOAT_APP.KEY_FONTSIZE + getDisplayIdAsString(), DEFAULT_FONTSIZE);
return DataUtils.clamp(fontSize, MIN_FONTSIZE, MAX_FONTSIZE);
}

public void setFontSize(int value) {
SharedPreferenceUtils.setIntStoredAsString(mSharedPreferences, TERMUX_FLOAT_APP.KEY_FONTSIZE, value, false);
SharedPreferenceUtils.setIntStoredAsString(mSharedPreferences, TERMUX_FLOAT_APP.KEY_FONTSIZE + getDisplayIdAsString(), value, false);
}

public void changeFontSize(boolean increase) {
Expand Down

0 comments on commit b94aea2

Please sign in to comment.