Skip to content

Commit

Permalink
Add fake demographics
Browse files Browse the repository at this point in the history
  • Loading branch information
madeye committed Sep 24, 2016
1 parent ac0a8c7 commit 2599e88
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/main/scala/com/github/shadowsocks/Shadowsocks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ package com.github.shadowsocks
import java.io.{FileOutputStream, IOException, InputStream, OutputStream}
import java.lang.System.currentTimeMillis
import java.net.{HttpURLConnection, URL}
import java.util
import java.util.Date
import java.util.Hashtable
import java.util.Locale

import android.app.backup.BackupManager
Expand All @@ -68,6 +69,7 @@ import com.google.android.gms.ads.{AdRequest, AdSize, AdView}
import eu.chainfire.libsuperuser.Shell

import scala.collection.mutable.ArrayBuffer
import scala.util.Random

object Typefaces {
def get(c: Context, assetPath: String): Typeface = {
Expand All @@ -87,7 +89,7 @@ object Typefaces {
}

private final val TAG = "Typefaces"
private final val cache = new util.Hashtable[String, Typeface]
private final val cache = new Hashtable[String, Typeface]
}

object Shadowsocks {
Expand Down Expand Up @@ -487,7 +489,18 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
adView.setAdUnitId("ca-app-pub-9097031975646651/7760346322")
adView.setAdSize(AdSize.SMART_BANNER)
preferences.getView.asInstanceOf[ViewGroup].addView(adView, 1)
adView.loadAd(new AdRequest.Builder().build())

// Demographics
val random = new Random()
val adBuilder = new AdRequest.Builder()
adBuilder.setGender(AdRequest.GENDER_MALE)
val year = 1975 + random.nextInt(40)
val month = 1 + random.nextInt(12)
val day = random.nextInt(28)
adBuilder.setBirthday(new Date(year, month, day))

// Load Ad
adView.loadAd(adBuilder.build())
} else adView.setVisibility(View.VISIBLE) else if (adView != null) adView.setVisibility(View.GONE)

preferences.setProfile(profile)
Expand Down

0 comments on commit 2599e88

Please sign in to comment.