Search in sources :

Example 6 with LoggerManager

use of com.giua.app.LoggerManager in project Giua-App by Giua-app.

the class LogdogViewerActivity method onCreate.

@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_logdog_viewer);
    linearLayout = findViewById(R.id.log_linearlayout);
    scrollView = findViewById(R.id.log_scroll_view);
    deleteLogs = findViewById(R.id.log_floating_deletelogs);
    ProgressBar progressBar = findViewById(R.id.logdog_progressbar);
    TextView pbText = findViewById(R.id.logdog_progressbartxt);
    deleteLogs.setOnClickListener(this::onClickDeleteLogs);
    Toolbar toolbar = findViewById(R.id.logDog_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    @SuppressLint("SimpleDateFormat") SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    LoggerManager loggerManager = new LoggerManager("Logdog", this);
    try {
        loggerManager.parseLogsFrom(AppData.getLogsString(this));
    } catch (ArrayIndexOutOfBoundsException e) {
        onClickDeleteLogs(null);
    }
    List<LoggerManager.Log> logs = loggerManager.getLogs();
    new Thread(() -> {
        int i = 0;
        TextView textView = new TextView(this);
        StringBuilder text = new StringBuilder();
        linearLayout.removeAllViews();
        for (LoggerManager.Log log : logs) {
            if (i == 1000)
                break;
            // Non so perchè ma dobbiamo fare questa cosa per passare variabili al thread
            int finalI = i;
            runOnUiThread(() -> pbText.setText(finalI + "/" + logs.size()));
            // --@ = Avvio dell'app
            // -.@ = Crash dell'app
            String[] splitted = log.text.split("@");
            if (log.text.startsWith("--@")) {
                text.append("<b>    \u23af\u23af\u23af     ").append(splitted[1]).append("     \u23af\u23af\u23af</b>");
            } else if (log.text.startsWith("-.@")) {
                text.append("<font color='red'>    \u23af\u23af\u23af     ").append(splitted[1]).append("     \u23af\u23af\u23af </font>");
            } else {
                switch(log.type) {
                    case "ERROR":
                        text.append("<font color='red'>");
                        break;
                    case "WARNING":
                        text.append("<font color='#FFA500'>");
                        break;
                    case "DEBUG":
                        text.append("<font color='gray'>");
                        break;
                    default:
                        text.append("<font color='black'>");
                        break;
                }
                // + "|" + log.type + "| " + log.tag + ": <b>" + log.text + "</b></font>"
                text.append(dateFormat.format(log.date)).append("|").append(log.type).append("| ").append(log.tag).append(": <b>").append(log.text).append("</b></font>");
            }
            text.append("<br>");
            i++;
        }
        if (logs.isEmpty()) {
            text.append(noLogPresentText());
        }
        if (logs.size() >= 2000) {
            // Troppi log da mostrare in html, ne tagliamo un quarto
            int last = text.length() - (text.length() / 4);
            runOnUiThread(() -> pbText.setText("Rendering\nonly " + last + " of " + text.length() + " chars"));
            textView.setText(Html.fromHtml(text.substring(0, last), 0));
        } else {
            runOnUiThread(() -> pbText.setText("Rendering " + text.length() + " chars"));
            textView.setText(Html.fromHtml(text.toString(), 0));
        }
        runOnUiThread(() -> {
            linearLayout.addView(textView);
            progressBar.setVisibility(View.INVISIBLE);
            pbText.setVisibility(View.INVISIBLE);
        });
    }).start();
}
Also used : SuppressLint(android.annotation.SuppressLint) LoggerManager(com.giua.app.LoggerManager) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar) SimpleDateFormat(java.text.SimpleDateFormat) Toolbar(androidx.appcompat.widget.Toolbar) SuppressLint(android.annotation.SuppressLint)

Example 7 with LoggerManager

use of com.giua.app.LoggerManager in project Giua-App by Giua-app.

the class SettingsFragment method swExpModeChangeListener.

