From c9bd85cbf35450dcfe8c056671186fe557a43493 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Thu, 10 Sep 2020 15:29:02 -0400 Subject: [PATCH] new about fragment --- .../instagrabber/activities/MainActivity.java | 1 + .../instagrabber/dialogs/AboutDialog.java | 87 ------ .../instagrabber/dialogs/SettingsDialog.java | 291 ------------------ .../fragments/settings/AboutFragment.java | 214 +++++++++++++ .../settings/MorePreferencesFragment.java | 5 +- .../java/awais/instagrabber/utils/Utils.java | 38 --- .../java/awaisomereport/CrashReporter.java | 8 +- .../java/awaisomereport/LogCollector.java | 2 +- .../main/res/drawable-anydpi/ic_warning.xml | 10 + app/src/main/res/drawable-hdpi/ic_warning.png | Bin 0 -> 322 bytes app/src/main/res/drawable-mdpi/ic_warning.png | Bin 0 -> 242 bytes .../main/res/drawable-xhdpi/ic_warning.png | Bin 0 -> 400 bytes .../main/res/drawable-xxhdpi/ic_warning.png | Bin 0 -> 562 bytes .../main/res/navigation/more_nav_graph.xml | 7 + app/src/main/res/values/strings.xml | 12 +- 15 files changed, 250 insertions(+), 425 deletions(-) delete mode 100755 app/src/main/java/awais/instagrabber/dialogs/AboutDialog.java delete mode 100755 app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java create mode 100644 app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java create mode 100644 app/src/main/res/drawable-anydpi/ic_warning.xml create mode 100644 app/src/main/res/drawable-hdpi/ic_warning.png create mode 100644 app/src/main/res/drawable-mdpi/ic_warning.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_warning.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_warning.png diff --git a/app/src/main/java/awais/instagrabber/activities/MainActivity.java b/app/src/main/java/awais/instagrabber/activities/MainActivity.java index 98927c17..e5b848bc 100644 --- a/app/src/main/java/awais/instagrabber/activities/MainActivity.java +++ b/app/src/main/java/awais/instagrabber/activities/MainActivity.java @@ -72,6 +72,7 @@ public class MainActivity extends BaseLanguageActivity { R.id.discoverFragment, R.id.morePreferencesFragment, R.id.settingsPreferencesFragment, + R.id.aboutFragment, R.id.hashTagFragment, R.id.locationFragment, R.id.savedViewerFragment, diff --git a/app/src/main/java/awais/instagrabber/dialogs/AboutDialog.java b/app/src/main/java/awais/instagrabber/dialogs/AboutDialog.java deleted file mode 100755 index b3203e40..00000000 --- a/app/src/main/java/awais/instagrabber/dialogs/AboutDialog.java +++ /dev/null @@ -1,87 +0,0 @@ -package awais.instagrabber.dialogs; - -import android.app.Dialog; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.text.SpannableStringBuilder; -import android.text.method.LinkMovementMethod; -import android.text.style.RelativeSizeSpan; -import android.text.style.URLSpan; -import android.view.View; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.LinearLayoutCompat; - -import com.google.android.material.bottomsheet.BottomSheetDialogFragment; - -import awais.instagrabber.R; -import awais.instagrabber.utils.TextUtils; -import awais.instagrabber.utils.Utils; - -public final class AboutDialog extends BottomSheetDialogFragment { - @NonNull - @Override - public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) { - final Dialog dialog = super.onCreateDialog(savedInstanceState); - final View contentView = View.inflate(getContext(), R.layout.dialog_main_about, null); - - final LinearLayoutCompat infoContainer = contentView.findViewById(R.id.infoContainer); - - final View btnTelegram = infoContainer.getChildAt(1); - final View btnMatrix = infoContainer.getChildAt(2); - final View btnProject = infoContainer.getChildAt(3); - final View.OnClickListener onClickListener = v -> { - final Intent intent = new Intent(Intent.ACTION_VIEW); - if (v == btnTelegram) { - intent.setData(Uri.parse("https://t.me/grabber_app")); - final String telegramPackage = Utils.getInstalledTelegramPackage(getContext()); - if (!TextUtils.isEmpty(telegramPackage)) - intent.setPackage(telegramPackage); - } else if (v == btnMatrix) { - intent.setData(Uri.parse("https://matrix.to/#/#instagrabber:matrix.org")); - } else - intent.setData(Uri.parse("https://instagrabber.austinhuang.me")); - startActivity(intent); - }; - btnProject.setOnClickListener(onClickListener); - btnTelegram.setOnClickListener(onClickListener); - btnMatrix.setOnClickListener(onClickListener); - - final String description = getString(R.string.description); - if (!TextUtils.isEmpty(description)) { - final SpannableStringBuilder descriptionText = new SpannableStringBuilder(description, 0, description.length()); - - int lastIndex = descriptionText.length() / 2; - for (int i = 0; i < descriptionText.length(); ++i) { - char c = descriptionText.charAt(i); - - if (c == '[') { - final int smallTextStart = i; - descriptionText.delete(i, i + 1); - - do { - c = descriptionText.charAt(i); - if (c == ']') { - descriptionText.delete(i, i + 1); - descriptionText.setSpan(new RelativeSizeSpan(0.6f), smallTextStart, i, 0); - } - ++i; - } while (c != ']' || i == descriptionText.length() - 1); - } - } - - lastIndex = TextUtils.indexOfChar(descriptionText, '@', lastIndex) - 12; - descriptionText.setSpan(new URLSpan("mailto:instagrabber@austinhuang.me"), lastIndex, lastIndex + 27, 0); - - final TextView textView = (TextView) infoContainer.getChildAt(0); - textView.setMovementMethod(new LinkMovementMethod()); - textView.setText(descriptionText, TextView.BufferType.SPANNABLE); - } - - dialog.setContentView(contentView); - return dialog; - } -} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java b/app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java deleted file mode 100755 index cd4c14fc..00000000 --- a/app/src/main/java/awais/instagrabber/dialogs/SettingsDialog.java +++ /dev/null @@ -1,291 +0,0 @@ -package awais.instagrabber.dialogs; - -import android.app.Activity; -import android.app.Dialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Bundle; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.CompoundButton; -import android.widget.Spinner; -import android.widget.Toast; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatCheckBox; -import androidx.appcompat.widget.AppCompatTextView; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.FragmentManager; - -import com.google.android.material.bottomsheet.BottomSheetDialogFragment; - -import java.text.SimpleDateFormat; - -import awais.instagrabber.BuildConfig; -import awais.instagrabber.R; -import awais.instagrabber.activities.Login; -import awais.instagrabber.utils.Constants; -import awais.instagrabber.utils.CookieUtils; -import awais.instagrabber.utils.DirectoryChooser; -import awais.instagrabber.utils.DownloadUtils; -import awais.instagrabber.utils.LocaleUtils; -import awais.instagrabber.utils.TextUtils; -import awais.instagrabber.utils.Utils; -import awaisomereport.CrashReporter; - -import static awais.instagrabber.utils.Constants.AMOLED_THEME; -import static awais.instagrabber.utils.Constants.APP_LANGUAGE; -import static awais.instagrabber.utils.Constants.APP_THEME; -import static awais.instagrabber.utils.Constants.AUTOLOAD_POSTS; -import static awais.instagrabber.utils.Constants.AUTOPLAY_VIDEOS; -import static awais.instagrabber.utils.Constants.BOTTOM_TOOLBAR; -import static awais.instagrabber.utils.Constants.CHECK_ACTIVITY; -import static awais.instagrabber.utils.Constants.CHECK_UPDATES; -import static awais.instagrabber.utils.Constants.COOKIE; -import static awais.instagrabber.utils.Constants.DM_MARK_AS_SEEN; -import static awais.instagrabber.utils.Constants.DOWNLOAD_USER_FOLDER; -import static awais.instagrabber.utils.Constants.FOLDER_PATH; -import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO; -import static awais.instagrabber.utils.Constants.INSTADP; -import static awais.instagrabber.utils.Constants.MARK_AS_SEEN; -import static awais.instagrabber.utils.Constants.MUTED_VIDEOS; -import static awais.instagrabber.utils.Constants.STORIESIG; -import static awais.instagrabber.utils.Utils.settingsHelper; - -@Deprecated -public final class SettingsDialog extends BottomSheetDialogFragment implements View.OnClickListener, AdapterView.OnItemSelectedListener, - CompoundButton.OnCheckedChangeListener { - private Activity activity; - private FragmentManager fragmentManager; - private View btnSaveTo, btnImportExport, btnLogin, btnLogout, btnTimeSettings, btnReport, btnPrivacy; - private AppCompatTextView settingTitle; - private Spinner spAppTheme, spLanguage; - private boolean somethingChanged = false; - private int currentTheme, currentLanguage, selectedLanguage; - private String currentCookie; - - @Override - public void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults) { - if (requestCode != 6200) return; - if (grantResults[0] == PackageManager.PERMISSION_GRANTED) showDirectoryChooser(); - else - Toast.makeText(activity, R.string.direct_download_perms_ask, Toast.LENGTH_SHORT).show(); - } - - private void showDirectoryChooser() { - FragmentManager fragmentManager = getFragmentManager(); - if (fragmentManager == null) fragmentManager = getChildFragmentManager(); - - new DirectoryChooser().setInitialDirectory(settingsHelper.getString(FOLDER_PATH)) - .setInteractionListener(path -> { - settingsHelper.putString(FOLDER_PATH, path); - somethingChanged = true; - }).show(fragmentManager, null); - } - - @NonNull - @Override - public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) { - final Dialog dialog = super.onCreateDialog(savedInstanceState); - - final Context context = getContext(); - activity = context instanceof Activity ? (Activity) context : getActivity(); - - fragmentManager = getFragmentManager(); - if (fragmentManager == null) fragmentManager = getChildFragmentManager(); - - final View contentView = View.inflate(activity, R.layout.dialog_main_settings, null); - - settingTitle = contentView.findViewById(R.id.settingTitle); - settingTitle.setText(getString(R.string.action_setting, BuildConfig.VERSION_NAME)); - btnLogin = contentView.findViewById(R.id.btnLogin); - btnLogout = contentView.findViewById(R.id.btnLogout); - btnSaveTo = contentView.findViewById(R.id.btnSaveTo); - btnImportExport = contentView.findViewById(R.id.importExport); - btnTimeSettings = contentView.findViewById(R.id.btnTimeSettings); - btnReport = contentView.findViewById(R.id.btnReport); - btnPrivacy = contentView.findViewById(R.id.btnPrivacy); - - Utils.setTooltipText(btnImportExport, R.string.import_export); - - btnLogin.setOnClickListener(this); - btnLogout.setOnClickListener(this); - btnReport.setOnClickListener(this); - btnSaveTo.setOnClickListener(this); - btnImportExport.setOnClickListener(this); - btnTimeSettings.setOnClickListener(this); - btnPrivacy.setOnClickListener(this); - - if (TextUtils.isEmpty(settingsHelper.getString(Constants.COOKIE))) btnLogout.setEnabled(false); - - spAppTheme = contentView.findViewById(R.id.spAppTheme); - currentTheme = Integer.parseInt(settingsHelper.getString(APP_THEME)); - spAppTheme.setSelection(currentTheme); - spAppTheme.setOnItemSelectedListener(this); - - spLanguage = contentView.findViewById(R.id.spLanguage); - currentLanguage = Integer.parseInt(settingsHelper.getString(APP_LANGUAGE)); - spLanguage.setSelection(currentLanguage); - spLanguage.setOnItemSelectedListener(this); - - currentCookie = settingsHelper.getString(COOKIE); - - final AppCompatCheckBox cbSaveTo = contentView.findViewById(R.id.cbSaveTo); - final AppCompatCheckBox cbMuteVideos = contentView.findViewById(R.id.cbMuteVideos); - final AppCompatCheckBox cbBottomToolbar = contentView.findViewById(R.id.cbBottomToolbar); - final AppCompatCheckBox cbAutoloadPosts = contentView.findViewById(R.id.cbAutoloadPosts); - final AppCompatCheckBox cbAutoplayVideos = contentView.findViewById(R.id.cbAutoplayVideos); - final AppCompatCheckBox cbDownloadUsername = contentView.findViewById(R.id.cbDownloadUsername); - final AppCompatCheckBox cbMarkAsSeen = contentView.findViewById(R.id.cbMarkAsSeen); - final AppCompatCheckBox cbMarkDmAsSeen = contentView.findViewById(R.id.cbMarkDmAsSeen); - final AppCompatCheckBox cbActivity = contentView.findViewById(R.id.cbActivity); - final AppCompatCheckBox cbInstadp = contentView.findViewById(R.id.cbInstadp); - final AppCompatCheckBox cbStoriesig = contentView.findViewById(R.id.cbStoriesig); - final AppCompatCheckBox cbAmoledTheme = contentView.findViewById(R.id.cbAmoledTheme); - final AppCompatCheckBox cbUpdates = contentView.findViewById(R.id.cbUpdates); - - cbSaveTo.setChecked(settingsHelper.getBoolean(FOLDER_SAVE_TO)); - cbMuteVideos.setChecked(settingsHelper.getBoolean(MUTED_VIDEOS)); - cbBottomToolbar.setChecked(settingsHelper.getBoolean(BOTTOM_TOOLBAR)); - cbAutoplayVideos.setChecked(settingsHelper.getBoolean(AUTOPLAY_VIDEOS)); - cbMarkAsSeen.setChecked(settingsHelper.getBoolean(MARK_AS_SEEN)); - cbMarkDmAsSeen.setChecked(settingsHelper.getBoolean(DM_MARK_AS_SEEN)); - cbInstadp.setChecked(settingsHelper.getBoolean(INSTADP)); - cbStoriesig.setChecked(settingsHelper.getBoolean(STORIESIG)); - cbAmoledTheme.setChecked(settingsHelper.getBoolean(AMOLED_THEME)); - cbActivity.setChecked(settingsHelper.getBoolean(CHECK_ACTIVITY)); - cbAutoloadPosts.setChecked(settingsHelper.getBoolean(AUTOLOAD_POSTS)); - cbDownloadUsername.setChecked(settingsHelper.getBoolean(DOWNLOAD_USER_FOLDER)); - cbUpdates.setChecked(settingsHelper.getBoolean(CHECK_UPDATES)); - - setupListener(cbSaveTo); - setupListener(cbMuteVideos); - setupListener(cbBottomToolbar); - setupListener(cbAutoloadPosts); - setupListener(cbAutoplayVideos); - setupListener(cbDownloadUsername); - setupListener(cbMarkAsSeen); - setupListener(cbMarkDmAsSeen); - setupListener(cbInstadp); - setupListener(cbStoriesig); - setupListener(cbAmoledTheme); - setupListener(cbActivity); - setupListener(cbUpdates); - - btnSaveTo.setEnabled(cbSaveTo.isChecked()); - - dialog.setContentView(contentView); - - return dialog; - } - - private void setupListener(@NonNull final AppCompatCheckBox checkBox) { - checkBox.setOnCheckedChangeListener(this); - ((View) checkBox.getParent()).setOnClickListener(this); - } - - @Override - public void onItemSelected(final AdapterView spinner, final View view, final int position, final long id) { - if (spinner == spAppTheme) { - if (position != currentTheme) { - settingsHelper.putString(APP_THEME, String.valueOf(position)); - somethingChanged = true; - } - } else if (spinner == spLanguage) { - selectedLanguage = position; - if (position != currentLanguage) { - settingsHelper.putString(APP_LANGUAGE, String.valueOf(position)); - somethingChanged = true; - } - } - } - - @Override - public void onClick(final View v) { - if (v == btnLogin) { - startActivity(new Intent(v.getContext(), Login.class)); - somethingChanged = true; - } else if (v == btnLogout) { - CookieUtils.setupCookies("LOGOUT"); - settingsHelper.putString(Constants.COOKIE, ""); - somethingChanged = true; - this.dismiss(); - } else if (v == btnImportExport) { - if (ContextCompat.checkSelfPermission(activity, DownloadUtils.PERMS[0]) == PackageManager.PERMISSION_DENIED) - requestPermissions(DownloadUtils.PERMS, 6007); - else Utils.showImportExportDialog(activity); - } else if (v == btnTimeSettings) { - new TimeSettingsDialog(settingsHelper.getBoolean(Constants.CUSTOM_DATE_TIME_FORMAT_ENABLED), - settingsHelper.getString(Constants.CUSTOM_DATE_TIME_FORMAT), - settingsHelper.getString(Constants.DATE_TIME_SELECTION), - (isCustomFormat, - formatSelection, - spTimeFormatSelectedItemPosition, - spSeparatorSelectedItemPosition, - spDateFormatSelectedItemPosition, - selectedFormat, currentFormat) -> { - if (isCustomFormat) { - settingsHelper.putString(Constants.CUSTOM_DATE_TIME_FORMAT, formatSelection); - } else { - final String formatSelectionUpdated = spTimeFormatSelectedItemPosition + ";" - + spSeparatorSelectedItemPosition + ';' - + spDateFormatSelectedItemPosition; // time;separator;date - settingsHelper.putString(Constants.DATE_TIME_FORMAT, selectedFormat); - settingsHelper.putString(Constants.DATE_TIME_SELECTION, formatSelectionUpdated); - } - settingsHelper.putBoolean(Constants.CUSTOM_DATE_TIME_FORMAT_ENABLED, isCustomFormat); - Utils.datetimeParser = (SimpleDateFormat) currentFormat.clone(); - } - ).show(fragmentManager, null); - } else if (v == btnReport) { - CrashReporter.get(activity.getApplication()).zipLogs().startCrashEmailIntent(activity, true); - } else if (v == btnSaveTo) { - if (ContextCompat.checkSelfPermission(activity, DownloadUtils.PERMS[0]) == PackageManager.PERMISSION_DENIED) - requestPermissions(DownloadUtils.PERMS, 6200); - else showDirectoryChooser(); - } else if (v == btnPrivacy) { - final Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse("https://instagrabber.austinhuang.me/disclosure#for-anonymous-users")); - startActivity(intent); - } else if (v instanceof ViewGroup) - ((ViewGroup) v).getChildAt(0).performClick(); - } - - @Override - public void onCheckedChanged(@NonNull final CompoundButton checkBox, final boolean checked) { - final int id = checkBox.getId(); - if (id == R.id.cbDownloadUsername) settingsHelper.putBoolean(DOWNLOAD_USER_FOLDER, checked); - else if (id == R.id.cbBottomToolbar) settingsHelper.putBoolean(BOTTOM_TOOLBAR, checked); - else if (id == R.id.cbAutoplayVideos) settingsHelper.putBoolean(AUTOPLAY_VIDEOS, checked); - else if (id == R.id.cbMuteVideos) settingsHelper.putBoolean(MUTED_VIDEOS, checked); - else if (id == R.id.cbAutoloadPosts) settingsHelper.putBoolean(AUTOLOAD_POSTS, checked); - else if (id == R.id.cbMarkAsSeen) settingsHelper.putBoolean(MARK_AS_SEEN, checked); - else if (id == R.id.cbMarkDmAsSeen) settingsHelper.putBoolean(DM_MARK_AS_SEEN, checked); - else if (id == R.id.cbInstadp) settingsHelper.putBoolean(INSTADP, checked); - else if (id == R.id.cbStoriesig) settingsHelper.putBoolean(STORIESIG, checked); - else if (id == R.id.cbAmoledTheme) settingsHelper.putBoolean(AMOLED_THEME, checked); - else if (id == R.id.cbActivity) settingsHelper.putBoolean(CHECK_ACTIVITY, checked); - else if (id == R.id.cbUpdates) settingsHelper.putBoolean(CHECK_UPDATES, checked); - else if (id == R.id.cbSaveTo) { - settingsHelper.putBoolean(FOLDER_SAVE_TO, checked); - btnSaveTo.setEnabled(checked); - } - somethingChanged = true; - } - - @Override - public void onDismiss(@NonNull final DialogInterface dialog) { - if (selectedLanguage != currentLanguage) - LocaleUtils.setLocale(activity != null ? activity.getBaseContext() : getLayoutInflater().getContext().getApplicationContext()); - super.onDismiss(dialog); - if (somethingChanged && activity != null) activity.recreate(); - } - - @Override - public void onNothingSelected(final AdapterView parent) { } -} \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java new file mode 100644 index 00000000..71388362 --- /dev/null +++ b/app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java @@ -0,0 +1,214 @@ +package awais.instagrabber.fragments.settings; + +import android.content.Context; +import android.content.Intent; +import android.content.res.TypedArray; +import android.net.Uri; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.appcompat.widget.AppCompatButton; +import androidx.appcompat.widget.AppCompatTextView; +import androidx.fragment.app.FragmentActivity; +import androidx.preference.ListPreference; +import androidx.preference.Preference; +import androidx.preference.PreferenceCategory; +import androidx.preference.PreferenceScreen; +import androidx.preference.PreferenceViewHolder; +import androidx.preference.SwitchPreferenceCompat; + +import com.google.android.material.switchmaterial.SwitchMaterial; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import awais.instagrabber.R; +import awais.instagrabber.dialogs.TimeSettingsDialog; +import awais.instagrabber.utils.Constants; +import awais.instagrabber.utils.CookieUtils; +import awais.instagrabber.utils.DirectoryChooser; +import awais.instagrabber.utils.TextUtils; +import awais.instagrabber.utils.Utils; + +import static awais.instagrabber.utils.Constants.FOLDER_PATH; +import static awais.instagrabber.utils.Constants.FOLDER_SAVE_TO; +import static awais.instagrabber.utils.Utils.settingsHelper; + +public class AboutFragment extends BasePreferencesFragment { + private static AppCompatTextView customPathTextView; + + @Override + void setupPreferenceScreen(final PreferenceScreen screen) { + final PreferenceCategory generalCategory = new PreferenceCategory(requireContext()); + screen.addPreference(generalCategory); + generalCategory.setTitle(R.string.pref_category_general); + generalCategory.setIconSpaceReserved(false); + generalCategory.addPreference(getDocsPreference()); + generalCategory.addPreference(getRepoPreference()); + generalCategory.addPreference(getFeedbackPreference()); + + final PreferenceCategory thirdPartyCategory = new PreferenceCategory(requireContext()); + screen.addPreference(thirdPartyCategory); + thirdPartyCategory.setTitle(R.string.about_category_3pt); + thirdPartyCategory.setSummary(R.string.about_category_3pt_summary); + thirdPartyCategory.setIconSpaceReserved(false); + // alphabetical order!!! + thirdPartyCategory.addPreference(getExoPlayerPreference()); + thirdPartyCategory.addPreference(getFrescoPreference()); + thirdPartyCategory.addPreference(getGlidePreference()); + thirdPartyCategory.addPreference(getJsoupPreference()); + thirdPartyCategory.addPreference(getPhotoViewPreference()); + thirdPartyCategory.addPreference(getRetrofitPreference()); + + final PreferenceCategory licenseCategory = new PreferenceCategory(requireContext()); + screen.addPreference(licenseCategory); + licenseCategory.setTitle(R.string.about_category_license); + licenseCategory.setIconSpaceReserved(false); + licenseCategory.addPreference(getLicensePreference()); + licenseCategory.addPreference(getLiabilityPreference()); + } + + private Preference getDocsPreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle(R.string.about_documentation); + preference.setSummary(R.string.about_documentation_summary); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://instagrabber.austinhuang.me")); + startActivity(intent); + return true; + }); + return preference; + } + + private Preference getRepoPreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle(R.string.about_repository); + preference.setSummary(R.string.about_repository_summary); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://github.com/austinhuang0131/instagrabber")); + startActivity(intent); + return true; + }); + return preference; + } + + private Preference getFeedbackPreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle(R.string.about_feedback); + preference.setSummary(R.string.about_feedback_summary); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_SENDTO); + intent.setData(Uri.parse(getString(R.string.about_feedback_summary))); + if (intent.resolveActivity(requireContext().getPackageManager()) != null) startActivity(intent); + return true; + }); + return preference; + } + + private Preference getRetrofitPreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle("Retrofit"); + preference.setSummary("Copyright 2013 Square, Inc. Apache Version 2.0."); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://square.github.io/retrofit/")); + startActivity(intent); + return true; + }); + return preference; + } + + private Preference getJsoupPreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle("jsoup"); + preference.setSummary("Copyright (c) 2009-2020 Jonathan Hedley. MIT License."); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://jsoup.org/")); + startActivity(intent); + return true; + }); + return preference; + } + + private Preference getFrescoPreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle("Fresco"); + preference.setSummary("Copyright (c) Facebook, Inc. and its affiliates. MIT License."); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://frescolib.org/")); + startActivity(intent); + return true; + }); + return preference; + } + + private Preference getGlidePreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle("Glide"); + preference.setSummary("Copyright 2014 Google, Inc. All rights reserved. Custom license."); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://bumptech.github.io/glide/")); + startActivity(intent); + return true; + }); + return preference; + } + + private Preference getPhotoViewPreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle("PhotoView"); + preference.setSummary("Copyright 2018 Chris Banes. Apache Version 2.0."); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://github.com/chrisbanes/PhotoView")); + startActivity(intent); + return true; + }); + return preference; + } + + private Preference getExoPlayerPreference() { + final Preference preference = new Preference(requireContext()); + preference.setTitle("ExoPlayer"); + preference.setSummary("Copyright (C) 2016 The Android Open Source Project. Apache Version 2.0."); + preference.setIconSpaceReserved(false); + preference.setOnPreferenceClickListener(p -> { + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse("https://exoplayer.dev/")); + startActivity(intent); + return true; + }); + return preference; + } + + private Preference getLicensePreference() { + final Preference preference = new Preference(requireContext()); + preference.setSummary(R.string.license); + preference.setEnabled(false); + preference.setIcon(R.drawable.ic_outline_info_24); + preference.setIconSpaceReserved(true); + return preference; + } + + private Preference getLiabilityPreference() { + final Preference preference = new Preference(requireContext()); + preference.setSummary(R.string.liability); + preference.setEnabled(false); + preference.setIcon(R.drawable.ic_warning); + preference.setIconSpaceReserved(true); + return preference; + } +} diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java index f6362a2a..3a622c23 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java @@ -30,7 +30,6 @@ import awais.instagrabber.activities.Login; import awais.instagrabber.adapters.AccountSwitcherListAdapter; import awais.instagrabber.adapters.AccountSwitcherListAdapter.OnAccountClickListener; import awais.instagrabber.databinding.PrefAccountSwitcherBinding; -import awais.instagrabber.dialogs.AboutDialog; import awais.instagrabber.repositories.responses.UserInfo; import awais.instagrabber.services.ProfileService; import awais.instagrabber.services.ServiceCallback; @@ -107,8 +106,8 @@ public class MorePreferencesFragment extends BasePreferencesFragment { return true; })); final Preference aboutPreference = getPreference(R.string.action_about, R.drawable.ic_outline_info_24, preference -> { - final AboutDialog aboutDialog = new AboutDialog(); - aboutDialog.show(getChildFragmentManager(), "About"); + final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToAboutFragment(); + NavHostFragment.findNavController(this).navigate(navDirections); return true; }); generalCategory.addPreference(aboutPreference); diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java index 6d6f98a4..1256c848 100755 --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -64,8 +64,6 @@ public final class Utils { public static SimpleDateFormat datetimeParser; public static SimpleCache simpleCache; - private static String telegramPackage; - public static int convertDpToPx(final float dp) { if (displayMetrics == null) displayMetrics = Resources.getSystem().getDisplayMetrics(); @@ -282,42 +280,6 @@ public final class Utils { activity.finish(); } - @Nullable - public static String getInstalledTelegramPackage(@Nullable final Context context) { - if (telegramPackage != null) return telegramPackage; - if (context == null) return null; - final String[] packages = { - "org.telegram.messenger", - "org.thunderdog.challegram", - "ir.ilmili.telegraph", - // "org.telegram.BifToGram", see GitHub issue 124 - "org.vidogram.messenger", - "com.xplus.messenger", - "com.ellipi.messenger", - "org.telegram.plus", - "com.iMe.android", - "org.viento.colibri", - "org.viento.colibrix", - "ml.parsgram", - "com.ringtoon.app.tl", - }; - final PackageManager packageManager = context.getPackageManager(); - for (final String pkg : packages) { - try { - final PackageInfo packageInfo = packageManager.getPackageInfo(pkg, 0); - if (packageInfo.applicationInfo.enabled) return pkg; - } catch (final Exception e) { - try { - if (packageManager.getApplicationInfo(pkg, 0).enabled) { - telegramPackage = pkg; - return pkg; - } - } catch (final Exception ignored) {} - } - } - return null; - } - public static SimpleCache getSimpleCacheInstance(final Context context) { if (context == null) { return null; diff --git a/app/src/main/java/awaisomereport/CrashReporter.java b/app/src/main/java/awaisomereport/CrashReporter.java index c980e0f0..90d86eb1 100755 --- a/app/src/main/java/awaisomereport/CrashReporter.java +++ b/app/src/main/java/awaisomereport/CrashReporter.java @@ -39,8 +39,6 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler { private CrashReporter(@NonNull final Application application) { this.application = application; - // set your email(s) here to receive crash reports - // this.email = ""; this.email = "instagrabber@austinhuang.me"; this.crashLogsZip = new File(application.getExternalCacheDir(), "crash_logs.zip"); } @@ -70,7 +68,9 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler { .append("\r\nDEVICE : ").append(Build.DEVICE) .append("\r\nPRODUCT : ").append(Build.PRODUCT) .append("\r\nHOST : ").append(Build.HOST) - .append("\r\nTAGS : ").append(Build.TAGS); + .append("\r\nTAGS : ").append(Build.TAGS) + .append("\r\nINSTRUCTION : Please attach details on how to produce this crash. Your help is appreciated.") + .append("\r\nPRIVACY : Your email address and crash report will be made PUBLIC on the GitHub repository."); reportBuilder.append("\r\n\r\nStack:\r\n==============\r\n"); final Writer result = new StringWriter(); @@ -107,7 +107,7 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler { public synchronized CrashReporter zipLogs() { final File logDir = Utils.logCollector != null ? Utils.logCollector.getLogDir() : - new File(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? application.getDataDir() : application.getFilesDir(), "ur_mom_gay_logs"); + new File(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? application.getDataDir() : application.getFilesDir(), "crashlogs"); try (final FileOutputStream fos = new FileOutputStream(crashLogsZip); final ZipOutputStream zos = new ZipOutputStream(fos)) { diff --git a/app/src/main/java/awaisomereport/LogCollector.java b/app/src/main/java/awaisomereport/LogCollector.java index b36db537..b784de6f 100755 --- a/app/src/main/java/awaisomereport/LogCollector.java +++ b/app/src/main/java/awaisomereport/LogCollector.java @@ -25,7 +25,7 @@ public final class LogCollector { public LogCollector(@NonNull final Application app) { logDir = new File(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? app.getDataDir() : app.getFilesDir(), - "ur_mom_gay_logs"); + "crashlogs"); if (logDir.exists()) deleteRecursive(logDir); diff --git a/app/src/main/res/drawable-anydpi/ic_warning.xml b/app/src/main/res/drawable-anydpi/ic_warning.xml new file mode 100644 index 00000000..506d0586 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_warning.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable-hdpi/ic_warning.png b/app/src/main/res/drawable-hdpi/ic_warning.png new file mode 100644 index 0000000000000000000000000000000000000000..e0c9ce344d33487f0856362388ff920ca96e5c68 GIT binary patch literal 322 zcmV-I0lof-P)XYSqft7X|Yr U#SDtI2><{907*qoM6N<$g3C^i{{R30 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_warning.png b/app/src/main/res/drawable-mdpi/ic_warning.png new file mode 100644 index 0000000000000000000000000000000000000000..f5fb4ae68b1fe801d416c8234e2d68fcdba109ce GIT binary patch literal 242 zcmV2A zo?=`UfaEB3y%jFQk$ho5cEo~G40@2D2N^VFagpPCUv$^PG_>aC$DS>lNUuyccJleKh0q`2$%Z9urJzMe)<}8xX)m9tiZ6_4>>i2u(E%cc?*UFa~@1q3Z z44may{qcyr(}j^+^{bu1-NOveaH{@)L8NkY7W=u6`BA%%U(7;u2P>& zHj#t-ZJU#r9VMVx$tE^|%VgDO-w90sK0Ef{ z4!-IV*Z~;mfrV_k(&#h9(Pb68?_gv!`krKL;(8@W?I*T^6d;pTuz**SC$pcvHZfus z&e>0lO{9`hvOOulCPqmh*nWoC#7GI?W%Z;@Bu@anC#8^0Qd#9jey^*)n?Uwg$o#&) uFe1O8cO!T}G%W5XG4@XJyV>DIY`DtYz-nwR6_atnJEwTVIt(Rs|H>cjnH1PqIJ|KK#SJ=X(-| z0|Y@31VIo4K@e1(`o3?*aa`Q(=P(Qx8g!o?1Dw8ZeK3CqJxABn4Cp2tA5xWY+!i|h z2WKC2ZFO7AP5kRoKy+Vh3pJ2(NU?$aV-R1rXGx zvUzp!ELXpE&3R%SQB|MDG>P9aP1Eb%YS4Z2@vKCQDwrF!&j7R<0<@a4^(T!k=ju6I z1C%YE%@L!Tjb}5)s5awSsTftL)yUhY#l)x@0g1)4lD3{35WDTi#HgA9vBtBpF{*Yz zZ1F5-zoiKfOP^MNt;^azN7iHD@Hng9UJ3x607wuJw%7v}|6M8^np?8fTkhVoh59Ad zBKEAB5;^LGErw3K^e%Ky&?1VIo4K@cRX9|V#**4e#_c>n+a07*qoM6N<$f?)at A@&Et; literal 0 HcmV?d00001 diff --git a/app/src/main/res/navigation/more_nav_graph.xml b/app/src/main/res/navigation/more_nav_graph.xml index 5d45890e..f025d67e 100644 --- a/app/src/main/res/navigation/more_nav_graph.xml +++ b/app/src/main/res/navigation/more_nav_graph.xml @@ -11,9 +11,16 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a595cfd1..abdfa50f 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -231,7 +231,8 @@ Oops.. the app crashed, but don\'t worry you can send error report to the developer to help him fix the issue. (: Use AMOLED mode for Dark theme Activity - InstaGrabber\nCopyright (C) 2019 AWAiS\nCopyright (C) 2020 Austin Huang, Ammar Githam\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See https://www.gnu.org/licenses/.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR \'\'AS IS\'\' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nSee project page for third-party attributions. + Copyright (C) 2019 AWAiS\nCopyright (C) 2020 Austin Huang, Ammar Githam\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See https://www.gnu.org/licenses/. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Select Picture Uploading... You have: @@ -259,4 +260,13 @@ Downloads Locale Add account + License (English only) + Visit our website + Get support, discuss, meet others, and have fun! + See our source code on GitHub + Audit, star, report bugs, contribute, and have fun (again)! + Send feedback by email + instagrabber@austinhuang.me + Third-Party Libraries + The following third-party libraries are used in this app: \ No newline at end of file