Eric Kok
4 years ago
committed by
GitHub
377 changed files with 38951 additions and 38617 deletions
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
# editorconfig.org |
||||
root = true |
||||
|
||||
[*] |
||||
charset = utf-8 |
||||
end_of_line = lf |
||||
indent_style = space |
||||
insert_final_newline = true |
||||
trim_trailing_whitespace = true |
@ -1,29 +1,28 @@
@@ -1,29 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Copyright 2010-2018 Eric Kok et al. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<resources> |
||||
|
||||
<!-- Used to enable checking for app updates in the background --> |
||||
<bool name="updatecheck_available">true</bool> |
||||
<!-- Used to enable the search UI --> |
||||
<bool name="search_available">true</bool> |
||||
<!-- Used to enable the RSS UI and background service --> |
||||
<bool name="rss_available">true</bool> |
||||
<!-- Used to allow adding of seedboxes via easy server setup --> |
||||
<bool name="seedboxes_available">true</bool> |
||||
<!-- Used to enable checking for app updates in the background --> |
||||
<bool name="updatecheck_available">true</bool> |
||||
<!-- Used to enable the search UI --> |
||||
<bool name="search_available">true</bool> |
||||
<!-- Used to enable the RSS UI and background service --> |
||||
<bool name="rss_available">true</bool> |
||||
<!-- Used to allow adding of seedboxes via easy server setup --> |
||||
<bool name="seedboxes_available">true</bool> |
||||
|
||||
</resources> |
||||
|
@ -1,24 +1,24 @@
@@ -1,24 +1,24 @@
|
||||
<!-- |
||||
Copyright 2010-2018 Eric Kok et al. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<resources> |
||||
|
||||
<string name="app_name" translatable="false">Transdroid</string> |
||||
<string name="app_name" translatable="false">Transdroid</string> |
||||
|
||||
<string name="donate_text">Donate with PayPal</string> |
||||
<string name="donate_url">https://paypal.me/erickoknl</string> |
||||
<string name="donate_text">Donate with PayPal</string> |
||||
<string name="donate_url">https://paypal.me/erickoknl</string> |
||||
|
||||
</resources> |
||||
|
@ -1,29 +1,28 @@
@@ -1,29 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Copyright 2010-2018 Eric Kok et al. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<resources> |
||||
|
||||
<!-- Used to enable checking for app updates in the background --> |
||||
<bool name="updatecheck_available">false</bool> |
||||
<!-- Used to enable the search UI --> |
||||
<bool name="search_available">false</bool> |
||||
<!-- Used to enable the RSS UI and background service --> |
||||
<bool name="rss_available">false</bool> |
||||
<!-- Used to allow adding of seedboxes via easy server setup --> |
||||
<bool name="seedboxes_available">true</bool> |
||||
<!-- Used to enable checking for app updates in the background --> |
||||
<bool name="updatecheck_available">false</bool> |
||||
<!-- Used to enable the search UI --> |
||||
<bool name="search_available">false</bool> |
||||
<!-- Used to enable the RSS UI and background service --> |
||||
<bool name="rss_available">false</bool> |
||||
<!-- Used to allow adding of seedboxes via easy server setup --> |
||||
<bool name="seedboxes_available">true</bool> |
||||
|
||||
</resources> |
||||
|
@ -1,24 +1,24 @@
@@ -1,24 +1,24 @@
|
||||
<!-- |
||||
Copyright 2010-2018 Eric Kok et al. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<resources> |
||||
|
||||
<string name="app_name" translatable="false">Transdrone</string> |
||||
<string name="app_name" translatable="false">Transdrone</string> |
||||
|
||||
<string name="donate_text"></string> |
||||
<string name="donate_url"></string> |
||||
<string name="donate_text" /> |
||||
<string name="donate_url" /> |
||||
|
||||
</resources> |
||||
|
@ -1,333 +1,331 @@
@@ -1,333 +1,331 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<!-- |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Copyright 2010-2018 Eric Kok et al. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
Transdroid 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. |
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with Transdroid. If not, see <http://www.gnu.org/licenses/>. |
||||
--> |
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
package="org.transdroid" > |
||||
|
||||
<uses-sdk /> |
||||
|
||||
<supports-screens |
||||
android:anyDensity="true" |
||||
android:largeScreens="true" |
||||
android:normalScreens="true" |
||||
android:smallScreens="true" |
||||
android:xlargeScreens="true" /> |
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" /> |
||||
<!-- To check for an active connection --> |
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
||||
<!-- To check currently connected wifi network name --> |
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
||||
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" /> |
||||
<!-- To start rss and torrents background check services --> |
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> |
||||
<uses-permission android:name="android.permission.VIBRATE" /> |
||||
<!-- To export settings file to external storage --> |
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
||||
|
||||
<uses-feature |
||||
android:name="android.hardware.touchscreen" |
||||
android:required="false" /> |
||||
|
||||
<uses-feature |
||||
android:name="android.software.leanback" |
||||
android:required="false" /> |
||||
|
||||
<application |
||||
android:name=".core.gui.TransdroidApp_" |
||||
android:allowBackup="true" |
||||
android:hardwareAccelerated="true" |
||||
android:icon="@drawable/ic_launcher" |
||||
android:banner="@drawable/banner" |
||||
android:label="@string/app_name" |
||||
android:theme="@style/Theme.AppCompat" |
||||
android:usesCleartextTraffic="true"> |
||||
|
||||
<uses-library |
||||
android:name="org.apache.http.legacy" |
||||
android:required="false" /> |
||||
|
||||
<!-- Main activities --> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.TorrentsActivity_" |
||||
android:allowTaskReparenting="true" |
||||
android:label="@string/app_name" |
||||
android:launchMode="singleTop" |
||||
android:theme="@style/TransdroidTheme" |
||||
android:windowSoftInputMode="stateHidden" > |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.SEARCH" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="org.transdroid.ADD_MULTIPLE" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="org.transdroid.START_SERVER" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:mimeType="application/x-bittorrent" |
||||
android:scheme="http" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:pathPattern=".*\\.torrent" |
||||
android:scheme="http" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:mimeType="application/x-bittorrent" |
||||
android:scheme="https" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:pathPattern=".*\\.torrent" |
||||
android:scheme="https" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:mimeType="application/x-bittorrent" |
||||
android:scheme="file" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:pathPattern=".*\\.torrent" |
||||
android:scheme="file" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:mimeType="application/x-bittorrent" |
||||
android:scheme="content" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:pathPattern=".*\\.torrent" |
||||
android:scheme="content" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data android:scheme="magnet" /> |
||||
</intent-filter> |
||||
|
||||
<meta-data |
||||
android:name="android.app.default_searchable" |
||||
android:value="org.transdroid.core.gui.search.SearchActivity_" /> |
||||
</activity> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.DetailsActivity_" |
||||
android:theme="@style/TransdroidTheme" |
||||
android:uiOptions="splitActionBarWhenNarrow" > |
||||
</activity> |
||||
|
||||
<!-- Settings screens --> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.MainSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.ServerSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.WebsearchSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.RssfeedSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.NotificationSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.SystemSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.HelpSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.navigation.DialogHelper_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
|
||||
<!-- Seedbox settings --> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.DediseedboxSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.SeedstuffSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.XirvikSharedSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.XirvikSemiSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.XirvikDediSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
|
||||
<!-- Search --> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.search.SearchActivity_" |
||||
android:icon="@drawable/ic_launcher" |
||||
android:label="@string/search_torrentsearch" |
||||
android:launchMode="singleTask" |
||||
android:theme="@style/TransdroidTheme" > |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.SEARCH" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.SEND" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
|
||||
<data android:mimeType="text/plain" /> |
||||
</intent-filter> |
||||
|
||||
<meta-data |
||||
android:name="android.app.searchable" |
||||
android:resource="@xml/searchable" /> |
||||
<meta-data |
||||
android:name="android.app.default_searchable" |
||||
android:value="org.transdroid.core.gui.search.SearchActivity_" /> |
||||
</activity> |
||||
|
||||
<provider |
||||
android:name="org.transdroid.core.gui.search.SearchHistoryProvider" |
||||
android:authorities="@string/search_history_authority" |
||||
android:exported="false" /> |
||||
|
||||
<!-- RSS --> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.rss.RssFeedsActivity_" |
||||
android:label="@string/rss_feeds" |
||||
android:launchMode="singleTop" |
||||
android:theme="@style/TransdroidTheme" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.rss.RssItemsActivity_" |
||||
android:label="@string/rss_feeds" |
||||
android:theme="@style/TransdroidTheme" /> |
||||
|
||||
<receiver android:name="org.transdroid.core.service.BootReceiver_" > |
||||
<intent-filter> |
||||
<action |
||||
android:name="android.intent.action.BOOT_COMPLETED" |
||||
android:value="android.intent.action.BOOT_COMPLETED" /> |
||||
</intent-filter> |
||||
</receiver> |
||||
|
||||
<service |
||||
android:name="org.transdroid.core.service.ControlService_" |
||||
android:exported="true" |
||||
tools:ignore="ExportedService" > |
||||
<intent-filter> |
||||
<action android:name="org.transdroid.control.SET_TRANSFER_RATES" /> |
||||
<action android:name="org.transdroid.control.PAUSE_ALL" /> |
||||
<action android:name="org.transdroid.control.RESUME_ALL" /> |
||||
<action android:name="org.transdroid.control.START_ALL" /> |
||||
<action android:name="org.transdroid.control.STOP_ALL" /> |
||||
</intent-filter> |
||||
</service> |
||||
|
||||
<!-- Home screen widget --> |
||||
<activity |
||||
android:name="org.transdroid.core.widget.ListWidgetConfigActivity_" |
||||
android:theme="@style/TransdroidTheme.WidgetConfig" > |
||||
<intent-filter> |
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> |
||||
</intent-filter> |
||||
</activity> |
||||
|
||||
<service |
||||
android:name="org.transdroid.core.widget.ListWidgetViewsService_" |
||||
android:exported="false" |
||||
android:permission="android.permission.BIND_REMOTEVIEWS" /> |
||||
|
||||
<receiver |
||||
android:name="org.transdroid.core.widget.ListWidgetProvider_"> |
||||
<intent-filter> |
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> |
||||
</intent-filter> |
||||
|
||||
<meta-data |
||||
android:name="android.appwidget.provider" |
||||
android:resource="@xml/listwidget_info" /> |
||||
</receiver> |
||||
</application> |
||||
xmlns:tools="http://schemas.android.com/tools" |
||||
package="org.transdroid"> |
||||
|
||||
<uses-sdk /> |
||||
|
||||
<supports-screens |
||||
android:anyDensity="true" |
||||
android:largeScreens="true" |
||||
android:normalScreens="true" |
||||
android:smallScreens="true" |
||||
android:xlargeScreens="true" /> |
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" /> |
||||
<!-- To check for an active connection --> |
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
||||
<!-- To check currently connected wifi network name --> |
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
||||
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" /> |
||||
<!-- To start rss and torrents background check services --> |
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> |
||||
<uses-permission android:name="android.permission.VIBRATE" /> |
||||
<!-- To export settings file to external storage --> |
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
||||
|
||||
<uses-feature |
||||
android:name="android.hardware.touchscreen" |
||||
android:required="false" /> |
||||
|
||||
<uses-feature |
||||
android:name="android.software.leanback" |
||||
android:required="false" /> |
||||
|
||||
<application |
||||
android:name=".core.gui.TransdroidApp_" |
||||
android:allowBackup="true" |
||||
android:banner="@drawable/banner" |
||||
android:hardwareAccelerated="true" |
||||
android:icon="@drawable/ic_launcher" |
||||
android:label="@string/app_name" |
||||
android:supportsRtl="true" |
||||
android:theme="@style/Theme.AppCompat" |
||||
android:usesCleartextTraffic="true"> |
||||
|
||||
<uses-library |
||||
android:name="org.apache.http.legacy" |
||||
android:required="false" /> |
||||
|
||||
<!-- Main activities --> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.TorrentsActivity_" |
||||
android:allowTaskReparenting="true" |
||||
android:label="@string/app_name" |
||||
android:launchMode="singleTop" |
||||
android:theme="@style/TransdroidTheme" |
||||
android:windowSoftInputMode="stateHidden"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.MAIN" /> |
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" /> |
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.SEARCH" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="org.transdroid.ADD_MULTIPLE" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="org.transdroid.START_SERVER" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:mimeType="application/x-bittorrent" |
||||
android:scheme="http" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:pathPattern=".*\\.torrent" |
||||
android:scheme="http" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:mimeType="application/x-bittorrent" |
||||
android:scheme="https" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:pathPattern=".*\\.torrent" |
||||
android:scheme="https" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:mimeType="application/x-bittorrent" |
||||
android:scheme="file" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:pathPattern=".*\\.torrent" |
||||
android:scheme="file" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:mimeType="application/x-bittorrent" |
||||
android:scheme="content" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data |
||||
android:host="*" |
||||
android:pathPattern=".*\\.torrent" |
||||
android:scheme="content" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.VIEW" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
<category android:name="android.intent.category.BROWSABLE" /> |
||||
|
||||
<data android:scheme="magnet" /> |
||||
</intent-filter> |
||||
|
||||
<meta-data |
||||
android:name="android.app.default_searchable" |
||||
android:value="org.transdroid.core.gui.search.SearchActivity_" /> |
||||
</activity> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.DetailsActivity_" |
||||
android:theme="@style/TransdroidTheme" |
||||
android:uiOptions="splitActionBarWhenNarrow" /> |
||||
|
||||
<!-- Settings screens --> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.MainSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.ServerSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.WebsearchSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.RssfeedSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.NotificationSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.SystemSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.settings.HelpSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.navigation.DialogHelper_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
|
||||
<!-- Seedbox settings --> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.DediseedboxSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.SeedstuffSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.XirvikSharedSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.XirvikSemiSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
<activity |
||||
android:name="org.transdroid.core.seedbox.XirvikDediSettingsActivity_" |
||||
android:theme="@style/TransdroidTheme.Settings" /> |
||||
|
||||
<!-- Search --> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.search.SearchActivity_" |
||||
android:icon="@drawable/ic_launcher" |
||||
android:label="@string/search_torrentsearch" |
||||
android:launchMode="singleTask" |
||||
android:theme="@style/TransdroidTheme"> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.SEARCH" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
</intent-filter> |
||||
<intent-filter> |
||||
<action android:name="android.intent.action.SEND" /> |
||||
|
||||
<category android:name="android.intent.category.DEFAULT" /> |
||||
|
||||
<data android:mimeType="text/plain" /> |
||||
</intent-filter> |
||||
|
||||
<meta-data |
||||
android:name="android.app.searchable" |
||||
android:resource="@xml/searchable" /> |
||||
<meta-data |
||||
android:name="android.app.default_searchable" |
||||
android:value="org.transdroid.core.gui.search.SearchActivity_" /> |
||||
</activity> |
||||
|
||||
<provider |
||||
android:name="org.transdroid.core.gui.search.SearchHistoryProvider" |
||||
android:authorities="@string/search_history_authority" |
||||
android:exported="false" /> |
||||
|
||||
<!-- RSS --> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.rss.RssFeedsActivity_" |
||||
android:label="@string/rss_feeds" |
||||
android:launchMode="singleTop" |
||||
android:theme="@style/TransdroidTheme" /> |
||||
<activity |
||||
android:name="org.transdroid.core.gui.rss.RssItemsActivity_" |
||||
android:label="@string/rss_feeds" |
||||
android:theme="@style/TransdroidTheme" /> |
||||
|
||||
<receiver android:name="org.transdroid.core.service.BootReceiver_"> |
||||
<intent-filter> |
||||
<action |
||||
android:name="android.intent.action.BOOT_COMPLETED" |
||||
android:value="android.intent.action.BOOT_COMPLETED" /> |
||||
</intent-filter> |
||||
</receiver> |
||||
|
||||
<service |
||||
android:name="org.transdroid.core.service.ControlService_" |
||||
android:exported="true" |
||||
tools:ignore="ExportedService"> |
||||
<intent-filter> |
||||
<action android:name="org.transdroid.control.SET_TRANSFER_RATES" /> |
||||
<action android:name="org.transdroid.control.PAUSE_ALL" /> |
||||
<action android:name="org.transdroid.control.RESUME_ALL" /> |
||||
<action android:name="org.transdroid.control.START_ALL" /> |
||||
<action android:name="org.transdroid.control.STOP_ALL" /> |
||||
</intent-filter> |
||||
</service> |
||||
|
||||
<!-- Home screen widget --> |
||||
<activity |
||||
android:name="org.transdroid.core.widget.ListWidgetConfigActivity_" |
||||
android:theme="@style/TransdroidTheme.WidgetConfig"> |
||||
<intent-filter> |
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" /> |
||||
</intent-filter> |
||||
</activity> |
||||
|
||||
<service |
||||
android:name="org.transdroid.core.widget.ListWidgetViewsService_" |
||||
android:exported="false" |
||||
android:permission="android.permission.BIND_REMOTEVIEWS" /> |
||||
|
||||
<receiver android:name="org.transdroid.core.widget.ListWidgetProvider_"> |
||||
<intent-filter> |
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> |
||||
</intent-filter> |
||||
|
||||
<meta-data |
||||
android:name="android.appwidget.provider" |
||||
android:resource="@xml/listwidget_info" /> |
||||
</receiver> |
||||
</application> |
||||
|
||||
</manifest> |
||||
|
@ -1,122 +1,122 @@
@@ -1,122 +1,122 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.app.search; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import android.os.Parcel; |
||||
import android.os.Parcelable; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* Represents a search result as retrieved by querying the Torrent Search package. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class SearchResult implements Parcelable { |
||||
|
||||
private final int id; |
||||
private final String name; |
||||
private final String torrentUrl; |
||||
private final String detailsUrl; |
||||
private final String size; |
||||
private final Date addedOn; |
||||
private final String seeders; |
||||
private final String leechers; |
||||
|
||||
public SearchResult(int id, String name, String torrentUrl, String detailsUrl, String size, long addedOnTime, |
||||
String seeders, String leechers) { |
||||
this.id = id; |
||||
this.name = name; |
||||
this.torrentUrl = torrentUrl; |
||||
this.detailsUrl = detailsUrl; |
||||
this.size = size; |
||||
this.addedOn = (addedOnTime == -1L) ? null : new Date(addedOnTime); |
||||
this.seeders = seeders; |
||||
this.leechers = leechers; |
||||
} |
||||
|
||||
public int getId() { |
||||
return id; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public String getTorrentUrl() { |
||||
return torrentUrl; |
||||
} |
||||
|
||||
public String getDetailsUrl() { |
||||
return detailsUrl; |
||||
} |
||||
|
||||
public String getSize() { |
||||
return size; |
||||
} |
||||
|
||||
public Date getAddedOn() { |
||||
return addedOn; |
||||
} |
||||
|
||||
public String getSeeders() { |
||||
return seeders; |
||||
} |
||||
|
||||
public String getLeechers() { |
||||
return leechers; |
||||
} |
||||
|
||||
@Override |
||||
public int describeContents() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public void writeToParcel(Parcel out, int flags) { |
||||
out.writeInt(id); |
||||
out.writeString(name); |
||||
out.writeString(torrentUrl); |
||||
out.writeString(detailsUrl); |
||||
out.writeString(size); |
||||
out.writeLong(addedOn == null ? -1 : addedOn.getTime()); |
||||
out.writeString(seeders); |
||||
out.writeString(leechers); |
||||
} |
||||
|
||||
public static final Parcelable.Creator<SearchResult> CREATOR = new Parcelable.Creator<SearchResult>() { |
||||
public SearchResult createFromParcel(Parcel in) { |
||||
return new SearchResult(in); |
||||
} |
||||
|
||||
public SearchResult[] newArray(int size) { |
||||
return new SearchResult[size]; |
||||
} |
||||
}; |
||||
|
||||
public SearchResult(Parcel in) { |
||||
id = in.readInt(); |
||||
name = in.readString(); |
||||
torrentUrl = in.readString(); |
||||
detailsUrl = in.readString(); |
||||
size = in.readString(); |
||||
long addedOnIn = in.readLong(); |
||||
addedOn = addedOnIn == -1 ? null : new Date(addedOnIn); |
||||
seeders = in.readString(); |
||||
leechers = in.readString(); |
||||
} |
||||
public static final Parcelable.Creator<SearchResult> CREATOR = new Parcelable.Creator<SearchResult>() { |
||||
public SearchResult createFromParcel(Parcel in) { |
||||
return new SearchResult(in); |
||||
} |
||||
|
||||
public SearchResult[] newArray(int size) { |
||||
return new SearchResult[size]; |
||||
} |
||||
}; |
||||
private final int id; |
||||
private final String name; |
||||
private final String torrentUrl; |
||||
private final String detailsUrl; |
||||
private final String size; |
||||
private final Date addedOn; |
||||
private final String seeders; |
||||
private final String leechers; |
||||
|
||||
public SearchResult(int id, String name, String torrentUrl, String detailsUrl, String size, long addedOnTime, |
||||
String seeders, String leechers) { |
||||
this.id = id; |
||||
this.name = name; |
||||
this.torrentUrl = torrentUrl; |
||||
this.detailsUrl = detailsUrl; |
||||
this.size = size; |
||||
this.addedOn = (addedOnTime == -1L) ? null : new Date(addedOnTime); |
||||
this.seeders = seeders; |
||||
this.leechers = leechers; |
||||
} |
||||
|
||||
public SearchResult(Parcel in) { |
||||
id = in.readInt(); |
||||
name = in.readString(); |
||||
torrentUrl = in.readString(); |
||||
detailsUrl = in.readString(); |
||||
size = in.readString(); |
||||
long addedOnIn = in.readLong(); |
||||
addedOn = addedOnIn == -1 ? null : new Date(addedOnIn); |
||||
seeders = in.readString(); |
||||
leechers = in.readString(); |
||||
} |
||||
|
||||
public int getId() { |
||||
return id; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public String getTorrentUrl() { |
||||
return torrentUrl; |
||||
} |
||||
|
||||
public String getDetailsUrl() { |
||||
return detailsUrl; |
||||
} |
||||
|
||||
public String getSize() { |
||||
return size; |
||||
} |
||||
|
||||
public Date getAddedOn() { |
||||
return addedOn; |
||||
} |
||||
|
||||
public String getSeeders() { |
||||
return seeders; |
||||
} |
||||
|
||||
public String getLeechers() { |
||||
return leechers; |
||||
} |
||||
|
||||
@Override |
||||
public int describeContents() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public void writeToParcel(Parcel out, int flags) { |
||||
out.writeInt(id); |
||||
out.writeString(name); |
||||
out.writeString(torrentUrl); |
||||
out.writeString(detailsUrl); |
||||
out.writeString(size); |
||||
out.writeLong(addedOn == null ? -1 : addedOn.getTime()); |
||||
out.writeString(seeders); |
||||
out.writeString(leechers); |
||||
} |
||||
|
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,122 +1,126 @@
@@ -1,122 +1,126 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.app.settings; |
||||
|
||||
import java.util.Date; |
||||
import android.net.Uri; |
||||
import android.text.TextUtils; |
||||
|
||||
import org.transdroid.core.gui.lists.SimpleListItem; |
||||
|
||||
import android.net.Uri; |
||||
import android.text.TextUtils; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* Represents a user-specified RSS feed. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class RssfeedSetting implements SimpleListItem { |
||||
|
||||
private static final String DEFAULT_NAME = "Default"; |
||||
|
||||
private final int order; |
||||
private final String name; |
||||
private final String url; |
||||
private final boolean requiresAuth; |
||||
private final boolean alarm; |
||||
private final String excludeFilter; |
||||
private final String includeFilter; |
||||
private Date lastViewed; |
||||
private final String lastViewedItemUrl; |
||||
|
||||
public RssfeedSetting(int order, String name, String baseUrl, boolean needsAuth, boolean alarm, String excludeFilter, String includeFilter, Date lastViewed, |
||||
String lastViewedItemUrl) { |
||||
this.order = order; |
||||
this.name = name; |
||||
this.url = baseUrl; |
||||
this.requiresAuth = needsAuth; |
||||
this.alarm = alarm; |
||||
this.excludeFilter = excludeFilter; |
||||
this.includeFilter = includeFilter; |
||||
this.lastViewed = lastViewed; |
||||
this.lastViewedItemUrl = lastViewedItemUrl; |
||||
} |
||||
|
||||
public int getOrder() { |
||||
return order; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
if (!TextUtils.isEmpty(name)) |
||||
return name; |
||||
if (!TextUtils.isEmpty(url)) { |
||||
String host = Uri.parse(url).getHost(); |
||||
return host == null ? DEFAULT_NAME : host; |
||||
} |
||||
return DEFAULT_NAME; |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url; |
||||
} |
||||
|
||||
public boolean requiresExternalAuthentication() { |
||||
return requiresAuth; |
||||
} |
||||
|
||||
public boolean shouldAlarmOnNewItems() { |
||||
return alarm; |
||||
} |
||||
|
||||
public String getExcludeFilter() { |
||||
return excludeFilter; |
||||
} |
||||
|
||||
public String getIncludeFilter() { |
||||
return includeFilter; |
||||
} |
||||
|
||||
/** |
||||
* Returns the date on which we last checked this feed. Note that this is NOT updated automatically after the |
||||
* settings were loaded from {@link ApplicationSettings}; instead the settings have to be manually loaded again |
||||
* using {@link ApplicationSettings#getRssfeedSetting(int)}. |
||||
* @return The last new item's URL as URL-encoded string |
||||
*/ |
||||
public Date getLastViewed() { |
||||
return this.lastViewed; |
||||
} |
||||
|
||||
/** |
||||
* Returns the URL of the item that was the newest last time we checked this feed. Note that this is NOT updated |
||||
* automatically after the settings were loaded from {@link ApplicationSettings}; instead the settings have to be |
||||
* manually loaded again using {@link ApplicationSettings#getRssfeedSetting(int)}. |
||||
* @return The last new item's URL as URL-encoded string |
||||
*/ |
||||
public String getLastViewedItemUrl() { |
||||
return this.lastViewedItemUrl; |
||||
} |
||||
|
||||
/** |
||||
* Returns a nicely formatted identifier containing (a portion of) the feed URL |
||||
* @return A string to identify this feed's URL |
||||
*/ |
||||
public String getHumanReadableIdentifier() { |
||||
String host = Uri.parse(url).getHost(); |
||||
String path = Uri.parse(url).getPath(); |
||||
return (host == null ? null : host + (path == null ? "" : path)); |
||||
} |
||||
private static final String DEFAULT_NAME = "Default"; |
||||
|
||||
private final int order; |
||||
private final String name; |
||||
private final String url; |
||||
private final boolean requiresAuth; |
||||
private final boolean alarm; |
||||
private final String excludeFilter; |
||||
private final String includeFilter; |
||||
private final String lastViewedItemUrl; |
||||
private Date lastViewed; |
||||
|
||||
public RssfeedSetting(int order, String name, String baseUrl, boolean needsAuth, boolean alarm, String excludeFilter, String includeFilter, Date lastViewed, |
||||
String lastViewedItemUrl) { |
||||
this.order = order; |
||||
this.name = name; |
||||
this.url = baseUrl; |
||||
this.requiresAuth = needsAuth; |
||||
this.alarm = alarm; |
||||
this.excludeFilter = excludeFilter; |
||||
this.includeFilter = includeFilter; |
||||
this.lastViewed = lastViewed; |
||||
this.lastViewedItemUrl = lastViewedItemUrl; |
||||
} |
||||
|
||||
public int getOrder() { |
||||
return order; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
if (!TextUtils.isEmpty(name)) |
||||
return name; |
||||
if (!TextUtils.isEmpty(url)) { |
||||
String host = Uri.parse(url).getHost(); |
||||
return host == null ? DEFAULT_NAME : host; |
||||
} |
||||
return DEFAULT_NAME; |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url; |
||||
} |
||||
|
||||
public boolean requiresExternalAuthentication() { |
||||
return requiresAuth; |
||||
} |
||||
|
||||
public boolean shouldAlarmOnNewItems() { |
||||
return alarm; |
||||
} |
||||
|
||||
public String getExcludeFilter() { |
||||
return excludeFilter; |
||||
} |
||||
|
||||
public String getIncludeFilter() { |
||||
return includeFilter; |
||||
} |
||||
|
||||
/** |
||||
* Returns the date on which we last checked this feed. Note that this is NOT updated automatically after the |
||||
* settings were loaded from {@link ApplicationSettings}; instead the settings have to be manually loaded again |
||||
* using {@link ApplicationSettings#getRssfeedSetting(int)}. |
||||
* |
||||
* @return The last new item's URL as URL-encoded string |
||||
*/ |
||||
public Date getLastViewed() { |
||||
return this.lastViewed; |
||||
} |
||||
|
||||
/** |
||||
* Returns the URL of the item that was the newest last time we checked this feed. Note that this is NOT updated |
||||
* automatically after the settings were loaded from {@link ApplicationSettings}; instead the settings have to be |
||||
* manually loaded again using {@link ApplicationSettings#getRssfeedSetting(int)}. |
||||
* |
||||
* @return The last new item's URL as URL-encoded string |
||||
*/ |
||||
public String getLastViewedItemUrl() { |
||||
return this.lastViewedItemUrl; |
||||
} |
||||
|
||||
/** |
||||
* Returns a nicely formatted identifier containing (a portion of) the feed URL |
||||
* |
||||
* @return A string to identify this feed's URL |
||||
*/ |
||||
public String getHumanReadableIdentifier() { |
||||
String host = Uri.parse(url).getHost(); |
||||
String path = Uri.parse(url).getPath(); |
||||
return (host == null ? null : host + (path == null ? "" : path)); |
||||
} |
||||
|
||||
} |
||||
|
@ -1,81 +1,82 @@
@@ -1,81 +1,82 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.app.settings; |
||||
|
||||
import org.transdroid.core.gui.lists.SimpleListItem; |
||||
import org.transdroid.core.gui.search.SearchSetting; |
||||
|
||||
import android.net.Uri; |
||||
import android.text.TextUtils; |
||||
|
||||
import org.transdroid.core.gui.lists.SimpleListItem; |
||||
import org.transdroid.core.gui.search.SearchSetting; |
||||
|
||||
/** |
||||
* Represents a user-specified website that can be searched (by starting the browser, rather than in-app) |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class WebsearchSetting implements SimpleListItem, SearchSetting { |
||||
|
||||
private static final String DEFAULT_NAME = "Default"; |
||||
public static final String KEY_PREFIX = "websearch_"; |
||||
|
||||
private final int order; |
||||
private final String name; |
||||
private final String baseUrl; |
||||
private final String cookies; |
||||
public static final String KEY_PREFIX = "websearch_"; |
||||
private static final String DEFAULT_NAME = "Default"; |
||||
private final int order; |
||||
private final String name; |
||||
private final String baseUrl; |
||||
private final String cookies; |
||||
|
||||
public WebsearchSetting(int order, String name, String baseUrl, String cookies) { |
||||
this.order = order; |
||||
this.name = name; |
||||
this.baseUrl = baseUrl; |
||||
this.cookies = cookies; |
||||
} |
||||
|
||||
public int getOrder() { |
||||
return order; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
if (!TextUtils.isEmpty(name)) |
||||
return name; |
||||
if (!TextUtils.isEmpty(baseUrl)) { |
||||
String host = Uri.parse(baseUrl).getHost(); |
||||
return host == null ? DEFAULT_NAME : host; |
||||
} |
||||
return DEFAULT_NAME; |
||||
} |
||||
|
||||
public WebsearchSetting(int order, String name, String baseUrl, String cookies) { |
||||
this.order = order; |
||||
this.name = name; |
||||
this.baseUrl = baseUrl; |
||||
this.cookies = cookies; |
||||
} |
||||
public String getBaseUrl() { |
||||
return baseUrl; |
||||
} |
||||
|
||||
public int getOrder() { |
||||
return order; |
||||
} |
||||
public String getCookies() { |
||||
return cookies; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
if (!TextUtils.isEmpty(name)) |
||||
return name; |
||||
if (!TextUtils.isEmpty(baseUrl)) { |
||||
String host = Uri.parse(baseUrl).getHost(); |
||||
return host == null? DEFAULT_NAME: host; |
||||
} |
||||
return DEFAULT_NAME; |
||||
} |
||||
|
||||
public String getBaseUrl() { |
||||
return baseUrl; |
||||
} |
||||
public String getKey() { |
||||
return KEY_PREFIX + getOrder(); |
||||
} |
||||
|
||||
public String getCookies() { |
||||
return cookies; |
||||
} |
||||
|
||||
public String getKey() { |
||||
return KEY_PREFIX + getOrder(); |
||||
} |
||||
/** |
||||
* Returns a nicely formatted identifier containing (a portion of) the search base URL |
||||
* |
||||
* @return A string to identify this site's search URL |
||||
*/ |
||||
public String getHumanReadableIdentifier() { |
||||
return Uri.parse(baseUrl).getHost(); |
||||
} |
||||
|
||||
/** |
||||
* Returns a nicely formatted identifier containing (a portion of) the search base URL |
||||
* @return A string to identify this site's search URL |
||||
*/ |
||||
public String getHumanReadableIdentifier() { |
||||
return Uri.parse(baseUrl).getHost(); |
||||
} |
||||
|
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,230 +1,235 @@
@@ -1,230 +1,235 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.lists; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import org.transdroid.R; |
||||
import org.transdroid.core.gui.navigation.*; |
||||
import org.transdroid.core.gui.lists.PiecesMapView; |
||||
import org.transdroid.daemon.Torrent; |
||||
import org.transdroid.daemon.TorrentFile; |
||||
|
||||
import android.content.Context; |
||||
import android.text.util.Linkify; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.BaseAdapter; |
||||
|
||||
import org.transdroid.R; |
||||
import org.transdroid.core.gui.navigation.FilterSeparatorView_; |
||||
import org.transdroid.daemon.Torrent; |
||||
import org.transdroid.daemon.TorrentFile; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* List adapter that holds a header view showing torrent details and show the list list contained by the torrent. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class DetailsAdapter extends MergeAdapter { |
||||
|
||||
private ViewHolderAdapter torrentDetailsViewAdapter = null; |
||||
private TorrentDetailsView torrentDetailsView = null; |
||||
private ViewHolderAdapter piecesSeparatorAdapter = null; |
||||
private ViewHolderAdapter piecesMapViewAdapter = null; |
||||
private PiecesMapView piecesMapView = null; |
||||
private ViewHolderAdapter trackersSeparatorAdapter = null; |
||||
private SimpleListItemAdapter trackersAdapter = null; |
||||
private ViewHolderAdapter errorsSeparatorAdapter = null; |
||||
private SimpleListItemAdapter errorsAdapter = null; |
||||
private ViewHolderAdapter torrentFilesSeparatorAdapter = null; |
||||
private TorrentFilesAdapter torrentFilesAdapter = null; |
||||
|
||||
public DetailsAdapter(Context context) { |
||||
// Immediately bind the adapters, or the MergeAdapter will not be able to determine the view types and instead
|
||||
// display nothing at all
|
||||
|
||||
// Torrent details header
|
||||
torrentDetailsView = TorrentDetailsView_.build(context); |
||||
torrentDetailsViewAdapter = new ViewHolderAdapter(torrentDetailsView); |
||||
torrentDetailsViewAdapter.setViewEnabled(false); |
||||
torrentDetailsViewAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(torrentDetailsViewAdapter); |
||||
|
||||
// Pieces map
|
||||
piecesSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText( |
||||
context.getString(R.string.status_pieces))); |
||||
piecesSeparatorAdapter.setViewEnabled(false); |
||||
piecesSeparatorAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(piecesSeparatorAdapter); |
||||
piecesMapView = new PiecesMapView(context); |
||||
piecesMapViewAdapter = new ViewHolderAdapter(piecesMapView); |
||||
piecesMapViewAdapter.setViewEnabled(false); |
||||
piecesMapViewAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(piecesMapViewAdapter); |
||||
|
||||
// Tracker errors
|
||||
errorsSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText( |
||||
context.getString(R.string.status_errors))); |
||||
errorsSeparatorAdapter.setViewEnabled(false); |
||||
errorsSeparatorAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(errorsSeparatorAdapter); |
||||
this.errorsAdapter = new SimpleListItemAdapter(context, new ArrayList<SimpleListItem>()); |
||||
this.errorsAdapter.setAutoLinkMask(Linkify.WEB_URLS); |
||||
addAdapter(errorsAdapter); |
||||
|
||||
// Trackers
|
||||
trackersSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText( |
||||
context.getString(R.string.status_trackers))); |
||||
trackersSeparatorAdapter.setViewEnabled(false); |
||||
trackersSeparatorAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(trackersSeparatorAdapter); |
||||
this.trackersAdapter = new SimpleListItemAdapter(context, new ArrayList<SimpleListItem>()); |
||||
addAdapter(trackersAdapter); |
||||
|
||||
// Torrent files
|
||||
torrentFilesSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText( |
||||
context.getString(R.string.status_files))); |
||||
torrentFilesSeparatorAdapter.setViewEnabled(false); |
||||
torrentFilesSeparatorAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(torrentFilesSeparatorAdapter); |
||||
this.torrentFilesAdapter = new TorrentFilesAdapter(context, new ArrayList<TorrentFile>()); |
||||
addAdapter(torrentFilesAdapter); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Update the torrent data in the details header of this merge adapter |
||||
* @param torrent The torrent for which detailed data is shown |
||||
*/ |
||||
public void updateTorrent(Torrent torrent) { |
||||
torrentDetailsView.update(torrent); |
||||
torrentDetailsViewAdapter.setViewVisibility(torrent == null ? View.GONE : View.VISIBLE); |
||||
} |
||||
|
||||
/** |
||||
* Update the list of files contained in this torrent |
||||
* @param torrentFiles The new list of files, or null if the list and header should be hidden |
||||
*/ |
||||
public void updateTorrentFiles(List<TorrentFile> torrentFiles) { |
||||
if (torrentFiles == null) { |
||||
torrentFilesAdapter.update(new ArrayList<TorrentFile>()); |
||||
torrentFilesSeparatorAdapter.setViewVisibility(View.GONE); |
||||
} else { |
||||
torrentFilesAdapter.update(torrentFiles); |
||||
torrentFilesSeparatorAdapter.setViewVisibility(View.VISIBLE); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Update the list of trackers |
||||
* @param trackers The new list of trackers known for this torrent, or null if the list and header should be hidden |
||||
*/ |
||||
public void updateTrackers(List<? extends SimpleListItem> trackers) { |
||||
if (trackers == null || trackers.isEmpty()) { |
||||
trackersAdapter.update(new ArrayList<SimpleListItemAdapter.SimpleStringItem>()); |
||||
trackersSeparatorAdapter.setViewVisibility(View.GONE); |
||||
} else { |
||||
trackersAdapter.update(trackers); |
||||
trackersSeparatorAdapter.setViewVisibility(View.VISIBLE); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Update the list of errors |
||||
* @param errors The new list of errors known for this torrent, or null if the list and header should be hidden |
||||
*/ |
||||
public void updateErrors(List<? extends SimpleListItem> errors) { |
||||
if (errors == null || errors.isEmpty()) { |
||||
errorsAdapter.update(new ArrayList<SimpleListItemAdapter.SimpleStringItem>()); |
||||
errorsSeparatorAdapter.setViewVisibility(View.GONE); |
||||
} else { |
||||
errorsAdapter.update(errors); |
||||
errorsSeparatorAdapter.setViewVisibility(View.VISIBLE); |
||||
} |
||||
} |
||||
|
||||
public void updatePieces(List<Integer> pieces) { |
||||
if (pieces == null || pieces.isEmpty()) { |
||||
piecesSeparatorAdapter.setViewEnabled(false); |
||||
piecesSeparatorAdapter.setViewVisibility(View.GONE); |
||||
piecesMapViewAdapter.setViewEnabled(false); |
||||
piecesMapViewAdapter.setViewVisibility(View.GONE); |
||||
} else { |
||||
piecesMapView.setPieces(pieces); |
||||
|
||||
piecesMapViewAdapter.setViewEnabled(true); |
||||
piecesMapViewAdapter.setViewVisibility(View.VISIBLE); |
||||
piecesSeparatorAdapter.setViewEnabled(true); |
||||
piecesSeparatorAdapter.setViewVisibility(View.VISIBLE); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Clear currently visible torrent, including header and shown lists |
||||
*/ |
||||
public void clear() { |
||||
updateTorrent(null); |
||||
updateTorrentFiles(null); |
||||
updateErrors(null); |
||||
updateTrackers(null); |
||||
} |
||||
|
||||
protected static class TorrentFilesAdapter extends BaseAdapter { |
||||
|
||||
private final Context context; |
||||
private List<TorrentFile> items; |
||||
|
||||
public TorrentFilesAdapter(Context context, List<TorrentFile> items) { |
||||
this.context = context; |
||||
this.items = items; |
||||
} |
||||
|
||||
/** |
||||
* Allows updating of the full data list underlying this adapter, replacing all items |
||||
* @param newItems The new list of files to display |
||||
*/ |
||||
public void update(List<TorrentFile> newItems) { |
||||
this.items = newItems; |
||||
notifyDataSetChanged(); |
||||
} |
||||
|
||||
@Override |
||||
public int getCount() { |
||||
return items.size(); |
||||
} |
||||
|
||||
@Override |
||||
public TorrentFile getItem(int position) { |
||||
return items.get(position); |
||||
} |
||||
|
||||
@Override |
||||
public long getItemId(int position) { |
||||
return position; |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
TorrentFileView torrentFileView; |
||||
if (convertView == null) { |
||||
torrentFileView = TorrentFileView_.build(context); |
||||
} else { |
||||
torrentFileView = (TorrentFileView) convertView; |
||||
} |
||||
torrentFileView.bind(getItem(position)); |
||||
return torrentFileView; |
||||
} |
||||
|
||||
} |
||||
private ViewHolderAdapter torrentDetailsViewAdapter = null; |
||||
private TorrentDetailsView torrentDetailsView = null; |
||||
private ViewHolderAdapter piecesSeparatorAdapter = null; |
||||
private ViewHolderAdapter piecesMapViewAdapter = null; |
||||
private PiecesMapView piecesMapView = null; |
||||
private ViewHolderAdapter trackersSeparatorAdapter = null; |
||||
private SimpleListItemAdapter trackersAdapter = null; |
||||
private ViewHolderAdapter errorsSeparatorAdapter = null; |
||||
private SimpleListItemAdapter errorsAdapter = null; |
||||
private ViewHolderAdapter torrentFilesSeparatorAdapter = null; |
||||
private TorrentFilesAdapter torrentFilesAdapter = null; |
||||
|
||||
public DetailsAdapter(Context context) { |
||||
// Immediately bind the adapters, or the MergeAdapter will not be able to determine the view types and instead
|
||||
// display nothing at all
|
||||
|
||||
// Torrent details header
|
||||
torrentDetailsView = TorrentDetailsView_.build(context); |
||||
torrentDetailsViewAdapter = new ViewHolderAdapter(torrentDetailsView); |
||||
torrentDetailsViewAdapter.setViewEnabled(false); |
||||
torrentDetailsViewAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(torrentDetailsViewAdapter); |
||||
|
||||
// Pieces map
|
||||
piecesSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText( |
||||
context.getString(R.string.status_pieces))); |
||||
piecesSeparatorAdapter.setViewEnabled(false); |
||||
piecesSeparatorAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(piecesSeparatorAdapter); |
||||
piecesMapView = new PiecesMapView(context); |
||||
piecesMapViewAdapter = new ViewHolderAdapter(piecesMapView); |
||||
piecesMapViewAdapter.setViewEnabled(false); |
||||
piecesMapViewAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(piecesMapViewAdapter); |
||||
|
||||
// Tracker errors
|
||||
errorsSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText( |
||||
context.getString(R.string.status_errors))); |
||||
errorsSeparatorAdapter.setViewEnabled(false); |
||||
errorsSeparatorAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(errorsSeparatorAdapter); |
||||
this.errorsAdapter = new SimpleListItemAdapter(context, new ArrayList<>()); |
||||
this.errorsAdapter.setAutoLinkMask(Linkify.WEB_URLS); |
||||
addAdapter(errorsAdapter); |
||||
|
||||
// Trackers
|
||||
trackersSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText( |
||||
context.getString(R.string.status_trackers))); |
||||
trackersSeparatorAdapter.setViewEnabled(false); |
||||
trackersSeparatorAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(trackersSeparatorAdapter); |
||||
this.trackersAdapter = new SimpleListItemAdapter(context, new ArrayList<>()); |
||||
addAdapter(trackersAdapter); |
||||
|
||||
// Torrent files
|
||||
torrentFilesSeparatorAdapter = new ViewHolderAdapter(FilterSeparatorView_.build(context).setText( |
||||
context.getString(R.string.status_files))); |
||||
torrentFilesSeparatorAdapter.setViewEnabled(false); |
||||
torrentFilesSeparatorAdapter.setViewVisibility(View.GONE); |
||||
addAdapter(torrentFilesSeparatorAdapter); |
||||
this.torrentFilesAdapter = new TorrentFilesAdapter(context, new ArrayList<>()); |
||||
addAdapter(torrentFilesAdapter); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Update the torrent data in the details header of this merge adapter |
||||
* |
||||
* @param torrent The torrent for which detailed data is shown |
||||
*/ |
||||
public void updateTorrent(Torrent torrent) { |
||||
torrentDetailsView.update(torrent); |
||||
torrentDetailsViewAdapter.setViewVisibility(torrent == null ? View.GONE : View.VISIBLE); |
||||
} |
||||
|
||||
/** |
||||
* Update the list of files contained in this torrent |
||||
* |
||||
* @param torrentFiles The new list of files, or null if the list and header should be hidden |
||||
*/ |
||||
public void updateTorrentFiles(List<TorrentFile> torrentFiles) { |
||||
if (torrentFiles == null) { |
||||
torrentFilesAdapter.update(new ArrayList<>()); |
||||
torrentFilesSeparatorAdapter.setViewVisibility(View.GONE); |
||||
} else { |
||||
torrentFilesAdapter.update(torrentFiles); |
||||
torrentFilesSeparatorAdapter.setViewVisibility(View.VISIBLE); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Update the list of trackers |
||||
* |
||||
* @param trackers The new list of trackers known for this torrent, or null if the list and header should be hidden |
||||
*/ |
||||
public void updateTrackers(List<? extends SimpleListItem> trackers) { |
||||
if (trackers == null || trackers.isEmpty()) { |
||||
trackersAdapter.update(new ArrayList<SimpleListItemAdapter.SimpleStringItem>()); |
||||
trackersSeparatorAdapter.setViewVisibility(View.GONE); |
||||
} else { |
||||
trackersAdapter.update(trackers); |
||||
trackersSeparatorAdapter.setViewVisibility(View.VISIBLE); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Update the list of errors |
||||
* |
||||
* @param errors The new list of errors known for this torrent, or null if the list and header should be hidden |
||||
*/ |
||||
public void updateErrors(List<? extends SimpleListItem> errors) { |
||||
if (errors == null || errors.isEmpty()) { |
||||
errorsAdapter.update(new ArrayList<SimpleListItemAdapter.SimpleStringItem>()); |
||||
errorsSeparatorAdapter.setViewVisibility(View.GONE); |
||||
} else { |
||||
errorsAdapter.update(errors); |
||||
errorsSeparatorAdapter.setViewVisibility(View.VISIBLE); |
||||
} |
||||
} |
||||
|
||||
public void updatePieces(List<Integer> pieces) { |
||||
if (pieces == null || pieces.isEmpty()) { |
||||
piecesSeparatorAdapter.setViewEnabled(false); |
||||
piecesSeparatorAdapter.setViewVisibility(View.GONE); |
||||
piecesMapViewAdapter.setViewEnabled(false); |
||||
piecesMapViewAdapter.setViewVisibility(View.GONE); |
||||
} else { |
||||
piecesMapView.setPieces(pieces); |
||||
|
||||
piecesMapViewAdapter.setViewEnabled(true); |
||||
piecesMapViewAdapter.setViewVisibility(View.VISIBLE); |
||||
piecesSeparatorAdapter.setViewEnabled(true); |
||||
piecesSeparatorAdapter.setViewVisibility(View.VISIBLE); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Clear currently visible torrent, including header and shown lists |
||||
*/ |
||||
public void clear() { |
||||
updateTorrent(null); |
||||
updateTorrentFiles(null); |
||||
updateErrors(null); |
||||
updateTrackers(null); |
||||
} |
||||
|
||||
protected static class TorrentFilesAdapter extends BaseAdapter { |
||||
|
||||
private final Context context; |
||||
private List<TorrentFile> items; |
||||
|
||||
public TorrentFilesAdapter(Context context, List<TorrentFile> items) { |
||||
this.context = context; |
||||
this.items = items; |
||||
} |
||||
|
||||
/** |
||||
* Allows updating of the full data list underlying this adapter, replacing all items |
||||
* |
||||
* @param newItems The new list of files to display |
||||
*/ |
||||
public void update(List<TorrentFile> newItems) { |
||||
this.items = newItems; |
||||
notifyDataSetChanged(); |
||||
} |
||||
|
||||
@Override |
||||
public int getCount() { |
||||
return items.size(); |
||||
} |
||||
|
||||
@Override |
||||
public TorrentFile getItem(int position) { |
||||
return items.get(position); |
||||
} |
||||
|
||||
@Override |
||||
public long getItemId(int position) { |
||||
return position; |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
TorrentFileView torrentFileView; |
||||
if (convertView == null) { |
||||
torrentFileView = TorrentFileView_.build(context); |
||||
} else { |
||||
torrentFileView = (TorrentFileView) convertView; |
||||
} |
||||
torrentFileView.bind(getItem(position)); |
||||
return torrentFileView; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -1,114 +1,117 @@
@@ -1,114 +1,117 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.lists; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import android.content.Context; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.BaseAdapter; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class SimpleListItemAdapter extends BaseAdapter { |
||||
|
||||
private final Context context; |
||||
private List<? extends SimpleListItem> items; |
||||
private int autoLinkMask = 0; |
||||
|
||||
public SimpleListItemAdapter(Context context, List<? extends SimpleListItem> items) { |
||||
this.context = context; |
||||
this.items = items; |
||||
} |
||||
|
||||
/** |
||||
* Allows updating of the full data list underlying this adapter, replacing all items |
||||
* @param newItems The new list of simple list items to display |
||||
*/ |
||||
public void update(List<? extends SimpleListItem> newItems) { |
||||
this.items = newItems; |
||||
notifyDataSetChanged(); |
||||
} |
||||
|
||||
public void setAutoLinkMask(int autoLinkMask) { |
||||
this.autoLinkMask = autoLinkMask; |
||||
} |
||||
|
||||
@Override |
||||
public int getCount() { |
||||
return items.size(); |
||||
} |
||||
|
||||
@Override |
||||
public SimpleListItem getItem(int position) { |
||||
return items.get(position); |
||||
} |
||||
|
||||
@Override |
||||
public long getItemId(int position) { |
||||
return position; |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
SimpleListItemView filterItemView; |
||||
if (convertView == null || !(convertView instanceof SimpleListItemView)) { |
||||
filterItemView = SimpleListItemView_.build(context); |
||||
} else { |
||||
filterItemView = (SimpleListItemView) convertView; |
||||
} |
||||
filterItemView.bind(getItem(position), autoLinkMask); |
||||
return filterItemView; |
||||
} |
||||
|
||||
/** |
||||
* Represents a very simple list item that only contains a single string to show in the list. Use wrapStringsList to |
||||
* wrap an existing list of strings into a list of {@link SimpleListItem}s. |
||||
* @author Eric Kok |
||||
*/ |
||||
public static class SimpleStringItem implements SimpleListItem { |
||||
|
||||
/** |
||||
* Wraps a simple string of strings into a list of SimpleStringItem to add as data to a |
||||
* {@link SimpleListItemAdapter} |
||||
* @param strings A list of string |
||||
* @return A list of SimpleStringItem objects representing the input strings |
||||
*/ |
||||
public static List<SimpleStringItem> wrapStringsList(List<String> strings) { |
||||
ArrayList<SimpleStringItem> errors = new ArrayList<SimpleStringItem>(); |
||||
if (strings != null) { |
||||
for (String string : strings) { |
||||
errors.add(new SimpleStringItem(string)); |
||||
} |
||||
} |
||||
return errors; |
||||
} |
||||
|
||||
private final String string; |
||||
|
||||
public SimpleStringItem(String string) { |
||||
this.string = string; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return this.string; |
||||
} |
||||
|
||||
} |
||||
private final Context context; |
||||
private List<? extends SimpleListItem> items; |
||||
private int autoLinkMask = 0; |
||||
|
||||
public SimpleListItemAdapter(Context context, List<? extends SimpleListItem> items) { |
||||
this.context = context; |
||||
this.items = items; |
||||
} |
||||
|
||||
/** |
||||
* Allows updating of the full data list underlying this adapter, replacing all items |
||||
* |
||||
* @param newItems The new list of simple list items to display |
||||
*/ |
||||
public void update(List<? extends SimpleListItem> newItems) { |
||||
this.items = newItems; |
||||
notifyDataSetChanged(); |
||||
} |
||||
|
||||
public void setAutoLinkMask(int autoLinkMask) { |
||||
this.autoLinkMask = autoLinkMask; |
||||
} |
||||
|
||||
@Override |
||||
public int getCount() { |
||||
return items.size(); |
||||
} |
||||
|
||||
@Override |
||||
public SimpleListItem getItem(int position) { |
||||
return items.get(position); |
||||
} |
||||
|
||||
@Override |
||||
public long getItemId(int position) { |
||||
return position; |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
SimpleListItemView filterItemView; |
||||
if (!(convertView instanceof SimpleListItemView)) { |
||||
filterItemView = SimpleListItemView_.build(context); |
||||
} else { |
||||
filterItemView = (SimpleListItemView) convertView; |
||||
} |
||||
filterItemView.bind(getItem(position), autoLinkMask); |
||||
return filterItemView; |
||||
} |
||||
|
||||
/** |
||||
* Represents a very simple list item that only contains a single string to show in the list. Use wrapStringsList to |
||||
* wrap an existing list of strings into a list of {@link SimpleListItem}s. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public static class SimpleStringItem implements SimpleListItem { |
||||
|
||||
private final String string; |
||||
|
||||
public SimpleStringItem(String string) { |
||||
this.string = string; |
||||
} |
||||
|
||||
/** |
||||
* Wraps a simple string of strings into a list of SimpleStringItem to add as data to a |
||||
* {@link SimpleListItemAdapter} |
||||
* |
||||
* @param strings A list of string |
||||
* @return A list of SimpleStringItem objects representing the input strings |
||||
*/ |
||||
public static List<SimpleStringItem> wrapStringsList(List<String> strings) { |
||||
ArrayList<SimpleStringItem> errors = new ArrayList<>(); |
||||
if (strings != null) { |
||||
for (String string : strings) { |
||||
errors.add(new SimpleStringItem(string)); |
||||
} |
||||
} |
||||
return errors; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return this.string; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -1,66 +1,68 @@
@@ -1,66 +1,68 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.lists; |
||||
|
||||
import java.util.List; |
||||
|
||||
import android.content.Context; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.ArrayAdapter; |
||||
import android.widget.TextView; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* A wrapper around {@link ArrayAdapter} that contains {@link SimpleListItem}s which simply show their name in the |
||||
* Spinner. The standard Android spinner resources are used for the layout. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class SimpleListItemSpinnerAdapter<T extends SimpleListItem> extends ArrayAdapter<T> { |
||||
|
||||
/** |
||||
* Constructs the adapter, supplying the {@link SimpleListItem}s to show in the spinner. The given resource will be |
||||
* ignored as the standard Android Spinner layout is used instead. |
||||
* @param context The UI context to inflate the layout in |
||||
* @param resource This is ignored; android.R.layout.simple_spinner_item is always used instead |
||||
* @param objects The items to show in the spinner, which can simply display some name |
||||
*/ |
||||
public SimpleListItemSpinnerAdapter(Context context, int resource, List<T> objects) { |
||||
super(context, android.R.layout.simple_spinner_item, objects); |
||||
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
// This relies on the ArrayAdapter implementation and the used standard xml layouts that simply return a
|
||||
// TextView; this can then be filled with the SimpleListItem's name instead of the standard toString()
|
||||
// implementation
|
||||
TextView text = (TextView) super.getView(position, convertView, parent); |
||||
text.setText(getItem(position).getName()); |
||||
return text; |
||||
} |
||||
/** |
||||
* Constructs the adapter, supplying the {@link SimpleListItem}s to show in the spinner. The given resource will be |
||||
* ignored as the standard Android Spinner layout is used instead. |
||||
* |
||||
* @param context The UI context to inflate the layout in |
||||
* @param resource This is ignored; android.R.layout.simple_spinner_item is always used instead |
||||
* @param objects The items to show in the spinner, which can simply display some name |
||||
*/ |
||||
public SimpleListItemSpinnerAdapter(Context context, int resource, List<T> objects) { |
||||
super(context, android.R.layout.simple_spinner_item, objects); |
||||
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
// This relies on the ArrayAdapter implementation and the used standard xml layouts that simply return a
|
||||
// TextView; this can then be filled with the SimpleListItem's name instead of the standard toString()
|
||||
// implementation
|
||||
TextView text = (TextView) super.getView(position, convertView, parent); |
||||
text.setText(getItem(position).getName()); |
||||
return text; |
||||
} |
||||
|
||||
@Override |
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) { |
||||
// This relies on the ArrayAdapter implementation and the used standard xml layouts that simply return a
|
||||
// TextView; this can then be filled with the SimpleListItem's name instead of the standard toString()
|
||||
// implementation
|
||||
TextView text = (TextView) super.getDropDownView(position, convertView, parent); |
||||
text.setText(getItem(position).getName()); |
||||
return text; |
||||
} |
||||
|
||||
@Override |
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) { |
||||
// This relies on the ArrayAdapter implementation and the used standard xml layouts that simply return a
|
||||
// TextView; this can then be filled with the SimpleListItem's name instead of the standard toString()
|
||||
// implementation
|
||||
TextView text = (TextView) super.getDropDownView(position, convertView, parent); |
||||
text.setText(getItem(position).getName()); |
||||
return text; |
||||
} |
||||
|
||||
} |
||||
|
@ -1,78 +1,81 @@
@@ -1,78 +1,81 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.lists; |
||||
|
||||
import android.content.Context; |
||||
|
||||
import org.transdroid.R; |
||||
import org.transdroid.daemon.TorrentsSortBy; |
||||
|
||||
/** |
||||
* Represents a way in which a torrents list can be sorted. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class SortByListItem implements SimpleListItem { |
||||
|
||||
private final TorrentsSortBy sortBy; |
||||
private final String name; |
||||
private final TorrentsSortBy sortBy; |
||||
private final String name; |
||||
|
||||
public SortByListItem(Context context, TorrentsSortBy sortBy) { |
||||
this.sortBy = sortBy; |
||||
switch (sortBy) { |
||||
case DateAdded: |
||||
this.name = context.getString(R.string.action_sort_added); |
||||
break; |
||||
case DateDone: |
||||
this.name = context.getString(R.string.action_sort_done); |
||||
break; |
||||
case Ratio: |
||||
this.name = context.getString(R.string.action_sort_ratio); |
||||
break; |
||||
case Status: |
||||
this.name = context.getString(R.string.action_sort_status); |
||||
break; |
||||
case UploadSpeed: |
||||
this.name = context.getString(R.string.action_sort_upspeed); |
||||
break; |
||||
case DownloadSpeed: |
||||
this.name = context.getString(R.string.action_sort_downspeed); |
||||
break; |
||||
case Percent: |
||||
this.name = context.getString(R.string.action_sort_percent); |
||||
break; |
||||
case Size: |
||||
this.name = context.getString(R.string.action_sort_size); |
||||
break; |
||||
default: |
||||
this.name = context.getString(R.string.action_sort_alpha); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Returns the contained represented sort order. |
||||
* |
||||
* @return The sort by order as its enumeration value |
||||
*/ |
||||
public TorrentsSortBy getSortBy() { |
||||
return sortBy; |
||||
} |
||||
|
||||
public SortByListItem(Context context, TorrentsSortBy sortBy) { |
||||
this.sortBy = sortBy; |
||||
switch (sortBy) { |
||||
case DateAdded: |
||||
this.name = context.getString(R.string.action_sort_added); |
||||
break; |
||||
case DateDone: |
||||
this.name = context.getString(R.string.action_sort_done); |
||||
break; |
||||
case Ratio: |
||||
this.name = context.getString(R.string.action_sort_ratio); |
||||
break; |
||||
case Status: |
||||
this.name = context.getString(R.string.action_sort_status); |
||||
break; |
||||
case UploadSpeed: |
||||
this.name = context.getString(R.string.action_sort_upspeed); |
||||
break; |
||||
case DownloadSpeed: |
||||
this.name = context.getString(R.string.action_sort_downspeed); |
||||
break; |
||||
case Percent: |
||||
this.name = context.getString(R.string.action_sort_percent); |
||||
break; |
||||
case Size: |
||||
this.name = context.getString(R.string.action_sort_size); |
||||
break; |
||||
default: |
||||
this.name = context.getString(R.string.action_sort_alpha); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Returns the contained represented sort order. |
||||
* @return The sort by order as its enumeration value |
||||
*/ |
||||
public TorrentsSortBy getSortBy() { |
||||
return sortBy; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return name; |
||||
} |
||||
@Override |
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
} |
||||
|
@ -1,69 +1,71 @@
@@ -1,69 +1,71 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.log; |
||||
|
||||
import java.sql.SQLException; |
||||
|
||||
import android.content.Context; |
||||
import android.database.sqlite.SQLiteDatabase; |
||||
import androidx.annotation.Keep; |
||||
import android.util.Log; |
||||
|
||||
import androidx.annotation.Keep; |
||||
|
||||
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; |
||||
import com.j256.ormlite.support.ConnectionSource; |
||||
import com.j256.ormlite.table.TableUtils; |
||||
|
||||
import java.sql.SQLException; |
||||
|
||||
/** |
||||
* Helper to access the database to access persisting objects. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class DatabaseHelper extends OrmLiteSqliteOpenHelper { |
||||
|
||||
private static final String DATABASE_NAME = "transdroid.db"; |
||||
private static final int DATABASE_VERSION = 1; |
||||
private static final String DATABASE_NAME = "transdroid.db"; |
||||
private static final int DATABASE_VERSION = 1; |
||||
|
||||
@Keep |
||||
public DatabaseHelper(Context context) { |
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION); |
||||
} |
||||
@Keep |
||||
public DatabaseHelper(Context context) { |
||||
super(context, DATABASE_NAME, null, DATABASE_VERSION); |
||||
} |
||||
|
||||
@Override |
||||
public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource) { |
||||
try { |
||||
TableUtils.createTable(connectionSource, ErrorLogEntry.class); |
||||
} catch (SQLException e) { |
||||
Log.e(org.transdroid.core.gui.log.Log.LOG_NAME, "Could not create new table for ErrorLogEntry", e); |
||||
} |
||||
} |
||||
@Override |
||||
public void onCreate(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource) { |
||||
try { |
||||
TableUtils.createTable(connectionSource, ErrorLogEntry.class); |
||||
} catch (SQLException e) { |
||||
Log.e(org.transdroid.core.gui.log.Log.LOG_NAME, "Could not create new table for ErrorLogEntry", e); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource, int oldVersion, |
||||
int newVersion) { |
||||
try { |
||||
switch (oldVersion) { |
||||
case 1: |
||||
TableUtils.createTable(connectionSource, ErrorLogEntry.class); |
||||
/*case 1: |
||||
@Override |
||||
public void onUpgrade(SQLiteDatabase sqLiteDatabase, ConnectionSource connectionSource, int oldVersion, |
||||
int newVersion) { |
||||
try { |
||||
switch (oldVersion) { |
||||
case 1: |
||||
TableUtils.createTable(connectionSource, ErrorLogEntry.class); |
||||
/*case 2: |
||||
etc...*/ |
||||
} |
||||
} |
||||
|
||||
} catch (SQLException e) { |
||||
Log.e(org.transdroid.core.gui.log.Log.LOG_NAME, "Could not upgrade the table for ErrorLogEntry", e); |
||||
} |
||||
} |
||||
} catch (SQLException e) { |
||||
Log.e(org.transdroid.core.gui.log.Log.LOG_NAME, "Could not upgrade the table for ErrorLogEntry", e); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -1,108 +1,107 @@
@@ -1,108 +1,107 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.log; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import android.os.Parcel; |
||||
import android.os.Parcelable; |
||||
|
||||
import com.j256.ormlite.field.DatabaseField; |
||||
import com.j256.ormlite.table.DatabaseTable; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* Represents an error log entry to be registered in the database. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
@DatabaseTable(tableName = "ErrorLogEntry") |
||||
public class ErrorLogEntry implements Parcelable { |
||||
|
||||
public static final String ID = "logId"; |
||||
public static final String DATEANDTIME = "dateAndTime"; |
||||
|
||||
@DatabaseField(id = true, columnName = ID) |
||||
private Integer logId; |
||||
@DatabaseField(columnName = DATEANDTIME) |
||||
private Date dateAndTime; |
||||
@DatabaseField |
||||
private Integer priority; |
||||
@DatabaseField |
||||
private String tag; |
||||
@DatabaseField |
||||
private String message; |
||||
|
||||
public ErrorLogEntry() { |
||||
} |
||||
|
||||
public ErrorLogEntry(Integer priority, String tag, String message) { |
||||
this.dateAndTime = new Date(); |
||||
this.priority = priority; |
||||
this.tag = tag; |
||||
this.message = message; |
||||
} |
||||
|
||||
public Integer getLogId() { |
||||
return logId; |
||||
} |
||||
|
||||
public Date getDateAndTime() { |
||||
return dateAndTime; |
||||
} |
||||
|
||||
public Integer getPriority() { |
||||
return priority; |
||||
} |
||||
|
||||
public String getTag() { |
||||
return tag; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
|
||||
public int describeContents() { |
||||
return 0; |
||||
} |
||||
|
||||
public void writeToParcel(Parcel out, int flags) { |
||||
out.writeInt(logId); |
||||
out.writeLong(dateAndTime.getTime()); |
||||
out.writeInt(priority); |
||||
out.writeString(tag); |
||||
out.writeString(message); |
||||
} |
||||
|
||||
public static final Parcelable.Creator<ErrorLogEntry> CREATOR = new Parcelable.Creator<ErrorLogEntry>() { |
||||
public ErrorLogEntry createFromParcel(Parcel in) { |
||||
return new ErrorLogEntry(in); |
||||
} |
||||
|
||||
public ErrorLogEntry[] newArray(int size) { |
||||
return new ErrorLogEntry[size]; |
||||
} |
||||
}; |
||||
|
||||
private ErrorLogEntry(Parcel in) { |
||||
logId = in.readInt(); |
||||
dateAndTime = new Date(in.readLong()); |
||||
priority = in.readInt(); |
||||
tag = in.readString(); |
||||
message = in.readString(); |
||||
} |
||||
public static final String ID = "logId"; |
||||
public static final String DATEANDTIME = "dateAndTime"; |
||||
public static final Parcelable.Creator<ErrorLogEntry> CREATOR = new Parcelable.Creator<ErrorLogEntry>() { |
||||
public ErrorLogEntry createFromParcel(Parcel in) { |
||||
return new ErrorLogEntry(in); |
||||
} |
||||
|
||||
public ErrorLogEntry[] newArray(int size) { |
||||
return new ErrorLogEntry[size]; |
||||
} |
||||
}; |
||||
@DatabaseField(id = true, columnName = ID) |
||||
private Integer logId; |
||||
@DatabaseField(columnName = DATEANDTIME) |
||||
private Date dateAndTime; |
||||
@DatabaseField |
||||
private Integer priority; |
||||
@DatabaseField |
||||
private String tag; |
||||
@DatabaseField |
||||
private String message; |
||||
|
||||
public ErrorLogEntry() { |
||||
} |
||||
|
||||
public ErrorLogEntry(Integer priority, String tag, String message) { |
||||
this.dateAndTime = new Date(); |
||||
this.priority = priority; |
||||
this.tag = tag; |
||||
this.message = message; |
||||
} |
||||
|
||||
private ErrorLogEntry(Parcel in) { |
||||
logId = in.readInt(); |
||||
dateAndTime = new Date(in.readLong()); |
||||
priority = in.readInt(); |
||||
tag = in.readString(); |
||||
message = in.readString(); |
||||
} |
||||
|
||||
public Integer getLogId() { |
||||
return logId; |
||||
} |
||||
|
||||
public Date getDateAndTime() { |
||||
return dateAndTime; |
||||
} |
||||
|
||||
public Integer getPriority() { |
||||
return priority; |
||||
} |
||||
|
||||
public String getTag() { |
||||
return tag; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
|
||||
public int describeContents() { |
||||
return 0; |
||||
} |
||||
|
||||
public void writeToParcel(Parcel out, int flags) { |
||||
out.writeInt(logId); |
||||
out.writeLong(dateAndTime.getTime()); |
||||
out.writeInt(priority); |
||||
out.writeString(tag); |
||||
out.writeString(message); |
||||
} |
||||
|
||||
} |
||||
|
@ -1,117 +1,124 @@
@@ -1,117 +1,124 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.navigation; |
||||
|
||||
import org.transdroid.R; |
||||
|
||||
import android.content.Context; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.ArrayAdapter; |
||||
import android.widget.Spinner; |
||||
import android.widget.TextView; |
||||
|
||||
import androidx.appcompat.widget.AppCompatSpinner; |
||||
|
||||
import org.transdroid.R; |
||||
|
||||
/** |
||||
* Spinner that holds actions that can be performed on list selections. The spinner itself has some title, which can for |
||||
* example be used to show the number of selected items. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class SelectionModificationSpinner extends Spinner { |
||||
|
||||
private SelectionDropDownAdapter selectionAdapter; |
||||
private OnModificationActionSelectedListener onModificationActionSelected = null; |
||||
|
||||
/** |
||||
* Instantiates a spinner that contains some fixed actions for a user to modify selections. |
||||
* @param context The interface context where the spinner will be shown in |
||||
*/ |
||||
public SelectionModificationSpinner(Context context) { |
||||
super(context); |
||||
selectionAdapter = new SelectionDropDownAdapter(context); |
||||
setAdapter(selectionAdapter); |
||||
} |
||||
|
||||
/** |
||||
* Updates the fixed title text shown in the spinner, regardless of spinner item action selection. |
||||
* @param title The new static string to show, such as the number of selected items |
||||
*/ |
||||
public void updateTitle(String title) { |
||||
selectionAdapter.titleView.setText(title); |
||||
invalidate(); |
||||
} |
||||
|
||||
/** |
||||
* Sets the listener for action selection events. |
||||
* @param onModificationActionSelected The listener that handles performing of the actions as selected in this |
||||
* spinner by the user |
||||
*/ |
||||
public void setOnModificationActionSelectedListener(OnModificationActionSelectedListener onModificationActionSelected) { |
||||
this.onModificationActionSelected = onModificationActionSelected; |
||||
} |
||||
|
||||
@Override |
||||
public void setSelection(int position) { |
||||
if (position == 0) { |
||||
onModificationActionSelected.selectAll(); |
||||
} else if (position == 1) { |
||||
onModificationActionSelected.selectFinished(); |
||||
} else if (position == 2) { |
||||
onModificationActionSelected.invertSelection(); |
||||
} |
||||
super.setSelection(position); |
||||
} |
||||
|
||||
/** |
||||
* Local adapter that holds the actions which can be performed and a title text view that always shows instead of a |
||||
* list item as in a normal spinner. |
||||
*/ |
||||
private class SelectionDropDownAdapter extends ArrayAdapter<String> { |
||||
|
||||
protected TextView titleView = null; |
||||
|
||||
public SelectionDropDownAdapter(Context context) { |
||||
super(context, android.R.layout.simple_list_item_1, new String[] { |
||||
context.getString(R.string.navigation_selectall), |
||||
context.getString(R.string.navigation_selectfinished), |
||||
context.getString(R.string.navigation_invertselection) }); |
||||
titleView = new TextView(getContext()); |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
// This returns the singleton text view showing the title with the number of selected items
|
||||
return titleView; |
||||
} |
||||
|
||||
@Override |
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) { |
||||
// This returns the actions to show in the spinner list
|
||||
return super.getView(position, convertView, parent); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Interface to implement if an interface want to respond to selection modification actions. |
||||
*/ |
||||
public interface OnModificationActionSelectedListener { |
||||
public void selectAll(); |
||||
public void selectFinished(); |
||||
public void invertSelection(); |
||||
} |
||||
public class SelectionModificationSpinner extends AppCompatSpinner { |
||||
|
||||
private SelectionDropDownAdapter selectionAdapter; |
||||
private OnModificationActionSelectedListener onModificationActionSelected = null; |
||||
|
||||
/** |
||||
* Instantiates a spinner that contains some fixed actions for a user to modify selections. |
||||
* |
||||
* @param context The interface context where the spinner will be shown in |
||||
*/ |
||||
public SelectionModificationSpinner(Context context) { |
||||
super(context); |
||||
selectionAdapter = new SelectionDropDownAdapter(context); |
||||
setAdapter(selectionAdapter); |
||||
} |
||||
|
||||
/** |
||||
* Updates the fixed title text shown in the spinner, regardless of spinner item action selection. |
||||
* |
||||
* @param title The new static string to show, such as the number of selected items |
||||
*/ |
||||
public void updateTitle(String title) { |
||||
selectionAdapter.titleView.setText(title); |
||||
invalidate(); |
||||
} |
||||
|
||||
/** |
||||
* Sets the listener for action selection events. |
||||
* |
||||
* @param onModificationActionSelected The listener that handles performing of the actions as selected in this |
||||
* spinner by the user |
||||
*/ |
||||
public void setOnModificationActionSelectedListener(OnModificationActionSelectedListener onModificationActionSelected) { |
||||
this.onModificationActionSelected = onModificationActionSelected; |
||||
} |
||||
|
||||
@Override |
||||
public void setSelection(int position) { |
||||
if (position == 0) { |
||||
onModificationActionSelected.selectAll(); |
||||
} else if (position == 1) { |
||||
onModificationActionSelected.selectFinished(); |
||||
} else if (position == 2) { |
||||
onModificationActionSelected.invertSelection(); |
||||
} |
||||
super.setSelection(position); |
||||
} |
||||
|
||||
/** |
||||
* Interface to implement if an interface want to respond to selection modification actions. |
||||
*/ |
||||
public interface OnModificationActionSelectedListener { |
||||
void selectAll(); |
||||
|
||||
void selectFinished(); |
||||
|
||||
void invertSelection(); |
||||
} |
||||
|
||||
/** |
||||
* Local adapter that holds the actions which can be performed and a title text view that always shows instead of a |
||||
* list item as in a normal spinner. |
||||
*/ |
||||
private static class SelectionDropDownAdapter extends ArrayAdapter<String> { |
||||
|
||||
protected TextView titleView = null; |
||||
|
||||
public SelectionDropDownAdapter(Context context) { |
||||
super(context, android.R.layout.simple_list_item_1, new String[]{ |
||||
context.getString(R.string.navigation_selectall), |
||||
context.getString(R.string.navigation_selectfinished), |
||||
context.getString(R.string.navigation_invertselection)}); |
||||
titleView = new TextView(getContext()); |
||||
} |
||||
|
||||
@Override |
||||
public View getView(int position, View convertView, ViewGroup parent) { |
||||
// This returns the singleton text view showing the title with the number of selected items
|
||||
return titleView; |
||||
} |
||||
|
||||
@Override |
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) { |
||||
// This returns the actions to show in the spinner list
|
||||
return super.getView(position, convertView, parent); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -1,165 +1,169 @@
@@ -1,165 +1,169 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.navigation; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
import android.content.Context; |
||||
import android.os.Parcel; |
||||
import android.os.Parcelable; |
||||
|
||||
import org.transdroid.R; |
||||
import org.transdroid.core.gui.lists.SimpleListItem; |
||||
import org.transdroid.daemon.Torrent; |
||||
|
||||
import android.content.Context; |
||||
import android.os.Parcel; |
||||
import android.os.Parcelable; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Enumeration of all status types, which filter the list of shown torrents based on transfer activity. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public enum StatusType { |
||||
|
||||
ShowAll { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.ShowAll, context.getString(R.string.navigation_status_showall)); |
||||
} |
||||
}, |
||||
OnlyDownloading { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.OnlyDownloading, context.getString(R.string.navigation_status_onlydown)); |
||||
} |
||||
}, |
||||
OnlyUploading { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.OnlyUploading, context.getString(R.string.navigation_status_onlyup)); |
||||
} |
||||
}, |
||||
OnlyActive { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.OnlyActive, context.getString(R.string.navigation_status_onlyactive)); |
||||
} |
||||
}, |
||||
OnlyInactive { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.OnlyInactive, context.getString(R.string.navigation_status_onlyinactive)); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* Returns the status type to show all torrents, represented as filter item to show in the navigation list. |
||||
* @param context The Android UI context, to access translations |
||||
* @return The show ShowAll status type filter item |
||||
*/ |
||||
public static StatusTypeFilter getShowAllType(Context context) { |
||||
return ShowAll.getFilterItem(context); |
||||
} |
||||
|
||||
/** |
||||
* Returns a list with all status types, represented as filter item that can be shown in the GUI. |
||||
* @param context The Android UI context, to access translations |
||||
* @return A list of filter items for all available status types |
||||
*/ |
||||
public static List<StatusTypeFilter> getAllStatusTypes(Context context) { |
||||
return Arrays.asList(ShowAll.getFilterItem(context), OnlyDownloading.getFilterItem(context), |
||||
OnlyUploading.getFilterItem(context), OnlyActive.getFilterItem(context), |
||||
OnlyInactive.getFilterItem(context)); |
||||
} |
||||
|
||||
/** |
||||
* Every status type can return a filter item that represents it in the navigation |
||||
* @param context The Android UI context, to access translations |
||||
* @return A filter item object to show in the GUI |
||||
*/ |
||||
public abstract StatusTypeFilter getFilterItem(Context context); |
||||
|
||||
public static class StatusTypeFilter implements SimpleListItem, NavigationFilter { |
||||
|
||||
private final StatusType statusType; |
||||
private final String name; |
||||
|
||||
StatusTypeFilter(StatusType statusType, String name) { |
||||
this.statusType = statusType; |
||||
this.name = name; |
||||
} |
||||
|
||||
public StatusType getStatusType() { |
||||
return statusType; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
@Override |
||||
public String getCode() { |
||||
// Uses the class name and status type enum to provide a unique navigation filter code
|
||||
return StatusTypeFilter.class.getSimpleName() + "_" + statusType.name(); |
||||
} |
||||
|
||||
/** |
||||
* Returns true if the torrent status matches this (selected) status type, false otherwise |
||||
* @param torrent The torrent to match against this status type |
||||
* @param dormantAsInactive If true, dormant (0KB/s, so no data transfer) torrents are never actively |
||||
* downloading or seeding |
||||
*/ |
||||
@Override |
||||
public boolean matches(Torrent torrent, boolean dormantAsInactive) { |
||||
switch (statusType) { |
||||
case OnlyDownloading: |
||||
return torrent.isDownloading(dormantAsInactive); |
||||
case OnlyUploading: |
||||
return torrent.isSeeding(dormantAsInactive); |
||||
case OnlyActive: |
||||
return torrent.isDownloading(dormantAsInactive) |
||||
|| torrent.isSeeding(dormantAsInactive); |
||||
case OnlyInactive: |
||||
return !torrent.isDownloading(dormantAsInactive) && !torrent.isSeeding(dormantAsInactive); |
||||
default: |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
private StatusTypeFilter(Parcel in) { |
||||
this.statusType = StatusType.valueOf(in.readString()); |
||||
this.name = in.readString(); |
||||
} |
||||
|
||||
public static final Parcelable.Creator<StatusTypeFilter> CREATOR = new Parcelable.Creator<StatusTypeFilter>() { |
||||
public StatusTypeFilter createFromParcel(Parcel in) { |
||||
return new StatusTypeFilter(in); |
||||
} |
||||
|
||||
public StatusTypeFilter[] newArray(int size) { |
||||
return new StatusTypeFilter[size]; |
||||
} |
||||
}; |
||||
|
||||
@Override |
||||
public int describeContents() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public void writeToParcel(Parcel dest, int flags) { |
||||
dest.writeString(statusType.name()); |
||||
dest.writeString(name); |
||||
} |
||||
|
||||
} |
||||
ShowAll { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.ShowAll, context.getString(R.string.navigation_status_showall)); |
||||
} |
||||
}, |
||||
OnlyDownloading { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.OnlyDownloading, context.getString(R.string.navigation_status_onlydown)); |
||||
} |
||||
}, |
||||
OnlyUploading { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.OnlyUploading, context.getString(R.string.navigation_status_onlyup)); |
||||
} |
||||
}, |
||||
OnlyActive { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.OnlyActive, context.getString(R.string.navigation_status_onlyactive)); |
||||
} |
||||
}, |
||||
OnlyInactive { |
||||
public StatusTypeFilter getFilterItem(Context context) { |
||||
return new StatusTypeFilter(StatusType.OnlyInactive, context.getString(R.string.navigation_status_onlyinactive)); |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* Returns the status type to show all torrents, represented as filter item to show in the navigation list. |
||||
* |
||||
* @param context The Android UI context, to access translations |
||||
* @return The show ShowAll status type filter item |
||||
*/ |
||||
public static StatusTypeFilter getShowAllType(Context context) { |
||||
return ShowAll.getFilterItem(context); |
||||
} |
||||
|
||||
/** |
||||
* Returns a list with all status types, represented as filter item that can be shown in the GUI. |
||||
* |
||||
* @param context The Android UI context, to access translations |
||||
* @return A list of filter items for all available status types |
||||
*/ |
||||
public static List<StatusTypeFilter> getAllStatusTypes(Context context) { |
||||
return Arrays.asList(ShowAll.getFilterItem(context), OnlyDownloading.getFilterItem(context), |
||||
OnlyUploading.getFilterItem(context), OnlyActive.getFilterItem(context), |
||||
OnlyInactive.getFilterItem(context)); |
||||
} |
||||
|
||||
/** |
||||
* Every status type can return a filter item that represents it in the navigation |
||||
* |
||||
* @param context The Android UI context, to access translations |
||||
* @return A filter item object to show in the GUI |
||||
*/ |
||||
public abstract StatusTypeFilter getFilterItem(Context context); |
||||
|
||||
public static class StatusTypeFilter implements SimpleListItem, NavigationFilter { |
||||
|
||||
public static final Parcelable.Creator<StatusTypeFilter> CREATOR = new Parcelable.Creator<StatusTypeFilter>() { |
||||
public StatusTypeFilter createFromParcel(Parcel in) { |
||||
return new StatusTypeFilter(in); |
||||
} |
||||
|
||||
public StatusTypeFilter[] newArray(int size) { |
||||
return new StatusTypeFilter[size]; |
||||
} |
||||
}; |
||||
private final StatusType statusType; |
||||
private final String name; |
||||
|
||||
StatusTypeFilter(StatusType statusType, String name) { |
||||
this.statusType = statusType; |
||||
this.name = name; |
||||
} |
||||
|
||||
private StatusTypeFilter(Parcel in) { |
||||
this.statusType = StatusType.valueOf(in.readString()); |
||||
this.name = in.readString(); |
||||
} |
||||
|
||||
public StatusType getStatusType() { |
||||
return statusType; |
||||
} |
||||
|
||||
@Override |
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
@Override |
||||
public String getCode() { |
||||
// Uses the class name and status type enum to provide a unique navigation filter code
|
||||
return StatusTypeFilter.class.getSimpleName() + "_" + statusType.name(); |
||||
} |
||||
|
||||
/** |
||||
* Returns true if the torrent status matches this (selected) status type, false otherwise |
||||
* |
||||
* @param torrent The torrent to match against this status type |
||||
* @param dormantAsInactive If true, dormant (0KB/s, so no data transfer) torrents are never actively |
||||
* downloading or seeding |
||||
*/ |
||||
@Override |
||||
public boolean matches(Torrent torrent, boolean dormantAsInactive) { |
||||
switch (statusType) { |
||||
case OnlyDownloading: |
||||
return torrent.isDownloading(dormantAsInactive); |
||||
case OnlyUploading: |
||||
return torrent.isSeeding(dormantAsInactive); |
||||
case OnlyActive: |
||||
return torrent.isDownloading(dormantAsInactive) |
||||
|| torrent.isSeeding(dormantAsInactive); |
||||
case OnlyInactive: |
||||
return !torrent.isDownloading(dormantAsInactive) && !torrent.isSeeding(dormantAsInactive); |
||||
default: |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public int describeContents() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
public void writeToParcel(Parcel dest, int flags) { |
||||
dest.writeString(statusType.name()); |
||||
dest.writeString(name); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
@ -1,69 +1,65 @@
@@ -1,69 +1,65 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.search; |
||||
|
||||
import org.transdroid.R; |
||||
|
||||
import android.annotation.SuppressLint; |
||||
import android.app.Activity; |
||||
import android.app.AlertDialog; |
||||
import android.content.Context; |
||||
import android.content.DialogInterface; |
||||
import android.content.DialogInterface.OnClickListener; |
||||
import android.content.Intent; |
||||
import android.net.Uri; |
||||
|
||||
import org.transdroid.R; |
||||
|
||||
import java.lang.ref.WeakReference; |
||||
|
||||
public class FilePickerHelper { |
||||
|
||||
public static final int ACTIVITY_FILEPICKER = 0x0000c0df; // A 'random' ID to identify file picker intents
|
||||
public static final Uri FILEMANAGER_MARKET_URI = Uri.parse("market://search?q=pname:org.openintents.filemanager"); |
||||
public static final int ACTIVITY_FILEPICKER = 0x0000c0df; // A 'random' ID to identify file picker intents
|
||||
public static final Uri FILEMANAGER_MARKET_URI = Uri.parse("market://search?q=pname:org.openintents.filemanager"); |
||||
|
||||
/** |
||||
* Call this to start a file picker intent. The calling activity will receive an Intent result with ID |
||||
* {@link #ACTIVITY_FILEPICKER} with an Intent that contains the selected local file as data Intent. |
||||
* @param activity The calling activity, to which the result is returned or a dialog is bound that asks to install |
||||
* the file picker |
||||
*/ |
||||
@SuppressLint("ValidFragment") |
||||
public static void startFilePicker(final Activity activity) { |
||||
try { |
||||
// Start a file manager that can handle the file/* file/* intents
|
||||
activity.startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).setType("application/x-bittorrent"), |
||||
ACTIVITY_FILEPICKER); |
||||
} catch (Exception e1) { |
||||
try { |
||||
// Start a file manager that can handle the PICK_FILE intent (specifically IO File Manager)
|
||||
activity.startActivityForResult(new Intent("org.openintents.action.PICK_FILE"), ACTIVITY_FILEPICKER); |
||||
} catch (Exception e2) { |
||||
// Can't start the file manager, for example with a SecurityException or when IO File Manager is not present
|
||||
final WeakReference<Context> intentStartContext = new WeakReference<Context>(activity); |
||||
new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert) |
||||
.setMessage(activity.getString(R.string.search_filemanagernotfound)) |
||||
.setPositiveButton(android.R.string.yes, new OnClickListener() { |
||||
@Override |
||||
public void onClick(DialogInterface dialog, int which) { |
||||
if (intentStartContext.get() != null) |
||||
intentStartContext.get().startActivity(new Intent(Intent.ACTION_VIEW, FILEMANAGER_MARKET_URI)); |
||||
} |
||||
}).setNegativeButton(android.R.string.no, null).show(); |
||||
} |
||||
} |
||||
} |
||||
/** |
||||
* Call this to start a file picker intent. The calling activity will receive an Intent result with ID |
||||
* {@link #ACTIVITY_FILEPICKER} with an Intent that contains the selected local file as data Intent. |
||||
* |
||||
* @param activity The calling activity, to which the result is returned or a dialog is bound that asks to install |
||||
* the file picker |
||||
*/ |
||||
@SuppressLint("ValidFragment") |
||||
public static void startFilePicker(final Activity activity) { |
||||
try { |
||||
// Start a file manager that can handle the file/* file/* intents
|
||||
activity.startActivityForResult(new Intent(Intent.ACTION_GET_CONTENT).setType("application/x-bittorrent"), |
||||
ACTIVITY_FILEPICKER); |
||||
} catch (Exception e1) { |
||||
try { |
||||
// Start a file manager that can handle the PICK_FILE intent (specifically IO File Manager)
|
||||
activity.startActivityForResult(new Intent("org.openintents.action.PICK_FILE"), ACTIVITY_FILEPICKER); |
||||
} catch (Exception e2) { |
||||
// Can't start the file manager, for example with a SecurityException or when IO File Manager is not present
|
||||
final WeakReference<Context> intentStartContext = new WeakReference<>(activity); |
||||
new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert) |
||||
.setMessage(activity.getString(R.string.search_filemanagernotfound)) |
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> { |
||||
if (intentStartContext.get() != null) |
||||
intentStartContext.get().startActivity(new Intent(Intent.ACTION_VIEW, FILEMANAGER_MARKET_URI)); |
||||
}).setNegativeButton(android.R.string.no, null).show(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -1,56 +1,57 @@
@@ -1,56 +1,57 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.search; |
||||
|
||||
import org.androidannotations.annotations.EViewGroup; |
||||
import org.androidannotations.annotations.ViewById; |
||||
import org.transdroid.R; |
||||
import org.transdroid.core.app.search.SearchResult; |
||||
|
||||
import android.content.Context; |
||||
import android.text.format.DateUtils; |
||||
import android.widget.RelativeLayout; |
||||
import android.widget.TextView; |
||||
|
||||
import org.androidannotations.annotations.EViewGroup; |
||||
import org.androidannotations.annotations.ViewById; |
||||
import org.transdroid.R; |
||||
import org.transdroid.core.app.search.SearchResult; |
||||
|
||||
/** |
||||
* View that represents a {@link SearchResult} object from an in-app search |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
@EViewGroup(resName = "list_item_searchresult") |
||||
public class SearchResultView extends RelativeLayout { |
||||
|
||||
// Views
|
||||
@ViewById |
||||
protected TextView nameText, seedersText, leechersText, sizeText, dateText; |
||||
// Views
|
||||
@ViewById |
||||
protected TextView nameText, seedersText, leechersText, sizeText, dateText; |
||||
|
||||
public SearchResultView(Context context) { |
||||
super(context); |
||||
} |
||||
public SearchResultView(Context context) { |
||||
super(context); |
||||
} |
||||
|
||||
public void bind(SearchResult result) { |
||||
public void bind(SearchResult result) { |
||||
|
||||
nameText.setText(result.getName()); |
||||
sizeText.setText(result.getSize()); |
||||
dateText.setText(result.getAddedOn() == null ? "" : DateUtils.getRelativeDateTimeString(getContext(), result |
||||
.getAddedOn().getTime(), DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, |
||||
DateUtils.FORMAT_ABBREV_MONTH)); |
||||
seedersText.setText(getContext().getString(R.string.search_seeders, result.getSeeders())); |
||||
leechersText.setText(getContext().getString(R.string.search_leechers, result.getLeechers())); |
||||
nameText.setText(result.getName()); |
||||
sizeText.setText(result.getSize()); |
||||
dateText.setText(result.getAddedOn() == null ? "" : DateUtils.getRelativeDateTimeString(getContext(), result |
||||
.getAddedOn().getTime(), DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, |
||||
DateUtils.FORMAT_ABBREV_MONTH)); |
||||
seedersText.setText(getContext().getString(R.string.search_seeders, result.getSeeders())); |
||||
leechersText.setText(getContext().getString(R.string.search_leechers, result.getLeechers())); |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
||||
|
@ -1,53 +1,54 @@
@@ -1,53 +1,54 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.settings; |
||||
|
||||
import org.transdroid.R; |
||||
import org.transdroid.core.gui.navigation.DialogHelper; |
||||
|
||||
import android.app.Activity; |
||||
import android.content.Intent; |
||||
import android.net.Uri; |
||||
|
||||
import org.transdroid.R; |
||||
import org.transdroid.core.gui.navigation.DialogHelper; |
||||
|
||||
/** |
||||
* Fragment that shows info about the application developer and used open source libraries. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class AboutDialog implements DialogHelper.DialogSpecification { |
||||
|
||||
private static final long serialVersionUID = -4711432869714292985L; |
||||
|
||||
@Override |
||||
public int getDialogLayoutId() { |
||||
return R.layout.dialog_about; |
||||
} |
||||
|
||||
@Override |
||||
public int getDialogMenuId() { |
||||
return R.menu.dialog_about; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onMenuItemSelected(Activity ownerActivity, int selectedItemId) { |
||||
if (selectedItemId == R.id.action_visitwebsite) { |
||||
ownerActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://transdroid.org"))); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
private static final long serialVersionUID = -4711432869714292985L; |
||||
|
||||
@Override |
||||
public int getDialogLayoutId() { |
||||
return R.layout.dialog_about; |
||||
} |
||||
|
||||
@Override |
||||
public int getDialogMenuId() { |
||||
return R.menu.dialog_about; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onMenuItemSelected(Activity ownerActivity, int selectedItemId) { |
||||
if (selectedItemId == R.id.action_visitwebsite) { |
||||
ownerActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://transdroid.org"))); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
||||
|
@ -1,53 +1,54 @@
@@ -1,53 +1,54 @@
|
||||
/* |
||||
/* |
||||
* Copyright 2010-2018 Eric Kok et al. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* Transdroid 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. |
||||
* |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
package org.transdroid.core.gui.settings; |
||||
|
||||
import org.transdroid.R; |
||||
import org.transdroid.core.gui.navigation.DialogHelper; |
||||
|
||||
import android.app.Activity; |
||||
import android.content.Intent; |
||||
import android.net.Uri; |
||||
|
||||
import org.transdroid.R; |
||||
import org.transdroid.core.gui.navigation.DialogHelper; |
||||
|
||||
/** |
||||
* Fragment that shows recent app changes. |
||||
* |
||||
* @author Eric Kok |
||||
*/ |
||||
public class ChangelogDialog implements DialogHelper.DialogSpecification { |
||||
|
||||
private static final long serialVersionUID = -4563410777022941124L; |
||||
|
||||
@Override |
||||
public int getDialogLayoutId() { |
||||
return R.layout.dialog_changelog; |
||||
} |
||||
|
||||
@Override |
||||
public int getDialogMenuId() { |
||||
return R.menu.dialog_about; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onMenuItemSelected(Activity ownerActivity, int selectedItemId) { |
||||
if (selectedItemId == R.id.action_visitwebsite) { |
||||
ownerActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://transdroid.org/about/changelog/"))); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
private static final long serialVersionUID = -4563410777022941124L; |
||||
|
||||
@Override |
||||
public int getDialogLayoutId() { |
||||
return R.layout.dialog_changelog; |
||||
} |
||||
|
||||
@Override |
||||
public int getDialogMenuId() { |
||||
return R.menu.dialog_about; |
||||
} |
||||
|
||||
@Override |
||||
public boolean onMenuItemSelected(Activity ownerActivity, int selectedItemId) { |
||||
if (selectedItemId == R.id.action_visitwebsite) { |
||||
ownerActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://transdroid.org/about/changelog/"))); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue