Browse Source

Merge branch 'dev'

pull/506/head
Eric Kok 6 years ago
parent
commit
133aa177a0
  1. 20
      app/build.gradle
  2. 1
      app/proguard-rules.pro
  3. 4
      app/src/lite/res/values/strings.xml
  4. 5
      app/src/main/AndroidManifest.xml
  5. 11
      app/src/main/java/org/transdroid/core/gui/DetailsActivity.java
  6. 4
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java
  7. 18
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  8. 17
      app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java
  9. 5
      app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java
  10. 12
      app/src/main/java/org/transdroid/core/gui/lists/SortByListItem.java
  11. 2
      app/src/main/java/org/transdroid/core/gui/log/DatabaseHelper.java
  12. 47
      app/src/main/java/org/transdroid/core/gui/settings/InterceptableEditTextPreference.java
  13. 5
      app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java
  14. 30
      app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  15. 48
      app/src/main/java/org/transdroid/core/service/ConnectivityHelper.java
  16. 2
      app/src/main/java/org/transdroid/daemon/DummyAdapter.java
  17. 3
      app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java
  18. 6
      app/src/main/res/values/changelog.xml
  19. 6
      app/src/main/res/values/strings.xml
  20. 5
      app/src/main/res/xml/pref_server.xml
  21. 6
      build.gradle
  22. 1
      gradle.properties
  23. 2
      gradle/wrapper/gradle-wrapper.properties

20
app/build.gradle

