new about fragment

This commit is contained in:
Austin Huang 2020-09-10 15:29:02 -04:00
parent 8049ddec45
commit c9bd85cbf3
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
15 changed files with 250 additions and 425 deletions

View File

@ -72,6 +72,7 @@ public class MainActivity extends BaseLanguageActivity {
R.id.discoverFragment, R.id.discoverFragment,
R.id.morePreferencesFragment, R.id.morePreferencesFragment,
R.id.settingsPreferencesFragment, R.id.settingsPreferencesFragment,
R.id.aboutFragment,
R.id.hashTagFragment, R.id.hashTagFragment,
R.id.locationFragment, R.id.locationFragment,
R.id.savedViewerFragment, R.id.savedViewerFragment,

View File

@ -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;
}
}

View File

@ -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) { }
}

View File

@ -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;
}
}

View File

@ -30,7 +30,6 @@ import awais.instagrabber.activities.Login;
import awais.instagrabber.adapters.AccountSwitcherListAdapter; import awais.instagrabber.adapters.AccountSwitcherListAdapter;
import awais.instagrabber.adapters.AccountSwitcherListAdapter.OnAccountClickListener; import awais.instagrabber.adapters.AccountSwitcherListAdapter.OnAccountClickListener;
import awais.instagrabber.databinding.PrefAccountSwitcherBinding; import awais.instagrabber.databinding.PrefAccountSwitcherBinding;
import awais.instagrabber.dialogs.AboutDialog;
import awais.instagrabber.repositories.responses.UserInfo; import awais.instagrabber.repositories.responses.UserInfo;
import awais.instagrabber.services.ProfileService; import awais.instagrabber.services.ProfileService;
import awais.instagrabber.services.ServiceCallback; import awais.instagrabber.services.ServiceCallback;
@ -107,8 +106,8 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
return true; return true;
})); }));
final Preference aboutPreference = getPreference(R.string.action_about, R.drawable.ic_outline_info_24, preference -> { final Preference aboutPreference = getPreference(R.string.action_about, R.drawable.ic_outline_info_24, preference -> {
final AboutDialog aboutDialog = new AboutDialog(); final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToAboutFragment();
aboutDialog.show(getChildFragmentManager(), "About"); NavHostFragment.findNavController(this).navigate(navDirections);
return true; return true;
}); });
generalCategory.addPreference(aboutPreference); generalCategory.addPreference(aboutPreference);

View File

