Code style fixes

This commit is contained in:
cketti 2017-02-14 01:53:28 +01:00
parent 6415f0c186
commit 57612c317e
9 changed files with 163 additions and 135 deletions

View file

@ -363,21 +363,22 @@
android:resource="@xml/unread_widget_info"/>
</receiver>
<receiver android:name=".widget.list.MailListViewWidgetProvider"
android:icon="@drawable/mail_list_widget_icon"
android:label="@string/mail_list_widget_text">
<receiver
android:name=".widget.list.MailListViewWidgetProvider"
android:icon="@drawable/mail_list_widget_icon"
android:label="@string/mail_list_widget_text">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/mail_list_view_widget_layout_info"/>
android:name="android.appwidget.provider"
android:resource="@xml/mail_list_view_widget_layout_info" />
</receiver>
<service android:name=".widget.list.MailListViewWidgetService"
android:enabled="true"
android:permission="android.permission.BIND_REMOTEVIEWS"/>
<service
android:name=".widget.list.MailListViewWidgetService"
android:enabled="true"
android:permission="android.permission.BIND_REMOTEVIEWS" />
<service
android:name=".service.MailService"

View file

@ -1,23 +1,26 @@
package com.fsck.k9.widget.list;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.*;
import android.os.Binder;
import android.view.View;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import com.fsck.k9.R;
import com.fsck.k9.provider.MessageProvider;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Binder;
import android.view.View;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import com.fsck.k9.R;
import com.fsck.k9.provider.MessageProvider;
public class MailListRemoteViewFactory implements RemoteViewsService.RemoteViewsFactory {
private static String [] MAIL_LIST_PROJECTIONS = {
private static String[] MAIL_LIST_PROJECTIONS = {
MessageProvider.MessageColumns._ID,
MessageProvider.MessageColumns.SENDER,
MessageProvider.MessageColumns.SEND_DATE,
@ -28,10 +31,12 @@ public class MailListRemoteViewFactory implements RemoteViewsService.RemoteViews
MessageProvider.MessageColumns.URI
};
private Context context;
private ArrayList<MailItem> mailItems;
private int count;
public MailListRemoteViewFactory(Context context) {
this.context = context;
}
@ -129,7 +134,11 @@ public class MailListRemoteViewFactory implements RemoteViewsService.RemoteViews
return true;
}
private static class MailItem {
private static Calendar cl = Calendar.getInstance();
private String id;
private String date;
private String sender;
@ -139,10 +148,9 @@ public class MailListRemoteViewFactory implements RemoteViewsService.RemoteViews
private String hasAttachment;
private String uri;
private static Calendar cl = Calendar.getInstance();
public MailItem(String id, String sender, String date, String subject,
String preview, String unread, String hasAttachment, String uri) {
public MailItem(String id, String sender, String date, String subject, String preview, String unread,
String hasAttachment, String uri) {
this.id = id;
this.sender = sender;
this.date = date;

View file

@ -1,24 +1,25 @@
package com.fsck.k9.widget.list;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import com.fsck.k9.BaseAccount;
import com.fsck.k9.R;
import com.fsck.k9.activity.AccountList;
public class MailListViewWidgetConfiguration extends AccountList {
private static final String PREFS_NAME = "mail_list_view_widget_configuration.xml";
private static final String PREF_PREFIX_KEY = "mail_list_view_widget.";
private int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
private static void saveAccountUuid(Context context, int appWidgetId, String accountUuid) {
SharedPreferences.Editor editor =
context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE).edit();
@ -45,8 +46,7 @@ public class MailListViewWidgetConfiguration extends AccountList {
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null) {
appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
// If they gave us an intent without the widget ID, just bail.
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
@ -68,7 +68,8 @@ public class MailListViewWidgetConfiguration extends AccountList {
saveAccountUuid(this, appWidgetId, accountUuid);
// Update widget
Context context = getApplicationContext();
MailListViewWidgetProvider.updateAppWidget(context, AppWidgetManager.getInstance(context), appWidgetId, accountUuid);
MailListViewWidgetProvider.updateAppWidget(
context, AppWidgetManager.getInstance(context), appWidgetId, accountUuid);
// Let the caller know that the configuration was successful
Intent resultValue = new Intent();

View file

@ -1,5 +1,6 @@
package com.fsck.k9.widget.list;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
@ -8,6 +9,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.RemoteViews;
import com.fsck.k9.Account;
import com.fsck.k9.Preferences;
import com.fsck.k9.R;
@ -17,7 +19,6 @@ import com.fsck.k9.activity.MessageList;
public class MailListViewWidgetProvider extends AppWidgetProvider {
public static final String PACKAGE_NAME = "com.fsck.k9";
public static String ACTION_VIEW_MAIL_ITEM = PACKAGE_NAME + ".provider.ACTION_VIEW_MAIL_ITEM";
public static String ACTION_COMPOSE_EMAIL = PACKAGE_NAME + ".provider.ACTION_COMPOSE_EMAIL";
@ -26,7 +27,7 @@ public class MailListViewWidgetProvider extends AppWidgetProvider {
Context appContext = context.getApplicationContext();
AppWidgetManager widgetManager = AppWidgetManager.getInstance(appContext);
ComponentName widget = new ComponentName(appContext, MailListViewWidgetProvider.class);
int [] widgetIds = widgetManager.getAppWidgetIds(widget);
int[] widgetIds = widgetManager.getAppWidgetIds(widget);
Intent intent = new Intent(context, MailListViewWidgetProvider.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
@ -34,7 +35,8 @@ public class MailListViewWidgetProvider extends AppWidgetProvider {
context.sendBroadcast(intent);
}
public static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, String acc) {
public static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId,
String acc) {
CharSequence widgetText = context.getString(R.string.mail_list_widget_text);
Account account = Preferences.getPreferences(context).getAccount(acc);
@ -78,7 +80,6 @@ public class MailListViewWidgetProvider extends AppWidgetProvider {
@Override
public void onReceive(Context context, Intent intent) {
// an intent from an item on the listview. get the uri and launch the MessageList activity
if (intent.getAction().equals(ACTION_VIEW_MAIL_ITEM)) {
Intent viewMailIntent = new Intent(context, MessageList.class);
@ -87,9 +88,8 @@ public class MailListViewWidgetProvider extends AppWidgetProvider {
viewMailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(viewMailIntent);
} else if (intent.getAction().equals(AppWidgetManager.ACTION_APPWIDGET_UPDATE)) {
AppWidgetManager.getInstance(context)
.notifyAppWidgetViewDataChanged(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS),
R.id.listView);
AppWidgetManager.getInstance(context).notifyAppWidgetViewDataChanged(
intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), R.id.listView);
} else if (intent.getAction().equals(ACTION_COMPOSE_EMAIL)) {
Intent newMessage = new Intent(context, MessageCompose.class)
.putExtra(MessageCompose.EXTRA_ACCOUNT, intent.getStringExtra(MessageCompose.EXTRA_ACCOUNT))
@ -98,7 +98,7 @@ public class MailListViewWidgetProvider extends AppWidgetProvider {
context.startActivity(newMessage);
}
}
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
for (int widgId : appWidgetIds) {
@ -106,4 +106,3 @@ public class MailListViewWidgetProvider extends AppWidgetProvider {
}
}
}

View file

@ -1,11 +1,11 @@
package com.fsck.k9.widget.list;
import android.content.Intent;
import android.widget.RemoteViewsService;
public class MailListViewWidgetService extends RemoteViewsService {
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {
return new MailListRemoteViewFactory(this.getApplicationContext());

View file

@ -1,55 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mail_list_item"
android:padding="@dimen/widget_padding"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/mail_list_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/widget_padding">
<TextView android:id="@+id/sender"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="start"
android:textSize="16sp"/>
<TextView
android:id="@+id/sender"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_centerVertical="true"
android:layout_gravity="start"
android:textSize="16sp" />
<ImageView android:id="@+id/attachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_email_attachment_small"
android:visibility="gone"
android:layout_centerInParent="true"
android:layout_toLeftOf="@+id/mail_date"
android:layout_toStartOf="@+id/mail_date"
android:layout_alignBottom="@+id/mail_date"/>
<ImageView
android:id="@+id/attachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/mail_date"
android:layout_centerInParent="true"
android:layout_toLeftOf="@+id/mail_date"
android:layout_toStartOf="@+id/mail_date"
android:src="@drawable/ic_email_attachment_small"
android:visibility="gone" />
<TextView android:id="@+id/mail_date"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBaseline="@+id/sender"
android:layout_centerVertical="true"/>
<TextView
android:id="@+id/mail_date"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignBaseline="@+id/sender"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true" />
<TextView android:id="@+id/mail_subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:paddingBottom="2dp"
android:singleLine="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/sender"/>
<TextView
android:id="@+id/mail_subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/sender"
android:paddingBottom="2dp"
android:singleLine="true"
android:textSize="15sp" />
<TextView android:id="@+id/mail_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="13sp"
android:singleLine="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/mail_subject"/>
<TextView
android:id="@+id/mail_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/mail_subject"
android:singleLine="true"
android:textSize="13sp" />
</RelativeLayout>

View file

@ -1,8 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:id="@+id/loadingText" android:textColor="@android:color/black" android:textSize="18sp" android:layout_width="match_parent" android:layout_height="match_parent"/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<TextView
android:id="@+id/loadingText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@android:color/black"
android:textSize="18sp" />
</LinearLayout>

View file

@ -1,48 +1,56 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/top_controls"
android:layout_width="match_parent"
android:id="@+id/top_controls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/light_grey"
android:orientation="horizontal"
android:padding="@dimen/widget_padding">
<TextView
android:id="@+id/folder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="@dimen/widget_padding"
android:background="@color/light_grey">
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textSize="18sp" />
<TextView android:id="@+id/folder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:id="@+id/mail_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/folder"
android:textSize="15sp" />
<TextView android:id="@+id/mail_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/folder"/>
<ImageButton
android:id="@+id/new_message"
style="?android:attr/borderlessButtonStyle"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/mail_address"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_action_compose_dark" />
<ImageButton android:id="@+id/new_message"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_compose_dark"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/mail_address"
style="?android:attr/borderlessButtonStyle"/>
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical">
<ListView android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white">
<ListView android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp"
android:divider="@color/light_grey"/>
android:divider="@color/light_grey"
android:dividerHeight="1dp" />
</LinearLayout>
</LinearLayout>

View file

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="250dp"
android:minHeight="180dp"
android:updatePeriodMillis="86400000"
android:previewImage="@drawable/mail_list_widget_icon"
android:configure="com.fsck.k9.widget.list.MailListViewWidgetConfiguration"
android:initialLayout="@layout/mail_list_view_widget_layout"
android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen|keyguard"
android:initialKeyguardLayout="@layout/mail_list_view_widget_layout">
android:configure="com.fsck.k9.widget.list.MailListViewWidgetConfiguration"
android:initialKeyguardLayout="@layout/mail_list_view_widget_layout"
android:initialLayout="@layout/mail_list_view_widget_layout"
android:minHeight="180dp"
android:minWidth="250dp"
android:previewImage="@drawable/mail_list_widget_icon"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="86400000"
android:widgetCategory="home_screen|keyguard">
</appwidget-provider>