1 /* 2 * Copyright 2018 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.example.android.support.wear.app; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.view.View; 22 import android.view.ViewGroup; 23 import android.widget.Button; 24 25 import androidx.wear.widget.ConfirmationOverlay; 26 27 import com.example.android.support.wear.R; 28 29 /** Main activity for the ConfirmationOverlay demo. */ 30 public class ConfirmationOverlayDemo extends Activity { 31 32 @Override onCreate(Bundle savedInstanceState)33 protected void onCreate(Bundle savedInstanceState) { 34 super.onCreate(savedInstanceState); 35 setContentView(R.layout.confirmation_overlay_demo); 36 final ViewGroup content = findViewById(R.id.content); 37 final ConfirmationOverlay overlay = new ConfirmationOverlay(); 38 39 Button activityTrigger = findViewById(R.id.activity_overlay_button); 40 activityTrigger.setOnClickListener(new View.OnClickListener() { 41 @Override 42 public void onClick(View v) { 43 overlay.showOn(ConfirmationOverlayDemo.this); 44 } 45 }); 46 47 Button viewTrigger = findViewById(R.id.view_overlay_button); 48 viewTrigger.setOnClickListener(new View.OnClickListener() { 49 @Override 50 public void onClick(View v) { 51 overlay.showAbove(content); 52 } 53 }); 54 } 55 } 56