Search in sources :

Example 1 with AppUpdateManager

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

the class LoginActivity method checkForUpdateChangelog.

private void checkForUpdateChangelog() {
    if (!AppData.getAppVersion(this).equals("") && !AppData.getAppVersion(this).equals(BuildConfig.VERSION_NAME)) {
        loggerManager.w("Aggiornamento installato rilevato");
        loggerManager.d("Cancello apk dell'aggiornamento e mostro changelog");
        new Analytics.Builder(Analytics.APP_UPDATED).addCustomValue("new_ver", BuildConfig.VERSION_NAME).addCustomValue("old_ver", AppData.getAppVersion(this)).send();
        AppUpdateManager upd = new AppUpdateManager(LoginActivity.this);
        upd.deleteOldApk();
        new Thread(upd::showDialogReleaseChangelog).start();
    }
    AppData.saveAppVersion(this, BuildConfig.VERSION_NAME);
}
Also used : Analytics(com.giua.app.Analytics) AppUpdateManager(com.giua.app.AppUpdateManager) GiuaScraperThread(com.giua.app.GiuaScraperThread)

Example 2 with AppUpdateManager

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

the class DrawerActivity method checkForUpdateChangelog.

private void checkForUpdateChangelog() {
    if (!AppData.getAppVersion(this).equals("") && !AppData.getAppVersion(this).equals(BuildConfig.VERSION_NAME)) {
        loggerManager.w("Aggiornamento installato rilevato");
        loggerManager.d("Cancello apk dell'aggiornamento e mostro changelog");
        new Analytics.Builder(Analytics.APP_UPDATED).addCustomValue("new_ver", BuildConfig.VERSION_NAME).addCustomValue("old_ver", AppData.getAppVersion(this)).send();
        AppUpdateManager upd = new AppUpdateManager(DrawerActivity.this);
        upd.deleteOldApk();
        new Thread(upd::showDialogReleaseChangelog).start();
    }
    AppData.saveAppVersion(this, BuildConfig.VERSION_NAME);
}
Also used : Analytics(com.giua.app.Analytics) AppUpdateManager(com.giua.app.AppUpdateManager) GiuaScraperThread(com.giua.app.GiuaScraperThread)

Example 3 with AppUpdateManager

use of com.giua.app.AppUpdateManager 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 4 with AppUpdateManager

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

the class HomeFragment method updateReminderOnClick.

private void updateReminderOnClick(View view) {
    loggerManager.d("Aggiornamento app richiesto dall'utente tramite Home");
    new Thread(() -> new AppUpdateManager(activity).startUpdateDialog()).start();
}
Also used : AppUpdateManager(com.giua.app.AppUpdateManager)

Example 5 with AppUpdateManager

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

the class HomeFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.fragment_home, container, false);
    activity = requireActivity();
    loggerManager = new LoggerManager("HomeFragment", activity);
    contentLayout = root.findViewById(R.id.home_content_layout);
    tvHomeworks = root.findViewById(R.id.home_txt_homeworks);
    tvTests = root.findViewById(R.id.home_txt_tests);
    swipeRefreshLayout = root.findViewById(R.id.home_swipe_refresh_layout);
    txUserInfo = root.findViewById(R.id.home_user_info);
    allCharts = new Vector<>(4);
    allCharts.add(new HomeChartView(activity));
    ((LinearLayout) allCharts.get(0).findViewById(R.id.view_home_main_layout)).addView(createArrowIconForChart(), 0);
    contentLayout.addView(allCharts.get(0));
    allCharts.get(0).setOnClickListener(this::mainChartOnClick);
    root.findViewById(R.id.home_agenda_alerts).setOnClickListener(this::agendaAlertsOnClick);
    swipeRefreshLayout.setRefreshing(true);
    swipeRefreshLayout.setOnRefreshListener(this::onRefresh);
    offlineMode = activity.getIntent().getBooleanExtra("offline", false);
    addVoteNotRelevantForMean = SettingsData.getSettingBoolean(activity, SettingKey.VOTE_NRFM_ON_CHART);
    new Thread(() -> {
        if (offlineMode) {
            activity.runOnUiThread(() -> txUserInfo.setText("Accesso eseguito in modalità Offline"));
        } else {
            String userType = GlobalVariables.gS.getUserTypeString();
            activity.runOnUiThread(() -> txUserInfo.setText("Accesso eseguito nell'account " + GlobalVariables.gS.getUser() + " (" + userType + ")"));
        }
        AppUpdateManager manager = new AppUpdateManager(activity);
        if (manager.checkForUpdates()) {
            activity.runOnUiThread(() -> {
                loggerManager.d("Rendo visibile avviso su home dell'aggiornamento");
                root.findViewById(R.id.home_app_update_reminder).setVisibility(View.VISIBLE);
                root.findViewById(R.id.home_app_update_reminder).setOnClickListener(this::updateReminderOnClick);
            });
        }
    }).start();
    return root;
}
Also used : LoggerManager(com.giua.app.LoggerManager) LinearLayout(android.widget.LinearLayout) AppUpdateManager(com.giua.app.AppUpdateManager) Nullable(androidx.annotation.Nullable)

Aggregations

AppUpdateManager (com.giua.app.AppUpdateManager)5 Analytics (com.giua.app.Analytics)3 Nullable (androidx.annotation.Nullable)2 GiuaScraperThread (com.giua.app.GiuaScraperThread)2 LoggerManager (com.giua.app.LoggerManager)2 Context (android.content.Context)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Html (android.text.Html)1 SpannableString (android.text.SpannableString)1 LinkMovementMethod (android.text.method.LinkMovementMethod)1 Linkify (android.text.util.Linkify)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 ConvenienceBuilder (com.danielstone.materialaboutlibrary.ConvenienceBuilder)1 MaterialAboutActivity (com.danielstone.materialaboutlibrary.MaterialAboutActivity)1 MaterialAboutActionItem (com.danielstone.materialaboutlibrary.items.MaterialAboutActionItem)1 MaterialAboutTitleItem (com.danielstone.materialaboutlibrary.items.MaterialAboutTitleItem)1