Skip to content

Commit 604b80c

Browse files
authored
Refreshing the project (#156)
* Make project compileable with latest version of Android Studio * Migrate to AndroidX * Update README.md * Downgrade android gradle plugin to stable version
1 parent f8c3b50 commit 604b80c

20 files changed

+98
-116
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ by Avram Lyon ([email protected])
44
[![Build Status](https://travis-ci.org/avram/zandy.svg?branch=master)](https://travis-ci.org/avram/zandy)
55

66
## Installation
7-
A built and signed version of Zandy is available for purchase on the Android Market (https://market.android.com/details?id=com.gimranov.zandy.app).
7+
A built and signed version of Zandy is available for purchase on the Google Play (https://play.google.com/store/apps/details?id=com.gimranov.zandy.app).
88

99
You can also check out this project and build an APK yourself:
1010
```
1111
./gradlew installGoogleDebug
1212
```
1313

1414
## Requirements
15-
Android 4.0.4 or later.
15+
Android 4.3 or later.
1616

1717
## Support
1818
See the Zandy User Guide (http://www.gimranov.com/avram/w/zandy-user-guide) for basic documentation. Feature requests and bug reports are highly encouraged-- please post to the issue tracker on GitHub or to the Zandy user forum (http://www.gimranov.com/forum). Also feel free to write to [email protected] with questions.

build.gradle

+23-23
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.5.0-alpha07'
8+
classpath 'com.android.tools.build:gradle:4.0.2'
99
//noinspection DifferentKotlinGradleVersion
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21"
10+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20'
1111
}
1212
}
1313

@@ -43,30 +43,29 @@ dependencies {
4343

4444
implementation 'com.github.blocoio:faker:1.0.1'
4545

46-
implementation 'com.android.support:support-annotations:28.0.0'
47-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.21"
46+
implementation 'androidx.annotation:annotation:1.1.0'
4847

49-
implementation 'com.android.support:support-v4:28.0.0'
50-
implementation 'com.android.support:design:28.0.0'
51-
implementation 'com.android.support:appcompat-v7:28.0.0'
52-
implementation 'com.android.support:recyclerview-v7:28.0.0'
53-
implementation 'com.android.support:cardview-v7:28.0.0'
54-
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
48+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
49+
implementation 'com.google.android.material:material:1.2.1'
50+
implementation 'androidx.appcompat:appcompat:1.2.0'
51+
implementation 'androidx.recyclerview:recyclerview:1.1.0'
52+
implementation 'androidx.cardview:cardview:1.0.0'
53+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
5554

56-
testImplementation 'junit:junit:4.12'
55+
testImplementation 'junit:junit:4.13.1'
5756

5857
// Required for instrumented tests
59-
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
58+
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
6059

6160
androidTestImplementation('com.schibsted.spain:barista:2.7.1') {
6261
exclude group: 'com.android.support'
6362
exclude group: 'org.jetbrains.kotlin' // Only if you already use Kotlin in your project
6463
}
6564

66-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
67-
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
68-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
69-
androidTestUtil 'com.android.support.test:orchestrator:1.0.2'
65+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
66+
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
67+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
68+
androidTestUtil 'androidx.test:orchestrator:1.3.0'
7069

7170
}
7271

@@ -81,27 +80,27 @@ testProperties.load(new FileInputStream(testPropertiesFile))
8180
testProperties.putAll(gradle.getStartParameter().getProjectProperties())
8281

8382
android {
84-
compileSdkVersion 28
83+
compileSdkVersion 29
8584
buildToolsVersion "28.0.3"
8685

8786
useLibrary 'org.apache.http.legacy'
8887

89-
dataBinding {
90-
enabled = true
88+
buildFeatures {
89+
dataBinding = true
9190
}
9291

9392
defaultConfig {
9493
versionCode 1461
9594
versionName "1.4.6.1"
9695

97-
minSdkVersion 14
98-
targetSdkVersion 28
96+
minSdkVersion 18
97+
targetSdkVersion 29
9998

100-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
99+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
101100
}
102101

103102
testOptions {
104-
execution 'ANDROID_TEST_ORCHESTRATOR'
103+
execution 'ANDROIDX_TEST_ORCHESTRATOR'
105104
}
106105

107106

@@ -124,6 +123,7 @@ android {
124123
debug {
125124
buildConfigField("String", "TEST_USER_ID", "\"${testProperties.testUserId}\"")
126125
buildConfigField("String", "TEST_USER_KEY_READONLY", "\"${testProperties.testUserKeyReadonly}\"")
126+
buildConfigField("String", "FLAVOR", "\"\"")
127127
}
128128
}
129129

gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
android.enableJetifier=true
2+
android.useAndroidX=true

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
6+
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-all.zip

src/androidTest/java/com/gimranov/zandy/app/ApiTest.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
import android.content.Context;
44
import android.content.SharedPreferences;
55
import android.preference.PreferenceManager;
6-
import android.support.test.filters.SmallTest;
7-
import android.support.test.runner.AndroidJUnit4;
6+
import androidx.test.filters.SmallTest;
7+
import androidx.test.ext.junit.runners.AndroidJUnit4;
88

99
import com.gimranov.zandy.app.data.Database;
1010
import com.gimranov.zandy.app.task.APIException;
1111
import com.gimranov.zandy.app.task.APIRequest;
12-
import com.gimranov.zandy.app.test.BuildConfig;
1312

1413
import org.junit.Before;
1514
import org.junit.Test;
1615
import org.junit.runner.RunWith;
1716

18-
import static android.support.test.InstrumentationRegistry.getTargetContext;
17+
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
1918
import static junit.framework.TestCase.assertTrue;
2019
import static junit.framework.TestCase.fail;
2120

@@ -40,7 +39,7 @@ public class ApiTest {
4039

4140
@Before
4241
public void setUp() {
43-
mContext = getTargetContext();
42+
mContext = getApplicationContext();
4443
mDb = new Database(mContext);
4544

4645
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(mContext);

src/androidTest/java/com/gimranov/zandy/app/MainActivityLoggedInTest.java

+13-30
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,25 @@
11
package com.gimranov.zandy.app;
22

3-
import android.app.Instrumentation;
4-
import android.content.Intent;
53
import android.content.SharedPreferences;
6-
import android.net.Uri;
74
import android.preference.PreferenceManager;
8-
import android.support.test.espresso.intent.rule.IntentsTestRule;
9-
import android.support.test.filters.LargeTest;
10-
import android.support.test.orchestrator.callback.OrchestratorCallback;
11-
import android.support.test.orchestrator.listeners.OrchestrationRunListener;
12-
import android.support.test.runner.AndroidJUnit4;
5+
6+
import androidx.test.espresso.intent.rule.IntentsTestRule;
7+
import androidx.test.ext.junit.runners.AndroidJUnit4;
8+
import androidx.test.filters.LargeTest;
139

1410
import com.gimranov.zandy.app.data.Database;
15-
import com.gimranov.zandy.app.test.*;
16-
import com.gimranov.zandy.app.test.BuildConfig;
1711

18-
import org.hamcrest.BaseMatcher;
19-
import org.hamcrest.Description;
2012
import org.junit.After;
2113
import org.junit.Before;
2214
import org.junit.Rule;
2315
import org.junit.Test;
2416
import org.junit.runner.RunWith;
2517

26-
import static android.support.test.InstrumentationRegistry.getInstrumentation;
27-
import static android.support.test.InstrumentationRegistry.getTargetContext;
28-
import static android.support.test.espresso.Espresso.onView;
29-
import static android.support.test.espresso.action.ViewActions.click;
30-
import static android.support.test.espresso.assertion.ViewAssertions.matches;
31-
import static android.support.test.espresso.intent.Intents.intended;
32-
import static android.support.test.espresso.intent.matcher.ComponentNameMatchers.hasClassName;
33-
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction;
34-
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
35-
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData;
36-
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
37-
import static android.support.test.espresso.matcher.ViewMatchers.withId;
38-
import static org.hamcrest.Matchers.allOf;
39-
import static org.hamcrest.Matchers.hasEntry;
18+
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
19+
import static androidx.test.espresso.Espresso.onView;
20+
import static androidx.test.espresso.assertion.ViewAssertions.matches;
21+
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
22+
import static androidx.test.espresso.matcher.ViewMatchers.withId;
4023
import static org.hamcrest.Matchers.not;
4124

4225
@RunWith(AndroidJUnit4.class)
@@ -48,7 +31,7 @@ public class MainActivityLoggedInTest {
4831
@Override
4932
protected void beforeActivityLaunched() {
5033
super.beforeActivityLaunched();
51-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getTargetContext());
34+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
5235
preferences.edit()
5336
.putString("user_id", BuildConfig.TEST_USER_ID)
5437
.putString("user_key", BuildConfig.TEST_USER_KEY_READONLY)
@@ -58,7 +41,7 @@ protected void beforeActivityLaunched() {
5841

5942
@Before
6043
public void setUpCredentials() {
61-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getTargetContext());
44+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
6245
preferences.edit()
6346
.putString("user_id", BuildConfig.TEST_USER_ID)
6447
.putString("user_key", BuildConfig.TEST_USER_KEY_READONLY)
@@ -67,14 +50,14 @@ public void setUpCredentials() {
6750

6851
@After
6952
public void clearCredentials() {
70-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getTargetContext());
53+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
7154
preferences.edit().clear().commit();
7255
}
7356

7457
@Before
7558
@After
7659
public void clearDatabase() {
77-
Database database = new Database(getTargetContext());
60+
Database database = new Database(getApplicationContext());
7861
database.resetAllData();
7962
}
8063

src/androidTest/java/com/gimranov/zandy/app/MainActivityLoggedOutTest.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
import android.content.Intent;
44
import android.net.Uri;
5-
import android.support.test.espresso.intent.rule.IntentsTestRule;
6-
import android.support.test.filters.LargeTest;
7-
import android.support.test.runner.AndroidJUnit4;
5+
import androidx.test.espresso.intent.rule.IntentsTestRule;
6+
import androidx.test.filters.LargeTest;
7+
import androidx.test.ext.junit.runners.AndroidJUnit4;
88

99
import org.hamcrest.BaseMatcher;
1010
import org.hamcrest.Description;
1111
import org.junit.Rule;
1212
import org.junit.Test;
1313
import org.junit.runner.RunWith;
1414

15-
import static android.support.test.espresso.Espresso.onView;
16-
import static android.support.test.espresso.action.ViewActions.click;
17-
import static android.support.test.espresso.intent.Intents.intended;
18-
import static android.support.test.espresso.intent.matcher.ComponentNameMatchers.hasClassName;
19-
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction;
20-
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
21-
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData;
22-
import static android.support.test.espresso.matcher.ViewMatchers.withId;
15+
import static androidx.test.espresso.Espresso.onView;
16+
import static androidx.test.espresso.action.ViewActions.click;
17+
import static androidx.test.espresso.intent.Intents.intended;
18+
import static androidx.test.espresso.intent.matcher.ComponentNameMatchers.hasClassName;
19+
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasAction;
20+
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
21+
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasData;
22+
import static androidx.test.espresso.matcher.ViewMatchers.withId;
2323
import static com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
2424
import static org.hamcrest.Matchers.allOf;
2525

src/androidTest/java/com/gimranov/zandy/app/SyncTest.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
import android.content.SharedPreferences;
55
import android.preference.PreferenceManager;
6-
import android.support.test.espresso.ViewInteraction;
7-
import android.support.test.filters.LargeTest;
8-
import android.support.test.rule.ActivityTestRule;
9-
import android.support.test.runner.AndroidJUnit4;
6+
import androidx.test.espresso.ViewInteraction;
7+
import androidx.test.filters.LargeTest;
8+
import androidx.test.rule.ActivityTestRule;
9+
import androidx.test.ext.junit.runners.AndroidJUnit4;
1010
import android.view.View;
1111
import android.view.ViewGroup;
1212
import android.view.ViewParent;
@@ -20,16 +20,16 @@
2020
import org.junit.Test;
2121
import org.junit.runner.RunWith;
2222

23-
import static android.support.test.InstrumentationRegistry.getTargetContext;
24-
import static android.support.test.espresso.Espresso.onView;
25-
import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
26-
import static android.support.test.espresso.action.ViewActions.click;
27-
import static android.support.test.espresso.assertion.ViewAssertions.matches;
28-
import static android.support.test.espresso.matcher.RootMatchers.withDecorView;
29-
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
30-
import static android.support.test.espresso.matcher.ViewMatchers.withClassName;
31-
import static android.support.test.espresso.matcher.ViewMatchers.withId;
32-
import static android.support.test.espresso.matcher.ViewMatchers.withText;
23+
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
24+
import static androidx.test.espresso.Espresso.onView;
25+
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
26+
import static androidx.test.espresso.action.ViewActions.click;
27+
import static androidx.test.espresso.assertion.ViewAssertions.matches;
28+
import static androidx.test.espresso.matcher.RootMatchers.withDecorView;
29+
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
30+
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
31+
import static androidx.test.espresso.matcher.ViewMatchers.withId;
32+
import static androidx.test.espresso.matcher.ViewMatchers.withText;
3333
import static org.hamcrest.Matchers.allOf;
3434
import static org.hamcrest.Matchers.is;
3535
import static org.hamcrest.Matchers.not;
@@ -43,7 +43,7 @@ public class SyncTest {
4343

4444
@Before
4545
public void setUpCredentials() {
46-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getTargetContext());
46+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
4747
preferences.edit()
4848
.putString("user_id", BuildConfig.TEST_USER_ID)
4949
.putString("user_key", BuildConfig.TEST_USER_KEY_READONLY)
@@ -52,20 +52,20 @@ public void setUpCredentials() {
5252

5353
@After
5454
public void clearCredentials() {
55-
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getTargetContext());
55+
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
5656
preferences.edit().clear().commit();
5757
}
5858

5959
@Before
6060
@After
6161
public void clearDatabase() {
62-
Database database = new Database(getTargetContext());
62+
Database database = new Database(getApplicationContext());
6363
database.resetAllData();
6464
}
6565

6666
@Test
6767
public void syncTest() {
68-
openActionBarOverflowOrOptionsMenu(getTargetContext());
68+
openActionBarOverflowOrOptionsMenu(getApplicationContext());
6969

7070
ViewInteraction textView = onView(
7171
allOf(withId(android.R.id.title), withText(R.string.menu_sync),

src/main/java/com/gimranov/zandy/app/AttachmentActivity.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import android.os.Handler;
3030
import android.os.Message;
3131
import android.preference.PreferenceManager;
32-
import android.support.annotation.NonNull;
32+
import androidx.annotation.NonNull;
3333
import android.text.Editable;
3434
import android.util.Base64;
3535
import android.util.Log;
@@ -40,7 +40,6 @@
4040
import android.view.View;
4141
import android.view.ViewGroup;
4242
import android.view.WindowManager;
43-
import android.webkit.MimeTypeMap;
4443
import android.widget.AdapterView;
4544
import android.widget.AdapterView.OnItemClickListener;
4645
import android.widget.AdapterView.OnItemLongClickListener;

src/main/java/com/gimranov/zandy/app/CollectionAdapter.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.gimranov.zandy.app
22

3-
import android.support.v7.widget.RecyclerView
3+
import androidx.recyclerview.widget.RecyclerView
44
import android.view.LayoutInflater
55
import android.view.ViewGroup
66
import com.gimranov.zandy.app.data.Database

src/main/java/com/gimranov/zandy/app/DrawerNavigationActivity.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package com.gimranov.zandy.app
22

33
import android.content.Intent
44
import android.os.Bundle
5-
import android.support.v4.view.GravityCompat
6-
import android.support.v7.app.ActionBarDrawerToggle
7-
import android.support.v7.app.AppCompatActivity
8-
import android.support.v7.widget.LinearLayoutManager
5+
import androidx.core.view.GravityCompat
6+
import androidx.appcompat.app.ActionBarDrawerToggle
7+
import androidx.appcompat.app.AppCompatActivity
8+
import androidx.recyclerview.widget.LinearLayoutManager
99
import android.view.Menu
1010
import android.view.MenuItem
1111
import com.gimranov.zandy.app.data.Database

0 commit comments

Comments
 (0)