-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add news/game template checking to request agent. * Remove gma framework from example ios project
- Loading branch information
Showing
20 changed files
with
413 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...android/src/main/java/io/flutter/plugins/googlemobileads/FlutterRequestAgentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.flutter.plugins.googlemobileads; | ||
|
||
import android.content.Context; | ||
import android.content.pm.ApplicationInfo; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.PackageManager.NameNotFoundException; | ||
import android.os.Bundle; | ||
import androidx.annotation.Nullable; | ||
|
||
/** Class that helps detect whether the news or game template is being used. */ | ||
class FlutterRequestAgentProvider { | ||
|
||
static final String GAME_VERSION_KEY = | ||
"io.flutter.plugins.googlemobileads.FLUTTER_GAME_TEMPLATE_VERSION"; | ||
static final String NEWS_VERSION_KEY = | ||
"io.flutter.plugins.googlemobileads.FLUTTER_NEWS_TEMPLATE_VERSION"; | ||
|
||
private final Context context; | ||
@Nullable private String newsTemplateVersion; | ||
@Nullable private String gameTemplateVersion; | ||
|
||
FlutterRequestAgentProvider(Context context) { | ||
this.context = context; | ||
processGameAndNewsTemplateVersions(context); | ||
} | ||
|
||
private void processGameAndNewsTemplateVersions(Context context) { | ||
try { | ||
ApplicationInfo info = | ||
context | ||
.getApplicationContext() | ||
.getPackageManager() | ||
.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); | ||
Bundle metaData = info.metaData; | ||
if (metaData != null) { | ||
gameTemplateVersion = info.metaData.getString(GAME_VERSION_KEY); | ||
newsTemplateVersion = info.metaData.getString(NEWS_VERSION_KEY); | ||
} | ||
} catch (NameNotFoundException | ClassCastException e) { | ||
// Do nothing | ||
} | ||
} | ||
|
||
String getRequestAgent() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(Constants.REQUEST_AGENT_PREFIX_VERSIONED); | ||
if (newsTemplateVersion != null) { | ||
sb.append("_"); | ||
sb.append(Constants.REQUEST_AGENT_NEWS_TEMPLATE_PREFIX); | ||
sb.append("-"); | ||
sb.append(newsTemplateVersion); | ||
} | ||
if (gameTemplateVersion != null) { | ||
sb.append("_"); | ||
sb.append(Constants.REQUEST_AGENT_GAME_TEMPLATE_PREFIX); | ||
sb.append("-"); | ||
sb.append(gameTemplateVersion); | ||
} | ||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.