blob: 080eecae9197b02f0d385b3d7c2746abe4e32146 (
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
45
46
|
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 AddActivity extends BaseConfigActivity {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_activity);
}
@Override
protected void onCurrentConfigChanged(final Config config) {
// Do nothing (this never happens).
}
@Override
protected void onEditingStateChanged(final boolean isEditing) {
// Go back to the main activity once the new configuration is created.
if (!isEditing)
finish();
}
@Override
protected void onServiceAvailable() {
super.onServiceAvailable();
final FragmentManager fm = getFragmentManager();
ConfigEditFragment fragment = (ConfigEditFragment) fm.findFragmentById(R.id.master_fragment);
if (fragment == null) {
fragment = new ConfigEditFragment();
final FragmentTransaction transaction = fm.beginTransaction();
transaction.add(R.id.master_fragment, fragment);
transaction.commit();
}
// Prime the state for the fragment to tell us it is finished.
setIsEditing(true);
}
}
|