長押し操作。疑似アカウントTLからの操作動線の見直し。

This commit is contained in:
tateisu 2017-05-11 16:58:45 +09:00
parent 8e0266ce51
commit ed37e9cf35
7 changed files with 162 additions and 104 deletions

View File

@ -2,6 +2,9 @@
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintSetTextI18n" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="EmptyStatementBody" enabled="false" level="WARNING" enabled_by_default="false">
<option name="m_reportEmptyBlocks" value="true" />
</inspection_tool>
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />

View File

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

View File

@ -1110,7 +1110,7 @@ public class ActMain extends AppCompatActivity
return col;
}
void performOpenUser( SavedAccount access_info, TootAccount user ){
void performOpenUser( @NonNull SavedAccount access_info, @NonNull TootAccount user ){
if( access_info.isPseudo() ){
Utils.showToast( this, false, R.string.not_available_for_pseudo_account );
}else{
@ -1283,8 +1283,7 @@ public class ActMain extends AppCompatActivity
final String host = m.group( 1 );
final String user = Uri.decode( m.group( 2 ) );
startGetAccount( access_info, host, user, new GetAccountCallback() {
@Override
public void onGetAccount( TootAccount who ){
@Override public void onGetAccount( TootAccount who ){
if( who != null ){
performOpenUser( access_info, who );
return;
@ -1535,7 +1534,7 @@ public class ActMain extends AppCompatActivity
if( tmp.statuses != null && ! tmp.statuses.isEmpty() ){
target_status = tmp.statuses.get( 0 );
log.d("status id conversion %s => %s",arg_status.id,target_status.id);
log.d( "status id conversion %s => %s", arg_status.id, target_status.id );
}
}
if( target_status == null ){
@ -1692,7 +1691,7 @@ public class ActMain extends AppCompatActivity
// 検索APIに他タンスのステータスのURLを投げると自タンスのステータスを得られる
String path = String.format( Locale.JAPAN, Column.PATH_SEARCH, Uri.encode( arg_status.url ) );
path = path + "&resolve=1";
result = client.request( path );
if( result == null || result.object == null ){
return result;
@ -2598,4 +2597,74 @@ public class ActMain extends AppCompatActivity
vFooterDivider2.setBackgroundColor( c );
}
}
ArrayList< SavedAccount > makeAccountListNonPseudo( LogCategory log ){
ArrayList< SavedAccount > dst = new ArrayList<>();
for( SavedAccount a : SavedAccount.loadAccountList( log ) ){
if( ! a.isPseudo() ){
dst.add( a );
}
}
Collections.sort( dst, new Comparator< SavedAccount >() {
@Override public int compare( SavedAccount a, SavedAccount b ){
return String.CASE_INSENSITIVE_ORDER.compare( AcctColor.getNickname( a.acct ), AcctColor.getNickname( b.acct ) );
}
} );
return dst;
}
void openBoostFromAnotherAccount( @NonNull final SavedAccount access_info, final TootStatus status ){
if( status == null ) return;
AccountPicker.pick( this, false, false
, getString( R.string.account_picker_boost )
, makeAccountListNonPseudo(log)
, new AccountPicker.AccountPickerCallback() {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
performBoost(
ai
, !ai.host.equalsIgnoreCase( access_info.host )
, true
, status
, false
, boost_complete_callback
);
}
} );
}
void openFavouriteFromAnotherAccount( @NonNull final SavedAccount access_info, final TootStatus status ){
if( status == null ) return;
AccountPicker.pick( this, false, false
, getString( R.string.account_picker_favourite )
// , account_list_non_pseudo_same_instance
, makeAccountListNonPseudo( log )
, new AccountPicker.AccountPickerCallback() {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
performFavourite(
ai
, ! ai.host.equalsIgnoreCase( access_info.host )
, true
, status
, favourite_complete_callback
);
}
} );
}
void openFollowFromAnotherAccount( @NonNull SavedAccount access_info, TootStatus status ){
if( status == null ) return;
openFollowFromAnotherAccount( access_info, status.account );
}
void openFollowFromAnotherAccount( @NonNull SavedAccount access_info, final TootAccount account ){
if( account == null ) return;
final String who_acct = access_info.getFullAcct( account );
AccountPicker.pick( this, false, false
, getString( R.string.account_picker_follow )
, makeAccountListNonPseudo( log ), new AccountPicker.AccountPickerCallback() {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
callRemoteFollow( ai, who_acct, account.locked, false, follow_complete_callback );
}
} );
}
}

View File

@ -24,7 +24,7 @@ import jp.juggler.subwaytooter.table.SavedAccount;
import jp.juggler.subwaytooter.table.UserRelation;
import jp.juggler.subwaytooter.util.LogCategory;
class DlgContextMenu implements View.OnClickListener {
class DlgContextMenu implements View.OnClickListener, View.OnLongClickListener {
private static final LogCategory log = new LogCategory( "DlgContextMenu" );
@ -107,7 +107,11 @@ class DlgContextMenu implements View.OnClickListener {
btnFavouriteAnotherAccount.setOnClickListener( this );
btnBoostAnotherAccount.setOnClickListener( this );
}
if( status_by_me ){
if( access_info.isPseudo() ){
btnDelete.setVisibility( View.GONE );
btnReport.setVisibility( View.GONE );
btnMuteApp.setVisibility( View.GONE );
}else if( status_by_me ){
btnDelete.setOnClickListener( this );
btnReport.setVisibility( View.GONE );
btnMuteApp.setVisibility( View.GONE );
@ -130,6 +134,8 @@ class DlgContextMenu implements View.OnClickListener {
btnMute.setOnClickListener( this );
btnBlock.setOnClickListener( this );
btnFollow.setOnLongClickListener( this );
// 被フォロー状態
ImageView ivFollowedBy = (ImageView) viewRoot.findViewById( R.id.ivFollowedBy );
if( ! relation.followed_by ){
@ -253,7 +259,7 @@ class DlgContextMenu implements View.OnClickListener {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
activity.performFavourite(
ai
, !ai.host.equalsIgnoreCase( access_info.host )
, ! ai.host.equalsIgnoreCase( access_info.host )
, true
, status
, activity.favourite_complete_callback
@ -273,7 +279,7 @@ class DlgContextMenu implements View.OnClickListener {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
activity.performBoost(
ai
, !ai.host.equalsIgnoreCase( access_info.host )
, ! ai.host.equalsIgnoreCase( access_info.host )
, true
, status
, false
@ -323,7 +329,9 @@ class DlgContextMenu implements View.OnClickListener {
break;
case R.id.btnFollow:
if( relation.following || relation.requested ){
if( access_info.isPseudo() ){
activity.openFollowFromAnotherAccount( access_info, who );
}else if( relation.following || relation.requested ){
activity.callFollow( access_info, who, false, false, activity.unfollow_complete_callback );
}else{
activity.callFollow( access_info, who, true, false, activity.follow_complete_callback );
@ -383,14 +391,7 @@ class DlgContextMenu implements View.OnClickListener {
break;
case R.id.btnFollowFromAnotherAccount:
final String who_acct = access_info.getFullAcct( who );
AccountPicker.pick( activity, false, false
, activity.getString( R.string.account_picker_follow )
, account_list_non_pseudo, new AccountPicker.AccountPickerCallback() {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
activity.callRemoteFollow( ai, who_acct, who.locked, false, activity.follow_complete_callback );
}
} );
activity.openFollowFromAnotherAccount( access_info, who );
break;
case R.id.btnSendMessageFromAnotherAccount:
@ -416,4 +417,15 @@ class DlgContextMenu implements View.OnClickListener {
}
}
@Override public boolean onLongClick( View v ){
switch( v.getId() ){
case R.id.btnFollow:
dialog.dismiss();
activity.openFollowFromAnotherAccount( access_info, who );
return true;
}
return false;
}
}

View File

@ -16,7 +16,7 @@ import jp.juggler.subwaytooter.util.Emojione;
import jp.juggler.subwaytooter.util.MyLinkMovementMethod;
import jp.juggler.subwaytooter.util.MyNetworkImageView;
class HeaderViewHolder implements View.OnClickListener {
class HeaderViewHolder implements View.OnClickListener, View.OnLongClickListener {
private final Column column;
private final ActMain activity;
private final SavedAccount access_info;
@ -61,6 +61,8 @@ class HeaderViewHolder implements View.OnClickListener {
btnMore.setOnClickListener( this );
btnFollow.setOnClickListener( this );
btnFollow.setOnLongClickListener( this );
tvNote.setMovementMethod( MyLinkMovementMethod.getInstance() );
}
@ -145,4 +147,14 @@ class HeaderViewHolder implements View.OnClickListener {
}
}
@Override public boolean onLongClick( View v ){
switch( v.getId() ){
case R.id.btnFollow:
activity.openFollowFromAnotherAccount( access_info,who );
return true;
}
return false;
}
}

View File

@ -136,6 +136,7 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
ivMedia3.setOnClickListener( this );
ivMedia4.setOnClickListener( this );
btnFollow.setOnClickListener( this );
btnFollow.setOnLongClickListener( this );
ivThumbnail.setOnClickListener( this );
// ここを個別タップにすると邪魔すぎる tvName.setOnClickListener( this );
@ -407,13 +408,26 @@ class ItemViewHolder implements View.OnClickListener, View.OnLongClickListener {
}
case R.id.ivThumbnail:
activity.performOpenUser( access_info, account_thumbnail );
if( access_info.isPseudo() ){
new DlgContextMenu( activity, access_info,account_thumbnail, null, column.column_type ).show();
}else{
activity.performOpenUser( access_info, account_thumbnail );
}
break;
case R.id.llBoosted:
activity.performOpenUser( access_info, account_boost );
if( access_info.isPseudo() ){
new DlgContextMenu( activity, access_info,account_boost, null, column.column_type ).show();
}else{
activity.performOpenUser( access_info, account_boost );
}
break;
case R.id.llFollow:
activity.performOpenUser( access_info, account_follow );
if( access_info.isPseudo() ){
new DlgContextMenu( activity, access_info,account_follow, null, column.column_type ).show();
}else{
activity.performOpenUser( access_info, account_follow );
}
break;
case R.id.btnFollow:
new DlgContextMenu( activity, access_info, account_follow, null, column.column_type ).show();
@ -431,10 +445,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();
break;
return true;
case R.id.btnFollow:
activity.openFollowFromAnotherAccount( access_info,account_follow );
return true;
}
return false;
}

View File

@ -9,13 +9,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.PopupWindow;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import jp.juggler.subwaytooter.api.entity.TootStatus;
import jp.juggler.subwaytooter.dialog.AccountPicker;
import jp.juggler.subwaytooter.table.AcctColor;
import jp.juggler.subwaytooter.table.SavedAccount;
import jp.juggler.subwaytooter.table.UserRelation;
import jp.juggler.subwaytooter.util.LogCategory;
@ -34,7 +28,7 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
private final ImageView ivFollowedBy2;
private final View llFollow2;
StatusButtons( ActMain activity,Column column, View viewRoot ){
StatusButtons( @NonNull ActMain activity, @NonNull Column column, @NonNull View viewRoot ){
this.activity = activity;
this.column = column;
this.access_info = column.access_info;
@ -53,7 +47,6 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
btnFavourite.setOnLongClickListener( this );
btnFollow2.setOnLongClickListener( this );
View v;
//
v = viewRoot.findViewById( R.id.btnMore );
@ -70,7 +63,7 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
private TootStatus status;
private UserRelation relation;
void bind( TootStatus status ){
void bind( @NonNull TootStatus status ){
this.status = status;
int color_normal = Styler.getAttributeColor( activity, R.attr.colorImageButton );
@ -101,7 +94,6 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
llFollow2.setVisibility( View.VISIBLE );
this.relation = UserRelation.load( access_info.db_id, status.account.id );
Styler.setFollowIcon( activity, btnFollow2, ivFollowedBy2, relation, column.column_type );
}
}
@ -132,7 +124,7 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
break;
case R.id.btnBoost:
if( access_info.isPseudo() ){
Utils.showToast( activity, false, R.string.not_available_for_pseudo_account );
activity.openBoostFromAnotherAccount( access_info, status );
}else{
activity.performBoost(
access_info
@ -144,9 +136,10 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
);
}
break;
case R.id.btnFavourite:
if( access_info.isPseudo() ){
Utils.showToast( activity, false, R.string.not_available_for_pseudo_account );
activity.openFavouriteFromAnotherAccount( access_info, status );
}else{
activity.performFavourite(
access_info
@ -157,12 +150,15 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
);
}
break;
case R.id.btnMore:
new DlgContextMenu( activity, access_info, status.account, status, column.column_type ).show();
break;
case R.id.btnFollow2:
//noinspection StatementWithEmptyBody
if( relation.blocking || relation.muting ){
if( access_info.isPseudo() ){
activity.openFollowFromAnotherAccount( access_info, status );
}else if( relation.blocking || relation.muting ){
// 何もしない
}else if( relation.following || relation.requested ){
activity.callFollow( access_info, status.account, false, false, activity.unfollow_complete_callback );
@ -176,76 +172,21 @@ class StatusButtons implements View.OnClickListener, View.OnLongClickListener {
@Override public boolean onLongClick( View v ){
if( close_window != null ) close_window.dismiss();
switch( v.getId() ){
case R.id. btnBoost :
if( status != null ){
AccountPicker.pick( activity, false, false
, activity.getString( R.string.account_picker_boost )
, makeAccountListNonPseudo(log)
, new AccountPicker.AccountPickerCallback() {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
activity.performBoost(
ai
, !ai.host.equalsIgnoreCase( access_info.host )
, true
, status
, false
, activity.boost_complete_callback
);
}
} );
}
break;
case R.id. btnFavourite :
if( status != null ){
AccountPicker.pick( activity, false, false
, activity.getString( R.string.account_picker_favourite )
// , account_list_non_pseudo_same_instance
, makeAccountListNonPseudo( log )
, new AccountPicker.AccountPickerCallback() {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
activity.performFavourite(
ai
, !ai.host.equalsIgnoreCase( access_info.host )
, true
, status
, activity.favourite_complete_callback
);
}
} );
}
break;
case R.id. btnFollow2 :
if( status != null ){
final String who_acct = access_info.getFullAcct( status.account );
AccountPicker.pick( activity, false, false
, activity.getString( R.string.account_picker_follow )
, makeAccountListNonPseudo( log ), new AccountPicker.AccountPickerCallback() {
@Override public void onAccountPicked( @NonNull SavedAccount ai ){
activity.callRemoteFollow( ai, who_acct, status.account.locked, false, activity.follow_complete_callback );
}
} );
}
case R.id.btnBoost:
activity.openBoostFromAnotherAccount( access_info, status );
break;
case R.id.btnFavourite:
activity.openFavouriteFromAnotherAccount( access_info, status );
break;
case R.id.btnFollow2:
activity.openFollowFromAnotherAccount( access_info, status );
break;
}
return true;
}
ArrayList< SavedAccount > makeAccountListNonPseudo( LogCategory log){
ArrayList< SavedAccount > dst = new ArrayList<>();
for( SavedAccount a : SavedAccount.loadAccountList( log ) ){
if( ! a.isPseudo() ){
dst.add( a );
}
}
Collections.sort( dst, new Comparator< SavedAccount >() {
@Override public int compare( SavedAccount a, SavedAccount b ){
return String.CASE_INSENSITIVE_ORDER.compare( AcctColor.getNickname( a.acct ), AcctColor.getNickname( b.acct ) );
}
} );
return dst;
}
}