Skip to content

Commit

Permalink
android update ttlock sdk version to 3.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
xtc committed Oct 19, 2023
1 parent 8bd63f5 commit 99757f1
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 34 deletions.
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

13 changes: 10 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ android {
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
debug {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
minifyEnabled true
shrinkResources true
zipAlignEnabled true
}
release {
buildConfigField "String", "API_URL", '"http://120.26.119.23:8085"'
minifyEnabled false
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand Down Expand Up @@ -47,7 +54,7 @@ dependencies {
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.2.6'
implementation 'com.ttlock:ttlock:3.3.7'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
}
Expand Down
10 changes: 6 additions & 4 deletions proguard-rules.pro → app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@
-dontwarn okio.**
#

#库的公共对外类和方法不被混淆
-keep public class com.ttlock.bl.sdk.** {*;}
-keep class com.ttlock.bl.sdk.api.PassageModeData {*;}


#============================Gson Start==============================
# Gson uses generic type information stored in a class file when working with fields. Proguard
Expand All @@ -150,4 +148,8 @@
#===========DFU======
-keep class com.ttlock.bl.sdk.service.DfuService.**{*;}
-keep class no.nordicsemi.android.dfu.** { *; }
#===========DFU======
#===========DFU======
#库的公共对外类和方法不被混淆
-keep public class com.ttlock.bl.sdk.** {*;}
-keep class com.ttlock.bl.sdk.api.PassageModeData {*;}

1 change: 1 addition & 0 deletions app/src/main/java/ttlock/demo/AuthActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

import com.ttlock.bl.sdk.util.DigitUtil;
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/ttlock/demo/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.ttlock.bl.sdk.api.TTLockClient;
import com.ttlock.bl.sdk.entity.LockError;
import com.ttlock.bl.sdk.keypad.model.KeypadError;

import java.text.SimpleDateFormat;
import java.util.Date;
Expand Down Expand Up @@ -51,6 +52,10 @@ public void makeErrorToast(LockError error){
Toast.makeText(this,error.getDescription(),Toast.LENGTH_LONG).show();
}

public void makeErrorToast(KeypadError error){
Toast.makeText(this,error.getDescription(),Toast.LENGTH_LONG).show();
}


/**
* make sure Bluetooth is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ private void initListener() {
//TODO:
configureGatewayInfo.plugName = device.getAddress();

configureGatewayInfo.plugVersion = device.getGatewayType();

GatewayClient.getDefault().initGateway(configureGatewayInfo, new InitGatewayCallback() {
@Override
public void onInitGatewaySuccess(DeviceInfo deviceInfo) {
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/ttlock/demo/lock/LockApiActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ public void onGetLockStatusSuccess(int status) {
makeToast("lock status is now " + status);
}

@Override
public void onGetDoorSensorStatusSuccess(int status) {

}

@Override
public void onFail(LockError error) {
makeErrorToast(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void setPassageMode2Lock(){
modeData.setEndDate(18 * 60);//pm: 6:00
modeData.setModeType(PassageModeType.Weekly);
//if mode is Weekly,then the WeekDays is
int[] mCircleWeeksArray = {1,2,3,4,5};
int[] mCircleWeeksArray = {1,2,3,4};
modeData.setRepeatWeekOrDays(GsonUtil.toJson(mCircleWeeksArray));
showConnectLockToast();
TTLockClient.getDefault().setPassageMode(modeData, mCurrentLock.getLockData(), mCurrentLock.getLockMac(), new SetPassageModeCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

import com.google.gson.reflect.TypeToken;
import com.ttlock.bl.sdk.api.TTLockClient;
import com.ttlock.bl.sdk.api.WirelessKeypadClient;
import com.ttlock.bl.sdk.callback.InitKeypadCallback;
import com.ttlock.bl.sdk.callback.ScanKeypadCallback;
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.keypad.InitKeypadCallback;
import com.ttlock.bl.sdk.keypad.ScanKeypadCallback;
import com.ttlock.bl.sdk.keypad.WirelessKeypadClient;
import com.ttlock.bl.sdk.keypad.model.InitKeypadResult;
import com.ttlock.bl.sdk.keypad.model.KeypadError;
import com.ttlock.bl.sdk.util.FeatureValueUtil;

import java.util.HashMap;
Expand Down Expand Up @@ -96,15 +98,15 @@ public void onClick(WirelessKeypad device) {
* String lockmac: the lock which need add wireless key pad Mac address
* InitKeypadCallback callback :
*/
WirelessKeypadClient.getDefault().initializeKeypad(device, mCurrentLock.getLockMac(), new InitKeypadCallback() {
WirelessKeypadClient.getDefault().initializeKeypad(device, mCurrentLock.getLockMac(), new InitKeypadCallback() {
@Override
public void onInitKeypadSuccess(int specialValue) {
public void onInitKeypadSuccess(InitKeypadResult initKeypadResult) {
makeToast("=---add success-- upload to server to finish-");
uploadToServer(device,specialValue);
uploadToServer(device, initKeypadResult);
}

@Override
public void onFail(LockError error) {
public void onFail(KeypadError error) {
makeErrorToast(error);
}
});
Expand All @@ -124,8 +126,8 @@ public void onScanKeyboardSuccess(WirelessKeypad device) {
}

@Override
public void onFail(LockError error) {
makeErrorToast(error);
public void onScanFailed(int error) {

}
});
}
Expand Down Expand Up @@ -154,7 +156,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
}
}

private void uploadToServer(WirelessKeypad device, int specialValue){
private void uploadToServer(WirelessKeypad device, InitKeypadResult initKeypadResult){
ApiService apiService = RetrofitAPIManager.provideClientApi();
HashMap<String,String> params = new HashMap<>(8);
String wirelessKeypadAlias = "MyTestPad-" + DateUtils.getMillsTimeFormat(System.currentTimeMillis());
Expand All @@ -164,7 +166,7 @@ private void uploadToServer(WirelessKeypad device, int specialValue){
params.put("wirelessKeyboardNumber",device.getName());
params.put("wirelessKeyboardName",wirelessKeypadAlias);
params.put("wirelessKeyboardMac",String.valueOf(device.getAddress()));
params.put("wirelessKeyboardSpecialValue",String.valueOf(specialValue));
params.put("wirelessKeypadFeatureValue", initKeypadResult.getFeatureValue());
params.put("date",String.valueOf(System.currentTimeMillis()));


Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_admin_passcode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Button
android:layout_width="wrap_content"
android:layout_height="60dp"
app:layout_constraintTop_toBottomOf="@id/tv_end_date"
app:layout_constraintTop_toBottomOf="parent"
android:id="@+id/btn_get"
android:textAllCaps="false"
android:text="@string/get_admin_passcode"/>
Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

ext {
agp_version = '7.2.2'
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools:r8:8.0.40'

classpath "com.android.tools.build:gradle:4.1.2"

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
Expand Down

0 comments on commit 99757f1

Please sign in to comment.