package com.example.onetap_ssh.fragment;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.onetap_ssh.R;
import com.example.onetap_ssh.databinding.FragmentAboutBinding;

public class AboutFragment extends NamedFragment {

    @Override
    public String getName() {
        return requireActivity().getString(R.string.fragment_about);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        FragmentAboutBinding binding = FragmentAboutBinding.inflate(inflater);
        try {
            PackageManager manager = requireContext().getPackageManager();
            PackageInfo info = manager.getPackageInfo(requireContext().getPackageName(), 0);
            String version = info.versionName;
            binding.appVersion.setText(version);
        } catch (PackageManager.NameNotFoundException ignored) {}
        return binding.getRoot();
    }
}
