|
|
@ -87,6 +87,7 @@ import com.keylesspalace.tusky.util.MediaUtils; |
|
|
|
import com.keylesspalace.tusky.util.MentionTokenizer; |
|
|
|
import com.keylesspalace.tusky.util.MentionTokenizer; |
|
|
|
import com.keylesspalace.tusky.util.ParserUtils; |
|
|
|
import com.keylesspalace.tusky.util.ParserUtils; |
|
|
|
import com.keylesspalace.tusky.util.SpanUtils; |
|
|
|
import com.keylesspalace.tusky.util.SpanUtils; |
|
|
|
|
|
|
|
import com.keylesspalace.tusky.util.StringUtils; |
|
|
|
import com.keylesspalace.tusky.util.ThemeUtils; |
|
|
|
import com.keylesspalace.tusky.util.ThemeUtils; |
|
|
|
import com.keylesspalace.tusky.view.EditTextTyped; |
|
|
|
import com.keylesspalace.tusky.view.EditTextTyped; |
|
|
|
import com.keylesspalace.tusky.view.RoundedTransformation; |
|
|
|
import com.keylesspalace.tusky.view.RoundedTransformation; |
|
|
@ -112,12 +113,6 @@ import retrofit2.Call; |
|
|
|
import retrofit2.Callback; |
|
|
|
import retrofit2.Callback; |
|
|
|
import retrofit2.Response; |
|
|
|
import retrofit2.Response; |
|
|
|
|
|
|
|
|
|
|
|
import static com.keylesspalace.tusky.util.MediaUtils.MEDIA_SIZE_UNKNOWN; |
|
|
|
|
|
|
|
import static com.keylesspalace.tusky.util.MediaUtils.getMediaSize; |
|
|
|
|
|
|
|
import static com.keylesspalace.tusky.util.MediaUtils.inputStreamGetBytes; |
|
|
|
|
|
|
|
import static com.keylesspalace.tusky.util.StringUtils.carriageReturn; |
|
|
|
|
|
|
|
import static com.keylesspalace.tusky.util.StringUtils.randomAlphanumericString; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ComposeActivity extends BaseActivity implements ComposeOptionsFragment.Listener, ParserUtils.ParserListener { |
|
|
|
public class ComposeActivity extends BaseActivity implements ComposeOptionsFragment.Listener, ParserUtils.ParserListener { |
|
|
|
private static final String TAG = "ComposeActivity"; // logging tag
|
|
|
|
private static final String TAG = "ComposeActivity"; // logging tag
|
|
|
|
private static final int STATUS_CHARACTER_LIMIT = 500; |
|
|
|
private static final int STATUS_CHARACTER_LIMIT = 500; |
|
|
@ -398,7 +393,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (Uri uri : uriList) { |
|
|
|
for (Uri uri : uriList) { |
|
|
|
long mediaSize = getMediaSize(getContentResolver(), uri); |
|
|
|
long mediaSize = MediaUtils.getMediaSize(getContentResolver(), uri); |
|
|
|
pickMedia(uri, mediaSize); |
|
|
|
pickMedia(uri, mediaSize); |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (type.equals("text/plain")) { |
|
|
|
} else if (type.equals("text/plain")) { |
|
|
@ -663,7 +658,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm |
|
|
|
// Just eat this exception.
|
|
|
|
// Just eat this exception.
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
mediaSize = MEDIA_SIZE_UNKNOWN; |
|
|
|
mediaSize = MediaUtils.MEDIA_SIZE_UNKNOWN; |
|
|
|
} |
|
|
|
} |
|
|
|
pickMedia(uri, mediaSize); |
|
|
|
pickMedia(uri, mediaSize); |
|
|
|
|
|
|
|
|
|
|
@ -1004,7 +999,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm |
|
|
|
final String filename = String.format("%s_%s_%s.%s", |
|
|
|
final String filename = String.format("%s_%s_%s.%s", |
|
|
|
getString(R.string.app_name), |
|
|
|
getString(R.string.app_name), |
|
|
|
String.valueOf(new Date().getTime()), |
|
|
|
String.valueOf(new Date().getTime()), |
|
|
|
randomAlphanumericString(10), |
|
|
|
StringUtils.randomAlphanumericString(10), |
|
|
|
fileExtension); |
|
|
|
fileExtension); |
|
|
|
|
|
|
|
|
|
|
|
byte[] content = item.content; |
|
|
|
byte[] content = item.content; |
|
|
@ -1019,7 +1014,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
content = inputStreamGetBytes(stream); |
|
|
|
content = MediaUtils.inputStreamGetBytes(stream); |
|
|
|
IOUtils.closeQuietly(stream); |
|
|
|
IOUtils.closeQuietly(stream); |
|
|
|
|
|
|
|
|
|
|
|
if (content == null) { |
|
|
|
if (content == null) { |
|
|
@ -1099,17 +1094,17 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm |
|
|
|
super.onActivityResult(requestCode, resultCode, data); |
|
|
|
super.onActivityResult(requestCode, resultCode, data); |
|
|
|
if (requestCode == MEDIA_PICK_RESULT && resultCode == RESULT_OK && data != null) { |
|
|
|
if (requestCode == MEDIA_PICK_RESULT && resultCode == RESULT_OK && data != null) { |
|
|
|
Uri uri = data.getData(); |
|
|
|
Uri uri = data.getData(); |
|
|
|
long mediaSize = getMediaSize(getContentResolver(), uri); |
|
|
|
long mediaSize = MediaUtils.getMediaSize(getContentResolver(), uri); |
|
|
|
pickMedia(uri, mediaSize); |
|
|
|
pickMedia(uri, mediaSize); |
|
|
|
} else if (requestCode == MEDIA_TAKE_PHOTO_RESULT && resultCode == RESULT_OK) { |
|
|
|
} else if (requestCode == MEDIA_TAKE_PHOTO_RESULT && resultCode == RESULT_OK) { |
|
|
|
long mediaSize = getMediaSize(getContentResolver(), photoUploadUri); |
|
|
|
long mediaSize = MediaUtils.getMediaSize(getContentResolver(), photoUploadUri); |
|
|
|
pickMedia(photoUploadUri, mediaSize); |
|
|
|
pickMedia(photoUploadUri, mediaSize); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void pickMedia(Uri uri, long mediaSize) { |
|
|
|
private void pickMedia(Uri uri, long mediaSize) { |
|
|
|
ContentResolver contentResolver = getContentResolver(); |
|
|
|
ContentResolver contentResolver = getContentResolver(); |
|
|
|
if (mediaSize == MEDIA_SIZE_UNKNOWN) { |
|
|
|
if (mediaSize == MediaUtils.MEDIA_SIZE_UNKNOWN) { |
|
|
|
displayTransientError(R.string.error_media_upload_opening); |
|
|
|
displayTransientError(R.string.error_media_upload_opening); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -1211,7 +1206,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm |
|
|
|
if (!TextUtils.isEmpty(headerInfo.title)) { |
|
|
|
if (!TextUtils.isEmpty(headerInfo.title)) { |
|
|
|
cleanBaseUrl(headerInfo); |
|
|
|
cleanBaseUrl(headerInfo); |
|
|
|
textEditor.append(headerInfo.title); |
|
|
|
textEditor.append(headerInfo.title); |
|
|
|
textEditor.append(carriageReturn); |
|
|
|
textEditor.append(StringUtils.carriageReturn); |
|
|
|
textEditor.append(headerInfo.baseUrl); |
|
|
|
textEditor.append(headerInfo.baseUrl); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!TextUtils.isEmpty(headerInfo.image)) { |
|
|
|
if (!TextUtils.isEmpty(headerInfo.image)) { |
|
|
@ -1230,7 +1225,8 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
long mediaSize = getMediaSize(getContentResolver(), headerInfo); |
|
|
|
long mediaSize = MediaUtils.getMediaSize(getContentResolver(), |
|
|
|
|
|
|
|
headerInfo); |
|
|
|
pickMedia(headerInfo, mediaSize); |
|
|
|
pickMedia(headerInfo, mediaSize); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|