diff options
author | cyBerta <cyberta@riseup.net> | 2018-02-25 23:04:10 +0100 |
---|---|---|
committer | cyBerta <cyberta@riseup.net> | 2018-02-28 01:45:41 +0100 |
commit | 30244cbf5b7eaf6152bcdc2cb5b6848f6e10798d (patch) | |
tree | ca610798a01a202fff04d5ad16b3caf43c8494cb /app/src/main/java/se/leap/bitmaskclient/fragments | |
parent | 62e36ee804262be866946ca467f7abeb2746add4 (diff) |
#8808 add dialog for always-on vpn infos
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/fragments')
-rw-r--r-- | app/src/main/java/se/leap/bitmaskclient/fragments/AlwaysOnDialog.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/fragments/AlwaysOnDialog.java b/app/src/main/java/se/leap/bitmaskclient/fragments/AlwaysOnDialog.java new file mode 100644 index 00000000..80510b86 --- /dev/null +++ b/app/src/main/java/se/leap/bitmaskclient/fragments/AlwaysOnDialog.java @@ -0,0 +1,67 @@ +package se.leap.bitmaskclient.fragments; + +import android.app.Dialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatDialogFragment; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.CheckBox; + +import butterknife.ButterKnife; +import butterknife.InjectView; +import se.leap.bitmaskclient.R; + +import static se.leap.bitmaskclient.ConfigHelper.saveShowAlwaysOnDialog; + +/** + * Created by cyberta on 25.02.18. + */ + + + +public class AlwaysOnDialog extends AppCompatDialogFragment { + + public final static String TAG = AlwaysOnDialog.class.getName(); + + @InjectView(R.id.do_not_show_again) + CheckBox doNotShowAgainCheckBox; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + LayoutInflater inflater = getActivity().getLayoutInflater(); + View view = inflater.inflate(R.layout.checkbox_confirm_dialog, null); + ButterKnife.inject(this, view); + + builder.setView(view) + .setMessage(R.string.always_on_vpn_user_message) + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + if (doNotShowAgainCheckBox.isChecked()) { + saveShowAlwaysOnDialog(getContext(), false); + } + Intent intent = new Intent("android.net.vpn.SETTINGS"); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + }) + .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }); + // Create the AlertDialog object and return it + return builder.create(); + } +} |