@ -64,8 +64,6 @@ public final class Utils {
public static SimpleDateFormat datetimeParser; public static SimpleDateFormat datetimeParser;
public static SimpleCache simpleCache; public static SimpleCache simpleCache;
private static String telegramPackage;
public static int convertDpToPx(final float dp) { public static int convertDpToPx(final float dp) {
if (displayMetrics == null) if (displayMetrics == null)
displayMetrics = Resources.getSystem().getDisplayMetrics(); displayMetrics = Resources.getSystem().getDisplayMetrics();
@ -282,42 +280,6 @@ public final class Utils {
activity.finish(); 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) { public static SimpleCache getSimpleCacheInstance(final Context context) {
if (context == null) { if (context == null) {
return null; return null;

View File

@ -39,8 +39,6 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler {
private CrashReporter(@NonNull final Application application) { private CrashReporter(@NonNull final Application application) {
this.application = application; this.application = application;
// set your email(s) here to receive crash reports
// this.email = "<email>";
this.email = "instagrabber@austinhuang.me"; this.email = "instagrabber@austinhuang.me";
this.crashLogsZip = new File(application.getExternalCacheDir(), "crash_logs.zip"); 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\nDEVICE : ").append(Build.DEVICE)
.append("\r\nPRODUCT : ").append(Build.PRODUCT) .append("\r\nPRODUCT : ").append(Build.PRODUCT)
.append("\r\nHOST : ").append(Build.HOST) .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"); reportBuilder.append("\r\n\r\nStack:\r\n==============\r\n");
final Writer result = new StringWriter(); final Writer result = new StringWriter();
@ -107,7 +107,7 @@ public final class CrashReporter implements Thread.UncaughtExceptionHandler {
public synchronized CrashReporter zipLogs() { public synchronized CrashReporter zipLogs() {
final File logDir = Utils.logCollector != null ? Utils.logCollector.getLogDir() : 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); try (final FileOutputStream fos = new FileOutputStream(crashLogsZip);
final ZipOutputStream zos = new ZipOutputStream(fos)) { final ZipOutputStream zos = new ZipOutputStream(fos)) {

View File

@ -25,7 +25,7 @@ public final class LogCollector {
public LogCollector(@NonNull final Application app) { public LogCollector(@NonNull final Application app) {
logDir = new File(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? app.getDataDir() : app.getFilesDir(), 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); if (logDir.exists()) deleteRecursive(logDir);

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M4.47,21h15.06c1.54,0 2.5,-1.67 1.73,-3L13.73,4.99c-0.77,-1.33 -2.69,-1.33 -3.46,0L2.74,18c-0.77,1.33 0.19,3 1.73,3zM12,14c-0.55,0 -1,-0.45 -1,-1v-2c0,-0.55 0.45,-1 1,-1s1,0.45 1,1v2c0,0.55 -0.45,1 -1,1zM13,18h-2v-2h2v2z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

View File

@ -11,9 +11,16 @@
<action <action
android:id="@+id/action_morePreferencesFragment_to_settingsPreferencesFragment" android:id="@+id/action_morePreferencesFragment_to_settingsPreferencesFragment"
app:destination="@id/settingsPreferencesFragment" /> app:destination="@id/settingsPreferencesFragment" />
<action
android:id="@+id/action_morePreferencesFragment_to_aboutFragment"
app:destination="@id/aboutFragment" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/settingsPreferencesFragment" android:id="@+id/settingsPreferencesFragment"
android:name="awais.instagrabber.fragments.settings.SettingsPreferencesFragment" android:name="awais.instagrabber.fragments.settings.SettingsPreferencesFragment"
android:label="@string/action_settings" /> android:label="@string/action_settings" />
<fragment
android:id="@+id/aboutFragment"
android:name="awais.instagrabber.fragments.settings.AboutFragment"
android:label="@string/action_about" />
</navigation> </navigation>

View File

@ -231,7 +231,8 @@
<string name="crash_descr">Oops.. the app crashed, but don\'t worry you can send error report to the developer to help him fix the issue. (:</string> <string name="crash_descr">Oops.. the app crashed, but don\'t worry you can send error report to the developer to help him fix the issue. (:</string>
<string name="use_amoled_dark_theme">Use AMOLED mode for Dark theme</string> <string name="use_amoled_dark_theme">Use AMOLED mode for Dark theme</string>
<string name="action_notif">Activity</string> <string name="action_notif">Activity</string>
<string name="license" translatable="false">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.</string> <string name="license" translatable="false">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/.</string>
<string name="liability" translatable="false">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.</string>
<string name="select_picture">Select Picture</string> <string name="select_picture">Select Picture</string>
<string name="uploading">Uploading...</string> <string name="uploading">Uploading...</string>
<string name="activity_count_prefix">You have:</string> <string name="activity_count_prefix">You have:</string>
@ -259,4 +260,13 @@
<string name="pref_category_downloads">Downloads</string> <string name="pref_category_downloads">Downloads</string>
<string name="pref_category_locale">Locale</string> <string name="pref_category_locale">Locale</string>
<string name="add_account">Add account</string> <string name="add_account">Add account</string>
<string name="about_category_license">License (English only)</string>
<string name="about_documentation">Visit our website</string>
<string name="about_documentation_summary">Get support, discuss, meet others, and have fun!</string>
<string name="about_repository">See our source code on GitHub</string>
<string name="about_repository_summary">Audit, star, report bugs, contribute, and have fun (again)!</string>
<string name="about_feedback">Send feedback by email</string>
<string name="about_feedback_summary" translatable="false">instagrabber@austinhuang.me</string>
<string name="about_category_3pt">Third-Party Libraries</string>
<string name="about_category_3pt_summary">The following third-party libraries are used in this app:</string>
</resources> </resources>