diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 0ce6772bb..22fa661d3 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -20,6 +20,9 @@ package org.schabi.newpipe; +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java index 962ec8a36..0450290d2 100644 --- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java +++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java @@ -128,47 +128,31 @@ public class AboutActivity extends AppCompatActivity { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_about, container, false); + Context context = this.getContext(); + TextView version = rootView.findViewById(R.id.app_version); version.setText(BuildConfig.VERSION_NAME); View githubLink = rootView.findViewById(R.id.github_link); - githubLink.setOnClickListener(new OnGithubLinkClickListener()); + githubLink.setOnClickListener(nv -> openWebsite(context.getString(R.string.github_url), context)); View donationLink = rootView.findViewById(R.id.donation_link); - donationLink.setOnClickListener(new OnDonationLinkClickListener()); + donationLink.setOnClickListener(v -> openWebsite(context.getString(R.string.donation_url), context)); View websiteLink = rootView.findViewById(R.id.website_link); - websiteLink.setOnClickListener(new OnWebsiteLinkClickListener()); + websiteLink.setOnClickListener(nv -> openWebsite(context.getString(R.string.website_url), context)); + + View privacyPolicyLink = rootView.findViewById(R.id.privacy_policy_link); + privacyPolicyLink.setOnClickListener(v -> openWebsite(context.getString(R.string.privacy_policy_url), context)); return rootView; } - private static class OnGithubLinkClickListener implements View.OnClickListener { - @Override - public void onClick(final View view) { - final Context context = view.getContext(); - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.github_url))); - context.startActivity(intent); - } + private void openWebsite(String url, Context context) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + context.startActivity(intent); } - private static class OnDonationLinkClickListener implements View.OnClickListener { - @Override - public void onClick(final View view) { - final Context context = view.getContext(); - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.donation_url))); - context.startActivity(intent); - } - } - - private static class OnWebsiteLinkClickListener implements View.OnClickListener { - @Override - public void onClick(final View view) { - final Context context = view.getContext(); - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(context.getString(R.string.website_url))); - context.startActivity(intent); - } - } } diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java index e4436322a..701e18cbf 100644 --- a/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java +++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragmentHelper.java @@ -42,7 +42,7 @@ public class LicenseFragmentHelper extends AsyncTask { } @Override - protected void onPostExecute(Integer result){ + protected void onPostExecute(Integer result) { Activity activity = getActivity(); if (activity == null) { return; diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 1b60c596f..3ad08c3ec 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -1,7 +1,9 @@ package org.schabi.newpipe.report; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.net.Uri; @@ -33,10 +35,8 @@ import org.json.JSONArray; import org.json.JSONObject; import org.schabi.newpipe.ActivityCommunicator; import org.schabi.newpipe.BuildConfig; -import org.schabi.newpipe.Downloader; import org.schabi.newpipe.MainActivity; import org.schabi.newpipe.R; -import org.schabi.newpipe.extractor.utils.Parser; import org.schabi.newpipe.util.ThemeHelper; import java.io.PrintWriter; @@ -44,9 +44,9 @@ import java.io.StringWriter; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; -import java.util.Locale; import java.util.TimeZone; import java.util.Vector; +import java.util.concurrent.atomic.AtomicBoolean; /* * Created by Christian Schabesberger on 24.10.15. @@ -210,12 +210,31 @@ public class ErrorActivity extends AppCompatActivity { currentTimeStamp = getCurrentTimeStamp(); reportButton.setOnClickListener((View v) -> { - Intent i = new Intent(Intent.ACTION_SENDTO); - i.setData(Uri.parse("mailto:" + ERROR_EMAIL_ADDRESS)) - .putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT) - .putExtra(Intent.EXTRA_TEXT, buildJson()); + Context context = this; + new AlertDialog.Builder(context) + .setIcon(android.R.drawable.ic_dialog_alert) + .setTitle(R.string.privacy_policy_title) + .setMessage(R.string.start_accept_privacy_policy) + .setCancelable(false) + .setNeutralButton(R.string.read_privacy_policy, (dialog, which) -> { + Intent webIntent = new Intent(Intent.ACTION_VIEW, + Uri.parse(context.getString(R.string.privacy_policy_url)) + ); + context.startActivity(webIntent); + }) + .setPositiveButton(R.string.accept, (dialog, which) -> { + Intent i = new Intent(Intent.ACTION_SENDTO); + i.setData(Uri.parse("mailto:" + ERROR_EMAIL_ADDRESS)) + .putExtra(Intent.EXTRA_SUBJECT, ERROR_EMAIL_SUBJECT) + .putExtra(Intent.EXTRA_TEXT, buildJson()); + + startActivity(Intent.createChooser(i, "Send Email")); + }) + .setNegativeButton(R.string.decline, (dialog, which) -> { + // do nothing + }) + .show(); - startActivity(Intent.createChooser(i, "Send Email")); }); // normal bugreport diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 6e1db563a..320f72ab9 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -111,5 +111,26 @@ android:layout_gravity="end" android:text="@string/open_in_browser" /> + + + + +