@ -8,8 +8,8 @@ android { @@ -8,8 +8,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 234
versionName '2.5.14'
versionCode 235
versionName '2.5.15'
javaCompileOptions {
annotationProcessorOptions {
@ -36,9 +36,14 @@ android { @@ -36,9 +36,14 @@ android {
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
signingConfig signingConfigs.releaseConfig
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "version"
@ -60,12 +65,13 @@ android { @@ -60,12 +65,13 @@ android {
}
dependencies {
implementation 'org.androidannotations:androidannotations-api:4.5.2'
implementation 'org.androidannotations:ormlite-api:4.5.2'
implementation 'org.androidannotations:androidannotations-api:4.6.0'
implementation 'org.androidannotations:ormlite-api:4.6.0'
implementation 'com.j256.ormlite:ormlite-core:4.48'
implementation 'com.j256.ormlite:ormlite-android:4.48'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.getbase:floatingactionbutton:1.10.1'
implementation 'com.nispok:snackbar:2.11.0'
@ -74,7 +80,7 @@ dependencies { @@ -74,7 +80,7 @@ dependencies {
transitive = true
}
implementation 'com.evernote:android-job:1.2.6'
annotationProcessor 'org.androidannotations:androidannotations:4.5.2'
annotationProcessor 'org.androidannotations:ormlite:4.5.2'
annotationProcessor 'org.androidannotations:androidannotations:4.6.0'
annotationProcessor 'org.androidannotations:ormlite:4.6.0'
}

1
app/proguard-rules.pro vendored

@ -0,0 +1 @@ @@ -0,0 +1 @@
-dontobfuscate

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

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
<string name="app_name" translatable="false">Transdrone</string>
<string name="donate_text">Donate via transdroid.org</string>
<string name="donate_url">https://transdroid.org</string>
<string name="donate_text"></string>
<string name="donate_url"></string>
</resources>

5
app/src/main/AndroidManifest.xml

@ -29,10 +29,15 @@ @@ -29,10 +29,15 @@
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

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

@ -170,6 +170,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx @@ -170,6 +170,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
@Background
public void refreshTorrentDetails(Torrent torrent) {
if (currentConnection == null) return;
if (!Daemon.supportsFineDetails(torrent.getDaemon())) {
return;
}
@ -183,6 +184,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx @@ -183,6 +184,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
@Background
public void refreshTorrentFiles(Torrent torrent) {
if (currentConnection == null) return;
if (!Daemon.supportsFileListing(torrent.getDaemon())) {
return;
}
@ -197,6 +199,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx @@ -197,6 +199,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
@Background
@Override
public void resumeTorrent(Torrent torrent) {
if (currentConnection == null) return;
torrent.mimicResume();
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute(log);
if (result instanceof DaemonTaskSuccessResult) {
@ -333,14 +336,14 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx @@ -333,14 +336,14 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
@UiThread
protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) {
// Update the details fragment with the new fine details for the shown torrent
if (fragmentDetails.isAdded())
if (fragmentDetails.isResumed())
fragmentDetails.updateTorrentDetails(torrent, torrentDetails);
}
@UiThread
protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) {
// Update the details fragment with the newly retrieved list of files
if (fragmentDetails.isAdded())
if (fragmentDetails.isResumed())
fragmentDetails.updateTorrentFiles(torrent, new ArrayList<>(torrentFiles));
}
@ -348,7 +351,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx @@ -348,7 +351,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
protected void onCommunicationError(DaemonTaskFailureResult result, boolean isCritical) {
log.i(this, result.getException().toString());
String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
if (fragmentDetails.isAdded())
if (fragmentDetails.isResumed())
fragmentDetails.updateIsLoading(false, isCritical ? error : null);
SnackbarManager.show(Snackbar.with(this).text(getString(LocalTorrent.getResourceForDaemonException(result.getException())))
.colorResource(R.color.red));
@ -357,7 +360,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx @@ -357,7 +360,7 @@ public class DetailsActivity extends AppCompatActivity implements TorrentTasksEx
@UiThread
protected void onTorrentsRetrieved(List<Torrent> torrents, List<org.transdroid.daemon.Label> labels) {
// Update the details fragment accordingly
if (fragmentDetails.isAdded()) {
if (fragmentDetails.isResumed()) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.perhapsUpdateTorrent(torrents);
fragmentDetails.updateLabels(Label.convertToNavigationLabels(labels, getResources().getString(R.string.labels_unlabeled)));

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

@ -150,10 +150,10 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -150,10 +150,10 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
if (torrent != null) {
updateTorrent(torrent);
}
if (torrentDetails != null) {
if (torrent != null && torrentDetails != null) {
updateTorrentDetails(torrent, torrentDetails);
}
if (torrentFiles != null) {
if (torrent != null && torrentFiles != null) {
updateTorrentFiles(torrent, torrentFiles);
}

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

@ -566,7 +566,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -566,7 +566,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
// Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(true, true);
if (fragmentDetails != null && fragmentDetails.isAdded() && fragmentDetails.getActivity() != null) {
if (fragmentDetails != null && fragmentDetails.isResumed() && fragmentDetails.getActivity() != null) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear();
fragmentDetails.setCurrentServerSettings(server);
@ -586,7 +586,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -586,7 +586,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
// Remember that the user last selected this
applicationSettings.setLastUsedNavigationFilter(currentFilter);
// Clear the details view
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear();
}
@ -599,7 +599,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -599,7 +599,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
* @param hasServerSettings Whether there are server settings available, so we can continue to connect
*/
private void updateFragmentVisibility(boolean hasServerSettings) {
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
if (hasServerSettings) {
getFragmentManager().beginTransaction().show(fragmentDetails).commit();
} else {
@ -905,7 +905,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -905,7 +905,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
* @param torrent The torrent to show detailed statistics for
*/
public void openDetails(Torrent torrent) {
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
fragmentDetails.updateTorrent(torrent);
} else {
DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels).startForResult(RESULT_DETAILS);
@ -1296,7 +1296,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -1296,7 +1296,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
fragmentTorrents.updateIsLoading(false);
if (isCritical) {
fragmentTorrents.updateError(error);
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
fragmentDetails.updateIsLoading(false, error);
}
}
@ -1312,13 +1312,13 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -1312,13 +1312,13 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
fragmentTorrents.updateTorrents(new ArrayList<>(torrents), lastNavigationLabels);
// Update the details fragment if the currently shown torrent is in the newly retrieved list
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
fragmentDetails.perhapsUpdateTorrent(torrents);
}
// Update local list of labels in the navigation
navigationListAdapter.updateLabels(lastNavigationLabels);
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
fragmentDetails.updateLabels(lastNavigationLabels);
}
@ -1347,7 +1347,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -1347,7 +1347,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
@UiThread
protected void onTorrentDetailsRetrieved(Torrent torrent, TorrentDetails torrentDetails) {
// Update the details fragment with the new fine details for the shown torrent
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
fragmentDetails.updateTorrentDetails(torrent, torrentDetails);
}
}
@ -1355,7 +1355,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -1355,7 +1355,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
@UiThread
protected void onTorrentFilesRetrieved(Torrent torrent, List<TorrentFile> torrentFiles) {
// Update the details fragment with the newly retrieved list of files
if (fragmentDetails != null && fragmentDetails.isAdded()) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
fragmentDetails.updateTorrentFiles(torrent, new ArrayList<>(torrentFiles));
}
}

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

@ -74,8 +74,8 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -74,8 +74,8 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
protected ApplicationSettings applicationSettings;
@Bean
protected SystemSettings systemSettings;
@InstanceState
protected ArrayList<Torrent> torrents = null;
// HACK Working around #391 while hopefully we rework the UI in the future to persist the list in db or something
protected static ArrayList<Torrent> torrents = null;
@InstanceState
protected ArrayList<Torrent> lastMultiSelectedTorrents;
@InstanceState
@ -144,7 +144,8 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -144,7 +144,8 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
* @param newTorrents The new, updated list of torrents
*/
public void updateTorrents(ArrayList<Torrent> newTorrents, ArrayList<Label> currentLabels) {
this.torrents = newTorrents;
if (!isResumed()) return;
torrents = newTorrents;
this.currentLabels = currentLabels;
applyAllFilters();
}
@ -155,8 +156,9 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -155,8 +156,9 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
* @param wasRemoved Whether the affected torrent was indeed removed; otherwise it was updated somehow
*/
public void quickUpdateTorrent(Torrent affected, boolean wasRemoved) {
if (!isResumed()) return;
// Remove the old torrent object first
Iterator<Torrent> iter = this.torrents.iterator();
Iterator<Torrent> iter = torrents.iterator();
while (iter.hasNext()) {
Torrent torrent = iter.next();
if (torrent.getUniqueID().equals(affected.getUniqueID())) {
@ -166,7 +168,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -166,7 +168,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
}
// In case it was an update, add the updated torrent object
if (!wasRemoved) {
this.torrents.add(affected);
torrents.add(affected);
}
// Now refresh the screen
applyAllFilters();
@ -178,7 +180,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -178,7 +180,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
* @param clearFilter Also clear any selected filter
*/
public void clear(boolean clearError, boolean clearFilter) {
this.torrents = null;
torrents = null;
if (clearError) {
this.connectionErrorMessage = null;
}
@ -420,6 +422,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -420,6 +422,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
* @param hasAConnection True if the user has servers configured and therefore has a connection that can be used
*/
public void updateConnectionStatus(boolean hasAConnection, Daemon daemonType) {
if (!isResumed()) return;
this.hasAConnection = hasAConnection;
this.daemonType = daemonType;
if (!hasAConnection) {
@ -440,6 +443,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -440,6 +443,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
* @param isLoading True if the list of torrents is (re)loading, false otherwise
*/
public void updateIsLoading(boolean isLoading) {
if (!isResumed()) return;
this.isLoading = isLoading;
if (isLoading) {
clear(true, false); // Indirectly also calls updateViewVisibility()
@ -453,6 +457,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -453,6 +457,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
* @param connectionErrorMessage The error message from the last failed connection attempt, or null to clear the visible error text
*/
public void updateError(String connectionErrorMessage) {
if (!isResumed()) return;
this.connectionErrorMessage = connectionErrorMessage;
errorText.setText(connectionErrorMessage);
if (connectionErrorMessage != null) {

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

@ -50,6 +50,7 @@ public class LocalTorrent { @@ -50,6 +50,7 @@ public class LocalTorrent {
}
private static final String DECIMAL_FORMATTER = "%.1f";
private static final String DECIMAL_FORMATTER_2 = "%.2f";
/**
* Builds a string showing the upload/download seed ratio. If not downloading, it will base the ratio on the total
@ -63,11 +64,11 @@ public class LocalTorrent { @@ -63,11 +64,11 @@ public class LocalTorrent {
baseSize = t.getDownloadedEver();
}
if (baseSize <= 0) {
return String.format(Locale.getDefault(), DECIMAL_FORMATTER, 0d);
return String.format(Locale.getDefault(), DECIMAL_FORMATTER_2, 0d);
} else if (t.getRatio() == Double.POSITIVE_INFINITY) {
return "\u221E";
} else {
return String.format(Locale.getDefault(), DECIMAL_FORMATTER, t.getRatio());
return String.format(Locale.getDefault(), DECIMAL_FORMATTER_2, t.getRatio());
}
}

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

@ -16,11 +16,10 @@ @@ -16,11 +16,10 @@
*/
package org.transdroid.core.gui.lists;
import android.content.Context;
import org.transdroid.R;
import org.transdroid.daemon.TorrentsSortBy;
import android.content.Context;
/**
* Represents a way in which a torrents list can be sorted.
* @author Eric Kok
@ -48,6 +47,15 @@ public class SortByListItem implements SimpleListItem { @@ -48,6 +47,15 @@ public class SortByListItem implements SimpleListItem {
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;

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

@ -20,6 +20,7 @@ import java.sql.SQLException; @@ -20,6 +20,7 @@ import java.sql.SQLException;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.Keep;
import android.util.Log;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
@ -35,6 +36,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { @@ -35,6 +36,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
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);
}

47
app/src/main/java/org/transdroid/core/gui/settings/InterceptableEditTextPreference.java

@ -0,0 +1,47 @@ @@ -0,0 +1,47 @@
package org.transdroid.core.gui.settings;
import android.content.Context;
import android.os.Build;
import android.preference.EditTextPreference;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
public class InterceptableEditTextPreference extends EditTextPreference {
private OnPreferenceClickListener overrideClickListener = null;
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public InterceptableEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public InterceptableEditTextPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public InterceptableEditTextPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public InterceptableEditTextPreference(Context context) {
super(context);
}
@Override
public OnPreferenceClickListener getOnPreferenceClickListener() {
return overrideClickListener;
}
@Override
public void setOnPreferenceClickListener(OnPreferenceClickListener onPreferenceClickListener) {
this.overrideClickListener = onPreferenceClickListener;
}
@Override
protected void onClick() {
if (overrideClickListener == null || !overrideClickListener.onPreferenceClick(this)) {
super.onClick();
}
}
}

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

@ -178,6 +178,7 @@ public class MainSettingsActivity extends PreferenceCompatActivity { @@ -178,6 +178,7 @@ public class MainSettingsActivity extends PreferenceCompatActivity {
boolean enableSearchUi = navigationHelper.enableSearchUi();
boolean enableRssUi = navigationHelper.enableRssUi();
boolean enableDonateLink = !getString(R.string.donate_url).isEmpty();
// Load the preference menu and attach actions
addPreferencesFromResource(R.xml.pref_main);
@ -191,7 +192,11 @@ public class MainSettingsActivity extends PreferenceCompatActivity { @@ -191,7 +192,11 @@ public class MainSettingsActivity extends PreferenceCompatActivity {
findPreference("header_background").setOnPreferenceClickListener(onBackgroundSettings);
findPreference("header_system").setOnPreferenceClickListener(onSystemSettings);
findPreference("header_help").setOnPreferenceClickListener(onHelpSettings);
if (enableDonateLink) {
findPreference("header_donate").setOnPreferenceClickListener(onDonate);
} else {
getPreferenceScreen().removePreference(findPreference("header_donate"));
}
// Keep a list of the server codes and names (for default server selection)
List<String> serverCodes = new ArrayList<>();

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

@ -26,14 +26,16 @@ import android.content.SharedPreferences; @@ -26,14 +26,16 @@ import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.support.annotation.NonNull;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.transdroid.R;
import org.transdroid.core.app.settings.ApplicationSettings_;
import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.daemon.Daemon;
/**
@ -44,9 +46,12 @@ import org.transdroid.daemon.Daemon; @@ -44,9 +46,12 @@ import org.transdroid.daemon.Daemon;
@OptionsMenu(R.menu.activity_deleteableprefs)
public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
@Bean
protected ConnectivityHelper connectivityHelper;
private static final int DIALOG_CONFIRMREMOVE = 0;
private EditTextPreference extraPass, folder, downloadDir, excludeFilter, includeFilter;
private EditTextPreference extraPass, folder, downloadDir, excludeFilter, includeFilter, localNetworkPreference;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -63,7 +68,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { @@ -63,7 +68,7 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
initTextPreference("server_user");
initTextPreference("server_pass");
extraPass = initTextPreference("server_extrapass");
initTextPreference("server_localnetwork");
localNetworkPreference = initTextPreference("server_localnetwork");
initTextPreference("server_localaddress");
initTextPreference("server_localport");
folder = initTextPreference("server_folder");
@ -83,6 +88,16 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { @@ -83,6 +88,16 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
initTextPreference("server_ssltrustkey", null, "server_sslenabled");
onPreferencesChanged();
localNetworkPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(final Preference preference) {
if (!connectivityHelper.hasNetworkNamePermission(ServerSettingsActivity.this)) {
connectivityHelper.askNetworkNamePermission(ServerSettingsActivity.this);
return true;
}
return false;
}
});
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@ -113,6 +128,13 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { @@ -113,6 +128,13 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
return null;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (connectivityHelper.requestedPermissionWasGranted(requestCode, permissions, grantResults)) {
localNetworkPreference.getOnPreferenceClickListener().onPreferenceClick(localNetworkPreference);
}
}
@Override
protected void onPreferencesChanged() {

48
app/src/main/java/org/transdroid/core/service/ConnectivityHelper.java

@ -16,17 +16,26 @@ @@ -16,17 +16,26 @@
*/
package org.transdroid.core.service;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.SystemService;
import org.androidannotations.annotations.EBean.Scope;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.EBean.Scope;
import org.androidannotations.annotations.SystemService;
import org.transdroid.R;
@EBean(scope = Scope.Singleton)
public class ConnectivityHelper {
private static final int REQUEST_LOCATION_PERMISSION = 0;
@SystemService
protected ConnectivityManager connectivityManager;
@SystemService
@ -39,10 +48,39 @@ public class ConnectivityHelper { @@ -39,10 +48,39 @@ public class ConnectivityHelper {
}
public String getConnectedNetworkName() {
if (wifiManager.getConnectionInfo() != null && wifiManager.getConnectionInfo().getSSID() != null) {
if (wifiManager != null && wifiManager.getConnectionInfo() != null && wifiManager.getConnectionInfo().getSSID() != null) {
return wifiManager.getConnectionInfo().getSSID().replace("\"", "");
}
return null;
}
public boolean hasNetworkNamePermission(final Context activityContext) {
return ContextCompat.checkSelfPermission(activityContext, Manifest.permission.ACCESS_FINE_LOCATION) ==
PackageManager.PERMISSION_GRANTED;
}
public void askNetworkNamePermission(final Activity activity) {
new AlertDialog.Builder(activity)
.setTitle(R.string.pref_local_permission_title)
.setMessage(activity.getString(R.string.pref_local_permission_rationale,
activity.getString(R.string.app_name)))
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ActivityCompat.requestPermissions(activity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_PERMISSION);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
public boolean requestedPermissionWasGranted(int requestCode, String[] permissions, int[] grantResults) {
return (requestCode == REQUEST_LOCATION_PERMISSION
&& permissions != null
&& grantResults != null
&& permissions[0].equals(Manifest.permission.ACCESS_FINE_LOCATION)
&& grantResults[0] == PackageManager.PERMISSION_GRANTED);
}
}

2
app/src/main/java/org/transdroid/daemon/DummyAdapter.java

@ -80,7 +80,7 @@ public class DummyAdapter implements IDaemonAdapter { @@ -80,7 +80,7 @@ public class DummyAdapter implements IDaemonAdapter {
TorrentStatus.Paused, TorrentStatus.Queued, TorrentStatus.Downloading, TorrentStatus.Seeding,
TorrentStatus.Error };
Random random = new Random();
for (int i = 1; i < 26; i++) {
for (int i = 1; i < 2026; i++) {
String name = names[i % names.length] + Integer.toString(i);
TorrentStatus status = statuses[i % statuses.length];
int peersGetting = status == TorrentStatus.Downloading ? i * random.nextInt(16) : 0;

3
app/src/main/java/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java

@ -339,6 +339,9 @@ public class RtorrentAdapter implements IDaemonAdapter { @@ -339,6 +339,9 @@ public class RtorrentAdapter implements IDaemonAdapter {
log.d(LOG_NAME, "Calling " + serverMethod + " with params [" +
(params.length() > 100 ? params.substring(0, 100) + "..." : params) + " ]");
return rpcclient.call(serverMethod, arguments);
} catch (IllegalArgumentException e) {
log.d(LOG_NAME, "Using " + buildWebUIUrl() + ": " + e.toString());
throw new DaemonException(ExceptionType.ConnectionError, "Error making call to " + serverMethod);
} catch (XMLRPCException e) {
log.d(LOG_NAME, e.toString());
if (e.getCause() instanceof UnauthorizdException) {

6
app/src/main/res/values/changelog.xml

@ -17,6 +17,12 @@ @@ -17,6 +17,12 @@
-->
<resources>
<string name="system_changelog">
Transdroid 2.5.15\n
- Support local network config on Android 8.1+ by asking for location permission\n
- Hacky fix to prevent crashes on > 1000 torrents\n
- Fix crashes during background or config changes\n
- Removed donate link in Transdrone\n
\n
Transdroid 2.5.14\n
- Fix crashes in the UI here and there\n
- Fix notifications on Android 8+\n

6
app/src/main/res/values/strings.xml

@ -251,7 +251,7 @@ @@ -251,7 +251,7 @@
<string name="pref_reqauth">Requires authentication</string>
<string name="pref_reqauth_info">Opens links in the webbrowser for user login</string>
<string name="pref_alarmrssnew">New item notification</string>
<string name="pref_alarmrssnew_info">Nofity when new torrents are released</string>
<string name="pref_alarmrssnew_info">Notify when new torrents are released</string>
<string name="pref_alarmrssexclude">Exclude filter</string>
<string name="pref_alarmrssexclude_info">Don\'t show torrents whose name matches these |-separated words</string>
<string name="pref_alarmrssinclude">Include filter</string>
@ -270,6 +270,8 @@ @@ -270,6 +270,8 @@
<string name="pref_localport">Local port number</string>
<string name="pref_localnetwork">Local network</string>
<string name="pref_localnetwork_info">The server\'s local network SSID</string>
<string name="pref_local_permission_title">Location permission</string>
<string name="pref_local_permission_rationale">To known the connected Wifi network SSID name, %1$s requires the location permission</string>
<string name="pref_folder">Folder</string>
<string name="pref_folder_info">Usually empty</string>
<string name="pref_scgifolder">SCGI mount point</string>
@ -277,7 +279,7 @@ @@ -277,7 +279,7 @@
<string name="pref_alarmdone">Finished notification</string>
<string name="pref_alarmdone_info">Notify when a torrent finishes</string>
<string name="pref_alarmnew">New torrent notification</string>
<string name="pref_alarmnew_info">Nofity when a torrent was added</string>
<string name="pref_alarmnew_info">Notify when a torrent was added</string>
<string name="pref_alarmexclude">Exclude filter</string>
<string name="pref_alarmexclude_info">Notify only if torrent name matches these |-separated words</string>
<string name="pref_alarminclude">Include filter</string>

5
app/src/main/res/xml/pref_server.xml

@ -15,7 +15,8 @@ @@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<EditTextPreference
android:key="server_name"
@ -49,7 +50,7 @@ @@ -49,7 +50,7 @@
android:key="server_port"
android:title="@string/pref_port"
android:inputType="numberSigned" />
<EditTextPreference
<org.transdroid.core.gui.settings.InterceptableEditTextPreference
android:key="server_localnetwork"
android:title="@string/pref_localnetwork"
android:summary="@string/pref_localnetwork_info"

6
build.gradle

@ -1,18 +1,18 @@ @@ -1,18 +1,18 @@
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.2'
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
mavenLocal()
maven { url "https://jitpack.io" }
}
}

1
gradle.properties

@ -16,3 +16,4 @@ @@ -16,3 +16,4 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.enableR8=true

2
gradle/wrapper/gradle-wrapper.properties vendored

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

Loading…
Cancel
Save