Skip to content

Commit

Permalink
Merge pull request #1379 from microsoft/develop
Browse files Browse the repository at this point in the history
Version 3.1.0
  • Loading branch information
zhangcc01 authored Mar 17, 2020
2 parents 19e7902 + af8e33d commit af4f0ee
Show file tree
Hide file tree
Showing 13 changed files with 478 additions and 59 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# App Center SDK for Android Change Log

## Version 3.1.0

### App Center Distribute

* **[Feature]** Add a `disableAutomaticCheckForUpdate` API that needs to be called before SDK start in order to turn off automatic check for update.
* **[Feature]** Add a `checkForUpdate` API to manually check for update.
* **[Fix]** Fix not checking updates on public track if it was ignored on error while initializing in-app update for private track.

## Version 3.0.0

### App Center Auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ static void startAppCenter(Application application, String startTypeString) {
if (savedTrack != 0) {
Distribute.setUpdateTrack(savedTrack);
}
boolean automaticCheckForUpdate = sSharedPreferences.getBoolean(application.getString(R.string.appcenter_distribute_disable_check_for_update_key), true);
if (!automaticCheckForUpdate) {
try {

/*
* TODO replace the next line with 'Distribute.disableAutomaticCheckForUpdate();'
* when updating the demo during release process.
*/
Method disableAutomaticCheckForUpdateMethod = Distribute.class.getMethod("disableAutomaticCheckForUpdate");
disableAutomaticCheckForUpdateMethod.invoke(null);
} catch (Exception e) {
Toast.makeText(application, "No DisableAutomaticCheckForUpdate API in this build", Toast.LENGTH_SHORT).show();
}
}
if (sSharedPreferences.contains(ANALYTICS_TRANSMISSION_INTERVAL_KEY)) {
int latency = sSharedPreferences.getInt(ANALYTICS_TRANSMISSION_INTERVAL_KEY, DEFAULT_TRANSMISSION_INTERVAL_IN_SECONDS);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.os.FileObserver;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -43,6 +44,7 @@
import com.microsoft.appcenter.utils.PrefStorageConstants;

import java.io.File;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
Expand Down Expand Up @@ -306,6 +308,41 @@ public void setEnabled(boolean enabled) {
Distribute.setEnabledForDebuggableBuild(enabled);
}
});
initCheckBoxSetting(R.string.appcenter_distribute_disable_check_for_update_key, R.string.appcenter_distribute_summary_enabled_check_for_update, R.string.appcenter_distribute_summary_disabled_check_for_update, new HasEnabled() {

@Override
public void setEnabled(boolean enabled) {
MainActivity.sSharedPreferences.edit().putBoolean(getString(R.string.appcenter_distribute_disable_check_for_update_key), enabled).apply();
Toast.makeText(getActivity(), R.string.appcenter_distribute_track_state_updated, Toast.LENGTH_SHORT).show();
}

@Override
public boolean isEnabled() {
return MainActivity.sSharedPreferences.getBoolean(getString(R.string.appcenter_distribute_disable_check_for_update_key), true);
}
});

