// Path: fidoclient/src/main/java/com/yalin/fidoclient/api/UAFClientApi.java
// public class UAFClientApi {
//     public static void doDiscover(Activity activity, int requestCode) {
//         if (activity == null) {
//             throw new IllegalArgumentException();
//         }
//         Intent intent = UAFIntent.getDiscoverIntent();
//         activity.startActivityForResult(intent, requestCode);
//     }
// 
//     public static void doCheckPolicy(Activity activity, int requestCode, String responseMessage) {
//         if (activity == null || TextUtils.isEmpty(responseMessage)) {
//             throw new IllegalArgumentException();
//         }
//         Intent intent = UAFIntent.getCheckPolicyIntent(new UAFMessage(responseMessage).toJson(), activity.getApplication().getPackageName());
//         activity.startActivityForResult(intent, requestCode);
//     }
// 
//     public static void doOperation(Activity activity, int requestCode, String responseMessage, String channelBinding) {
//         if (activity == null || TextUtils.isEmpty(responseMessage)) {
//             throw new IllegalArgumentException();
//         }
//         Intent intent = UAFIntent.getUAFOperationIntent(new UAFMessage(responseMessage).toJson(), null, channelBinding);
//         activity.startActivityForResult(intent, requestCode);
//     }
// 
//     public static void doOperation(Fragment fragment, int requestCode, String responseMessage, String channelBinding) {
//         if (fragment == null || TextUtils.isEmpty(responseMessage)) {
//             throw new IllegalArgumentException();
//         }
//         Intent intent = UAFIntent.getUAFOperationIntent(new UAFMessage(responseMessage).toJson(), null, channelBinding);
//         fragment.startActivityForResult(intent, requestCode);
//     }
// 
//     public static List<RegRecord> getRegRecords(String username) {
//         if (TextUtils.isEmpty(username)) {
//             throw new IllegalArgumentException();
//         }
//         return null;
//     }
// 
//     public static DeregistrationRequest[] getDeRegistrationRequests(RegRecord regRecord) {
//         if (regRecord == null) {
//             throw new IllegalArgumentException("regRecord must not be null!");
//         }
//         DeregistrationRequest[] deRegistrationRequests = new DeregistrationRequest[1];
//         deRegistrationRequests[0] = new DeregistrationRequest();
//         deRegistrationRequests[0].authenticators = new DeregisterAuthenticator[1];
//         deRegistrationRequests[0].authenticators[0] = new DeregisterAuthenticator();
//         deRegistrationRequests[0].authenticators[0].aaid = regRecord.aaid;
//         deRegistrationRequests[0].authenticators[0].keyID = regRecord.keyId;
// 
//         return deRegistrationRequests;
//     }
// 
//     public static AsmInfo getDefaultAsmInfo(Context context) {
//         return UAFClientActivity.getAsmInfo(context);
//     }
// 
//     public static void clearDefaultAsm(Context context) {
//         UAFClientActivity.setAsmInfo(context, null);
//     }
// }
// 
// Path: fidoclient/src/main/java/com/yalin/fidoclient/msg/AsmInfo.java
// public class AsmInfo {
//     public String appName;
//     public String pack;
//     public Drawable icon;
// 
//     public AsmInfo appName(String appName) {
//         this.appName = appName;
//         return this;
//     }
// 
//     public AsmInfo pack(String pack) {
//         this.pack = pack;
//         return this;
//     }
// 
//     public AsmInfo icon(Drawable icon) {
//         this.icon = icon;
//         return this;
//     }
// }


import android.content.DialogInterface;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import com.yalin.fidoclient.R;
import com.yalin.fidoclient.api.UAFClientApi;
import com.yalin.fidoclient.msg.AsmInfo;
/*
 * Copyright 2016 YaLin Jin
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.yalin.fidoclient.ui;



public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = MainActivity.class.getSimpleName();
    private View rootCoordinator;

    private AsmInfo asmInfo;

    private Button btnDefaultAsm;

    private boolean hasDefault = false;

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

        initView();
        initData();
    }

    private void initView() {
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        rootCoordinator = findViewById(R.id.root_coordinator);

        btnDefaultAsm = (Button) findViewById(R.id.setting_btn_asm_name);
        btnDefaultAsm.setOnClickListener(this);
    }

    private void initData() {
// Path: fidoclient/src/main/java/com/yalin/fidoclient/api/UAFClientApi.java
// public class UAFClientApi {
//     public static void doDiscover(Activity activity, int requestCode) {
//         if (activity == null) {
//             throw new IllegalArgumentException();
//         }
//         Intent intent = UAFIntent.getDiscoverIntent();
//         activity.startActivityForResult(intent, requestCode);
//     }
// 
//     public static void doCheckPolicy(Activity activity, int requestCode, String responseMessage) {
//         if (activity == null || TextUtils.isEmpty(responseMessage)) {
//             throw new IllegalArgumentException();
//         }
//         Intent intent = UAFIntent.getCheckPolicyIntent(new UAFMessage(responseMessage).toJson(), activity.getApplication().getPackageName());
//         activity.startActivityForResult(intent, requestCode);
//     }
// 
//     public static void doOperation(Activity activity, int requestCode, String responseMessage, String channelBinding) {
//         if (activity == null || TextUtils.isEmpty(responseMessage)) {
//             throw new IllegalArgumentException();
//         }
//         Intent intent = UAFIntent.getUAFOperationIntent(new UAFMessage(responseMessage).toJson(), null, channelBinding);
//         activity.startActivityForResult(intent, requestCode);
//     }
// 
//     public static void doOperation(Fragment fragment, int requestCode, String responseMessage, String channelBinding) {
//         if (fragment == null || TextUtils.isEmpty(responseMessage)) {
//             throw new IllegalArgumentException();
//         }
//         Intent intent = UAFIntent.getUAFOperationIntent(new UAFMessage(responseMessage).toJson(), null, channelBinding);
//         fragment.startActivityForResult(intent, requestCode);
//     }
// 
//     public static List<RegRecord> getRegRecords(String username) {
//         if (TextUtils.isEmpty(username)) {
//             throw new IllegalArgumentException();
//         }
//         return null;
//     }
// 
//     public static DeregistrationRequest[] getDeRegistrationRequests(RegRecord regRecord) {
//         if (regRecord == null) {
//             throw new IllegalArgumentException("regRecord must not be null!");
//         }
//         DeregistrationRequest[] deRegistrationRequests = new DeregistrationRequest[1];
//         deRegistrationRequests[0] = new DeregistrationRequest();
//         deRegistrationRequests[0].authenticators = new DeregisterAuthenticator[1];
//         deRegistrationRequests[0].authenticators[0] = new DeregisterAuthenticator();
//         deRegistrationRequests[0].authenticators[0].aaid = regRecord.aaid;
//         deRegistrationRequests[0].authenticators[0].keyID = regRecord.keyId;
// 
//         return deRegistrationRequests;
//     }
// 
//     public static AsmInfo getDefaultAsmInfo(Context context) {
//         return UAFClientActivity.getAsmInfo(context);
//     }
// 
//     public static void clearDefaultAsm(Context context) {
//         UAFClientActivity.setAsmInfo(context, null);
//     }
// }
// 
// Path: fidoclient/src/main/java/com/yalin/fidoclient/msg/AsmInfo.java
// public class AsmInfo {
//     public String appName;
//     public String pack;
//     public Drawable icon;
// 
//     public AsmInfo appName(String appName) {
//         this.appName = appName;
//         return this;
//     }
// 
//     public AsmInfo pack(String pack) {
//         this.pack = pack;
//         return this;
//     }
// 
//     public AsmInfo icon(Drawable icon) {
//         this.icon = icon;
//         return this;
//     }
// }


// Path: fidoclient/src/main/java/com/yalin/fidoclient/ui/MainActivity.java
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import com.yalin.fidoclient.R;
import com.yalin.fidoclient.api.UAFClientApi;
import com.yalin.fidoclient.msg.AsmInfo;

/*
 * Copyright 2016 YaLin Jin
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.yalin.fidoclient.ui;



public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = MainActivity.class.getSimpleName();
    private View rootCoordinator;

    private AsmInfo asmInfo;

    private Button btnDefaultAsm;

    private boolean hasDefault = false;

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

        initView();
        initData();
    }

    private void initView() {
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        rootCoordinator = findViewById(R.id.root_coordinator);

        btnDefaultAsm = (Button) findViewById(R.id.setting_btn_asm_name);
        btnDefaultAsm.setOnClickListener(this);
    }

    private void initData() {
        asmInfo = UAFClientApi.getDefaultAsmInfo(getApplicationContext());