Browse Source

Java 8 migration

pull/559/head
TacoTheDank 4 years ago
parent
commit
2c7e36dfce
  1. 109
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java
  2. 11
      app/src/main/java/org/transdroid/core/gui/ServerPickerDialog.java
  3. 5
      app/src/main/java/org/transdroid/core/gui/ServerStatusView.java
  4. 21
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  5. 16
      app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java
  6. 11
      app/src/main/java/org/transdroid/core/gui/TransdroidApp.java
  7. 1
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListAdapter.java
  8. 19
      app/src/main/java/org/transdroid/core/gui/navigation/NavigationHelper.java
  9. 38
      app/src/main/java/org/transdroid/core/gui/navigation/SetLabelDialog.java
  10. 12
      app/src/main/java/org/transdroid/core/gui/navigation/SetStorageLocationDialog.java
  11. 11
      app/src/main/java/org/transdroid/core/gui/navigation/SetTrackersDialog.java
  12. 56
      app/src/main/java/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java
  13. 9
      app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java
  14. 9
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java
  15. 11
      app/src/main/java/org/transdroid/core/gui/search/BarcodeHelper.java
  16. 11
      app/src/main/java/org/transdroid/core/gui/search/FilePickerHelper.java
  17. 8
      app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java
  18. 29
      app/src/main/java/org/transdroid/core/gui/search/UrlEntryDialog.java
  19. 27
      app/src/main/java/org/transdroid/core/gui/settings/HelpSettingsActivity.java
  20. 9
      app/src/main/java/org/transdroid/core/gui/settings/KeyBoundPreferencesActivity.java
  21. 102
      app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java
  22. 11
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedPreference.java
  23. 11
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java
  24. 11
      app/src/main/java/org/transdroid/core/gui/settings/ServerPreference.java
  25. 25
      app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  26. 46
      app/src/main/java/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  27. 11
      app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java
  28. 11
      app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java
  29. 13
      app/src/main/java/org/transdroid/core/seedbox/SeedboxPreference.java
  30. 10
      app/src/main/java/org/transdroid/core/service/ConnectivityHelper.java
  31. 7
      app/src/main/java/org/transdroid/core/widget/ListWidgetConfigActivity.java
  32. 9
      app/src/main/java/org/transdroid/daemon/adapters/uTorrent/UTorrentAdapter.java
  33. 35
      app/src/main/java/org/transdroid/daemon/util/HttpHelper.java

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

@ -121,12 +121,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -121,12 +121,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
// Show contextual action bar to start/stop/remove/etc. torrents in batch mode
detailsMenu.setEnabled(false);
contextualMenu.setVisibility(View.VISIBLE);
contextualMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onActionItemClicked(mode, menuItem);
}
});
contextualMenu.setOnMenuItemClickListener(menuItem -> onActionItemClicked(mode, menuItem));
contextualMenu.getMenu().clear();
getActivity().getMenuInflater().inflate(R.menu.fragment_details_cab_main, contextualMenu.getMenu());
Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext();
@ -301,12 +296,9 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -301,12 +296,9 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
detailsList.setMultiChoiceModeListener(onDetailsSelected);
detailsList.setFastScrollEnabled(true);
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
((RefreshableActivity) getActivity()).refreshScreen();
swipeRefreshLayout.setRefreshing(false); // Use our custom indicator
}
swipeRefreshLayout.setOnRefreshListener(() -> {
((RefreshableActivity) getActivity()).refreshScreen();
swipeRefreshLayout.setRefreshing(false); // Use our custom indicator
});
}
@ -454,55 +446,52 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -454,55 +446,52 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
public void createMenuOptions() {
getActivity().getMenuInflater().inflate(R.menu.fragment_details, detailsMenu.getMenu());
detailsMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.action_pause:
pauseTorrent();
return true;
case R.id.action_updatetrackers:
updateTrackers();
return true;
case R.id.action_start_forced:
startTorrentForced();
return true;
case R.id.action_remove_withdata:
removeTorrentWithData();
return true;
case R.id.action_stop:
stopTorrent();
return true;
case R.id.action_toggle_sequential:
toggleSequentialDownload(menuItem);
return true;
case R.id.action_toggle_firstlastpiece:
toggleFirstLastPieceDownload(menuItem);
return true;
case R.id.action_forcerecheck:
setForceRecheck();
return true;
case R.id.action_changelocation:
changeStorageLocation();
return true;
case R.id.action_start_default:
startTorrentDefault();
return true;
case R.id.action_remove_default:
removeTorrentDefault();
return true;
case R.id.action_start_direct:
startTorrentDirect();
return true;
case R.id.action_setlabel:
setLabel();
return true;
case R.id.action_resume:
resumeTorrent();
return true;
}
return false;
detailsMenu.setOnMenuItemClickListener(menuItem -> {
switch (menuItem.getItemId()) {
case R.id.action_pause:
pauseTorrent();
return true;
case R.id.action_updatetrackers:
updateTrackers();
return true;
case R.id.action_start_forced:
startTorrentForced();
return true;
case R.id.action_remove_withdata:
removeTorrentWithData();
return true;
case R.id.action_stop:
stopTorrent();
return true;
case R.id.action_toggle_sequential:
toggleSequentialDownload(menuItem);
return true;
case R.id.action_toggle_firstlastpiece:
toggleFirstLastPieceDownload(menuItem);
return true;
case R.id.action_forcerecheck:
setForceRecheck();
return true;
case R.id.action_changelocation:
changeStorageLocation();
return true;
case R.id.action_start_default:
startTorrentDefault();
return true;
case R.id.action_remove_default:
removeTorrentDefault();
return true;
case R.id.action_start_direct:
startTorrentDirect();
return true;
case R.id.action_setlabel:
setLabel();
return true;
case R.id.action_resume:
resumeTorrent();
return true;
}
return false;
});
}

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

