Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Individual zoom setting based on display ID #3208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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