use of com.microsoft.appcenter.sasquatch.features.TestFeaturesListAdapter in project AppCenter-SDK-Android by Microsoft.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sSharedPreferences = getSharedPreferences("Sasquatch", Context.MODE_PRIVATE);
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().build());
/* Set custom log URL if one was configured in settings. */
String logUrl = sSharedPreferences.getString(LOG_URL_KEY, getString(R.string.log_url));
if (!TextUtils.isEmpty(logUrl)) {
AppCenter.setLogUrl(logUrl);
}
/* Set listeners. */
AnalyticsPrivateHelper.setListener(getAnalyticsListener());
Crashes.setListener(getCrashesListener());
Distribute.setListener(new SasquatchDistributeListener());
Push.setListener(getPushListener());
/* Set distribute urls. */
String installUrl = getString(R.string.install_url);
if (!TextUtils.isEmpty(installUrl)) {
Distribute.setInstallUrl(installUrl);
}
String apiUrl = getString(R.string.api_url);
if (!TextUtils.isEmpty(apiUrl)) {
Distribute.setApiUrl(apiUrl);
}
Push.setSenderId(SENDER_ID);
/* Set crash attachments. */
sCrashesListener.setTextAttachment(sSharedPreferences.getString(TEXT_ATTACHMENT_KEY, null));
String fileAttachment = sSharedPreferences.getString(FILE_ATTACHMENT_KEY, null);
if (fileAttachment != null) {
sCrashesListener.setFileAttachment(Uri.parse(fileAttachment));
}
/* Enable Firebase analytics if we enabled the setting previously. */
if (sSharedPreferences.getBoolean(FIREBASE_ENABLED_KEY, false)) {
Push.enableFirebaseAnalytics(this);
}
/* Start App Center. */
AppCenter.start(getApplication(), sSharedPreferences.getString(APP_SECRET_KEY, getString(R.string.app_secret)), Analytics.class, Crashes.class, Distribute.class, Push.class);
/* Attach NDK Crash Handler (if available) after SDK is initialized. */
CrashesPrivateHelper.getMinidumpDirectory().thenAccept(new AppCenterConsumer<String>() {
@Override
public void accept(String path) {
/* Path is null when Crashes is disabled. */
if (path != null) {
setupNativeCrashesListener(path);
}
}
});
/* Use some App Center getters. */
AppCenter.getInstallId().thenAccept(new AppCenterConsumer<UUID>() {
@Override
public void accept(UUID uuid) {
Log.i(LOG_TAG, "InstallId=" + uuid);
}
});
/* Print last crash. */
Crashes.hasCrashedInLastSession().thenAccept(new AppCenterConsumer<Boolean>() {
@Override
public void accept(Boolean crashed) {
Log.i(LOG_TAG, "Crashes.hasCrashedInLastSession=" + crashed);
}
});
Crashes.getLastSessionCrashReport().thenAccept(new AppCenterConsumer<ErrorReport>() {
@Override
public void accept(ErrorReport data) {
if (data != null) {
Log.i(LOG_TAG, "Crashes.getLastSessionCrashReport().getThrowable()=", data.getThrowable());
}
}
});
/* Populate UI. */
((TextView) findViewById(R.id.package_name)).setText(String.format(getString(R.string.sdk_source_format), getPackageName().substring(getPackageName().lastIndexOf(".") + 1)));
TestFeatures.initialize(this);
ListView listView = findViewById(R.id.list);
listView.setAdapter(new TestFeaturesListAdapter(TestFeatures.getAvailableControls()));
listView.setOnItemClickListener(TestFeatures.getOnItemClickListener());
}
use of com.microsoft.appcenter.sasquatch.features.TestFeaturesListAdapter in project mobile-center-sdk-android by Microsoft.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sSharedPreferences = getSharedPreferences("Sasquatch", Context.MODE_PRIVATE);
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().build());
/* Set custom log URL if one was configured in settings. */
String startType = sSharedPreferences.getString(APPCENTER_START_TYPE, StartType.APP_SECRET.toString());
String logUrl = sSharedPreferences.getString(LOG_URL_KEY, getLogUrl(this, startType));
if (!TextUtils.isEmpty(logUrl)) {
AppCenter.setLogUrl(logUrl);
}
/* Set listeners. */
AnalyticsPrivateHelper.setListener(getAnalyticsListener());
Crashes.setListener(getCrashesListener());
Distribute.setListener(new SasquatchDistributeListener());
/* Set distribute urls. */
String installUrl = getString(R.string.install_url);
if (!TextUtils.isEmpty(installUrl)) {
Distribute.setInstallUrl(installUrl);
}
String apiUrl = getString(R.string.api_url);
if (!TextUtils.isEmpty(apiUrl)) {
Distribute.setApiUrl(apiUrl);
}
/* Set crash attachments. */
AttachmentsUtil.getInstance();
/* Set max storage size. */
setMaxStorageSize();
/* Set debug enabled for distribute. */
setDistributeEnabledForDebuggableBuild();
/* Start App Center. */
startAppCenter(getApplication(), startType);
/* Set user id. */
String userId = sSharedPreferences.getString(USER_ID_KEY, null);
if (userId != null) {
setUserId(userId);
}
/* Attach NDK Crash Handler after SDK is initialized. */
Crashes.getMinidumpDirectory().thenAccept(new AppCenterConsumer<String>() {
@Override
public void accept(String path) {
/* Path is null when Crashes is disabled. */
if (path != null) {
setupNativeCrashesListener(path);
}
}
});
/* Use some App Center getters. */
AppCenter.getInstallId().thenAccept(new AppCenterConsumer<UUID>() {
@Override
public void accept(UUID uuid) {
Log.i(LOG_TAG, "InstallId=" + uuid);
}
});
/* Print last crash. */
Crashes.hasCrashedInLastSession().thenAccept(new AppCenterConsumer<Boolean>() {
@Override
public void accept(Boolean crashed) {
Log.i(LOG_TAG, "Crashes.hasCrashedInLastSession=" + crashed);
}
});
Crashes.getLastSessionCrashReport().thenAccept(new AppCenterConsumer<ErrorReport>() {
@Override
public void accept(ErrorReport data) {
if (data != null) {
Log.i(LOG_TAG, "Crashes.getLastSessionCrashReport().getStackTrace()=" + data.getStackTrace());
}
}
});
/* Populate UI. */
((TextView) findViewById(R.id.package_name)).setText(String.format(getString(R.string.sdk_source_format), getPackageName().substring(getPackageName().lastIndexOf(".") + 1)));
TestFeatures.initialize(this);
ListView listView = findViewById(R.id.list);
listView.setAdapter(new TestFeaturesListAdapter(TestFeatures.getAvailableControls()));
listView.setOnItemClickListener(TestFeatures.getOnItemClickListener());
/* Restore the MSA authentication callback. */
String msaUserId = sSharedPreferences.getString(MSA_TOKEN_KEY, null);
String refreshToken = sSharedPreferences.getString(MSA_REFRESH_TOKEN_KEY, null);
String refreshTokenScope = sSharedPreferences.getString(MSA_REFRESH_TOKEN_SCOPE_KEY, null);
int rawAuthType = sSharedPreferences.getInt(MSA_AUTH_TYPE_KEY, 0);
if (msaUserId != null && refreshToken != null && refreshTokenScope != null) {
AuthenticationProvider.Type mAuthType = AuthenticationProvider.Type.values()[rawAuthType];
MSAAuthenticationProvider tokenProvider = MSAAuthenticationProvider.getInstance(refreshToken, refreshTokenScope, this);
AuthenticationProvider provider = new AuthenticationProvider(mAuthType, msaUserId, tokenProvider);
AnalyticsTransmissionTarget.addAuthenticationProvider(provider);
}
}
use of com.microsoft.appcenter.sasquatch.features.TestFeaturesListAdapter in project mobile-center-sdk-android by Microsoft.
the class AuthenticationProviderActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auth_provider_list);
/* Populate UI. */
mFeatureList = new ArrayList<>();
mFeatureList.add(new TestFeatures.TestFeatureTitle(R.string.msa_title));
mFeatureList.add(new TestFeatures.TestFeature(R.string.msa_compact_title, R.string.msa_compact_description, new View.OnClickListener() {
@Override
public void onClick(View v) {
startMSALoginActivity(AuthenticationProvider.Type.MSA_COMPACT);
}
}));
mFeatureList.add(new TestFeatures.TestFeature(R.string.msa_delegate_title, R.string.msa_delegate_description, new View.OnClickListener() {
@Override
public void onClick(View v) {
startMSALoginActivity(AuthenticationProvider.Type.MSA_DELEGATE);
}
}));
mListView = findViewById(R.id.list);
mListView.setAdapter(new TestFeaturesListAdapter(mFeatureList));
mListView.setOnItemClickListener(TestFeatures.getOnItemClickListener());
}
Aggregations