Home | History | Annotate | Download | only in managedprovisioning
      1 /*
      2  * Copyright 2014, The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.managedprovisioning;
     18 
     19 import android.app.Activity;
     20 import android.app.AlertDialog;
     21 import android.app.Dialog;
     22 import android.app.DialogFragment;
     23 import android.content.DialogInterface;
     24 import android.os.Bundle;
     25 
     26 /**
     27  * Dialog used to notify the user that the managed provisioning failed, and shutdown the current
     28  * activity.
     29  *
     30  * Note: You should not do any more work in your app after showing this dialog. See guidelines for
     31  * {@code Activity#finish()} method call.
     32  */
     33 public class ManagedProvisioningErrorDialog extends DialogFragment {
     34 
     35   private final String message;
     36 
     37   public ManagedProvisioningErrorDialog(String message) {
     38       super();
     39       this.message = message;
     40   }
     41 
     42   @Override
     43   public Dialog onCreateDialog(Bundle savedInstanceState) {
     44       // TODO: This disappears when you rotate, fix it when we refactor the app
     45 
     46       AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
     47       // TODO: Get strings from PM.
     48       alertDialogBuilder.setTitle(R.string.provisioning_error_title)
     49               .setMessage(message)
     50               .setCancelable(false)
     51               .setPositiveButton("OK", new DialogInterface.OnClickListener() {
     52                         @Override
     53                         public void onClick(DialogInterface dialog,int id) {
     54                             // Close activity
     55                             getActivity().setResult(Activity.RESULT_CANCELED);
     56                             getActivity().finish();
     57                       }});
     58       return alertDialogBuilder.create();
     59   }
     60 }
     61