Skip to content

Commit

Permalink
updating to google play service admob system, deprecating old ads system
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Jul 18, 2016
1 parent 1966ba9 commit 066fd3b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 19 deletions.
4 changes: 3 additions & 1 deletion sudoku-android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ Make sure you've defined the necessary properties in your settings.xml, namely
android.storepass

Of course, you have to create a corresponding keystore and use your own storepass.

For example, you could place those values in your settings.xml in the SETTINGS.android profile.

For upload to app store use

target/sudoku-android-aligned.apk.

via the web interface of googles play store.
via the google play store web interface.



15 changes: 9 additions & 6 deletions sudoku-android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>5.0.1_r2</version>
<version>6.0_r2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android.admob</groupId>
<artifactId>admob</artifactId>
<version>6.4.1-r11</version>
<groupId>com.google.android.gms</groupId>
<artifactId>play-services-ads</artifactId>
<version>9.2.0</version>
<type>aar</type>
</dependency>

</dependencies>


Expand All @@ -58,7 +60,7 @@
<artifactId>scala-maven-plugin</artifactId>
</plugin>

<plugin>
<plugin>
<groupId>com.simpligility.maven.plugins</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
Expand All @@ -75,6 +77,7 @@
</sdk>
<extractDuplicates>true</extractDuplicates>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
<failOnDuplicatePackages>false</failOnDuplicatePackages>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -103,7 +106,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<version>1.4</version>
<executions>
<execution>
<id>signing</id>
Expand Down
3 changes: 2 additions & 1 deletion sudoku-android/proguard.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
# for development
-dontoptimize

#Keep classes that are referenced on the AndroidManifest
#Keep classes that are referenced in androidmanifest.xml
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class org.opencv.android.JavaCameraView { *; }
-keep public class com.google.android.gms.ads.Adview { *; }
-keep class scala.collection.SeqLike { public protected *; }
-keep public class net.ladstatt.**
4 changes: 3 additions & 1 deletion sudoku-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

<activity
android:name="com.google.ads.AdActivity"
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

<activity
Expand Down
10 changes: 10 additions & 0 deletions sudoku-android/src/main/res/layout/sudoku.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
android:layout_height="match_parent"
android:id="@+id/mainLayout">

<!--
<com.google.android.gms.ads.AdView
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-1727389366588084/4496274256"/>
-->


<org.opencv.android.JavaCameraView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import _root_.android.util.Log
import _root_.android.view.View.OnClickListener
import _root_.android.view.{Gravity, View, WindowManager}
import _root_.android.widget.{Button, FrameLayout}
import com.google.ads.{AdRequest, AdSize, AdView}
import com.google.android.gms.ads.{AdRequest, AdSize, AdView, MobileAds}
import net.ladstatt.sudoku._
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2
import org.opencv.android.{CameraBridgeViewBase, OpenCVLoader}
Expand Down Expand Up @@ -56,11 +56,9 @@ class SudokuCapturer extends Activity with CvCameraViewListener2 with CanLog {
var frameNr: Int = 0
var solution: Mat = _
var calculationInProgress = false
var adView: AdView = _
val defaultLibrary: DigitLibrary = Map().withDefaultValue((Double.MaxValue, None))
val defaultHitCounts: HitCounters = Map().withDefaultValue(Map[Int, Int]().withDefaultValue(0))
val AdsenseKey: String = "ca-app-pub-1727389366588084/4496274256"

val AdUnitId: String = "ca-app-pub-1727389366588084/4496274256"

var currState: SudokuState = AndroidOpenCV.DefaultAndroidState

Expand All @@ -73,12 +71,16 @@ class SudokuCapturer extends Activity with CvCameraViewListener2 with CanLog {
/** Called when the activity is first created. */
override def onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)

initAssets()

Log.i(TAG, "called onCreate")
getWindow.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
setContentView(R.layout.sudoku)

MobileAds.initialize(this, AdUnitId)
// val adView = findViewById(R.id.ad_view).asInstanceOf[AdView]

cameraView = findViewById(R.id.sudoku).asInstanceOf[CameraBridgeViewBase]
cameraView.setCvCameraViewListener(this)
rescanButton = findViewById(R.id.button_rescan).asInstanceOf[Button]
Expand All @@ -94,13 +96,22 @@ class SudokuCapturer extends Activity with CvCameraViewListener2 with CanLog {
}
})


adView = new AdView(this, AdSize.BANNER, AdsenseKey)
adView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP)
val adView: AdView = new AdView(this)
adView.setAdSize(AdSize.SMART_BANNER)
adView.setAdUnitId(AdUnitId)
adView.setVisibility(View.VISIBLE)

adView.setForegroundGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP)
// adView = new AdView(this, AdSize.BANNER, AdUnitId)
// adView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP)
// adView.setVisibility(View.VISIBLE)

findViewById(R.id.mainLayout).asInstanceOf[FrameLayout].addView(adView)

val r = new AdRequest()
val adRequestBuilder = new AdRequest.Builder()
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
val r = adRequestBuilder.build()

adView.loadAd(r)

handler = new Handler()
Expand Down Expand Up @@ -145,8 +156,8 @@ class SudokuCapturer extends Activity with CvCameraViewListener2 with CanLog {

val pipeline: FramePipeline = FramePipeline(frame, SParams())

pipeline.detectRectangle match {
case None => SFailure("No rectangle detected",SCandidate(frameNr,pipeline, SRectangle(frame, pipeline.corners,pipeline.corners),currState))
pipeline.detectRectangle match {
case None => SFailure("No rectangle detected", SCandidate(frameNr, pipeline, SRectangle(frame, pipeline.corners, pipeline.corners), currState))
case Some(r) =>
val rectangle: SRectangle = SRectangle(pipeline)
val (sudokuResult, nextState) = Await.result(SCandidate(frameNr, pipeline, rectangle, currState).calc, Duration.Inf)
Expand Down

0 comments on commit 066fd3b

Please sign in to comment.