1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2025-01-28 01:29:23 +01:00
This commit is contained in:
tateisu 2017-04-29 05:19:32 +09:00
parent 923ad24b86
commit 3efa7d2f4a
7 changed files with 253 additions and 187 deletions

View File

@ -9,8 +9,8 @@ android {
applicationId "jp.juggler.subwaytooter"
minSdkVersion 21
targetSdkVersion 25
versionCode 19
versionName "0.1.9"
versionCode 20
versionName "0.2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

View File

@ -326,10 +326,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
View btnAttachment;
View btnPost;
View llAttachment;
NetworkImageView ivMedia1;
NetworkImageView ivMedia2;
NetworkImageView ivMedia3;
NetworkImageView ivMedia4;
final NetworkImageView[] ivMedia = new NetworkImageView[4];
CheckBox cbNSFW;
CheckBox cbContentWarning;
EditText etContentWarning;
@ -351,10 +348,10 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
btnAttachment = findViewById( R.id.btnAttachment );
btnPost = findViewById( R.id.btnPost );
llAttachment = findViewById( R.id.llAttachment );
ivMedia1 = (NetworkImageView) findViewById( R.id.ivMedia1 );
ivMedia2 = (NetworkImageView) findViewById( R.id.ivMedia2 );
ivMedia3 = (NetworkImageView) findViewById( R.id.ivMedia3 );
ivMedia4 = (NetworkImageView) findViewById( R.id.ivMedia4 );
ivMedia[0] = (NetworkImageView) findViewById( R.id.ivMedia1 );
ivMedia[1] = (NetworkImageView) findViewById( R.id.ivMedia2 );
ivMedia[2] = (NetworkImageView) findViewById( R.id.ivMedia3 );
ivMedia[3] = (NetworkImageView) findViewById( R.id.ivMedia4 );
cbNSFW = (CheckBox) findViewById( R.id.cbNSFW );
cbContentWarning = (CheckBox) findViewById( R.id.cbContentWarning );
etContentWarning = (EditText) findViewById( R.id.etContentWarning );
@ -379,11 +376,13 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
btnAttachment.setOnClickListener( this );
btnPost.setOnClickListener( this );
btnRemoveReply.setOnClickListener( this );
ivMedia1.setOnClickListener( this );
ivMedia2.setOnClickListener( this );
ivMedia3.setOnClickListener( this );
ivMedia4.setOnClickListener( this );
for( NetworkImageView iv :ivMedia){
iv.setOnClickListener( this );
iv.setDefaultImageResId( Styler.getAttributeResourceId( this,R.attr.btn_refresh ));
// iv.setErrorImageResId( Styler.getAttributeResourceId( this,R.attr.btn_refresh ));
}
cbContentWarning.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged( CompoundButton buttonView, boolean isChecked ){
@ -410,12 +409,18 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
}
private void updateTextCount(){
tvCharCount.setText( Integer.toString( 500 - etContent.getText().length() ) );
String s = etContent.getText().toString();
int count = s.codePointCount( 0,s.length() );
int remain = 500 - count;
tvCharCount.setText( Integer.toString( remain ) );
int color = Styler.getAttributeColor( this, remain < 0 ? R.attr.colorRegexFilterError : android.R.attr.textColorPrimary );
tvCharCount.setTextColor( color );
}
private void updateContentWarning(){
etContentWarning.setVisibility( cbContentWarning.isChecked() ? View.VISIBLE : View.GONE );
}
//////////////////////////////////////////////////////////
// Account
@ -433,6 +438,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
if( ! attachment_list.isEmpty() ){
// 添付ファイルがあったら確認の上添付ファイルを捨てないと切り替えられない
Utils.showToast( this, false, R.string.cant_change_account_when_attachment_specified );
return;
}
final ArrayList< SavedAccount > tmp_account_list = new ArrayList<>();
@ -445,6 +451,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
}else{
tmp_account_list.addAll( account_list );
}
String[] caption_list = new String[ tmp_account_list.size() ];
for( int i = 0, ie = tmp_account_list.size() ; i < ie ; ++ i ){
caption_list[ i ] = tmp_account_list.get( i ).acct;
@ -490,14 +497,11 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
private void showMediaAttachment(){
if( attachment_list.isEmpty() ){
llAttachment.setVisibility( View.GONE );
cbNSFW.setVisibility( View.GONE );
}else{
llAttachment.setVisibility( View.VISIBLE );
cbNSFW.setVisibility( View.VISIBLE );
showAttachment_sub( ivMedia1, 0 );
showAttachment_sub( ivMedia2, 1 );
showAttachment_sub( ivMedia3, 2 );
showAttachment_sub( ivMedia4, 3 );
for(int i=0,ie=ivMedia.length;i<ie;++i){
showAttachment_sub( ivMedia[i], i );
}
}
}
@ -507,12 +511,10 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
}else{
iv.setVisibility( View.VISIBLE );
PostAttachment a = attachment_list.get( idx );
if( a.status == ATTACHMENT_UPLOADING ){
iv.setImageDrawable( Styler.getAttributeDrawable( this, R.attr.ic_loading ) );
}else if( a.attachment != null ){
if( a.attachment != null && a.status == ATTACHMENT_UPLOADED ){
iv.setImageUrl( a.attachment.preview_url, App1.getImageLoader() );
}else{
iv.setImageDrawable( Styler.getAttributeDrawable( this, R.attr.ic_unknown ) );
iv.setImageUrl( null, App1.getImageLoader() );
}
}
}
@ -622,6 +624,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
@Override
public void writeTo( BufferedSink sink ) throws IOException{
InputStream is = getContentResolver().openInputStream( uri );
if( is == null ) throw new IOException( "openInputStream() failed. uri="+uri );
try{
byte[] tmp = new byte[ 4096 ];
for( ; ; ){
@ -672,8 +675,14 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
attachment_list.remove( pa );
}else{
String sv = etContent.getText().toString();
int l = sv.length();
if( l > 0 ){
char c = sv.charAt( l - 1 );
if( c > 0x20 ) sv = sv + " ";
}
sv = sv + pa.attachment.text_url + " ";
etContent.setText( sv );
etContent.setSelection( sv.length() );
}
showMediaAttachment();
@ -797,7 +806,7 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
for( PostAttachment pa : attachment_list ){
if( pa.attachment != null ){
sb.append( "&media_ids[]=" + pa.attachment.id );
sb.append( "&media_ids[]=" ).append( pa.attachment.id );
}
}

View File

@ -1,221 +1,267 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical"
>
<LinearLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="12dp"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
android:fadingEdgeLength="20dp"
android:requiresFadingEdge="vertical"
android:cacheColorHint="#00000000"
android:scrollbarStyle="outsideOverlay"
android:fadeScrollbars="false"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorReplyBackground"
android:orientation="vertical"
android:padding="6dp"
android:id="@+id/llReply"
android:layout_marginBottom="12dp"
android:padding="12dp"
>
<TextView
<LinearLayout
android:id="@+id/llReply"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/reply_to_this_status"
/>
android:layout_marginBottom="4dp"
android:background="?attr/colorReplyBackground"
android:orientation="vertical"
android:padding="6dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/reply_to_this_status"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivReply"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginEnd="8dp"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<TextView
android:id="@+id/tvReplyTo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
/>
<ImageButton
android:id="@+id/btnRemoveReply"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="4dp"
android:background="@drawable/btn_bg_transparent"
android:gravity="center_vertical"
android:src="?attr/btn_close"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivReply"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:text="@string/post_from"
/>
<Button
android:id="@+id/btnAccount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/tvReplyTo"
android:gravity="center_vertical"
/>
<ImageButton
android:id="@+id/btnRemoveReply"
android:layout_marginStart="4dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@drawable/btn_bg_transparent"
android:gravity="center_vertical"
android:src="?attr/btn_close"
android:paddingEnd="8dp"
android:paddingStart="8dp"
android:textAllCaps="false"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:text="@string/post_from"
/>
<Button
android:id="@+id/btnAccount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/btn_bg_transparent"
<LinearLayout
android:id="@+id/llAttachment"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="4dp"
android:baselineAligned="false"
android:gravity="center_vertical"
android:paddingEnd="8dp"
android:paddingStart="8dp"
android:textAllCaps="false"
/>
</LinearLayout>
android:orientation="horizontal"
>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivMedia1"
android:layout_width="48dp"
android:layout_height="match_parent"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivMedia2"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginStart="4dp"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivMedia3"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginStart="4dp"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivMedia4"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginStart="4dp"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<CheckBox
android:id="@+id/cbNSFW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_marginStart="4dp"
android:text="@string/nsfw"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageButton
android:id="@+id/btnAttachment"
android:layout_width="wrap_content"
<CheckBox
android:id="@+id/cbContentWarning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg_transparent"
android:minHeight="48dp"
android:minWidth="48dp"
android:src="?attr/btn_attachment"
android:layout_marginTop="4dp"
android:text="@string/content_warning"
/>
<ImageButton
android:id="@+id/btnVisibility"
android:layout_width="wrap_content"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg_transparent"
android:minHeight="48dp"
android:minWidth="48dp"
/>
android:background="?attr/colorPostFormBackground"
>
<EditText
android:id="@+id/etContentWarning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/content_warning_hint"
android:inputType="text"
/>
</FrameLayout>
<TextView
android:id="@+id/tvCharCount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:gravity="end|center_vertical"
/>
<ImageButton
android:id="@+id/btnPost"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/btn_bg_transparent"
android:minHeight="48dp"
android:minWidth="48dp"
android:src="?attr/btn_post"
android:layout_marginTop="8dp"
android:text="@string/status"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPostFormBackground"
>
<EditText
android:id="@+id/etContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start|top"
android:hint="@string/content_hint"
android:inputType="textMultiLine"
android:minLines="5"
/>
</FrameLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/llAttachment"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginTop="12dp"
android:orientation="horizontal"
>
</ScrollView>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivMedia1"
android:layout_width="48dp"
android:layout_height="match_parent"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/color_column_header"
android:baselineAligned="false"
android:orientation="horizontal"
>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivMedia2"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivMedia3"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/ivMedia4"
android:layout_width="48dp"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:background="@drawable/btn_bg_transparent"
android:scaleType="fitCenter"
/>
</LinearLayout>
<CheckBox
android:id="@+id/cbNSFW"
android:layout_width="match_parent"
<ImageButton
android:id="@+id/btnAttachment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/nsfw"
android:background="@drawable/btn_bg_transparent"
android:minHeight="48dp"
android:minWidth="48dp"
android:src="?attr/btn_attachment"
/>
<CheckBox
android:id="@+id/cbContentWarning"
android:layout_width="match_parent"
<ImageButton
android:id="@+id/btnVisibility"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/content_warning"
/>
<EditText
android:id="@+id/etContentWarning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/content_warning_hint"
android:layout_marginStart="4dp"
android:background="@drawable/btn_bg_transparent"
android:minHeight="48dp"
android:minWidth="48dp"
tools:src="?attr/ic_public"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/status"
android:id="@+id/tvCharCount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="4dp"
android:layout_marginStart="4dp"
android:layout_weight="1"
android:gravity="end|center_vertical"
tools:text="-500"
tools:textColor="#f00"
/>
<EditText
android:id="@+id/etContent"
android:layout_width="match_parent"
<ImageButton
android:id="@+id/btnPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/content_hint"
android:inputType="textMultiLine"
android:background="@drawable/btn_bg_transparent"
android:minHeight="48dp"
android:minWidth="48dp"
android:src="?attr/btn_post"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -67,6 +67,9 @@
<!-- カラム設定の正規表現フィルタのエラー表示 #f00 -->
<attr name="colorRegexFilterError" format="color"/>
<!-- 投稿画面のEditTextの下に引くFrameLayoutの背景 -->
<attr name="colorPostFormBackground" format="color"/>
<attr name="btn_attachment" format="reference" />
<attr name="btn_boost" format="reference" />

View File

@ -22,7 +22,10 @@
<color name="Light_color_column_header">#cccccc</color>
<color name="Light_colorReplyBackground">#cccccc</color>
<color name="Light_colorSettingDivider">#ddd</color>
<color name="Light_colorPostFormBackground">#eee</color>
<color name="Light_colorProfileBackgroundMask">#C0FFFFFF</color>
<color name="Light_colorPrimaryDark">#303030</color>
@ -62,6 +65,7 @@
<color name="Dark_colorReplyBackground">#333</color>
<color name="Dark_colorSettingDivider">#222</color>
<color name="Dark_colorPostFormBackground">#111</color>
<color name="Dark_colorProfileBackgroundMask">#C0000000</color>
<color name="Dark_colorBackground">#000</color>

View File

@ -1,4 +1,6 @@
<resources>
<resources
>
<string name="app_name">Subway Tooter</string>
<string name="action_settings">Settings</string>

View File

@ -33,6 +33,7 @@
<item name="colorSettingDivider">@color/Light_colorSettingDivider</item>
<item name="colorRegexFilterError">@color/Light_colorRegexFilterError</item>
<item name="colorPostFormBackground">@color/Light_colorPostFormBackground</item>
<item name="btn_attachment">@drawable/btn_attachment</item>
@ -109,6 +110,7 @@
<item name="colorSearchFormBackground">@color/Dark_colorSearchFormBackground</item>
<item name="colorSettingDivider">@color/Dark_colorSettingDivider</item>
<item name="colorRegexFilterError">@color/Dark_colorRegexFilterError</item>
<item name="colorPostFormBackground">@color/Dark_colorPostFormBackground</item>
<item name="btn_attachment">@drawable/btn_attachment_dark</item>
<item name="btn_boost">@drawable/btn_boost_dark</item>