mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-28 01:29:23 +01:00
カラム設定に保護を追加
This commit is contained in:
parent
04f25e1734
commit
b4ba5c7f96
@ -120,6 +120,11 @@ public class ActColumnList extends AppCompatActivity {
|
||||
// 左にスワイプした(右端に青が見えた) なら要素を削除する
|
||||
if( swipedDirection == ListSwipeItem.SwipeDirection.LEFT ){
|
||||
MyItem adapterItem = (MyItem) item.getTag();
|
||||
if( adapterItem.json.optBoolean( Column.KEY_DONT_CLOSE,false )){
|
||||
Utils.showToast( ActColumnList.this,false,R.string.column_has_dont_close_option );
|
||||
listView.resetSwipedViews(null);
|
||||
return;
|
||||
}
|
||||
listAdapter.removeItem( listAdapter.getPositionForItem( adapterItem ) );
|
||||
}
|
||||
}
|
||||
@ -218,6 +223,10 @@ public class ActColumnList extends AppCompatActivity {
|
||||
, true // 長押しでドラッグ開始するなら真
|
||||
);
|
||||
|
||||
ivBookmark = viewRoot.findViewById( R.id.ivBookmark );
|
||||
tvAccess = (TextView) viewRoot.findViewById( R.id.tvAccess );
|
||||
tvName = (TextView) viewRoot.findViewById( R.id.tvName );
|
||||
|
||||
// リスト要素のビューが ListSwipeItem だった場合、Swipe操作を制御できる
|
||||
if( viewRoot instanceof ListSwipeItem ){
|
||||
ListSwipeItem lsi = (ListSwipeItem) viewRoot;
|
||||
@ -225,12 +234,11 @@ public class ActColumnList extends AppCompatActivity {
|
||||
lsi.setSupportedSwipeDirection( ListSwipeItem.SwipeDirection.LEFT );
|
||||
}
|
||||
|
||||
ivBookmark = viewRoot.findViewById( R.id.ivBookmark );
|
||||
tvAccess = (TextView) viewRoot.findViewById( R.id.tvAccess );
|
||||
tvName = (TextView) viewRoot.findViewById( R.id.tvName );
|
||||
}
|
||||
|
||||
void bind( MyItem item ){
|
||||
|
||||
|
||||
itemView.setTag( item ); // itemView は親クラスのメンバ変数
|
||||
ivBookmark.setVisibility( item.bOldSelection ? View.VISIBLE: View.INVISIBLE );
|
||||
tvAccess.setText( item.access );
|
||||
|
@ -631,6 +631,11 @@ public class ActMain extends AppCompatActivity
|
||||
}
|
||||
|
||||
public void performColumnClose( boolean bConfirm, final Column column ){
|
||||
if( column.dont_close){
|
||||
Utils.showToast( this,false,R.string.column_has_dont_close_option );
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! bConfirm && ! pref.getBoolean( Pref.KEY_DONT_CONFIRM_BEFORE_CLOSE_COLUMN, false ) ){
|
||||
new AlertDialog.Builder( this )
|
||||
.setMessage( R.string.confirm_close_column )
|
||||
|
@ -73,6 +73,9 @@ class Column {
|
||||
private static final String KEY_ACCOUNT_ROW_ID = "account_id";
|
||||
private static final String KEY_TYPE = "type";
|
||||
private static final String KEY_WITH_ATTACHMENT = "with_attachment";
|
||||
static final String KEY_DONT_CLOSE = "dont_close";
|
||||
|
||||
|
||||
private static final String KEY_PROFILE_ID = "profile_id";
|
||||
private static final String KEY_PROFILE_TAB = "tab";
|
||||
private static final String KEY_STATUS_ID = "status_id";
|
||||
@ -103,6 +106,7 @@ class Column {
|
||||
final int type;
|
||||
|
||||
boolean with_attachment;
|
||||
boolean dont_close;
|
||||
|
||||
private long profile_id;
|
||||
volatile TootAccount who_account;
|
||||
@ -153,6 +157,7 @@ class Column {
|
||||
item.put( KEY_ACCOUNT_ROW_ID, access_info.db_id );
|
||||
item.put( KEY_TYPE, type );
|
||||
item.put( KEY_WITH_ATTACHMENT, with_attachment );
|
||||
item.put( KEY_DONT_CLOSE, dont_close );
|
||||
|
||||
switch( type ){
|
||||
case TYPE_CONVERSATION:
|
||||
@ -185,6 +190,7 @@ class Column {
|
||||
this.access_info = ac;
|
||||
this.type = src.optInt( KEY_TYPE );
|
||||
this.with_attachment = src.optBoolean( KEY_WITH_ATTACHMENT );
|
||||
this.dont_close = src.optBoolean( KEY_DONT_CLOSE );
|
||||
|
||||
switch( type ){
|
||||
|
||||
|
@ -76,12 +76,9 @@ class ColumnViewHolder implements View.OnClickListener, Column.VisualCallback, S
|
||||
private CheckBox cbResolve;
|
||||
private View llColumnSetting;
|
||||
|
||||
|
||||
void onPageCreate( View root, int page_idx, int page_count ){
|
||||
log.d( "onPageCreate:%s", column.getColumnName( true ) );
|
||||
|
||||
|
||||
|
||||
( (TextView) root.findViewById( R.id.tvColumnIndex ) )
|
||||
.setText( activity.getString( R.string.column_index, page_idx + 1, page_count ) );
|
||||
|
||||
@ -108,10 +105,10 @@ class ColumnViewHolder implements View.OnClickListener, Column.VisualCallback, S
|
||||
|
||||
listView.setFastScrollEnabled( ! Pref.pref( activity ).getBoolean( Pref.KEY_DISABLE_FAST_SCROLLER, false ) );
|
||||
|
||||
boolean bAllowColumnSetting;
|
||||
boolean bAllowMediaOnly;
|
||||
switch( column.type ){
|
||||
default:
|
||||
bAllowColumnSetting = true;
|
||||
bAllowMediaOnly = true;
|
||||
break;
|
||||
case Column.TYPE_SEARCH:
|
||||
case Column.TYPE_CONVERSATION:
|
||||
@ -119,22 +116,23 @@ class ColumnViewHolder implements View.OnClickListener, Column.VisualCallback, S
|
||||
case Column.TYPE_BLOCKS:
|
||||
case Column.TYPE_MUTES:
|
||||
case Column.TYPE_NOTIFICATIONS:
|
||||
bAllowColumnSetting = false;
|
||||
bAllowMediaOnly = false;
|
||||
break;
|
||||
}
|
||||
View btnColumnSetting = root.findViewById( R.id.btnColumnSetting );
|
||||
llColumnSetting = root.findViewById( R.id.llColumnSetting );
|
||||
if( ! bAllowColumnSetting ){
|
||||
btnColumnSetting.setVisibility( View.GONE );
|
||||
llColumnSetting.setVisibility( View.GONE );
|
||||
}else{
|
||||
btnColumnSetting.setVisibility( View.VISIBLE );
|
||||
btnColumnSetting.setOnClickListener( this );
|
||||
llColumnSetting.setVisibility( View.GONE );
|
||||
CheckBox cbWithAttachment = (CheckBox) root.findViewById( R.id.cbWithAttachment );
|
||||
cbWithAttachment.setChecked( column.with_attachment );
|
||||
cbWithAttachment.setOnCheckedChangeListener( this );
|
||||
}
|
||||
btnColumnSetting.setVisibility( View.VISIBLE );
|
||||
btnColumnSetting.setOnClickListener( this );
|
||||
llColumnSetting.setVisibility( View.GONE );
|
||||
|
||||
CheckBox cbWithAttachment = (CheckBox) root.findViewById( R.id.cbWithAttachment );
|
||||
cbWithAttachment.setChecked( column.with_attachment );
|
||||
cbWithAttachment.setOnCheckedChangeListener( this );
|
||||
cbWithAttachment.setEnabled( bAllowMediaOnly );
|
||||
|
||||
CheckBox cbDontCloseColumn = (CheckBox) root.findViewById( R.id.cbDontCloseColumn );
|
||||
cbDontCloseColumn.setChecked( column.dont_close );
|
||||
cbDontCloseColumn.setOnCheckedChangeListener( this );
|
||||
|
||||
if( column.type != Column.TYPE_SEARCH ){
|
||||
llSearch.setVisibility( View.GONE );
|
||||
@ -173,11 +171,18 @@ class ColumnViewHolder implements View.OnClickListener, Column.VisualCallback, S
|
||||
|
||||
@Override public void onCheckedChanged( CompoundButton view, boolean isChecked ){
|
||||
switch( view.getId() ){
|
||||
|
||||
case R.id.cbWithAttachment:
|
||||
column.with_attachment = isChecked;
|
||||
activity.saveColumnList();
|
||||
column.reload();
|
||||
break;
|
||||
|
||||
case R.id.cbDontCloseColumn:
|
||||
column.dont_close = isChecked;
|
||||
activity.saveColumnList();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,7 +286,7 @@ class ColumnViewHolder implements View.OnClickListener, Column.VisualCallback, S
|
||||
swipyRefreshLayout.setVisibility( View.VISIBLE );
|
||||
status_adapter.set( column.list_data );
|
||||
if( column.scroll_hack > 0 ){
|
||||
listView.setSelectionFromTop( column.scroll_hack-1,-(int)(0.5f + 80f * activity.density ));
|
||||
listView.setSelectionFromTop( column.scroll_hack - 1, - (int) ( 0.5f + 80f * activity.density ) );
|
||||
column.scroll_hack = 0;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,12 @@
|
||||
android:text="@string/with_attachment"
|
||||
android:id="@+id/cbWithAttachment"
|
||||
/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dont_close_column"
|
||||
android:id="@+id/cbDontCloseColumn"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -169,4 +169,6 @@
|
||||
<string name="send_header_from_name">From-Name</string>
|
||||
<string name="send_header_content_warning">Content-Warning</string>
|
||||
<string name="send_header_url">Status-URL</string>
|
||||
<string name="column_has_dont_close_option">保護されたカラムは閉じられません</string>
|
||||
<string name="dont_close_column">保護(閉じることができない)</string>
|
||||
</resources>
|
||||
|
@ -168,4 +168,6 @@
|
||||
<string name="send_header_from_name">From-Name</string>
|
||||
<string name="send_header_content_warning">Content-Warning</string>
|
||||
<string name="send_header_url">Status-URL</string>
|
||||
<string name="dont_close_column">don\'t close column</string>
|
||||
<string name="column_has_dont_close_option">this column has \'dont close\' option.</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user