Browse Source

Correct look of the preview widget in the widget config screen.

pull/13/merge
Eric Kok 11 years ago
parent
commit
93ee507359
  1. 4
      core/AndroidManifest.xml
  2. 4
      core/res/layout-v11/actionbar_donebutton.xml
  3. 19
      core/res/layout-v11/activity_widgetconfig.xml
  4. 67
      core/res/layout-v11/widget_torrents_dark.xml
  5. 63
      core/res/layout-v11/widget_torrents_light.xml
  6. 2
      core/res/values-sw600dp/dimens.xml
  7. 4
      core/res/values/dimens.xml
  8. 14
      core/res/values/styles.xml
  9. 28
      core/src/org/transdroid/core/widget/WidgetConfigActivity.java
  10. 5
      full/AndroidManifest.xml
  11. 5
      lite/AndroidManifest.xml

4
core/AndroidManifest.xml

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.transdroid.core"
android:versionCode="5"
android:versionName="2.0-beta1" >
android:versionCode="6"
android:versionName="2.0" >
<uses-sdk
android:minSdkVersion="7"

4
core/res/layout-v11/actionbar_donebutton.xml

@ -18,13 +18,13 @@ @@ -18,13 +18,13 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/actionbar_done"
style="?actionButtonStyle"
style="?android:actionButtonStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" >
<TextView
style="?actionBarTabTextStyle"
style="?android:actionBarTabTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"

19
core/res/layout-v11/activity_widgetconfig.xml

@ -19,8 +19,7 @@ @@ -19,8 +19,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerPadding="@dimen/margin_default"
android:orientation="@integer/widget_config_orientation"
android:padding="@dimen/margin_default" >
android:orientation="@integer/widget_config_orientation" >
<FrameLayout
android:layout_width="@dimen/widget_preview_width"
@ -35,8 +34,10 @@ @@ -35,8 +34,10 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_light"
android:fillViewport="true"
android:orientation="vertical" >
android:paddingLeft="@dimen/margin_default"
android:paddingRight="@dimen/margin_default" >
<LinearLayout
android:layout_width="match_parent"
@ -54,22 +55,26 @@ @@ -54,22 +55,26 @@
<Spinner
android:id="@+id/server_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_half" />
<Spinner
android:id="@+id/filter_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_default" />
<Spinner
android:id="@+id/sort_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_default" />
<CheckBox
android:id="@+id/reverseorder_check_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_half"
android:text="@string/widget_reversesortorder" />
<TextView
@ -84,6 +89,8 @@ @@ -84,6 +89,8 @@
android:id="@+id/darktheme_check_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_half"
android:layout_marginTop="@dimen/margin_half"
android:text="@string/widget_usedarktheme" />
</LinearLayout>
</ScrollView>

67
core/res/layout-v11/widget_torrents_dark.xml

@ -2,63 +2,78 @@ @@ -2,63 +2,78 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_dark"
android:padding="@dimen/margin_widget" >
<ImageButton
android:id="@+id/icon_image"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@drawable/selectable_background_transdroid2"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/selectable_background_transdroid"
android:contentDescription="@string/widget_opentransdroid"
android:padding="8dp"
android:src="@drawable/ic_launcher"
android:scaleType="fitXY" />
android:padding="4dp"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<include
android:id="@+id/status_view"
<LinearLayout
android:id="@+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_toRightOf="@id/icon_image"
android:background="@drawable/selectable_background_transdroid"
android:clickable="true"
android:orientation="vertical"
android:paddingTop="2dp"
android:paddingRight="@dimen/margin_half" >
<TextView
android:id="@+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentRight="true"
layout="@layout/actionbar_serverstatus"
android:background="@drawable/selectable_background_transdroid2" />
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"
android:textColor="@color/text_actionbar_dark"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_filter" />
<include
android:id="@+id/navigation_view"
<TextView
android:id="@+id/server_text"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_toLeftOf="@id/navigation_view"
android:layout_toRightOf="@id/icon_image"
layout="@layout/actionbar_navigation"
android:background="@color/background_light" />
android:layout_height="wrap_content"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:textColor="@color/text_actionbar_dark"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_server" />
</LinearLayout>
<View
android:id="@+id/topline_view"
android:layout_height="2dp"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/icon_image"
android:background="@color/green" />
<View
android:id="@+id/bottomline_view"
android:layout_height="2dp"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="@color/green" />
<com.actionbarsherlock.view.SherlockListView
<ListView
android:id="@+id/torrents_list"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/topline_view"
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_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/topline_view"
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"

