fix AdView
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:ads="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
tools:ignore="UnknownIdInLayout" android:clipChildren="false">
|
||||
<include layout="@layout/toolbar_light_dark" />
|
||||
<com.google.android.gms.ads.AdView
|
||||
android:id="@+id/adView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/toolbar"
|
||||
ads:adSize="SMART_BANNER"
|
||||
ads:adUnitId="ca-app-pub-9097031975646651/7760346322">
|
||||
</com.google.android.gms.ads.AdView>
|
||||
<fragment android:name="com.github.shadowsocks.ShadowsocksSettings"
|
||||
android:id="@android:id/content"
|
||||
android:layout_below="@+id/adView"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"/>
|
||||
<com.github.jorgecastilloprz.FABProgressCircle android:id="@+id/fabProgressCircle" app:reusable="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:elevation="6dp"
|
||||
android:layout_alignBottom="@+id/toolbar"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="@dimen/fab_margin_bottom">
|
||||
<android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:backgroundTint="@color/material_blue_grey_700"
|
||||
android:src="@drawable/ic_cloud_off"
|
||||
app:pressedTranslationZ="6dp" app:borderWidth="0dp" />
|
||||
</com.github.jorgecastilloprz.FABProgressCircle>
|
||||
</RelativeLayout>
|
||||
@@ -413,28 +413,8 @@ class Shadowsocks
|
||||
}
|
||||
}
|
||||
|
||||
def initAdView() {
|
||||
if (settings.getString(Key.proxy, "") == "198.199.101.152") {
|
||||
val layoutView = {
|
||||
if (Build.VERSION.SDK_INT > 10) {
|
||||
drawer.getContentContainer.getChildAt(0)
|
||||
} else {
|
||||
getLayoutView(drawer.getContentContainer.getParent)
|
||||
}
|
||||
}
|
||||
if (layoutView != null) {
|
||||
val adView = new AdView(this)
|
||||
adView.setAdUnitId("ca-app-pub-9097031975646651/7760346322")
|
||||
adView.setAdSize(AdSize.SMART_BANNER)
|
||||
layoutView.asInstanceOf[ViewGroup].addView(adView, 0)
|
||||
adView.loadAd(new AdRequest.Builder().build())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def setContentView(layoutResId: Int) {
|
||||
drawer.setContentView(layoutResId)
|
||||
initAdView()
|
||||
onContentChanged()
|
||||
}
|
||||
|
||||
@@ -442,7 +422,13 @@ class Shadowsocks
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContentView(R.layout.layout_main)
|
||||
if (settings.getString(Key.proxy, "") == "198.199.101.152") {
|
||||
setContentView(R.layout.layout_main_ad)
|
||||
val adView = findViewById(R.id.adView).asInstanceOf[AdView]
|
||||
adView.loadAd(new AdRequest.Builder().build())
|
||||
} else {
|
||||
setContentView(R.layout.layout_main)
|
||||
}
|
||||
|
||||
// Update the profile
|
||||
if (!status.getBoolean(getVersionName, false)) {
|
||||
|
||||
Reference in New Issue
Block a user