Skip to content

Commit

Permalink
Fixed ObjectiveC APIDemo custom playback controls issue.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 676606721
  • Loading branch information
nventimigli authored and copybara-github committed Oct 11, 2024
1 parent 6908d41 commit 9b71e1b
Show file tree
Hide file tree
Showing 19 changed files with 261 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
1CD352992C9CE6A600534FCC /* CustomControls.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1CD352982C9CE6A600534FCC /* CustomControls.xib */; };
4A96E7211B856D5000031470 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A96E7201B856D5000031470 /* main.m */; };
4A96E7241B856D5000031470 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A96E7231B856D5000031470 /* AppDelegate.m */; };
4A96E72D1B856D5000031470 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A96E72B1B856D5000031470 /* Main.storyboard */; };
Expand All @@ -32,6 +33,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1CD352982C9CE6A600534FCC /* CustomControls.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CustomControls.xib; sourceTree = "<group>"; };
4A96E71B1B856D5000031470 /* APIDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = APIDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
4A96E71F1B856D5000031470 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4A96E7201B856D5000031470 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -169,6 +171,7 @@
AEE8DA9A201BD788008792E6 /* GAMCustomVideoControls */ = {
isa = PBXGroup;
children = (
1CD352982C9CE6A600534FCC /* CustomControls.xib */,
50DC0CEA212F1C2D00424CC7 /* GAMCustomVideoControlsController.h */,
50DC0CEB212F1C2D00424CC7 /* GAMCustomVideoControlsController.m */,
AEE8DA9C201BD7A5008792E6 /* SimpleNativeAdView.h */,
Expand Down Expand Up @@ -243,6 +246,7 @@
4A96E72D1B856D5000031470 /* Main.storyboard in Resources */,
4A96E7321B856D5000031470 /* LaunchScreen.xib in Resources */,
4A96E72F1B856D5000031470 /* Images.xcassets in Resources */,
1CD352992C9CE6A600534FCC /* CustomControls.xib in Resources */,
AED1111020320CA900EA4BEE /* NativeAdView.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
99 changes: 17 additions & 82 deletions Objective-C/advanced/APIDemo/APIDemo/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<rect key="frame" x="318" y="229" width="47" height="34"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<state key="normal" title="Install">
<color key="titleColor" red="0.016804177310000001" green="0.19835099580000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
Expand Down Expand Up @@ -104,13 +105,13 @@
<constraint firstItem="beR-eV-DX1" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="Mvs-eV-Wzb"/>
<constraint firstItem="Ysb-of-cat" firstAttribute="centerY" secondItem="hwF-UL-Q8H" secondAttribute="centerY" id="Rud-i8-Myz"/>
<constraint firstItem="fNp-yu-K4i" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="TYN-lq-3DK"/>
<constraint firstItem="Ysb-of-cat" firstAttribute="top" secondItem="fNp-yu-K4i" secondAttribute="bottom" constant="15.5" id="TwW-Pe-AvQ"/>
<constraint firstItem="fNp-yu-K4i" firstAttribute="top" secondItem="PEQ-D9-2Vv" secondAttribute="bottom" constant="5" id="V0m-hf-6NS"/>
<constraint firstItem="GTT-Yh-eSq" firstAttribute="centerY" secondItem="2Of-AP-0h9" secondAttribute="centerY" id="YgR-kp-age"/>
<constraint firstItem="hwF-UL-Q8H" firstAttribute="leading" secondItem="Ysb-of-cat" secondAttribute="trailing" constant="10" id="aLb-sm-wAb"/>
<constraint firstAttribute="right" relation="greaterThanOrEqual" secondItem="lp1-oz-XOs" secondAttribute="right" constant="20" symbolic="YES" id="czi-qD-IaJ"/>
<constraint firstAttribute="trailing" secondItem="E5w-YA-UY8" secondAttribute="trailing" constant="10" id="eNM-dN-tvx"/>
<constraint firstItem="E5w-YA-UY8" firstAttribute="leading" secondItem="hwF-UL-Q8H" secondAttribute="trailing" constant="10" id="f39-vH-KWq"/>
<constraint firstItem="Ysb-of-cat" firstAttribute="top" secondItem="fNp-yu-K4i" secondAttribute="bottom" constant="15.5" id="g05-rC-22O"/>
<constraint firstItem="iNa-bH-h1m" firstAttribute="leading" secondItem="PEQ-D9-2Vv" secondAttribute="leading" id="mof-5F-8vM"/>
<constraint firstItem="E5w-YA-UY8" firstAttribute="centerY" secondItem="hwF-UL-Q8H" secondAttribute="centerY" id="rNj-VY-YrO"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="E5w-YA-UY8" secondAttribute="bottom" constant="20" symbolic="YES" id="uEI-XT-igi"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23089" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23077"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand All @@ -19,11 +16,11 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="375" placeholderIntrinsicHeight="24" text="Headline" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EJ7-Y2-nrO">
<rect key="frame" x="5" y="5" width="365" height="24"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hoj-tc-K51">
<rect key="frame" x="101.5" y="39" width="171" height="100"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hoj-tc-K51" customClass="NativeAdView" customModule="APIDemo" customModuleProvider="target">
<rect key="frame" x="102" y="39" width="171" height="100"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="100" id="Z4E-2z-qz3"/>
Expand All @@ -33,7 +30,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Caption" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Opb-BT-xiP">
<rect key="frame" x="5" y="149" width="365" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="textColor" systemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand All @@ -49,11 +46,16 @@
<constraint firstAttribute="trailing" secondItem="Opb-BT-xiP" secondAttribute="trailing" constant="5" id="WYZ-v6-Hph"/>
</constraints>
<connections>
<outlet property="captionView" destination="Opb-BT-xiP" id="hSg-rU-Z7U"/>
<outlet property="headlineView" destination="EJ7-Y2-nrO" id="BKi-kL-8EA"/>
<outlet property="mainPlaceholder" destination="hoj-tc-K51" id="pmf-nl-x4R"/>
<outlet property="captionView" destination="Opb-BT-xiP" id="JQy-dl-IMG"/>
<outlet property="headlineView" destination="EJ7-Y2-nrO" id="dDU-Lq-0zL"/>
<outlet property="mainPlaceholder" destination="hoj-tc-K51" id="Rho-nb-5UT"/>
</connections>
<point key="canvasLocation" x="13" y="27"/>
<point key="canvasLocation" x="20.800000000000001" y="24.287856071964018"/>
</view>
</objects>
<resources>
<systemColor name="darkTextColor">
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
63 changes: 63 additions & 0 deletions Objective-C/advanced/APIDemo/APIDemo/CustomControls.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23089" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23077"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clipsSubviews="YES" contentMode="scaleToFill" placeholderIntrinsicWidth="63" placeholderIntrinsicHeight="34" translatesAutoresizingMaskIntoConstraints="NO" id="hcJ-K0-VFO" customClass="CustomControlsView">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" placeholderIntrinsicWidth="63" placeholderIntrinsicHeight="34" translatesAutoresizingMaskIntoConstraints="NO" id="pao-J4-Vnr" userLabel="Controls Inner View">
<rect key="frame" x="0.0" y="0.0" width="63" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleAspectFit" fixedFrame="YES" preservesSuperviewLayoutMargins="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="45d-iM-MBo">
<rect key="frame" x="5" y="5" width="24" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" button="YES" image="YES"/>
</accessibility>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="video_pause"/>
<connections>
<action selector="playPause:" destination="hcJ-K0-VFO" eventType="touchUpInside" id="0CB-eL-LvM"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFit" fixedFrame="YES" preservesSuperviewLayoutMargins="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EeV-x8-pU7">
<rect key="frame" x="34" y="5" width="24" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" button="YES" image="YES"/>
</accessibility>
<state key="normal" image="video_mute"/>
<connections>
<action selector="muteUnmute:" destination="hcJ-K0-VFO" eventType="touchUpInside" id="WHq-Bk-O5c"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.79650297619047616" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="34" id="UmE-7W-Sbr"/>
<constraint firstAttribute="width" constant="63" id="nll-Ck-Ktr"/>
</constraints>
<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
<connections>
<outlet property="controlsView" destination="pao-J4-Vnr" id="u9k-TG-zXG"/>
<outlet property="muteButton" destination="EeV-x8-pU7" id="3ms-b3-3dN"/>
<outlet property="playButton" destination="45d-iM-MBo" id="3aL-mq-Onh"/>
</connections>
<point key="canvasLocation" x="-180" y="-635"/>
</view>
</objects>
<resources>
<image name="video_mute" width="96" height="96"/>
<image name="video_pause" width="96" height="96"/>
</resources>
</document>
26 changes: 11 additions & 15 deletions Objective-C/advanced/APIDemo/APIDemo/CustomControlsView.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
// Copyright 2024 Google LLC
//
// Copyright (C) 2018 Google, Inc.
//
// CustomControlsView.h
// APIDemo
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <UIKit/UIKit.h>

/// A custom view which encapsulates the display of video controller related information and also
/// custom video controls. Set the video options when requesting an ad, then set the video
/// controller when the ad is received.
@interface CustomControlsView : UIView<GADVideoControllerDelegate>
@interface CustomControlsView : UIView <GADVideoControllerDelegate>

/// Resets the controls status, and lets the controls view know the initial mute state.
- (void)resetWithStartMuted:(BOOL)startMuted;
Expand Down
Loading

0 comments on commit 9b71e1b

Please sign in to comment.