diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java
index af618204f..d7d289338 100644
--- a/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java
+++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/provider/TwidereDataStore.java
@@ -286,6 +286,16 @@ public interface TwidereDataStore {
}
+ interface Suggestions extends BaseColumns {
+ String TYPE = "type";
+ String VALUE1 = "value1";
+ String VALUE2 = "value2";
+
+ interface Compose extends Suggestions {
+
+ }
+ }
+
interface CachedValues extends BaseColumns {
String NAME = "name";
diff --git a/twidere/src/main/java/edu/tsinghua/hotmobi/HotMobiLogger.java b/twidere/src/main/java/edu/tsinghua/hotmobi/HotMobiLogger.java
index 3c9448d0a..292dc6821 100644
--- a/twidere/src/main/java/edu/tsinghua/hotmobi/HotMobiLogger.java
+++ b/twidere/src/main/java/edu/tsinghua/hotmobi/HotMobiLogger.java
@@ -30,6 +30,7 @@ import android.text.TextUtils;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.app.TwidereApplication;
+import org.mariotaku.twidere.util.JsonSerializer;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.util.dagger.ApplicationModule;
@@ -65,6 +66,7 @@ public class HotMobiLogger {
public static final String LOGTAG = "HotMobiLogger";
public static final long UPLOAD_INTERVAL_MILLIS = TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS);
public static final String LAST_UPLOAD_TIME = "last_upload_time";
+ public static final String FALLBACK_CACHED_LOCATION = "fallback_cached_location";
final static SimpleDateFormat DATE_FORMAT;
static {
@@ -123,8 +125,18 @@ public class HotMobiLogger {
public static LatLng getCachedLatLng(Context context) {
final Location location = Utils.getCachedLocation(context);
- if (location == null) return null;
- return new LatLng(location.getLatitude(), location.getLongitude());
+ if (location == null) {
+ return getFallbackCachedLocation(context);
+ }
+ final LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
+ final SharedPreferences prefs = context.getSharedPreferences("spice_data_profiling", Context.MODE_PRIVATE);
+ prefs.edit().putString(FALLBACK_CACHED_LOCATION, JsonSerializer.serialize(latLng, LatLng.class)).apply();
+ return latLng;
+ }
+
+ private static LatLng getFallbackCachedLocation(Context context) {
+ final SharedPreferences prefs = context.getSharedPreferences("spice_data_profiling", Context.MODE_PRIVATE);
+ return JsonSerializer.parse(prefs.getString(FALLBACK_CACHED_LOCATION, null), LatLng.class);
}
public static File getLogFile(Context context, long accountId, String type) {
diff --git a/twidere/src/main/java/org/mariotaku/twidere/util/widget/ScreenNameTokenizer.java b/twidere/src/main/java/org/mariotaku/twidere/util/widget/StatusTextTokenizer.java
similarity index 52%
rename from twidere/src/main/java/org/mariotaku/twidere/util/widget/ScreenNameTokenizer.java
rename to twidere/src/main/java/org/mariotaku/twidere/util/widget/StatusTextTokenizer.java
index ccfdd2312..a1c4e12a8 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/util/widget/ScreenNameTokenizer.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/util/widget/StatusTextTokenizer.java
@@ -27,61 +27,52 @@ import android.widget.MultiAutoCompleteTextView;
/**
* Created by mariotaku on 15/5/14.
*/
-public class ScreenNameTokenizer implements MultiAutoCompleteTextView.Tokenizer {
+public class StatusTextTokenizer implements MultiAutoCompleteTextView.Tokenizer {
@Override
- public int findTokenStart(final CharSequence text, final int cursor) {
- int start = cursor;
-
- while (start > 0 && text.charAt(start - 1) != ' ') {
- start--;
- }
-
- while (start < cursor && text.charAt(start) == ' ') {
- start++;
- }
-
- if (start < cursor && isToken(text.charAt(start))) {
- start++;
- } else {
- start = cursor;
- }
-
- return start;
- }
-
- @Override
- public int findTokenEnd(final CharSequence text, final int cursor) {
+ public int findTokenStart(CharSequence text, int cursor) {
int i = cursor;
- final int len = text.length();
-
- while (i < len) {
- if (text.charAt(i) == ' ')
- return i;
- else {
- i++;
- }
- }
-
- return len;
- }
-
- @Override
- public CharSequence terminateToken(final CharSequence text) {
- int i = text.length();
-
- while (i > 0 && isToken(text.charAt(i - 1))) {
+ // Search backward to find start symbol
+ while (i > 0 && !isStartSymbol(text.charAt(i - 1))) {
i--;
}
-
- if (i > 0 && text.charAt(i - 1) == ' ' || !(text instanceof Spanned)) return text;
- final SpannableString sp = new SpannableString(text);
- TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0);
- return sp;
+ return i;
}
- private static boolean isToken(final char character) {
- switch (character) {
+ @Override
+ public int findTokenEnd(CharSequence text, int cursor) {
+ int i = cursor;
+ int len = text.length();
+ // Search backward to find start symbol
+ while (i > 0 && !isStartSymbol(text.charAt(i - 1))) {
+ i--;
+ }
+ // Search forward to find space
+ while (i < len && !isSpace(text.charAt(i))) {
+ i++;
+ }
+ return i;
+ }
+
+ @Override
+ public CharSequence terminateToken(CharSequence text) {
+ // We already have spaces at the end, so just ignore
+ if (text instanceof Spanned) {
+ SpannableString sp = new SpannableString(text + " ");
+ TextUtils.copySpansFrom((Spanned) text, 0, text.length(),
+ Object.class, sp, 0);
+ return sp;
+ } else {
+ return text + " ";
+ }
+ }
+
+ private static boolean isSpace(final char c) {
+ return Character.isSpaceChar(c) || Character.isWhitespace(c);
+ }
+
+ private static boolean isStartSymbol(final char c) {
+ switch (c) {
case '\uff20':
case '@':
case '\uff03':
diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/ComposeEditText.java b/twidere/src/main/java/org/mariotaku/twidere/view/ComposeEditText.java
index dd71ea00b..ec12ff71c 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/view/ComposeEditText.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/view/ComposeEditText.java
@@ -21,15 +21,12 @@ package org.mariotaku.twidere.view;
import android.content.Context;
import android.support.v7.widget.AppCompatMultiAutoCompleteTextView;
-import android.text.InputType;
import android.text.method.ArrowKeyMovementMethod;
import android.util.AttributeSet;
-import com.rengwuxian.materialedittext.MaterialMultiAutoCompleteTextView;
-
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.UserHashtagAutoCompleteAdapter;
-import org.mariotaku.twidere.util.widget.ScreenNameTokenizer;
+import org.mariotaku.twidere.util.widget.StatusTextTokenizer;
public class ComposeEditText extends AppCompatMultiAutoCompleteTextView {
@@ -46,15 +43,8 @@ public class ComposeEditText extends AppCompatMultiAutoCompleteTextView {
public ComposeEditText(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
- setTokenizer(new ScreenNameTokenizer());
+ setTokenizer(new StatusTextTokenizer());
setMovementMethod(ArrowKeyMovementMethod.getInstance());
- setupComposeInputType();
- }
-
- private void setupComposeInputType() {
- int rawInputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
- rawInputType |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
- setRawInputType(rawInputType);
}
@Override
@@ -85,11 +75,4 @@ public class ComposeEditText extends AppCompatMultiAutoCompleteTextView {
if (mAdapter == null) return;
mAdapter.setAccountId(mAccountId);
}
-
- @Override
- protected void replaceText(final CharSequence text) {
- super.replaceText(text);
- append(" ");
- }
-
}
diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/ComposeMaterialEditText.java b/twidere/src/main/java/org/mariotaku/twidere/view/ComposeMaterialEditText.java
index 84e2f1d4b..cf888af66 100644
--- a/twidere/src/main/java/org/mariotaku/twidere/view/ComposeMaterialEditText.java
+++ b/twidere/src/main/java/org/mariotaku/twidere/view/ComposeMaterialEditText.java
@@ -29,7 +29,7 @@ import android.util.AttributeSet;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.UserHashtagAutoCompleteAdapter;
-import org.mariotaku.twidere.util.widget.ScreenNameTokenizer;
+import org.mariotaku.twidere.util.widget.StatusTextTokenizer;
import org.mariotaku.twidere.view.iface.IThemeBackgroundTintView;
public class ComposeMaterialEditText extends AppCompatMultiAutoCompleteTextView implements IThemeBackgroundTintView {
@@ -47,7 +47,7 @@ public class ComposeMaterialEditText extends AppCompatMultiAutoCompleteTextView
public ComposeMaterialEditText(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
- setTokenizer(new ScreenNameTokenizer());
+ setTokenizer(new StatusTextTokenizer());
setMovementMethod(ArrowKeyMovementMethod.getInstance());
setupComposeInputType();
}
diff --git a/twidere/src/main/res/layout/activity_compose.xml b/twidere/src/main/res/layout/activity_compose.xml
index ca4c8e2b8..64f4efefd 100644
--- a/twidere/src/main/res/layout/activity_compose.xml
+++ b/twidere/src/main/res/layout/activity_compose.xml
@@ -61,6 +61,7 @@
android:completionThreshold="1"
android:gravity="top"
android:hint="@string/status_hint"
+ android:inputType="text|textLongMessage|textAutoComplete|textMultiLine"
android:minLines="6"
android:padding="@dimen/element_spacing_normal"
android:scrollbars="vertical" />
diff --git a/twidere/src/main/res/values/strings.xml b/twidere/src/main/res/values/strings.xml
index 6c93f7721..efb3e5a25 100644
--- a/twidere/src/main/res/values/strings.xml
+++ b/twidere/src/main/res/values/strings.xml
@@ -543,7 +543,7 @@
Transparent
Dark ActionBar
Click profile image to select account when writing a tweet.
- Set your favorite quote format in "Settings" - "Content & Storage"
+ Set your favorite quote format in "Settings" - "Compose"
You can hide unwanted tweets from timeline and notification by using "Filters".
View Replies
Compact cards