From 057d99feef866b0c7d090c353328f47e1e3441e0 Mon Sep 17 00:00:00 2001 From: tateisu Date: Tue, 15 Jan 2019 22:43:56 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A2=E3=83=97=E3=83=AA=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=81=AB=E3=80=8C=E8=A6=8B=E3=81=9F=E7=9B=AE/=E3=82=AB?= =?UTF-8?q?=E3=83=A9=E3=83=A0=E3=82=B9=E3=83=88=E3=83=AA=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=81=AE=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3=E3=81=AE=E5=A4=A7?= =?UTF-8?q?=E3=81=8D=E3=81=95=E3=80=8D=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subwaytooter/ActAppSettingChild.kt | 6 +- .../java/jp/juggler/subwaytooter/ActMain.kt | 40 ++++++++++- .../main/java/jp/juggler/subwaytooter/Pref.kt | 1 + .../res/layout/act_app_setting_appearance.xml | 19 ++++++ app/src/main/res/layout/act_main.xml | 4 +- app/src/main/res/layout/lv_column_strip.xml | 5 +- app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values/strings.xml | 2 + fixIconAlpha.pl | 66 +++++++++++++++---- 9 files changed, 124 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/jp/juggler/subwaytooter/ActAppSettingChild.kt b/app/src/main/java/jp/juggler/subwaytooter/ActAppSettingChild.kt index c291f3be..465d44ca 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ActAppSettingChild.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/ActAppSettingChild.kt @@ -156,7 +156,7 @@ class ActAppSettingChild : AppCompatActivity() private var etBoostButtonSize : EditText? = null private var etReplyIconSize : EditText? = null private var etHeaderIconSize : EditText? = null - + private var etStripIconSize : EditText? = null private var tvUserAgentError : TextView? = null private var llColumnHeader : View? = null @@ -430,7 +430,7 @@ class ActAppSettingChild : AppCompatActivity() etBoostButtonSize = findViewById(R.id.etBoostButtonSize) etReplyIconSize = findViewById(R.id.etReplyIconSize) etHeaderIconSize = findViewById(R.id.etHeaderIconSize) - + etStripIconSize= findViewById(R.id.etStripIconSize) tvTimelineFontUrl = findViewById(R.id.tvTimelineFontUrl) tvTimelineFontBoldUrl = findViewById(R.id.tvTimelineFontBoldUrl) @@ -510,6 +510,7 @@ class ActAppSettingChild : AppCompatActivity() etBoostButtonSize?.setText(Pref.spBoostButtonSize(pref)) etReplyIconSize?.setText(Pref.spReplyIconSize(pref)) etHeaderIconSize?.setText(Pref.spHeaderIconSize(pref)) + etStripIconSize?.setText(Pref.spStripIconSize(pref)) etPullNotificationCheckInterval?.setText(Pref.spPullNotificationCheckInterval(pref)) etMediaSizeMax?.setText(Pref.spMediaSizeMax(pref)) @@ -591,6 +592,7 @@ class ActAppSettingChild : AppCompatActivity() putText(Pref.spBoostButtonSize, etBoostButtonSize) putText(Pref.spReplyIconSize, etReplyIconSize) putText(Pref.spHeaderIconSize, etHeaderIconSize) + putText(Pref.spStripIconSize, etStripIconSize) putText(Pref.spPullNotificationCheckInterval, etPullNotificationCheckInterval) putText(Pref.spMediaSizeMax, etMediaSizeMax) putText(Pref.spMovieSizeMax, etMovieSizeMax) diff --git a/app/src/main/java/jp/juggler/subwaytooter/ActMain.kt b/app/src/main/java/jp/juggler/subwaytooter/ActMain.kt index 75c8c67e..5be7987c 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/ActMain.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/ActMain.kt @@ -91,6 +91,7 @@ class ActMain : AppCompatActivity() var boostButtonSize = 1 var replyIconSize = 1 var headerIconSize = 1 + var stripIconSize = 1 var timeline_font : Typeface = Typeface.DEFAULT var timeline_font_bold : Typeface = Typeface.DEFAULT_BOLD } @@ -1250,7 +1251,7 @@ class ActMain : AppCompatActivity() boostButtonSize = parseIconSize(Pref.spBoostButtonSize) replyIconSize = parseIconSize(Pref.spReplyIconSize) headerIconSize = parseIconSize(Pref.spHeaderIconSize) - + stripIconSize = parseIconSize(Pref.spStripIconSize) run { var round_ratio = 33f try { @@ -1462,7 +1463,23 @@ class ActMain : AppCompatActivity() }) internal fun updateColumnStrip() { - llEmpty.visibility = if(app_state.column_list.isEmpty()) View.VISIBLE else View.GONE + vg(llEmpty, app_state.column_list.isEmpty()) + + val iconSize = stripIconSize + val rootW = (iconSize * 1.25f + 0.5f).toInt() + val rootH = (iconSize * 1.5f + 0.5f).toInt() + val iconTopMargin = (iconSize * 0.125f + 0.5f).toInt() + val barHeight = (iconSize * 0.094f + 0.5f).toInt() + val barTopMargin = (iconSize * 0.094f + 0.5f).toInt() + + // 両端のメニューと投稿ボタンの大きさ + val pad = (rootH - iconSize ) shr 1 + btnToot.layoutParams.width = rootH // not W + btnToot.layoutParams.height = rootH + btnToot.setPaddingRelative(pad,pad,pad,pad) + btnMenu.layoutParams.width = rootH // not W + btnMenu.layoutParams.height = rootH + btnMenu.setPaddingRelative(pad,pad,pad,pad) llColumnStrip.removeAllViews() for(i in 0 until app_state.column_list.size) { @@ -1471,6 +1488,21 @@ class ActMain : AppCompatActivity() val viewRoot = layoutInflater.inflate(R.layout.lv_column_strip, llColumnStrip, false) val ivIcon = viewRoot.findViewById(R.id.ivIcon) + val vAcctColor = viewRoot.findViewById(R.id.vAcctColor) + + // root: 48x48dp LinearLayout(vertical), gravity=center + viewRoot.layoutParams.width = rootW + viewRoot.layoutParams.height = rootH + + // ivIcon: 32x32dp marginTop="4dp" 図柄が32x32dp、パディングなし + ivIcon.layoutParams.width = iconSize + ivIcon.layoutParams.height = iconSize + (ivIcon.layoutParams as? LinearLayout.LayoutParams)?.topMargin = iconTopMargin + + // vAcctColor: 32x3dp marginTop="3dp" + vAcctColor.layoutParams.width = iconSize + vAcctColor.layoutParams.height = barHeight + (vAcctColor.layoutParams as? LinearLayout.LayoutParams)?.topMargin = barTopMargin viewRoot.tag = i viewRoot.setOnClickListener { v -> @@ -1496,9 +1528,11 @@ class ActMain : AppCompatActivity() // val ac = AcctColor.load(column.access_info.acct) if(AcctColor.hasColorForeground(ac)) { - val vAcctColor = viewRoot.findViewById(R.id.vAcctColor) vAcctColor.setBackgroundColor(ac.color_fg) + }else{ + vAcctColor.visibility = View.INVISIBLE } + // llColumnStrip.addView(viewRoot) } diff --git a/app/src/main/java/jp/juggler/subwaytooter/Pref.kt b/app/src/main/java/jp/juggler/subwaytooter/Pref.kt index 4482667d..f8a0ac8d 100644 --- a/app/src/main/java/jp/juggler/subwaytooter/Pref.kt +++ b/app/src/main/java/jp/juggler/subwaytooter/Pref.kt @@ -425,6 +425,7 @@ object Pref { val spBoostButtonSize = StringPref("BoostButtonSize", "35") val spReplyIconSize = StringPref("ReplyIconSize", "24") val spHeaderIconSize = StringPref("HeaderIconSize", "32") + val spStripIconSize = StringPref("StripIconSize", "32") val spMediaSizeMax = StringPref("max_media_size", "8") val spMovieSizeMax = StringPref("max_movie_size", "40") val spTimelineFont = StringPref("timeline_font", "", skipImport = true) diff --git a/app/src/main/res/layout/act_app_setting_appearance.xml b/app/src/main/res/layout/act_app_setting_appearance.xml index 5e0fcc3a..3e194fdd 100644 --- a/app/src/main/res/layout/act_app_setting_appearance.xml +++ b/app/src/main/res/layout/act_app_setting_appearance.xml @@ -515,6 +515,25 @@ + + + + + + + + + + @@ -68,6 +68,7 @@ android:background="@drawable/bg_button_cw" android:contentDescription="@string/menu" app:srcCompat="?attr/ic_hamburger" + android:scaleType="fitCenter" /> diff --git a/app/src/main/res/layout/lv_column_strip.xml b/app/src/main/res/layout/lv_column_strip.xml index 4adeeee6..8dd1d499 100644 --- a/app/src/main/res/layout/lv_column_strip.xml +++ b/app/src/main/res/layout/lv_column_strip.xml @@ -12,11 +12,12 @@ 返信アイコンの大きさ(単位:dp。デフォルト:24。アプリ再起動が必要) ヘッダ部アイコンの大きさ(単位:dp。デフォルト:32。アプリ再起動が必要) ヘッダ部テキストの大きさ(単位:sp。デフォルト:14。アプリ再起動が必要) + カラムストリップのアイコンの大きさ(単位:dp。デフォルト:32。アプリ再起動が必要) All 本文中のリンクをコンテキストメニューに表示する 予約投稿はマストドン2.7.0以降で使えます diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8abc3ce5..d66cf456 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -865,6 +865,8 @@ Reply icon size(Unit:dp. default:24. app restart required) Header icon size(Unit:dp. default:32. app restart required) Header text size(Unit:sp. default:14. app restart required) + Column strip icon size(Unit:dp. default:32. app restart required) + All Show links in context menu Scheduled status requires Mastodon 2.7.0 or later. diff --git a/fixIconAlpha.pl b/fixIconAlpha.pl index 5a2d6d23..cbd36801 100644 --- a/fixIconAlpha.pl +++ b/fixIconAlpha.pl @@ -10,8 +10,32 @@ my $dry_run = grep{ $_ eq '--dry-run'} @ARGV; my $resdir = 'app/src/main/res'; my $dstdir = 'tmp'; +my $trimdir = 'trim24'; + my $tmpfile = 'tmp/tmp.png'; +my %density = ( + mdpi => 1, + hdpi => 1.5, + xhdpi=> 2, + xxhdpi => 3, + xxxhdpi => 4, +); + +sub savePng($$){ + my($image,$path)=@_; + + my $dir = $path; + $dir =~ s|/[^/]+\z||; + make_path($dir); + + $image->saveAlpha(1); + open(my $fh,">",$path) or die "$path $!"; + binmode $fh; + print $fh $image->png; + close($fh) or die "$path $!"; +} + sub fix($){ my($relpath) = @_; @@ -57,12 +81,39 @@ Loop: for( my $y = 0; $y < $height ;++$y){ } } } - + + $relpath=~ /drawable-(\w+)/; + my $density = $density{ $1 }; + +# if( $density and !$isColor){ +# my $dp_w = int(0.5 + $width/$density); +# my $dp_h = int(0.5 + $height/$density); +# if( $dp_w == 32 && $dp_h == 32 ){ +# say "${dp_w}x${dp_h}dp, alphaMax=$alphaMax, isColor=${isColor}, $relpath"; +# +# # create trimmed +# my $trim_w = int(0.5 + $width * 24/32); +# my $trim_h = int(0.5 + $height * 24/32); +# my $offsetX = int($width-$trim_w)/2; +# my $offsetY = int($width-$trim_w)/2; +# +# my $i2 = GD::Image->newTrueColor($trim_w,$trim_h); +# $i2->alphaBlending(0); +# $i2->filledRectangle(0,0,$trim_w,$trim_h, $image->colorAllocateAlpha(0,0,0,127)); +# $i2->alphaBlending(1); +# $i2->copy($image,0,0,$offsetX,$offsetY,$trim_w,$trim_h); +# +# my $dstfile = "$trimdir/$relpath"; +# return if not $dstfile =~ s/(png|webp)\z/png/i; +# savePng($i2,$dstfile); +# } +# } + return if $isColor; return if $alphaMax == 0; return if $alphaMax >= 126; - say "$width x $height ,alphaMax=$alphaMax $relpath"; + say "${width}x${height}, alphaMax=$alphaMax, isColor=${isColor}, $relpath"; my $scale = 127.0/$alphaMax; @@ -82,16 +133,7 @@ Loop: for( my $y = 0; $y < $height ;++$y){ } } - my $dstdir = $dstfile; - $dstdir =~ s|/[^/]+\z||; - make_path($dstdir); - - $image->saveAlpha(1); - open(my $fh,">",$dstfile) or die "$dstfile $!"; - binmode $fh; - print $fh $image->png; - close($fh) or die "$dstfile $!"; - + savePng($image,$dstfile); return if $dry_run; if(1){