summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/android/ConfigAddActivity.java
blob: f299a67c346ecf20c15e3099e3e447bec4000cfc (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
package com.wireguard.android;

import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;

import com.wireguard.config.Config;

/**
 * Standalone activity for creating configurations.
 */

public class ConfigAddActivity extends BaseConfigActivity {
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.config_add_activity);
    }

    @Override
    protected void onCurrentConfigChanged(final Config config) {
        // This is the result of ConfigEditFragment signalling that a configuration was created.
        if (config != null)
            finish();
    }

    @Override
    protected void onServiceAvailable() {
        super.onServiceAvailable();
        final FragmentManager fm = getFragmentManager();
        if (fm.findFragmentById(R.id.master_fragment) == null) {
            final FragmentTransaction transaction = fm.beginTransaction();
            transaction.add(R.id.master_fragment, new ConfigEditFragment());
            transaction.commit();
        }
    }
}