63
core/res/layout-v11/widget_torrents_light.xml

@ -2,63 +2,78 @@ @@ -2,63 +2,78 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="48dp"
android:layout_height="48dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/selectable_background_transdroid2"
android:contentDescription="@string/widget_opentransdroid"
android:padding="8dp"
android:src="@drawable/ic_launcher"
android:scaleType="fitXY" />
android:padding="4dp"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
<include
android:id="@+id/status_view"
<LinearLayout
android:id="@+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_toRightOf="@id/icon_image"
android:background="@drawable/selectable_background_transdroid2"
android:clickable="true"
android:orientation="vertical"
android:paddingTop="2dp"
android:paddingRight="@dimen/margin_half" >
<TextView
android:id="@+id/filter_text"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentRight="true"
layout="@layout/actionbar_serverstatus"
android:background="@drawable/selectable_background_transdroid2" />
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed"
android:textColor="@color/text_actionbar_light"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_filter" />
<include
android:id="@+id/navigation_view"
<TextView
android:id="@+id/server_text"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_toLeftOf="@id/navigation_view"
android:layout_toRightOf="@id/icon_image"
layout="@layout/actionbar_navigation"
android:background="@color/background_light" />
android:layout_height="wrap_content"
android:layout_marginTop="-4dip"
android:fontFamily="sans-serif-light"
android:textColor="@color/text_actionbar_light"
android:textIsSelectable="false"
android:textSize="@dimen/ui_navigation_server" />
</LinearLayout>
<View
android:id="@+id/topline_view"
android:layout_height="2dp"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/icon_image"
android:background="@color/green" />
<View
android:id="@+id/bottomline_view"
android:layout_height="2dp"
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_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/topline_view"
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_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/topline_view"
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"

2
core/res/values-sw600dp/dimens.xml

@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
<!-- Widget configuration -->
<integer name="widget_config_orientation">0</integer>
<dimen name="widget_preview_padding">15dp</dimen>
<dimen name="widget_preview_padding">30dp</dimen>
<dimen name="widget_preview_height">-1dp</dimen>
<dimen name="widget_preview_width">300dp</dimen>

4
core/res/values/dimens.xml

@ -43,8 +43,8 @@ @@ -43,8 +43,8 @@
<!-- Widget configuration -->
<integer name="widget_config_orientation">1</integer>
<dimen name="widget_preview_padding">10dp</dimen>
<dimen name="widget_preview_height">150dp</dimen>
<dimen name="widget_preview_padding">20dp</dimen>
<dimen name="widget_preview_height">200dp</dimen>
<dimen name="widget_preview_width">-1dp</dimen>
</resources>

14
core/res/values/styles.xml

@ -17,10 +17,10 @@ @@ -17,10 +17,10 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="TransdroidTheme" parent="Theme.Transdroid.Light">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:textViewStyle">@style/DefaultTextView</item>
<item name="android:windowBackground">@color/background_light</item>
<item name="ic_action_discard">@drawable/ic_action_discard_light</item>
<item name="ic_action_done">@drawable/ic_action_done_light</item>
<item name="ic_action_filter">@drawable/ic_action_filter_light</item>
@ -49,10 +49,10 @@ @@ -49,10 +49,10 @@
</style>
<style name="TransdroidTheme.Dark" parent="Theme.Transdroid.Dark">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:textViewStyle">@style/DefaultTextView</item>
<item name="android:windowBackground">@color/background_dark</item>
<item name="ic_action_discard">@drawable/ic_action_discard_dark</item>
<item name="ic_action_done">@drawable/ic_action_done_dark</item>
<item name="ic_action_filter">@drawable/ic_action_filter_dark</item>
@ -80,6 +80,16 @@ @@ -80,6 +80,16 @@
<item name="text_actionbar">@color/text_actionbar_dark</item>
</style>
<!-- No theme background to let users wall paper shine through -->
<!-- Inspired by NoNonsenseNotes's ThemeWidgetConfig -->
<style name="TransdroidTheme.WidgetConfig" parent="@style/TransdroidTheme">
<item name="android:background">@null</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<!-- Taken from http://stackoverflow.com/questions/10020466/android-4-0-sub-title-section-label-styling -->
<style name="SectionHeader" parent="android:Widget.Holo.Light.TextView">
<item name="android:drawableBottom">@drawable/section_header</item>

