fixed interactions notification count

updated library version
This commit is contained in:
Mariotaku Lee 2016-02-01 22:31:11 +08:00
parent 95354b3e5c
commit aee9bab7b4
5 changed files with 19 additions and 25 deletions

View File

@ -43,7 +43,7 @@ dependencies {
compile 'com.android.support:support-v4:23.1.1' compile 'com.android.support:support-v4:23.1.1'
compile 'com.bluelinelabs:logansquare:1.3.4' compile 'com.bluelinelabs:logansquare:1.3.4'
compile 'org.apache.commons:commons-lang3:3.4' compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.github.mariotaku.RestFu:library:0.9.13' compile 'com.github.mariotaku.RestFu:library:0.9.14'
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.2' compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.2'
compile 'com.github.mariotaku.SQLiteQB:library:0.9.3' compile 'com.github.mariotaku.SQLiteQB:library:0.9.3'
compile 'com.github.mariotaku.ObjectCursor:core:0.9.3' compile 'com.github.mariotaku.ObjectCursor:core:0.9.3'

View File

@ -108,8 +108,8 @@ dependencies {
compile 'com.soundcloud.android:android-crop:1.0.1@aar' compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.2' compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.2'
compile 'com.github.mariotaku:PickNCrop:0.9.2' compile 'com.github.mariotaku:PickNCrop:0.9.2'
compile 'com.github.mariotaku.RestFu:library:0.9.13' compile 'com.github.mariotaku.RestFu:library:0.9.15'
compile 'com.github.mariotaku.RestFu:okhttp:0.9.13' compile 'com.github.mariotaku.RestFu:okhttp:0.9.15'
compile 'com.github.mariotaku:InetAddressJni:0.9.1' compile 'com.github.mariotaku:InetAddressJni:0.9.1'
compile 'com.lnikkila:extendedtouchview:0.1.0' compile 'com.lnikkila:extendedtouchview:0.1.0'
compile 'com.google.dagger:dagger:2.0.2' compile 'com.google.dagger:dagger:2.0.2'

View File

@ -1335,15 +1335,11 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
applyNotificationPreferences(builder, pref, pref.getHomeTimelineNotificationType()); applyNotificationPreferences(builder, pref, pref.getHomeTimelineNotificationType());
final Resources resources = context.getResources(); final Resources resources = context.getResources();
final String title = resources.getQuantityString(R.plurals.N_new_interactions,
count, count);
final String accountName = DataStoreUtils.getAccountDisplayName(context, accountId, mNameFirst); final String accountName = DataStoreUtils.getAccountDisplayName(context, accountId, mNameFirst);
builder.setContentTitle(title);
builder.setContentText(accountName); builder.setContentText(accountName);
final InboxStyle style = new InboxStyle(); final InboxStyle style = new InboxStyle();
builder.setStyle(style); builder.setStyle(style);
builder.setAutoCancel(true); builder.setAutoCancel(true);
style.setBigContentTitle(title);
style.setSummaryText(accountName); style.setSummaryText(accountName);
final ParcelableActivityCursorIndices ci = new ParcelableActivityCursorIndices(c); final ParcelableActivityCursorIndices ci = new ParcelableActivityCursorIndices(c);
int messageLines = 0; int messageLines = 0;
@ -1382,6 +1378,12 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
messageLines++; messageLines++;
} }
} }
if (messageLines == 0) return;
final int displayCount = messageLines + count - c.getPosition();
final String title = resources.getQuantityString(R.plurals.N_new_interactions,
displayCount, displayCount);
builder.setContentTitle(title);
style.setBigContentTitle(title);
builder.setContentIntent(getContentIntent(context, CustomTabType.NOTIFICATIONS_TIMELINE, builder.setContentIntent(getContentIntent(context, CustomTabType.NOTIFICATIONS_TIMELINE,
NotificationType.INTERACTIONS, accountId)); NotificationType.INTERACTIONS, accountId));
if (timestamp != -1) { if (timestamp != -1) {

View File

@ -42,7 +42,7 @@ import org.mariotaku.restfu.http.Endpoint;
import org.mariotaku.restfu.http.HttpRequest; import org.mariotaku.restfu.http.HttpRequest;
import org.mariotaku.restfu.http.HttpResponse; import org.mariotaku.restfu.http.HttpResponse;
import org.mariotaku.restfu.http.MultiValueMap; import org.mariotaku.restfu.http.MultiValueMap;
import org.mariotaku.restfu.http.mime.BaseBody; import org.mariotaku.restfu.http.mime.SimpleBody;
import org.mariotaku.restfu.http.mime.FormBody; import org.mariotaku.restfu.http.mime.FormBody;
import org.mariotaku.restfu.okhttp.OkHttpRestClient; import org.mariotaku.restfu.okhttp.OkHttpRestClient;
import org.mariotaku.twidere.Constants; import org.mariotaku.twidere.Constants;
@ -231,7 +231,7 @@ public class OAuthPasswordAuthenticator implements Constants {
} }
} }
}; };
PARSER.parse(BaseBody.reader(response.getBody()), handler); PARSER.parse(SimpleBody.reader(response.getBody()), handler);
} }
private AuthorizeResponseData getAuthorizeResponseData(OAuthToken requestToken, private AuthorizeResponseData getAuthorizeResponseData(OAuthToken requestToken,
@ -361,7 +361,7 @@ public class OAuthPasswordAuthenticator implements Constants {
} }
} }
}; };
PARSER.parse(BaseBody.reader(response.getBody()), handler); PARSER.parse(SimpleBody.reader(response.getBody()), handler);
return data; return data;
} catch (AttoParseException e) { } catch (AttoParseException e) {
throw new AuthenticationException("Malformed HTML", e); throw new AuthenticationException("Malformed HTML", e);

View File

@ -14,6 +14,7 @@ import android.webkit.URLUtil;
import org.mariotaku.restfu.ExceptionFactory; import org.mariotaku.restfu.ExceptionFactory;
import org.mariotaku.restfu.RestAPIFactory; import org.mariotaku.restfu.RestAPIFactory;
import org.mariotaku.restfu.RestClient; import org.mariotaku.restfu.RestClient;
import org.mariotaku.restfu.RestConverter;
import org.mariotaku.restfu.RestRequest; import org.mariotaku.restfu.RestRequest;
import org.mariotaku.restfu.http.Authorization; import org.mariotaku.restfu.http.Authorization;
import org.mariotaku.restfu.http.Endpoint; import org.mariotaku.restfu.http.Endpoint;
@ -21,8 +22,6 @@ import org.mariotaku.restfu.http.HttpRequest;
import org.mariotaku.restfu.http.HttpResponse; import org.mariotaku.restfu.http.HttpResponse;
import org.mariotaku.restfu.http.MultiValueMap; import org.mariotaku.restfu.http.MultiValueMap;
import org.mariotaku.restfu.http.SimpleValueMap; import org.mariotaku.restfu.http.SimpleValueMap;
import org.mariotaku.restfu.http.mime.BaseBody;
import org.mariotaku.restfu.http.mime.Body;
import org.mariotaku.sqliteqb.library.Expression; import org.mariotaku.sqliteqb.library.Expression;
import org.mariotaku.twidere.BuildConfig; import org.mariotaku.twidere.BuildConfig;
import org.mariotaku.twidere.TwidereConstants; import org.mariotaku.twidere.TwidereConstants;
@ -41,10 +40,10 @@ import org.mariotaku.twidere.api.twitter.auth.OAuthToken;
import org.mariotaku.twidere.api.twitter.util.TwitterConverterFactory; import org.mariotaku.twidere.api.twitter.util.TwitterConverterFactory;
import org.mariotaku.twidere.model.ConsumerKeyType; import org.mariotaku.twidere.model.ConsumerKeyType;
import org.mariotaku.twidere.model.ParcelableCredentials; import org.mariotaku.twidere.model.ParcelableCredentials;
import org.mariotaku.twidere.model.RequestType;
import org.mariotaku.twidere.provider.TwidereDataStore; import org.mariotaku.twidere.provider.TwidereDataStore;
import org.mariotaku.twidere.util.dagger.DependencyHolder; import org.mariotaku.twidere.util.dagger.DependencyHolder;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -250,15 +249,6 @@ public class TwitterAPIFactory implements TwidereConstants {
return new EmptyAuthorization(); return new EmptyAuthorization();
} }
private static void addParam(MultiValueMap<String> params, String name, Object value) {
params.add(name, String.valueOf(value));
}
private static void addPart(MultiValueMap<Body> params, String name, Object value) {
final Body typedData = BaseBody.wrap(value);
params.add(name, typedData);
}
public static boolean verifyApiFormat(@NonNull String format) { public static boolean verifyApiFormat(@NonNull String format) {
return URLUtil.isValidUrl(getApiBaseUrl(format, "test")); return URLUtil.isValidUrl(getApiBaseUrl(format, "test"));
} }
@ -421,8 +411,10 @@ public class TwitterAPIFactory implements TwidereConstants {
} }
@Override @Override
public HttpRequest create(@NonNull Endpoint endpoint, @NonNull RestRequest info, public <E extends Exception> HttpRequest create(@NonNull Endpoint endpoint, @NonNull RestRequest info,
@Nullable Authorization authorization) { @Nullable Authorization authorization,
RestConverter.Factory<E> converterFactory)
throws IOException, RestConverter.ConvertException, E {
final String restMethod = info.getMethod(); final String restMethod = info.getMethod();
final String url = Endpoint.constructUrl(endpoint.getUrl(), info); final String url = Endpoint.constructUrl(endpoint.getUrl(), info);
MultiValueMap<String> headers = info.getHeaders(); MultiValueMap<String> headers = info.getHeaders();
@ -434,7 +426,7 @@ public class TwitterAPIFactory implements TwidereConstants {
headers.add("Authorization", authorization.getHeader(endpoint, info)); headers.add("Authorization", authorization.getHeader(endpoint, info));
} }
headers.add("User-Agent", userAgent); headers.add("User-Agent", userAgent);
return new HttpRequest(restMethod, url, headers, info.getBody(), RequestType.API); return new HttpRequest(restMethod, url, headers, info.getBody(converterFactory), null);
} }
} }