mirror of https://codeberg.org/gitnex/GitNex.git
Use system default font (option in settings)
This commit is contained in:
parent
349b954dd5
commit
f7e3c2ec82
|
@ -85,6 +85,7 @@ public class IssueDetailActivity extends BaseActivity
|
|||
AssigneesListAdapter.AssigneesListAdapterListener,
|
||||
BottomSheetListener {
|
||||
|
||||
private Typeface myTypeface;
|
||||
public static boolean singleIssueUpdate = false;
|
||||
public static boolean commentPosted = false;
|
||||
private final List<Label> labelsList = new ArrayList<>();
|
||||
|
@ -185,7 +186,7 @@ public class IssueDetailActivity extends BaseActivity
|
|||
},
|
||||
50));
|
||||
|
||||
Typeface myTypeface = AppUtil.getTypeface(this);
|
||||
myTypeface = AppUtil.getTypeface(this);
|
||||
viewBinding.toolbarTitle.setTypeface(myTypeface);
|
||||
viewBinding.toolbarTitle.setText(repoName);
|
||||
|
||||
|
@ -935,13 +936,13 @@ public class IssueDetailActivity extends BaseActivity
|
|||
TextDrawable drawable =
|
||||
TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.useFont(myTypeface)
|
||||
.textColor(new ColorInverter().getContrastColor(color))
|
||||
.fontSize(textSize)
|
||||
.width(
|
||||
LabelWidthCalculator.calculateLabelWidth(
|
||||
labelName,
|
||||
Typeface.DEFAULT,
|
||||
myTypeface,
|
||||
textSize,
|
||||
AppUtil.getPixelsFromDensity(ctx, 10)))
|
||||
.height(height)
|
||||
|
|
|
@ -162,6 +162,22 @@ public class MainActivity extends BaseActivity
|
|||
Menu menu = navigationView.getMenu();
|
||||
navNotifications = menu.findItem(R.id.nav_notifications);
|
||||
|
||||
navigationView
|
||||
.getViewTreeObserver()
|
||||
.addOnGlobalLayoutListener(
|
||||
() -> {
|
||||
ArrayList<View> menuItems = new ArrayList<>(menu.size());
|
||||
for (int i = 0; i < menu.size(); i++) {
|
||||
MenuItem item = menu.getItem(i);
|
||||
navigationView.findViewsWithText(
|
||||
menuItems, item.getTitle(), View.FIND_VIEWS_WITH_TEXT);
|
||||
}
|
||||
|
||||
for (final View menuItem : menuItems) {
|
||||
((TextView) menuItem).setTypeface(myTypeface);
|
||||
}
|
||||
});
|
||||
|
||||
ActionBarDrawerToggle toggle =
|
||||
new ActionBarDrawerToggle(
|
||||
this,
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SettingsCodeEditorActivity extends BaseActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActivitySettingsCodeEditorBinding activitySettingsCodeEditorBinding =
|
||||
ActivitySettingsCodeEditorBinding.inflate(getLayoutInflater());
|
||||
ActivitySettingsCodeEditorBinding.inflate(getLayoutInflater());
|
||||
setContentView(activitySettingsCodeEditorBinding.getRoot());
|
||||
|
||||
initCloseListener();
|
||||
|
@ -38,99 +38,105 @@ public class SettingsCodeEditorActivity extends BaseActivity {
|
|||
activitySettingsCodeEditorBinding.ceColorSelected.setText(colorList[colorSelectedChoice]);
|
||||
|
||||
activitySettingsCodeEditorBinding.ceColorSelectionFrame.setOnClickListener(
|
||||
view -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.ceSyntaxHighlightColor)
|
||||
.setSingleChoiceItems(
|
||||
colorList,
|
||||
colorSelectedChoice,
|
||||
(dialogInterfaceColor, i) -> {
|
||||
colorSelectedChoice = i;
|
||||
activitySettingsCodeEditorBinding.ceColorSelected
|
||||
.setText(colorList[i]);
|
||||
tinyDB.putInt("ceColorId", i);
|
||||
view -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.ceSyntaxHighlightColor)
|
||||
.setSingleChoiceItems(
|
||||
colorList,
|
||||
colorSelectedChoice,
|
||||
(dialogInterfaceColor, i) -> {
|
||||
colorSelectedChoice = i;
|
||||
activitySettingsCodeEditorBinding.ceColorSelected
|
||||
.setText(colorList[i]);
|
||||
tinyDB.putInt("ceColorId", i);
|
||||
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
});
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
// indentation selector dialog
|
||||
indentationList = getResources().getStringArray(R.array.ceIndentation);
|
||||
activitySettingsCodeEditorBinding.indentationSelected.setText(indentationList[indentationSelectedChoice]);
|
||||
activitySettingsCodeEditorBinding.indentationSelected.setText(
|
||||
indentationList[indentationSelectedChoice]);
|
||||
|
||||
activitySettingsCodeEditorBinding.indentationSelectionFrame.setOnClickListener(
|
||||
view -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.ceIndentation)
|
||||
.setSingleChoiceItems(
|
||||
indentationList,
|
||||
indentationSelectedChoice,
|
||||
(dialogInterfaceColor, i) -> {
|
||||
indentationSelectedChoice = i;
|
||||
activitySettingsCodeEditorBinding.indentationSelected
|
||||
.setText(indentationList[i]);
|
||||
tinyDB.putInt("ceIndentationId", i);
|
||||
view -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.ceIndentation)
|
||||
.setSingleChoiceItems(
|
||||
indentationList,
|
||||
indentationSelectedChoice,
|
||||
(dialogInterfaceColor, i) -> {
|
||||
indentationSelectedChoice = i;
|
||||
activitySettingsCodeEditorBinding
|
||||
.indentationSelected.setText(
|
||||
indentationList[i]);
|
||||
tinyDB.putInt("ceIndentationId", i);
|
||||
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
});
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
|
||||
// indentation tabs selector dialog
|
||||
if (indentationList[indentationSelectedChoice].startsWith("Tabs")) {
|
||||
activitySettingsCodeEditorBinding.indentationTabsSelectionFrame.setVisibility(View.VISIBLE);
|
||||
activitySettingsCodeEditorBinding.indentationTabsSelectionFrame.setVisibility(
|
||||
View.VISIBLE);
|
||||
} else {
|
||||
activitySettingsCodeEditorBinding.indentationTabsSelectionFrame.setVisibility(View.GONE);
|
||||
activitySettingsCodeEditorBinding.indentationTabsSelectionFrame.setVisibility(
|
||||
View.GONE);
|
||||
}
|
||||
|
||||
indentationTabsList = getResources().getStringArray(R.array.ceIndentationTabsWidth);
|
||||
activitySettingsCodeEditorBinding.indentationTabsSelected.setText(indentationTabsList[indentationTabsSelectedChoice]);
|
||||
activitySettingsCodeEditorBinding.indentationTabsSelected.setText(
|
||||
indentationTabsList[indentationTabsSelectedChoice]);
|
||||
|
||||
activitySettingsCodeEditorBinding.indentationTabsSelectionFrame.setOnClickListener(
|
||||
view -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.ceIndentationTabsWidth)
|
||||
.setSingleChoiceItems(
|
||||
indentationTabsList,
|
||||
indentationTabsSelectedChoice,
|
||||
(dialogInterfaceColor, i) -> {
|
||||
indentationTabsSelectedChoice = i;
|
||||
activitySettingsCodeEditorBinding.indentationTabsSelected
|
||||
.setText(indentationTabsList[i]);
|
||||
tinyDB.putInt("ceIndentationTabsId", i);
|
||||
view -> {
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(ctx)
|
||||
.setTitle(R.string.ceIndentationTabsWidth)
|
||||
.setSingleChoiceItems(
|
||||
indentationTabsList,
|
||||
indentationTabsSelectedChoice,
|
||||
(dialogInterfaceColor, i) -> {
|
||||
indentationTabsSelectedChoice = i;
|
||||
activitySettingsCodeEditorBinding
|
||||
.indentationTabsSelected.setText(
|
||||
indentationTabsList[i]);
|
||||
tinyDB.putInt("ceIndentationTabsId", i);
|
||||
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
});
|
||||
SettingsFragment.refreshParent = true;
|
||||
this.recreate();
|
||||
this.overridePendingTransition(0, 0);
|
||||
dialogInterfaceColor.dismiss();
|
||||
Toasty.success(
|
||||
appCtx,
|
||||
getResources()
|
||||
.getString(R.string.settingsSave));
|
||||
});
|
||||
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
materialAlertDialogBuilder.create().show();
|
||||
});
|
||||
}
|
||||
|
||||
private void initCloseListener() {
|
||||
|
|
|
@ -230,6 +230,8 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
Typeface typeface = AppUtil.getTypeface(context);
|
||||
|
||||
if (issue.getLabels() != null) {
|
||||
|
||||
if (!tinyDb.getBoolean("showLabelsInList", false)) { // default
|
||||
|
@ -251,7 +253,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
TextDrawable drawable =
|
||||
TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.useFont(typeface)
|
||||
.width(54)
|
||||
.height(54)
|
||||
.endConfig()
|
||||
|
@ -283,13 +285,13 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
TextDrawable drawable =
|
||||
TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.useFont(typeface)
|
||||
.textColor(new ColorInverter().getContrastColor(color))
|
||||
.fontSize(textSize)
|
||||
.width(
|
||||
LabelWidthCalculator.calculateLabelWidth(
|
||||
labelName,
|
||||
Typeface.DEFAULT,
|
||||
typeface,
|
||||
textSize,
|
||||
AppUtil.getPixelsFromDensity(context, 8)))
|
||||
.height(height)
|
||||
|
|
|
@ -457,6 +457,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
|
||||
void bindData(TimelineComment timelineComment) {
|
||||
|
||||
Typeface typeface = AppUtil.getTypeface(context);
|
||||
int fontSize = 14;
|
||||
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
||||
|
||||
|
@ -500,13 +501,13 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
TextDrawable drawable =
|
||||
TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.useFont(typeface)
|
||||
.textColor(new ColorInverter().getContrastColor(color))
|
||||
.fontSize(textSize)
|
||||
.width(
|
||||
LabelWidthCalculator.calculateLabelWidth(
|
||||
issueComment.getLabel().getName(),
|
||||
Typeface.DEFAULT,
|
||||
typeface,
|
||||
textSize,
|
||||
AppUtil.getPixelsFromDensity(context, 10)))
|
||||
.height(height)
|
||||
|
|
|
@ -208,6 +208,8 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
Typeface typeface = AppUtil.getTypeface(context);
|
||||
|
||||
if (issue.getLabels() != null) {
|
||||
|
||||
if (!tinyDb.getBoolean("showLabelsInList", false)) { // default
|
||||
|
@ -229,7 +231,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
TextDrawable drawable =
|
||||
TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.useFont(typeface)
|
||||
.width(54)
|
||||
.height(54)
|
||||
.endConfig()
|
||||
|
@ -261,13 +263,13 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
TextDrawable drawable =
|
||||
TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.useFont(typeface)
|
||||
.textColor(new ColorInverter().getContrastColor(color))
|
||||
.fontSize(textSize)
|
||||
.width(
|
||||
LabelWidthCalculator.calculateLabelWidth(
|
||||
labelName,
|
||||
Typeface.DEFAULT,
|
||||
typeface,
|
||||
textSize,
|
||||
AppUtil.getPixelsFromDensity(context, 8)))
|
||||
.height(height)
|
||||
|
|
|
@ -198,6 +198,8 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 15, 0);
|
||||
|
||||
Typeface typeface = AppUtil.getTypeface(context);
|
||||
|
||||
if (pullRequest.getLabels() != null) {
|
||||
|
||||
if (!tinyDb.getBoolean("showLabelsInList", false)) { // default
|
||||
|
@ -219,7 +221,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
TextDrawable drawable =
|
||||
TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.useFont(typeface)
|
||||
.width(54)
|
||||
.height(54)
|
||||
.endConfig()
|
||||
|
@ -251,13 +253,13 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
TextDrawable drawable =
|
||||
TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.useFont(Typeface.DEFAULT)
|
||||
.useFont(typeface)
|
||||
.textColor(new ColorInverter().getContrastColor(color))
|
||||
.fontSize(textSize)
|
||||
.width(
|
||||
LabelWidthCalculator.calculateLabelWidth(
|
||||
labelName,
|
||||
Typeface.DEFAULT,
|
||||
typeface,
|
||||
textSize,
|
||||
AppUtil.getPixelsFromDensity(context, 8)))
|
||||
.height(height)
|
||||
|
|
|
@ -599,6 +599,9 @@ public class AppUtil {
|
|||
Typeface.createFromAsset(
|
||||
context.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
case 3:
|
||||
typeface = Typeface.DEFAULT;
|
||||
break;
|
||||
default:
|
||||
typeface =
|
||||
Typeface.createFromAsset(
|
||||
|
|
|
@ -14,7 +14,7 @@ public class FontsOverride {
|
|||
public static void setDefaultFont(Context context) {
|
||||
final Typeface regular = AppUtil.getTypeface(context);
|
||||
|
||||
for (String field : new String[] {"DEFAULT", "MONOSPACE", "SERIF", "SANS_SERIF"}) {
|
||||
for (String field : new String[] {"MONOSPACE"}) {
|
||||
replaceFont(field, regular);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<item>Roboto</item>
|
||||
<item>Manrope</item>
|
||||
<item>Source Code Pro</item>
|
||||
<item>@string/system_font</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="themes">
|
||||
|
|
|
@ -254,6 +254,7 @@
|
|||
<string name="ceSyntaxHighlightColor">Syntax Highlighting Color</string>
|
||||
<string name="ceIndentation">Indentation</string>
|
||||
<string name="ceIndentationTabsWidth">Tabs Width</string>
|
||||
<string name="system_font">System Default Font</string>
|
||||
<!-- settings -->
|
||||
|
||||
<string name="noMoreData">No more data available</string>
|
||||
|
|
Loading…
Reference in New Issue