From e937c59651c3563a8be35baae2309eb979fe35e7 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Wed, 15 May 2019 20:38:29 -0700 Subject: [PATCH] Migrate to AndroidX --- app/build.gradle | 39 ++++++++----- .../ExampleInstrumentedTest.java | 7 ++- .../simplemarkdown/MainActivityTests.java | 25 ++++---- .../view/activity/AutosaveTest.java | 35 +++++------ .../view/activity/ExplorerActivityTest.java | 19 +++--- app/src/main/AndroidManifest.xml | 2 +- .../simplemarkdown/MarkdownApplication.java | 2 +- .../presentation/MarkdownPresenter.java | 4 +- .../presentation/MarkdownPresenterImpl.java | 36 +----------- .../simplemarkdown/utility/Utils.java | 3 +- .../view/DisableableViewPager.java | 7 ++- .../view/activity/ExplorerActivity.java | 5 +- .../view/activity/MainActivity.java | 10 ++-- .../view/activity/MarkdownInfoActivity.java | 5 +- .../view/activity/SettingsActivity.java | 5 +- .../view/activity/SplashActivity.java | 5 +- .../view/activity/SupportActivity.kt | 58 +++++++++++++++++++ .../view/adapter/EditPagerAdapter.java | 7 ++- .../view/fragment/EditFragment.java | 7 ++- .../view/fragment/PreviewFragment.java | 7 ++- .../view/fragment/SettingsFragment.java | 3 +- app/src/main/res/layout/activity_explorer.xml | 12 ++-- app/src/main/res/layout/activity_main.xml | 8 +-- app/src/main/res/layout/content_explorer.xml | 4 +- build.gradle | 5 +- gradle.properties | 2 + 26 files changed, 186 insertions(+), 136 deletions(-) create mode 100644 app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SupportActivity.kt diff --git a/app/build.gradle b/app/build.gradle index ee9cc27..8b55ef5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,7 @@ apply plugin: 'com.android.application' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-kapt' apply plugin: 'io.fabric' def keystorePropertiesFile = rootProject.file("keystore.properties") @@ -29,7 +32,7 @@ android { multiDexEnabled true versionCode 18 versionName "0.6.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { release { @@ -57,28 +60,24 @@ android { } } -ext { - acraVersion = '5.2.0' - support_version = "28.0.0" -} - dependencies { + def lifecycle_version = "2.0.0" annotationProcessor 'com.google.dagger:dagger-compiler:2.21' annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0' testImplementation 'junit:junit:4.12' testImplementation 'org.robolectric:robolectric:4.2' implementation fileTree(include: ['*.jar'], dir: 'libs') - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test:rules:1.0.2' - androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3' - implementation "com.android.support:appcompat-v7:$support_version" - implementation 'com.android.support.constraint:constraint-layout:1.1.3' - implementation "com.android.support:design:$support_version" - implementation "com.android.support:support-v13:$support_version" + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' + androidTestImplementation 'androidx.test:runner:1.1.1' + androidTestImplementation 'androidx.test:rules:1.1.1' + androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.legacy:legacy-support-v13:1.0.0' implementation 'com.commonsware.cwac:anddown:0.3.0' implementation 'com.google.dagger:dagger:2.21' implementation 'com.jakewharton:butterknife:8.8.1' @@ -89,7 +88,15 @@ dependencies { implementation 'com.google.firebase:firebase-core:16.0.8' implementation 'com.android.billingclient:billing:1.2' implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9' - implementation 'com.android.support:multidex:1.0.3' + implementation 'androidx.multidex:multidex:2.0.1' + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" + kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" + compile "androidx.core:core-ktx:1.0.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' } apply plugin: 'com.google.gms.google-services' +repositories { + mavenCentral() +} diff --git a/app/src/androidTest/java/com/wbrawner/simplemarkdown/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/wbrawner/simplemarkdown/ExampleInstrumentedTest.java index aeecc22..53cb592 100644 --- a/app/src/androidTest/java/com/wbrawner/simplemarkdown/ExampleInstrumentedTest.java +++ b/app/src/androidTest/java/com/wbrawner/simplemarkdown/ExampleInstrumentedTest.java @@ -1,13 +1,14 @@ package com.wbrawner.simplemarkdown; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; + +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * Instrumentation test, which will execute on an Android device. diff --git a/app/src/androidTest/java/com/wbrawner/simplemarkdown/MainActivityTests.java b/app/src/androidTest/java/com/wbrawner/simplemarkdown/MainActivityTests.java index da36015..a5d0ebc 100644 --- a/app/src/androidTest/java/com/wbrawner/simplemarkdown/MainActivityTests.java +++ b/app/src/androidTest/java/com/wbrawner/simplemarkdown/MainActivityTests.java @@ -2,13 +2,14 @@ package com.wbrawner.simplemarkdown; import android.content.Context; import android.content.pm.ActivityInfo; -import android.support.test.InstrumentationRegistry; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; -import android.support.test.uiautomator.UiDevice; -import android.support.test.uiautomator.UiObject; -import android.support.test.uiautomator.UiScrollable; -import android.support.test.uiautomator.UiSelector; + +import androidx.test.InstrumentationRegistry; +import androidx.test.rule.ActivityTestRule; +import androidx.test.runner.AndroidJUnit4; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.UiObject; +import androidx.test.uiautomator.UiScrollable; +import androidx.test.uiautomator.UiSelector; import com.wbrawner.simplemarkdown.view.activity.MainActivity; @@ -17,11 +18,11 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static android.support.test.InstrumentationRegistry.getInstrumentation; -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; -import static android.support.test.espresso.action.ViewActions.click; -import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static androidx.test.InstrumentationRegistry.getInstrumentation; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.matcher.ViewMatchers.withText; import static org.junit.Assert.assertEquals; /** diff --git a/app/src/androidTest/java/com/wbrawner/simplemarkdown/view/activity/AutosaveTest.java b/app/src/androidTest/java/com/wbrawner/simplemarkdown/view/activity/AutosaveTest.java index 1b0679d..bf3a37d 100644 --- a/app/src/androidTest/java/com/wbrawner/simplemarkdown/view/activity/AutosaveTest.java +++ b/app/src/androidTest/java/com/wbrawner/simplemarkdown/view/activity/AutosaveTest.java @@ -2,15 +2,16 @@ package com.wbrawner.simplemarkdown.view.activity; import android.Manifest; -import android.support.test.espresso.ViewInteraction; -import android.support.test.filters.LargeTest; -import android.support.test.rule.ActivityTestRule; -import android.support.test.rule.GrantPermissionRule; -import android.support.test.runner.AndroidJUnit4; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; +import androidx.test.espresso.ViewInteraction; +import androidx.test.filters.LargeTest; +import androidx.test.rule.ActivityTestRule; +import androidx.test.rule.GrantPermissionRule; +import androidx.test.runner.AndroidJUnit4; + import com.wbrawner.simplemarkdown.R; import org.hamcrest.Description; @@ -20,18 +21,18 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import static android.support.test.InstrumentationRegistry.getInstrumentation; -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; -import static android.support.test.espresso.action.ViewActions.click; -import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard; -import static android.support.test.espresso.action.ViewActions.replaceText; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withClassName; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static android.support.test.espresso.matcher.ViewMatchers.withParent; -import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static androidx.test.InstrumentationRegistry.getInstrumentation; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; +import static androidx.test.espresso.action.ViewActions.replaceText; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withClassName; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withParent; +import static androidx.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.is; diff --git a/app/src/androidTest/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivityTest.java b/app/src/androidTest/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivityTest.java index 3970862..2a69b8a 100644 --- a/app/src/androidTest/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivityTest.java +++ b/app/src/androidTest/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivityTest.java @@ -2,10 +2,11 @@ package com.wbrawner.simplemarkdown.view.activity; import android.Manifest; import android.content.Intent; -import android.support.test.rule.ActivityTestRule; -import android.support.test.rule.GrantPermissionRule; import android.widget.TextView; +import androidx.test.rule.ActivityTestRule; +import androidx.test.rule.GrantPermissionRule; + import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.utility.Constants; @@ -14,13 +15,13 @@ import org.junit.Test; import java.util.HashMap; -import static android.support.test.espresso.Espresso.onData; -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.action.ViewActions.click; -import static android.support.test.espresso.assertion.ViewAssertions.matches; -import static android.support.test.espresso.matcher.ViewMatchers.withId; -import static android.support.test.espresso.matcher.ViewMatchers.withParent; -import static android.support.test.espresso.matcher.ViewMatchers.withText; +import static androidx.test.espresso.Espresso.onData; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withParent; +import static androidx.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c3ffb8d..4227bd8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -53,7 +53,7 @@ android:theme="@style/AppTheme" /> diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java b/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java index 6a3aecf..08c7970 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/MarkdownApplication.java @@ -1,6 +1,6 @@ package com.wbrawner.simplemarkdown; -import android.support.multidex.MultiDexApplication; +import androidx.multidex.MultiDexApplication; public class MarkdownApplication extends MultiDexApplication { diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenter.java b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenter.java index fa49ea5..bb372ff 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenter.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenter.java @@ -3,15 +3,13 @@ package com.wbrawner.simplemarkdown.presentation; import android.content.Context; import android.net.Uri; -import com.android.billingclient.api.BillingClientStateListener; -import com.android.billingclient.api.PurchasesUpdatedListener; import com.wbrawner.simplemarkdown.view.MarkdownEditView; import com.wbrawner.simplemarkdown.view.MarkdownPreviewView; import java.io.File; import java.io.InputStream; -public interface MarkdownPresenter extends PurchasesUpdatedListener, BillingClientStateListener { +public interface MarkdownPresenter { File getFile(); void loadMarkdown(); diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java index a7c2627..a968988 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/presentation/MarkdownPresenterImpl.java @@ -5,12 +5,7 @@ import android.database.Cursor; import android.net.Uri; import android.os.Handler; import android.provider.OpenableColumns; -import android.support.annotation.Nullable; -import com.android.billingclient.api.BillingClient; -import com.android.billingclient.api.BillingClientStateListener; -import com.android.billingclient.api.Purchase; -import com.android.billingclient.api.PurchasesUpdatedListener; import com.commonsware.cwac.anddown.AndDown; import com.crashlytics.android.Crashlytics; import com.wbrawner.simplemarkdown.model.MarkdownFile; @@ -22,27 +17,18 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; -import java.util.List; -public class MarkdownPresenterImpl - implements MarkdownPresenter, BillingClientStateListener, PurchasesUpdatedListener { +public class MarkdownPresenterImpl implements MarkdownPresenter { private final Object fileLock = new Object(); private MarkdownFile file; private volatile MarkdownEditView editView; private volatile MarkdownPreviewView previewView; private Handler fileHandler = new Handler(); - private BillingClient billingClient; public MarkdownPresenterImpl(Context context, MarkdownFile file) { synchronized (fileLock) { this.file = file; } - - - billingClient = BillingClient.newBuilder(context.getApplicationContext()) - .setListener(this) - .build(); - billingClient.startConnection(this); } @Override @@ -255,24 +241,4 @@ public class MarkdownPresenterImpl } } } - - @Override - public void onBillingSetupFinished(int responseCode) { - if (responseCode != BillingClient.BillingResponse.OK) { - return; - } - - // The billing client is ready. You can query purchases here. - } - - @Override - public void onBillingServiceDisconnected() { - // TODO: Set a flag and just try again later - billingClient.startConnection(this); - } - - @Override - public void onPurchasesUpdated(int responseCode, @Nullable List purchases) { - - } } diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/utility/Utils.java b/app/src/main/java/com/wbrawner/simplemarkdown/utility/Utils.java index a9412f7..122135d 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/utility/Utils.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/utility/Utils.java @@ -8,7 +8,8 @@ import android.os.Environment; import android.os.Handler; import android.os.HandlerThread; import android.preference.PreferenceManager; -import android.support.v4.content.ContextCompat; + +import androidx.core.content.ContextCompat; import com.crashlytics.android.Crashlytics; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/DisableableViewPager.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/DisableableViewPager.java index 253dea4..8ecdc60 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/DisableableViewPager.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/DisableableViewPager.java @@ -2,12 +2,13 @@ package com.wbrawner.simplemarkdown.view; import android.annotation.SuppressLint; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.viewpager.widget.ViewPager; + public class DisableableViewPager extends ViewPager { private boolean isSwipeLocked = false; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivity.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivity.java index 3da7d59..9a1d5d3 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivity.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/ExplorerActivity.java @@ -5,8 +5,6 @@ import android.content.Intent; import android.os.Bundle; import android.os.Environment; import android.os.Handler; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -15,6 +13,9 @@ import android.widget.EditText; import android.widget.ListView; import android.widget.SimpleAdapter; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; + import com.crashlytics.android.Crashlytics; import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.utility.Constants; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java index 2894ae9..d99028c 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.java @@ -7,16 +7,18 @@ import android.content.res.AssetManager; import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.design.widget.TabLayout; -import android.support.v4.app.ActivityCompat; -import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.lifecycle.ViewModelProviders; + import com.crashlytics.android.Crashlytics; +import com.google.android.material.tabs.TabLayout; import com.wbrawner.simplemarkdown.MarkdownApplication; import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.presentation.MarkdownPresenter; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MarkdownInfoActivity.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MarkdownInfoActivity.java index 1eb3cdb..1c183b7 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MarkdownInfoActivity.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MarkdownInfoActivity.java @@ -2,11 +2,12 @@ package com.wbrawner.simplemarkdown.view.activity; import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; import android.webkit.WebView; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; + import com.wbrawner.simplemarkdown.R; import butterknife.BindView; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SettingsActivity.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SettingsActivity.java index a6efcfa..225f0b5 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SettingsActivity.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SettingsActivity.java @@ -1,10 +1,11 @@ package com.wbrawner.simplemarkdown.view.activity; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + import com.wbrawner.simplemarkdown.R; public class SettingsActivity extends AppCompatActivity { diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SplashActivity.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SplashActivity.java index 8fe37cf..86a6997 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SplashActivity.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SplashActivity.java @@ -4,8 +4,9 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import com.crashlytics.android.Crashlytics; import com.wbrawner.simplemarkdown.MarkdownApplication; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SupportActivity.kt b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SupportActivity.kt new file mode 100644 index 0000000..00985ec --- /dev/null +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/SupportActivity.kt @@ -0,0 +1,58 @@ +package com.wbrawner.simplemarkdown.view.activity + +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.android.billingclient.api.* +import java.util.* + +class SupportActivity : AppCompatActivity(), BillingClientStateListener, PurchasesUpdatedListener { + private lateinit var billingClient: BillingClient + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + billingClient = BillingClient.newBuilder(applicationContext) + .setListener(this) + .build() + billingClient.startConnection(this) + + } + + override fun onBillingSetupFinished(responseCode: Int) { + if (responseCode != BillingClient.BillingResponse.OK) { + return + } + + // The billing client is ready. You can query purchases here. + val skuList = ArrayList() + skuList.add("support_the_developer") + val params = SkuDetailsParams.newBuilder() + params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP) + billingClient.querySkuDetailsAsync(params.build()) { responseCode1, skuDetailsList -> + // Process the result. + if (responseCode1 != BillingClient.BillingResponse.OK || skuDetailsList == null) { + return@querySkuDetailsAsync + } + + val skuDetails = skuDetailsList!!.get(0) + val sku = skuDetails.getSku() + val price = skuDetails.getPrice() + Log.d("SimpleMarkdown", + "Got product with sku: " + sku + " and price: " + price + " " + skuDetails.getPriceCurrencyCode()) + val flowParams = BillingFlowParams.newBuilder() + .setSkuDetails(skuDetails) + .build() + val responseCode2 = billingClient.launchBillingFlow(this, flowParams) + } + } + + override fun onBillingServiceDisconnected() { + // TODO: Set a flag and just try again later + billingClient.startConnection(this) + } + + override fun onPurchasesUpdated(responseCode: Int, purchases: List?) { + + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/adapter/EditPagerAdapter.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/adapter/EditPagerAdapter.java index 9b10d5e..3e07ce1 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/adapter/EditPagerAdapter.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/adapter/EditPagerAdapter.java @@ -6,9 +6,10 @@ package com.wbrawner.simplemarkdown.view.adapter; import android.content.Context; import android.content.res.Configuration; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; + +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.view.fragment.EditFragment; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/EditFragment.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/EditFragment.java index de4fa76..ca83ae2 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/EditFragment.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/EditFragment.java @@ -4,9 +4,6 @@ import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -16,6 +13,10 @@ import android.widget.EditText; import android.widget.ScrollView; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + import com.jakewharton.rxbinding2.widget.RxTextView; import com.wbrawner.simplemarkdown.MarkdownApplication; import com.wbrawner.simplemarkdown.R; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/PreviewFragment.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/PreviewFragment.java index bbf10d0..e916eda 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/PreviewFragment.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/PreviewFragment.java @@ -4,14 +4,15 @@ import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + import com.wbrawner.simplemarkdown.BuildConfig; import com.wbrawner.simplemarkdown.MarkdownApplication; import com.wbrawner.simplemarkdown.R; diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/SettingsFragment.java b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/SettingsFragment.java index 370b708..347aecb 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/SettingsFragment.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/SettingsFragment.java @@ -7,12 +7,13 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; -import android.support.annotation.Nullable; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.Nullable; + import com.wbrawner.simplemarkdown.R; import com.wbrawner.simplemarkdown.utility.Constants; import com.wbrawner.simplemarkdown.utility.Utils; diff --git a/app/src/main/res/layout/activity_explorer.xml b/app/src/main/res/layout/activity_explorer.xml index 9c75bfc..ba015e8 100644 --- a/app/src/main/res/layout/activity_explorer.xml +++ b/app/src/main/res/layout/activity_explorer.xml @@ -1,12 +1,12 @@ - - - - + - - + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 7be78a9..d190acc 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -4,22 +4,22 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - + diff --git a/app/src/main/res/layout/content_explorer.xml b/app/src/main/res/layout/content_explorer.xml index 178daf3..6af3651 100644 --- a/app/src/main/res/layout/content_explorer.xml +++ b/app/src/main/res/layout/content_explorer.xml @@ -1,5 +1,5 @@ - - + diff --git a/build.gradle b/build.gradle index 81138c3..4edf054 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { + ext.kotlin_version = '1.3.31' repositories { jcenter() google() @@ -9,9 +10,10 @@ buildscript { } } dependencies { - classpath 'com.android.tools.build:gradle:3.4.0' + classpath 'com.android.tools.build:gradle:3.4.1' classpath 'com.google.gms:google-services:4.2.0' classpath 'io.fabric.tools:gradle:1.26.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -22,6 +24,7 @@ allprojects { url "https://s3.amazonaws.com/repo.commonsware.com" } maven { url 'https://maven.google.com' } + google() } } diff --git a/gradle.properties b/gradle.properties index aac7c9b..9e6fce1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode.