Skip to content

Commit

Permalink
aspect ratio and scaling fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Sep 12, 2019
1 parent 9ea08c1 commit b6a9595
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,15 @@ protected void onDraw(Canvas canvas) {
adjustY = adjustX;
}
else {
adjustX = scale * cWidth / maxWidth;
adjustY = scale * cHeight / height;
float adjust = scale * Math.max(cWidth / maxWidth, cHeight / height);
if (adjust * maxWidth > cWidth)
adjustX = cWidth / maxWidth;
else
adjustX = adjust;
if (adjust * height > cHeight)
adjustY = cHeight / height;
else
adjustY = adjust;
}

paint.setTextSize(adjustY * BASE_FONT_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public class Options extends PreferenceActivity {
public static final String PREF_ALARM = "alarm";
public static final String PREF_VOLUME = "volume";
public static final String PREF_FULLSCREEN = "fullscreen";
public static final int highlightPercent = 25;
public static String PREF_CONTROL_FULLSCREEN = "controlFS";
public static final String PREF_BOOT_ADJUSTED = "bootAdjusted";
public static final int highlightPercent = 25;
static Map<String, int[]> colorMap = new HashMap<String,int[]>();
static final int[] defaultColor = {Color.WHITE, Color.BLACK};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ public boolean onLongClick(View view) {
chrono.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!options.getBoolean(Options.PREF_CONTROL_FULLSCREEN, true))
return;
SharedPreferences.Editor ed = options.edit();
ed.putBoolean(Options.PREF_FULLSCREEN, ! options.getBoolean(Options.PREF_FULLSCREEN, false));
MyChrono.apply(ed);
Expand Down Expand Up @@ -189,6 +191,9 @@ else if (o.equals("portrait"))

private void setFullScreen()
{
if (!options.getBoolean(Options.PREF_CONTROL_FULLSCREEN, true))
return;

boolean fs = options.getBoolean(Options.PREF_FULLSCREEN, false);
Window w = getWindow();
WindowManager.LayoutParams attrs = w.getAttributes();
Expand All @@ -204,7 +209,7 @@ private void setFullScreen()

View dv = w.getDecorView();

if(Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
if(Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) {
dv.setSystemUiVisibility(fs ? View.GONE : View.VISIBLE);
} else if(Build.VERSION.SDK_INT >= 19) {
int flags = dv.getSystemUiVisibility();
Expand All @@ -224,10 +229,11 @@ protected void onResume() {

setVolumeControlStream(Options.getStream(options));

setFullScreen();
setOrientation();
debug("theme");

setTheme();
setFullScreen();
debug("theme");
int orientation = getResources().getConfiguration().orientation;
chrono.post(new Runnable() {
@Override
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/xml/options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
android:key="keepAspect"
android:defaultValue="true"
android:summary="Keep font aspect ratio (turn off to stretch fonts to fill more screen space)"></CheckBoxPreference>
<CheckBoxPreference android:title="Control Fullscreen"
android:key="controlFS"
android:defaultValue="true"
android:summary="Allow switching to fullscreen mode by tapping in middle of screen"></CheckBoxPreference>
<CheckBoxPreference android:title="Allow Three Line"
android:key="threeLine"
android:defaultValue="true"
Expand Down

0 comments on commit b6a9595

Please sign in to comment.