28
core/src/org/transdroid/core/widget/WidgetConfigActivity.java

@ -30,7 +30,6 @@ import org.androidannotations.annotations.ViewById; @@ -30,7 +30,6 @@ import org.androidannotations.annotations.ViewById;
import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.lists.SimpleListItem;
import org.transdroid.core.gui.lists.SortByListItem;
import org.transdroid.core.gui.lists.TorrentsAdapter;
@ -58,12 +57,12 @@ import android.view.View.OnClickListener; @@ -58,12 +57,12 @@ import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.SherlockListView;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@EActivity(resName = "activity_widgetconfig")
@ -77,7 +76,7 @@ public class WidgetConfigActivity extends SherlockActivity { @@ -77,7 +76,7 @@ public class WidgetConfigActivity extends SherlockActivity {
@ViewById
protected TextView filterText, serverText, errorText;
@ViewById
protected SherlockListView torrentsList;
protected ListView torrentsList;
@Bean
protected TorrentsAdapter previewTorrentsAdapter;
private List<Torrent> previewTorrents = null;
@ -92,25 +91,20 @@ public class WidgetConfigActivity extends SherlockActivity { @@ -92,25 +91,20 @@ public class WidgetConfigActivity extends SherlockActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// Set the theme according to the user preference
if (SystemSettings_.getInstance_(this).useDarkTheme()) {
setTheme(R.style.TransdroidTheme_Dark);
getSupportActionBar().setIcon(R.drawable.ic_activity_torrents);
}
super.onCreate(savedInstanceState);
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));
finish();
}
if (getIntent() != null && getIntent().getExtras() != null) {
// Get the appwidget ID we are configuring
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));
}
// Invalid configuration; return canceled result
setResult(RESULT_CANCELED,
new Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID));
finish();
}
@ -122,6 +116,7 @@ public class WidgetConfigActivity extends SherlockActivity { @@ -122,6 +116,7 @@ public class WidgetConfigActivity extends SherlockActivity {
for (TorrentsSortBy order : TorrentsSortBy.values()) {
sortOrders.add(new SortByListItem(order));
}
serverSpinner.setAdapter(new FilterListItemAdapter(this, applicationSettings.getServerSettings()));
filterSpinner.setAdapter(new FilterListItemAdapter(this, StatusType.getAllStatusTypes(this)));
sortSpinner.setAdapter(new FilterListItemAdapter(this, sortOrders));
@ -254,7 +249,8 @@ public class WidgetConfigActivity extends SherlockActivity { @@ -254,7 +249,8 @@ public class WidgetConfigActivity extends SherlockActivity {
// Return the widget configuration result
AppWidgetManager manager = AppWidgetManager.getInstance(WidgetConfigActivity.this);
manager.updateAppWidget(appWidgetId, WidgetProvider.buildRemoteViews(getApplicationContext(), appWidgetId, config));
manager.updateAppWidget(appWidgetId,
WidgetProvider.buildRemoteViews(getApplicationContext(), appWidgetId, config));
manager.notifyAppWidgetViewDataChanged(appWidgetId, R.id.torrents_list);
setResult(RESULT_OK, new Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId));
finish();

5
full/AndroidManifest.xml

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.transdroid.full"
android:versionCode="5"
android:versionName="2.0-beta1" >
android:versionCode="6"
android:versionName="2.0" >
<uses-sdk
android:minSdkVersion="7"
@ -250,6 +250,7 @@ @@ -250,6 +250,7 @@
<!-- Home screen widget -->
<activity
android:name="org.transdroid.core.widget.WidgetConfigActivity_"
android:theme="@style/TransdroidTheme.WidgetConfig"
android:enabled="@bool/widget_available" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />

5
lite/AndroidManifest.xml

@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.transdroid.lite"
android:versionCode="5"
android:versionName="2.0-beta1" >
android:versionCode="6"
android:versionName="2.0" >
<uses-sdk
android:minSdkVersion="7"
@ -217,6 +217,7 @@ @@ -217,6 +217,7 @@
<receiver
android:name="org.transdroid.core.widget.WidgetProvider_"
android:theme="@style/TransdroidTheme.WidgetConfig"
android:enabled="@bool/widget_available" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />

Loading…
Cancel
Save