Skip to content

Commit

Permalink
Merge pull request #53 from flipkart-incubator/androidx
Browse files Browse the repository at this point in the history
Android X Migration
  • Loading branch information
yasirmhd authored Jun 3, 2019
2 parents 36a6608 + a89f397 commit e0f2bc5
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android:
components:
- tools
- platform-tools
- build-tools-25.0.2
- android-25
- build-tools-28.0.3
- android-28
- extra-android-support
- extra-android-m2repository
- extra-google-m2repository
Expand Down
12 changes: 6 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ allprojects {
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 28
buildToolsVersion "28.0.3"
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
useLibrary 'org.apache.http.legacy'
Expand All @@ -33,9 +33,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.squareup.okhttp3:okhttp:3.14.2'
implementation project(':library')
}
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
tools:replace="android:icon"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning"
tools:replace="android:icon">
<activity
android:name="com.flipkart.okhttpstatsdemo.MainActivity"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
android:fitsSystemWindows="true"
tools:context="com.flipkart.okhttpstatsdemo.MainActivity">

<android.support.design.widget.AppBarLayout
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.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" />

</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="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
9 changes: 0 additions & 9 deletions app/src/main/res/values-v21/styles.xml

This file was deleted.

6 changes: 0 additions & 6 deletions app/src/main/res/values-w820dp/dimens.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.4.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ 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.1.1-all.zip
18 changes: 9 additions & 9 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:2.2.3'
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.7.5'
}
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.3'
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
Expand All @@ -61,11 +61,11 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'androidx.annotation:annotation:1.0.2'
implementation 'com.squareup.okhttp3:okhttp:3.14.2'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.18.0'
testImplementation 'org.mockito:mockito-core:2.19.1'
testImplementation 'com.squareup.okhttp3:mockwebserver:3.6.0'
testImplementation 'org.robolectric:robolectric:3.3.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

package com.flipkart.okhttpstats.handler;

import android.support.annotation.Nullable;
import androidx.annotation.Nullable;

import com.flipkart.okhttpstats.model.RequestStats;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.support.annotation.VisibleForTesting;
import androidx.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

package com.flipkart.okhttpstats.interpreter;

import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import android.util.Log;

import com.flipkart.okhttpstats.NetworkInterceptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package com.flipkart.okhttpstats.reporter;


import android.support.annotation.Nullable;
import androidx.annotation.Nullable;

import java.io.IOException;
import java.net.URL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.flipkart.okhttpstats.response;

import android.support.annotation.NonNull;
import androidx.annotation.NonNull;

import java.io.FilterInputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void testResponseReceivedCalledForEventReporter() throws Exception {
Response response = new Response.Builder()
.code(200)
.request(request)
.message("")
.protocol(Protocol.HTTP_1_1)
.addHeader("Content-Length", "20")
.build();
Expand Down Expand Up @@ -103,7 +104,7 @@ public void testOkHttpInspectorRequest() {
.addHeader("HOST", "flipkart")
.build();

DefaultInterpreter.OkHttpInspectorRequest okHttpInspectorRequest = new DefaultInterpreter.OkHttpInspectorRequest(1, request.url().url(), request.method(), Utils.contentLength(request.headers()), request.header("HOST"));
DefaultInterpreter.OkHttpInspectorRequest okHttpInspectorRequest = new DefaultInterpreter.OkHttpInspectorRequest(1, request.url().url(), request.method(), Utils.contentLength(request.headers()), request.header("HOST"), null);

//assert id is same
Assert.assertTrue(okHttpInspectorRequest.requestId() == 1);
Expand Down Expand Up @@ -164,6 +165,7 @@ public void testResponseBody() throws IOException {
.request(request)
.protocol(Protocol.HTTP_1_1)
.code(200)
.message("")
.addHeader("Content-Length", "20")
.body(ResponseBody.create(MediaType.parse("text/plain"), "any text"))
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.flipkart.okhttpstats.interpreter;

import android.net.Uri;
import android.support.annotation.Nullable;

import androidx.annotation.Nullable;

import com.flipkart.okhttpstats.BuildConfig;
import com.flipkart.okhttpstats.NetworkInterceptor;
Expand All @@ -18,8 +19,10 @@

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPOutputStream;

import okhttp3.Call;
import okhttp3.Connection;
import okhttp3.Interceptor;
import okhttp3.MediaType;
Expand Down Expand Up @@ -96,6 +99,7 @@ public void testInterceptedResponse() throws IOException {
.request(request)
.protocol(Protocol.HTTP_1_1)
.code(200)
.message("")
.addHeader("Content-Length", "20")
.body(ResponseBody.create(MediaType.parse("text/plain"), "any text"))
.build();
Expand Down Expand Up @@ -148,6 +152,7 @@ public void testInterceptedResponseWithContentLength() throws IOException {
.header("Content-Length", "8")
.protocol(Protocol.HTTP_1_1)
.code(200)
.message("")
.body(ResponseBody.create(MediaType.parse("text/plain"), "any text"))
.build();

Expand Down Expand Up @@ -194,6 +199,7 @@ public void testInterceptedRequest() throws IOException {
.protocol(Protocol.HTTP_1_1)
.addHeader("Content-Length", "20")
.code(200)
.message("")
.body(ResponseBody.create(MediaType.parse("text/plain"), "any text"))
.build();

Expand Down Expand Up @@ -316,7 +322,7 @@ public void testOkHttpInspectorRequest() {
.addHeader("HOST", "flipkart")
.build();

DefaultInterpreter.OkHttpInspectorRequest okHttpInspectorRequest = new DefaultInterpreter.OkHttpInspectorRequest(1, request.url().url(), request.method(), Utils.contentLength(request.headers()), request.header("HOST"));
DefaultInterpreter.OkHttpInspectorRequest okHttpInspectorRequest = new DefaultInterpreter.OkHttpInspectorRequest(1, request.url().url(), request.method(), Utils.contentLength(request.headers()), request.header("HOST"), null);

//assert id is same
Assert.assertTrue(okHttpInspectorRequest.requestId() == 1);
Expand Down Expand Up @@ -382,5 +388,40 @@ public Response proceed(Request request) {
public Connection connection() {
return mConnection;
}

@Override
public Call call() {
return null;
}

@Override
public int connectTimeoutMillis() {
return 0;
}

@Override
public Interceptor.Chain withConnectTimeout(int timeout, TimeUnit unit) {
return null;
}

@Override
public int readTimeoutMillis() {
return 0;
}

@Override
public Interceptor.Chain withReadTimeout(int timeout, TimeUnit unit) {
return null;
}

@Override
public int writeTimeoutMillis() {
return 0;
}

@Override
public Interceptor.Chain withWriteTimeout(int timeout, TimeUnit unit) {
return null;
}
}
}

0 comments on commit e0f2bc5

Please sign in to comment.