GitNex/app/src/main/java/org/mian/gitnex/activities/BaseActivity.java
M M Arif 7c6247782b [Frontport] Fix Acra and workmanager, update gradle (#856)
Move acra to application

[Frontport] Fix Acra and workmanager errors, update gradle

Fix ACRA and workmanager errors

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/856
Reviewed-by: opyale <opyale@noreply.codeberg.org>
Co-Authored-By: M M Arif <mmarif@noreply.codeberg.org>
Co-Committed-By: M M Arif <mmarif@noreply.codeberg.org>
2021-03-30 16:31:39 +02:00

88 lines
1.8 KiB
Java

package org.mian.gitnex.activities;
import android.content.Context;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import org.mian.gitnex.R;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.notifications.Notifications;
/**
* Author M M Arif
*/
public abstract class BaseActivity extends AppCompatActivity {
protected TinyDB tinyDB;
protected Context ctx = this;
protected Context appCtx;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.appCtx = getApplicationContext();
this.tinyDB = TinyDB.getInstance(appCtx);
switch(tinyDB.getInt("themeId")) {
case 1:
tinyDB.putString("currentTheme", "light");
setTheme(R.style.AppThemeLight);
break;
case 2:
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
tinyDB.putString("currentTheme", "dark");
setTheme(R.style.AppTheme);
}
else {
tinyDB.putString("currentTheme", "light");
setTheme(R.style.AppThemeLight);
}
break;
case 3:
tinyDB.putString("currentTheme", "light");
setTheme(R.style.AppThemeRetro);
break;
case 4:
if(TimeHelper.timeBetweenHours(18, 6)) { // 6pm to 6am
tinyDB.putString("currentTheme", "dark");
setTheme(R.style.AppTheme);
}
else {
tinyDB.putString("currentTheme", "light");
setTheme(R.style.AppThemeRetro);
}
break;
case 5:
tinyDB.putString("currentTheme", "dark");
setTheme(R.style.AppThemePitchBlack);
break;
default:
tinyDB.putString("currentTheme", "dark");
setTheme(R.style.AppTheme);
}
AppUtil.setAppLocale(getResources(), tinyDB.getString("locale"));
Notifications.startWorker(appCtx);
}
}