Browse Source

Java 8 migration

pull/559/head
TacoTheDank 4 years ago
parent
commit
2c7e36dfce
  1. 17
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java
  2. 7
      app/src/main/java/org/transdroid/core/gui/ServerPickerDialog.java
  3. 5
      app/src/main/java/org/transdroid/core/gui/ServerStatusView.java
  4. 13
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  5. 12
      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. 24
      app/src/main/java/org/transdroid/core/gui/navigation/SetLabelDialog.java
  10. 8
      app/src/main/java/org/transdroid/core/gui/navigation/SetStorageLocationDialog.java
  11. 7
      app/src/main/java/org/transdroid/core/gui/navigation/SetTrackersDialog.java
  12. 22
      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. 7
      app/src/main/java/org/transdroid/core/gui/search/BarcodeHelper.java
  16. 7
      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. 13
      app/src/main/java/org/transdroid/core/gui/search/UrlEntryDialog.java
  19. 15
      app/src/main/java/org/transdroid/core/gui/settings/HelpSettingsActivity.java
  20. 5
      app/src/main/java/org/transdroid/core/gui/settings/KeyBoundPreferencesActivity.java
  21. 62
      app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java
  22. 5
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedPreference.java
  23. 7
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java
  24. 5
      app/src/main/java/org/transdroid/core/gui/settings/ServerPreference.java
  25. 13
      app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  26. 28
      app/src/main/java/org/transdroid/core/gui/settings/SystemSettingsActivity.java
  27. 5
      app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java
  28. 7
      app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java
  29. 7
      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. 13
      app/src/main/java/org/transdroid/daemon/util/HttpHelper.java

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

@ -121,12 +121,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
// Show contextual action bar to start/stop/remove/etc. torrents in batch mode // Show contextual action bar to start/stop/remove/etc. torrents in batch mode
detailsMenu.setEnabled(false); detailsMenu.setEnabled(false);
contextualMenu.setVisibility(View.VISIBLE); contextualMenu.setVisibility(View.VISIBLE);
contextualMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() { contextualMenu.setOnMenuItemClickListener(menuItem -> onActionItemClicked(mode, menuItem));
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onActionItemClicked(mode, menuItem);
}
});
contextualMenu.getMenu().clear(); contextualMenu.getMenu().clear();
getActivity().getMenuInflater().inflate(R.menu.fragment_details_cab_main, contextualMenu.getMenu()); getActivity().getMenuInflater().inflate(R.menu.fragment_details_cab_main, contextualMenu.getMenu());
Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext(); Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext();
@ -301,12 +296,9 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
detailsList.setMultiChoiceModeListener(onDetailsSelected); detailsList.setMultiChoiceModeListener(onDetailsSelected);
detailsList.setFastScrollEnabled(true); detailsList.setFastScrollEnabled(true);
if (getActivity() != null && getActivity() instanceof RefreshableActivity) { if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { swipeRefreshLayout.setOnRefreshListener(() -> {
@Override
public void onRefresh() {
((RefreshableActivity) getActivity()).refreshScreen(); ((RefreshableActivity) getActivity()).refreshScreen();
swipeRefreshLayout.setRefreshing(false); // Use our custom indicator swipeRefreshLayout.setRefreshing(false); // Use our custom indicator
}
}); });
} }
@ -454,9 +446,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
public void createMenuOptions() { public void createMenuOptions() {
getActivity().getMenuInflater().inflate(R.menu.fragment_details, detailsMenu.getMenu()); getActivity().getMenuInflater().inflate(R.menu.fragment_details, detailsMenu.getMenu());
detailsMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() { detailsMenu.setOnMenuItemClickListener(menuItem -> {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case R.id.action_pause: case R.id.action_pause:
pauseTorrent(); pauseTorrent();
@ -502,7 +492,6 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
return true; return true;
} }
return false; return false;
}
}); });
} }

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

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

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

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

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

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

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

@ -130,12 +130,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
actionsToolbar.setEnabled(false); actionsToolbar.setEnabled(false);
actionsMenu.setVisibility(View.VISIBLE); actionsMenu.setVisibility(View.VISIBLE);
addmenuButton.setVisibility(View.GONE); addmenuButton.setVisibility(View.GONE);
actionsMenu.setOnMenuItemClickListener(new ActionMenuView.OnMenuItemClickListener() { actionsMenu.setOnMenuItemClickListener(menuItem -> onActionItemClicked(mode, menuItem));
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
return onActionItemClicked(mode, menuItem);
}
});
actionsMenu.getMenu().clear(); actionsMenu.getMenu().clear();
getActivity().getMenuInflater().inflate(R.menu.fragment_torrents_cab, actionsMenu.getMenu()); getActivity().getMenuInflater().inflate(R.menu.fragment_torrents_cab, actionsMenu.getMenu());
Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext(); Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext();
@ -256,12 +251,9 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
} }
// Allow pulls on the list view to refresh the torrents // Allow pulls on the list view to refresh the torrents
if (getActivity() != null && getActivity() instanceof RefreshableActivity) { if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { swipeRefreshLayout.setOnRefreshListener(() -> {
@Override
public void onRefresh() {
((RefreshableActivity) getActivity()).refreshScreen(); ((RefreshableActivity) getActivity()).refreshScreen();
swipeRefreshLayout.setRefreshing(false); // Use our custom indicator swipeRefreshLayout.setRefreshing(false); // Use our custom indicator
}
}); });
} }
nosettingsText.setText(getString(R.string.navigation_nosettings, getString(R.string.app_name))); 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;
import android.app.Application; import android.app.Application;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.evernote.android.job.JobConfig; import com.evernote.android.job.JobConfig;
import com.evernote.android.job.JobManager; import com.evernote.android.job.JobManager;
import com.evernote.android.job.util.JobLogger;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EApplication; import org.androidannotations.annotations.EApplication;
@ -41,12 +37,7 @@ public class TransdroidApp extends Application {
super.onCreate(); super.onCreate();
// Configure Android-Job // Configure Android-Job
JobConfig.addLogger(new JobLogger() { JobConfig.addLogger((priority, tag, message, t) -> log.d(tag, message));
@Override
public void log(int priority, @NonNull String tag, @NonNull String message, @Nullable Throwable t) {
log.d(tag, message);
}
});
JobManager.create(this).addJobCreator(new ScheduledJobCreator()); 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;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.app.settings.ServerSetting; import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.lists.MergeAdapter; 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.lists.ViewHolderAdapter;
import org.transdroid.core.gui.navigation.StatusType.StatusTypeFilter; 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;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.style.TypefaceSpan; import android.text.style.TypefaceSpan;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache; import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator; import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
@ -160,17 +158,12 @@ public class NavigationHelper {
return true; return true;
if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) { if (!ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
// Never asked again: show a dialog with an explanation // Never asked again: show a dialog with an explanation
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(() ->
public void run() { new MaterialDialog.Builder(context)
new MaterialDialog.Builder(context).content(R.string.permission_readtorrent).positiveText(android.R.string.ok) .content(R.string.permission_readtorrent)
.onPositive(new MaterialDialog.SingleButtonCallback() { .positiveText(android.R.string.ok)
@Override .onPositive((dialog, which) ->
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode)).show());
ActivityCompat.requestPermissions(activity, new String[]{permission}, requestCode);
}
}).show();
}
});
return false; return false;
} }
// Permission not granted (and we asked for it already before) // Permission not granted (and we asked for it already before)

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

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

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

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

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

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

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

@ -23,9 +23,6 @@ import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import org.transdroid.R; import org.transdroid.R;
@ -33,9 +30,7 @@ import org.transdroid.core.app.settings.SettingsUtils;
public class SetTransferRatesDialog { public class SetTransferRatesDialog {
private static OnClickListener onNumberClicked = new OnClickListener() { private static OnClickListener onNumberClicked = v -> {
@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 // Append the text contents of the button itself as text to the current number (as reference in the view's
// tag) // tag)
TextView numberView = (TextView) v.getTag(); TextView numberView = (TextView) v.getTag();
@ -43,7 +38,6 @@ public class SetTransferRatesDialog {
numberView.setText(""); numberView.setText("");
} }
numberView.setText(numberView.getText().toString() + ((Button) v).getText().toString()); numberView.setText(numberView.getText().toString() + ((Button) v).getText().toString());
}
}; };
/** /**
@ -63,9 +57,7 @@ public class SetTransferRatesDialog {
.positiveText(R.string.status_update) .positiveText(R.string.status_update)
.neutralText(R.string.status_maxspeed_reset) .neutralText(R.string.status_maxspeed_reset)
.negativeText(android.R.string.cancel) .negativeText(android.R.string.cancel)
.onPositive(new MaterialDialog.SingleButtonCallback() { .onPositive((dialog, which) -> {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
int maxDown = -1, maxUp = -1; int maxDown = -1, maxUp = -1;
try { try {
maxDown = Integer.parseInt(maxSpeedDown.getText().toString()); maxDown = Integer.parseInt(maxSpeedDown.getText().toString());
@ -78,14 +70,10 @@ public class SetTransferRatesDialog {
return; return;
} }
onRatesPickedListener.onRatesPicked(maxDown, maxUp); onRatesPickedListener.onRatesPicked(maxDown, maxUp);
}
}) })
.onNeutral(new MaterialDialog.SingleButtonCallback() { .onNeutral((dialog, which) ->
@Override onRatesPickedListener.resetRates());
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
onRatesPickedListener.resetRates();
}
});
MaterialDialog dialog = SettingsUtils.applyDialogTheme(builder).build(); 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, 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;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -301,12 +300,8 @@ public class RssFeedsActivity extends AppCompatActivity {
} }
// Sort by -newest // Sort by -newest
Collections.sort(recentItems, new Comparator<RemoteRssItem>() { Collections.sort(recentItems, (lhs, rhs) ->
@Override rhs.getTimestamp().compareTo(lhs.getTimestamp()));
public int compare(RemoteRssItem lhs, RemoteRssItem rhs) {
return rhs.getTimestamp().compareTo(lhs.getTimestamp());
}
});
} catch (DaemonException e) { } catch (DaemonException e) {
onCommunicationError(e); onCommunicationError(e);
return; return;

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

@ -21,7 +21,6 @@ import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.Item; import org.transdroid.core.rssparser.Item;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -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 // 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(); List<Item> items = channel.getItems();
// Reverse-order sort the items on their published date // Reverse-order sort the items on their published date
Collections.sort(items, new Comparator<Item>() { Collections.sort(items, (lhs, rhs) ->
@Override -lhs.getPubdate().compareTo(rhs.getPubdate()));
public int compare(Item lhs, Item rhs) {
return -lhs.getPubdate().compareTo(rhs.getPubdate());
}
});
for (Item item : items) { for (Item item : items) {
if (item.getPubdate() == null || setting.getLastViewed() == null || item.getPubdate().after(setting.getLastViewed())) { if (item.getPubdate() == null || setting.getLastViewed() == null || item.getPubdate().after(setting.getLastViewed())) {
newCount++; newCount++;

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

@ -20,8 +20,6 @@ import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
@ -76,12 +74,9 @@ public class BarcodeHelper {
final WeakReference<Context> intentStartContext = new WeakReference<>(activity); final WeakReference<Context> intentStartContext = new WeakReference<>(activity);
new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert) new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(activity.getString(R.string.search_barcodescannernotfound)) .setMessage(activity.getString(R.string.search_barcodescannernotfound))
.setPositiveButton(android.R.string.yes, new OnClickListener() { .setPositiveButton(android.R.string.yes, (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
if (intentStartContext.get() != null) if (intentStartContext.get() != null)
intentStartContext.get().startActivity(new Intent(Intent.ACTION_VIEW, SCANNER_MARKET_URI)); intentStartContext.get().startActivity(new Intent(Intent.ACTION_VIEW, SCANNER_MARKET_URI));
}
}).setNegativeButton(android.R.string.no, null).show(); }).setNegativeButton(android.R.string.no, null).show();
} }
} }

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

@ -20,8 +20,6 @@ import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
@ -56,12 +54,9 @@ public class FilePickerHelper {
final WeakReference<Context> intentStartContext = new WeakReference<>(activity); final WeakReference<Context> intentStartContext = new WeakReference<>(activity);
new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert) new AlertDialog.Builder(activity).setIcon(android.R.drawable.ic_dialog_alert)
.setMessage(activity.getString(R.string.search_filemanagernotfound)) .setMessage(activity.getString(R.string.search_filemanagernotfound))
.setPositiveButton(android.R.string.yes, new OnClickListener() { .setPositiveButton(android.R.string.yes, (dialog, which) -> {
@Override
public void onClick(DialogInterface dialog, int which) {
if (intentStartContext.get() != null) if (intentStartContext.get() != null)
intentStartContext.get().startActivity(new Intent(Intent.ACTION_VIEW, FILEMANAGER_MARKET_URI)); intentStartContext.get().startActivity(new Intent(Intent.ACTION_VIEW, FILEMANAGER_MARKET_URI));
}
}).setNegativeButton(android.R.string.no, null).show(); }).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 {
protected void init() { protected void init() {
searchToolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material); searchToolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material);
searchToolbar.setNavigationOnClickListener(new View.OnClickListener() { searchToolbar.setNavigationOnClickListener(v ->
@Override TorrentsActivity_.intent(SearchActivity.this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start());
public void onClick(View v) {
TorrentsActivity_.intent(SearchActivity.this).flags(Intent.FLAG_ACTIVITY_CLEAR_TOP).start();
}
});
setSupportActionBar(searchToolbar); setSupportActionBar(searchToolbar);
// Get the user query, as coming from the standard SearchManager // Get the user query, as coming from the standard SearchManager

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -19,7 +19,6 @@ package org.transdroid.core.service;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
@ -66,13 +65,8 @@ public class ConnectivityHelper {
.setTitle(R.string.pref_local_permission_title) .setTitle(R.string.pref_local_permission_title)
.setMessage(activity.getString(R.string.pref_local_permission_rationale, .setMessage(activity.getString(R.string.pref_local_permission_rationale,
activity.getString(R.string.app_name))) activity.getString(R.string.app_name)))
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, (dialog, which) -> ActivityCompat.requestPermissions(activity,
@Override new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION_PERMISSION))
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) .setNegativeButton(android.R.string.cancel, null)
.show(); .show();
} }

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

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

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

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

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

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

Loading…
Cancel
Save