Browse Source

Fixed crash on adding widget as well as widget layout issues (with new Material theme) and Control Service start bug on Android Lolliopo+. Fixed #218.

pull/256/head
Eric Kok 9 years ago
parent
commit
4ac0a279cc
  1. 4
      app/build.gradle
  2. 4
      app/src/main/java/org/transdroid/core/gui/DetailsActivity.java
  3. 4
      app/src/main/java/org/transdroid/core/gui/DetailsFragment.java
  4. 7
      app/src/main/java/org/transdroid/core/gui/TorrentsActivity.java
  5. 6
      app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java
  6. 4
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java
  7. 4
      app/src/main/java/org/transdroid/core/gui/rss/RssitemsActivity.java
  8. 4
      app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java
  9. 3
      app/src/main/java/org/transdroid/core/gui/search/SearchActivity.java
  10. 7
      app/src/main/java/org/transdroid/core/gui/settings/PreferenceCompatActivity.java
  11. 51
      app/src/main/java/org/transdroid/core/widget/ListWidgetConfigActivity.java
  12. 44
      app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java
  13. 2
      app/src/main/java/org/transdroid/core/widget/ListWidgetViewsService.java
  14. 9
      app/src/main/res/layout/widget_torrents_dark.xml
  15. 331
      app/src/main/res/layout/widget_torrents_light.xml
  16. 4
      app/src/main/res/values/changelog.xml
  17. 2
      app/src/main/res/values/dimens.xml
  18. 2
      app/src/main/res/values/styles.xml
  19. 2
      build.gradle

4
app/build.gradle

@ -37,8 +37,8 @@ dependencies { @@ -37,8 +37,8 @@ dependencies {
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-annotations:22.1.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-annotations:22.2.0'
compile 'com.getbase:floatingactionbutton:1.8.0'
compile 'com.afollestad:material-dialogs:0.6.3.3'
compile 'com.nispok:snackbar:2.10.6'

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

@ -20,7 +20,7 @@ import android.annotation.TargetApi; @@ -20,7 +20,7 @@ import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.nispok.snackbar.Snackbar;
@ -84,7 +84,7 @@ import java.util.List; @@ -84,7 +84,7 @@ import java.util.List;
*/
@EActivity(R.layout.activity_details)
@OptionsMenu(R.menu.activity_details)
public class DetailsActivity extends ActionBarActivity implements TorrentTasksExecutor, RefreshableActivity {
public class DetailsActivity extends AppCompatActivity implements TorrentTasksExecutor, RefreshableActivity {
@Extra
@InstanceState

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

@ -24,7 +24,7 @@ import android.content.Context; @@ -24,7 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ActionMenuView;
import android.view.ActionMode;
import android.view.Menu;
@ -487,7 +487,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen @@ -487,7 +487,7 @@ public class DetailsFragment extends Fragment implements OnTrackersUpdatedListen
});
contextualMenu.getMenu().clear();
getActivity().getMenuInflater().inflate(R.menu.fragment_details_cab_main, contextualMenu.getMenu());
Context themedContext = ((ActionBarActivity) getActivity()).getSupportActionBar().getThemedContext();
Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext();
mode.getMenuInflater().inflate(R.menu.fragment_details_cab_secondary, menu);
selectionManagerMode = new SelectionManagerMode(themedContext, detailsList, R.plurals.navigation_filesselected);
selectionManagerMode.setOnlyCheckClass(TorrentFile.class);

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

@ -26,8 +26,8 @@ import android.os.Build; @@ -26,8 +26,8 @@ import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
@ -145,7 +145,7 @@ import java.util.Map.Entry; @@ -145,7 +145,7 @@ import java.util.Map.Entry;
* @author Eric Kok
*/
@EActivity(R.layout.activity_torrents)
public class TorrentsActivity extends ActionBarActivity implements TorrentTasksExecutor, RefreshableActivity {
public class TorrentsActivity extends AppCompatActivity implements TorrentTasksExecutor, RefreshableActivity {
private static final int RESULT_DETAILS = 0;
@ -795,8 +795,7 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE @@ -795,8 +795,7 @@ public class TorrentsActivity extends ActionBarActivity implements TorrentTasksE
protected void onBarcodeScanHandled(String barcode, String result) {
log.d(this, "Scanned barcode " + barcode + " and got " + result);
if (TextUtils.isEmpty(result)) {
SnackbarManager.show(Snackbar.with(this).text(R.string.error_noproductforcode).colorResource(R.color.red)
.type(SnackbarType.MULTI_LINE));
SnackbarManager.show(Snackbar.with(this).text(R.string.error_noproductforcode).colorResource(R.color.red).type(SnackbarType.MULTI_LINE));
} else if (result.startsWith("http") || result.startsWith("https")) {
addTorrentByUrl(result, "QR code result"); // No torrent title known
} else if (result.startsWith("magnet")) {

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

@ -19,7 +19,7 @@ package org.transdroid.core.gui; @@ -19,7 +19,7 @@ package org.transdroid.core.gui;
import android.app.Fragment;
import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.ActionMenuView;
import android.support.v7.widget.Toolbar;
import android.view.ActionMode;
@ -281,7 +281,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -281,7 +281,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
});
actionsMenu.getMenu().clear();
getActivity().getMenuInflater().inflate(R.menu.fragment_torrents_cab, actionsMenu.getMenu());
Context themedContext = ((ActionBarActivity) getActivity()).getSupportActionBar().getThemedContext();
Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext();
selectionManagerMode = new SelectionManagerMode(themedContext, torrentsList, R.plurals.navigation_torrentsselected);
selectionManagerMode.onCreateActionMode(mode, menu);
return true;
@ -354,7 +354,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener @@ -354,7 +354,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
} else if (itemId == R.id.action_setlabel) {
lastMultiSelectedTorrents = checked;
if (currentLabels != null) {
SetLabelDialog.show(getActivity(), TorrentsFragment.this,currentLabels);
SetLabelDialog.show(getActivity(), TorrentsFragment.this, currentLabels);
}
mode.finish();
return true;

4
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java

@ -21,7 +21,7 @@ import android.content.Intent; @@ -21,7 +21,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
@ -51,7 +51,7 @@ import java.util.Date; @@ -51,7 +51,7 @@ import java.util.Date;
import java.util.List;
@EActivity(R.layout.activity_rssfeeds)
public class RssfeedsActivity extends ActionBarActivity {
public class RssfeedsActivity extends AppCompatActivity {
// Settings and local data
@Bean

4
app/src/main/java/org/transdroid/core/gui/rss/RssitemsActivity.java

@ -20,7 +20,7 @@ import android.annotation.TargetApi; @@ -20,7 +20,7 @@ import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import org.androidannotations.annotations.AfterViews;
@ -36,7 +36,7 @@ import org.transdroid.core.gui.navigation.NavigationHelper; @@ -36,7 +36,7 @@ import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.rssparser.Channel;
@EActivity(R.layout.activity_rssitems)
public class RssitemsActivity extends ActionBarActivity {
public class RssitemsActivity extends AppCompatActivity {
@Extra
protected Channel rssfeed = null;

4
app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java

@ -27,7 +27,7 @@ import android.content.Context; @@ -27,7 +27,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.ActionMode;
import android.view.Menu;
@ -80,7 +80,7 @@ public class RssitemsFragment extends Fragment { @@ -80,7 +80,7 @@ public class RssitemsFragment extends Fragment {
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
// Show contextual action bar to add items in batch mode
mode.getMenuInflater().inflate(R.menu.fragment_rssitems_cab, menu);
Context themedContext = ((ActionBarActivity) getActivity()).getSupportActionBar().getThemedContext();
Context themedContext = ((AppCompatActivity) getActivity()).getSupportActionBar().getThemedContext();
selectionManagerMode = new SelectionManagerMode(themedContext, rssitemsList, R.plurals.rss_itemsselected);
selectionManagerMode.onCreateActionMode(mode, menu);
return true;

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

@ -26,6 +26,7 @@ import android.provider.SearchRecentSuggestions; @@ -26,6 +26,7 @@ import android.provider.SearchRecentSuggestions;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
@ -62,7 +63,7 @@ import java.util.List; @@ -62,7 +63,7 @@ import java.util.List;
*/
@EActivity(R.layout.activity_search)
@OptionsMenu(R.menu.activity_search)
public class SearchActivity extends ActionBarActivity implements ActionBar.OnNavigationListener {
public class SearchActivity extends AppCompatActivity implements ActionBar.OnNavigationListener {
@ViewById
protected Toolbar searchToolbar;

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

@ -3,6 +3,7 @@ package org.transdroid.core.gui.settings; @@ -3,6 +3,7 @@ package org.transdroid.core.gui.settings;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatCallback;
import android.support.v7.app.AppCompatDelegate;
@ -62,4 +63,10 @@ public class PreferenceCompatActivity extends PreferenceActivity implements AppC @@ -62,4 +63,10 @@ public class PreferenceCompatActivity extends PreferenceActivity implements AppC
public void onSupportActionModeFinished(ActionMode actionMode) {
}
@Nullable
@Override
public ActionMode onWindowStartingSupportActionMode(ActionMode.Callback callback) {
return acd.startSupportActionMode(callback);
}
}

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

@ -22,7 +22,7 @@ import android.content.Intent; @@ -22,7 +22,7 @@ import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
@ -66,7 +66,7 @@ import java.util.List; @@ -66,7 +66,7 @@ import java.util.List;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@EActivity(resName = "activity_widgetconfig")
public class ListWidgetConfigActivity extends ActionBarActivity {
public class ListWidgetConfigActivity extends AppCompatActivity {
// Views and adapters
@ViewById
@ -127,14 +127,12 @@ public class ListWidgetConfigActivity extends ActionBarActivity { @@ -127,14 +127,12 @@ public class ListWidgetConfigActivity extends ActionBarActivity {
boolean reverseSort = reverseorderCheckBox.isChecked();
boolean showstatus = showstatusCheckBox.isChecked();
boolean useDarkTheme = darkthemeCheckBox.isChecked();
ListWidgetConfig config =
new ListWidgetConfig(server, statusType, sortBy, reverseSort, showstatus, useDarkTheme);
ListWidgetConfig config = new ListWidgetConfig(server, statusType, sortBy, reverseSort, showstatus, useDarkTheme);
applicationSettings.setWidgetConfig(appWidgetId, config);
// Return the widget configuration result
AppWidgetManager manager = AppWidgetManager.getInstance(ListWidgetConfigActivity.this);
manager.updateAppWidget(appWidgetId,
ListWidgetProvider.buildRemoteViews(getApplicationContext(), appWidgetId, config));
manager.updateAppWidget(appWidgetId, ListWidgetProvider.buildRemoteViews(getApplicationContext(), appWidgetId, config));
manager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.torrents_list);
setResult(RESULT_OK, new Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId));
finish();
@ -149,14 +147,12 @@ public class ListWidgetConfigActivity extends ActionBarActivity { @@ -149,14 +147,12 @@ public class ListWidgetConfigActivity extends ActionBarActivity {
if (getIntent() == null || getIntent().getExtras() == null ||
!getIntent().hasExtra(AppWidgetManager.EXTRA_APPWIDGET_ID)) {
// Invalid configuration; return canceled result
setResult(RESULT_CANCELED,
new Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID));
setResult(RESULT_CANCELED, new Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID));
finish();
}
// Get the appwidget ID we are configuring
appWidgetId =
getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
appWidgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
// Set preliminary canceled result and continue with the initialisation
setResult(RESULT_CANCELED, new Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId));
@ -166,27 +162,26 @@ public class ListWidgetConfigActivity extends ActionBarActivity { @@ -166,27 +162,26 @@ public class ListWidgetConfigActivity extends ActionBarActivity {
protected void init() {
// Populate the selection spinners with custom array adapters
List<SortByListItem> sortOrders = new ArrayList<SortByListItem>();
List<SortByListItem> sortOrders = new ArrayList<>();
for (TorrentsSortBy order : TorrentsSortBy.values()) {
sortOrders.add(new SortByListItem(this, order));
}
serverSpinner.setAdapter(
new SimpleListItemSpinnerAdapter<ServerSetting>(this, 0, applicationSettings.getAllServerSettings()));
filterSpinner.setAdapter(
new SimpleListItemSpinnerAdapter<StatusTypeFilter>(this, 0, StatusType.getAllStatusTypes(this)));
sortSpinner.setAdapter(new SimpleListItemSpinnerAdapter<SortByListItem>(this, 0, sortOrders));
// TODO: Update to AndroidAnnotations 3.0 and use @CheckedChanged
serverSpinner.setAdapter(new SimpleListItemSpinnerAdapter<>(this, 0, applicationSettings.getAllServerSettings()));
filterSpinner.setAdapter(new SimpleListItemSpinnerAdapter<>(this, 0, StatusType.getAllStatusTypes(this)));
sortSpinner.setAdapter(new SimpleListItemSpinnerAdapter<>(this, 0, sortOrders));
reverseorderCheckBox.setOnCheckedChangeListener(reverseorderCheckedChanged);
showstatusCheckBox.setOnCheckedChangeListener(showstatusCheckChanged);
torrentsList.setEmptyView(errorText);
// Set up action bar with a done button
// Inspired by NoNonsenseNotes's ListWidgetConfig.java (Apache License, Version 2.0)
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
View doneButtonFrame = getLayoutInflater().inflate(R.layout.actionbar_donebutton, null);
doneButtonFrame.findViewById(R.id.actionbar_done).setOnClickListener(doneClicked);
getSupportActionBar().setCustomView(doneButtonFrame);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
View doneButtonFrame = getLayoutInflater().inflate(R.layout.actionbar_donebutton, null);
doneButtonFrame.findViewById(R.id.actionbar_done).setOnClickListener(doneClicked);
getSupportActionBar().setCustomView(doneButtonFrame);
}
}
@ -215,13 +210,12 @@ public class ListWidgetConfigActivity extends ActionBarActivity { @@ -215,13 +210,12 @@ public class ListWidgetConfigActivity extends ActionBarActivity {
}
// Create a connection object and retrieve the live torrents
IDaemonAdapter connection = ((ServerSetting) serverSpinner.getSelectedItem())
.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
IDaemonAdapter connection =
((ServerSetting) serverSpinner.getSelectedItem()).createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
DaemonTaskResult result = RetrieveTask.create(connection).execute(log);
if (result instanceof RetrieveTaskSuccessResult) {
// Success; show the active torrents in the widget preview
onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(),
((RetrieveTaskSuccessResult) result).getLabels());
onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(), ((RetrieveTaskSuccessResult) result).getLabels());
} else {
// Can't connect right now; provide a nice error message
showError(false);
@ -252,7 +246,7 @@ public class ListWidgetConfigActivity extends ActionBarActivity { @@ -252,7 +246,7 @@ public class ListWidgetConfigActivity extends ActionBarActivity {
}
// Get the already loaded torrents and filter and sort them
ArrayList<Torrent> filteredTorrents = new ArrayList<Torrent>(previewTorrents.size());
ArrayList<Torrent> filteredTorrents = new ArrayList<>(previewTorrents.size());
StatusTypeFilter statusTypeFilter = (StatusTypeFilter) filterSpinner.getSelectedItem();
boolean dormantAsInactive = systemSettings.treatDormantAsInactive();
for (Torrent torrent : previewTorrents) {
@ -266,8 +260,7 @@ public class ListWidgetConfigActivity extends ActionBarActivity { @@ -266,8 +260,7 @@ public class ListWidgetConfigActivity extends ActionBarActivity {
}
TorrentsSortBy sortBy = ((SortByListItem) sortSpinner.getSelectedItem()).getSortBy();
Daemon serverType = filteredTorrents.get(0).getDaemon();
Collections
.sort(filteredTorrents, new TorrentsComparator(serverType, sortBy, reverseorderCheckBox.isChecked()));
Collections.sort(filteredTorrents, new TorrentsComparator(serverType, sortBy, reverseorderCheckBox.isChecked()));
// Update the server status count and speeds
int downcount = 0, upcount = 0, downspeed = 0, upspeed = 0;

44
app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java

@ -30,14 +30,17 @@ import android.widget.RemoteViews; @@ -30,14 +30,17 @@ import android.widget.RemoteViews;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EReceiver;
import org.transdroid.R;
import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.*;
import org.transdroid.core.gui.log.*;
import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.ApplicationSettings_;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.log.Log_;
import org.transdroid.core.service.ControlService;
import org.transdroid.core.service.ControlService_;
/**
* The provider of a list-style Transdroid widget, which controls the general loading and (touch) event handling. The
* list rows' remote views are loaded in the accompanying {@link ListWidgetViewsService}.
* The provider of a list-style Transdroid widget, which controls the general loading and (touch) event handling. The list rows' remote views are
* loaded in the accompanying {@link ListWidgetViewsService}.
* @author Eric Kok
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@ -53,8 +56,8 @@ public class ListWidgetProvider extends AppWidgetProvider { @@ -53,8 +56,8 @@ public class ListWidgetProvider extends AppWidgetProvider {
protected ApplicationSettings applicationSettings;
/**
* Loads and sets up the layout for some specific app widget given the user's widget settings. Note that the views
* for the list view rows are loaded separately in the {@link WidgetViewsFactory}.
* Loads and sets up the layout for some specific app widget given the user's widget settings. Note that the views for the list view rows are
* loaded separately in the {@link WidgetViewsFactory}.
* @param context The app widget context, with access to resources
* @param appWidgetId The specific ID of the app widget to load
* @param config The user widget configuration, with filter and theme preferences
@ -69,9 +72,9 @@ public class ListWidgetProvider extends AppWidgetProvider { @@ -69,9 +72,9 @@ public class ListWidgetProvider extends AppWidgetProvider {
}
ApplicationSettings appSettings = ApplicationSettings_.getInstance_(context);
if (config.getServerId() < 0 || config.getServerId() > appSettings.getMaxOfAllServers()) {
Log_.getInstance_(context).e("ListWidgetProvider",
"Tried to set up widget " + appWidgetId + " but the bound server ID " + config.getServerId() +
" no longer exists.");
Log_.getInstance_(context)
.e("ListWidgetProvider", "Tried to set up widget " + appWidgetId + " but the bound server ID " + config.getServerId() +
" no longer exists.");
return null;
}
@ -86,8 +89,7 @@ public class ListWidgetProvider extends AppWidgetProvider { @@ -86,8 +89,7 @@ public class ListWidgetProvider extends AppWidgetProvider {
rv.setRemoteAdapter(appWidgetId, R.id.torrents_list, data);
Intent open = new Intent(context, TorrentsActivity_.class);
open.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
rv.setPendingIntentTemplate(R.id.torrents_list,
PendingIntent.getActivity(context, appWidgetId, open, PendingIntent.FLAG_UPDATE_CURRENT));
rv.setPendingIntentTemplate(R.id.torrents_list, PendingIntent.getActivity(context, appWidgetId, open, PendingIntent.FLAG_UPDATE_CURRENT));
rv.setEmptyView(R.id.torrents_list, R.id.error_text);
rv.setTextViewText(R.id.error_text, context.getString(R.string.widget_loading));
@ -103,10 +105,8 @@ public class ListWidgetProvider extends AppWidgetProvider { @@ -103,10 +105,8 @@ public class ListWidgetProvider extends AppWidgetProvider {
start.setAction(INTENT_STARTSERVER);
start.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
start.putExtra(EXTRA_SERVER, config.getServerId());
rv.setOnClickPendingIntent(R.id.icon_image,
PendingIntent.getActivity(context, appWidgetId, start, PendingIntent.FLAG_UPDATE_CURRENT));
rv.setOnClickPendingIntent(R.id.navigation_view,
PendingIntent.getActivity(context, appWidgetId, start, PendingIntent.FLAG_UPDATE_CURRENT));
rv.setOnClickPendingIntent(R.id.icon_image, PendingIntent.getActivity(context, appWidgetId, start, PendingIntent.FLAG_UPDATE_CURRENT));
rv.setOnClickPendingIntent(R.id.navigation_view, PendingIntent.getActivity(context, appWidgetId, start, PendingIntent.FLAG_UPDATE_CURRENT));
// Set up the widgets refresh button pending intent (calling this WidgetProvider itself)
// Make sure that the intent is unique using a custom data path (rather than just the extras)
@ -114,8 +114,7 @@ public class ListWidgetProvider extends AppWidgetProvider { @@ -114,8 +114,7 @@ public class ListWidgetProvider extends AppWidgetProvider {
refresh.setData(Uri.parse("intent://widget/" + appWidgetId + "/refresh"));
refresh.putExtra(EXTRA_REFRESH, appWidgetId);
refresh.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
rv.setOnClickPendingIntent(R.id.refresh_button,
PendingIntent.getBroadcast(context, appWidgetId, refresh, PendingIntent.FLAG_UPDATE_CURRENT));
rv.setOnClickPendingIntent(R.id.refresh_button, PendingIntent.getBroadcast(context, appWidgetId, refresh, PendingIntent.FLAG_UPDATE_CURRENT));
// Set up the control (pause and resume) buttons (calling the WidgetProvider itself)
Intent pauseall = new Intent(context, ListWidgetProvider_.class);
@ -144,8 +143,7 @@ public class ListWidgetProvider extends AppWidgetProvider { @@ -144,8 +143,7 @@ public class ListWidgetProvider extends AppWidgetProvider {
// Refresh a specific app widget
if (intent.hasExtra(EXTRA_REFRESH)) {
// Manually requested a refresh for the app widget of which the ID was supplied
RemoteViews views =
buildRemoteViews(context, appWidgetId, applicationSettings.getWidgetConfig(appWidgetId));
RemoteViews views = buildRemoteViews(context, appWidgetId, applicationSettings.getWidgetConfig(appWidgetId));
if (views != null) {
AppWidgetManager.getInstance(context).updateAppWidget(appWidgetId, views);
AppWidgetManager.getInstance(context).notifyAppWidgetViewDataChanged(appWidgetId, R.id.torrents_list);
@ -155,7 +153,8 @@ public class ListWidgetProvider extends AppWidgetProvider { @@ -155,7 +153,8 @@ public class ListWidgetProvider extends AppWidgetProvider {
// No refresh: this is a control intent: copy the action and EXTRA_APPWIDGET_ID to start the control service
if (intent.getAction().startsWith("org.transdroid.control.")) {
Intent action = new Intent(intent.getAction());
Intent action = new Intent(context, ControlService_.class);
action.setAction(intent.getAction());
action.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
context.startService(action);
}
@ -164,8 +163,7 @@ public class ListWidgetProvider extends AppWidgetProvider { @@ -164,8 +163,7 @@ public class ListWidgetProvider extends AppWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
for (int appWidgetId : appWidgetIds) {
appWidgetManager.updateAppWidget(appWidgetId,
buildRemoteViews(context, appWidgetId, applicationSettings.getWidgetConfig(appWidgetId)));
appWidgetManager.updateAppWidget(appWidgetId, buildRemoteViews(context, appWidgetId, applicationSettings.getWidgetConfig(appWidgetId)));
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.torrents_list);
}
}

2
app/src/main/java/org/transdroid/core/widget/ListWidgetViewsService.java

@ -117,7 +117,7 @@ class WidgetViewsFactory implements RemoteViewsService.RemoteViewsFactory { @@ -117,7 +117,7 @@ class WidgetViewsFactory implements RemoteViewsService.RemoteViewsFactory {
// We have data; filter, sort and store it to use later when getViewAt gets called
SystemSettings systemSettings = SystemSettings_.getInstance_(context);
ArrayList<Torrent> filteredTorrents = new ArrayList<Torrent>();
ArrayList<Torrent> filteredTorrents = new ArrayList<>();
List<Torrent> allTorrents = ((RetrieveTaskSuccessResult) result).getTorrents();
for (Torrent torrent : allTorrents) {
if (config.getStatusType().getFilterItem(context)

9
app/src/main/res/layout/widget_torrents_dark.xml

@ -19,8 +19,7 @@ @@ -19,8 +19,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_dark"
android:padding="@dimen/margin_widget">
android:background="@color/background_dark">
<ImageButton
android:id="@+id/icon_image"
@ -86,7 +85,8 @@ @@ -86,7 +85,8 @@
android:maxLines="1"
android:textColor="@color/text_actionbar_dark"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_filter" />
android:textSize="@dimen/ui_navigation_filter"
tools:text="Filter" />
<TextView
android:id="@+id/server_text"
@ -98,7 +98,8 @@ @@ -98,7 +98,8 @@
android:maxLines="1"
android:textColor="@color/text_actionbar_dark"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_server" />
android:textSize="@dimen/ui_navigation_server"
tools:text="Server" />
</LinearLayout>
<RelativeLayout

331
app/src/main/res/layout/widget_torrents_light.xml

@ -19,176 +19,175 @@ @@ -19,176 +19,175 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_light"
android:padding="@dimen/margin_widget" >
<ImageButton
android:id="@+id/icon_image"
android:layout_width="@dimen/widget_header_height"
android:layout_height="@dimen/widget_header_height"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/widget_opentransdroid"
android:padding="@dimen/widget_header_padding"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<ImageButton
android:id="@+id/refresh_button"
android:layout_width="@dimen/widget_header_height"
android:layout_height="@dimen/widget_header_height"
android:layout_alignParentRight="true"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/action_refresh"
android:padding="@dimen/widget_header_padding"
android:scaleType="fitXY"
android:src="@drawable/ic_action_refresh" />
<ImageButton
android:id="@+id/pauseall_button"
android:layout_width="@dimen/widget_header_height"
android:layout_height="@dimen/widget_header_height"
android:layout_toLeftOf="@id/refresh_button"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/action_pauseall"
android:padding="@dimen/widget_header_padding"
android:scaleType="fitXY"
android:src="@drawable/ic_action_pause" />
<ImageButton
android:id="@+id/resumeall_button"
android:layout_width="@dimen/widget_header_height"
android:layout_height="@dimen/widget_header_height"
android:layout_toLeftOf="@id/pauseall_button"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/action_resumeall"
android:padding="@dimen/widget_header_padding"
android:scaleType="fitXY"
android:src="@drawable/ic_action_resume" />
android:background="@color/background_light">
<LinearLayout
android:id="@+id/navigation_view"
android:id="@+id/header_wrapper"
android:layout_width="match_parent"
android:layout_height="@dimen/widget_header_height"
android:layout_toLeftOf="@id/resumeall_button"
android:layout_toRightOf="@id/icon_image"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:orientation="vertical"
android:paddingRight="@dimen/margin_half"
android:paddingTop="3dp" >
<TextView
android:id="@+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"
android:textColor="@color/text_actionbar_light"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_filter" />
<TextView
android:id="@+id/server_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-4dip"
android:ellipsize="marquee"
android:fontFamily="sans-serif-light"
android:maxLines="1"
android:textColor="@color/text_actionbar_light"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_server" />
</LinearLayout>
android:background="@color/green"
android:orientation="horizontal">
<ImageButton
android:id="@+id/icon_image"
android:layout_width="@dimen/widget_header_height"
android:layout_height="@dimen/widget_header_height"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/widget_opentransdroid"
android:padding="@dimen/widget_header_padding"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:id="@+id/navigation_view"
android:layout_width="0dp"
android:layout_height="@dimen/widget_header_height"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:orientation="vertical"
android:paddingRight="@dimen/margin_half"
android:paddingEnd="@dimen/margin_half"
android:paddingTop="3dp" >
<TextView
android:id="@+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"
android:textColor="@color/text_actionbar_dark"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_filter"
tools:text="Filter" />
<TextView
android:id="@+id/server_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-4dip"
android:ellipsize="marquee"
android:fontFamily="sans-serif-light"
android:maxLines="1"
android:textColor="@color/text_actionbar_dark"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_server"
tools:text="Server"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/serverstatus_view"
android:layout_width="0dp"
android:layout_height="@dimen/widget_header_height"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:paddingTop="@dimen/ui_serverstatus_margin"
android:visibility="gone" >
<TextView
android:id="@+id/upcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↑"
android:textColor="@color/text_bright_dark"
android:textSize="@dimen/ui_serverstatus_sign"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/upcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="@color/text_bright_dark"
android:textSize="@dimen/ui_serverstatus_bignumber" />
<TextView
android:id="@+id/downcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_text"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↓"
android:textColor="@color/text_bright_dark"
android:textSize="@dimen/ui_serverstatus_sign"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/downcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/downcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="@color/text_bright_dark"
android:textSize="@dimen/ui_serverstatus_bignumber" />
<TextView
android:id="@+id/upspeed_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/upcount_text"
android:layout_alignParentRight="true"
android:layout_below="@id/upcount_text"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="@color/text_bright_dark"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
<TextView
android:id="@+id/downspeed_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/downcount_text"
android:layout_alignRight="@id/downcount_sign"
android:layout_below="@id/downcount_text"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="@color/text_bright_dark"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
</RelativeLayout>
<ImageButton
android:id="@+id/resumeall_button"
android:layout_width="@dimen/widget_header_height"
android:layout_height="@dimen/widget_header_height"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/action_resumeall"
android:padding="@dimen/widget_header_padding"
android:scaleType="fitXY"
android:src="@drawable/ic_action_resume" />
<ImageButton
android:id="@+id/pauseall_button"
android:layout_width="@dimen/widget_header_height"
android:layout_height="@dimen/widget_header_height"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/action_pauseall"
android:padding="@dimen/widget_header_padding"
android:scaleType="fitXY"
android:src="@drawable/ic_action_pause" />
<ImageButton
android:id="@+id/refresh_button"
android:layout_width="@dimen/widget_header_height"
android:layout_height="@dimen/widget_header_height"
android:background="?android:attr/selectableItemBackground"
android:contentDescription="@string/action_refresh"
android:padding="@dimen/widget_header_padding"
android:scaleType="fitXY"
android:src="@drawable/ic_action_refresh" />
<RelativeLayout
android:id="@+id/serverstatus_view"
android:layout_width="match_parent"
android:layout_height="@dimen/widget_header_height"
android:layout_toLeftOf="@id/resumeall_button"
android:layout_toRightOf="@id/icon_image"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:paddingTop="@dimen/ui_serverstatus_margin"
android:visibility="gone" >
<TextView
android:id="@+id/upcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↑"
android:textColor="@color/text_bright_light"
android:textSize="@dimen/ui_serverstatus_sign"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/upcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="@color/text_bright_light"
android:textSize="@dimen/ui_serverstatus_bignumber" />
<TextView
android:id="@+id/downcount_sign"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/upcount_text"
android:fontFamily="sans-serif-light"
android:paddingTop="@dimen/ui_serverstatus_signmargin"
android:text="↓"
android:textColor="@color/text_bright_light"
android:textSize="@dimen/ui_serverstatus_sign"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/downcount_text"
android:layout_width="@dimen/ui_serverstatus_width"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/downcount_sign"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="@color/text_bright_light"
android:textSize="@dimen/ui_serverstatus_bignumber" />
<TextView
android:id="@+id/upspeed_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/upcount_text"
android:layout_alignParentRight="true"
android:layout_below="@id/upcount_text"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="@color/text_bright_light"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
<TextView
android:id="@+id/downspeed_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/downcount_text"
android:layout_alignRight="@id/downcount_sign"
android:layout_below="@id/downcount_text"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:textColor="@color/text_bright_light"
android:textSize="@dimen/ui_serverstatus_smallnumber" />
</RelativeLayout>
<TextView
android:id="@+id/topline_view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/icon_image"
android:background="@color/green" />
</LinearLayout>
<TextView
android:id="@+id/bottomline_view"
@ -202,7 +201,7 @@ @@ -202,7 +201,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/bottomline_view"
android:layout_below="@id/topline_view"
android:layout_below="@id/header_wrapper"
android:visibility="gone" />
<TextView

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

@ -17,6 +17,10 @@ @@ -17,6 +17,10 @@
-->
<resources>
<string name="system_changelog">
Transdroid 2.5.2\n
- Native Dediseedbox support\n
- Prevent widget from crashing\n
\n
Transdroid 2.5.1\n
- Improved rTorrent backwards compatibility\n
- UI fixes for dark theme\n

2
app/src/main/res/values/dimens.xml

@ -51,7 +51,7 @@ @@ -51,7 +51,7 @@
<dimen name="widget_preview_height">200dp</dimen>
<dimen name="widget_preview_width">-1dp</dimen>
<dimen name="widget_header_height">46dp</dimen>
<dimen name="widget_header_padding">6dp</dimen>
<dimen name="widget_header_padding">8dp</dimen>
<dimen name="widget_list_item_height">54dp</dimen>
<dimen name="widget_list_item_padding">6dp</dimen>
<dimen name="widget_list_item_padding_left">12dp</dimen>

2
app/src/main/res/values/styles.xml

@ -34,6 +34,8 @@ @@ -34,6 +34,8 @@
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="windowActionBar">true</item>
<item name="windowNoTitle">false</item>
</style>
<style name="DefaultToolbar">

2
build.gradle

@ -3,7 +3,7 @@ buildscript { @@ -3,7 +3,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}

Loading…
Cancel
Save