/* TODO Remove all try catch blocks here and use Distribute.checkForUpdate directly while preparing the demo app with prerelease jCenter SDK. */
try {
final Method checkForUpdate = Distribute.class.getMethod("checkForUpdate");
initClickableSetting(R.string.appcenter_distribute_check_for_update_key, new Preference.OnPreferenceClickListener() {

@Override
public boolean onPreferenceClick(Preference preference) {
try {
checkForUpdate.invoke(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
return true;
}
});
} catch (NoSuchMethodException e) {
PreferenceGroup distributeSection = (PreferenceGroup) getPreferenceManager().findPreference(getString(R.string.distribute_key));

//noinspection ConstantConditions
distributeSection.removePreference(distributeSection.findPreference(getString(R.string.appcenter_distribute_check_for_update_key)));
}
final HasSummary updateTrackHasSummary = new HasSummary() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,24 @@
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;

import com.microsoft.appcenter.crashes.Crashes;
import com.microsoft.appcenter.distribute.Distribute;
import com.microsoft.appcenter.sasquatch.R;
import com.microsoft.appcenter.sasquatch.activities.AuthenticationProviderActivity;
import com.microsoft.appcenter.sasquatch.activities.CrashActivity;
import com.microsoft.appcenter.sasquatch.activities.CustomPropertiesActivity;
import com.microsoft.appcenter.sasquatch.activities.DeviceInfoActivity;
import com.microsoft.appcenter.sasquatch.activities.DummyActivity;
import com.microsoft.appcenter.sasquatch.activities.EventActivity;
import com.microsoft.appcenter.sasquatch.activities.MainActivity;
import com.microsoft.appcenter.sasquatch.activities.ManagedErrorActivity;
import com.microsoft.appcenter.sasquatch.activities.PageActivity;
import com.microsoft.appcenter.utils.AppCenterLog;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -47,13 +52,32 @@ public static void initialize(Activity parentActivity) {
sTestFeatureModels.add(new TestFeatureTitle(R.string.miscellaneous_title));
sTestFeatureModels.add(new TestFeature(R.string.title_custom_properties, R.string.description_custom_properties, CustomPropertiesActivity.class));
sTestFeatureModels.add(new TestFeature(R.string.title_device_info, R.string.description_device_info, DeviceInfoActivity.class));
sTestFeatureModels.add(new TestFeature(R.string.title_check_for_update, R.string.description_check_for_update, checkForUpdateClickListener));
}

@SuppressWarnings("unchecked")
private static boolean hadMemoryWarning() {
return Crashes.hasReceivedMemoryWarningInLastSession().get();
}

private static View.OnClickListener checkForUpdateClickListener = new View.OnClickListener() {

@Override
public void onClick(View view) {
try {

/*
* TODO replace the next line with 'Distribute.checkForUpdate();'
* when updating the demo during release process.
*/
Method checkForUpdateMethod = Distribute.class.getMethod("checkForUpdate");
checkForUpdateMethod.invoke(null);
} catch (Exception e) {
AppCenterLog.warn(MainActivity.LOG_TAG, "No CheckForUpdate API in this build");
}
}
};

public static List<TestFeatureModel> getAvailableControls() {
return sTestFeatureModels;
}
Expand Down
7 changes: 7 additions & 0 deletions apps/sasquatch/src/main/res/values/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@
<string name="distribute_title" tools:ignore="MissingTranslation">Distribute</string>

<string name="appcenter_distribute_state_key" tools:ignore="MissingTranslation">appcenter_distribute_state_key</string>
<string name="appcenter_distribute_disable_check_for_update_key" tools:ignore="MissingTranslation">appcenter_distribute_disable_check_for_update_key</string>
<string name="appcenter_distribute_state_title" tools:ignore="MissingTranslation">Distribute state</string>
<string name="appcenter_distribute_state_summary_enabled" tools:ignore="MissingTranslation">Distribute is enabled</string>
<string name="appcenter_distribute_state_summary_disabled" tools:ignore="MissingTranslation">Distribute is disabled</string>
<string name="appcenter_distribute_summary_disabled_check_for_update" tools:ignore="MissingTranslation">Automatic check for update is disabled</string>
<string name="appcenter_distribute_summary_enabled_check_for_update" tools:ignore="MissingTranslation">Automatic check for update is enabled</string>

<string name="appcenter_distribute_debug_state_key" tools:ignore="MissingTranslation">appcenter_distribute_debug_state_key</string>
<string name="appcenter_distribute_debug_state_title" tools:ignore="MissingTranslation">Distribute in debug state</string>
<string name="appcenter_distribute_auto_check_for_update_title" tools:ignore="MissingTranslation">Automatic check for update</string>
<string name="appcenter_distribute_debug_summary_enabled" tools:ignore="MissingTranslation">Distribute in debug is enabled</string>
<string name="appcenter_distribute_debug_summary_disabled" tools:ignore="MissingTranslation">Distribute in debug is disabled</string>

Expand All @@ -74,6 +78,9 @@
<string name="appcenter_distribute_track_public_enabled" tools:ignore="MissingTranslation">Distribute uses public track</string>
<string name="appcenter_distribute_track_private_enabled" tools:ignore="MissingTranslation">Distribute uses private track</string>
<string name="appcenter_distribute_track_state_updated" tools:ignore="MissingTranslation">Update track will be changed only when the application is restarted.</string>
<string name="appcenter_distribute_automatic_check_updated" tools:ignore="MissingTranslation">Automatic update check settings will be applied after the application is restarted.</string>
<string name="appcenter_distribute_check_for_update_key" tools:ignore="MissingTranslation">appcenter_distribute_check_for_update_key</string>
<string name="appcenter_distribute_check_for_update_title" tools:ignore="MissingTranslation">Check for updates</string>

<string name="push_key" tools:ignore="MissingTranslation">appcenter_push</string>
<string name="push_title" tools:ignore="MissingTranslation">Push</string>
Expand Down
2 changes: 2 additions & 0 deletions apps/sasquatch/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<string name="description_auth" tools:ignore="MissingTranslation">Associate telemetry with user information</string>
<string name="title_device_info" tools:ignore="MissingTranslation">Device info</string>
<string name="description_device_info" tools:ignore="MissingTranslation">Display device information</string>
<string name="title_check_for_update" tools:ignore="MissingTranslation">Check for Update</string>
<string name="description_check_for_update" tools:ignore="MissingTranslation">Checks for new Distribute releases</string>
<string name="title_generate_page_log" tools:ignore="MissingTranslation">Generate page logs</string>
<string name="description_generate_page_log" tools:ignore="MissingTranslation">Simulate page open and close 5 times</string>
<string name="error_device_info" tools:ignore="MissingTranslation">Could not retrieve device information</string>
Expand Down
6 changes: 6 additions & 0 deletions apps/sasquatch/src/main/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
<CheckBoxPreference
android:key="@string/appcenter_distribute_debug_state_key"
android:title="@string/appcenter_distribute_debug_state_title" />
<CheckBoxPreference
android:key="@string/appcenter_distribute_disable_check_for_update_key"
android:title="@string/appcenter_distribute_auto_check_for_update_title" />
<Preference
android:key="@string/appcenter_distribute_check_for_update_key"
android:title="@string/appcenter_distribute_check_for_update_title" />
<ListPreference
android:key="@string/appcenter_distribute_track_state_key"
android:entries="@array/appcenter_distribute_update_track_entries"
Expand Down
Loading

0 comments on commit af4f0ee

Please sign in to comment.