Skip to content

Commit

Permalink
migrate to androidx and update the sdk version to 3.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xtc committed Jul 22, 2022
1 parent 287f038 commit 44648ce
Show file tree
Hide file tree
Showing 56 changed files with 144 additions and 116 deletions.
18 changes: 9 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
Expand Down Expand Up @@ -37,17 +37,17 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
// implementation(name: 'ttlock-release-3.0.7', ext: 'aar')
implementation 'no.nordicsemi.android:dfu:1.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'no.nordicsemi.android:dfu:1.11.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.ttlock:ttlock:3.1.9'
implementation 'com.ttlock:ttlock:3.2.4'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package tool.pubhouse.com.ttlocksdkdemo;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ttlock/demo/AuthActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ttlock.demo;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.view.View;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ttlock/demo/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.Toast;

import com.ttlock.bl.sdk.api.TTLockClient;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ttlock/demo/IndexActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ttlock.demo;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import ttlock.demo.databinding.ActivityIndexBinding;
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/ttlock/demo/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package ttlock.demo;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import ttlock.demo.databinding.ActivityMainBinding;
import ttlock.demo.fingerprint.FingerprintActivity;
import ttlock.demo.firmwareupdate.FirmwareUpdateActivity;
import ttlock.demo.gateway.UserGatewayActivity;
import ttlock.demo.iccard.ICCardActivity;
import ttlock.demo.lock.LockApiActivity;
import ttlock.demo.passcode.PasscodeActivity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ttlock.demo.fingerprint;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.google.gson.reflect.TypeToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.google.gson.reflect.TypeToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ttlock.demo.fingerprint;

import android.app.Activity;
import android.databinding.DataBindingUtil;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import androidx.databinding.DataBindingUtil;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ttlock.demo.fingerprint;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import android.util.Log;

import com.google.gson.reflect.TypeToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package ttlock.demo.firmwareupdate;

import android.databinding.DataBindingUtil;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;

Expand Down Expand Up @@ -29,6 +34,7 @@ public class FirmwareUpdateActivity extends BaseActivity {
private ActivityFirmwareUpdateBinding binding;
private LockUpgradeObj lockUpgradeObj;
private boolean isFailure;
protected static final int REQUEST_PERMISSION_REQ_CODE = 11;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -131,6 +137,10 @@ public void onFail(LockError error) {
}

private void startDfu() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_REQ_CODE);
return;
}
if (mCurrentLock != null) {
LockDfuClient.getDefault().startDfu(getApplicationContext(), ApiService.CLIENT_ID, MyApplication.getmInstance().getAccountInfo().getAccess_token(), mCurrentLock.getLockId(), mCurrentLock.getLockData(), mCurrentLock.getLockMac(), new DfuCallback() {
@Override
Expand Down Expand Up @@ -186,6 +196,25 @@ private void initListener(){
});
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if(grantResults.length == 0 ){
return;
}

switch (requestCode) {
case REQUEST_PERMISSION_REQ_CODE: {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED && permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)) {
startDfu();
}
break;
}
default:
break;
}
}

/**
* stopBTService should be called when Activity is finishing to release Bluetooth resource.
*/
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/ttlock/demo/gateway/GatewayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.ttlock.bl.sdk.gateway.api.GatewayClient;
import com.ttlock.bl.sdk.gateway.callback.ScanGatewayCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.app.Activity;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.view.View;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.app.Activity;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.text.TextUtils;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ttlock.demo.gateway;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.google.gson.reflect.TypeToken;
import com.ttlock.bl.sdk.util.GsonUtil;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ttlock.demo.gateway.adapter;

import android.app.Activity;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import android.app.Activity;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import android.content.Context;
import android.content.DialogInterface;
import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.NonNull;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -73,7 +73,7 @@ public void onClick(View v) {
}
});

View view = getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet);
View view = getDelegate().findViewById(com.google.android.material.R.id.design_bottom_sheet);
final BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(view);
// bottomSheetBehavior.setSkipCollapsed(false);
// bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ttlock/demo/iccard/ICCardActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ttlock.demo.iccard;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.google.gson.reflect.TypeToken;
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/ttlock/demo/iccard/ICCardListAdapter.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package ttlock.demo.iccard;

import android.app.Activity;
import android.databinding.DataBindingUtil;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import androidx.databinding.DataBindingUtil;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.google.gson.reflect.TypeToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ttlock.demo.iccard;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;

import com.google.gson.reflect.TypeToken;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ttlock.demo.lock;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.google.gson.reflect.TypeToken;
Expand All @@ -10,7 +10,6 @@
import com.ttlock.bl.sdk.callback.SetLockMuteModeCallback;
import com.ttlock.bl.sdk.callback.SetRemoteUnlockSwitchCallback;
import com.ttlock.bl.sdk.constant.FeatureValue;
import com.ttlock.bl.sdk.device.WirelessKeypad;
import com.ttlock.bl.sdk.entity.LockError;
import com.ttlock.bl.sdk.util.FeatureValueUtil;

Expand All @@ -19,7 +18,6 @@
import okhttp3.ResponseBody;
import retrofit2.Call;
import ttlock.demo.BaseActivity;
import ttlock.demo.DateUtils;
import ttlock.demo.MyApplication;
import ttlock.demo.R;
import ttlock.demo.databinding.ActivityEnableDisableSomeLockFuncionBinding;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ttlock/demo/lock/LockApiActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ttlock.demo.lock;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.google.gson.reflect.TypeToken;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ttlock/demo/lock/LockTimeActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ttlock.demo.lock;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.ttlock.bl.sdk.api.TTLockClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ttlock.demo.lock;


import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;

import com.ttlock.bl.sdk.api.TTLockClient;
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/ttlock/demo/lock/ScanLockActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.google.gson.reflect.TypeToken;
import com.ttlock.bl.sdk.api.ExtendedBluetoothDevice;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/ttlock/demo/lock/UnlockActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ttlock.demo.lock;

import android.databinding.DataBindingUtil;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
Expand Down
Loading

0 comments on commit 44648ce

Please sign in to comment.