use of com.giua.app.LoggerManager in project Giua-App by Giua-app.
the class AutomaticLoginActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_automatic_login);
loggerManager = new LoggerManager("AutomaticLoginActivity", this);
loggerManager.d("onCreate chiamato");
btnLogout = findViewById(R.id.loading_screen_logout_btn);
tvAutoLogin = findViewById(R.id.loading_screen_minor_text_view);
pbLoadingScreen = findViewById(R.id.loading_screen_progressbar);
btnOffline = findViewById(R.id.loading_screen_offline_btn);
btnOffline.setOnClickListener(this::btnOfflineOnClick);
btnLogout.setOnClickListener(this::btnLogoutOnClick);
findViewById(R.id.loading_screen_btn_settings).setOnClickListener(this::btnSettingOnClick);
GiuaScraper.setDebugMode(true);
loginWithPreviousCredentials();
}
use of com.giua.app.LoggerManager in project Giua-App by Giua-app.
the class AutomaticLoginActivity method loginWithPreviousCredentials.
private void loginWithPreviousCredentials() {
if (GlobalVariables.gsThread == null || GlobalVariables.gsThread.isInterrupted() || GlobalVariables.gsThread.isInterrupting())
GlobalVariables.gsThread = new GiuaScraperThread();
loggerManager.d("Login automatico con credenziali salvate in corso");
GlobalVariables.gsThread.addTask(() -> {
runOnUiThread(() -> pbLoadingScreen.setVisibility(View.VISIBLE));
try {
String username = AppData.getActiveUsername(this);
String password = AccountData.getPassword(this, username);
String cookie = AccountData.getCookie(this, username);
String savedSiteUrl = AccountData.getSiteUrl(this, username);
GlobalVariables.gS = new GiuaScraper(username, password, cookie, true, SettingsData.getSettingBoolean(this, SettingKey.DEMO_MODE), new LoggerManager("GiuaScraper", this));
if (!savedSiteUrl.equals(""))
GlobalVariables.gS.setPrivateSiteUrl(savedSiteUrl);
GlobalVariables.gS.login();
AccountData.setCredentials(this, username, password, GlobalVariables.gS.getCookie(), GlobalVariables.gS.getUserTypeString(), GlobalVariables.gS.getProfilePage(false).getProfileInformation()[2]);
AccountData.setSiteUrl(this, username, GlobalVariables.gS.getSiteUrl());
if (!AppData.getAllAccountUsernames(this).contains(username))
AppData.addAccountUsername(this, username);
startDrawerActivity();
} catch (GiuaScraperExceptions.YourConnectionProblems | GiuaScraperExceptions.SiteConnectionProblems e) {
loggerManager.e("Errore di connessione - " + e.getMessage());
loggerManager.e(Arrays.toString(e.getStackTrace()));
runOnUiThread(() -> btnLogout.setVisibility(View.VISIBLE));
runOnUiThread(() -> btnOffline.setVisibility(View.VISIBLE));
if (SettingsData.getSettingBoolean(this, SettingKey.EXP_MODE))
runOnUiThread(() -> btnOffline.setVisibility(View.VISIBLE));
if (e.getClass() == GiuaScraperExceptions.YourConnectionProblems.class)
runOnUiThread(() -> setErrorMessage(getString(R.string.your_connection_error)));
else if (e.getClass() == GiuaScraperExceptions.SiteConnectionProblems.class)
runOnUiThread(() -> setErrorMessage(getString(R.string.site_connection_error)));
else
runOnUiThread(() -> setErrorMessage("E' stato riscontrato qualche problema sconosciuto riguardo la rete"));
runOnUiThread(() -> pbLoadingScreen.setVisibility(View.INVISIBLE));
threadSleepWithTextUpdates();
if (waitToReLogin < 30)
waitToReLogin += 5;
loginWithPreviousCredentials();
} catch (GiuaScraperExceptions.SessionCookieEmpty sce) {
// Se il login non dovesse funzionare lancia l acitvity di login ed elimina le credenziali salvate
if (AppData.getActiveUsername(this).equals("gsuite")) {
// Questa condizione si verifica quando è presente un acccount studente con il cookie scaduto
loggerManager.w("Cookie gS dell'account studente scaduto, avvio StudentLoginActivity");
startStudentLoginActivity();
} else {
loggerManager.w("Cookie gS scaduto, avvio ActivityManager");
AppData.removeAccountUsername(this, AppData.getActiveUsername(this));
AppData.saveActiveUsername(this, "");
setErrorMessage("Le credenziali di accesso non sono più valide");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
startActivity(new Intent(AutomaticLoginActivity.this, ActivityManager.class));
}
} catch (GiuaScraperExceptions.MaintenanceIsActiveException e) {
loggerManager.e("Errore: sito in manutenzione");
try {
Maintenance maintenance = GlobalVariables.gS.getMaintenanceInfo();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
runOnUiThread(() -> setErrorMessage("Il sito è in manutenzione sino alle " + simpleDateFormat.format(maintenance.end)));
} catch (Exception e2) {
loggerManager.e("Errore nel ricevere informazioni manutenzione: " + e.getMessage());
runOnUiThread(() -> setErrorMessage(getString(R.string.maintenance_is_active_error)));
}
runOnUiThread(() -> btnLogout.setVisibility(View.VISIBLE));
if (SettingsData.getSettingBoolean(this, SettingKey.EXP_MODE))
runOnUiThread(() -> btnOffline.setVisibility(View.VISIBLE));
runOnUiThread(() -> pbLoadingScreen.setVisibility(View.GONE));
runOnUiThread(() -> tvAutoLogin.setText("Accesso fallito."));
}
});
if (SettingsData.getSettingBoolean(this, SettingKey.EXP_MODE)) {
new Thread(() -> {
// mostra il pulsante per l'offline dopo 5 secondi
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
runOnUiThread(() -> {
btnOffline.setVisibility(View.INVISIBLE);
btnOffline.setAlpha(0f);
btnOffline.animate().alpha(1f).setDuration(400);
btnOffline.setVisibility(View.VISIBLE);
});
}).start();
}
}
use of com.giua.app.LoggerManager in project Giua-App by Giua-app.
the class BugReportActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bugreport);
lm = new LoggerManager("BugReportActivity", this);
btnSend = findViewById(R.id.btn_bug_send);
btnCancel = findViewById(R.id.btn_bug_cancel);
txBugTitle = findViewById(R.id.txtBugTitle);
txBugDesc = findViewById(R.id.txtBugDesc);
txBugDesc2 = findViewById(R.id.txtBugDesc2);
progressBar = findViewById(R.id.bug_progressbar);
btnSend.setOnClickListener(v -> onSendBug());
btnCancel.setOnClickListener(v -> exitActivity());
dontStealMePlease = BuildConfig.SECRET_KEY;
fromCAOC = getIntent().getBooleanExtra("fromCAOC", false);
if (fromCAOC) {
stacktrace = getIntent().getStringExtra("stacktrace");
}
}
use of com.giua.app.LoggerManager in project Giua-App by Giua-app.
the class CaocActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_caoc);
loggerManager = new LoggerManager("ErrorHandler", CaocActivity.this);
loggerManager.d("onCreate chiamato");
loggerManager.e("-.@CRASH");
loggerManager.d("Costruzione activity error handler");
Button restartButton = findViewById(R.id.caoc_restart_btn);
Button reportCrash = findViewById(R.id.caoc_report_btn);
final CaocConfig config = CustomActivityOnCrash.getConfigFromIntent(getIntent());
if (config == null) {
// This should never happen - Just finish the activity to avoid a recursive crash.
loggerManager.e("Errore Critico: Config di CAOC è null. Impossibile continuare");
finish();
return;
}
restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app);
restartButton.setOnClickListener(v -> {
loggerManager.w("Riavvio app");
Intent intent = new Intent(this, ActivityManager.class);
intent.putExtra("fromCAOC", true);
intent.putExtra("stacktrace", getAllErrorDetailsFromIntent(getIntent()));
CustomActivityOnCrash.restartApplicationWithIntent(this, intent, config);
});
/*if (config.isShowRestartButton() && config.getRestartActivityClass() != null) {
restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app);
restartButton.setOnClickListener(v -> {
loggerManager.w("Riavvio app");
CustomActivityOnCrash.restartApplication(CaocActivity.this, config);
});
} else {
restartButton.setOnClickListener(v -> {
loggerManager.w("Chiusura app");
CustomActivityOnCrash.closeApplication(CaocActivity.this, config);
});
}*/
Button moreInfoButton = findViewById(R.id.caoc_error_info_btn);
moreInfoButton.setOnClickListener(v -> {
AlertDialog dialog = new AlertDialog.Builder(CaocActivity.this).setTitle(R.string.customactivityoncrash_error_activity_error_details_title).setMessage(getAllErrorDetailsFromIntent(getIntent())).setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null).setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy, (dialog1, which) -> copyErrorToClipboard()).show();
TextView textView = dialog.findViewById(android.R.id.message);
if (textView != null) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size));
}
});
Integer defaultErrorActivityDrawableId = config.getErrorDrawable();
ImageView errorImageView = findViewById(R.id.caoc_image);
if (defaultErrorActivityDrawableId != null) {
errorImageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme()));
}
reportCrash.setOnClickListener(v -> {
loggerManager.d("Avvio BugReportActivity in un nuovo processo");
Intent intent = new Intent(this, BugReportActivity.class);
intent.putExtra("fromCAOC", true);
intent.putExtra("stacktrace", getAllErrorDetailsFromIntent(getIntent()));
CustomActivityOnCrash.restartApplicationWithIntent(this, intent, config);
});
findViewById(R.id.caoc_settings_btn).setOnClickListener(this::btnSettingOnClick);
AppData.saveCrashStatus(this, true);
loggerManager.e(getAllErrorDetailsFromIntent(getIntent()));
}
use of com.giua.app.LoggerManager in project Giua-App by Giua-app.
the class DrawerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null)
savedInstanceState.clear();
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drawer);
loggerManager = new LoggerManager("DrawerActivity", this);
loggerManager.d("onCreate chiamato");
offlineMode = getIntent().getBooleanExtra("offline", false);
demoMode = SettingsData.getSettingBoolean(this, SettingKey.DEMO_MODE);
goTo = getIntent().getStringExtra("goTo");
notificationsDBController = new NotificationsDBController(this);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (GlobalVariables.gsThread == null || GlobalVariables.gsThread.isInterrupted())
GlobalVariables.gsThread = new GiuaScraperThread();
if (GlobalVariables.gS == null) {
loggerManager.w("gs è null ma non dovrebbe esserlo quindi avvio AutomaticLogin");
startActivityManager();
return;
}
if (!offlineMode) {
GlobalVariables.gsThread.addTask(() -> {
if (!GlobalVariables.gS.isSessionValid(GlobalVariables.gS.getCookie())) {
runOnUiThread(this::startActivityManager);
}
});
}
myFragmentManager = new MyFragmentManager(this, toolbar, getSupportFragmentManager(), offlineMode, demoMode, unstableFeatures);
myDrawerManager = new MyDrawerManager(this, this::onChangeAccountFromDrawer, this::settingsItemOnClick, this::logoutItemOnClick, realUsername, userType, toolbar, myFragmentManager, demoMode);
if (goTo == null || goTo.equals(""))
myFragmentManager.changeFragment(R.id.nav_home);
else if (goTo.equals(AppNotificationsParams.NEWSLETTERS_NOTIFICATION_GOTO))
myFragmentManager.changeFragment(R.id.nav_newsletters);
else if (goTo.equals(AppNotificationsParams.ALERTS_NOTIFICATION_GOTO))
myFragmentManager.changeFragment(R.id.nav_alerts);
else if (goTo.equals(AppNotificationsParams.VOTES_NOTIFICATION_GOTO))
myFragmentManager.changeFragment(R.id.nav_votes);
else if (goTo.equals(AppNotificationsParams.AGENDA_NOTIFICATION_GOTO))
myFragmentManager.changeFragment(R.id.nav_agenda);
else
myFragmentManager.changeFragment(R.id.nav_home);
setupAppNotifications();
getAndSetupUsernameUsertype();
new Thread(() -> {
// Anche se siamo in offline mode, proviamo a scaricarle comunque (magari il registro è in manutenzione)
loggerManager.d("Scarico le informazioni sulle funzionalità instabili");
try {
unstableFeatures = GiuaScraper.getExtPage("https://giua-app.github.io/unstable_features2.txt").text();
myFragmentManager.unstableFeatures = unstableFeatures;
} catch (Exception ignored) {
}
}).start();
checkForUpdateChangelog();
}
Aggregations