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;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user