Compare commits

...

5 Commits

  1. 2
      README.md
  2. 4
      app/build.gradle
  3. 2
      app/src/full/res/values/bools.xml
  4. 2
      app/src/full/res/values/strings.xml
  5. 2
      app/src/lite/res/values/bools.xml
  6. 2
      app/src/lite/res/values/strings.xml
  7. 7
      app/src/main/AndroidManifest.xml
  8. 2
      app/src/main/java/org/transdroid/core/app/search/SearchHelper.java
  9. 2
      app/src/main/java/org/transdroid/core/app/search/SearchResult.java
  10. 2
      app/src/main/java/org/transdroid/core/app/search/SearchSite.java
  11. 2
      app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java
  12. 2
      app/src/main/java/org/transdroid/core/app/settings/NotificationSettings.java
  13. 2
      app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java
  14. 2
      app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java
  15. 5
      app/src/main/java/org/transdroid/core/app/settings/SettingsPersistence.java
  16. 2
      app/src/main/java/org/transdroid/core/app/settings/SystemSettings.java
  17. 2
      app/src/main/java/org/transdroid/core/app/settings/WebsearchSetting.java
  18. 3
      app/src/main/java/org/transdroid/core/gui/DetailsActivity.java
  19. 2
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java
  20. 2
      app/src/main/java/org/transdroid/core/gui/ServerPickerDialog.java
  21. 2
      app/src/main/java/org/transdroid/core/gui/ServerSelectionView.java
  22. 2
      app/src/main/java/org/transdroid/core/gui/ServerStatusView.java
  23. 2
      app/src/main/java/org/transdroid/core/gui/TorrentTasksExecutor.java
  24. 19
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  25. 2
      app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java
  26. 2
      app/src/main/java/org/transdroid/core/gui/TransdroidApp.java
  27. 2
      app/src/main/java/org/transdroid/core/gui/lists/DetailsAdapter.java
  28. 2
      app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java
  29. 2
      app/src/main/java/org/transdroid/core/gui/lists/MergeAdapter.java
  30. 2
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItem.java
  31. 2
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemAdapter.java
  32. 2
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemSpinnerAdapter.java
  33. 2
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemView.java
  34. 2
      app/src/main/java/org/transdroid/core/gui/lists/SortByListItem.java
  35. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentDetailsView.java
  36. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java
  37. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentFileView.java
  38. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentProgressBar.java
  39. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentStatusLayout.java
  40. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentView.java
  41. 2
      app/src/main/java/org/transdroid/core/gui/lists/TorrentsAdapter.java
  42. 2
      app/src/main/java/org/transdroid/core/gui/lists/ViewHolderAdapter.java
  43. 2
      app/src/main/java/org/transdroid/core/gui/log/DatabaseHelper.java
  44. 2
      app/src/main/java/org/transdroid/core/gui/log/ErrorLogEntry.java
  45. 2
      app/src/main/java/org/transdroid/core/gui/log/ErrorLogSender.java
  46. 2
      app/src/main/java/org/transdroid/core/gui/log/Log.java
  47. 2
      app/src/main/java/org/transdroid/core/gui/log/LogUncaughtExceptionHandler.java
  48. 2
      app/src/main/java/org/transdroid/core/gui/navigation/DialogHelper.java
  49. 2
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListAdapter.java
  50. 2
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemAdapter.java
  51. 2
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemView.java
  52. 2
      app/src/main/java/org/transdroid/core/gui/navigation/FilterSeparatorView.java
  53. 2
      app/src/main/java/org/transdroid/core/gui/navigation/Label.java
  54. 2
      app/src/main/java/org/transdroid/core/gui/navigation/NavigationFilter.java
  55. 56
      app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java
  56. 2
      app/src/main/java/org/transdroid/core/gui/navigation/RefreshableActivity.java
  57. 2
      app/src/main/java/org/transdroid/core/gui/navigation/SelectionManagerMode.java
  58. 2
      app/src/main/java/org/transdroid/core/gui/navigation/SelectionModificationSpinner.java
  59. 2
      app/src/main/java/org/transdroid/core/gui/navigation/SetLabelDialog.java
  60. 2
      app/src/main/java/org/transdroid/core/gui/navigation/SetStorageLocationDialog.java
  61. 2
      app/src/main/java/org/transdroid/core/gui/navigation/SetTrackersDialog.java
  62. 2
      app/src/main/java/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java
  63. 2
      app/src/main/java/org/transdroid/core/gui/navigation/StatusType.java
  64. 2
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java
  65. 2
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssItemView.java
  66. 3
      app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java
  67. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssFeedsFragment.java
  68. 3
      app/src/main/java/org/transdroid/core/gui/rss/RssItemsActivity.java
  69. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssItemsFragment.java
  70. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java
  71. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedView.java
  72. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsAdapter.java
  73. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssitemStatusLayout.java
  74. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssitemView.java
  75. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssitemsAdapter.java
  76. 2
      app/src/main/java/org/transdroid/core/gui/search/BarcodeHelper.java
  77. 2
      app/src/main/java/org/transdroid/core/gui/search/FilePickerHelper.java
  78. 3
      app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java
  79. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchHistoryProvider.java
  80. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchResultView.java
  81. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchResultsAdapter.java
  82. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java
  83. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchSetting.java
  84. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchSettingSelectionView.java
  85. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchSettingsDropDownAdapter.java
  86. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchSiteView.java
  87. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchSitesAdapter.java
  88. 2
      app/src/main/java/org/transdroid/core/gui/search/SendIntentHelper.java
  89. 2
      app/src/main/java/org/transdroid/core/gui/search/UrlEntryDialog.java
  90. 2
      app/src/main/java/org/transdroid/core/gui/settings/AboutDialog.java
  91. 2
      app/src/main/java/org/transdroid/core/gui/settings/ChangelogDialog.java
  92. 5
      app/src/main/java/org/transdroid/core/gui/settings/HelpSettingsActivity.java
  93. 2
      app/src/main/java/org/transdroid/core/gui/settings/KeyBoundPreferencesActivity.java
  94. 5
      app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java
  95. 32
      app/src/main/java/org/transdroid/core/gui/settings/NotificationSettingsActivity.java
  96. 2
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedPreference.java
  97. 5
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java
  98. 2
      app/src/main/java/org/transdroid/core/gui/settings/ServerPreference.java
  99. 6
      app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  100. 83
      app/src/main/java/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  101. Some files were not shown because too many files have changed in this diff Show More

2
README.md

@ -58,7 +58,7 @@ Contributions by various others (see commit log).
License License
======= =======
Copyright 2010-2023 Eric Kok et al. Copyright 2010-2024 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

4
app/build.gradle

@ -6,8 +6,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 34 targetSdkVersion 34
versionCode 243 versionCode 244
versionName '2.5.23' versionName '2.5.24'
javaCompileOptions { javaCompileOptions {
annotationProcessorOptions { annotationProcessorOptions {

2
app/src/full/res/values/bools.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!-- <?xml version="1.0" encoding="utf-8"?><!--
Copyright 2010-2018 Eric Kok et al. Copyright 2010-2024 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

2
app/src/full/res/values/strings.xml

@ -1,5 +1,5 @@
<!-- <!--
Copyright 2010-2018 Eric Kok et al. Copyright 2010-2024 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

2
app/src/lite/res/values/bools.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!-- <?xml version="1.0" encoding="utf-8"?><!--
Copyright 2010-2018 Eric Kok et al. Copyright 2010-2024 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

2
app/src/lite/res/values/strings.xml

@ -1,5 +1,5 @@
<!-- <!--
Copyright 2010-2018 Eric Kok et al. Copyright 2010-2024 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

7
app/src/main/AndroidManifest.xml

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!-- <?xml version="1.0" encoding="utf-8"?><!--
Copyright 2010-2018 Eric Kok et al. Copyright 2010-2024 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -35,8 +35,8 @@
<!-- To start rss and torrents background check services --> <!-- To start rss and torrents background check services -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<!-- To export settings file to external storage --> <!-- To show torrent and app update notifications -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-feature <uses-feature
android:name="android.hardware.touchscreen" android:name="android.hardware.touchscreen"
@ -69,7 +69,6 @@
<activity <activity
android:name="org.transdroid.core.gui.TorrentsActivity_" android:name="org.transdroid.core.gui.TorrentsActivity_"
android:allowTaskReparenting="true" android:allowTaskReparenting="true"
android:label="@string/app_name"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/TransdroidTheme" android:theme="@style/TransdroidTheme"
android:windowSoftInputMode="stateHidden" android:windowSoftInputMode="stateHidden"

2
app/src/main/java/org/transdroid/core/app/search/SearchHelper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/app/search/SearchResult.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/app/search/SearchSite.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/app/settings/NotificationSettings.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/app/settings/RssfeedSetting.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/app/settings/ServerSetting.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

5
app/src/main/java/org/transdroid/core/app/settings/SettingsPersistence.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -44,10 +44,7 @@ import java.io.OutputStream;
@EBean(scope = Scope.Singleton) @EBean(scope = Scope.Singleton)
public class SettingsPersistence { public class SettingsPersistence {
public static final String DEFAULT_SETTINGS_DIR = Environment.getExternalStorageDirectory().toString()
+ "/Transdroid/";
public static final String DEFAULT_SETTINGS_FILENAME = "settings.json"; public static final String DEFAULT_SETTINGS_FILENAME = "settings.json";
public static final File DEFAULT_SETTINGS_FILE = new File(DEFAULT_SETTINGS_DIR + DEFAULT_SETTINGS_FILENAME);
@Bean @Bean
protected ApplicationSettings applicationSettings; protected ApplicationSettings applicationSettings;
@Bean @Bean

2
app/src/main/java/org/transdroid/core/app/settings/SystemSettings.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/app/settings/WebsearchSetting.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

3
app/src/main/java/org/transdroid/core/gui/DetailsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -141,7 +141,6 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();

2
app/src/main/java/org/transdroid/core/gui/DetailsFragment.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/ServerPickerDialog.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/ServerSelectionView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/ServerStatusView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/TorrentTasksExecutor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

19
app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -214,8 +214,6 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
// Auto refresh task // Auto refresh task
private AsyncTask<Void, Void, Void> autoRefreshTask; private AsyncTask<Void, Void, Void> autoRefreshTask;
private String awaitingAddLocalFile;
private String awaitingAddTitle;
/** /**
* Handles item selections on the dedicated list of filter items * Handles item selections on the dedicated list of filter items
*/ */
@ -395,7 +393,6 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
} }
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void startAutoRefresh() { public void startAutoRefresh() {
// Check if already running // Check if already running
if (autoRefreshTask != null || stopRefresh || systemSettings.getRefreshIntervalMilliseconds() == 0) { if (autoRefreshTask != null || stopRefresh || systemSettings.getRefreshIntervalMilliseconds() == 0) {
@ -751,14 +748,6 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
return true; return true;
} }
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (awaitingAddLocalFile != null && awaitingAddTitle != null &&
Boolean.TRUE.equals(navigationHelper.handleTorrentReadPermissionResult(requestCode, grantResults))) {
addTorrentByFile(awaitingAddLocalFile, awaitingAddTitle);
}
}
@Click(R.id.addmenu_link_button) @Click(R.id.addmenu_link_button)
protected void startUrlEntryDialog() { protected void startUrlEntryDialog() {
addmenuButton.collapse(); addmenuButton.collapse();
@ -1026,12 +1015,6 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
@Background @Background
protected void addTorrentByFile(String localFile, String title) { protected void addTorrentByFile(String localFile, String title) {
if (!navigationHelper.checkTorrentReadPermission(this)) {
// No read permission yet (which we get the result of in onRequestPermissionsResult)
awaitingAddLocalFile = localFile;
awaitingAddTitle = title;
return;
}
DaemonTaskResult result = AddByFileTask.create(currentConnection, localFile).execute(log); DaemonTaskResult result = AddByFileTask.create(currentConnection, localFile).execute(log);
if (result instanceof DaemonTaskSuccessResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, title)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, title));

2
app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/TransdroidApp.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/DetailsAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/MergeAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/SimpleListItem.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemSpinnerAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/SortByListItem.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/TorrentDetailsView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/TorrentFileView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/TorrentProgressBar.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/TorrentStatusLayout.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/TorrentView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/TorrentsAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/lists/ViewHolderAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/log/DatabaseHelper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/log/ErrorLogEntry.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/log/ErrorLogSender.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/log/Log.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/log/LogUncaughtExceptionHandler.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/DialogHelper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/FilterListAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/FilterSeparatorView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/Label.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/NavigationFilter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

56
app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -18,14 +18,12 @@ package org.transdroid.core.gui.navigation;
import android.Manifest; import android.Manifest;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.style.TypefaceSpan; import android.text.style.TypefaceSpan;
@ -60,9 +58,7 @@ import java.util.List;
@EBean @EBean
public class NavigationHelper { public class NavigationHelper {
private static final int REQUEST_TORRENT_READ_PERMISSION = 0; private static final int REQUEST_NOTIFICATIONS_PERMISSION = 0;
private static final int REQUEST_SETTINGS_READ_PERMISSION = 1;
private static final int REQUEST_SETTINGS_WRITE_PERMISSION = 2;
private static ImageLoader imageCache; private static ImageLoader imageCache;
@RootContext @RootContext
@ -134,25 +130,11 @@ public class NavigationHelper {
return null; return null;
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public boolean checkOrRequestNotificationPermission(final Activity activity) {
public boolean checkTorrentReadPermission(final Activity activity) { return checkPermission(activity, Manifest.permission.POST_NOTIFICATIONS, REQUEST_NOTIFICATIONS_PERMISSION, R.string.permission_notifications);
return Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ||
checkPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE, REQUEST_TORRENT_READ_PERMISSION);
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private boolean checkPermission(final Activity activity, final String permission, final int requestCode, final int explainer) {
public boolean checkSettingsReadPermission(final Activity activity) {
return Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ||
checkPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE, REQUEST_SETTINGS_READ_PERMISSION);
}
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public boolean checkSettingsWritePermission(final Activity activity) {
return Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ||
checkPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE, REQUEST_SETTINGS_WRITE_PERMISSION);
}
private boolean checkPermission(final Activity activity, final String permission, final int requestCode) {
if (hasPermission(permission)) if (hasPermission(permission))
// Permission already granted // Permission already granted
return true; return true;
@ -160,43 +142,27 @@ public class NavigationHelper {
// Never asked again: show a dialog with an explanation // Never asked again: show a dialog with an explanation
activity.runOnUiThread(() -> activity.runOnUiThread(() ->
new AlertDialog.Builder(context) new AlertDialog.Builder(context)
.setMessage(R.string.permission_readtorrent) .setMessage(explainer)
.setPositiveButton(android.R.string.ok, (dialog, which) -> .setPositiveButton(android.R.string.ok, (dialog, which) ->
ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode)) ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode))
.show()); .show());
return false; return false;
} }
// Permission not granted (and we asked for it already before) // Permission not granted (and we asked for it already before)
ActivityCompat.requestPermissions(activity, new String[]{permission}, REQUEST_TORRENT_READ_PERMISSION); ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
return false; return false;
} }
private boolean hasPermission(String requiredPermission) { public boolean hasPermission(String requiredPermission) {
return ContextCompat.checkSelfPermission(context, requiredPermission) == PackageManager.PERMISSION_GRANTED; return ContextCompat.checkSelfPermission(context, requiredPermission) == PackageManager.PERMISSION_GRANTED;
} }
public Boolean handleTorrentReadPermissionResult(int requestCode, int[] grantResults) { public Boolean handleNotificationPermissionResult(int requestCode, int[] grantResults) {
if (requestCode == REQUEST_TORRENT_READ_PERMISSION) { if (requestCode == REQUEST_NOTIFICATIONS_PERMISSION) {
// Return permission granting result
return grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
}
return null;
}
public Boolean handleSettingsReadPermissionResult(int requestCode, int[] grantResults) {
if (requestCode == REQUEST_SETTINGS_READ_PERMISSION) {
// Return permission granting result // Return permission granting result
return grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED; return grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
} }
return null; return false;
}
public Boolean handleSettingsWritePermissionResult(int requestCode, int[] grantResults) {
if (requestCode == REQUEST_SETTINGS_WRITE_PERMISSION) {
// Return permission granting result
return grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
}
return null;
} }
/** /**

2
app/src/main/java/org/transdroid/core/gui/navigation/RefreshableActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/SelectionManagerMode.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/SelectionModificationSpinner.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/SetLabelDialog.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/SetStorageLocationDialog.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/SetTrackersDialog.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/navigation/StatusType.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssItemView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

3
app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -150,7 +150,6 @@ public class RssFeedsActivity extends AppCompatActivity {
} }
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();

2
app/src/main/java/org/transdroid/core/gui/rss/RssFeedsFragment.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

3
app/src/main/java/org/transdroid/core/gui/rss/RssItemsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -74,7 +74,6 @@ public class RssItemsActivity extends AppCompatActivity {
fragmentItems.update(rssfeed, false, requiresExternalAuthentication); fragmentItems.update(rssfeed, false, requiresExternalAuthentication);
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();

2
app/src/main/java/org/transdroid/core/gui/rss/RssItemsFragment.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/rss/RssfeedView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/rss/RssitemStatusLayout.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/rss/RssitemView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/rss/RssitemsAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/BarcodeHelper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/FilePickerHelper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

3
app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -277,7 +277,6 @@ public class SearchActivity extends AppCompatActivity {
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();

2
app/src/main/java/org/transdroid/core/gui/search/SearchHistoryProvider.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SearchResultView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SearchResultsAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SearchSetting.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SearchSettingSelectionView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SearchSettingsDropDownAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SearchSiteView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SearchSitesAdapter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/SendIntentHelper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/search/UrlEntryDialog.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/settings/AboutDialog.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

2
app/src/main/java/org/transdroid/core/gui/settings/ChangelogDialog.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

5
app/src/main/java/org/transdroid/core/gui/settings/HelpSettingsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,11 +16,9 @@
*/ */
package org.transdroid.core.gui.settings; package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.preference.Preference; import androidx.preference.Preference;
@ -88,7 +86,6 @@ public class HelpSettingsActivity extends PreferenceCompatActivity {
findPreference("system_about").setOnPreferenceClickListener(onAboutClick); findPreference("system_about").setOnPreferenceClickListener(onAboutClick);
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();

2
app/src/main/java/org/transdroid/core/gui/settings/KeyBoundPreferencesActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

5
app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,13 +16,11 @@
*/ */
package org.transdroid.core.gui.settings; package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@ -256,7 +254,6 @@ public class MainSettingsActivity extends PreferenceCompatActivity {
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); TorrentsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();

32
app/src/main/java/org/transdroid/core/gui/settings/NotificationSettingsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,13 +16,12 @@
*/ */
package org.transdroid.core.gui.settings; package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
@ -30,12 +29,15 @@ import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.app.settings.NotificationSettings; import org.transdroid.core.app.settings.NotificationSettings;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.service.RssCheckerJob; import org.transdroid.core.service.RssCheckerJob;
import org.transdroid.core.service.ServerCheckerJob; import org.transdroid.core.service.ServerCheckerJob;
@EActivity @EActivity
public class NotificationSettingsActivity extends PreferenceCompatActivity implements OnSharedPreferenceChangeListener { public class NotificationSettingsActivity extends PreferenceCompatActivity implements OnSharedPreferenceChangeListener {
@Bean
protected NavigationHelper navigationHelper;
@Bean @Bean
protected NotificationSettings notificationSettings; protected NotificationSettings notificationSettings;
@ -47,9 +49,19 @@ public class NotificationSettingsActivity extends PreferenceCompatActivity imple
// Load the notification-related preferences from XML and update availability thereof // Load the notification-related preferences from XML and update availability thereof
addPreferencesFromResource(R.xml.pref_notifications); addPreferencesFromResource(R.xml.pref_notifications);
boolean disabled = !notificationSettings.isEnabledForRss() && !notificationSettings.isEnabledForTorrents(); updatePrefsEnabled();
updatePrefsEnabled(disabled);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (navigationHelper.handleNotificationPermissionResult(requestCode, grantResults)) {
// Now that we have permission, schedule the jobs
ServerCheckerJob.schedule(getApplicationContext());
RssCheckerJob.schedule(getApplicationContext());
updatePrefsEnabled();
}
} }
@Override @Override
@ -71,7 +83,6 @@ public class NotificationSettingsActivity extends PreferenceCompatActivity imple
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
@ -79,11 +90,18 @@ public class NotificationSettingsActivity extends PreferenceCompatActivity imple
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
boolean needsPermission = notificationSettings.isEnabledForRss() || notificationSettings.isEnabledForTorrents();
if (needsPermission && !navigationHelper.checkOrRequestNotificationPermission(this)) {
return;
}
// Already have permission to show notifications, so update the jobs now
ServerCheckerJob.schedule(getApplicationContext()); ServerCheckerJob.schedule(getApplicationContext());
RssCheckerJob.schedule(getApplicationContext()); RssCheckerJob.schedule(getApplicationContext());
updatePrefsEnabled();
} }
private void updatePrefsEnabled(boolean disabled) { private void updatePrefsEnabled() {
boolean disabled = !notificationSettings.isEnabledForRss() && !notificationSettings.isEnabledForTorrents();
findPreference("notifications_interval").setEnabled(!disabled); findPreference("notifications_interval").setEnabled(!disabled);
findPreference("notifications_sound").setEnabled(!disabled); findPreference("notifications_sound").setEnabled(!disabled);
findPreference("notifications_vibrate").setEnabled(!disabled); findPreference("notifications_vibrate").setEnabled(!disabled);

2
app/src/main/java/org/transdroid/core/gui/settings/RssfeedPreference.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

5
app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,10 +16,8 @@
*/ */
package org.transdroid.core.gui.settings; package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@ -60,7 +58,6 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity {
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();

2
app/src/main/java/org/transdroid/core/gui/settings/ServerPreference.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by

6
app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,11 +16,9 @@
*/ */
package org.transdroid.core.gui.settings; package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.Dialog; import android.app.Dialog;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -95,7 +93,6 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
}); });
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
@ -123,6 +120,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (connectivityHelper.requestedPermissionWasGranted(requestCode, permissions, grantResults)) { if (connectivityHelper.requestedPermissionWasGranted(requestCode, permissions, grantResults)) {
localNetworkPreference.getOnPreferenceClickListener().onPreferenceClick(localNetworkPreference); localNetworkPreference.getOnPreferenceClickListener().onPreferenceClick(localNetworkPreference);
} }

83
app/src/main/java/org/transdroid/core/gui/settings/SystemSettingsActivity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2018 Eric Kok et al. * Copyright 2010-2024 Eric Kok et al.
* *
* Transdroid is free software: you can redistribute it and/or modify * Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,13 +16,11 @@
*/ */
package org.transdroid.core.gui.settings; package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
@ -48,7 +46,6 @@ import org.transdroid.core.gui.search.BarcodeHelper;
import org.transdroid.core.gui.search.SearchHistoryProvider; import org.transdroid.core.gui.search.SearchHistoryProvider;
import org.transdroid.core.service.AppUpdateJob; import org.transdroid.core.service.AppUpdateJob;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -68,6 +65,7 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
protected ErrorLogSender errorLogSender; protected ErrorLogSender errorLogSender;
@Bean @Bean
protected SettingsPersistence settingsPersistence; protected SettingsPersistence settingsPersistence;
private OnPreferenceClickListener onImportSettingsClick = preference -> { private OnPreferenceClickListener onImportSettingsClick = preference -> {
showDialog(DIALOG_IMPORTSETTINGS); showDialog(DIALOG_IMPORTSETTINGS);
return true; return true;
@ -77,7 +75,10 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
return true; return true;
}; };
private OnPreferenceClickListener onCheckUpdatesClick = preference -> { private OnPreferenceClickListener onCheckUpdatesClick = preference -> {
AppUpdateJob.schedule(getApplicationContext()); if (!navigationHelper.checkOrRequestNotificationPermission(this)) {
// Already have permission: continue
AppUpdateJob.schedule(getApplicationContext());
}
return true; return true;
}; };
private OnPreferenceClickListener onClearSearchClick = preference -> { private OnPreferenceClickListener onClearSearchClick = preference -> {
@ -88,9 +89,6 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
private OnClickListener importSettingsFromFile = new OnClickListener() { private OnClickListener importSettingsFromFile = new OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
&& !navigationHelper.checkSettingsReadPermission(SystemSettingsActivity.this))
return; // We are requesting permission to access file storage
importSettingsFromFile(); importSettingsFromFile();
} }
}; };
@ -101,9 +99,6 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
private OnClickListener exportSettingsToFile = new OnClickListener() { private OnClickListener exportSettingsToFile = new OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
&& !navigationHelper.checkSettingsWritePermission(SystemSettingsActivity.this))
return; // We are requesting permission to access file storage
exportSettingsToFile(); exportSettingsToFile();
} }
}; };
@ -142,7 +137,6 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
findPreference("system_exportsettings").setOnPreferenceClickListener(onExportSettingsClick); findPreference("system_exportsettings").setOnPreferenceClickListener(onExportSettingsClick);
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home) @OptionsItem(android.R.id.home)
protected void navigateUp() { protected void navigateUp() {
MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start(); MainSettingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
@ -150,32 +144,18 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (Boolean.TRUE.equals(navigationHelper.handleSettingsReadPermissionResult(requestCode, grantResults))) { super.onRequestPermissionsResult(requestCode, permissions, grantResults);
importSettingsFromFile(); if (navigationHelper.handleNotificationPermissionResult(requestCode, grantResults)) {
} else if (Boolean.TRUE.equals(navigationHelper.handleSettingsWritePermissionResult(requestCode, grantResults))) { // Now that we have permission, schedule the job
exportSettingsToFile(); AppUpdateJob.schedule(getApplicationContext());
} }
} }
private void importSettingsFromFile() { private void importSettingsFromFile() {
try { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { intent.addCategory(Intent.CATEGORY_OPENABLE);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SystemSettingsActivity.this); intent.setType("application/json");
settingsPersistence.importSettingsFromFile(prefs, SettingsPersistence.DEFAULT_SETTINGS_FILE); startActivityForResult(intent, ACTIVITY_IMPORT_SETTINGS);
SnackbarManager.show(Snackbar.with(SystemSettingsActivity.this).text(R.string.pref_import_success));
} else {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/json");
startActivityForResult(intent, ACTIVITY_IMPORT_SETTINGS);
}
} catch (FileNotFoundException e) {
SnackbarManager
.show(Snackbar.with(SystemSettingsActivity.this).text(R.string.error_file_not_found).colorResource(R.color.red));
} catch (JSONException e) {
SnackbarManager.show(Snackbar.with(SystemSettingsActivity.this)
.text(getString(R.string.error_no_valid_settings_file, getString(R.string.app_name))).colorResource(R.color.red));
}
} }
@OnActivityResult(ACTIVITY_IMPORT_SETTINGS) @OnActivityResult(ACTIVITY_IMPORT_SETTINGS)
@ -196,22 +176,11 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
} }
private void exportSettingsToFile() { private void exportSettingsToFile() {
try { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { intent.addCategory(Intent.CATEGORY_OPENABLE);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SystemSettingsActivity.this); intent.setType("application/json");
settingsPersistence.exportSettingsToFile(prefs, SettingsPersistence.DEFAULT_SETTINGS_FILE); intent.putExtra(Intent.EXTRA_TITLE, SettingsPersistence.DEFAULT_SETTINGS_FILENAME);
SnackbarManager.show(Snackbar.with(SystemSettingsActivity.this).text(R.string.pref_export_success)); startActivityForResult(intent, ACTIVITY_EXPORT_SETTINGS);
} else {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/json");
intent.putExtra(Intent.EXTRA_TITLE, SettingsPersistence.DEFAULT_SETTINGS_FILENAME);
startActivityForResult(intent, ACTIVITY_EXPORT_SETTINGS);
}
} catch (JSONException | IOException e) {
SnackbarManager.show(Snackbar.with(SystemSettingsActivity.this).text(R.string.error_cant_write_settings_file)
.colorResource(R.color.red));
}
} }
@OnActivityResult(ACTIVITY_EXPORT_SETTINGS) @OnActivityResult(ACTIVITY_EXPORT_SETTINGS)
@ -255,12 +224,7 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
case DIALOG_IMPORTSETTINGS: case DIALOG_IMPORTSETTINGS:
// @formatter:off // @formatter:off
return new AlertDialog.Builder(this) return new AlertDialog.Builder(this)
.setMessage( .setMessage(getString(R.string.pref_import_dialog_android10))
getString(
Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
? R.string.pref_import_dialog : R.string.pref_import_dialog_android10,
getString(R.string.app_name),
SettingsPersistence.DEFAULT_SETTINGS_FILE.toString()))
.setPositiveButton(R.string.pref_import_fromfile, importSettingsFromFile) .setPositiveButton(R.string.pref_import_fromfile, importSettingsFromFile)
.setNeutralButton(R.string.pref_import_fromqr, importSettingsFromQr) .setNeutralButton(R.string.pref_import_fromqr, importSettingsFromQr)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
@ -269,12 +233,7 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
case DIALOG_EXPORTSETTINGS: case DIALOG_EXPORTSETTINGS:
// @formatter:off // @formatter:off
return new AlertDialog.Builder(this) return new AlertDialog.Builder(this)
.setMessage( .setMessage(getString(R.string.pref_export_dialog_android10))
getString(
Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT
? R.string.pref_export_dialog : R.string.pref_export_dialog_android10,
getString(R.string.app_name),
SettingsPersistence.DEFAULT_SETTINGS_FILE.toString()))
.setPositiveButton(R.string.pref_export_tofile, exportSettingsToFile) .setPositiveButton(R.string.pref_export_tofile, exportSettingsToFile)
.setNeutralButton(R.string.pref_export_toqr, exportSettingsToQr) .setNeutralButton(R.string.pref_export_toqr, exportSettingsToQr)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save