private boolean swExpModeChangeListener(Preference preference, Object o) {
    SwitchPreference swExpMode = Objects.requireNonNull(findPreference("experimentalMode"));
    if ((boolean) o) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle("Attenzione").setMessage("La modalità sperimentale include funzionalità incomplete oppure non testate, " + "per favore non segnalare bug con questa modalità attiva.\n\n" + "Dopo l'attivazione sarà necessario riavviare l'app.\n" + "Funzionalità incluse:\n" + "- Modalità Offline\n\n" + "Vuoi attivare la modalità sperimentale?").setPositiveButton("Si", (dialog, which) -> {
            SettingsData.saveSettingBoolean(requireActivity(), SettingKey.EXP_MODE, true);
            swExpMode.setChecked(true);
            new LoggerManager("SettigsFragment", getContext()).w("Funzionalità Sperimentali attivate");
        }).setNegativeButton("No", (dialog, which) -> {
            SettingsData.saveSettingBoolean(requireActivity(), SettingKey.EXP_MODE, false);
            swExpMode.setChecked(false);
            new LoggerManager("SettigsFragment", getContext()).w("Funzionalità Sperimentali disabilitate");
        });
        builder.show();
        return true;
    }
    SettingsData.saveSettingBoolean(requireActivity(), SettingKey.EXP_MODE, false);
    swExpMode.setChecked(false);
    new LoggerManager("SettigsFragment", getContext()).w("Funzionalità Sperimentali disabilitate");
    return true;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) SettingsData(com.giua.app.SettingsData) AboutActivity(com.giua.app.ui.activities.AboutActivity) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) Intent(android.content.Intent) SystemClock(android.os.SystemClock) Random(java.util.Random) PendingIntent(android.app.PendingIntent) R(com.giua.app.R) GiuaScraper(com.giua.webscraper.GiuaScraper) PreferenceFragmentCompat(androidx.preference.PreferenceFragmentCompat) AppData(com.giua.app.AppData) ActivityManager(com.giua.app.ActivityManager) HashSet(java.util.HashSet) SettingKey(com.giua.app.SettingKey) View(android.view.View) EditTextPreference(androidx.preference.EditTextPreference) AppNotifications(com.giua.app.AppNotifications) LogdogViewerActivity(com.giua.app.ui.activities.LogdogViewerActivity) AlarmManager(android.app.AlarmManager) SwitchPreference(androidx.preference.SwitchPreference) AppCompatDelegate(androidx.appcompat.app.AppCompatDelegate) Set(java.util.Set) Preference(androidx.preference.Preference) Objects(java.util.Objects) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) BugReportActivity(com.giua.app.ui.activities.BugReportActivity) ListPreference(androidx.preference.ListPreference) LoginActivity(com.giua.app.ui.activities.LoginActivity) Pattern(java.util.regex.Pattern) AppIntroActivity(com.giua.app.ui.activities.AppIntroActivity) Snackbar(com.google.android.material.snackbar.Snackbar) LoggerManager(com.giua.app.LoggerManager) SwitchPreference(androidx.preference.SwitchPreference) LoggerManager(com.giua.app.LoggerManager)

Example 8 with LoggerManager

use of com.giua.app.LoggerManager in project Giua-App by Giua-app.

the class SettingsFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
    // Load the preferences from an XML resource
    setPreferencesFromResource(R.xml.preferences, rootKey);
    this.context = requireActivity();
    loggerManager = new LoggerManager("SettingsFragment", context);
    setupAllObjects();
}
Also used : LoggerManager(com.giua.app.LoggerManager)

Example 9 with LoggerManager

use of com.giua.app.LoggerManager in project Giua-App by Giua-app.

the class AboutActivity method getMaterialAboutList.

