|
|
@ -2,25 +2,36 @@ package com.example.beacondemo.Activity; |
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
import androidx.appcompat.app.AlertDialog; |
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager; |
|
|
|
import androidx.recyclerview.widget.RecyclerView; |
|
|
|
|
|
|
|
import android.annotation.SuppressLint; |
|
|
|
import android.content.Intent; |
|
|
|
import android.graphics.Color; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.provider.SyncStateContract; |
|
|
|
import android.text.Html; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.TextView; |
|
|
|
import android.widget.Toast; |
|
|
|
|
|
|
|
import com.example.beacondemo.R; |
|
|
|
import com.example.beacondemo.adapter.RecycleAdapter; |
|
|
|
import com.minew.beaconplus.sdk.MTCentralManager; |
|
|
|
import com.minew.beaconplus.sdk.MTConnectionFeature; |
|
|
|
import com.minew.beaconplus.sdk.MTConnectionHandler; |
|
|
|
import com.minew.beaconplus.sdk.MTFrameHandler; |
|
|
|
import com.minew.beaconplus.sdk.MTPeripheral; |
|
|
|
import com.minew.beaconplus.sdk.enums.ConnectState; |
|
|
|
import com.minew.beaconplus.sdk.enums.FeatureSupported; |
|
|
|
import com.minew.beaconplus.sdk.enums.FrameType; |
|
|
|
import com.minew.beaconplus.sdk.enums.PasswordState; |
|
|
|
import com.minew.beaconplus.sdk.enums.TriggerType; |
|
|
|
import com.minew.beaconplus.sdk.enums.Version; |
|
|
|
import com.minew.beaconplus.sdk.exception.MTException; |
|
|
@ -44,6 +55,7 @@ import com.minew.beaconplus.sdk.interfaces.SetTriggerListener; |
|
|
|
import com.minew.beaconplus.sdk.model.Trigger; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
public class DetailActivity extends AppCompatActivity implements View.OnClickListener { |
|
|
@ -69,6 +81,8 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis |
|
|
|
RecyclerView mRecycle; |
|
|
|
|
|
|
|
ArrayList<MinewFrame> advFrames; |
|
|
|
TextView tv_resetPass; |
|
|
|
EditText edtPassR,edtConPassR; |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
@ -80,6 +94,48 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis |
|
|
|
initView(); |
|
|
|
initData(); |
|
|
|
initListener(); |
|
|
|
|
|
|
|
|
|
|
|
tv_resetPass.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
resetPassword(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@SuppressLint("MissingInflatedId") |
|
|
|
public void resetPassword() { |
|
|
|
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); |
|
|
|
LayoutInflater inflater = this.getLayoutInflater(); |
|
|
|
dialogBuilder.setCancelable(false); |
|
|
|
final View dialogView = inflater.inflate(R.layout.password_reset, null); |
|
|
|
dialogBuilder.setView(dialogView); |
|
|
|
edtPassR = dialogView.findViewById(R.id.edtPassR); |
|
|
|
edtConPassR = dialogView.findViewById(R.id.edtConPassR); |
|
|
|
|
|
|
|
//System.out.println("Value of userPass "+String.valueOf(userPass)); |
|
|
|
dialogBuilder.setPositiveButton("SUBMIT", null); |
|
|
|
dialogBuilder.setTitle("Reset Password"); |
|
|
|
dialogBuilder.setMessage("Please enter password to you want to reset."); |
|
|
|
|
|
|
|
dialogBuilder.setNegativeButton("CANCEL",null); |
|
|
|
final AlertDialog b = dialogBuilder.create(); |
|
|
|
b.show(); |
|
|
|
Button positiveButton = b.getButton(AlertDialog.BUTTON_POSITIVE); |
|
|
|
Button cancel = b.getButton(AlertDialog.BUTTON_NEGATIVE); |
|
|
|
positiveButton.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
} |
|
|
|
}); |
|
|
|
cancel.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
b.dismiss(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void initView() { |
|
|
@ -96,6 +152,8 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis |
|
|
|
txt_zaxis=findViewById(R.id.txt_zaxis); |
|
|
|
|
|
|
|
mRecycle = findViewById(R.id.recycle); |
|
|
|
tv_resetPass = findViewById(R.id.tv_resetPass); |
|
|
|
|
|
|
|
|
|
|
|
Intent intent = getIntent(); |
|
|
|
String mac = intent.getStringExtra("mac"); |
|
|
@ -292,6 +350,40 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis |
|
|
|
return super.toString(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/*MTConnectionHandler mtConnectionHandler = mtPeripheral.mMTConnectionHandler; |
|
|
|
ConnectState connectState = mtConnectionHandler.getConnectState(); |
|
|
|
// password require or not. None, Require |
|
|
|
PasswordState passwordState = mMTConnectionHandler.getPasswordState(); |
|
|
|
// device info, such as:(Firmware Version: 0.9.1); |
|
|
|
HashMap<String, String> systeminfos = (HashMap<String, String>) mMTConnectionHandler.systeminfos; |
|
|
|
String manufacturer = systeminfos.get(SyncStateContract.Constants.manufacturer); |
|
|
|
String modlenumber = systeminfos.get(Constants.modlenumber); |
|
|
|
String macAddress = systeminfos.get(Constants.serialnumber); |
|
|
|
String hardware = systeminfos.get(Constants.hardware); |
|
|
|
String firmware = systeminfos.get(Constants.firmware); |
|
|
|
String software = systeminfos.get(Constants.software);*/ |
|
|
|
|
|
|
|
// device features |
|
|
|
/*MTConnectionFeature mtConnectionFeature = mMTConnectionHandler.mTConnectionFeature; |
|
|
|
// atitude of slot(s), |
|
|
|
int slotAtitude = mtConnectionFeature.getSlotAtitude(); |
|
|
|
Log.d("slotAtitude", String.valueOf(slotAtitude)); |
|
|
|
// parameters can be modified:none,adv,txpower,adv/txpower |
|
|
|
FeatureSupported featureSupported = mtConnectionFeature.getFeatureSupported(); |
|
|
|
Log.d("featureSupported", String.valueOf(featureSupported)); |
|
|
|
// // frames supported(multiple) |
|
|
|
List<FrameType> supportedSlots = mtConnectionFeature.getSupportedSlots(); |
|
|
|
Log.d("supportedSlots", String.valueOf(supportedSlots)); |
|
|
|
// Txpower supported(multiple) |
|
|
|
byte[] supportedTxpowers = mtConnectionFeature.getSupportedTxpowers(); |
|
|
|
Log.d("supportedTxpowers", String.valueOf(supportedTxpowers)); |
|
|
|
// trigger supported(multiple) |
|
|
|
ArrayList<TriggerType> supportTriggers = (ArrayList<TriggerType>) mtConnectionFeature.supportTriggers; |
|
|
|
Log.d("supportTriggers", String.valueOf(supportTriggers)); |
|
|
|
// Version of firmware; |
|
|
|
Version version = mtConnectionFeature.getVersion(); |
|
|
|
Log.d("version", String.valueOf(version));*/ |
|
|
|
} |
|
|
|
|
|
|
|
private void initListener() { |
|
|
@ -300,7 +392,9 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis |
|
|
|
} |
|
|
|
|
|
|
|
public void saveTrigger() { |
|
|
|
System.out.println("Inside save trigger method"); |
|
|
|
Version version = this.mMTConnectionHandler.mTConnectionFeature.getVersion(); |
|
|
|
System.out.println("Version Inside save trigger method" + version.getValue()); |
|
|
|
if (version.getValue() >= 4) { |
|
|
|
if (this.mMTConnectionHandler.mTConnectionFeature.supportTriggers.size() > 0 |
|
|
|
&& this.mMTConnectionHandler.triggers.size() > 0) { |
|
|
|