1 /* 2 * Copyright (C) 2016 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.cts.documentprovider; 18 19 import android.app.Activity; 20 import android.app.AlertDialog.Builder; 21 import android.app.AlertDialog; 22 import android.content.DialogInterface; 23 import android.content.Intent; 24 import android.net.Uri; 25 import android.os.Bundle; 26 27 public class WebLinkActivity extends Activity { 28 public static final String EXTRA_DOCUMENT_ID = 29 "com.android.cts.documentprovider.EXTRA_DOCUMENT_ID"; 30 private static final Uri FAKE_WEB_LINK = Uri.parse( 31 "http://www.foobar.com/shared/SW33TCH3RR13S"); 32 33 @Override onCreate(Bundle savedInstanceState)34 protected void onCreate(Bundle savedInstanceState) { 35 super.onCreate(savedInstanceState); 36 37 final String documentId = getIntent().getStringExtra(EXTRA_DOCUMENT_ID); 38 final String email = getIntent().getStringExtra(Intent.EXTRA_EMAIL); 39 40 new AlertDialog.Builder(this) 41 .setTitle("Grant permissions to this file to " + email + "?") 42 .setMessage(documentId) 43 .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { 44 public void onClick(DialogInterface dialog, int which) { 45 final Intent intent = new Intent(); 46 intent.setData(FAKE_WEB_LINK); 47 setResult(RESULT_OK, intent); 48 finish(); 49 } 50 }) 51 .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { 52 public void onClick(DialogInterface dialog, int which) { 53 setResult(RESULT_CANCELED, null); 54 finish(); 55 } 56 }) 57 .setIcon(android.R.drawable.ic_dialog_alert) 58 .show(); 59 } 60 } 61