use of org.flyve.mdm.agent.core.deeplink.DeeplinkPresenter in project android-mdm-agent by flyve-mdm.
the class StartEnrollmentActivity method onCreate.
/**
* Called when the activity is starting
* It shows the UI to start the enrollment
* @param savedInstanceState if the activity is being re-initialized, it contains the data it most recently supplied
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start_enrollment);
sendBroadcast();
presenter = new DeeplinkPresenter(this);
// check if broker is on cache open the main activity
MqttData cache = new MqttData(StartEnrollmentActivity.this);
if (!cache.getBroker().isEmpty()) {
openMain();
}
TextView txtIntro = findViewById(R.id.txtIntro);
txtIntro.setText(Html.fromHtml(StartEnrollmentActivity.this.getResources().getString(R.string.walkthrough_step_1)));
txtIntro.setMovementMethod(LinkMovementMethod.getInstance());
txtMessage = findViewById(R.id.txtMessage);
txtTitle = findViewById(R.id.txtTitle);
pb = findViewById(R.id.progressBar);
// get the deeplink
String deeplink = "";
Intent intent = getIntent();
Uri data = null;
// come from QR scan
Bundle bundle = intent.getExtras();
if (bundle != null) {
String str = bundle.getString("data");
if (str != null) {
data = Uri.parse(str);
}
}
// come from deeplink
if (data == null) {
data = intent.getData();
}
try {
deeplink = data.getQueryParameter("data");
} catch (Exception ex) {
presenter.showSnackError(CommonErrorType.DEEPLINK_GETQUERYPARAMETER, ex.getMessage());
}
TextView txtVersion = findViewById(R.id.txtVersion);
txtVersion.setText(MDMAgent.getCompleteVersion());
presenter.lint(StartEnrollmentActivity.this, deeplink);
btnEnroll = findViewById(R.id.btnEnroll);
btnEnroll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (OptionsEnrollmentActivity.needOptions()) {
Intent miIntent = new Intent(StartEnrollmentActivity.this, OptionsEnrollmentActivity.class);
StartEnrollmentActivity.this.startActivity(miIntent);
StartEnrollmentActivity.this.finish();
} else {
Intent miIntent = new Intent(StartEnrollmentActivity.this, PermissionEnrollmentActivity.class);
StartEnrollmentActivity.this.startActivity(miIntent);
StartEnrollmentActivity.this.finish();
}
}
});
}