summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/android/ConfigDetailFragment.java
blob: d6c02935a04fff6eb663b2500455c5fc541dc74d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.wireguard.android;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wireguard.android.databinding.ConfigDetailFragmentBinding;
import com.wireguard.config.Config;

/**
 * Fragment for viewing information about a WireGuard configuration.
 */

public class ConfigDetailFragment extends BaseConfigFragment {
    private ConfigDetailFragmentBinding binding;

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);
    }

    @Override
    public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
        inflater.inflate(R.menu.config_detail, menu);
    }

    @Override
    public View onCreateView(final LayoutInflater inflater, final ViewGroup parent,
                             final Bundle savedInstanceState) {
        binding = ConfigDetailFragmentBinding.inflate(inflater, parent, false);
        binding.setConfig(getCurrentConfig());
        return binding.getRoot();
    }

    @Override
    protected void onCurrentConfigChanged(final Config config) {
        if (binding != null)
            binding.setConfig(config);
    }
}