Search in sources :

Example 1 with ChangelogBottomSheet

use of xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.ChangelogBottomSheet in project grocy-android by patzly.

the class OverviewStartFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    activity = (MainActivity) requireActivity();
    viewModel = new ViewModelProvider(this).get(OverviewStartViewModel.class);
    viewModel.setOfflineLive(!activity.isOnline());
    binding.setViewModel(viewModel);
    binding.setFragment(this);
    binding.setActivity(activity);
    binding.setLifecycleOwner(getViewLifecycleOwner());
    clickUtil = new ClickUtil(1000);
    viewModel.getIsLoadingLive().observe(getViewLifecycleOwner(), state -> {
        if (!state) {
            viewModel.setCurrentQueueLoading(null);
        }
    });
    viewModel.getEventHandler().observeEvent(getViewLifecycleOwner(), event -> {
        if (event.getType() == Event.SNACKBAR_MESSAGE) {
            activity.showSnackbar(((SnackbarMessage) event).getSnackbar(activity, activity.binding.frameMainContainer));
        }
    });
    infoFullscreenHelper = new InfoFullscreenHelper(binding.frameContainer);
    viewModel.getInfoFullscreenLive().observe(getViewLifecycleOwner(), infoFullscreen -> infoFullscreenHelper.setInfo(infoFullscreen));
    viewModel.getOfflineLive().observe(getViewLifecycleOwner(), this::appBarOfflineInfo);
    binding.toolbar.setOnMenuItemClickListener(item -> {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            navigateDeepLink(getString(R.string.deep_link_settingsFragment));
        } else if (id == R.id.action_about) {
            navigateDeepLink(getString(R.string.deep_link_aboutFragment));
        } else if (id == R.id.action_feedback) {
            activity.showBottomSheet(new FeedbackBottomSheet());
        } else if (id == R.id.action_changelog) {
            activity.showBottomSheet(new ChangelogBottomSheet());
        }
        return false;
    });
    // for offline info in app bar
    binding.swipe.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
    if (savedInstanceState == null) {
        viewModel.loadFromDatabase(true);
    }
    // UPDATE UI
    updateUI((getArguments() == null || getArguments().getBoolean(Constants.ARGUMENT.ANIMATED, true)) && savedInstanceState == null);
}
Also used : ChangelogBottomSheet(xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.ChangelogBottomSheet) OverviewStartViewModel(xyz.zedler.patrick.grocy.viewmodel.OverviewStartViewModel) ClickUtil(xyz.zedler.patrick.grocy.util.ClickUtil) FeedbackBottomSheet(xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.FeedbackBottomSheet) InfoFullscreenHelper(xyz.zedler.patrick.grocy.helper.InfoFullscreenHelper) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Example 2 with ChangelogBottomSheet

use of xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.ChangelogBottomSheet in project grocy-android by patzly.

the class AboutFragment method onClick.

@Override
public void onClick(View v) {
    if (clickUtil.isDisabled()) {
        return;
    }
    if (v.getId() == R.id.linear_intro) {
        ViewUtil.startIcon(binding.imageIntro);
        navigate(R.id.onboardingFragment);
    } else if (v.getId() == R.id.linear_changelog) {
        ViewUtil.startIcon(binding.imageChangelog);
        activity.showBottomSheet(new ChangelogBottomSheet());
    } else if (v.getId() == R.id.linear_developers) {
        ViewUtil.startIcon(binding.imageDevelopers);
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_developer))));
    } else if (v.getId() == R.id.linear_github) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_github))));
    } else if (v.getId() == R.id.linear_license_conscrypt) {
        ViewUtil.startIcon(binding.imageLicenseConscrypt);
        showTextBottomSheet(R.raw.license_apache, R.string.license_conscrypt, R.string.url_conscrypt);
    } else if (v.getId() == R.id.linear_license_fuzzywuzzy) {
        ViewUtil.startIcon(binding.imageLicenseFuzzywuzzy);
        showTextBottomSheet(R.raw.license_gpl, R.string.license_fuzzywuzzy, R.string.url_fuzzywuzzy);
    } else if (v.getId() == R.id.linear_license_gson) {
        ViewUtil.startIcon(binding.imageLicenseGson);
        showTextBottomSheet(R.raw.license_apache, R.string.license_gson, R.string.url_gson);
    } else if (v.getId() == R.id.linear_license_jost) {
        ViewUtil.startIcon(binding.imageLicenseJost);
        showTextBottomSheet(R.raw.license_ofl, R.string.license_jost, R.string.url_jost);
    } else if (v.getId() == R.id.linear_license_material_components) {
        ViewUtil.startIcon(binding.imageLicenseMaterialComponents);
        showTextBottomSheet(R.raw.license_apache, R.string.license_material_components, R.string.url_material_components);
    } else if (v.getId() == R.id.linear_license_material_icons) {
        ViewUtil.startIcon(binding.imageLicenseMaterialIcons);
        showTextBottomSheet(R.raw.license_apache, R.string.license_material_icons, R.string.url_material_icons);
    } else if (v.getId() == R.id.linear_license_netcipher) {
        ViewUtil.startIcon(binding.imageLicenseNetcipher);
        showTextBottomSheet(R.raw.license_apache, R.string.license_netcipher, R.string.url_netcipher);
    } else if (v.getId() == R.id.linear_license_volley) {
        ViewUtil.startIcon(binding.imageLicenseVolley);
        showTextBottomSheet(R.raw.license_apache, R.string.license_volley, R.string.url_volley);
    } else if (v.getId() == R.id.linear_license_xzing_android) {
        ViewUtil.startIcon(binding.imageLicenseXzingAndroid);
        showTextBottomSheet(R.raw.license_apache, R.string.license_xzing_android, R.string.url_zxing_android);
    }
}
Also used : ChangelogBottomSheet(xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.ChangelogBottomSheet) Intent(android.content.Intent)

Aggregations

ChangelogBottomSheet (xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.ChangelogBottomSheet)2 Intent (android.content.Intent)1 ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 FeedbackBottomSheet (xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.FeedbackBottomSheet)1 InfoFullscreenHelper (xyz.zedler.patrick.grocy.helper.InfoFullscreenHelper)1 ClickUtil (xyz.zedler.patrick.grocy.util.ClickUtil)1 OverviewStartViewModel (xyz.zedler.patrick.grocy.viewmodel.OverviewStartViewModel)1