diff --git a/app/src/main/java/jp/juggler/subwaytooter/ActPost.java b/app/src/main/java/jp/juggler/subwaytooter/ActPost.java index 13d36146..1345d8e8 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ActPost.java +++ b/app/src/main/java/jp/juggler/subwaytooter/ActPost.java @@ -546,7 +546,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener, setContentView( R.layout.act_post ); - Styler.fixHorizontalPadding( findViewById( R.id.llContent ) ); + Styler.fixHorizontalMargin( findViewById( R.id.scrollView ) ); Styler.fixHorizontalMargin( findViewById( R.id.llFooterBar ) ); formRoot = findViewById( R.id.viewRoot ); diff --git a/app/src/main/java/jp/juggler/subwaytooter/HeaderViewHolder.java b/app/src/main/java/jp/juggler/subwaytooter/HeaderViewHolder.java index aa32981c..3d5e8f2e 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/HeaderViewHolder.java +++ b/app/src/main/java/jp/juggler/subwaytooter/HeaderViewHolder.java @@ -1,6 +1,5 @@ package jp.juggler.subwaytooter; -import android.support.v4.view.ViewCompat; import android.view.View; import android.widget.Button; import android.widget.ImageButton; @@ -137,7 +136,7 @@ class HeaderViewHolder implements View.OnClickListener, View.OnLongClickListener btnFollowers.setText( activity.getString( R.string.followers ) + "\n" + who.followers_count ); UserRelation relation = UserRelation.load( access_info.db_id, who.id ); - Styler.setFollowIcon( activity, btnFollow, ivFollowedBy, relation, column.column_type ); + Styler.setFollowIcon( activity, btnFollow, ivFollowedBy, relation ); } } diff --git a/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.java b/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.java index 5ae07cb4..2ee9df66 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.java +++ b/app/src/main/java/jp/juggler/subwaytooter/ItemViewHolder.java @@ -296,7 +296,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener { setAcct( tvFollowerAcct, access_info.getFullAcct( who ), R.attr.colorAcctSmall ); UserRelation relation = UserRelation.load( access_info.db_id, who.id ); - Styler.setFollowIcon( activity, btnFollow, ivFollowedBy, relation, column.column_type ); + Styler.setFollowIcon( activity, btnFollow, ivFollowedBy, relation ); } private void showStatus( ActMain activity, TootStatus status ){ diff --git a/app/src/main/java/jp/juggler/subwaytooter/StatusButtons.java b/app/src/main/java/jp/juggler/subwaytooter/StatusButtons.java index 120839fd..306884d0 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/StatusButtons.java +++ b/app/src/main/java/jp/juggler/subwaytooter/StatusButtons.java @@ -13,7 +13,6 @@ import jp.juggler.subwaytooter.api.entity.TootStatus; import jp.juggler.subwaytooter.table.SavedAccount; import jp.juggler.subwaytooter.table.UserRelation; import jp.juggler.subwaytooter.util.LogCategory; -import jp.juggler.subwaytooter.util.Utils; class StatusButtons implements View.OnClickListener, View.OnLongClickListener { static final LogCategory log = new LogCategory( "StatusButtons" ); @@ -97,7 +96,7 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener { }else{ llFollow2.setVisibility( View.VISIBLE ); this.relation = UserRelation.load( access_info.db_id, status.account.id ); - Styler.setFollowIcon( activity, btnFollow2, ivFollowedBy2, relation, column.column_type ); + Styler.setFollowIcon( activity, btnFollow2, ivFollowedBy2, relation ); } } diff --git a/app/src/main/java/jp/juggler/subwaytooter/Styler.java b/app/src/main/java/jp/juggler/subwaytooter/Styler.java index b741c7b4..0b77d18f 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/Styler.java +++ b/app/src/main/java/jp/juggler/subwaytooter/Styler.java @@ -11,7 +11,6 @@ import android.graphics.drawable.RippleDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.StateListDrawable; import android.graphics.drawable.shapes.RectShape; -import android.graphics.drawable.shapes.RoundRectShape; import android.os.Build; import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; @@ -21,7 +20,6 @@ import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.ImageView; -import java.util.Arrays; import java.util.Locale; import jp.juggler.subwaytooter.api.entity.TootStatus; @@ -76,9 +74,7 @@ public class Styler { @NonNull Context context , @NonNull ImageButton ib , @NonNull ImageView iv - , @NonNull UserRelation relation - ,int column_type - + , @NonNull UserRelation relation ){ // 被フォロー状態 @@ -176,13 +172,18 @@ public class Styler { return states; } - static void fixHorizontalPadding( View v ){ + private static final float form_width_max = 420f; + + private static int getHorizontalPadding(View v,float delta_dp){ DisplayMetrics dm = v.getResources().getDisplayMetrics(); - int sw = dm.widthPixels; - int content_w = (int)(0.5f + 360f * dm.density); - int pad_lr = (sw-content_w)/2; - int pad_min = (int)(0.5f + 12f * dm.density); - if( pad_lr < pad_min ) pad_lr = pad_min; + int screen_w = dm.widthPixels; + int content_w = (int)(0.5f + form_width_max * dm.density); + int pad_lr = (screen_w-content_w)/2; + return (pad_lr < 0 ? 0 : pad_lr) + (int)(0.5f + delta_dp * dm.density); + } + + static void fixHorizontalPadding( View v ){ + int pad_lr = getHorizontalPadding( v ,12f); int pad_t = v.getPaddingTop(); int pad_b = v.getPaddingBottom(); @@ -190,12 +191,7 @@ public class Styler { } static void fixHorizontalPadding2( View v ){ - DisplayMetrics dm = v.getResources().getDisplayMetrics(); - int sw = dm.widthPixels; - int content_w = (int)(0.5f + 360f * dm.density); - int pad_lr = (sw-content_w)/2; - int pad_min = 0; - if( pad_lr < pad_min ) pad_lr = pad_min; + int pad_lr = getHorizontalPadding( v ,0f); int pad_t = v.getPaddingTop(); int pad_b = v.getPaddingBottom(); @@ -203,12 +199,7 @@ public class Styler { } static void fixHorizontalMargin( View v ){ - DisplayMetrics dm = v.getResources().getDisplayMetrics(); - int sw = dm.widthPixels; - int content_w = (int)(0.5f + 360f * dm.density); - int pad_lr = (sw-content_w)/2; - int pad_min = 0; - if( pad_lr < pad_min ) pad_lr = pad_min; + int pad_lr = getHorizontalPadding( v ,0f); ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); lp.leftMargin = pad_lr;