Browse Source

Fix a bunch of deprecations

pull/559/head
TacoTheDank 4 years ago
parent
commit
7566d9b233
  1. 2
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java
  2. 5
      app/src/main/java/org/transdroid/core/gui/ServerPickerDialog.java
  3. 11
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  4. 2
      app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java
  5. 12
      app/src/main/java/org/transdroid/core/gui/navigation/SetLabelDialog.java
  6. 7
      app/src/main/java/org/transdroid/core/gui/navigation/SetStorageLocationDialog.java
  7. 9
      app/src/main/java/org/transdroid/core/gui/navigation/SetTrackersDialog.java
  8. 12
      app/src/main/java/org/transdroid/core/gui/navigation/SetTransferRatesDialog.java
  9. 7
      app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java
  10. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchResultsFragment.java
  11. 7
      app/src/main/java/org/transdroid/core/gui/search/UrlEntryDialog.java
  12. 8
      app/src/main/java/org/transdroid/core/service/AppUpdateJobRunner.java

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

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
package org.transdroid.core.gui;
import android.annotation.SuppressLint;
import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
@ -34,6 +33,7 @@ import android.widget.TextView; @@ -34,6 +33,7 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.ActionMenuView;
import androidx.fragment.app.Fragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.nispok.snackbar.Snackbar;

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

@ -18,11 +18,12 @@ package org.transdroid.core.gui; @@ -18,11 +18,12 @@ package org.transdroid.core.gui;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import androidx.fragment.app.DialogFragment;
import org.transdroid.R;
import org.transdroid.core.app.settings.ServerSetting;
@ -47,7 +48,7 @@ public class ServerPickerDialog extends DialogFragment { @@ -47,7 +48,7 @@ public class ServerPickerDialog extends DialogFragment {
Bundle arguments = new Bundle();
arguments.putStringArray("serverNames", serverNames);
dialog.setArguments(arguments);
dialog.show(activity.getFragmentManager(), "serverpicker");
dialog.show(activity.getSupportFragmentManager(), "serverpicker");
}
@Override

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

@ -39,7 +39,6 @@ import androidx.appcompat.app.AppCompatActivity; @@ -39,7 +39,6 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.MenuItemCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import com.getbase.floatingactionbutton.FloatingActionButton;
@ -296,7 +295,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -296,7 +295,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
drawerToggle =
new ActionBarDrawerToggle(this, drawerLayout, torrentsToolbar, R.string.navigation_opendrawer, R.string.navigation_closedrawer);
drawerToggle.setDrawerIndicatorEnabled(true);
drawerLayout.setDrawerListener(drawerToggle);
drawerLayout.addDrawerListener(drawerToggle);
}
navigationList.setAdapter(navigationListAdapter);
navigationList.setOnItemClickListener(onFilterListItemClicked);
@ -467,7 +466,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -467,7 +466,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
stopAutoRefresh();
}
});
MenuItemCompat.setOnActionExpandListener(item, new MenuItemCompat.OnActionExpandListener() {
item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
@ -480,7 +479,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -480,7 +479,7 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
return true;
}
});
MenuItemCompat.setActionView(item, searchView);
item.setActionView(searchView);
searchMenu = item;
}
return true;
@ -619,9 +618,9 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE @@ -619,9 +618,9 @@ public class TorrentsActivity extends AppCompatActivity implements TorrentTasksE
private void updateFragmentVisibility(boolean hasServerSettings) {
if (fragmentDetails != null && fragmentDetails.isResumed()) {
if (hasServerSettings) {
getFragmentManager().beginTransaction().show(fragmentDetails).commit();
getSupportFragmentManager().beginTransaction().show(fragmentDetails).commit();
} else {
getFragmentManager().beginTransaction().hide(fragmentDetails).commit();
getSupportFragmentManager().beginTransaction().hide(fragmentDetails).commit();
}
}
invalidateOptionsMenu();

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

@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
*/
package org.transdroid.core.gui;
import android.app.Fragment;
import android.content.Context;
import android.view.ActionMode;
import android.view.Menu;
@ -30,6 +29,7 @@ import android.widget.TextView; @@ -30,6 +29,7 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.getbase.floatingactionbutton.FloatingActionsMenu;

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

@ -25,6 +25,9 @@ import android.widget.AdapterView.OnItemClickListener; @@ -25,6 +25,9 @@ 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;
@ -62,9 +65,9 @@ public class SetLabelDialog { @@ -62,9 +65,9 @@ public class SetLabelDialog {
.positiveText(R.string.status_update)
.neutralText(R.string.status_label_remove)
.negativeText(android.R.string.cancel)
.callback(new MaterialDialog.ButtonCallback() {
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
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));
@ -72,9 +75,10 @@ public class SetLabelDialog { @@ -72,9 +75,10 @@ public class SetLabelDialog {
}
onLabelPickedListener.onLabelPicked(newLabelEdit.getText().toString());
}
})
.onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onNeutral(MaterialDialog dialog) {
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
onLabelPickedListener.onLabelPicked(null);
}
});

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

@ -21,6 +21,9 @@ import android.view.LayoutInflater; @@ -21,6 +21,9 @@ 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;
@ -43,9 +46,9 @@ public class SetStorageLocationDialog { @@ -43,9 +46,9 @@ public class SetStorageLocationDialog {
.customView(locationLayout, false)
.positiveText(R.string.status_update)
.negativeText(android.R.string.cancel)
.callback(new MaterialDialog.ButtonCallback() {
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
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());
}

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

@ -16,12 +16,15 @@ @@ -16,12 +16,15 @@
*/
package org.transdroid.core.gui.navigation;
import android.app.DialogFragment;
import android.content.Context;
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;
@ -47,9 +50,9 @@ public class SetTrackersDialog extends DialogFragment { @@ -47,9 +50,9 @@ public class SetTrackersDialog extends DialogFragment {
.customView(trackersLayout, false)
.positiveText(R.string.status_update)
.negativeText(android.R.string.cancel)
.callback(new MaterialDialog.ButtonCallback() {
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
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")));
}

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

@ -23,6 +23,9 @@ import android.view.View.OnClickListener; @@ -23,6 +23,9 @@ 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;
@ -60,9 +63,9 @@ public class SetTransferRatesDialog { @@ -60,9 +63,9 @@ public class SetTransferRatesDialog {
.positiveText(R.string.status_update)
.neutralText(R.string.status_maxspeed_reset)
.negativeText(android.R.string.cancel)
.callback(new MaterialDialog.ButtonCallback() {
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
int maxDown = -1, maxUp = -1;
try {
maxDown = Integer.parseInt(maxSpeedDown.getText().toString());
@ -76,9 +79,10 @@ public class SetTransferRatesDialog { @@ -76,9 +79,10 @@ public class SetTransferRatesDialog {
}
onRatesPickedListener.onRatesPicked(maxDown, maxUp);
}
})
.onNeutral(new MaterialDialog.SingleButtonCallback() {
@Override
public void onNeutral(MaterialDialog dialog) {
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
onRatesPickedListener.resetRates();
}
});

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

@ -35,7 +35,6 @@ import android.widget.TextView; @@ -35,7 +35,6 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.MenuItemCompat;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Bean;
@ -193,7 +192,7 @@ public class SearchActivity extends AppCompatActivity { @@ -193,7 +192,7 @@ public class SearchActivity extends AppCompatActivity {
searchView.setQueryRefinementEnabled(true);
searchView.setIconified(false);
searchView.setIconifiedByDefault(false);
MenuItemCompat.setActionView(item, searchView);
item.setActionView(searchView);
searchMenu = item;
final MenuItem sortBySeeders = menu.findItem(R.id.action_sort_seeders);
final MenuItem sortByAdded = menu.findItem(R.id.action_sort_added);
@ -218,9 +217,9 @@ public class SearchActivity extends AppCompatActivity { @@ -218,9 +217,9 @@ public class SearchActivity extends AppCompatActivity {
searchsitesList.setVisibility(searchInstalled ? View.VISIBLE : View.GONE);
}
if (searchInstalled) {
getFragmentManager().beginTransaction().show(fragmentResults).commit();
getSupportFragmentManager().beginTransaction().show(fragmentResults).commit();
} else {
getFragmentManager().beginTransaction().hide(fragmentResults).commit();
getSupportFragmentManager().beginTransaction().hide(fragmentResults).commit();
}
installmoduleText.setVisibility(searchInstalled ? View.GONE : View.VISIBLE);

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

@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
*/
package org.transdroid.core.gui.search;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@ -32,6 +31,7 @@ import android.widget.TextView; @@ -32,6 +31,7 @@ import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager;

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

@ -24,6 +24,9 @@ import android.view.LayoutInflater; @@ -24,6 +24,9 @@ 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;
@ -47,9 +50,9 @@ public class UrlEntryDialog { @@ -47,9 +50,9 @@ public class UrlEntryDialog {
urlEdit.setText(content);
}
new MaterialDialog.Builder(activity).customView(inputLayout, false).positiveText(android.R.string.ok).negativeText(android.R.string.cancel)
.callback(new MaterialDialog.ButtonCallback() {
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
String url = urlEdit.getText().toString();
Uri uri = Uri.parse(url);
if (!TextUtils.isEmpty(url)) {

8
app/src/main/java/org/transdroid/core/service/AppUpdateJobRunner.java

@ -108,9 +108,9 @@ public class AppUpdateJobRunner { @@ -108,9 +108,9 @@ public class AppUpdateJobRunner {
// New version of the app?
try {
PackageInfo appPackage = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
log.d(this, "Local Transdroid is at " + appPackage.versionCode + " and the reported latest version is "
log.d(this, "Local Transdroid is at " + appPackage.getLongVersionCode() + " and the reported latest version is "
+ appVersion);
if (appPackage.versionCode < appVersion) {
if (appPackage.getLongVersionCode() < appVersion) {
// New version available! Notify the user.
newNotification(context.getString(R.string.update_app_newversion),
context.getString(R.string.update_app_newversion),
@ -124,9 +124,9 @@ public class AppUpdateJobRunner { @@ -124,9 +124,9 @@ public class AppUpdateJobRunner {
// New version of the search module?
try {
PackageInfo searchPackage = context.getPackageManager().getPackageInfo("org.transdroid.search", 0);
log.d(this, "Local Transdroid Seach is at " + searchPackage.versionCode
log.d(this, "Local Transdroid Seach is at " + searchPackage.getLongVersionCode()
+ " and the reported latest version is " + searchVersion);
if (searchPackage.versionCode < searchVersion) {
if (searchPackage.getLongVersionCode() < searchVersion) {
// New version available! Notify the user.
newNotification(context.getString(R.string.update_search_newversion),
context.getString(R.string.update_search_newversion),

Loading…
Cancel
Save