mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-11 08:53:54 +01:00
アプリ設定に「見た目/カラムストリップのアイコンの大きさ」を追加
This commit is contained in:
parent
cec2cf012f
commit
057d99feef
@ -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)
|
||||
|
@ -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<ImageView>(R.id.ivIcon)
|
||||
val vAcctColor = viewRoot.findViewById<View>(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<View>(R.id.vAcctColor)
|
||||
vAcctColor.setBackgroundColor(ac.color_fg)
|
||||
}else{
|
||||
vAcctColor.visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
//
|
||||
llColumnStrip.addView(viewRoot)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -515,6 +515,25 @@
|
||||
|
||||
<View style="@style/setting_divider"/>
|
||||
|
||||
<TextView
|
||||
style="@style/setting_row_label"
|
||||
android:labelFor="@+id/etStripIconSize"
|
||||
android:text="@string/strip_icon_size"
|
||||
/>
|
||||
|
||||
<LinearLayout style="@style/setting_row_form">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etStripIconSize"
|
||||
style="@style/setting_horizontal_stretch"
|
||||
android:gravity="center"
|
||||
android:inputType="numberDecimal"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View style="@style/setting_divider"/>
|
||||
|
||||
<TextView
|
||||
style="@style/setting_row_label"
|
||||
android:text="@string/show_instance_ticker"
|
||||
|
@ -57,7 +57,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
@ -68,6 +68,7 @@
|
||||
android:background="@drawable/bg_button_cw"
|
||||
android:contentDescription="@string/menu"
|
||||
app:srcCompat="?attr/ic_hamburger"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
|
||||
<View
|
||||
@ -112,6 +113,7 @@
|
||||
android:background="@drawable/bg_button_cw"
|
||||
android:contentDescription="@string/toot"
|
||||
app:srcCompat="?attr/ic_edit"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -12,11 +12,12 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivIcon"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
tools:ignore="ContentDescription"
|
||||
android:layout_marginTop="4dp"
|
||||
android:importantForAccessibility="no"
|
||||
tools:ignore="ContentDescription"
|
||||
android:scaleType="fitCenter"
|
||||
/>
|
||||
|
||||
<View
|
||||
|
@ -844,6 +844,7 @@
|
||||
<string name="reply_icon_size">返信アイコンの大きさ(単位:dp。デフォルト:24。アプリ再起動が必要)</string>
|
||||
<string name="header_icon_size">ヘッダ部アイコンの大きさ(単位:dp。デフォルト:32。アプリ再起動が必要)</string>
|
||||
<string name="header_text_size">ヘッダ部テキストの大きさ(単位:sp。デフォルト:14。アプリ再起動が必要)</string>
|
||||
<string name="strip_icon_size">カラムストリップのアイコンの大きさ(単位:dp。デフォルト:32。アプリ再起動が必要)</string>
|
||||
<string name="all">All</string>
|
||||
<string name="show_links_in_context_menu">本文中のリンクをコンテキストメニューに表示する</string>
|
||||
<string name="scheduled_status_requires_mastodon_2_7_0">予約投稿はマストドン2.7.0以降で使えます</string>
|
||||
|
@ -865,6 +865,8 @@
|
||||
<string name="reply_icon_size">Reply icon size(Unit:dp. default:24. app restart required)</string>
|
||||
<string name="header_icon_size">Header icon size(Unit:dp. default:32. app restart required)</string>
|
||||
<string name="header_text_size">Header text size(Unit:sp. default:14. app restart required)</string>
|
||||
<string name="strip_icon_size">Column strip icon size(Unit:dp. default:32. app restart required)</string>
|
||||
|
||||
<string name="all">All</string>
|
||||
<string name="show_links_in_context_menu">Show links in context menu</string>
|
||||
<string name="scheduled_status_requires_mastodon_2_7_0">Scheduled status requires Mastodon 2.7.0 or later.</string>
|
||||
|
@ -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){
|
||||
|
Loading…
Reference in New Issue
Block a user