package com.anand.firebaseapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.anand.geofence.reference.AppSharedpreferences;
import com.anand.geofence.sample.RetrofitCall;
import com.google.firebase.messaging.FirebaseMessaging;

public class MainActivity extends AppCompatActivity {
    AppSharedpreferences appSharedpreferences;
    TextView token;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        FirebaseMessaging.getInstance().setAutoInitEnabled(true);
        appSharedpreferences = AppSharedpreferences.getInstance(MainActivity.this);

    }

    private void initView() {
        token = findViewById(R.id.token);

        token.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //String tokenstr = appSharedpreferences.getString("token");
                token.setText(appSharedpreferences.getString("token"));
                Log.i("FCMtoken","FCMtoken : "+appSharedpreferences.getString("token"));
               /* ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("label", token.getText());
                clipboard.setPrimaryClip(clip);*/
                Intent in = new Intent(MainActivity.this, RetrofitCall.class);
                startActivity(in);
            }
        });
    }
}