@NonNull
@Override
protected MaterialAboutList getMaterialAboutList(@NonNull Context context) {
    loggerManager = new LoggerManager("AboutActivity", this);
    loggerManager.d("getMaterialAboutList chiamato");
    loggerManager.d("costruisco pagina about...");
    importantInteger += 160 + 120 + 20 - 1;
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();
    // Add items to card
    appCardBuilder.addItem(new MaterialAboutTitleItem.Builder().text("Giua App").desc("L'app non ufficiale per registri giua@school").icon(R.mipmap.ic_launcher).build());
    appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(this, new IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_information_outline).sizeDp(18), "Versione", false).setOnClickAction(this::justANormalJavaFunction));
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Changelog").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_history).sizeDp(18)).setOnClickAction(() -> {
        loggerManager.d("Mostro dialogo changelog");
        new Thread(() -> {
            String body = AppUpdateManager.buildChangelogForHTML(new AppUpdateManager(this).getReleasesJson());
            final SpannableString txt = new SpannableString(Html.fromHtml(body, 0));
            Linkify.addLinks(txt, Linkify.ALL);
            runOnUiThread(() -> {
                final AlertDialog d = new AlertDialog.Builder(this).setTitle("Changelog").setMessage(txt).setPositiveButton("Chiudi", (dialog, id) -> dialog.dismiss()).setCancelable(true).create();
                d.show();
                ((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
            });
        }).start();
    }).build());
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Privacy Policy").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_lock).sizeDp(18)).setOnClickAction(() -> {
        loggerManager.d("Mostro dialogo privacy");
        String body = getString(R.string.privacy);
        final SpannableString txt = new SpannableString(Html.fromHtml(body, 0));
        Linkify.addLinks(txt, Linkify.ALL);
        final AlertDialog d = new AlertDialog.Builder(this).setTitle("Privacy Policy").setMessage(txt).setPositiveButton("Chiudi", (dialog, id) -> dialog.dismiss()).setCancelable(true).create();
        d.show();
        ((TextView) d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
    }).build());
    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Licenze").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_book).sizeDp(18)).setOnClickAction(() -> {
        Intent intent = new Intent(getBaseContext(), AboutLicenseActivity.class);
        intent.putExtra("", getIntent().getIntExtra("", 0));
        context.startActivity(intent);
    }).build());
    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title("Sviluppatori");
    // authorCardBuilder.titleColor(ContextCompat.getColor(c, R.color.colorAccent));
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Hiem").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_account).sizeDp(18)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Franck1421").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_account).sizeDp(18)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Krek3r").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_account).sizeDp(18)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Source code su GitHub").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_github_circle).sizeDp(18)).setOnClickAction(ConvenienceBuilder.createWebViewDialogOnClickAction(this, "", "Chiudi", "https://github.com/Giua-app/Giua-App", true, false)).build());
    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Sito web ufficiale").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon2.cmd_web).sizeDp(18)).setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(this, Uri.parse("https://giua-app.github.io"))).build());
    MaterialAboutCard.Builder otherCardBuilder = new MaterialAboutCard.Builder();
    otherCardBuilder.title("Altro");
    otherCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Guarda gli analytics pubblici").icon(new IconicsDrawable(this).icon(CommunityMaterial.Icon.cmd_google_analytics).sizeDp(18)).setOnClickAction(ConvenienceBuilder.createWebsiteOnClickAction(this, Uri.parse("https://app.posthog.com/shared_dashboard/m3EBhJ_T3dsd4rl3HV399mwKj8szDg"))).build());
    loggerManager.d("Creazione pagina about completata");
    return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), otherCardBuilder.build());
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) MaterialAboutCard(com.danielstone.materialaboutlibrary.model.MaterialAboutCard) Context(android.content.Context) AlertDialog(androidx.appcompat.app.AlertDialog) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) OpenSourceLicense(com.danielstone.materialaboutlibrary.util.OpenSourceLicense) MaterialAboutList(com.danielstone.materialaboutlibrary.model.MaterialAboutList) Intent(android.content.Intent) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) LinkMovementMethod(android.text.method.LinkMovementMethod) Linkify(android.text.util.Linkify) R(com.giua.app.R) ConvenienceBuilder(com.danielstone.materialaboutlibrary.ConvenienceBuilder) Analytics(com.giua.app.Analytics) CommunityMaterial(com.mikepenz.community_material_typeface_library.CommunityMaterial) AppUpdateManager(com.giua.app.AppUpdateManager) SpannableString(android.text.SpannableString) MaterialAboutActivity(com.danielstone.materialaboutlibrary.MaterialAboutActivity) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) MaterialAboutTitleItem(com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem) Html(android.text.Html) Snackbar(com.google.android.material.snackbar.Snackbar) MaterialAboutActionItem(com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem) LoggerManager(com.giua.app.LoggerManager) MaterialAboutTitleItem(com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem) MaterialAboutCard(com.danielstone.materialaboutlibrary.model.MaterialAboutCard) ConvenienceBuilder(com.danielstone.materialaboutlibrary.ConvenienceBuilder) MaterialAboutActionItem(com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem) Intent(android.content.Intent) SpannableString(android.text.SpannableString) AppUpdateManager(com.giua.app.AppUpdateManager) SpannableString(android.text.SpannableString) MaterialAboutList(com.danielstone.materialaboutlibrary.model.MaterialAboutList) LoggerManager(com.giua.app.LoggerManager) TextView(android.widget.TextView) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable) NonNull(androidx.annotation.NonNull)

