支持AndroidX版本

pull/27/head
jenly1314 5 years ago
parent cd4fa1ea7a
commit 55e92e5f17
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. 10
      .idea/misc.xml
  3. 2
      app-dialog/build.gradle
  4. 6
      app-dialog/src/androidTest/java/com/king/app/dialog/ExampleInstrumentedTest.java
  5. 11
      app-dialog/src/main/java/com/king/app/dialog/AppDialog.java
  6. 13
      app-dialog/src/main/java/com/king/app/dialog/AppDialogConfig.java
  7. 7
      app-dialog/src/main/java/com/king/app/dialog/fragment/BaseDialogFragment.java
  8. 2
      app-updater/build.gradle
  9. 5
      app-updater/src/androidTest/java/com/king/app/updater/ExampleInstrumentedTest.java
  10. 7
      app-updater/src/main/java/com/king/app/updater/AppUpdater.java
  11. 3
      app-updater/src/main/java/com/king/app/updater/UpdateConfig.java
  12. 3
      app-updater/src/main/java/com/king/app/updater/http/HttpManager.java
  13. 3
      app-updater/src/main/java/com/king/app/updater/http/IHttpManager.java
  14. 3
      app-updater/src/main/java/com/king/app/updater/provider/AppUpdaterFileProvider.java
  15. 13
      app-updater/src/main/java/com/king/app/updater/service/DownloadService.java
  16. 4
      app-updater/src/main/java/com/king/app/updater/util/AppUtils.java
  17. 7
      app-updater/src/main/java/com/king/app/updater/util/PermissionUtils.java
  18. 3
      app-updater/src/main/java/com/king/app/updater/util/SSLSocketFactoryUtils.java
  19. 2
      app/build.gradle
  20. BIN
      app/release/app-release.apk
  21. 2
      app/release/output.json
  22. 5
      app/src/androidTest/java/com/king/appupdater/ExampleInstrumentedTest.java
  23. 5
      app/src/main/java/com/king/appupdater/MainActivity.java
  24. 4
      app/src/main/res/layout/activity_main.xml
  25. 24
      versions.gradle

@ -5,7 +5,7 @@
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="7">
<list size="10">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
@ -13,18 +13,24 @@
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="6">
<list size="9">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
</list>
</value>
</option>

