Setting Manrope as default font. (#379)
Revert "store default if user didnt touch Font settings"
This reverts commit 9c5f9731
store default if user didnt touch Font settings
Setting translatable to false
Last changes.
Defaulting to Manrope in strings.xml
Default to Manrope in settings.
Changes in default value.
Automatic formatting.
Merge remote-tracking branch 'remotes/main/master' into manrope
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/BaseActivity.java
Manrope just literally as default font.
Reformatting code.
Making optimizations.
Moving initialization to BaseActivity
Merge remote-tracking branch 'remotes/main/master' into manrope
Setting Manrope as default font.
Co-authored-by: opyale <example@example.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/379
Reviewed-by: 6543 <6543@noreply.gitea.io>
Reviewed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
@@ -13,75 +13,67 @@ import org.mian.gitnex.util.TinyDB;
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||
|
||||
if(tinyDb.getInt("themeId") == 1) {
|
||||
setTheme(R.style.AppThemeLight);
|
||||
}
|
||||
else if(tinyDb.getInt("themeId") == 2) {
|
||||
if(tinyDb.getInt("themeId") == 1) {
|
||||
setTheme(R.style.AppThemeLight);
|
||||
}
|
||||
else if(tinyDb.getInt("themeId") == 2) {
|
||||
|
||||
boolean timeSetterFlag = TimeHelper.timeBetweenHours(18, 6); // 6pm to 6am
|
||||
boolean timeSetterFlag = TimeHelper.timeBetweenHours(18, 6); // 6pm to 6am
|
||||
|
||||
if(timeSetterFlag) {
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
setTheme(R.style.AppThemeLight);
|
||||
}
|
||||
if(timeSetterFlag) {
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
else {
|
||||
setTheme(R.style.AppThemeLight);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
}
|
||||
else {
|
||||
setTheme(R.style.AppTheme);
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutResourceId());
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutResourceId());
|
||||
|
||||
if(tinyDb.getInt("customFontId") == 0) {
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
|
||||
case 0:
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 1) {
|
||||
case 2:
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/manroperegular.ttf");
|
||||
default:
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/manroperegular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 2) {
|
||||
}
|
||||
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/sourcecodeproregular.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/sourcecodeproregular.ttf");
|
||||
// enabling counter badges by default
|
||||
if(tinyDb.getString("enableCounterBadgesInit").isEmpty()) {
|
||||
tinyDb.putBoolean("enableCounterBadges", true);
|
||||
tinyDb.putString("enableCounterBadgesInit", "yes");
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
FontsOverride.setDefaultFont(this, "DEFAULT", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "MONOSPACE", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SERIF", "fonts/roboto.ttf");
|
||||
FontsOverride.setDefaultFont(this, "SANS_SERIF", "fonts/roboto.ttf");
|
||||
|
||||
}
|
||||
|
||||
// enabling counter badges by default
|
||||
if(tinyDb.getString("enableCounterBadgesInit").isEmpty()) {
|
||||
tinyDb.putBoolean("enableCounterBadges", true);
|
||||
tinyDb.putString("enableCounterBadgesInit", "yes");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected abstract int getLayoutResourceId();
|
||||
protected abstract int getLayoutResourceId();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public class IssueDetailActivity extends BaseActivity {
|
||||
|
||||
Typeface myTypeface;
|
||||
|
||||
switch(tinyDb.getInt("customFontId")) {
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
case 1:
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/manroperegular.ttf");
|
||||
|
||||
@@ -109,24 +109,19 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
|
||||
|
||||
if(tinyDb.getInt("customFontId") == 0) {
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 1) {
|
||||
case 2:
|
||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/manroperegular.ttf");
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 2) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/roboto.ttf");
|
||||
default:
|
||||
myTypeface = Typeface.createFromAsset(getAssets(), "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -58,24 +58,20 @@ public class OrganizationDetailActivity extends BaseActivity implements BottomSh
|
||||
TabLayout tabLayout = findViewById(R.id.tabs);
|
||||
|
||||
Typeface myTypeface;
|
||||
if(tinyDb.getInt("customFontId") == 0) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/roboto.ttf");
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 1) {
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/manroperegular.ttf");
|
||||
case 2:
|
||||
myTypeface = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 2) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/roboto.ttf");
|
||||
default:
|
||||
myTypeface = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -92,24 +92,20 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
TabLayout tabLayout = findViewById(R.id.tabs);
|
||||
|
||||
Typeface myTypeface;
|
||||
if(tinyDb.getInt("customFontId") == 0) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/roboto.ttf");
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 1) {
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/manroperegular.ttf");
|
||||
case 2:
|
||||
myTypeface = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 2) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getApplicationContext()).getAssets(), "fonts/roboto.ttf");
|
||||
default:
|
||||
myTypeface = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -84,24 +84,19 @@ public class RepoStargazersAdapter extends BaseAdapter {
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
Typeface myTypeface;
|
||||
|
||||
if(tinyDb.getInt("customFontId") == 0) {
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 1) {
|
||||
case 2:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 2) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
default:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -84,24 +84,19 @@ public class RepoWatchersAdapter extends BaseAdapter {
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
Typeface myTypeface;
|
||||
|
||||
if(tinyDb.getInt("customFontId") == 0) {
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 1) {
|
||||
case 2:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 2) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
default:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.helpers.FontsOverride;
|
||||
import org.mian.gitnex.helpers.RoundedTransformation;
|
||||
import org.mian.gitnex.models.UserInfo;
|
||||
import org.mian.gitnex.util.TinyDB;
|
||||
@@ -85,24 +86,19 @@ public class TeamMembersByOrgAdapter extends BaseAdapter {
|
||||
final TinyDB tinyDb = new TinyDB(mCtx);
|
||||
Typeface myTypeface;
|
||||
|
||||
if(tinyDb.getInt("customFontId") == 0) {
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 1) {
|
||||
case 2:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 2) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/roboto.ttf");
|
||||
default:
|
||||
myTypeface = Typeface.createFromAsset(mCtx.getAssets(), "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -58,24 +58,20 @@ public class ProfileFragment extends Fragment {
|
||||
mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
|
||||
Typeface myTypeface;
|
||||
if(tinyDb.getInt("customFontId") == 0) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getContext()).getAssets(), "fonts/roboto.ttf");
|
||||
switch(tinyDb.getInt("customFontId", -1)) {
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 1) {
|
||||
case 0:
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getContext()).getAssets(), "fonts/roboto.ttf");
|
||||
break;
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getContext()).getAssets(), "fonts/manroperegular.ttf");
|
||||
case 2:
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getContext()).getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
else if (tinyDb.getInt("customFontId") == 2) {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getContext()).getAssets(), "fonts/sourcecodeproregular.ttf");
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getContext()).getAssets(), "fonts/roboto.ttf");
|
||||
default:
|
||||
myTypeface = Typeface.createFromAsset(Objects.requireNonNull(getContext()).getAssets(), "fonts/manroperegular.ttf");
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ public class SettingsFragment extends Fragment {
|
||||
}
|
||||
|
||||
if(customFontSelectedChoice == 0) {
|
||||
customFontSelectedChoice = tinyDb.getInt("customFontId");
|
||||
customFontSelectedChoice = tinyDb.getInt("customFontId", 1);
|
||||
}
|
||||
|
||||
if(themeSelectedChoice == 0) {
|
||||
|
||||
@@ -171,6 +171,10 @@ public class TinyDB {
|
||||
return preferences.getInt(key, 0);
|
||||
}
|
||||
|
||||
public int getInt(String key, int defaultValue) {
|
||||
return preferences.getInt(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parsed ArrayList of Integers from SharedPreferences at 'key'
|
||||
* @param key SharedPreferences key
|
||||
|
||||
Reference in New Issue
Block a user