Commit dc7ea981 authored by Max Lv's avatar Max Lv

fix AdView

parent 8598e5a1
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
android:summary="@string/auto_connect_summary" android:summary="@string/auto_connect_summary"
android:title="@string/auto_connect"> android:title="@string/auto_connect">
</CheckBoxPreference> </CheckBoxPreference>
<Preference android:key="blank">
</Preference>
</PreferenceScreen> </PreferenceScreen>
...@@ -45,7 +45,7 @@ import android.graphics.{Color, Bitmap, Typeface} ...@@ -45,7 +45,7 @@ import android.graphics.{Color, Bitmap, Typeface}
import android.os._ import android.os._
import android.preference._ import android.preference._
import android.util.Log import android.util.Log
import android.view.{View, ViewGroup, ViewParent, KeyEvent} import android.view._
import android.widget._ import android.widget._
import com.google.analytics.tracking.android.EasyTracker import com.google.analytics.tracking.android.EasyTracker
import de.keyboardsurfer.android.widget.crouton.Crouton import de.keyboardsurfer.android.widget.crouton.Crouton
...@@ -75,6 +75,9 @@ import com.github.shadowsocks.preferences.{ProfileEditTextPreference, PasswordEd ...@@ -75,6 +75,9 @@ import com.github.shadowsocks.preferences.{ProfileEditTextPreference, PasswordEd
import com.github.shadowsocks.database.Item import com.github.shadowsocks.database.Item
import com.github.shadowsocks.database.Category import com.github.shadowsocks.database.Category
import scala.Option import scala.Option
import android.view.ViewGroup.LayoutParams
import com.github.shadowsocks.database.Item
import com.github.shadowsocks.database.Category
class ProfileIconDownloader(context: Context, connectTimeout: Int, readTimeout: Int) class ProfileIconDownloader(context: Context, connectTimeout: Int, readTimeout: Int)
extends BaseImageDownloader(context, connectTimeout, readTimeout) { extends BaseImageDownloader(context, connectTimeout, readTimeout) {
...@@ -460,18 +463,21 @@ class Shadowsocks ...@@ -460,18 +463,21 @@ class Shadowsocks
} }
} }
def initAdView(layoutResId: Int) { def initAdView() {
if (settings.getString(Key.proxy, "") == "198.199.101.152") { if (settings.getString(Key.proxy, "") == "198.199.101.152") {
val adView = { val layoutView = drawer.getContentContainer
if (isSinglePane) {
new AdView(this, AdSize.SMART_BANNER, "a151becb8068b09")
} else {
new AdView(this, AdSize.BANNER, "a151becb8068b09")
}
}
val layoutView = findViewById(layoutResId).asInstanceOf[ViewGroup]
if (layoutView != null) { if (layoutView != null) {
layoutView.addView(adView, 0) val adView = {
if (isSinglePane) {
new AdView(this, AdSize.SMART_BANNER, "a151becb8068b09")
} else {
new AdView(this, AdSize.BANNER, "a151becb8068b09")
}
}
val params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
params.gravity = Gravity.BOTTOM
adView.setLayoutParams(params)
layoutView.asInstanceOf[ViewGroup].addView(adView, 0)
adView.loadAd(new AdRequest) adView.loadAd(new AdRequest)
} }
} }
...@@ -479,7 +485,7 @@ class Shadowsocks ...@@ -479,7 +485,7 @@ class Shadowsocks
override def setContentView(layoutResId: Int) { override def setContentView(layoutResId: Int) {
drawer.setContentView(layoutResId) drawer.setContentView(layoutResId)
initAdView(layoutResId) initAdView()
onContentChanged() onContentChanged()
} }
...@@ -496,7 +502,6 @@ class Shadowsocks ...@@ -496,7 +502,6 @@ class Shadowsocks
menuAdapter.setListener(this) menuAdapter.setListener(this)
listView.setAdapter(menuAdapter) listView.setAdapter(menuAdapter)
drawer.setMenuView(listView) drawer.setMenuView(listView)
// The drawable that replaces the up indicator in the action bar // The drawable that replaces the up indicator in the action bar
drawer.setSlideDrawable(R.drawable.ic_drawer) drawer.setSlideDrawable(R.drawable.ic_drawer)
// Whether the previous drawable should be shown // Whether the previous drawable should be shown
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment