Browse Source

Fixed merge conflict

pull/585/head
Eric Kok 4 years ago
parent
commit
1a89f35f2d
  1. 76
      app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java
  2. 5
      app/src/main/java/org/transdroid/core/widget/ListWidgetProvider.java
  3. 222
      app/src/main/res/layout/widget_torrents_dark.xml

76
app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java

@ -734,44 +734,44 @@ public class ApplicationSettings {
prefs.edit().putString(server.getUniqueIdentifier(), lastStats.toString()).apply(); prefs.edit().putString(server.getUniqueIdentifier(), lastStats.toString()).apply();
} }
/** /**
* Returns the user configuration for some specific app widget, if the widget is known at all. * Returns the user configuration for some specific app widget, if the widget is known at all.
* * @param appWidgetId The unique ID of the app widget to retrieve settings for, as supplied by the AppWidgetManager
* @param appWidgetId The unique ID of the app widget to retrieve settings for, as supplied by the AppWidgetManager * @return A widget configuration object, or null if no settings were stored for the widget ID
* @return A widget configuration object, or null if no settings were stored for the widget ID */
*/ public ListWidgetConfig getWidgetConfig(int appWidgetId) {
public ListWidgetConfig getWidgetConfig(int appWidgetId) { if (!prefs.contains("widget_server_" + appWidgetId))
if (!prefs.contains("widget_server_" + appWidgetId)) return null;
return null; // @formatter:off
// @formatter:off return new ListWidgetConfig(
return new ListWidgetConfig( prefs.getInt("widget_server_" + appWidgetId, -1),
prefs.getInt("widget_server_" + appWidgetId, -1), StatusType.valueOf(prefs.getString("widget_status_" + appWidgetId, StatusType.ShowAll.name())),
StatusType.valueOf(prefs.getString("widget_status_" + appWidgetId, StatusType.ShowAll.name())), TorrentsSortBy.valueOf(prefs.getString("widget_sortby_" + appWidgetId, TorrentsSortBy.Alphanumeric.name())),
TorrentsSortBy.valueOf(prefs.getString("widget_sortby_" + appWidgetId, TorrentsSortBy.Alphanumeric.name())), prefs.getBoolean("widget_reverse_" + appWidgetId, false),
prefs.getBoolean("widget_reverse_" + appWidgetId, false), prefs.getBoolean("widget_showstatus_" + appWidgetId, false),
prefs.getBoolean("widget_showstatus_" + appWidgetId, false)); prefs.getBoolean("widget_darktheme_" + appWidgetId, false));
// @formatter:on // @formatter:on
} }
/** /**
* Stores the user settings for some specific app widget. Existing settings for the supplied app widget ID will be * Stores the user settings for some specific app widget. Existing settings for the supplied app widget ID will be
* overridden. * overridden.
* * @param appWidgetId The unique ID of the app widget to store settings for, as supplied by the AppWidgetManager
* @param appWidgetId The unique ID of the app widget to store settings for, as supplied by the AppWidgetManager * @param settings A widget configuration object, which may not be null
* @param settings A widget configuration object, which may not be null */
*/ public void setWidgetConfig(int appWidgetId, ListWidgetConfig settings) {
public void setWidgetConfig(int appWidgetId, ListWidgetConfig settings) { if (settings == null)
if (settings == null) throw new InvalidParameterException(
throw new InvalidParameterException( "The widget setting may not be null. Use removeWidgetConfig instead to remove existing settings for some app widget.");
"The widget setting may not be null. Use removeWidgetConfig instead to remove existing settings for some app widget."); Editor edit = prefs.edit();
Editor edit = prefs.edit(); edit.putInt("widget_server_" + appWidgetId, settings.getServerId());
edit.putInt("widget_server_" + appWidgetId, settings.getServerId()); edit.putString("widget_status_" + appWidgetId, settings.getStatusType().name());
edit.putString("widget_status_" + appWidgetId, settings.getStatusType().name()); edit.putString("widget_sortby_" + appWidgetId, settings.getSortBy().name());
edit.putString("widget_sortby_" + appWidgetId, settings.getSortBy().name()); edit.putBoolean("widget_reverse_" + appWidgetId, settings.shouldReserveSort());
edit.putBoolean("widget_reverse_" + appWidgetId, settings.shouldReserveSort()); edit.putBoolean("widget_showstatus_" + appWidgetId, settings.shouldShowStatusView());
edit.putBoolean("widget_showstatus_" + appWidgetId, settings.shouldShowStatusView()); edit.putBoolean("widget_darktheme_" + appWidgetId, settings.shouldUseDarkTheme());
edit.apply(); edit.apply();
} }
/** /**
* Remove the setting for some specific app widget. * Remove the setting for some specific app widget.

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

@ -80,8 +80,9 @@ public class ListWidgetProvider extends AppWidgetProvider {
return null; return null;
} }
// Load the dark or light widget layout xml // Load the dark or light widget layout xml
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_torrents); RemoteViews rv = new RemoteViews(context.getPackageName(),
config.shouldUseDarkTheme() ? R.layout.widget_torrents_dark : R.layout.widget_torrents);
// Set up the widget's list view loading service which refers to the WidgetViewsFactory // Set up the widget's list view loading service which refers to the WidgetViewsFactory
Intent data = new Intent(context, ListWidgetViewsService_.class); Intent data = new Intent(context, ListWidgetViewsService_.class);

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

@ -0,0 +1,222 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-2018 Eric Kok et al.
Transdroid is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Transdroid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transdroid_dark_background">
<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" />
<LinearLayout
android:id="@+id/navigation_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: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:singleLine="true"
android:textColor="@color/transdroid_dark_text_bright"
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:singleLine="true"
android:textColor="@color/transdroid_dark_text_bright"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_server"
tools:text="Server" />
</LinearLayout>
<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/transdroid_dark_text_bright"
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/transdroid_dark_text_bright"
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/transdroid_dark_text_bright"
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/transdroid_dark_text_bright"
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/transdroid_dark_text_bright"
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/transdroid_dark_text_bright"
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" />
<TextView
android:id="@+id/bottomline_view"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="@color/green" />
<ListView
android:id="@+id/torrents_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/bottomline_view"
android:layout_below="@id/topline_view"
android:visibility="gone" />
<TextView
android:id="@+id/error_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/bottomline_view"
android:layout_below="@id/topline_view"
android:layout_gravity="center"
android:gravity="center"
android:maxWidth="400dip"
android:padding="@dimen/margin_default"
android:textIsSelectable="false"
android:visibility="gone" />
</RelativeLayout>
Loading…
Cancel
Save