@ -11,7 +11,7 @@ android {
targetSdkVersion build_versions.targetSdk
versionCode app_version.versionCode
versionName app_version.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

@ -1,11 +1,10 @@
package com.king.app.dialog;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.InstrumentationRegistry;
import static org.junit.Assert.*;
@ -14,7 +13,6 @@ import static org.junit.Assert.*;
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {

@ -3,10 +3,6 @@ package com.king.app.dialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
@ -17,6 +13,11 @@ import android.widget.TextView;
import com.king.app.dialog.fragment.AppDialogFragment;
import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
@ -38,7 +39,7 @@ public enum AppDialog {
* @param config 弹框配置 {@link AppDialogConfig}
* @return
*/
public View createAppDialogView(@NonNull Context context,@NonNull AppDialogConfig config){
public View createAppDialogView(@NonNull Context context, @NonNull AppDialogConfig config){
View view = config.getView(context);
TextView tvDialogTitle = view.findViewById(config.getTitleId());
setText(tvDialogTitle,config.getTitle());

@ -1,12 +1,13 @@
package com.king.app.dialog;
import android.content.Context;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
@ -14,11 +15,13 @@ public class AppDialogConfig {
/**
* 布局ID
*/
private @LayoutRes int layoutId = R.layout.app_dialog;
private @LayoutRes
int layoutId = R.layout.app_dialog;
/**
* 标题视图ID
*/
private @IdRes int titleId = R.id.tvDialogTitle;
private @IdRes
int titleId = R.id.tvDialogTitle;
/**
* 内容视图ID
*/

@ -5,9 +5,6 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
@ -18,6 +15,10 @@ import android.widget.TextView;
import com.king.app.dialog.R;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/

@ -11,7 +11,7 @@ android {
targetSdkVersion build_versions.targetSdk
versionCode app_version.versionCode
versionName app_version.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

@ -1,12 +1,13 @@
package com.king.app.updater;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import static org.junit.Assert.*;
/**

@ -6,8 +6,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
@ -19,6 +17,9 @@ import com.king.app.updater.util.PermissionUtils;
import java.util.Map;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
@ -43,7 +44,7 @@ public class AppUpdater {
private ServiceConnection mServiceConnection;
public AppUpdater(@NonNull Context context,@NonNull UpdateConfig config){
public AppUpdater(@NonNull Context context, @NonNull UpdateConfig config){
this.mContext = context;
this.mConfig = config;
}

@ -4,13 +4,14 @@ package com.king.app.updater;
import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.DrawableRes;
import com.king.app.updater.constant.Constants;
import java.util.HashMap;
import java.util.Map;
import androidx.annotation.DrawableRes;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>

@ -2,7 +2,6 @@ package com.king.app.updater.http;
import android.os.AsyncTask;
import android.os.Build;
import android.support.annotation.Nullable;
import android.util.Log;
import com.king.app.updater.constant.Constants;
@ -18,6 +17,8 @@ import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import androidx.annotation.Nullable;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/

@ -1,11 +1,12 @@
package com.king.app.updater.http;
import android.support.annotation.Nullable;
import java.io.File;
import java.io.Serializable;
import java.util.Map;
import androidx.annotation.Nullable;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/

@ -1,6 +1,7 @@
package com.king.app.updater.provider;
import android.support.v4.content.FileProvider;
import androidx.core.content.FileProvider;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>

@ -12,11 +12,6 @@ import android.os.Binder;
import android.os.Build;
import android.os.Environment;
import android.os.IBinder;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import android.util.Log;
@ -30,6 +25,12 @@ import com.king.app.updater.util.AppUtils;
import java.io.File;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat;
import androidx.core.content.FileProvider;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
@ -347,7 +348,7 @@ public class DownloadService extends Service {
* @param title
* @param content
*/
private void showStartNotification(int notifyId,String channelId, String channelName,@DrawableRes int icon,CharSequence title,CharSequence content,boolean isVibrate,boolean isSound){
private void showStartNotification(int notifyId, String channelId, String channelName, @DrawableRes int icon, CharSequence title, CharSequence content, boolean isVibrate, boolean isSound){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
createNotificationChannel(channelId,channelName,isVibrate,isSound);
}

@ -7,10 +7,12 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import java.io.File;
import java.lang.Exception;
import androidx.core.content.FileProvider;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>

@ -9,12 +9,13 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/
@ -33,7 +34,7 @@ public enum PermissionUtils {
* @param requestCode
* @return
*/
public boolean verifyReadAndWritePermissions(@NonNull Activity activity,int requestCode){
public boolean verifyReadAndWritePermissions(@NonNull Activity activity, int requestCode){
int readResult = checkPermission(activity,Manifest.permission.READ_EXTERNAL_STORAGE);
int writeResult = checkPermission(activity,Manifest.permission.WRITE_EXTERNAL_STORAGE);

@ -1,7 +1,6 @@
package com.king.app.updater.util;
import android.content.Context;
import android.support.annotation.RawRes;
import java.io.InputStream;
import java.security.KeyManagementException;
@ -21,6 +20,8 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
import androidx.annotation.RawRes;
/**
* @author Jenly <a href="mailto:jenly1314@gmail.com">Jenly</a>
*/

@ -10,7 +10,7 @@ android {
targetSdkVersion build_versions.targetSdk
versionCode app_version.versionCode
versionName app_version.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Binary file not shown.

@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":5,"versionName":"1.0.4","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":6,"versionName":"1.0.4-androidx","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

@ -1,12 +1,13 @@
package com.king.appupdater;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import static org.junit.Assert.*;
/**

@ -4,8 +4,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
@ -24,6 +22,9 @@ import com.king.app.updater.util.PermissionUtils;
import java.io.File;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private final Object mLock = new Object();

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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"
@ -104,4 +104,4 @@
app:layout_constraintRight_toRightOf="parent"
style="@style/OnClick"/>
</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,7 +1,7 @@
//App
def app_version = [:]
app_version.versionCode = 5 //androidx 6
app_version.versionName = "1.0.4"
app_version.versionCode = 6 //androidx 6
app_version.versionName = "1.0.4-androidx"
ext.app_version = app_version
//build version
@ -15,28 +15,30 @@ ext.build_versions = build_versions
// App dependencies
def versions = [:]
//support
versions.supportLibrary = "28.0.0"
versions.supportLibrary = "1.0.0+"
versions.constraintLayout = "1.1.3"
//test
versions.junit = "4.12"
versions.runner = "1.0.2"
versions.espresso = "3.0.2"
versions.junit = "1.1.0"
versions.test = "1.2.0"
versions.runner = "1.2.0"
versions.espresso = "3.2.0"
ext.versions = versions
ext.deps = [:]
//support
def support = [:]
support.appcompat = "com.android.support:appcompat-v7:$versions.supportLibrary"
support.constraintlayout = "com.android.support.constraint:constraint-layout:$versions.constraintLayout"
support.appcompat = "androidx.appcompat:appcompat:$versions.supportLibrary"
support.constraintlayout = "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
deps.support = support
//test
def test = [:]
test.junit = "junit:junit:$versions.junit"
test.runner = "com.android.support.test:runner:$versions.runner"
test.espresso = "com.android.support.test.espresso:espresso-core:$versions.espresso"
test.junit = "androidx.test.ext:junit:$versions.junit"
test.test = "androidx.test:core:$versions.test"
test.runner = "androidx.test:runner:$versions.runner"
test.espresso = "androidx.test.espresso:espresso-core:$versions.espresso"
deps.test = test

Loading…
Cancel
Save