package com.example.nexilissamplecodeburger;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import io.nexilis.service.Callback;
import io.nexilis.service.API;
import io.nexilis.service.utils.callback.SimCardDetectionCallback;
import io.nexilis.service.utils.xthunder.FloatingButton;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /**
         *
         * Nexilis provides an API security shield service, which functions to detect threats such as malware, ADB, screencapture, and Sim Swapping.
         */

        //SECURITY

        //SMS
        //EMAIL
        //SMARTBOT
        
        /*************************************
         Connect to our server with your nexilis.io Account, and implement the required Callback.
         Please Subscribe or contact us to get your nexilis.io Account.
         Do not share your nexilis.io Account or ever give it out to someone outside your organization.
         ************************************/
        /**
         * API.connect (String NexilisAccount, Activity RegisteredActivity, int NexilisButtonMode, boolean UserMayModifyUID, Callback ConnectCallback)
         *
         * NexilisAccount 		: Your Nexilis.io Account.
         * RegisteredActivity 	: Android's Activity class that is used to register the Nexilis Button
         * NexilisButtonMode 	: The flag that determines when the Nexilis Button should appear.
         *      0 = Disabled Nexilis Button
         * 		1 = Within registered Activity, (Nexilis Button only appears when users are in the registered activity)
         * 		2 = Within App (Nexilis Button always appears as long as user is in the App),
         * 		3 = Always On (Nexilis Button always appears even if the application process is closed)
         * UserMayModifyUID 	: Sets whether users are allowed to change the Nexilis UserID.
         * 		true = enabled,
         * 		false = disabled
         * ConnectCallback	: The callback interface to be invoked when calling the method connect.
         * 		You need to implement onSuccess(String NexilisUserID) & onFailed(String reasonCode) to handle the RESULT.
         *
         */
        API.connect("***REPLACE***WITH***YOUR***NEXILIS***ACCOUNT***", this, 0, new Callback() {

            @Override
            public void onSuccess(final String NexilisUserID) {
                /**************************************
                 The NexilisUserID parameter is generated automatically and can be mapped to a User ID on the application level.
                 For example, the Nexilis User ID (e.g. User001) can be mapped into the corresponding Application User ID (e.g. John Doe),
                 so you don't have to share your Application User ID with Nexilis while still being able to monitor your user activities.
                 **************************************/
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        //FLOATING
                        Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID, Toast.LENGTH_LONG).show();
                    }
                });
            }

            @Override
            public void onFailed(final String reasonCode) {
                /**
                 * reasonCode 	: Returns a code based on the status of the function connect called.
                 * 		2:Your trial subscription has expired. Please subscribe to continue using Nexilis.
                 * 		3:Your monthly subscription is not paid in full. Please pay your monthly subscription bill to continue using Nexilis service.
                 * 		4:Your Customer Engagement Credit has run out and your Prepaid Credit Balance is empty. Please top-up your Prepaid Credit Balance to continue using Nexilis
                 *		23:Unsupported Android version
                 * 		93:Missing the required overlay permission
                 * 		94:Unregistered User
                 * 		95:Invalid Nexilis Button Mode (1,2,3)
                 * 		96:Activity is null
                 * 		97:Account is empty
                 * 		98:Your account didn't match
                 * 		99:Something went wrong
                 */
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getBaseContext(), reasonCode, Toast.LENGTH_LONG).show();
                    }
                });
            }
        });
        /**
         *
         * An OPTIONAL Method to change your Nexilis User ID
         * You can call this method anytime after Nexilis.connect calls onSuccess
         *
         * String ResponCode = Nexilis.changeUsername(String NewUserID)
         *
         * ResponCode 	: Returns a code based on the status of the function call.
         * 		00:Success
         *		23:Unsupported Android version
         * 		94:Unregistered User
         * 		96:Activity is null
         * 		97:Account is empty
         * 		101:Unable to access server. Check your connection and try again later
         * 		102:Duplicate username
         * 		103:Username is empty
         * 		104:Username length is too short
         * 		105:Username length is too long
         * 		106:Illegal State. Be sure call Nexilis.connect and #callback state onSuccess called
         * NewUserID	: Desired User ID
         */
    }
    //BREAK
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        //FEATURES
        return super.onOptionsItemSelected(item);
    }
}