Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

for sync.

  • Loading branch information...
commit de8d667ba507e2df424f7eb4a34ae5e69e1e9738 1 parent 725ba80
@mariotaku authored
View
2  src/org/mariotaku/actionbarcompat/ActionModeNative.java
@@ -8,7 +8,7 @@
import android.view.MenuItem;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
-class ActionModeNative extends ActionMode {
+final class ActionModeNative extends ActionMode {
private final Callback mCallbackProxy;
private final android.view.ActionMode mActionMode;
View
4 src/org/mariotaku/twidere/ITwidereService.aidl
@@ -19,6 +19,8 @@
package org.mariotaku.twidere;
+import org.mariotaku.twidere.model.ParcelableLocation;
+
interface ITwidereService {
int getHomeTimeline(in long[] account_ids, in long[] max_ids);
int getMentions(in long[] account_ids, in long[] max_ids);
@@ -30,7 +32,7 @@ interface ITwidereService {
int getSentDirectMessagesWithSinceIds(in long[] account_ids, in long[] max_ids, in long[] since_ids);
int refreshAll();
int getLocalTrends(long account_id, int woeid);
- int updateStatus(in long[] account_ids, String content, in Location location, in Uri image_uri, long in_reply_to, boolean delete_image);
+ int updateStatus(in long[] account_ids, String content, in ParcelableLocation location, in Uri image_uri, long in_reply_to, boolean delete_image);
int destroyStatus(long account_id, long status_id);
int sendDirectMessage(long account_id, String screen_name, long user_id, String message);
int destroyDirectMessage(long account_id, long message_id);
View
8 src/org/mariotaku/twidere/activity/ComposeActivity.java
@@ -94,6 +94,7 @@
import android.widget.Toast;
import com.twitter.Validator;
+import org.mariotaku.twidere.model.ParcelableLocation;
public class ComposeActivity extends BaseActivity implements TextWatcher, LocationListener, OnMenuItemClickListener,
OnClickListener, OnLongClickListener, PopupMenu.OnMenuItemClickListener, OnEditorActionListener,
@@ -106,7 +107,7 @@
private ServiceInterface mService;
private LocationManager mLocationManager;
private SharedPreferences mPreferences;
- private Location mRecentLocation;
+ private ParcelableLocation mRecentLocation;
private ContentResolver mResolver;
private final Validator mValidator = new Validator();
@@ -467,7 +468,7 @@ public void onLoadFinished(final Loader<Bitmap> loader, final Bitmap data) {
/** Sets the mRecentLocation object to the current location of the device **/
@Override
public void onLocationChanged(final Location location) {
- mRecentLocation = location;
+ mRecentLocation = location != null ? new ParcelableLocation(location) : null;
}
@Override
@@ -693,7 +694,8 @@ private boolean getLocation() {
final String provider = mLocationManager.getBestProvider(criteria, true);
if (provider != null) {
- mRecentLocation = mLocationManager.getLastKnownLocation(provider);
+ final Location location = mLocationManager.getLastKnownLocation(provider);
+ mRecentLocation = location != null ? new ParcelableLocation(location) : null;
} else {
Toast.makeText(this, R.string.cannot_get_location, Toast.LENGTH_SHORT).show();
}
View
9 src/org/mariotaku/twidere/activity/MultiSelectActivity.java
@@ -190,10 +190,13 @@ protected void onStop() {
}
private void updateMultiSelectCount() {
- if (mActionMode != null) {
- final int count = mApplication.getSelectedItems().size();
- mActionMode.setTitle(getResources().getQuantityString(R.plurals.Nitems_selected, count, count));
+ if (mActionMode == null) return;
+ final int count = mApplication.getSelectedItems().size();
+ if (count == 0) {
+ mActionMode.finish();
+ return;
}
+ mActionMode.setTitle(getResources().getQuantityString(R.plurals.Nitems_selected, count, count));
}
private void updateMultiSelectState() {
View
7 src/org/mariotaku/twidere/adapter/CursorStatusesAdapter.java
@@ -244,14 +244,17 @@ public View newView(final Context context, final Cursor cursor, final ViewGroup
if (!(tag instanceof StatusViewHolder)) {
final StatusViewHolder holder = new StatusViewHolder(view);
view.setTag(holder);
- holder.profile_image.setOnClickListener(this);
- holder.image_preview.setOnClickListener(this);
+ holder.profile_image.setOnClickListener(mMultiSelectEnabled ? null : this);
+ holder.image_preview.setOnClickListener(mMultiSelectEnabled ? null : this);
+ //holder.image_preview.setClickable(!mMultiSelectEnabled);
+ //holder.profile_image.setClickable(!mMultiSelectEnabled);
}
return view;
}
@Override
public void onClick(final View view) {
+ if (mMultiSelectEnabled) return;
final Object tag = view.getTag();
final ParcelableStatus status = tag instanceof Integer ? getStatus((Integer) tag) : null;
if (status == null) return;
View
8 src/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.java
@@ -146,8 +146,10 @@ public View getView(final int position, final View convertView, final ViewGroup
} else {
holder = new StatusViewHolder(view);
view.setTag(holder);
- holder.image_preview.setOnClickListener(this);
- holder.profile_image.setOnClickListener(this);
+ holder.profile_image.setOnClickListener(mMultiSelectEnabled ? null : this);
+ holder.image_preview.setOnClickListener(mMultiSelectEnabled ? null : this);
+ //holder.image_preview.setClickable(!mMultiSelectEnabled);
+ //holder.profile_image.setClickable(!mMultiSelectEnabled);
}
final ParcelableStatus status = getItem(position);
@@ -241,7 +243,6 @@ public View getView(final int position, final View convertView, final ViewGroup
} else {
mProfileImageLoader.displayImage(parseURL(status.profile_image_url_string), holder.profile_image);
}
- holder.profile_image.setOnClickListener(this);
holder.profile_image.setTag(position);
}
final boolean has_preview = mDisplayImagePreview && status.has_media && status.image_preview_url != null;
@@ -257,6 +258,7 @@ public View getView(final int position, final View convertView, final ViewGroup
@Override
public void onClick(final View view) {
+ if (mMultiSelectEnabled) return;
final Object tag = view.getTag();
final ParcelableStatus status = tag instanceof Integer ? getStatus((Integer) tag) : null;
if (status == null) return;
View
19 src/org/mariotaku/twidere/model/Account.java
@@ -1,3 +1,22 @@
+/*
+ * Twidere - Twitter client for Android
+ *
+ * Copyright (C) 2012 Mariotaku Lee <mariotaku.lee@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
package org.mariotaku.twidere.model;
import java.util.ArrayList;
View
21 src/org/mariotaku/twidere/model/DraftItem.java
@@ -1,3 +1,22 @@
+/*
+ * Twidere - Twitter client for Android
+ *
+ * Copyright (C) 2012 Mariotaku Lee <mariotaku.lee@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
package org.mariotaku.twidere.model;
import org.mariotaku.twidere.provider.TweetStore.Drafts;
@@ -26,4 +45,4 @@ public DraftItem(final Cursor cursor, final int position) {
is_photo_attached = cursor.getShort(cursor.getColumnIndex(Drafts.IS_PHOTO_ATTACHED)) == 1;
}
-}
+}
View
19 src/org/mariotaku/twidere/model/HomeTabSpec.java
@@ -1,3 +1,22 @@
+/*
+ * Twidere - Twitter client for Android
+ *
+ * Copyright (C) 2012 Mariotaku Lee <mariotaku.lee@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
package org.mariotaku.twidere.model;
import android.os.Bundle;
View
22 src/org/mariotaku/twidere/model/ParcelableLocation.aidl
@@ -0,0 +1,22 @@
+/*
+ * Twidere - Twitter client for Android
+ *
+ * Copyright (C) 2012 Mariotaku Lee <mariotaku.lee@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.mariotaku.twidere.model;
+
+parcelable ParcelableLocation;
View
38 src/org/mariotaku/twidere/model/ParcelableLocation.java
@@ -24,38 +24,44 @@
import android.os.Parcel;
import android.os.Parcelable;
import java.io.Serializable;
+import android.location.Location;
public class ParcelableLocation implements Serializable, Parcelable {
public final double latitude, longitude;
- public static final Parcelable.Creator<ParcelableUserList> CREATOR = new Parcelable.Creator<ParcelableUserList>() {
+ public static final Parcelable.Creator<ParcelableLocation> CREATOR = new Parcelable.Creator<ParcelableLocation>() {
@Override
- public ParcelableUserList createFromParcel(final Parcel in) {
- return new ParcelableUserList(in);
+ public ParcelableLocation createFromParcel(final Parcel in) {
+ return new ParcelableLocation(in);
}
@Override
- public ParcelableUserList[] newArray(final int size) {
- return new ParcelableUserList[size];
+ public ParcelableLocation[] newArray(final int size) {
+ return new ParcelableLocation[size];
}
};
public ParcelableLocation(final GeoLocation location) {
- if (location == null) {
- latitude = -1;
- longitude = -1;
- return;
- }
- latitude = location.getLatitude();
- longitude = location.getLongitude();
+ latitude = location != null ? location.getLatitude() : -1;
+ longitude = location != null ? location.getLongitude() : -1;
}
+ public ParcelableLocation(final Location location) {
+ latitude = location != null ? location.getLatitude() : -1;
+ longitude = location != null ? location.getLongitude() : -1;
+ }
+
public ParcelableLocation(final Parcel in) {
latitude = in.readDouble();
longitude = in.readDouble();
}
+ public ParcelableLocation(final double latitude, final double longitude) {
+ this.latitude = latitude;
+ this.longitude = longitude;
+ }
+
public ParcelableLocation(final String location_string) {
if (location_string == null) {
latitude = -1;
@@ -96,4 +102,12 @@ public void writeToParcel(final Parcel out, final int flags) {
public static boolean isValidLocation(final ParcelableLocation location) {
return location != null && location.isValid();
}
+
+ public GeoLocation toGeoLocation() {
+ return isValid() ? new GeoLocation(latitude, longitude) : null;
+ }
+
+ public static GeoLocation toGeoLocation(final ParcelableLocation location) {
+ return isValidLocation(location) ? location.toGeoLocation() : null;
+ }
}
View
21 src/org/mariotaku/twidere/model/TabSpec.java
@@ -1,3 +1,22 @@
+/*
+ * Twidere - Twitter client for Android
+ *
+ * Copyright (C) 2012 Mariotaku Lee <mariotaku.lee@gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
package org.mariotaku.twidere.model;
import static org.mariotaku.twidere.util.Utils.bundleEquals;
@@ -35,4 +54,4 @@ public boolean equals(final Object o) {
&& bundleEquals(args, spec.args) && position == spec.position;
}
-}
+}
View
12 src/org/mariotaku/twidere/service/TwidereService.java
@@ -98,6 +98,7 @@
import com.twitter.Validator;
import edu.ucdavis.earlybird.ProfilingUtil;
+import org.mariotaku.twidere.model.ParcelableLocation;
public class TwidereService extends Service implements Constants {
@@ -433,7 +434,7 @@ public int updateProfileImage(final long account_id, final Uri image_uri, final
return mAsyncTaskManager.add(task, true);
}
- public int updateStatus(final long[] account_ids, final String content, final Location location,
+ public int updateStatus(final long[] account_ids, final String content, final ParcelableLocation location,
final Uri image_uri, final long in_reply_to, final boolean delete_image) {
final UpdateStatusTask task = new UpdateStatusTask(account_ids, content, location, image_uri, in_reply_to,
delete_image);
@@ -2713,10 +2714,9 @@ public int updateProfileImage(final long account_id, final Uri image_uri, final
}
@Override
- public int updateStatus(final long[] account_ids, final String content, final Location location,
+ public int updateStatus(final long[] account_ids, final String content, final ParcelableLocation location,
final Uri image_uri, final long in_reply_to, final boolean delete_image) {
return mService.get().updateStatus(account_ids, content, location, image_uri, in_reply_to, delete_image);
-
}
@Override
@@ -3428,12 +3428,12 @@ private TwidereService getOuterType() {
private final long[] account_ids;
private final String content;
- private final Location location;
+ private final ParcelableLocation location;
private final Uri image_uri;
private final long in_reply_to;
private final boolean use_uploader, use_shortener, delete_image;
- public UpdateStatusTask(final long[] account_ids, final String content, final Location location,
+ public UpdateStatusTask(final long[] account_ids, final String content, final ParcelableLocation location,
final Uri image_uri, final long in_reply_to, final boolean delete_image) {
super(TwidereService.this, mAsyncTaskManager);
final String uploader_component = mPreferences.getString(PREFERENCE_KEY_IMAGE_UPLOADER, null);
@@ -3546,7 +3546,7 @@ public int hashCode() {
: unshortened_content);
status.setInReplyToStatusId(in_reply_to);
if (location != null) {
- status.setLocation(new GeoLocation(location.getLatitude(), location.getLongitude()));
+ status.setLocation(ParcelableLocation.toGeoLocation(location));
}
if (!use_uploader && image_file != null && image_file.exists()) {
status.setMedia(image_file);
View
3  src/org/mariotaku/twidere/util/ServiceInterface.java
@@ -33,6 +33,7 @@
import android.net.Uri;
import android.os.IBinder;
import android.os.RemoteException;
+import org.mariotaku.twidere.model.ParcelableLocation;
public final class ServiceInterface implements Constants, ITwidereService {
@@ -547,7 +548,7 @@ public int updateProfileImage(final long account_id, final Uri image_uri, final
}
@Override
- public int updateStatus(final long[] account_ids, final String content, final Location location,
+ public int updateStatus(final long[] account_ids, final String content, final ParcelableLocation location,
final Uri image_uri, final long in_reply_to, final boolean delete_image) {
if (mService == null) return -1;
try {
Please sign in to comment.
Something went wrong with that request. Please try again.