@ -18,8 +18,6 @@ package org.transdroid.core.gui; @@ -18,8 +18,6 @@ package org.transdroid.core.gui;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import androidx.fragment.app.DialogFragment;
@ -55,12 +53,9 @@ public class ServerPickerDialog extends DialogFragment { @@ -55,12 +53,9 @@ public class ServerPickerDialog extends DialogFragment {
public Dialog onCreateDialog(Bundle savedInstanceState) {
String[] serverNames = getArguments().getStringArray("serverNames");
return new AlertDialog.Builder(getActivity()).setTitle(R.string.navigation_pickserver)
.setItems(serverNames, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (getActivity() != null && getActivity() instanceof TorrentsActivity)
((TorrentsActivity) getActivity()).switchServerAndAddFromIntent(which);
}
.setItems(serverNames, (dialog, which) -> {
if (getActivity() != null && getActivity() instanceof TorrentsActivity)
((TorrentsActivity) getActivity()).switchServerAndAddFromIntent(which);
}).create();
}

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

@ -42,11 +42,8 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis @@ -42,11 +42,8 @@ public class ServerStatusView extends RelativeLayout implements OnRatesPickedLis
@ViewById
protected View speedswrapperLayout;
private TorrentsActivity activity;
private OnClickListener onStartDownPickerClicked = new OnClickListener() {
public void onClick(View v) {
private OnClickListener onStartDownPickerClicked = v ->
SetTransferRatesDialog.show(getContext(), ServerStatusView.this);
}
};
public ServerStatusView(Context context) {
super(context);

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

@ -27,7 +27,6 @@ import android.os.Bundle; @@ -27,7 +27,6 @@ import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@ -270,13 +269,8 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -270,13 +269,8 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
torrentsToolbar.addView(serverSelectionView);
}
actionsToolbar.addView(serverStatusView);
actionsToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
// Redirect to the classic activity implementation so we can use @OptionsItem methods
return onOptionsItemSelected(menuItem);
}
});
// Redirect to the classic activity implementation so we can use @OptionsItem methods
actionsToolbar.setOnMenuItemClickListener(this::onOptionsItemSelected);
setSupportActionBar(torrentsToolbar); // For direct menu item inflation by the contained fragments
getSupportActionBar().setDisplayShowTitleEnabled(false);
@ -458,13 +452,10 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -458,13 +452,10 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
SearchView searchView = new SearchView(torrentsToolbar.getContext());
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true);
searchView.setOnSearchClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Pause autorefresh
stopRefresh = true;
stopAutoRefresh();
}
searchView.setOnSearchClickListener(v -> {
// Pause autorefresh
stopRefresh = true;
stopAutoRefresh();
});
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override

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

@ -130,12 +130,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -130,12 +130,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
actionsToolbar.setEnabled(false);
actionsMenu.setVisibility(View.VISIBLE);
addmenuButton.setVisibility(View.GONE);
actionsMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onActionItemClicked(mode, menuItem);
}
});
actionsMenu.setOnMenuItemClickListener(menuItem -> onActionItemClicked(mode, menuItem));
actionsMenu.getMenu().clear();
getActivity().getMenuInflater().inflate(R.menu.fragment_torrents_cab, actionsMenu.getMenu());
Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext();
@ -256,12 +251,9 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -256,12 +251,9 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
}
// Allow pulls on the list view to refresh the torrents
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
((RefreshableActivity) getActivity()).refreshScreen();
swipeRefreshLayout.setRefreshing(false); // Use our custom indicator
}
swipeRefreshLayout.setOnRefreshListener(() -> {
((RefreshableActivity) getActivity()).refreshScreen();
swipeRefreshLayout.setRefreshing(false); // Use our custom indicator
});
}
nosettingsText.setText(getString(R.string.navigation_nosettings, getString(R.string.app_name)));

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

