Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f263c705 authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Report current font size in the 'Font size' setting summary"

parents f098231e 8a510c57
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1564,8 +1564,8 @@
    <string name="automatic_brightness">Automatic brightness</string>
    <!-- [CHAR LIMIT=30] Sound & display settings screen, setting option name to change font size -->
    <string name="title_font_size">Font size</string>
    <!-- [CHAR LIMIT=40] Sound & display settings screen, setting option summary to change font size -->
    <string name="summary_font_size">Overall size of fonts</string>
    <!-- [CHAR LIMIT=30] Sound & display settings screen, setting option summary displaying the currently selected font size -->
    <string name="summary_font_size">Current font size: %1$s</string>
    <!-- [CHAR LIMIT=40] Sound & display settings screen, title of dialog for picking font size -->
    <string name="dialog_title_font_size">Select font size</string>

+13 −3
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.app.admin.DevicePolicyManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
@@ -150,8 +151,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
        screenTimeoutPreference.setEnabled(revisedEntries.size() > 0);
    }

    int floatToIndex(float val, int resid) {
        String[] indices = getResources().getStringArray(resid);
    int floatToIndex(float val) {
        String[] indices = getResources().getStringArray(R.array.entryvalues_font_size);
        float lastVal = Float.parseFloat(indices[0]);
        for (int i=1; i<indices.length; i++) {
            float thisVal = Float.parseFloat(indices[i]);
@@ -169,7 +170,16 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
        } catch (RemoteException e) {
            Log.w(TAG, "Unable to retrieve font size");
        }
        pref.setValueIndex(floatToIndex(mCurConfig.fontScale, R.array.entryvalues_font_size));

        // mark the appropriate item in the preferences list
        int index = floatToIndex(mCurConfig.fontScale);
        pref.setValueIndex(index);

        // report the current size in the summary text
        final Resources res = getResources();
        String[] fontSizeNames = res.getStringArray(R.array.entries_font_size);
        pref.setSummary(String.format(res.getString(R.string.summary_font_size),
                fontSizeNames[index]));
    }
    
    @Override