2017-08-16 00:36:11 +02:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2017-08-22 08:27:29 +02:00
|
|
|
public class AddActivity extends BaseConfigActivity {
|
2017-08-16 00:36:11 +02:00
|
|
|
@Override
|
|
|
|
public void onCreate(final Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
2017-08-22 08:27:29 +02:00
|
|
|
setContentView(R.layout.add_activity);
|
2017-08-16 00:36:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCurrentConfigChanged(final Config config) {
|
2017-08-24 08:27:56 +02:00
|
|
|
// 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)
|
2017-08-16 00:36:11 +02:00
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onServiceAvailable() {
|
|
|
|
super.onServiceAvailable();
|
|
|
|
final FragmentManager fm = getFragmentManager();
|
2017-08-24 08:27:56 +02:00
|
|
|
ConfigEditFragment fragment = (ConfigEditFragment) fm.findFragmentById(R.id.master_fragment);
|
|
|
|
if (fragment == null) {
|
|
|
|
fragment = new ConfigEditFragment();
|
2017-08-16 00:36:11 +02:00
|
|
|
final FragmentTransaction transaction = fm.beginTransaction();
|
2017-08-24 08:27:56 +02:00
|
|
|
transaction.add(R.id.master_fragment, fragment);
|
2017-08-16 00:36:11 +02:00
|
|
|
transaction.commit();
|
|
|
|
}
|
2017-08-24 08:27:56 +02:00
|
|
|
// Prime the state for the fragment to tell us it is finished.
|
|
|
|
setIsEditing(true);
|
2017-08-16 00:36:11 +02:00
|
|
|
}
|
|
|
|
}
|