bring widget up to holo ui standards (lol)

This commit is contained in:
Andrew Dolgov 2015-02-12 22:19:17 +03:00
parent 7d3dc5900b
commit bd75699773
11 changed files with 48 additions and 37 deletions

View File

@ -1,14 +1,5 @@
package org.fox.ttrss.widget;
import java.util.HashMap;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.R;
import org.fox.ttrss.util.SimpleLoginManager;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
@ -17,9 +8,17 @@ import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.View;
import android.widget.RemoteViews;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.fox.ttrss.ApiRequest;
import org.fox.ttrss.R;
import org.fox.ttrss.util.SimpleLoginManager;
import java.util.HashMap;
public class WidgetUpdateService extends Service {
private final String TAG = this.getClass().getSimpleName();
@ -51,8 +50,7 @@ public class WidgetUpdateService extends Service {
final AppWidgetManager manager = AppWidgetManager.getInstance(this);
try {
view.setTextViewText(R.id.counter, String.valueOf(""));
view.setViewVisibility(R.id.progress, View.VISIBLE);
view.setTextViewText(R.id.counter, String.valueOf("..."));
manager.updateAppWidget(thisWidget, view);
@ -80,7 +78,6 @@ public class WidgetUpdateService extends Service {
if (content != null) {
int unread = content.get("unread").getAsInt();
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, String.valueOf(unread));
manager.updateAppWidget(thisWidget, view);
@ -91,7 +88,6 @@ public class WidgetUpdateService extends Service {
}
}
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, "?");
manager.updateAppWidget(thisWidget, view);
}
@ -112,7 +108,6 @@ public class WidgetUpdateService extends Service {
@Override
protected void onLoginFailed(int requestId, ApiRequest ar) {
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, "?");
manager.updateAppWidget(thisWidget, view);
}
@ -132,7 +127,6 @@ public class WidgetUpdateService extends Service {
} catch (Exception e) {
e.printStackTrace();
view.setViewVisibility(R.id.progress, View.GONE);
view.setTextViewText(R.id.counter, getString(R.string.app_name));
manager.updateAppWidget(thisWidget, view);

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,24 @@
<!--
Copyright 2011 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/appwidget_bg_pressed" android:state_pressed="true" />
<item android:drawable="@drawable/appwidget_dark_bg_focused"
android:state_focused="true"
android:state_enabled="true"
android:state_window_focused="true" />
<item android:drawable="@drawable/appwidget_dark_bg" />
</selector>

View File

@ -1,42 +1,34 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_main"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
android:padding="@dimen/widget_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:background="@drawable/appwidget_dark_bg_clickable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="110dp"
android:padding="8dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingTop="2dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:text="-1"
android:shadowColor="#cc000000"
android:shadowDx="0"
android:shadowDy="3"
android:shadowRadius="3"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:text="123"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/primary_text_dark" />
android:textColor="@android:color/primary_text_dark"
android:textSize="13sp" />
</LinearLayout>
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</FrameLayout>
</FrameLayout>

View File

@ -2,4 +2,5 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="widget_margin">0dp</dimen> <!-- we're v14+ anyway -->
</resources>

View File

@ -3,6 +3,6 @@
android:minHeight="40dp"
android:updatePeriodMillis="86400000"
android:initialLayout="@layout/widget_small"
android:resizeMode="horizontal|vertical"
android:resizeMode="none"
android:widgetCategory="home_screen">
</appwidget-provider>