mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-02-05 21:23:26 +01:00
- 内蔵ビューアの静止画表示に画像のピクセル数を記載
- 添付メディアのアップロード中は投稿ボタンを押すとエラーにする
This commit is contained in:
parent
c775088d5f
commit
bcc14d1de0
@ -10,8 +10,8 @@ android {
|
||||
applicationId "jp.juggler.subwaytooter"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 26
|
||||
versionCode 194
|
||||
versionName "1.9.4"
|
||||
versionCode 195
|
||||
versionName "1.9.5"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
@ -162,22 +162,19 @@ public class ActMediaViewer extends AppCompatActivity implements View.OnClickLis
|
||||
findViewById( R.id.btnDownload ).setOnClickListener( this );
|
||||
findViewById( R.id.btnMore ).setOnClickListener( this );
|
||||
|
||||
// findViewById( R.id.btnBrowser ).setOnClickListener( this );
|
||||
// findViewById( R.id.btnShare ).setOnClickListener( this );
|
||||
// findViewById( R.id.btnCopy ).setOnClickListener( this );
|
||||
|
||||
pbvImage.setCallback( new PinchBitmapView.Callback() {
|
||||
@Override public void onSwipe( int delta ){
|
||||
if( isDestroyed() ) return;
|
||||
loadDelta( delta );
|
||||
}
|
||||
|
||||
@Override public void onMove( final float tx, final float ty, final float scale ){
|
||||
@Override
|
||||
public void onMove( final float bitmap_w, final float bitmap_h, final float tx, final float ty, final float scale ){
|
||||
App1.app_state.handler.post( new Runnable() {
|
||||
@Override public void run(){
|
||||
if( isDestroyed() ) return;
|
||||
if( tvStatus.getVisibility() == View.VISIBLE ){
|
||||
tvStatus.setText( getString(R.string.zooming_of,scale ));
|
||||
tvStatus.setText( getString( R.string.zooming_of,(int) bitmap_w, (int)bitmap_h, scale ) );
|
||||
}
|
||||
}
|
||||
} );
|
||||
@ -189,7 +186,7 @@ public class ActMediaViewer extends AppCompatActivity implements View.OnClickLis
|
||||
|
||||
exoView.setPlayer( exoPlayer );
|
||||
}
|
||||
|
||||
|
||||
void loadDelta( int delta ){
|
||||
if( media_list.size() < 2 ) return;
|
||||
int size = media_list.size();
|
||||
@ -289,7 +286,7 @@ public class ActMediaViewer extends AppCompatActivity implements View.OnClickLis
|
||||
}
|
||||
|
||||
tvStatus.setVisibility( View.VISIBLE );
|
||||
tvStatus.setText(null);
|
||||
tvStatus.setText( null );
|
||||
|
||||
pbvImage.setVisibility( View.VISIBLE );
|
||||
pbvImage.setBitmap( null );
|
||||
@ -343,16 +340,15 @@ public class ActMediaViewer extends AppCompatActivity implements View.OnClickLis
|
||||
|
||||
try{
|
||||
//noinspection ConstantConditions
|
||||
data = ProgressResponseBody.bytes( response,new ProgressResponseBody.Callback() {
|
||||
data = ProgressResponseBody.bytes( response, new ProgressResponseBody.Callback() {
|
||||
@Override public void progressBytes( long bytesRead, long bytesTotal ){
|
||||
// 50MB以上のデータはキャンセルする
|
||||
if( Math.max(bytesRead,bytesTotal) >= 50000000 ){
|
||||
if( Math.max( bytesRead, bytesTotal ) >= 50000000 ){
|
||||
throw new RuntimeException( "media attachment is larger than 50000000" );
|
||||
}
|
||||
publishApiProgressRatio( (int) bytesRead, (int) bytesTotal );
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
return new TootApiResult( "" );
|
||||
}catch( Throwable ex ){
|
||||
|
@ -263,7 +263,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
}
|
||||
|
||||
SharedPreferences pref;
|
||||
ArrayList< PostAttachment > attachment_list;
|
||||
@NonNull ArrayList< PostAttachment > attachment_list = new ArrayList<>( );
|
||||
AppState app_state;
|
||||
boolean isPostComplete;
|
||||
PostHelper post_helper;
|
||||
@ -318,7 +318,9 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
}else if( ! TextUtils.isEmpty( sv ) ){
|
||||
|
||||
// state から復元する
|
||||
this.attachment_list = app_state.attachment_list = new ArrayList<>();
|
||||
app_state.attachment_list = this.attachment_list;
|
||||
this.attachment_list.clear();
|
||||
|
||||
try{
|
||||
JSONArray array = new JSONArray( sv );
|
||||
for( int i = 0, ie = array.length() ; i < ie ; ++ i ){
|
||||
@ -341,7 +343,8 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
this.in_reply_to_image = savedInstanceState.getString( KEY_IN_REPLY_TO_IMAGE );
|
||||
this.in_reply_to_url = savedInstanceState.getString( KEY_IN_REPLY_TO_URL );
|
||||
}else{
|
||||
this.attachment_list = app_state.attachment_list = null;
|
||||
app_state.attachment_list = this.attachment_list;
|
||||
this.attachment_list.clear();
|
||||
|
||||
Intent intent = getIntent();
|
||||
long account_db_id = intent.getLongExtra( KEY_ACCOUNT_DB_ID, SavedAccount.INVALID_ID );
|
||||
@ -536,10 +539,10 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
outState.putString( KEY_VISIBILITY, visibility );
|
||||
}
|
||||
|
||||
if( attachment_list != null && ! attachment_list.isEmpty() ){
|
||||
if( ! attachment_list.isEmpty() ){
|
||||
JSONArray array = new JSONArray();
|
||||
for( PostAttachment pa : attachment_list ){
|
||||
if( pa.status == PostAttachment.ATTACHMENT_UPLOADED ){
|
||||
if( pa.status == PostAttachment.STATUS_UPLOADED ){
|
||||
// アップロード完了したものだけ保持する
|
||||
array.put( pa.attachment.json );
|
||||
}
|
||||
@ -775,7 +778,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
|
||||
private void performAccountChooser(){
|
||||
|
||||
if( attachment_list != null && ! attachment_list.isEmpty() ){
|
||||
if( ! attachment_list.isEmpty() ){
|
||||
// 添付ファイルがあったら確認の上添付ファイルを捨てないと切り替えられない
|
||||
Utils.showToast( this, false, R.string.cant_change_account_when_attachment_specified );
|
||||
return;
|
||||
@ -905,7 +908,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
|
||||
if( isFinishing() ) return;
|
||||
|
||||
if( attachment_list == null || attachment_list.isEmpty() ){
|
||||
if( attachment_list.isEmpty() ){
|
||||
llAttachment.setVisibility( View.GONE );
|
||||
}else{
|
||||
llAttachment.setVisibility( View.VISIBLE );
|
||||
@ -921,7 +924,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
}else{
|
||||
iv.setVisibility( View.VISIBLE );
|
||||
PostAttachment a = attachment_list.get( idx );
|
||||
if( a.attachment != null && a.status == PostAttachment.ATTACHMENT_UPLOADED ){
|
||||
if( a.attachment != null && a.status == PostAttachment.STATUS_UPLOADED ){
|
||||
iv.setImageUrl( pref, 16f, a.attachment.preview_url );
|
||||
}else{
|
||||
iv.setImageUrl( pref, 16f, null );
|
||||
@ -1075,7 +1078,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
|
||||
private void performAttachment(){
|
||||
|
||||
if( attachment_list != null && attachment_list.size() >= 4 ){
|
||||
if( attachment_list.size() >= 4 ){
|
||||
Utils.showToast( this, false, R.string.attachment_too_many );
|
||||
return;
|
||||
}
|
||||
@ -1203,7 +1206,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
static HashSet< String > acceptable_mime_types;
|
||||
|
||||
@SuppressLint("StaticFieldLeak") void addAttachment( final Uri uri, final String mime_type ){
|
||||
if( attachment_list != null && attachment_list.size() >= 4 ){
|
||||
if( attachment_list.size() >= 4 ){
|
||||
Utils.showToast( this, false, R.string.attachment_too_many );
|
||||
return;
|
||||
}
|
||||
@ -1233,9 +1236,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
return;
|
||||
}
|
||||
|
||||
if( attachment_list == null ){
|
||||
this.attachment_list = app_state.attachment_list = new ArrayList<>();
|
||||
}
|
||||
app_state.attachment_list = this.attachment_list;
|
||||
|
||||
final PostAttachment pa = new PostAttachment( this );
|
||||
attachment_list.add( pa );
|
||||
@ -1322,12 +1323,12 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
|
||||
@Override protected void handleResult( TootApiResult result ){
|
||||
if( pa.attachment == null ){
|
||||
pa.status = PostAttachment.ATTACHMENT_UPLOAD_FAILED;
|
||||
pa.status = PostAttachment.STATUS_UPLOAD_FAILED;
|
||||
if( result != null ){
|
||||
Utils.showToast( ActPost.this, true, result.error );
|
||||
}
|
||||
}else{
|
||||
pa.status = PostAttachment.ATTACHMENT_UPLOADED;
|
||||
pa.status = PostAttachment.STATUS_UPLOADED;
|
||||
}
|
||||
// 投稿中に画面回転があった場合、新しい画面のコールバックを呼び出す必要がある
|
||||
pa.callback.onPostAttachmentComplete( pa );
|
||||
@ -1338,31 +1339,35 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
|
||||
// 添付メディア投稿が完了したら呼ばれる
|
||||
@Override public void onPostAttachmentComplete( PostAttachment pa ){
|
||||
if( pa.status != PostAttachment.ATTACHMENT_UPLOADED ){
|
||||
if( attachment_list != null ){
|
||||
attachment_list.remove( pa );
|
||||
showMediaAttachment();
|
||||
if( ! attachment_list.contains( pa ) ){
|
||||
// この添付メディアはリストにない
|
||||
return;
|
||||
}
|
||||
|
||||
if( pa.status == PostAttachment.STATUS_UPLOAD_FAILED ){
|
||||
// アップロード失敗
|
||||
attachment_list.remove( pa );
|
||||
showMediaAttachment();
|
||||
}else if( pa.status == PostAttachment.STATUS_UPLOADED ){
|
||||
// アップロード完了
|
||||
Utils.showToast( ActPost.this, false, R.string.attachment_uploaded );
|
||||
|
||||
// 投稿欄の末尾に追記する
|
||||
int selStart = etContent.getSelectionStart();
|
||||
int selEnd = etContent.getSelectionEnd();
|
||||
Editable e = etContent.getEditableText();
|
||||
int len = e.length();
|
||||
char last_char = ( len <= 0 ? ' ' : e.charAt( len - 1 ) );
|
||||
if( ! EmojiDecoder.isWhitespaceBeforeEmoji( last_char ) ){
|
||||
e.append( " " ).append( pa.attachment.text_url );
|
||||
}else{
|
||||
e.append( pa.attachment.text_url );
|
||||
}
|
||||
etContent.setSelection( selStart, selEnd );
|
||||
|
||||
showMediaAttachment();
|
||||
}else{
|
||||
if( attachment_list != null && attachment_list.contains( pa ) ){
|
||||
|
||||
Utils.showToast( ActPost.this, false, R.string.attachment_uploaded );
|
||||
|
||||
// 投稿欄の末尾に追記する
|
||||
int selStart = etContent.getSelectionStart();
|
||||
int selEnd = etContent.getSelectionEnd();
|
||||
Editable e = etContent.getEditableText();
|
||||
int len = e.length();
|
||||
char last_char = ( len <= 0 ? ' ' : e.charAt( len - 1 ) );
|
||||
if( ! EmojiDecoder.isWhitespaceBeforeEmoji( last_char ) ){
|
||||
e.append( " " ).append( pa.attachment.text_url );
|
||||
}else{
|
||||
e.append( pa.attachment.text_url );
|
||||
}
|
||||
etContent.setSelection( selStart, selEnd );
|
||||
|
||||
showMediaAttachment();
|
||||
}
|
||||
// アップロード中…?
|
||||
}
|
||||
}
|
||||
|
||||
@ -1548,10 +1553,8 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
@Override public void run(){
|
||||
etContent.setText( "" );
|
||||
etContentWarning.setText( "" );
|
||||
if( attachment_list != null ){
|
||||
attachment_list.clear();
|
||||
showMediaAttachment();
|
||||
}
|
||||
attachment_list.clear();
|
||||
showMediaAttachment();
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -1571,6 +1574,15 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
// post
|
||||
|
||||
private void performPost(){
|
||||
|
||||
// アップロード中は投稿できない
|
||||
for( PostAttachment pa : attachment_list ){
|
||||
if( pa.status == PostAttachment.STATUS_UPLOADING ){
|
||||
Utils.showToast( this,false,R.string.media_attachment_still_uploading );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
post_helper.content = etContent.getText().toString().trim();
|
||||
|
||||
if( ! cbEnquete.isChecked() ){
|
||||
@ -1676,10 +1688,8 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
|
||||
try{
|
||||
JSONArray tmp_attachment_list = new JSONArray();
|
||||
if( attachment_list != null ){
|
||||
for( PostAttachment pa : attachment_list ){
|
||||
if( pa.attachment != null ) tmp_attachment_list.put( pa.attachment.json );
|
||||
}
|
||||
for( PostAttachment pa : attachment_list ){
|
||||
if( pa.attachment != null ) tmp_attachment_list.put( pa.attachment.json );
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
@ -1871,11 +1881,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener,
|
||||
if( account != null ) setAccount( account );
|
||||
|
||||
if( tmp_attachment_list.length() > 0 ){
|
||||
if( attachment_list != null ){
|
||||
attachment_list.clear();
|
||||
}else{
|
||||
attachment_list = new ArrayList<>();
|
||||
}
|
||||
attachment_list.clear();
|
||||
for( int i = 0, ie = tmp_attachment_list.length() ; i < ie ; ++ i ){
|
||||
TootAttachment ta = TootAttachment.parse( tmp_attachment_list.optJSONObject( i ) );
|
||||
if( ta != null ){
|
||||
|
@ -114,13 +114,6 @@ public class Styler {
|
||||
// 被フォローリクエスト状態の時に followed_by が 真と偽の両方がありえるようなので
|
||||
// Relationshipだけを見ても被フォローリクエスト状態は分からないっぽい
|
||||
// 仕方ないので馬鹿正直に「 followed_byが真ならバッジをつける」しかできない
|
||||
// if( column_type == Column.TYPE_FOLLOW_REQUESTS ){
|
||||
// // フォローリクエストされてる状態でも followed_by はtrueになる
|
||||
// int color = Styler.getAttributeColor( context,R.attr.colorRegexFilterError );
|
||||
// Drawable d = Styler.getAttributeDrawable( context,R.attr.ic_followed_by ).mutate();
|
||||
// d.setColorFilter( color, PorterDuff.Mode.SRC_ATOP );
|
||||
// iv.setImageDrawable( d );
|
||||
// }
|
||||
}
|
||||
|
||||
// follow button
|
||||
|
@ -8,9 +8,9 @@ public class PostAttachment {
|
||||
void onPostAttachmentComplete(PostAttachment pa);
|
||||
}
|
||||
|
||||
public static final int ATTACHMENT_UPLOADING = 1;
|
||||
public static final int ATTACHMENT_UPLOADED = 2;
|
||||
public static final int ATTACHMENT_UPLOAD_FAILED = 3;
|
||||
public static final int STATUS_UPLOADING = 1;
|
||||
public static final int STATUS_UPLOADED = 2;
|
||||
public static final int STATUS_UPLOAD_FAILED = 3;
|
||||
|
||||
public int status;
|
||||
public TootAttachment attachment;
|
||||
@ -18,11 +18,11 @@ public class PostAttachment {
|
||||
|
||||
|
||||
public PostAttachment(Callback callback){
|
||||
this.status = ATTACHMENT_UPLOADING;
|
||||
this.status = STATUS_UPLOADING;
|
||||
this.callback = callback;
|
||||
}
|
||||
public PostAttachment( TootAttachment a ){
|
||||
this.status = ATTACHMENT_UPLOADED;
|
||||
this.status = STATUS_UPLOADED;
|
||||
this.attachment = a;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class PinchBitmapView extends View {
|
||||
// ページめくり操作のコールバック
|
||||
public interface Callback {
|
||||
void onSwipe( int delta );
|
||||
void onMove(float tx,float ty,float scale);
|
||||
void onMove(float bitmap_w,float bitmap_h,float tx,float ty,float scale);
|
||||
}
|
||||
|
||||
@Nullable Callback callback;
|
||||
@ -131,13 +131,14 @@ public class PinchBitmapView extends View {
|
||||
current_trans_y = ( view_h - draw_h ) / 2f;
|
||||
|
||||
|
||||
if( callback != null ) callback.onMove( bitmap_w,bitmap_h, current_trans_x,current_trans_y,current_scale );
|
||||
}else{
|
||||
current_trans_x = current_trans_y = 0f;
|
||||
current_scale = 1f;
|
||||
|
||||
if( callback != null ) callback.onMove( 0f,0f, current_trans_x,current_trans_y,current_scale );
|
||||
}
|
||||
|
||||
if( callback != null ) callback.onMove( current_trans_x,current_trans_y,current_scale );
|
||||
|
||||
// 画像がnullに変化した時も再描画が必要
|
||||
invalidate();
|
||||
}
|
||||
@ -405,7 +406,7 @@ public class PinchBitmapView extends View {
|
||||
current_trans_y = clipTranslate( view_h, bitmap_h, current_scale, start_image_trans_y + move_y );
|
||||
}
|
||||
|
||||
if( callback != null ) callback.onMove( current_trans_x,current_trans_y,current_scale );
|
||||
if( callback != null ) callback.onMove( bitmap_w,bitmap_h,current_trans_x,current_trans_y,current_scale );
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
@ -117,6 +117,7 @@
|
||||
android:gravity="start|bottom"
|
||||
android:textSize="12sp"
|
||||
android:alpha="0.5"
|
||||
android:textColor="#ffffff"
|
||||
/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
@ -585,7 +585,8 @@
|
||||
<string name="media_attachment_type_error">The type of media attachment is \"%1$s\". ST can\'t handle it, but you can try open in browser.</string>
|
||||
<string name="video_buffering">Buffering…</string>
|
||||
<string name="dont_repeat_download_to_same_url">Can\'t repeat downloading same URL in a short time.</string>
|
||||
<string name="zooming_of">×%1$,.1f</string>
|
||||
<string name="zooming_of">×%3$.1f\n%1$d×%2$d</string>
|
||||
<string name="media_attachment_still_uploading">Media uploading has not completed yet.</string>
|
||||
|
||||
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>-->
|
||||
<!--<string name="abc_action_bar_home_description_format">%1$s, %2$s</string>-->
|
||||
|
@ -872,6 +872,7 @@
|
||||
<string name="media_attachment_type_error">添付メディアの種類\"%1$s\"はこのアプリでは開けません。下の「…」にある「ブラウザで開く」を試すことができます</string>
|
||||
<string name="video_buffering">バッファ中…</string>
|
||||
<string name="dont_repeat_download_to_same_url">同じURLを数秒以内に繰り返しダウンロードすることはできません</string>
|
||||
<string name="zooming_of">×%1$,.1f</string>
|
||||
<string name="zooming_of">×%3$.1f\n%1$d×%2$d</string>
|
||||
<string name="media_attachment_still_uploading">添付メディアのアップロードが終わってません</string>
|
||||
|
||||
</resources>
|
||||
|
@ -575,5 +575,6 @@
|
||||
<string name="media_attachment_type_error">The type of media attachment is \"%1$s\". ST can\'t handle it, but you can try open in browser.</string>
|
||||
<string name="video_buffering">Buffering…</string>
|
||||
<string name="dont_repeat_download_to_same_url">Can\'t repeat downloading same URL in a few second.</string>
|
||||
<string name="zooming_of">×%1$,.1f</string>
|
||||
<string name="zooming_of">×%3$.1f\n%1$d×%2$d</string>
|
||||
<string name="media_attachment_still_uploading">Media uploading has not completed yet.</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user