Example 10 with LoggerManager

use of com.giua.app.LoggerManager in project Giua-App by Giua-app.

the class AccountsActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_accounts);
    isChooserMode = getIntent().getBooleanExtra("account_chooser_mode", false);
    goTo = getIntent().getStringExtra("goTo");
    if (goTo == null)
        goTo = "";
    mainLayout = findViewById(R.id.activity_accounts_main);
    layoutAllAccounts = findViewById(R.id.activity_accounts_layout);
    swipeView = findViewById(R.id.accounts_swipe_view);
    layoutManageAccount = findViewById(R.id.accounts_manage_account_layout);
    ivManageAccountDelete = findViewById(R.id.accounts_manage_account_delete);
    tvManageAccountUsername = findViewById(R.id.accounts_manage_account_username);
    tvManageAccountEmail = findViewById(R.id.accounts_manage_account_email);
    etManageAccountUrl = findViewById(R.id.accounts_manage_account_url);
    dotColorPreview = findViewById(R.id.accounts_manage_account_dot_colored);
    layoutAddAccount = findViewById(R.id.accounts_add_account_layout);
    btnAddAccountMenu = findViewById(R.id.accounts_add_account_button_menu);
    btnAddNormalAccount = findViewById(R.id.accounts_add_account_button);
    btnAddStudentAccount = findViewById(R.id.accounts_add_account_student_button);
    tvAddAccountSave = findViewById(R.id.accounts_add_account_save_text);
    tilAddAccountUsername = findViewById(R.id.accounts_add_account_username);
    tilAddAccountPassword = findViewById(R.id.accounts_add_account_password);
    tilAddAccountUrl = findViewById(R.id.accounts_add_account_url);
    etAddAccountUsername = tilAddAccountUsername.getEditText();
    etAddAccountPassword = tilAddAccountPassword.getEditText();
    etAddAccountUrl = tilAddAccountUrl.getEditText();
    if (isChooserMode)
        btnAddAccountMenu.setVisibility(View.GONE);
    if (AppData.getAllAccountUsernames(this).contains("gsuite"))
        btnAddStudentAccount.setVisibility(View.GONE);
    else
        checkGoogleLoginAvailability();
    accountCardParams.leftMargin = AppUtils.convertDpToPx(10, this);
    accountCardParams.rightMargin = AppUtils.convertDpToPx(10, this);
    accountCardParams.topMargin = AppUtils.convertDpToPx(10, this);
    loggerManager = new LoggerManager("AccountsActivity", this);
    setupToolBar();
    setupListeners();
}
Also used : LoggerManager(com.giua.app.LoggerManager)

Aggregations

LoggerManager (com.giua.app.LoggerManager)20 Intent (android.content.Intent)6 TextView (android.widget.TextView)5 GiuaScraper (com.giua.webscraper.GiuaScraper)5 SimpleDateFormat (java.text.SimpleDateFormat)5 GiuaScraperThread (com.giua.app.GiuaScraperThread)4 R (com.giua.app.R)4 SuppressLint (android.annotation.SuppressLint)3 Bundle (android.os.Bundle)3 View (android.view.View)3 LinearLayout (android.widget.LinearLayout)3 NonNull (androidx.annotation.NonNull)3 Nullable (androidx.annotation.Nullable)3 AlertDialog (androidx.appcompat.app.AlertDialog)3 Context (android.content.Context)2 SpannableString (android.text.SpannableString)2 LayoutInflater (android.view.LayoutInflater)2 ProgressBar (android.widget.ProgressBar)2 ResourcesCompat (androidx.core.content.res.ResourcesCompat)2 Analytics (com.giua.app.Analytics)2