Skip to content

Commit

Permalink
Updating Android SDK to version 8.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
radixdev committed May 20, 2020
1 parent de5ba8d commit dd2994c
Show file tree
Hide file tree
Showing 52 changed files with 578 additions and 611 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 8.0.1

[Release Date](https://github.com/Appboy/appboy-android-sdk/releases/tag/v8.0.1)

##### Fixed
- Fixed an Activity resolution issue in `com.appboy.ui.AppboyWebViewActivity` by removing a call to `setDownloadListener()`.
- Fixed an implementation issue in 8.0.0 related to setting runtime configuration after stopping the SDK.

## 8.0.0

[Release Date](https://github.com/Appboy/appboy-android-sdk/releases/tag/v8.0.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package com.appboy.ui;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.WindowManager;
import android.webkit.DownloadListener;
import android.webkit.ConsoleMessage;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;

import com.appboy.Constants;
import com.appboy.enums.Channel;
Expand All @@ -41,29 +39,30 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.com_appboy_webview_activity);

WebView webView = findViewById(R.id.com_appboy_webview_activity_webview);
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

WebSettings webSettings = webView.getSettings();
// JavaScript is enabled by default to support a larger number of web pages. If JavaScript support is not
// necessary, then it should be disabled.
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowFileAccess(false);
// Plugin support is disabled by default. If plugins, such as flash, are required, change the PluginState.
webSettings.setPluginState(WebSettings.PluginState.OFF);
webSettings.setDisplayZoomControls(false);

webSettings.setBuiltInZoomControls(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setDisplayZoomControls(false);
webSettings.setDomStorageEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && ViewUtils.isDeviceInNightMode(this.getApplicationContext())) {
webSettings.setForceDark(WebSettings.FORCE_DARK_ON);
}

// Instruct webview to be as large as its parent view.
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
webView.setLayoutParams(layoutParams);

webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onConsoleMessage(ConsoleMessage cm) {
AppboyLogger.d(TAG, "Braze WebView Activity log. Line: " + cm.lineNumber()
+ ". SourceId: " + cm.sourceId()
+ ". Log Level: " + cm.messageLevel()
+ ". Message: " + cm.message());
return true;
}

@Nullable
@Override
public Bitmap getDefaultVideoPoster() {
Expand All @@ -73,19 +72,6 @@ public Bitmap getDefaultVideoPoster() {
}
});

webView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
});

webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Expand All @@ -95,15 +81,19 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
// for example, redirects to the play store via a "store://" Uri.
if (!AppboyFileUtils.REMOTE_SCHEMES.contains(Uri.parse(url).getScheme())) {
IAction action = ActionFactory.createUriActionFromUrlString(url, getIntent().getExtras(), false, Channel.UNKNOWN);
// Instead of using AppboyNavigator, just open directly.
action.execute(view.getContext());
if (action != null) {
// Instead of using AppboyNavigator, just open directly.
action.execute(view.getContext());

// Close the WebView if the action was executed successfully
finish();
return true;
// Close the WebView if the action was executed successfully
finish();
return true;
} else {
return false;
}
}
} catch (Exception e) {
AppboyLogger.i(TAG, "Unexpected exception while processing url " + url + ". Passing url back to WebView.", e);
AppboyLogger.e(TAG, "Unexpected exception while processing url " + url + ". Passing url back to WebView.", e);
}
return super.shouldOverrideUrlLoading(view, url);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.appboy.enums.Channel;
import com.appboy.support.StringUtils;
Expand All @@ -12,6 +13,7 @@ public class ActionFactory {
* Convenience method for creating {@link UriAction} instances. Returns null if the supplied url
* is null, blank, or can not be parsed into a valid Uri.
*/
@Nullable
public static UriAction createUriActionFromUrlString(String url, Bundle extras, boolean openInWebView, Channel channel) {
if (!StringUtils.isNullOrBlank(url)) {
Uri uri = Uri.parse(url);
Expand All @@ -24,6 +26,7 @@ public static UriAction createUriActionFromUrlString(String url, Bundle extras,
* Convenience method for creating {@link UriAction} instances. Returns null if the supplied uri
* is null.
*/
@Nullable
public static UriAction createUriActionFromUri(Uri uri, Bundle extras, boolean openInWebView, Channel channel) {
if (uri != null) {
return new UriAction(uri, extras, openInWebView, channel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public WebView getMessageWebView() {
if (mMessageWebView != null) {
WebSettings webSettings = mMessageWebView.getSettings();
webSettings.setJavaScriptEnabled(true);

webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setDisplayZoomControls(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
android:layout_height="match_parent">

<WebView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/com_appboy_webview_activity_webview"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
</RelativeLayout>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ext {
buildToolsVersion = '29.0.0'
minSdkVersion = 16
targetSdkVersion = 29
appVersionName = '8.0.0'
appVersionName = '8.0.1'
}

subprojects {
Expand All @@ -33,5 +33,5 @@ subprojects {
}

group = 'com.appboy'
version = '8.0.0'
version = '8.0.1'
}
5 changes: 2 additions & 3 deletions droidboy/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:name=".DroidboyApplication"
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher_droidboy"
android:icon="@mipmap/ic_launcher_droidboy"
android:label="@string/app_name"
android:theme="@style/Theme.Droidboy"
android:usesCleartextTraffic="true">
Expand Down Expand Up @@ -53,8 +53,7 @@

<activity
android:name=".activity.DroidBoyActivity"
android:icon="@drawable/ic_launcher_droidboy"
android:label="@string/droid_boy"
android:icon="@mipmap/ic_launcher_droidboy"
android:windowSoftInputMode="stateUnchanged">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Loading

0 comments on commit dd2994c

Please sign in to comment.