@ -18,12 +18,8 @@ package org.transdroid.core.gui; @@ -18,12 +18,8 @@ package org.transdroid.core.gui;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.evernote.android.job.JobConfig;
import com.evernote.android.job.JobManager;
import com.evernote.android.job.util.JobLogger;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EApplication;
@ -41,12 +37,7 @@ public class TransdroidApp extends Application { @@ -41,12 +37,7 @@ public class TransdroidApp extends Application {
super.onCreate();
// Configure Android-Job
JobConfig.addLogger(new JobLogger() {
@Override
public void log(int priority, @NonNull String tag, @NonNull String message, @Nullable Throwable t) {
log.d(tag, message);
}
});
JobConfig.addLogger((priority, tag, message, t) -> log.d(tag, message));
JobManager.create(this).addJobCreator(new ScheduledJobCreator());
}

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

@ -24,7 +24,6 @@ import org.androidannotations.annotations.RootContext; @@ -24,7 +24,6 @@ import org.androidannotations.annotations.RootContext;
import org.transdroid.R;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.lists.MergeAdapter;
import org.transdroid.core.gui.lists.SimpleListItem;
import org.transdroid.core.gui.lists.ViewHolderAdapter;
import org.transdroid.core.gui.navigation.StatusType.StatusTypeFilter;

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

@ -30,11 +30,9 @@ import android.text.Spannable; @@ -30,11 +30,9 @@ import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.TypefaceSpan;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
@ -160,17 +158,12 @@ public class NavigationHelper { @@ -160,17 +158,12 @@ public class NavigationHelper {
return true;
if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// Never asked again: show a dialog with an explanation
activity.runOnUiThread(new Runnable() {
public void run() {
new MaterialDialog.Builder(context).content(R.string.permission_readtorrent).positiveText(android.R.string.ok)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
}
}).show();
}
});
activity.runOnUiThread(() ->
new MaterialDialog.Builder(context)
.content(R.string.permission_readtorrent)
.positiveText(android.R.string.ok)
.onPositive((dialog, which) ->
ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode)).show());
return false;
}
// Permission not granted (and we asked for it already before)

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

@ -20,14 +20,9 @@ import android.content.Context; @@ -20,14 +20,9 @@ import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.EditText;
import android.widget.ListView;
import androidx.annotation.NonNull;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;
@ -65,23 +60,17 @@ public class SetLabelDialog { @@ -65,23 +60,17 @@ public class SetLabelDialog {
.positiveText(R.string.status_update)
.neutralText(R.string.status_label_remove)
.negativeText(android.R.string.cancel)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
// User should have provided a new label
if (TextUtils.isEmpty(newLabelEdit.getText())) {
SnackbarManager.show(Snackbar.with(context).text(R.string.error_notalabel).colorResource(R.color.red));
return;
}
onLabelPickedListener.onLabelPicked(newLabelEdit.getText().toString());
.onPositive((dialog, which) -> {
// User should have provided a new label
if (TextUtils.isEmpty(newLabelEdit.getText())) {
SnackbarManager.show(Snackbar.with(context).text(R.string.error_notalabel).colorResource(R.color.red));
return;
}
onLabelPickedListener.onLabelPicked(newLabelEdit.getText().toString());
})
.onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
onLabelPickedListener.onLabelPicked(null);
}
});
.onNeutral((dialog, which) ->
onLabelPickedListener.onLabelPicked(null));
final MaterialDialog dialog = SettingsUtils
.applyDialogTheme(builder)
.build();
@ -92,12 +81,9 @@ public class SetLabelDialog { @@ -92,12 +81,9 @@ public class SetLabelDialog {
labelsList.setVisibility(View.GONE);
} else {
labelsList.setAdapter(new FilterListItemAdapter(context, currentLabels));
labelsList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
onLabelPickedListener.onLabelPicked(((Label) labelsList.getItemAtPosition(position)).getName());
dialog.dismiss();
}
labelsList.setOnItemClickListener((parent, view, position, id) -> {
onLabelPickedListener.onLabelPicked(((Label) labelsList.getItemAtPosition(position)).getName());
dialog.dismiss();
});
}

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

