supports app shortcuts

fixed npe
This commit is contained in:
Mariotaku Lee 2016-10-23 20:51:08 +08:00
parent af4477f765
commit e98200217a
10 changed files with 94 additions and 49 deletions

View File

@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.13.0'
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath('fr.avianey.androidsvgdrawable:gradle-plugin:3.0.0') {
@ -34,7 +34,7 @@ subprojects {
if (project.hasProperty('android')) {
android {
compileSdkVersion 24
compileSdkVersion 25
buildToolsVersion '24.0.1'
lintOptions {

View File

@ -39,7 +39,7 @@ dependencies {
apt 'com.bluelinelabs:logansquare-compiler:1.3.7'
apt 'com.hannesdorfmann.parcelableplease:processor:1.0.2'
apt 'com.github.mariotaku.ObjectCursor:processor:0.9.9'
compile 'com.android.support:support-annotations:24.2.1'
compile 'com.android.support:support-annotations:25.0.0'
compile 'com.bluelinelabs:logansquare:1.3.7'
compile 'com.github.mariotaku.RestFu:library:0.9.34'
compile 'com.github.mariotaku.RestFu:oauth:0.9.34'

View File

@ -34,7 +34,7 @@ android {
defaultConfig {
applicationId "org.mariotaku.twidere"
minSdkVersion 14
targetSdkVersion 24
targetSdkVersion 25
versionCode 212
versionName '3.2.8'
multiDexEnabled true
@ -120,17 +120,17 @@ dependencies {
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:24.2.1'
androidTestCompile 'com.android.support:support-annotations:25.0.0'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:preference-v7:24.2.1'
compile 'com.android.support:preference-v14:24.2.1'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:cardview-v7:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
compile 'com.android.support:preference-v7:25.0.0'
compile 'com.android.support:preference-v14:25.0.0'
compile 'com.twitter:twitter-text:1.13.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0'

View File

@ -119,6 +119,10 @@
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/compose_shortcuts"/>
</activity>
<activity
android:name=".activity.MainHondaJOJOActivity"
@ -135,6 +139,10 @@
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/compose_shortcuts"/>
</activity>
<activity
android:name=".activity.HomeActivity"
@ -171,6 +179,8 @@
<intent-filter android:label="@string/compose">
<action android:name="android.intent.action.MAIN"/>
<action android:name="org.mariotaku.twidere.COMPOSE"/>
<action android:name="org.mariotaku.twidere.COMPOSE_TAKE_PHOTO"/>
<action android:name="org.mariotaku.twidere.COMPOSE_PICK_IMAGE"/>
<action android:name="org.mariotaku.twidere.REPLY"/>
<action android:name="org.mariotaku.twidere.QUOTE"/>
<action android:name="org.mariotaku.twidere.EDIT_DRAFT"/>

View File

@ -20,6 +20,7 @@
package org.mariotaku.twidere.util;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.SparseIntArray;
import org.mariotaku.microblog.library.twitter.model.ErrorInfo;
@ -66,6 +67,7 @@ public class StatusCodeMessageUtils {
return TWITTER_ERROR_CODE_MESSAGES.get(code, -1) != -1;
}
@Nullable
public static String getHttpStatusMessage(final Context context, final int code) {
if (context == null) return null;
final int res_id = HTTP_STATUS_CODE_MESSAGES.get(code, -1);
@ -73,12 +75,14 @@ public class StatusCodeMessageUtils {
return null;
}
@Nullable
public static String getMessage(final Context context, final int statusCode, final int errorCode) {
if (containsHttpStatus(statusCode)) return getHttpStatusMessage(context, statusCode);
if (containsTwitterError(errorCode)) return getTwitterErrorMessage(context, errorCode);
return null;
}
@Nullable
public static String getTwitterErrorMessage(final Context context, final int code) {
if (context == null) return null;
final int resId = TWITTER_ERROR_CODE_MESSAGES.get(code, -1);

View File

@ -47,7 +47,6 @@ import android.net.Uri;
import android.nfc.NfcAdapter;
import android.nfc.NfcAdapter.CreateNdefMessageCallback;
import android.os.AsyncTask;
import android.os.BadParcelableException;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Bundle;
@ -59,7 +58,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.annotation.WorkerThread;
import android.support.v4.app.Fragment;
import android.support.v4.net.ConnectivityManagerCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
@ -109,38 +107,6 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.CopyLinkActivity;
import org.mariotaku.twidere.adapter.iface.IBaseAdapter;
import org.mariotaku.twidere.annotation.CustomTabType;
import org.mariotaku.twidere.fragment.AccountsManagerFragment;
import org.mariotaku.twidere.fragment.DirectMessagesFragment;
import org.mariotaku.twidere.fragment.DraftsFragment;
import org.mariotaku.twidere.fragment.FiltersFragment;
import org.mariotaku.twidere.fragment.GroupFragment;
import org.mariotaku.twidere.fragment.IncomingFriendshipsFragment;
import org.mariotaku.twidere.fragment.InteractionsTimelineFragment;
import org.mariotaku.twidere.fragment.ItemsListFragment;
import org.mariotaku.twidere.fragment.ListsFragment;
import org.mariotaku.twidere.fragment.MessagesConversationFragment;
import org.mariotaku.twidere.fragment.MutesUsersListFragment;
import org.mariotaku.twidere.fragment.PublicTimelineFragment;
import org.mariotaku.twidere.fragment.SavedSearchesListFragment;
import org.mariotaku.twidere.fragment.SearchFragment;
import org.mariotaku.twidere.fragment.StatusFavoritersListFragment;
import org.mariotaku.twidere.fragment.StatusFragment;
import org.mariotaku.twidere.fragment.StatusRetweetersListFragment;
import org.mariotaku.twidere.fragment.UserBlocksListFragment;
import org.mariotaku.twidere.fragment.UserFavoritesFragment;
import org.mariotaku.twidere.fragment.UserFollowersFragment;
import org.mariotaku.twidere.fragment.UserFragment;
import org.mariotaku.twidere.fragment.UserFriendsFragment;
import org.mariotaku.twidere.fragment.UserGroupsFragment;
import org.mariotaku.twidere.fragment.UserListFragment;
import org.mariotaku.twidere.fragment.UserListMembersFragment;
import org.mariotaku.twidere.fragment.UserListMembershipsFragment;
import org.mariotaku.twidere.fragment.UserListSubscribersFragment;
import org.mariotaku.twidere.fragment.UserListTimelineFragment;
import org.mariotaku.twidere.fragment.UserMediaTimelineFragment;
import org.mariotaku.twidere.fragment.UserMentionsFragment;
import org.mariotaku.twidere.fragment.UserProfileEditorFragment;
import org.mariotaku.twidere.fragment.UserTimelineFragment;
import org.mariotaku.twidere.graphic.PaddingDrawable;
import org.mariotaku.twidere.model.AccountPreferences;
import org.mariotaku.twidere.model.ParcelableAccount;
@ -647,12 +613,17 @@ public final class Utils implements Constants {
if (t instanceof MicroBlogException)
return getTwitterErrorMessage(context, action, (MicroBlogException) t);
else if (t != null) return getErrorMessage(context, trimLineBreak(t.getMessage()));
TwidereBugReporter.logException(new IllegalStateException());
return context.getString(R.string.error_unknown_error);
}
public static String getErrorMessage(final Context context, final Throwable t) {
if (t == null) return null;
if (context != null && t instanceof MicroBlogException)
@Nullable
public static String getErrorMessage(@NonNull final Context context, final Throwable t) {
if (t == null) {
TwidereBugReporter.logException(new IllegalStateException());
return context.getString(R.string.error_unknown_error);
}
if (t instanceof MicroBlogException)
return getTwitterErrorMessage(context, (MicroBlogException) t);
return t.getMessage();
}
@ -900,6 +871,7 @@ public final class Utils implements Constants {
return getErrorMessage(context, action, trimLineBreak(te.getMessage()));
}
@Nullable
public static String getTwitterErrorMessage(final Context context, final MicroBlogException te) {
if (te == null) return null;
if (StatusCodeMessageUtils.containsTwitterError(te.getErrorCode())) {

View File

@ -133,7 +133,8 @@ abstract class ParcelableStatusesFragment : AbsStatusesFragment() {
} else if (loader is MicroBlogAPIStatusesLoader) {
val e = loader.exception
if (e != null) {
showError(R.drawable.ic_info_error_generic, Utils.getErrorMessage(context, e))
showError(R.drawable.ic_info_error_generic, Utils.getErrorMessage(context, e) ?:
context.getString(R.string.error_unknown_error))
} else {
showEmpty(R.drawable.ic_info_refresh, getString(R.string.swipe_down_to_refresh))
}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:targetApi="n_mr1">
<shortcut
android:enabled="true"
android:icon="@drawable/ic_app_shortcut_compose"
android:shortcutId="compose"
android:shortcutLongLabel="@string/compose"
android:shortcutShortLabel="@string/compose">
<intent
android:action="org.mariotaku.twidere.COMPOSE"
android:targetClass="org.mariotaku.twidere.activity.ComposeActivity"
android:targetPackage="org.mariotaku.twidere"/>
</shortcut>
<shortcut
android:enabled="true"
android:icon="@drawable/ic_app_shortcut_camera"
android:shortcutId="compose-take-photo"
android:shortcutLongLabel="@string/take_photo"
android:shortcutShortLabel="@string/take_photo">
<intent
android:action="org.mariotaku.twidere.COMPOSE_TAKE_PHOTO"
android:targetClass="org.mariotaku.twidere.activity.ComposeActivity"
android:targetPackage="org.mariotaku.twidere"/>
</shortcut>
<!-- Specify more shortcuts here. -->
</shortcuts>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>ic_app_shortcut_camera-mdpi</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Miscellaneous" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="ic_app_shortcut_camera-mdpi">
<circle id="Oval-2" fill="#FAFAFA" cx="24" cy="24" r="24"></circle>
<g id="Group" transform="translate(14.000000, 15.000000)" fill="#55ACEE">
<circle id="Oval" cx="10" cy="10" r="3.2"></circle>
<path d="M7,0 L5.17,2 L2,2 C0.9,2 0,2.9 0,4 L0,16 C0,17.1 0.9,18 2,18 L18,18 C19.1,18 20,17.1 20,16 L20,4 C20,2.9 19.1,2 18,2 L14.83,2 L13,0 L7,0 L7,0 Z M10,15 C7.24,15 5,12.76 5,10 C5,7.24 7.24,5 10,5 C12.76,5 15,7.24 15,10 C15,12.76 12.76,15 10,15 L10,15 Z" id="Shape"></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 40.3 (33839) - http://www.bohemiancoding.com/sketch -->
<title>ic_app_shortcut_compose-mdpi</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Miscellaneous" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="ic_app_shortcut_compose-mdpi">
<circle id="Oval-2" fill="#FAFAFA" cx="24" cy="24" r="24"></circle>
<path d="M34.9691703,15.5269946 C34.5538589,15.5204967 34.0503207,16.1296754 34.4586385,16.5536638 C34.5812953,16.7594308 35.3500517,17.0123076 35.7922615,17.1563445 C35.4113801,17.7860999 32.8393544,18.3606231 31.9070557,17.9431327 C31.546617,17.7243698 30.8935237,18.2923951 31.226526,18.8604204 C31.3421891,19.0385713 32.3971446,19.8053242 32.8936892,20.1405079 C32.5402442,20.4556563 29.0638941,20.3435675 28.6340575,20.0175892 C28.1445065,19.8394382 27.5317608,20.4004241 27.8857438,20.8866841 L30.1269191,22.4337272 C29.9364784,22.8474273 26.8211049,24.353317 26.0163046,24.3912214 C25.3239396,23.939617 23.8924064,23.9109179 22.9660252,24.3912214 C21.9186013,24.9180933 19.6542934,26.9698071 18.5875026,28.4567446 C18.2507345,29.1157406 17.4088144,29.850004 15.7152907,30.3768759 C20.995448,21.9063139 30.7751707,13.9252608 37,14.0005282 C36.983323,14.7537438 35.8062487,15.4517272 34.9691703,15.5269946 L34.9691703,15.5269946 Z M21.9417339,18.5490624 L13.9932547,18.5490624 C13.6930685,18.5490624 13.4386096,18.5820934 13.4386096,18.9102377 L13.4386096,31.1750353 C13.4386096,31.3916322 13.5591144,31.6174344 13.7931306,31.6174344 L25.5859301,31.6174344 C25.9194703,31.6174344 25.9194703,31.4988477 25.9194703,31.3104084 L25.9194703,28.1697538 C26.3218705,28.6121529 28.255328,27.9022567 28.3586178,27.5259196 L28.3586178,31.8340313 C28.3586178,32.8406653 27.4198634,34 26.2782951,34 L13.1518725,34 C12.1039106,34 11,32.9446318 11,31.8340313 L11,18.2604471 C11,17.2814292 12.0221395,16.2390568 13.1518725,16.2390568 L23.9349059,16.2390568 C22.8939375,17.1081517 22.8035589,17.5565073 21.9417339,18.5490624 L21.9417339,18.5490624 Z" id="未命名-#1" fill="#55ACEE"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB