Add setting to enable sending buffering events #2

Closed
kekkyojin wants to merge 1 commit from buffer-analytics-setting into master
4 changed files with 16 additions and 1 deletions

View file

@ -282,6 +282,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
public static final String PREFERENCE_KEY_NOTIFICATION_CREATOR = "io.lbry.browser.preference.notifications.Creator";
public static final String PREFERENCE_KEY_KEEP_SDK_BACKGROUND = "io.lbry.browser.preference.other.KeepSdkInBackground";
public static final String PREFERENCE_KEY_PARTICIPATE_DATA_NETWORK = "io.lbry.browser.preference.other.ParticipateInDataNetwork";
public static final String PREFERENCE_KEY_SEND_BUFFERING_EVENTS = "io.lbry.browser.preference.other.SendBufferingEvents";
// Internal flags / setting preferences
public static final String PREFERENCE_KEY_INTERNAL_SKIP_WALLET_ACCOUNT = "io.lbry.browser.preference.internal.WalletSkipAccount";

View file

@ -294,7 +294,15 @@ public class FileViewFragment extends BaseFragment implements
loadingNewClaim = false;
}
} else if (playbackState == Player.STATE_BUFFERING) {
if (MainActivity.appPlayer != null && MainActivity.appPlayer.getCurrentPosition() > 0) {
Context ctx = getContext();
boolean sendBufferingEvents = false;
if (ctx != null) {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(ctx);
sendBufferingEvents = sp.getBoolean(MainActivity.PREFERENCE_KEY_SEND_BUFFERING_EVENTS, false);
}
if (MainActivity.appPlayer != null && MainActivity.appPlayer.getCurrentPosition() > 0 && sendBufferingEvents) {
// we only want to log a buffer event after the media has already started playing
String mediaSourceUrl = getStreamingUrl();
long duration = MainActivity.appPlayer.getDuration();

View file

@ -245,6 +245,7 @@
<string name="keep_sdk_in_background">Keep the LBRY service running in the background for improved wallet and network performance</string>
<string name="participate_in_data_network">Participate in the data network (requires app and background service restart)</string>
<string name="send_buffering_events">Send buffering events to LBRY servers</string>
<!-- URL suggestions -->
<string name="search_url_title">%1$s - Search</string>

View file

@ -58,5 +58,10 @@
app:title="@string/participate_in_data_network"
app:iconSpaceReserved="false"
app:singleLineTitle="false" />
<SwitchPreferenceCompat
app:key="io.lbry.browser.preference.other.SendBufferingEvents"
app:title="@string/send_buffering_events"
app:iconSpaceReserved="false"
app:singleLineTitle="false" />
</PreferenceCategory>
</PreferenceScreen>