mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-30 16:35:00 +01:00
fixed a stupid bug cause send tweet longer than 15 seconds
bug fixes
This commit is contained in:
parent
4f34fb4780
commit
e7d013bb12
@ -15,4 +15,4 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
org.gradle.parallel=true
|
||||
# org.gradle.parallel=true
|
||||
|
@ -294,7 +294,7 @@ public class MediaEntityJSONImpl implements MediaEntity {
|
||||
variants = VariantJSONImpl.fromJSONArray(json.getJSONArray("variants"));
|
||||
final JSONArray aspectRatioJson = json.getJSONArray("aspect_ratio");
|
||||
aspectRatio = new long[]{aspectRatioJson.getLong(0), aspectRatioJson.getLong(1)};
|
||||
duration = json.getLong("duration_millis");
|
||||
duration = json.optLong("duration_millis", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,7 @@ android {
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd")
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm")
|
||||
versionNameSuffix String.format(" (dev %s)", format.format(new Date()))
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ import android.support.v4.util.LongSparseArray;
|
||||
import android.support.v7.internal.view.SupportMenuInflater;
|
||||
import android.support.v7.widget.ActionMenuView;
|
||||
import android.support.v7.widget.ActionMenuView.OnMenuItemClickListener;
|
||||
import android.support.v7.widget.FixedLinearLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.Adapter;
|
||||
@ -105,9 +106,8 @@ import org.mariotaku.twidere.service.BackgroundOperationService;
|
||||
import org.mariotaku.twidere.task.TwidereAsyncTask;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.ContentValuesCreator;
|
||||
import android.support.v7.widget.FixedLinearLayoutManager;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MathUtils;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.ParseUtils;
|
||||
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
@ -1127,12 +1127,15 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
final int tweetLength = mValidator.getTweetLength(text), maxLength = mValidator.getMaxTweetLength();
|
||||
if (!mStatusShortenerUsed && tweetLength > maxLength) {
|
||||
mEditText.setError(getString(R.string.error_message_status_too_long));
|
||||
final int text_length = mEditText.length();
|
||||
mEditText.setSelection(text_length - (tweetLength - maxLength), text_length);
|
||||
final int textLength = mEditText.length();
|
||||
mEditText.setSelection(textLength - (tweetLength - maxLength), textLength);
|
||||
return;
|
||||
} else if (!hasMedia && (isEmpty(text) || noReplyContent(text))) {
|
||||
mEditText.setError(getString(R.string.error_message_no_content));
|
||||
return;
|
||||
} else if (mAccountsAdapter.isSelectionEmpty()) {
|
||||
mEditText.setError(getString(R.string.no_account_selected));
|
||||
return;
|
||||
}
|
||||
final boolean attachLocation = mPreferences.getBoolean(KEY_ATTACH_LOCATION, false);
|
||||
// if (mRecentLocation == null && attachLocation) {
|
||||
@ -1265,6 +1268,10 @@ public class ComposeActivity extends ThemedFragmentActivity implements TextWatch
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isSelectionEmpty() {
|
||||
return getSelectedAccountIds().length == 0;
|
||||
}
|
||||
|
||||
public void setSelectedAccountIds(long... accountIds) {
|
||||
mSelection.clear();
|
||||
if (accountIds != null) {
|
||||
|
@ -41,6 +41,7 @@ import android.view.View.OnLayoutChangeListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.diegocarloslima.byakugallery.lib.TileBitmapDrawable;
|
||||
import com.diegocarloslima.byakugallery.lib.TileBitmapDrawable.OnInitializeListener;
|
||||
@ -206,8 +207,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
||||
mVideoLoader = TwidereApplication.getInstance(getActivity()).getVideoLoader();
|
||||
final String url = getBestVideoUrl(getMedia());
|
||||
if (url != null) {
|
||||
// mVideoLoader.loadVideo(url, this);
|
||||
mWebView.loadUrl(url);
|
||||
mVideoLoader.loadVideo(url, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
||||
|
||||
@Override
|
||||
public void onVideoLoadingComplete(String uri, VideoLoadingListener listener, File file) {
|
||||
mWebView.loadUrl(Uri.fromFile(file).toString());
|
||||
Toast.makeText(getActivity(), String.format("%s length: %d", file, file.length()), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,7 +79,7 @@ public class MessageEntriesAdapter extends Adapter<ViewHolder> implements Consta
|
||||
mProfileImageStyle = Utils.getProfileImageStyle(preferences.getString(KEY_PROFILE_IMAGE_STYLE, null));
|
||||
mMediaPreviewStyle = Utils.getMediaPreviewStyle(preferences.getString(KEY_MEDIA_PREVIEW_STYLE, null));
|
||||
mTextSize = preferences.getInt(KEY_TEXT_SIZE, context.getResources().getInteger(R.integer.default_text_size));
|
||||
mReadStateManager = new ReadStateManager(context);
|
||||
mReadStateManager = app.getReadStateManager();
|
||||
mReadStateChangeListener = new OnSharedPreferenceChangeListener() {
|
||||
|
||||
@Override
|
||||
|
@ -51,6 +51,7 @@ import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MediaLoaderWrapper;
|
||||
import org.mariotaku.twidere.util.MessagesManager;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
import org.mariotaku.twidere.util.StrictModeUtils;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.Utils;
|
||||
@ -93,6 +94,7 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
private SQLiteDatabase mDatabase;
|
||||
private Bus mMessageBus;
|
||||
private VideoLoader mVideoLoader;
|
||||
private ReadStateManager mReadStateManager;
|
||||
|
||||
public AsyncTaskManager getAsyncTaskManager() {
|
||||
if (mAsyncTaskManager != null) return mAsyncTaskManager;
|
||||
@ -123,6 +125,11 @@ public class TwidereApplication extends MultiDexApplication implements Constants
|
||||
return mResolver = new TwidereHostAddressResolver(this);
|
||||
}
|
||||
|
||||
public ReadStateManager getReadStateManager() {
|
||||
if (mReadStateManager != null) return mReadStateManager;
|
||||
return mReadStateManager = new ReadStateManager(this);
|
||||
}
|
||||
|
||||
public ImageDownloader getImageDownloader() {
|
||||
if (mImageDownloader != null) return mImageDownloader;
|
||||
return mImageDownloader = new TwidereImageDownloader(this, false);
|
||||
|
@ -120,9 +120,7 @@ public abstract class AbsStatusesFragment<Data> extends BaseSupportFragment impl
|
||||
|
||||
public abstract int getStatuses(long[] accountIds, long[] maxIds, long[] sinceIds);
|
||||
|
||||
public boolean isRefreshing() {
|
||||
return mSwipeRefreshLayout.isRefreshing();
|
||||
}
|
||||
public abstract boolean isRefreshing();
|
||||
|
||||
public AbsStatusesAdapter<Data> getAdapter() {
|
||||
return mAdapter;
|
||||
@ -157,7 +155,7 @@ public abstract class AbsStatusesFragment<Data> extends BaseSupportFragment impl
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mReadStateManager = new ReadStateManager(getActivity());
|
||||
mReadStateManager = getReadStateManager();
|
||||
final View view = getView();
|
||||
if (view == null) throw new AssertionError();
|
||||
final Context context = view.getContext();
|
||||
|
@ -38,6 +38,7 @@ import org.mariotaku.twidere.fragment.iface.IBaseFragment;
|
||||
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.MultiSelectManager;
|
||||
import org.mariotaku.twidere.util.ReadStateManager;
|
||||
|
||||
public class BaseSupportFragment extends Fragment implements IBaseFragment, Constants {
|
||||
|
||||
@ -84,6 +85,10 @@ public class BaseSupportFragment extends Fragment implements IBaseFragment, Cons
|
||||
return getApplication() != null ? getApplication().getTwitterWrapper() : null;
|
||||
}
|
||||
|
||||
public ReadStateManager getReadStateManager() {
|
||||
return getApplication() != null ? getApplication().getReadStateManager() : null;
|
||||
}
|
||||
|
||||
public void invalidateOptionsMenu() {
|
||||
final FragmentActivity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
|
@ -205,7 +205,7 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
|
||||
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mMessageDrafts = getSharedPreferences(MESSAGE_DRAFTS_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
mImageLoader = TwidereApplication.getInstance(activity).getImageLoaderWrapper();
|
||||
mReadStateManager = new ReadStateManager(activity);
|
||||
mReadStateManager = getReadStateManager();
|
||||
mTwitterWrapper = getTwitterWrapper();
|
||||
mValidator = new TwidereValidator(activity);
|
||||
|
||||
@ -792,7 +792,7 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
|
||||
|
||||
public SetReadStateTask(Context context, ParcelableAccount account, ParcelableUser recipient) {
|
||||
mContext = context;
|
||||
mReadStateManager = new ReadStateManager(context);
|
||||
mReadStateManager = TwidereApplication.getInstance(context).getReadStateManager();
|
||||
mAccount = account;
|
||||
mRecipient = recipient;
|
||||
}
|
||||
|
@ -55,6 +55,12 @@ public class HomeTimelineFragment extends CursorStatusesFragment {
|
||||
setRefreshing(twitter.isHomeTimelineRefreshing());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRefreshing() {
|
||||
final AsyncTwitterWrapper twitter = getTwitterWrapper();
|
||||
return twitter != null && twitter.isHomeTimelineRefreshing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatuses(long[] accountIds, long[] maxIds, long[] sinceIds) {
|
||||
final AsyncTwitterWrapper twitter = getTwitterWrapper();
|
||||
|
@ -46,6 +46,12 @@ public class MentionsTimelineFragment extends CursorStatusesFragment {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRefreshing() {
|
||||
final AsyncTwitterWrapper twitter = getTwitterWrapper();
|
||||
return twitter != null && twitter.isMentionsTimelineRefreshing();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNotificationType() {
|
||||
return NOTIFICATION_ID_MENTIONS_TIMELINE;
|
||||
|
@ -21,6 +21,7 @@ package org.mariotaku.twidere.fragment.support;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
import com.squareup.otto.Subscribe;
|
||||
@ -147,6 +148,12 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment<Lis
|
||||
return args != null ? args.getLong(EXTRA_ACCOUNT_ID, -1) : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRefreshing() {
|
||||
final LoaderManager lm = getLoaderManager();
|
||||
return lm.hasRunningLoaders();
|
||||
}
|
||||
|
||||
protected String[] getSavedStatusesFileArgs() {
|
||||
return null;
|
||||
}
|
||||
|
@ -326,7 +326,7 @@ public final class TwidereDataProvider extends ContentProvider implements Consta
|
||||
mPreferences.registerOnSharedPreferenceChangeListener(this);
|
||||
updatePreferences();
|
||||
mPermissionsManager = new PermissionsManager(context);
|
||||
mReadStateManager = new ReadStateManager(context);
|
||||
mReadStateManager = app.getReadStateManager();
|
||||
mImagePreloader = new ImagePreloader(context, app.getImageLoader());
|
||||
final IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(BROADCAST_HOME_ACTIVITY_ONSTART);
|
||||
|
@ -305,20 +305,12 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
final Uri draftUri = mResolver.insert(Drafts.CONTENT_URI, draftValues);
|
||||
final long draftId = ParseUtils.parseLong(draftUri.getLastPathSegment(), -1);
|
||||
mTwitter.addSendingDraftId(draftId);
|
||||
|
||||
try {
|
||||
Thread.sleep(15000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final List<SingleResponse<ParcelableStatus>> result = updateStatus(builder, item);
|
||||
boolean failed = false;
|
||||
Exception exception = null;
|
||||
final Expression where = Expression.equals(Drafts._ID, draftId);
|
||||
final List<Long> failedAccountIds = ListUtils.fromArray(ParcelableAccount.getAccountIds(item.accounts));
|
||||
|
||||
|
||||
|
||||
for (final SingleResponse<ParcelableStatus> response : result) {
|
||||
|
||||
if (response.getData() == null) {
|
||||
@ -334,7 +326,7 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
+ response.getData().in_reply_to_user_id + "," + response.getData().in_reply_to_status_id);
|
||||
SpiceProfilingUtil.profile(this.getBaseContext(), response.getData().account_id, response.getData().id + ",Tweet," + response.getData().account_id + ","
|
||||
+ response.getData().in_reply_to_user_id + "," + response.getData().in_reply_to_status_id);
|
||||
} else
|
||||
} else
|
||||
for (final ParcelableMedia spiceMedia : response.getData().media) {
|
||||
SpiceProfilingUtil.log(this.getBaseContext(), response.getData().id + ",Media," + response.getData().account_id + ","
|
||||
+ response.getData().in_reply_to_user_id + "," + response.getData().in_reply_to_status_id + "," + spiceMedia.media_url + "," + TypeMappingUtil.getMediaType(spiceMedia.type));
|
||||
@ -395,6 +387,7 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
final long accountId, final long recipientId,
|
||||
final String text, final String imageUri) {
|
||||
final Twitter twitter = getTwitterInstance(this, accountId, true, true);
|
||||
if (twitter == null) return SingleResponse.getInstance();
|
||||
try {
|
||||
final ParcelableDirectMessage directMessage;
|
||||
if (imageUri != null) {
|
||||
@ -420,8 +413,6 @@ public class BackgroundOperationService extends IntentService implements Constan
|
||||
Utils.setLastSeen(this, recipientId, System.currentTimeMillis());
|
||||
|
||||
|
||||
|
||||
|
||||
return SingleResponse.getInstance(directMessage);
|
||||
} catch (final IOException e) {
|
||||
return SingleResponse.getInstance(e);
|
||||
|
@ -120,6 +120,7 @@ public class OkHttpClientImpl implements HttpClient, TwidereConstants {
|
||||
client.setProxy(new Proxy(Type.HTTP, InetSocketAddress.createUnresolved(conf.getHttpProxyHost(),
|
||||
conf.getHttpProxyPort())));
|
||||
}
|
||||
// client.setHostnameVerifier(new HostResolvedHostnameVerifier());
|
||||
Internal.instance.setNetwork(client, new Network() {
|
||||
@Override
|
||||
public InetAddress[] resolveInetAddresses(String host) throws UnknownHostException {
|
||||
|
@ -29,7 +29,7 @@
|
||||
tools:visibility="gone">
|
||||
|
||||
<ProgressBar
|
||||
style="?android:progressBarStyleLarge"
|
||||
style="?android:progressBarStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user