Move decision of whether to show button into ShowNfcSweetspotActivity

This commit is contained in:
Vincent Breitmoser 2017-10-12 10:05:00 +02:00
parent 287d3251c5
commit dfed7d3c93
2 changed files with 8 additions and 6 deletions

View file

@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -36,7 +35,6 @@ import android.view.animation.Animation;
import org.sufficientlysecure.keychain.BuildConfig; import org.sufficientlysecure.keychain.BuildConfig;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.securitytoken.NfcSweetspotData;
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo; import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction; import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity; import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
@ -94,10 +92,10 @@ public class CreateSecurityTokenWaitFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.create_security_token_wait_fragment, container, false); View view = inflater.inflate(R.layout.create_security_token_wait_fragment, container, false);
boolean showLocateHotspot = NfcSweetspotData.SWEETSPOT_DATA.containsKey(Build.MODEL); boolean showLocateSweetspot = ShowNfcSweetspotActivity.hasSweetspotData();
View locateHotspotView = view.findViewById(R.id.button_locate_nfc); View buttonLocateSweetspot = view.findViewById(R.id.button_locate_nfc);
locateHotspotView.setVisibility(showLocateHotspot ? View.VISIBLE : View.GONE); buttonLocateSweetspot.setVisibility(showLocateSweetspot ? View.VISIBLE : View.GONE);
locateHotspotView.setOnClickListener(new OnClickListener() { buttonLocateSweetspot.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(getActivity(), ShowNfcSweetspotActivity.class); Intent intent = new Intent(getActivity(), ShowNfcSweetspotActivity.class);

View file

@ -113,4 +113,8 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity {
return metrics; return metrics;
} }
public static boolean hasSweetspotData() {
return NfcSweetspotData.SWEETSPOT_DATA.containsKey(Build.MODEL);
}
} }