自動CWの表示を改善
This commit is contained in:
parent
2718326e52
commit
6dd3a9d9ec
|
@ -9,8 +9,8 @@ android {
|
||||||
applicationId "jp.juggler.subwaytooter"
|
applicationId "jp.juggler.subwaytooter"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 128
|
versionCode 129
|
||||||
versionName "1.2.8"
|
versionName "1.2.9"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4425,22 +4425,23 @@ public class ActMain extends AppCompatActivity
|
||||||
int lv_pad = (int) ( 0.5f + 12 * density );
|
int lv_pad = (int) ( 0.5f + 12 * density );
|
||||||
int icon_width = (int) ( 0.5f + 48 * density );
|
int icon_width = (int) ( 0.5f + 48 * density );
|
||||||
int icon_end = (int) ( 0.5f + 4 * density );
|
int icon_end = (int) ( 0.5f + 4 * density );
|
||||||
nAutoCwCellWidth = column_w - lv_pad - icon_width - icon_end;
|
nAutoCwCellWidth = column_w - lv_pad*2 - icon_width - icon_end;
|
||||||
}
|
}
|
||||||
// この後各カラムは再描画される
|
// この後各カラムは再描画される
|
||||||
}
|
}
|
||||||
|
|
||||||
TootStatusLike.AutoCW checkAutoCW( @NonNull TootStatusLike status, @NonNull CharSequence text ){
|
void checkAutoCW( @NonNull TootStatusLike status, @NonNull CharSequence text ){
|
||||||
if( nAutoCwLines <= 0 || nAutoCwCellWidth <= 0 ){
|
if( nAutoCwLines <= 0 || nAutoCwCellWidth <= 0 ){
|
||||||
// 設定が無効
|
// 設定が無効
|
||||||
status.auto_cw = null;
|
status.auto_cw = null;
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
TootStatusLike.AutoCW a = status.auto_cw;
|
TootStatusLike.AutoCW a = status.auto_cw;
|
||||||
if( a != null && a.refActivity.get() == ActMain.this && a.cell_width == nAutoCwCellWidth ){
|
if( a != null && a.refActivity.get() == ActMain.this && a.cell_width == nAutoCwCellWidth ){
|
||||||
// 以前に計算した値がまだ使える
|
// 以前に計算した値がまだ使える
|
||||||
return a;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( a == null ) a = status.auto_cw = new TootStatusLike.AutoCW();
|
if( a == null ) a = status.auto_cw = new TootStatusLike.AutoCW();
|
||||||
|
|
||||||
// 計算時の条件(文字フォント、文字サイズ、カラム幅)を覚えておいて、再利用時に同じか確認する
|
// 計算時の条件(文字フォント、文字サイズ、カラム幅)を覚えておいて、再利用時に同じか確認する
|
||||||
|
@ -4469,13 +4470,24 @@ public class ActMain extends AppCompatActivity
|
||||||
if( l != null ){
|
if( l != null ){
|
||||||
int line_count = l.getLineCount();
|
int line_count = l.getLineCount();
|
||||||
if( line_count > nAutoCwLines ){
|
if( line_count > nAutoCwLines ){
|
||||||
SpannableStringBuilder sb = new SpannableStringBuilder( );
|
SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||||
sb.append( getString(R.string.auto_cw_prefix));
|
sb.append( getString( R.string.auto_cw_prefix ) );
|
||||||
sb.append( text,0, l.getLineEnd( nAutoCwLines-1 ) );
|
sb.append( text, 0, l.getLineEnd( nAutoCwLines - 1 ) );
|
||||||
|
int last = sb.length();
|
||||||
|
while( last > 0 ){
|
||||||
|
char c = sb.charAt( last - 1 );
|
||||||
|
if( c == '\n' || Character.isWhitespace( c ) ){
|
||||||
|
-- last;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( last < sb.length() ){
|
||||||
|
sb.delete( last, sb.length() );
|
||||||
|
}
|
||||||
|
sb.append( '…' );
|
||||||
a.decoded_spoiler_text = sb;
|
a.decoded_spoiler_text = sb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -450,7 +450,8 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||||
showContent( cw_shown );
|
showContent( cw_shown );
|
||||||
}else{
|
}else{
|
||||||
// 自動CWを使うかもしれない
|
// 自動CWを使うかもしれない
|
||||||
TootStatusLike.AutoCW r = activity.checkAutoCW( status, content );
|
activity.checkAutoCW( status, content );
|
||||||
|
TootStatusLike.AutoCW r = status.auto_cw;
|
||||||
if( r != null && r.decoded_spoiler_text != null ){
|
if( r != null && r.decoded_spoiler_text != null ){
|
||||||
// 自動CWされた内容を表示
|
// 自動CWされた内容を表示
|
||||||
llContentWarning.setVisibility( View.VISIBLE );
|
llContentWarning.setVisibility( View.VISIBLE );
|
||||||
|
@ -567,9 +568,15 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showContent( boolean shown ){
|
private void showContent( boolean shown ){
|
||||||
btnContentWarning.setText( shown ? R.string.hide : R.string.show );
|
|
||||||
llContents.setVisibility( shown ? View.VISIBLE : View.GONE );
|
llContents.setVisibility( shown ? View.VISIBLE : View.GONE );
|
||||||
|
btnContentWarning.setText( shown ? R.string.hide : R.string.show );
|
||||||
|
if(status!=null){
|
||||||
|
TootStatusLike.AutoCW r = status.auto_cw;
|
||||||
|
if( r != null && r.decoded_spoiler_text != null ){
|
||||||
|
// 自動CWの場合はContentWarningのテキストを切り替える
|
||||||
|
tvContentWarning.setText( shown ? activity.getString( R.string.auto_cw_prefix ) : r.decoded_spoiler_text );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMedia( MyNetworkImageView iv, TootStatus status, int idx ){
|
private void setMedia( MyNetworkImageView iv, TootStatus status, int idx ){
|
||||||
|
|
|
@ -455,7 +455,7 @@
|
||||||
<string name="make_enquete">Make enquete</string>
|
<string name="make_enquete">Make enquete</string>
|
||||||
<string name="dont_use_action_button_with_quick_toot_bar">Disable IME Action button when using \"Quick Toot\" bar (app restart required)</string>
|
<string name="dont_use_action_button_with_quick_toot_bar">Disable IME Action button when using \"Quick Toot\" bar (app restart required)</string>
|
||||||
|
|
||||||
<string name="auto_cw">Automatically hide long sentences (set line counts greater than 0 to enable this option. app restart required)</string>
|
<string name="auto_cw">Automatically hide long text (set line counts greater than 0 to enable this option. app restart required)</string>
|
||||||
<string name="auto_cw_prefix">(Automatic CW)</string>
|
<string name="auto_cw_prefix">(Automatic CW)</string>
|
||||||
|
|
||||||
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>-->
|
<!--<string name="abc_action_bar_home_description">Revenir à l\'accueil</string>-->
|
||||||
|
|
|
@ -450,7 +450,7 @@
|
||||||
<string name="choice4">choice 4(optional)</string>
|
<string name="choice4">choice 4(optional)</string>
|
||||||
<string name="make_enquete">Make enquete</string>
|
<string name="make_enquete">Make enquete</string>
|
||||||
<string name="dont_use_action_button_with_quick_toot_bar">Disable IME Action button when using \"Quick Toot\" bar (app restart required)</string>
|
<string name="dont_use_action_button_with_quick_toot_bar">Disable IME Action button when using \"Quick Toot\" bar (app restart required)</string>
|
||||||
<string name="auto_cw">Automatically hide long sentences (set line counts greater than 0 to enable this option. app restart required)</string>
|
<string name="auto_cw">Automatically hide long text (set line counts greater than 0 to enable this option. app restart required)</string>
|
||||||
<string name="auto_cw_prefix">(Automatic CW)</string>
|
<string name="auto_cw_prefix">(Automatic CW)</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue