カラム設定で全ての画像を隠す

This commit is contained in:
tateisu 2017-05-11 23:59:21 +09:00
parent d2c44518fd
commit 09df39a631
9 changed files with 81 additions and 31 deletions

View File

@ -9,8 +9,8 @@ android {
applicationId "jp.juggler.subwaytooter"
minSdkVersion 21
targetSdkVersion 25
versionCode 45
versionName "0.4.5"
versionCode 46
versionName "0.4.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

View File

@ -117,6 +117,8 @@ class Column implements StreamReader.Callback {
private static final String KEY_DONT_SHOW_REPLY = "dont_show_reply";
private static final String KEY_DONT_STREAMING = "dont_streaming";
private static final String KEY_DONT_AUTO_REFRESH = "dont_auto_refresh";
private static final String KEY_HIDE_MEDIA_DEFAULT = "hide_media_default";
private static final String KEY_REGEX_TEXT = "regex_text";
private static final String KEY_HEADER_BACKGROUND_COLOR = "header_background_color";
@ -167,6 +169,7 @@ class Column implements StreamReader.Callback {
boolean dont_show_reply;
boolean dont_streaming;
boolean dont_auto_refresh;
boolean hide_media_default;
String regex_text;
@ -197,7 +200,7 @@ class Column implements StreamReader.Callback {
this.context = app_state.context;
this.access_info = access_info;
this.column_type = type;
this.callback_ref = new WeakReference< Callback >( callback );
this.callback_ref = new WeakReference<>( callback );
switch( type ){
case TYPE_CONVERSATION:
@ -232,6 +235,8 @@ class Column implements StreamReader.Callback {
item.put( KEY_DONT_SHOW_REPLY, dont_show_reply );
item.put( KEY_DONT_STREAMING, dont_streaming );
item.put( KEY_DONT_AUTO_REFRESH, dont_auto_refresh );
item.put( KEY_HIDE_MEDIA_DEFAULT, hide_media_default );
item.put( KEY_REGEX_TEXT, regex_text );
item.put( KEY_HEADER_BACKGROUND_COLOR, header_bg_color );
@ -282,6 +287,8 @@ class Column implements StreamReader.Callback {
this.dont_show_reply = src.optBoolean( KEY_DONT_SHOW_REPLY );
this.dont_streaming = src.optBoolean( KEY_DONT_STREAMING );
this.dont_auto_refresh = src.optBoolean( KEY_DONT_AUTO_REFRESH );
this.hide_media_default = src.optBoolean( KEY_HIDE_MEDIA_DEFAULT );
this.regex_text = Utils.optStringX( src, KEY_REGEX_TEXT );
this.header_bg_color = src.optInt( KEY_HEADER_BACKGROUND_COLOR );
@ -1351,7 +1358,7 @@ class Column implements StreamReader.Callback {
}
}
boolean bRefreshingTop;
private boolean bRefreshingTop;
void startRefresh( final boolean bSilent, final boolean bBottom, final long status_id, final int refresh_after_toot ){
@ -2520,6 +2527,21 @@ class Column implements StreamReader.Callback {
}
}
boolean canShowMedia(){
switch( column_type ){
case TYPE_REPORTS:
case TYPE_MUTES:
case TYPE_BLOCKS:
case TYPE_FOLLOW_REQUESTS:
case TYPE_BOOSTED_BY:
case TYPE_FAVOURITED_BY:
return false;
default:
return true;
}
}
boolean canAutoRefresh(){
switch( column_type ){
default:
@ -2551,7 +2573,7 @@ class Column implements StreamReader.Callback {
private boolean bPutGap;
void resumeStreaming( boolean bPutGap ){
private void resumeStreaming( boolean bPutGap ){
if( ! canStreaming() ){
return;

View File

@ -200,6 +200,15 @@ class ColumnViewHolder
cb.setOnCheckedChangeListener( this );
}
cb = (CheckBox) root.findViewById( R.id.cbHideMediaDefault );
if( ! column.canShowMedia() ){
cb.setVisibility( View.GONE );
}else{
cb.setVisibility(View.VISIBLE );
cb.setChecked( column.hide_media_default );
cb.setOnCheckedChangeListener( this );
}
etRegexFilter = (EditText) root.findViewById( R.id.etRegexFilter );
if( ! bAllowFilter ){
etRegexFilter.setVisibility( View.GONE );
@ -454,6 +463,12 @@ class ColumnViewHolder
column.dont_auto_refresh = isChecked;
activity.app_state.saveColumnList();
break;
case R.id.cbHideMediaDefault:
column.hide_media_default = isChecked;
activity.app_state.saveColumnList();
column.fireShowContent();
break;
}
}

View File

@ -81,7 +81,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
private TootGap gap;
private int position;
ItemViewHolder( ActMain activity,Column column, ItemListAdapter list_adapter,View view ){
ItemViewHolder( ActMain activity, Column column, ItemListAdapter list_adapter, View view ){
this.activity = activity;
this.column = column;
this.access_info = column.access_info;
@ -115,7 +115,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
this.tvContent = (MyTextView) view.findViewById( R.id.tvContent );
this.tvMentions = (MyTextView) view.findViewById( R.id.tvMentions );
this.buttons_for_status = column.bSimpleList ? null : new StatusButtons( activity,column, view );
this.buttons_for_status = column.bSimpleList ? null : new StatusButtons( activity, column, view );
this.flMedia = view.findViewById( R.id.flMedia );
this.btnShowMedia = view.findViewById( R.id.btnShowMedia );
@ -159,7 +159,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
}
void bind( Object item ,int position){
void bind( Object item, int position ){
this.position = position;
this.status = null;
this.account_thumbnail = null;
@ -261,7 +261,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
private void showFollow( TootAccount who ){
account_follow = who;
llFollow.setVisibility( View.VISIBLE );
ivFollow.setCornerRadius( activity.pref,16f );
ivFollow.setCornerRadius( activity.pref, 16f );
ivFollow.setImageUrl( access_info.supplyBaseUrl( who.avatar_static ), App1.getImageLoader() );
tvFollowerName.setText( who.display_name );
setAcct( tvFollowerAcct, access_info.getFullAcct( who ), R.attr.colorAcctSmall );
@ -279,16 +279,16 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
tvTime.setText( TootStatus.formatTime( status.time_created_at ) );
tvName.setText( status.account.display_name );
ivThumbnail.setCornerRadius( activity.pref,16f );
ivThumbnail.setCornerRadius( activity.pref, 16f );
ivThumbnail.setImageUrl( access_info.supplyBaseUrl( status.account.avatar_static ), App1.getImageLoader() );
tvContent.setText( status.decoded_content );
// if( status.decoded_tags == null ){
// tvTags.setVisibility( View.GONE );
// }else{
// tvTags.setVisibility( View.VISIBLE );
// tvTags.setText( status.decoded_tags );
// }
// if( status.decoded_tags == null ){
// tvTags.setVisibility( View.GONE );
// }else{
// tvTags.setVisibility( View.VISIBLE );
// tvTags.setText( status.decoded_tags );
// }
if( status.decoded_mentions == null ){
tvMentions.setVisibility( View.GONE );
@ -317,8 +317,14 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
setMedia( ivMedia3, status, 2 );
setMedia( ivMedia4, status, 3 );
@SuppressWarnings("SimplifiableConditionalExpression")
boolean default_shown =
column.hide_media_default ? false :
access_info.dont_hide_nsfw ? true :
! status.sensitive;
// hide sensitive media
boolean is_shown = MediaShown.isShown( access_info.host, status.id, access_info.dont_hide_nsfw || ! status.sensitive );
boolean is_shown = MediaShown.isShown( access_info.host, status.id, default_shown );
btnShowMedia.setVisibility( ! is_shown ? View.VISIBLE : View.GONE );
}
@ -373,7 +379,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
TootAttachment ta = status.media_attachments.get( idx );
String url = ta.preview_url;
if( TextUtils.isEmpty( url ) ) url = ta.remote_url;
iv.setCornerRadius( activity.pref,16f ); // 正方形じゃないせいかうまく動かない activity.density * 4f );
iv.setCornerRadius( activity.pref, 16f ); // 正方形じゃないせいかうまく動かない activity.density * 4f );
iv.setImageUrl( access_info.supplyBaseUrl( url ), App1.getImageLoader() );
}
}
@ -409,22 +415,22 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
case R.id.ivThumbnail:
if( access_info.isPseudo() ){
new DlgContextMenu( activity, access_info,account_thumbnail, null, column.column_type ).show();
new DlgContextMenu( activity, access_info, account_thumbnail, null, column.column_type ).show();
}else{
activity.performOpenUser( access_info, account_thumbnail );
}
break;
case R.id.llBoosted:
if( access_info.isPseudo() ){
new DlgContextMenu( activity, access_info,account_boost, null, column.column_type ).show();
new DlgContextMenu( activity, access_info, account_boost, null, column.column_type ).show();
}else{
activity.performOpenUser( access_info, account_boost );
}
break;
case R.id.llFollow:
if( access_info.isPseudo() ){
new DlgContextMenu( activity, access_info,account_follow, null, column.column_type ).show();
new DlgContextMenu( activity, access_info, account_follow, null, column.column_type ).show();
}else{
activity.performOpenUser( access_info, account_follow );
}
@ -445,17 +451,17 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
@Override public boolean onLongClick( View v ){
switch( v.getId() ){
case R.id.ivThumbnail:
new DlgContextMenu( activity, access_info, account_thumbnail, null, column.column_type ).show();
return true;
case R.id.btnFollow:
activity.openFollowFromAnotherAccount( access_info,account_follow );
activity.openFollowFromAnotherAccount( access_info, account_follow );
return true;
}
return false;
}
@ -486,7 +492,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
void onItemClick( MyListView listView, View anchor ){
if( status != null ){
activity.closeListItemPopup();
activity.list_item_popup = new StatusButtonsPopup( activity,column );
activity.list_item_popup = new StatusButtonsPopup( activity, column );
activity.list_item_popup.show( listView, anchor, status );
}
}

View File

@ -288,7 +288,6 @@ public class TootApiClient {
ex.printStackTrace();
return new TootApiResult( Utils.formatError( ex, "API data error" ) );
}
// 認証ページURLを作る
final String browser_url = "https://" + instance + "/oauth/authorize"

View File

@ -173,7 +173,12 @@
android:layout_height="wrap_content"
android:text="@string/dont_refresh_on_activity_resume"
/>
<CheckBox
android:id="@+id/cbHideMediaDefault"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hide_media_default"
/>
<LinearLayout
android:id="@+id/llRegexFilter"
android:layout_width="match_parent"

View File

@ -308,5 +308,6 @@
<string name="already_favourited">Already favourited.</string>
<string name="status_id_conversion_failed">Status id conversion failed.</string>
<string name="dont_screen_off">Don\'t screen off while main activity is shown</string>
<string name="hide_media_default">Hide all media</string>
</resources>

View File

@ -594,4 +594,5 @@
<string name="already_favourited">既にお気に入り済みです</string>
<string name="status_id_conversion_failed">ステータスIDを変換できませんでした</string>
<string name="dont_screen_off">メイン画面表示中は自動消灯無効</string>
<string name="hide_media_default">全ての画像を隠す</string>
</resources>

View File

@ -304,4 +304,5 @@
<string name="already_favourited">Already favourited.</string>
<string name="already_boosted">Already boosted.</string>
<string name="dont_screen_off">Don\'t screen off while main activity is shown</string>
<string name="hide_media_default">Hide all media</string>
</resources>