diff --git a/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java b/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java index 555eb5da..ccdbfd8b 100644 --- a/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/activities/MainActivity.java @@ -6,10 +6,11 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.ComponentName; import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; -import android.os.Build; +import android.net.Uri; import android.os.Bundle; import android.os.IBinder; import android.preference.PreferenceManager; @@ -40,6 +41,7 @@ import com.nutomic.syncthingandroid.syncthing.RestApi; import com.nutomic.syncthingandroid.syncthing.SyncthingService; import java.util.Date; +import java.util.concurrent.TimeUnit; import static java.lang.Math.min; @@ -58,7 +60,7 @@ public class MainActivity extends SyncthingActivity * * @see #showUsageReportingDialog() */ - private static final long USAGE_REPORTING_DIALOG_DELAY = 3 * 24 * 60 * 60 * 1000; + private static final long USAGE_REPORTING_DIALOG_DELAY = TimeUnit.DAYS.toMillis(3); private AlertDialog mLoadingDialog; @@ -362,22 +364,32 @@ public class MainActivity extends SyncthingActivity /** * Displays dialog asking user to accept/deny usage reporting. */ - @SuppressLint("InflateParams") private void showUsageReportingDialog() { final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - getApi().setUsageReportAccepted( - (which == DialogInterface.BUTTON_POSITIVE) - ? RestApi.UsageReportSetting.ACCEPTED - : RestApi.UsageReportSetting.DENIED, - MainActivity.this); + switch (which) { + case DialogInterface.BUTTON_POSITIVE: + getApi().setUsageReportAccepted(RestApi.UsageReportSetting.ACCEPTED, + MainActivity.this); + break; + case DialogInterface.BUTTON_NEGATIVE: + getApi().setUsageReportAccepted(RestApi.UsageReportSetting.DENIED, + MainActivity.this); + break; + case DialogInterface.BUTTON_NEUTRAL: + Uri uri = Uri.parse("https://data.syncthing.net"); + startActivity(new Intent(Intent.ACTION_VIEW, uri)); + break; + } + } }; getApi().getUsageReport(new RestApi.OnReceiveUsageReportListener() { @Override public void onReceiveUsageReport(String report) { + @SuppressLint("InflateParams") View v = LayoutInflater.from(MainActivity.this) .inflate(R.layout.dialog_usage_reporting, null); TextView tv = (TextView) v.findViewById(R.id.example); @@ -387,6 +399,7 @@ public class MainActivity extends SyncthingActivity .setView(v) .setPositiveButton(R.string.yes, listener) .setNegativeButton(R.string.no, listener) + .setNeutralButton("Open Website", listener) .setCancelable(false) .show(); } diff --git a/src/main/res/layout/dialog_usage_reporting.xml b/src/main/res/layout/dialog_usage_reporting.xml index 88609e6d..a0bbf081 100644 --- a/src/main/res/layout/dialog_usage_reporting.xml +++ b/src/main/res/layout/dialog_usage_reporting.xml @@ -13,7 +13,7 @@ android:paddingBottom="10dip" android:text="@string/usage_reporting_dialog_description" /> - - +