@ -21,9 +21,6 @@ import android.view.LayoutInflater; @@ -21,9 +21,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import androidx.annotation.NonNull;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R;
@ -46,12 +43,9 @@ public class SetStorageLocationDialog { @@ -46,12 +43,9 @@ public class SetStorageLocationDialog {
.customView(locationLayout, false)
.positiveText(R.string.status_update)
.negativeText(android.R.string.cancel)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
// User is done editing and requested to update given the text input
onStorageLocationUpdatedListener.onStorageLocationUpdated(locationText.getText().toString());
}
.onPositive((dialog, which) -> {
// User is done editing and requested to update given the text input
onStorageLocationUpdatedListener.onStorageLocationUpdated(locationText.getText().toString());
});
SettingsUtils

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

@ -21,10 +21,8 @@ import android.view.LayoutInflater; @@ -21,10 +21,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R;
@ -50,12 +48,9 @@ public class SetTrackersDialog extends DialogFragment { @@ -50,12 +48,9 @@ public class SetTrackersDialog extends DialogFragment {
.customView(trackersLayout, false)
.positiveText(R.string.status_update)
.negativeText(android.R.string.cancel)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
// User is done editing and requested to update given the text input
onTrackersUpdatedListener.onTrackersUpdated(Arrays.asList(trackersText.getText().toString().split("\n")));
}
.onPositive((dialog, which) -> {
// User is done editing and requested to update given the text input
onTrackersUpdatedListener.onTrackersUpdated(Arrays.asList(trackersText.getText().toString().split("\n")));
});
SettingsUtils.applyDialogTheme(builder).show();
}

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

@ -23,9 +23,6 @@ import android.view.View.OnClickListener; @@ -23,9 +23,6 @@ import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R;
@ -33,17 +30,14 @@ import org.transdroid.core.app.settings.SettingsUtils; @@ -33,17 +30,14 @@ import org.transdroid.core.app.settings.SettingsUtils;
public class SetTransferRatesDialog {
private static OnClickListener onNumberClicked = new OnClickListener() {
@Override
public void onClick(View v) {
// Append the text contents of the button itself as text to the current number (as reference in the view's
// tag)
TextView numberView = (TextView) v.getTag();
if (numberView.getText().toString().equals(v.getContext().getString(R.string.status_maxspeed_novalue))) {
numberView.setText("");
}
numberView.setText(numberView.getText().toString() + ((Button) v).getText().toString());
private static OnClickListener onNumberClicked = v -> {
// Append the text contents of the button itself as text to the current number (as reference in the view's
// tag)
TextView numberView = (TextView) v.getTag();
if (numberView.getText().toString().equals(v.getContext().getString(R.string.status_maxspeed_novalue))) {
numberView.setText("");
}
numberView.setText(numberView.getText().toString() + ((Button) v).getText().toString());
};
/**
@ -63,29 +57,23 @@ public class SetTransferRatesDialog { @@ -63,29 +57,23 @@ public class SetTransferRatesDialog {
.positiveText(R.string.status_update)
.neutralText(R.string.status_maxspeed_reset)
.negativeText(android.R.string.cancel)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
int maxDown = -1, maxUp = -1;
try {
maxDown = Integer.parseInt(maxSpeedDown.getText().toString());
maxUp = Integer.parseInt(maxSpeedUp.getText().toString());
} catch (NumberFormatException e) {
// Impossible as we only input via the number buttons
}
if (maxDown <= 0 || maxUp <= 0) {
onRatesPickedListener.onInvalidNumber();
return;
}
onRatesPickedListener.onRatesPicked(maxDown, maxUp);
.onPositive((dialog, which) -> {
int maxDown = -1, maxUp = -1;
try {
maxDown = Integer.parseInt(maxSpeedDown.getText().toString());
maxUp = Integer.parseInt(maxSpeedUp.getText().toString());
} catch (NumberFormatException e) {
// Impossible as we only input via the number buttons
}
})
.onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
onRatesPickedListener.resetRates();
if (maxDown <= 0 || maxUp <= 0) {
onRatesPickedListener.onInvalidNumber();
return;
}
});
onRatesPickedListener.onRatesPicked(maxDown, maxUp);
})
.onNeutral((dialog, which) ->
onRatesPickedListener.resetRates());
MaterialDialog dialog = SettingsUtils.applyDialogTheme(builder).build();
bindButtons(dialog.getCustomView(), maxSpeedDown, R.id.down1Button, R.id.down2Button, R.id.down3Button, R.id.down4Button, R.id.down5Button,

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

@ -72,7 +72,6 @@ import org.transdroid.daemon.task.DaemonTaskSuccessResult; @@ -72,7 +72,6 @@ import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@ -301,12 +300,8 @@ public class RssFeedsActivity extends AppCompatActivity { @@ -301,12 +300,8 @@ public class RssFeedsActivity extends AppCompatActivity {
}
// Sort by -newest
Collections.sort(recentItems, new Comparator<RemoteRssItem>() {
@Override
public int compare(RemoteRssItem lhs, RemoteRssItem rhs) {
return rhs.getTimestamp().compareTo(lhs.getTimestamp());
}
});
Collections.sort(recentItems, (lhs, rhs) ->
rhs.getTimestamp().compareTo(lhs.getTimestamp()));
} catch (DaemonException e) {
onCommunicationError(e);
return;

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

@ -21,7 +21,6 @@ import org.transdroid.core.rssparser.Channel; @@ -21,7 +21,6 @@ import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.Item;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@ -61,12 +60,8 @@ public class RssfeedLoader { @@ -61,12 +60,8 @@ public class RssfeedLoader {
// Count the number of new items, based on the date that this RSS feed was last viewed by the user
List<Item> items = channel.getItems();
// Reverse-order sort the items on their published date
Collections.sort(items, new Comparator<Item>() {
@Override
public int compare(Item lhs, Item rhs) {
return -lhs.getPubdate().compareTo(rhs.getPubdate());
}
});
Collections.sort(items, (lhs, rhs) ->
-lhs.getPubdate().compareTo(rhs.getPubdate()));
for (Item item : items) {
if (item.getPubdate() == null || setting.getLastViewed() == null || item.getPubdate().after(setting.getLastViewed())) {
newCount++;

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

@ -20,8 +20,6 @@ import android.annotation.SuppressLint; @@ -20,8 +20,6 @@ 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;
@ -76,12 +74,9 @@ public class BarcodeHelper { @@ -76,12 +74,9 @@ public class BarcodeHelper {
final WeakReference<Context> intentStartContext = new WeakReference<>(activity);
new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(activity.getString(R.string.search_barcodescannernotfound))
.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, SCANNER_MARKET_URI));
}
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
if (intentStartContext.get() != null)
intentStartContext.get().startActivity(new Intent(Intent.ACTION_VIEW, SCANNER_MARKET_URI));
}).setNegativeButton(android.R.string.no, null).show();
}
}

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

@ -20,8 +20,6 @@ import android.annotation.SuppressLint; @@ -20,8 +20,6 @@ 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;
@ -56,12 +54,9 @@ public class FilePickerHelper { @@ -56,12 +54,9 @@ public class FilePickerHelper {
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, 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));
}
.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();
}
}

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

@ -116,12 +116,8 @@ public class SearchActivity extends AppCompatActivity { @@ -116,12 +116,8 @@ public class SearchActivity extends AppCompatActivity {
protected void init() {
searchToolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
searchToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TorrentsActivity_.intent(SearchActivity.this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
});
searchToolbar.setNavigationOnClickListener(v ->
TorrentsActivity_.intent(SearchActivity.this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start());
setSupportActionBar(searchToolbar);
// Get the user query, as coming from the standard SearchManager

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

@ -24,9 +24,6 @@ import android.view.LayoutInflater; @@ -24,9 +24,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import androidx.annotation.NonNull;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R;
@ -49,19 +46,19 @@ public class UrlEntryDialog { @@ -49,19 +46,19 @@ public class UrlEntryDialog {
CharSequence content = clipboard.getPrimaryClip().getItemAt(0).coerceToText(activity);
urlEdit.setText(content);
}
new MaterialDialog.Builder(activity).customView(inputLayout, false).positiveText(android.R.string.ok).negativeText(android.R.string.cancel)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
String url = urlEdit.getText().toString();
Uri uri = Uri.parse(url);
if (!TextUtils.isEmpty(url)) {
String title = NavigationHelper.extractNameFromUri(uri);
if (uri.getScheme() != null && uri.getScheme().equals("magnet")) {
activity.addTorrentByMagnetUrl(url, title);
} else {
activity.addTorrentByUrl(url, title);
}
new MaterialDialog.Builder(activity)
.customView(inputLayout, false)
.positiveText(android.R.string.ok)
.negativeText(android.R.string.cancel)
.onPositive((dialog, which) -> {
String url = urlEdit.getText().toString();
Uri uri = Uri.parse(url);
if (!TextUtils.isEmpty(url)) {
String title = NavigationHelper.extractNameFromUri(uri);
if (uri.getScheme() != null && uri.getScheme().equals("magnet")) {
activity.addTorrentByMagnetUrl(url, title);
} else {
activity.addTorrentByUrl(url, title);
}
}
}).show();

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

@ -58,26 +58,17 @@ public class HelpSettingsActivity extends PreferenceCompatActivity { @@ -58,26 +58,17 @@ public class HelpSettingsActivity extends PreferenceCompatActivity {
return true;
}
};
private OnPreferenceClickListener onInstallHelpClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(INSTALLHELP_URI)));
return true;
}
private OnPreferenceClickListener onInstallHelpClick = preference -> {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(INSTALLHELP_URI)));
return true;
};
private OnPreferenceClickListener onChangeLogClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_CHANGELOG);
return true;
}
private OnPreferenceClickListener onChangeLogClick = preference -> {
showDialog(DIALOG_CHANGELOG);
return true;
};
private OnPreferenceClickListener onAboutClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_ABOUT);
return true;
}
private OnPreferenceClickListener onAboutClick = preference -> {
showDialog(DIALOG_ABOUT);
return true;
};
@Override

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

@ -51,12 +51,9 @@ public abstract class KeyBoundPreferencesActivity extends PreferenceCompatActivi @@ -51,12 +51,9 @@ public abstract class KeyBoundPreferencesActivity extends PreferenceCompatActivi
private SharedPreferences sharedPrefs;
private Map<String, String> originalSummaries = new HashMap<>();
private OnSharedPreferenceChangeListener onPreferenceChangeListener = new OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
showValueOnSummary(key);
onPreferencesChanged();
}
private OnSharedPreferenceChangeListener onPreferenceChangeListener = (sharedPreferences, key) -> {
showValueOnSummary(key);
onPreferencesChanged();
};
/**

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

@ -19,7 +19,6 @@ package org.transdroid.core.gui.settings; @@ -19,7 +19,6 @@ package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
@ -80,83 +79,44 @@ public class MainSettingsActivity extends PreferenceCompatActivity { @@ -80,83 +79,44 @@ public class MainSettingsActivity extends PreferenceCompatActivity {
return true;
}
};
private OnPreferenceClickListener onAddWebsearch = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
WebsearchSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
}
private OnPreferenceClickListener onAddWebsearch = preference -> {
WebsearchSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
};
private OnPreferenceClickListener onAddRssfeed = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
RssfeedSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
}
private OnPreferenceClickListener onAddRssfeed = preference -> {
RssfeedSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
};
private OnPreferenceClickListener onBackgroundSettings = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
NotificationSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
}
private OnPreferenceClickListener onBackgroundSettings = preference -> {
NotificationSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
};
private OnPreferenceClickListener onSystemSettings = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SystemSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
}
private OnPreferenceClickListener onSystemSettings = preference -> {
SystemSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
};
private OnPreferenceClickListener onHelpSettings = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
HelpSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
}
private OnPreferenceClickListener onHelpSettings = preference -> {
HelpSettingsActivity_.intent(MainSettingsActivity.this).start();
return true;
};
private OnPreferenceClickListener onDonate = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.donate_url))));
return true;
}
};
private OnServerClickedListener onServerClicked = new OnServerClickedListener() {
@Override
public void onServerClicked(ServerSetting serverSetting) {
ServerSettingsActivity_.intent(MainSettingsActivity.this).key(serverSetting.getOrder()).start();
}
private OnPreferenceClickListener onDonate = preference -> {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.donate_url))));
return true;
};
private OnSeedboxClickedListener onSeedboxClicked = new OnSeedboxClickedListener() {
@Override
public void onSeedboxClicked(ServerSetting serverSetting, SeedboxProvider provider, int seedboxOffset) {
// NOTE: The seedboxOffset is the seedbox type-unique order that we need to supply uin the Extras bundle to
// edit this specific seedbox
startActivity(provider.getSettings().getSettingsActivityIntent(MainSettingsActivity.this).putExtra("key", seedboxOffset));
}
private OnServerClickedListener onServerClicked = serverSetting -> ServerSettingsActivity_.intent(MainSettingsActivity.this).key(serverSetting.getOrder()).start();
private OnSeedboxClickedListener onSeedboxClicked = (serverSetting, provider, seedboxOffset) -> {
// NOTE: The seedboxOffset is the seedbox type-unique order that we need to supply uin the Extras bundle to
// edit this specific seedbox
startActivity(provider.getSettings().getSettingsActivityIntent(MainSettingsActivity.this).putExtra("key", seedboxOffset));
};
private OnWebsearchClickedListener onWebsearchClicked = new OnWebsearchClickedListener() {
@Override
public void onWebsearchClicked(WebsearchSetting websearchSetting) {
WebsearchSettingsActivity_.intent(MainSettingsActivity.this).key(websearchSetting.getOrder()).start();
}
};
private OnRssfeedClickedListener onRssfeedClicked = new OnRssfeedClickedListener() {
@Override
public void onRssfeedClicked(RssfeedSetting rssfeedSetting) {
RssfeedSettingsActivity_.intent(MainSettingsActivity.this).key(rssfeedSetting.getOrder()).start();
}
};
private OnClickListener onAddSeedbox = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Start the configuration activity for this specific chosen seedbox
if (which == 0)
ServerSettingsActivity_.intent(MainSettingsActivity.this).start();
else
startActivity(SeedboxProvider.values()[which - 1].getSettings().getSettingsActivityIntent(MainSettingsActivity.this));
}
private OnWebsearchClickedListener onWebsearchClicked = websearchSetting -> WebsearchSettingsActivity_.intent(MainSettingsActivity.this).key(websearchSetting.getOrder()).start();
private OnRssfeedClickedListener onRssfeedClicked = rssfeedSetting -> RssfeedSettingsActivity_.intent(MainSettingsActivity.this).key(rssfeedSetting.getOrder()).start();
private OnClickListener onAddSeedbox = (dialog, which) -> {
// Start the configuration activity for this specific chosen seedbox
if (which == 0)
ServerSettingsActivity_.intent(MainSettingsActivity.this).start();
else
startActivity(SeedboxProvider.values()[which - 1].getSettings().getSettingsActivityIntent(MainSettingsActivity.this));
};
@Override

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

@ -36,13 +36,10 @@ public class RssfeedPreference extends Preference { @@ -36,13 +36,10 @@ public class RssfeedPreference extends Preference {
public RssfeedPreference(Context context) {
super(context);
OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onRssfeedClickedListener != null)
onRssfeedClickedListener.onRssfeedClicked(rssfeedSetting);
return true;
}
OnPreferenceClickListener onPreferenceClicked = preference -> {
if (onRssfeedClickedListener != null)
onRssfeedClickedListener.onRssfeedClicked(rssfeedSetting);
return true;
};
setOnPreferenceClickListener(onPreferenceClicked);
setIconSpaceReserved(false);

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

@ -19,8 +19,6 @@ package org.transdroid.core.gui.settings; @@ -19,8 +19,6 @@ package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
@ -76,12 +74,9 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity { @@ -76,12 +74,9 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity {
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_CONFIRMREMOVE) {
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(RssfeedSettingsActivity.this).removeRssfeedSettings(key);
finish();
}
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
ApplicationSettings_.getInstance_(RssfeedSettingsActivity.this).removeRssfeedSettings(key);
finish();
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;

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

@ -36,13 +36,10 @@ public class ServerPreference extends Preference { @@ -36,13 +36,10 @@ public class ServerPreference extends Preference {
public ServerPreference(Context context) {
super(context);
OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onServerClickedListener != null)
onServerClickedListener.onServerClicked(serverSetting);
return true;
}
OnPreferenceClickListener onPreferenceClicked = preference -> {
if (onServerClickedListener != null)
onServerClickedListener.onServerClicked(serverSetting);
return true;
};
setOnPreferenceClickListener(onPreferenceClicked);
setIconSpaceReserved(false);

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

@ -19,8 +19,6 @@ package org.transdroid.core.gui.settings; @@ -19,8 +19,6 @@ package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
@ -28,7 +26,6 @@ import android.os.Bundle; @@ -28,7 +26,6 @@ import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.preference.EditTextPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceManager;
import org.androidannotations.annotations.Bean;
@ -89,15 +86,12 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { @@ -89,15 +86,12 @@ 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;
localNetworkPreference.setOnPreferenceClickListener(preference -> {
if (!connectivityHelper.hasNetworkNamePermission(ServerSettingsActivity.this)) {
connectivityHelper.askNetworkNamePermission(ServerSettingsActivity.this);
return true;
}
return false;
});
}
@ -116,12 +110,9 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { @@ -116,12 +110,9 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_CONFIRMREMOVE) {
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(ServerSettingsActivity.this).removeNormalServerSettings(key);
finish();
}
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
ApplicationSettings_.getInstance_(ServerSettingsActivity.this).removeNormalServerSettings(key);
finish();
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;

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

@ -28,7 +28,6 @@ import android.os.Bundle; @@ -28,7 +28,6 @@ import android.os.Bundle;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceClickListener;
import androidx.preference.PreferenceManager;
@ -69,34 +68,22 @@ public class SystemSettingsActivity extends PreferenceCompatActivity { @@ -69,34 +68,22 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
protected ErrorLogSender errorLogSender;
@Bean
protected SettingsPersistence settingsPersistence;
private OnPreferenceClickListener onImportSettingsClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_IMPORTSETTINGS);
return true;
}
private OnPreferenceClickListener onImportSettingsClick = preference -> {
showDialog(DIALOG_IMPORTSETTINGS);
return true;
};
private OnPreferenceClickListener onExportSettingsClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(DIALOG_EXPORTSETTINGS);
return true;
}
private OnPreferenceClickListener onExportSettingsClick = preference -> {
showDialog(DIALOG_EXPORTSETTINGS);
return true;
};
private OnPreferenceClickListener onCheckUpdatesClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
AppUpdateJob.schedule(getApplicationContext());
return true;
}
private OnPreferenceClickListener onCheckUpdatesClick = preference -> {
AppUpdateJob.schedule(getApplicationContext());
return true;
};
private OnPreferenceClickListener onClearSearchClick = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
SearchHistoryProvider.clearHistory(getApplicationContext());
SnackbarManager.show(Snackbar.with(SystemSettingsActivity.this).text(R.string.pref_clearsearch_success));
return true;
}
private OnPreferenceClickListener onClearSearchClick = preference -> {
SearchHistoryProvider.clearHistory(getApplicationContext());
SnackbarManager.show(Snackbar.with(SystemSettingsActivity.this).text(R.string.pref_clearsearch_success));
return true;
};
private OnClickListener importSettingsFromFile = new OnClickListener() {
@Override
@ -108,12 +95,9 @@ public class SystemSettingsActivity extends PreferenceCompatActivity { @@ -108,12 +95,9 @@ public class SystemSettingsActivity extends PreferenceCompatActivity {
}
};
private OnClickListener importSettingsFromQr = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
private OnClickListener importSettingsFromQr = (dialog, which) ->
BarcodeHelper.startBarcodeScanner(SystemSettingsActivity.this, BarcodeHelper.ACTIVITY_BARCODE_QRSETTINGS);
}
};
private OnClickListener exportSettingsToFile = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {

11
app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java

@ -36,13 +36,10 @@ public class WebsearchPreference extends Preference { @@ -36,13 +36,10 @@ public class WebsearchPreference extends Preference {
public WebsearchPreference(Context context) {
super(context);
OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onWebsearchClickedListener != null)
onWebsearchClickedListener.onWebsearchClicked(websearchSetting);
return true;
}
OnPreferenceClickListener onPreferenceClicked = preference -> {
if (onWebsearchClickedListener != null)
onWebsearchClickedListener.onWebsearchClicked(websearchSetting);
return true;
};
setOnPreferenceClickListener(onPreferenceClicked);
setIconSpaceReserved(false);

11
app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java

@ -19,8 +19,6 @@ package org.transdroid.core.gui.settings; @@ -19,8 +19,6 @@ package org.transdroid.core.gui.settings;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
@ -72,12 +70,9 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity { @@ -72,12 +70,9 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity {
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_CONFIRMREMOVE) {
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(WebsearchSettingsActivity.this).removeWebsearchSettings(key);
finish();
}
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
ApplicationSettings_.getInstance_(WebsearchSettingsActivity.this).removeWebsearchSettings(key);
finish();
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;

13
app/src/main/java/org/transdroid/core/seedbox/SeedboxPreference.java

@ -18,8 +18,6 @@ package org.transdroid.core.seedbox; @@ -18,8 +18,6 @@ package org.transdroid.core.seedbox;
import android.content.Context;
import androidx.preference.Preference;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.settings.ServerPreference;
@ -36,13 +34,10 @@ public class SeedboxPreference extends ServerPreference { @@ -36,13 +34,10 @@ public class SeedboxPreference extends ServerPreference {
public SeedboxPreference(Context context) {
super(context);
OnPreferenceClickListener onSeedboxPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onSeedboxClickedListener != null)
onSeedboxClickedListener.onSeedboxClicked(serverSetting, provider, onSeedboxClickedListenerOffset);
return true;
}
OnPreferenceClickListener onSeedboxPreferenceClicked = preference -> {
if (onSeedboxClickedListener != null)
onSeedboxClickedListener.onSeedboxClicked(serverSetting, provider, onSeedboxClickedListenerOffset);
return true;
};
setOnPreferenceClickListener(onSeedboxPreferenceClicked);
}

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

@ -19,7 +19,6 @@ package org.transdroid.core.service; @@ -19,7 +19,6 @@ package org.transdroid.core.service;
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;
@ -66,13 +65,8 @@ public class ConnectivityHelper { @@ -66,13 +65,8 @@ public class ConnectivityHelper {
.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);
}
})
.setPositiveButton(android.R.string.ok, (dialog, which) -> ActivityCompat.requestPermissions(activity,
new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_PERMISSION))
.setNegativeButton(android.R.string.cancel, null)
.show();
}

7
app/src/main/java/org/transdroid/core/widget/ListWidgetConfigActivity.java

@ -100,12 +100,7 @@ public class ListWidgetConfigActivity extends AppCompatActivity { @@ -100,12 +100,7 @@ public class ListWidgetConfigActivity extends AppCompatActivity {
}
};
private List<Torrent> previewTorrents = null;
protected OnCheckedChangeListener reverseorderCheckedChanged = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
filterTorrents();
}
};
protected OnCheckedChangeListener reverseorderCheckedChanged = (buttonView, isChecked) -> filterTorrents();
private int appWidgetId;
private OnClickListener doneClicked = new OnClickListener() {
@Override

9
app/src/main/java/org/transdroid/daemon/adapters/uTorrent/UTorrentAdapter.java

@ -74,7 +74,6 @@ import java.net.URI; @@ -74,7 +74,6 @@ import java.net.URI;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@ -339,12 +338,8 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier { @@ -339,12 +338,8 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier {
}
}
Collections.sort(remoteRssChannels, new Comparator<RemoteRssChannel>() {
@Override
public int compare(RemoteRssChannel lhs, RemoteRssChannel rhs) {
return lhs.getName().compareToIgnoreCase(rhs.getName());
}
});
Collections.sort(remoteRssChannels, (lhs, rhs) ->
lhs.getName().compareToIgnoreCase(rhs.getName()));
}
private ArrayList<Label> parseJsonRetrieveGetLabels(JSONArray lresults) throws JSONException {

35
app/src/main/java/org/transdroid/daemon/util/HttpHelper.java

@ -22,10 +22,7 @@ import android.net.Uri; @@ -22,10 +22,7 @@ import android.net.Uri;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
@ -40,7 +37,6 @@ import org.apache.http.params.BasicHttpParams; @@ -40,7 +37,6 @@ import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HttpContext;
import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.DaemonException.ExceptionType;
import org.transdroid.daemon.DaemonSettings;
@ -71,32 +67,27 @@ public class HttpHelper { @@ -71,32 +67,27 @@ public class HttpHelper {
/**
* HTTP request interceptor to allow for GZip-encoded data transfer
*/
public static HttpRequestInterceptor gzipRequestInterceptor = new HttpRequestInterceptor() {
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
if (!request.containsHeader("Accept-Encoding")) {
request.addHeader("Accept-Encoding", "gzip");
}
public static HttpRequestInterceptor gzipRequestInterceptor = (request, context) -> {
if (!request.containsHeader("Accept-Encoding")) {
request.addHeader("Accept-Encoding", "gzip");
}
};
/**
* HTTP response interceptor that decodes GZipped data
*/
public static HttpResponseInterceptor gzipResponseInterceptor = new HttpResponseInterceptor() {
public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
HttpEntity entity = response.getEntity();
Header ceheader = entity.getContentEncoding();
if (ceheader != null) {
HeaderElement[] codecs = ceheader.getElements();
for (HeaderElement codec : codecs) {
if (codec.getName().equalsIgnoreCase("gzip")) {
response.setEntity(new GzipDecompressingEntity(response.getEntity()));
return;
}
public static HttpResponseInterceptor gzipResponseInterceptor = (response, context) -> {
HttpEntity entity = response.getEntity();
Header ceheader = entity.getContentEncoding();
if (ceheader != null) {
HeaderElement[] codecs = ceheader.getElements();
for (HeaderElement codec : codecs) {
if (codec.getName().equalsIgnoreCase("gzip")) {
response.setEntity(new GzipDecompressingEntity(response.getEntity()));
return;
}
}
}
};
/**

Loading…
Cancel
Save