Skip to content

Commit

Permalink
Updated toolchain and converted to AndroidX
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkutik committed Nov 16, 2019
1 parent 3488147 commit 94e8c24
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ captures/
# IntelliJ project files
*.iml
.idea/
.cxx/

# Misc
.DS_Store
Expand Down
9 changes: 7 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ android {
targetSdkVersion targetSdkVer
versionCode 7
versionName "0.7"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

//check if the keystore details are defined in gradle.properties (this is so the key is not in github)
Expand Down Expand Up @@ -43,8 +45,11 @@ android {

dependencies {
implementation project(':rootbeerlib')
implementation "com.android.support:appcompat-v7:$supportLibVer"
implementation "com.android.support:design:$supportLibVer"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.0-alpha01'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'uk.co.barbuzz:beerprogressview:0.0.4'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.scottyab.rootbeer;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.ext.junit.runners.AndroidJUnit4;

@RunWith(AndroidJUnit4.class)
public class ApplicationTest {

@Test
public void someTest() {
Assert.assertTrue(true);
}

}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.scottyab.rootbeer.sample"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:theme="@style/AppTheme.NoActionBar"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand Down
48 changes: 24 additions & 24 deletions app/src/main/java/com/scottyab/rootbeer/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

import java.util.ArrayList;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import uk.co.barbuzz.beerprogressview.BeerProgressView;


Expand Down Expand Up @@ -43,24 +44,24 @@ protected void onCreate(Bundle savedInstanceState) {

private void initView() {
mActivity = this;
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

beerView = (BeerProgressView) findViewById(R.id.loadingRootCheckBeerView);
isRootedText = (TextViewFont) findViewById(R.id.content_main_is_rooted_text);
isRootedTextDisclaimer = (TextView) findViewById(R.id.content_mainisRootedTextDisclaimer);

ImageView rootCheck1ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_1);
ImageView rootCheck2ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_2);
ImageView rootCheck3ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_3);
ImageView rootCheck4ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_4);
ImageView rootCheck5ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_5);
ImageView rootCheck6ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_6);
ImageView rootCheck7ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_7);
ImageView rootCheck8ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_8);
ImageView rootCheck9ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_9);
ImageView rootCheck10ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_10);
ImageView rootCheck11ImageView = (ImageView) findViewById(R.id.content_main_root_check_image_11);
beerView = findViewById(R.id.loadingRootCheckBeerView);
isRootedText = findViewById(R.id.content_main_is_rooted_text);
isRootedTextDisclaimer = findViewById(R.id.content_mainisRootedTextDisclaimer);

ImageView rootCheck1ImageView = findViewById(R.id.content_main_root_check_image_1);
ImageView rootCheck2ImageView = findViewById(R.id.content_main_root_check_image_2);
ImageView rootCheck3ImageView = findViewById(R.id.content_main_root_check_image_3);
ImageView rootCheck4ImageView = findViewById(R.id.content_main_root_check_image_4);
ImageView rootCheck5ImageView = findViewById(R.id.content_main_root_check_image_5);
ImageView rootCheck6ImageView = findViewById(R.id.content_main_root_check_image_6);
ImageView rootCheck7ImageView = findViewById(R.id.content_main_root_check_image_7);
ImageView rootCheck8ImageView = findViewById(R.id.content_main_root_check_image_8);
ImageView rootCheck9ImageView = findViewById(R.id.content_main_root_check_image_9);
ImageView rootCheck10ImageView = findViewById(R.id.content_main_root_check_image_10);
ImageView rootCheck11ImageView = findViewById(R.id.content_main_root_check_image_11);
checkRootImageViewList = new ArrayList<>();
checkRootImageViewList.add(rootCheck1ImageView);
checkRootImageViewList.add(rootCheck2ImageView);
Expand All @@ -74,7 +75,7 @@ private void initView() {
checkRootImageViewList.add(rootCheck10ImageView);
checkRootImageViewList.add(rootCheck11ImageView);

floatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
floatingActionButton = findViewById(R.id.fab);
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -117,9 +118,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

private void showInfoDialog() {
if (infoDialog != null && infoDialog.isShowing()) {
//do nothing if already showing
} else {
//do nothing if already showing
if (infoDialog == null || !infoDialog.isShowing()) {
infoDialog = new AlertDialog.Builder(this)
.setTitle(R.string.app_name)
.setMessage(R.string.info_details)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.util.Log;

import androidx.appcompat.widget.AppCompatTextView;

/**
* Created by 1andbarb on 22/04/2016.
*/
Expand Down
23 changes: 12 additions & 11 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:fitsSystemWindows="true">
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
android:theme="@style/AppTheme.NoActionBar.AppBarOverlay">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
app:popupTheme="@style/AppTheme.NoActionBar.PopupOverlay"/>

</android.support.design.widget.AppBarLayout>
</com.google.android.material.appbar.AppBarLayout>

<include layout="@layout/content_main"/>

<android.support.design.widget.FloatingActionButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_lock_open_white_24dp"/>
app:srcCompat="@drawable/ic_lock_open_white_24dp"/>

</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
11 changes: 11 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@
<style name="AppTheme.PopupOverlay"
parent="ThemeOverlay.AppCompat.Light"/>

<style name="AppTheme.NoActionBar.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.NoActionBar.AppBarOverlay"
parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

<style name="AppTheme.NoActionBar.PopupOverlay"
parent="ThemeOverlay.AppCompat.Light"/>

</resources>
23 changes: 10 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.5.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -26,17 +23,17 @@ allprojects {

repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
}

subprojects {
ext.compileSdkVer = 27
ext.buildToolsVer = "27.0.3"
ext.compileSdkVer = 29
ext.buildToolsVer = "29.0.2"
ext.minSdkVer = 15
ext.targetSdkVer = 27
ext.supportLibVer = "27.1.1"
ext.targetSdkVer = 29
}

task clean(type: Delete) {
delete rootProject.buildDir
}
8 changes: 8 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

VERSION_NAME=0.0.7
VERSION_CODE=7
GROUP=com.scottyab
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 11 11:54:48 BST 2018
#Fri Nov 15 10:32:08 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
6 changes: 5 additions & 1 deletion rootbeerlib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ android {
targetSdkVersion targetSdkVer
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
Expand Down Expand Up @@ -49,7 +51,9 @@ android {

dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.10.0'
testImplementation 'org.mockito:mockito-core:3.1.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
}

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.scottyab.rootbeer;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import androidx.test.ext.junit.runners.AndroidJUnit4;

@RunWith(AndroidJUnit4.class)
public class ApplicationTest {

@Test
public void someTest() {
Assert.assertTrue(true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;

import static junit.framework.Assert.assertFalse;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import static org.mockito.AdditionalMatchers.not;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -40,7 +40,7 @@ public void testIsRooted() {
when(rootBeer.checkForRootNative()).thenReturn(false);

// Test we return false when all methods return false
assertTrue(!rootBeer.isRooted());
assertFalse(rootBeer.isRooted());

when(rootBeer.checkForRootNative()).thenReturn(true);

Expand Down Expand Up @@ -70,7 +70,7 @@ public void testIsRootedWithoutBusyBoxCheck() {
assertTrue(rootBeer.isRooted());

// Test it doesn't matter what checkForBinary("busybox") returns
assertTrue(!rootBeer.isRootedWithoutBusyBoxCheck());
assertFalse(rootBeer.isRootedWithoutBusyBoxCheck());

}

Expand Down

0 comments on commit 94e8c24

Please sign in to comment.