mirror of
https://github.com/tateisu/SubwayTooter
synced 2025-01-28 01:29:23 +01:00
0.1.3 トゥートの削除
This commit is contained in:
parent
46d29a4f2d
commit
c8624ca1cb
@ -9,8 +9,8 @@ android {
|
||||
applicationId "jp.juggler.subwaytooter"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 25
|
||||
versionCode 12
|
||||
versionName "0.1.2"
|
||||
versionCode 13
|
||||
versionName "0.1.3"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.customtabs.CustomTabsIntent;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
@ -125,10 +126,9 @@ public class ActMain extends AppCompatActivity
|
||||
llEmpty.setVisibility( View.VISIBLE );
|
||||
}
|
||||
|
||||
Uri uri = ActOAuthCallback.last_uri.get();
|
||||
Uri uri = ActOAuthCallback.last_uri.getAndSet(null);
|
||||
if( uri != null ){
|
||||
ActOAuthCallback.last_uri.set( null );
|
||||
updateAccessToken( uri );
|
||||
handleIntentUri( uri );
|
||||
}
|
||||
}
|
||||
|
||||
@ -439,7 +439,8 @@ public class ActMain extends AppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAccessToken( final Uri uri ){
|
||||
// ActOAuthCallbackで受け取ったUriを処理する
|
||||
private void handleIntentUri( @NonNull final Uri uri ){
|
||||
|
||||
// 通知タップ
|
||||
// subwaytooter://notification_click?db_id=(db_id)
|
||||
@ -902,7 +903,7 @@ public class ActMain extends AppCompatActivity
|
||||
|
||||
private void performTootButton(){
|
||||
Column c = pager_adapter.getColumn( pager.getCurrentItem() );
|
||||
if( c != null && c.access_info != null ){
|
||||
if( c != null ){
|
||||
ActPost.open( this, c.access_info.db_id, "" );
|
||||
}
|
||||
}
|
||||
@ -912,7 +913,7 @@ public class ActMain extends AppCompatActivity
|
||||
}
|
||||
|
||||
public void performMention( SavedAccount account, TootAccount who ){
|
||||
ActPost.open( this, account.db_id, account.getFullAcct( who ) + " " );
|
||||
ActPost.open( this, account.db_id, "@"+account.getFullAcct( who ) + " " );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
@ -1408,10 +1409,9 @@ public class ActMain extends AppCompatActivity
|
||||
}
|
||||
|
||||
// アカウントを選択してからユーザをフォローする
|
||||
void followFromAnotherAccount( final SavedAccount access_info, final TootAccount who, final RelationChangedCallback callback ){
|
||||
AccountPicker.pick( ActMain.this, false, new AccountPicker.AccountPickerCallback() {
|
||||
@Override
|
||||
public void onAccountPicked( SavedAccount ai ){
|
||||
void followFromAccount( final SavedAccount access_info, final TootAccount who, final RelationChangedCallback callback ){
|
||||
AccountPicker.pick( ActMain.this, true, new AccountPicker.AccountPickerCallback() {
|
||||
@Override public void onAccountPicked( SavedAccount ai ){
|
||||
String acct = who.acct;
|
||||
if( ! acct.contains( "@" ) ){
|
||||
acct = acct + "@" + access_info.host;
|
||||
@ -1559,6 +1559,54 @@ public class ActMain extends AppCompatActivity
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
private void deleteStatus( final SavedAccount access_info, final long status_id ){
|
||||
new AsyncTask< Void, Void, TootApiResult >() {
|
||||
|
||||
@Override
|
||||
protected TootApiResult doInBackground( Void... params ){
|
||||
TootApiClient client = new TootApiClient( ActMain.this, new TootApiClient.Callback() {
|
||||
@Override
|
||||
public boolean isApiCancelled(){
|
||||
return isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishApiProgress( String s ){
|
||||
|
||||
}
|
||||
} );
|
||||
client.setAccount( access_info );
|
||||
|
||||
Request.Builder request_builder = new Request.Builder().delete();
|
||||
|
||||
TootApiResult result = client.request( "/api/v1/statuses/" + status_id , request_builder );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCancelled( TootApiResult result ){
|
||||
onPostExecute( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute( TootApiResult result ){
|
||||
boolean bOK = false;
|
||||
if( result != null ){
|
||||
if( result.object != null ){
|
||||
Utils.showToast( ActMain.this, false,R.string.delete_succeeded );
|
||||
for( Column column : pager_adapter.column_list ){
|
||||
column.removeStatus( access_info, status_id );
|
||||
}
|
||||
showColumnMatchAccount( access_info );
|
||||
}else{
|
||||
Utils.showToast( ActMain.this, false, result.error );
|
||||
}
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
|
||||
interface ReportCompleteCallback {
|
||||
void onReportComplete( TootApiResult result );
|
||||
@ -1652,6 +1700,13 @@ public class ActMain extends AppCompatActivity
|
||||
|
||||
ActionsDialog dialog = new ActionsDialog();
|
||||
|
||||
dialog.addAction( getString( R.string.open_web_page ), new Runnable() {
|
||||
@Override public void run(){
|
||||
// 強制的にブラウザで開く
|
||||
openChromeTab( access_info, status.url, true );
|
||||
}
|
||||
} );
|
||||
|
||||
final ArrayList< SavedAccount > tmp_list = new ArrayList<>();
|
||||
for( SavedAccount a : SavedAccount.loadAccountList( log ) ){
|
||||
if( a.host.equalsIgnoreCase( access_info.host ) ){
|
||||
@ -1680,17 +1735,18 @@ public class ActMain extends AppCompatActivity
|
||||
} );
|
||||
}
|
||||
|
||||
dialog.addAction( getString( R.string.follow ), new Runnable() {
|
||||
dialog.addAction( getString( R.string.follow_from_another_account ), new Runnable() {
|
||||
@Override public void run(){
|
||||
callFollow( access_info, status.account, true, null );
|
||||
followFromAccount( access_info, status.account, follow_comolete_callback );
|
||||
}
|
||||
} );
|
||||
|
||||
dialog.addAction( getString( R.string.follow_from_another_account ), new Runnable() {
|
||||
dialog.addAction( getString( R.string.follow ), new Runnable() {
|
||||
@Override public void run(){
|
||||
followFromAnotherAccount( access_info, status.account, follow_comolete_callback );
|
||||
callFollow( access_info, status.account, true, follow_comolete_callback );
|
||||
}
|
||||
} );
|
||||
|
||||
dialog.addAction( getString( R.string.unfollow ), new Runnable() {
|
||||
@Override public void run(){
|
||||
callFollow( access_info, status.account, false, null );
|
||||
@ -1721,16 +1777,18 @@ public class ActMain extends AppCompatActivity
|
||||
openReportForm( access_info, status.account, status );
|
||||
}
|
||||
} );
|
||||
dialog.addAction( getString( R.string.open_web_page ), new Runnable() {
|
||||
@Override public void run(){
|
||||
// 強制的にブラウザで開く
|
||||
openChromeTab( access_info, status.url, true );
|
||||
}
|
||||
} );
|
||||
if( access_info.isMe( status.account) ){
|
||||
dialog.addAction( getString( R.string.delete ), new Runnable() {
|
||||
@Override public void run(){
|
||||
deleteStatus( access_info, status.id );
|
||||
}
|
||||
} );
|
||||
}
|
||||
dialog.show( this, null );
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void openAccountMoreMenu( final SavedAccount access_info, final TootAccount who ){
|
||||
ActionsDialog dialog = new ActionsDialog();
|
||||
|
||||
@ -1741,12 +1799,12 @@ public class ActMain extends AppCompatActivity
|
||||
} );
|
||||
dialog.addAction( getString( R.string.follow ), new Runnable() {
|
||||
@Override public void run(){
|
||||
callFollow( access_info, who, true, null );
|
||||
callFollow( access_info, who, true, follow_comolete_callback );
|
||||
}
|
||||
} );
|
||||
dialog.addAction( getString( R.string.follow_from_another_account ), new Runnable() {
|
||||
@Override public void run(){
|
||||
followFromAnotherAccount( access_info, who, follow_comolete_callback );
|
||||
followFromAccount( access_info, who, follow_comolete_callback );
|
||||
}
|
||||
} );
|
||||
dialog.addAction( getString( R.string.unfollow ), new Runnable() {
|
||||
|
@ -224,13 +224,15 @@ public class ActPost extends AppCompatActivity implements View.OnClickListener {
|
||||
}
|
||||
|
||||
// mention を自動設定する
|
||||
String acct_me = account.getFullAcct( account );
|
||||
ArrayList< String > mention_list = new ArrayList<>();
|
||||
mention_list.add( account.getFullAcct( repley_status.account ) );
|
||||
mention_list.add( "@"+account.getFullAcct( repley_status.account ) );
|
||||
if( repley_status.mentions != null ){
|
||||
for( TootMention mention : repley_status.mentions ){
|
||||
sv = account.getFullAcct( mention.acct );
|
||||
if( !sv.equals( acct_me ) && ! mention_list.contains( sv ) ){
|
||||
|
||||
if( account.isMe(mention.acct)) continue;
|
||||
|
||||
sv = "@"+account.getFullAcct(mention.acct );
|
||||
if( ! mention_list.contains( sv ) ){
|
||||
mention_list.add( sv );
|
||||
}
|
||||
}
|
||||
|
@ -73,9 +73,11 @@ class Column {
|
||||
static final String KEY_COLUMN_NAME = "column_name";
|
||||
static final String KEY_OLD_INDEX = "old_index";
|
||||
|
||||
private final @NonNull ActMain activity;
|
||||
private final
|
||||
@NonNull ActMain activity;
|
||||
|
||||
final @NonNull SavedAccount access_info;
|
||||
final
|
||||
@NonNull SavedAccount access_info;
|
||||
|
||||
final int type;
|
||||
static final int TYPE_HOME = 1;
|
||||
@ -103,7 +105,6 @@ class Column {
|
||||
String search_query;
|
||||
boolean search_resolve;
|
||||
|
||||
|
||||
int scroll_pos;
|
||||
int scroll_y;
|
||||
|
||||
@ -112,24 +113,24 @@ class Column {
|
||||
this.access_info = access_info;
|
||||
this.type = type;
|
||||
switch( type ){
|
||||
|
||||
|
||||
case TYPE_CONVERSATION:
|
||||
this.status_id = (Long) getParamAt( params, 0 );
|
||||
break;
|
||||
|
||||
|
||||
case TYPE_PROFILE:
|
||||
this.profile_id = (Long) getParamAt( params, 0 );
|
||||
break;
|
||||
|
||||
|
||||
case TYPE_HASHTAG:
|
||||
this.hashtag = (String) getParamAt( params, 0 );
|
||||
break;
|
||||
|
||||
|
||||
case TYPE_SEARCH:
|
||||
this.search_query = (String) getParamAt( params, 0 );
|
||||
this.search_resolve = (Boolean) getParamAt( params, 1 );
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
startLoading();
|
||||
@ -164,32 +165,32 @@ class Column {
|
||||
|
||||
Column( @NonNull ActMain activity, JSONObject src ){
|
||||
this.activity = activity;
|
||||
|
||||
|
||||
SavedAccount ac = SavedAccount.loadAccount( log, src.optLong( KEY_ACCOUNT_ROW_ID ) );
|
||||
if( ac == null ) throw new RuntimeException( "missing account" );
|
||||
this.access_info = ac;
|
||||
|
||||
|
||||
this.type = src.optInt( KEY_TYPE );
|
||||
switch( type ){
|
||||
|
||||
|
||||
case TYPE_CONVERSATION:
|
||||
this.status_id = src.optLong( KEY_STATUS_ID );
|
||||
break;
|
||||
|
||||
|
||||
case TYPE_PROFILE:
|
||||
this.profile_id = src.optLong( KEY_PROFILE_ID );
|
||||
this.profile_tab = src.optInt( KEY_PROFILE_TAB );
|
||||
break;
|
||||
|
||||
|
||||
case TYPE_HASHTAG:
|
||||
this.hashtag = src.optString( KEY_HASHTAG );
|
||||
break;
|
||||
|
||||
|
||||
case TYPE_SEARCH:
|
||||
this.search_query = src.optString( KEY_SEARCH_QUERY );
|
||||
this.search_resolve = src.optBoolean( KEY_SEARCH_RESOLVE, false );
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
startLoading();
|
||||
}
|
||||
@ -287,8 +288,6 @@ class Column {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
interface StatusEntryCallback {
|
||||
void onIterate( TootStatus status );
|
||||
}
|
||||
@ -324,33 +323,61 @@ class Column {
|
||||
// ミュート、ブロックが成功した時に呼ばれる
|
||||
void removeStatusByAccount( SavedAccount target_account, long who_id ){
|
||||
if( ! target_account.acct.equals( access_info.acct ) ) return;
|
||||
{
|
||||
// remove from status_list
|
||||
ArrayList< Object > tmp_list = new ArrayList<>( list_data.size() );
|
||||
for( Object o : list_data ){
|
||||
if( o instanceof TootStatus ){
|
||||
TootStatus item = (TootStatus) o;
|
||||
if( item.account.id == who_id
|
||||
|| ( item.reblog != null && item.reblog.account.id == who_id )
|
||||
){
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList< Object > tmp_list = new ArrayList<>( list_data.size() );
|
||||
for( Object o : list_data ){
|
||||
if( o instanceof TootStatus ){
|
||||
TootStatus item = (TootStatus) o;
|
||||
if( item.account.id == who_id
|
||||
|| ( item.reblog != null && item.reblog.account.id == who_id )
|
||||
){
|
||||
continue;
|
||||
}
|
||||
if( o instanceof TootNotification ){
|
||||
TootNotification item = (TootNotification) o;
|
||||
if( item.account.id == who_id ) continue;
|
||||
if( item.status != null ){
|
||||
if( item.status.account.id == who_id ) continue;
|
||||
if( item.status.reblog != null && item.status.reblog.account.id == who_id )
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tmp_list.add( o );
|
||||
}
|
||||
list_data.clear();
|
||||
list_data.addAll( tmp_list );
|
||||
if( o instanceof TootNotification ){
|
||||
TootNotification item = (TootNotification) o;
|
||||
if( item.account.id == who_id ) continue;
|
||||
if( item.status != null ){
|
||||
if( item.status.account.id == who_id ) continue;
|
||||
if( item.status.reblog != null && item.status.reblog.account.id == who_id )
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tmp_list.add( o );
|
||||
}
|
||||
list_data.clear();
|
||||
list_data.addAll( tmp_list );
|
||||
}
|
||||
|
||||
// 自分のステータスを削除した時に呼ばれる
|
||||
void removeStatus( SavedAccount target_account, long status_id ){
|
||||
|
||||
if( ! target_account.host.equals( access_info.host ) ) return;
|
||||
|
||||
ArrayList< Object > tmp_list = new ArrayList<>( list_data.size() );
|
||||
for( Object o : list_data ){
|
||||
if( o instanceof TootStatus ){
|
||||
TootStatus item = (TootStatus) o;
|
||||
if( item.id == status_id
|
||||
|| ( item.reblog != null && item.reblog.id == status_id )
|
||||
){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if( o instanceof TootNotification ){
|
||||
TootNotification item = (TootNotification) o;
|
||||
if( item.status != null ){
|
||||
if( item.status.id == status_id ) continue;
|
||||
if( item.status.reblog != null && item.status.reblog.id == status_id )
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tmp_list.add( o );
|
||||
}
|
||||
list_data.clear();
|
||||
list_data.addAll( tmp_list );
|
||||
}
|
||||
|
||||
interface VisualCallback {
|
||||
@ -412,7 +439,6 @@ class Column {
|
||||
|
||||
final ArrayList< Object > list_data = new ArrayList<>();
|
||||
|
||||
|
||||
void reload(){
|
||||
list_data.clear();
|
||||
startLoading();
|
||||
@ -471,14 +497,14 @@ class Column {
|
||||
TootApiResult parseNotifications( TootApiResult result ){
|
||||
if( result != null ){
|
||||
saveRange( result, true, true );
|
||||
TootNotification.List src= TootNotification.parseList( log, access_info, result.array );
|
||||
if( src != null){
|
||||
TootNotification.List src = TootNotification.parseList( log, access_info, result.array );
|
||||
if( src != null ){
|
||||
list_tmp = new ArrayList<>();
|
||||
list_tmp.addAll( src );
|
||||
//
|
||||
AlarmService.injectData( activity,access_info.db_id, src );
|
||||
AlarmService.injectData( activity, access_info.db_id, src );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -527,7 +553,7 @@ class Column {
|
||||
client.callback.publishApiProgress( "" );
|
||||
}
|
||||
switch( profile_tab ){
|
||||
|
||||
|
||||
default:
|
||||
case TAB_STATUS:
|
||||
return parseStatuses( client.request(
|
||||
@ -622,7 +648,6 @@ class Column {
|
||||
list_data.clear();
|
||||
list_data.addAll( list_tmp );
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -735,7 +760,7 @@ class Column {
|
||||
list_tmp = new ArrayList<>();
|
||||
list_tmp.addAll( src );
|
||||
//
|
||||
AlarmService.injectData( activity,access_info.db_id, src );
|
||||
AlarmService.injectData( activity, access_info.db_id, src );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -765,7 +790,7 @@ class Column {
|
||||
client.setAccount( access_info );
|
||||
|
||||
switch( type ){
|
||||
|
||||
|
||||
default:
|
||||
case TYPE_HOME:
|
||||
return parseStatuses( client.request( addRange( bBottom, PATH_HOME ) ) );
|
||||
@ -793,22 +818,21 @@ class Column {
|
||||
client.callback.publishApiProgress( "" );
|
||||
}
|
||||
switch( profile_tab ){
|
||||
|
||||
|
||||
default:
|
||||
case TAB_STATUS:
|
||||
return parseStatuses( client.request(addRange( bBottom,
|
||||
String.format( Locale.JAPAN, PATH_ACCOUNT_STATUSES, profile_id ) ) ));
|
||||
|
||||
return parseStatuses( client.request( addRange( bBottom,
|
||||
String.format( Locale.JAPAN, PATH_ACCOUNT_STATUSES, profile_id ) ) ) );
|
||||
|
||||
case TAB_FOLLOWING:
|
||||
return parseAccountList( client.request(addRange( bBottom,
|
||||
String.format( Locale.JAPAN, PATH_ACCOUNT_FOLLOWING, profile_id ) ) ));
|
||||
|
||||
return parseAccountList( client.request( addRange( bBottom,
|
||||
String.format( Locale.JAPAN, PATH_ACCOUNT_FOLLOWING, profile_id ) ) ) );
|
||||
|
||||
case TAB_FOLLOWERS:
|
||||
return parseAccountList( client.request(addRange( bBottom,
|
||||
String.format( Locale.JAPAN, PATH_ACCOUNT_FOLLOWERS, profile_id ) ) ));
|
||||
return parseAccountList( client.request( addRange( bBottom,
|
||||
String.format( Locale.JAPAN, PATH_ACCOUNT_FOLLOWERS, profile_id ) ) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
case TYPE_HASHTAG:
|
||||
return parseStatuses( client.request( addRange( bBottom,
|
||||
|
@ -15,7 +15,7 @@ import jp.juggler.subwaytooter.api.entity.TootAccount;
|
||||
import jp.juggler.subwaytooter.util.LinkClickContext;
|
||||
import jp.juggler.subwaytooter.util.LogCategory;
|
||||
|
||||
public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
public class SavedAccount extends TootAccount implements LinkClickContext {
|
||||
private static final LogCategory log = new LogCategory( "SavedAccount" );
|
||||
|
||||
private static final String table = "access_info";
|
||||
@ -25,7 +25,7 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
private static final String COL_USER = "u";
|
||||
private static final String COL_ACCOUNT = "a";
|
||||
private static final String COL_TOKEN = "t";
|
||||
|
||||
|
||||
private static final String COL_VISIBILITY = "visibility";
|
||||
private static final String COL_CONFIRM_BOOST = "confirm_boost";
|
||||
private static final String COL_DONT_HIDE_NSFW = "dont_hide_nsfw";
|
||||
@ -34,7 +34,7 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
private static final String COL_NOTIFICATION_FAVOURITE = "notification_favourite";
|
||||
private static final String COL_NOTIFICATION_FOLLOW = "notification_follow";
|
||||
|
||||
public static final long INVALID_ID = -1L;
|
||||
public static final long INVALID_ID = - 1L;
|
||||
|
||||
// login information
|
||||
public long db_id = INVALID_ID;
|
||||
@ -67,31 +67,31 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
+ ",notification_follow integer default 1"
|
||||
+ ")"
|
||||
);
|
||||
db.execSQL("create index if not exists " + table + "_user on " + table + "(u)" );
|
||||
db.execSQL("create index if not exists " + table + "_host on " + table + "(h,u)" );
|
||||
db.execSQL( "create index if not exists " + table + "_user on " + table + "(u)" );
|
||||
db.execSQL( "create index if not exists " + table + "_host on " + table + "(h,u)" );
|
||||
}
|
||||
|
||||
public static void onDBUpgrade( SQLiteDatabase db, int oldVersion, int newVersion ){
|
||||
if( oldVersion < 2 && newVersion >= 2){
|
||||
if( oldVersion < 2 && newVersion >= 2 ){
|
||||
try{
|
||||
db.execSQL( "alter table "+table+" add column notification_mention integer default 1" );
|
||||
}catch(Throwable ex){
|
||||
ex.printStackTrace( );
|
||||
db.execSQL( "alter table " + table + " add column notification_mention integer default 1" );
|
||||
}catch( Throwable ex ){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try{
|
||||
db.execSQL( "alter table "+table+" add column notification_boost integer default 1" );
|
||||
}catch(Throwable ex){
|
||||
ex.printStackTrace( );
|
||||
db.execSQL( "alter table " + table + " add column notification_boost integer default 1" );
|
||||
}catch( Throwable ex ){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try{
|
||||
db.execSQL( "alter table "+table+" add column notification_favourite integer default 1" );
|
||||
}catch(Throwable ex){
|
||||
ex.printStackTrace( );
|
||||
db.execSQL( "alter table " + table + " add column notification_favourite integer default 1" );
|
||||
}catch( Throwable ex ){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try{
|
||||
db.execSQL( "alter table "+table+" add column notification_follow integer default 1" );
|
||||
}catch(Throwable ex){
|
||||
ex.printStackTrace( );
|
||||
db.execSQL( "alter table " + table + " add column notification_follow integer default 1" );
|
||||
}catch( Throwable ex ){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,18 +99,18 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
private SavedAccount(){
|
||||
}
|
||||
|
||||
private static SavedAccount parse( Cursor cursor ) throws JSONException{
|
||||
private static SavedAccount parse( Cursor cursor ) throws JSONException{
|
||||
JSONObject src = new JSONObject( cursor.getString( cursor.getColumnIndex( COL_ACCOUNT ) ) );
|
||||
SavedAccount dst = new SavedAccount();
|
||||
dst = (SavedAccount)parse(log,dst,src,dst);
|
||||
if( dst != null){
|
||||
dst = (SavedAccount) parse( log, dst, src, dst );
|
||||
if( dst != null ){
|
||||
dst.db_id = cursor.getLong( cursor.getColumnIndex( COL_ID ) );
|
||||
dst.host = cursor.getString( cursor.getColumnIndex( COL_HOST ) );
|
||||
dst.acct = cursor.getString( cursor.getColumnIndex( COL_USER ) );
|
||||
|
||||
int colIdx_visibility = cursor.getColumnIndex( COL_VISIBILITY );
|
||||
dst.visibility = cursor.isNull( colIdx_visibility )? null : cursor.getString( colIdx_visibility );
|
||||
|
||||
dst.visibility = cursor.isNull( colIdx_visibility ) ? null : cursor.getString( colIdx_visibility );
|
||||
|
||||
dst.confirm_boost = ( 0 != cursor.getInt( cursor.getColumnIndex( COL_CONFIRM_BOOST ) ) );
|
||||
dst.dont_hide_nsfw = ( 0 != cursor.getInt( cursor.getColumnIndex( COL_DONT_HIDE_NSFW ) ) );
|
||||
|
||||
@ -124,15 +124,14 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
public static long insert( String host, String acct, JSONObject account,JSONObject token ){
|
||||
public static long insert( String host, String acct, JSONObject account, JSONObject token ){
|
||||
try{
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put( COL_HOST, host );
|
||||
cv.put( COL_USER, acct );
|
||||
cv.put( COL_ACCOUNT, account.toString() );
|
||||
cv.put( COL_TOKEN, token.toString() );
|
||||
return App1.getDB().insert( table, null, cv );
|
||||
return App1.getDB().insert( table, null, cv );
|
||||
}catch( Throwable ex ){
|
||||
log.e( ex, "saveAccount failed." );
|
||||
}
|
||||
@ -141,7 +140,7 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
|
||||
public void delete(){
|
||||
try{
|
||||
App1.getDB().delete( table, COL_ID + "=?", new String[]{ Long.toString(db_id) } );
|
||||
App1.getDB().delete( table, COL_ID + "=?", new String[]{ Long.toString( db_id ) } );
|
||||
}catch( Throwable ex ){
|
||||
log.e( ex, "saveAccount failed." );
|
||||
}
|
||||
@ -150,33 +149,33 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
public void updateTokenInfo( JSONObject token_info ){
|
||||
if( db_id != INVALID_ID ){
|
||||
this.token_info = token_info;
|
||||
|
||||
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put( COL_TOKEN, token_info.toString() );
|
||||
App1.getDB().update( table, cv, COL_ID + "=?", new String[]{ Long.toString(db_id) } );
|
||||
App1.getDB().update( table, cv, COL_ID + "=?", new String[]{ Long.toString( db_id ) } );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveSetting(){
|
||||
if( db_id != INVALID_ID ){
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put( COL_VISIBILITY, visibility );
|
||||
cv.put( COL_CONFIRM_BOOST, confirm_boost? 1:0 );
|
||||
cv.put( COL_DONT_HIDE_NSFW, dont_hide_nsfw ? 1: 0 );
|
||||
cv.put( COL_CONFIRM_BOOST, confirm_boost ? 1 : 0 );
|
||||
cv.put( COL_DONT_HIDE_NSFW, dont_hide_nsfw ? 1 : 0 );
|
||||
|
||||
cv.put( COL_NOTIFICATION_MENTION, notification_mention ? 1: 0 );
|
||||
cv.put( COL_NOTIFICATION_BOOST, notification_boost ? 1: 0 );
|
||||
cv.put( COL_NOTIFICATION_FAVOURITE, notification_favourite ? 1: 0 );
|
||||
cv.put( COL_NOTIFICATION_FOLLOW, notification_follow ? 1: 0 );
|
||||
|
||||
App1.getDB().update( table, cv, COL_ID + "=?", new String[]{ Long.toString(db_id) } );
|
||||
cv.put( COL_NOTIFICATION_MENTION, notification_mention ? 1 : 0 );
|
||||
cv.put( COL_NOTIFICATION_BOOST, notification_boost ? 1 : 0 );
|
||||
cv.put( COL_NOTIFICATION_FAVOURITE, notification_favourite ? 1 : 0 );
|
||||
cv.put( COL_NOTIFICATION_FOLLOW, notification_follow ? 1 : 0 );
|
||||
|
||||
App1.getDB().update( table, cv, COL_ID + "=?", new String[]{ Long.toString( db_id ) } );
|
||||
}
|
||||
}
|
||||
|
||||
// onResumeの時に設定を読み直す
|
||||
public void reloadSetting(){
|
||||
if( db_id != INVALID_ID ){
|
||||
SavedAccount b = loadAccount( log,db_id );
|
||||
SavedAccount b = loadAccount( log, db_id );
|
||||
if( b != null ){
|
||||
this.visibility = b.visibility;
|
||||
this.confirm_boost = b.confirm_boost;
|
||||
@ -192,7 +191,7 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
|
||||
public static SavedAccount loadAccount( LogCategory log, long db_id ){
|
||||
try{
|
||||
Cursor cursor = App1.getDB().query( table, null, COL_ID+"=?", new String[]{ Long.toString(db_id) }, null, null, null );
|
||||
Cursor cursor = App1.getDB().query( table, null, COL_ID + "=?", new String[]{ Long.toString( db_id ) }, null, null, null );
|
||||
try{
|
||||
if( cursor.moveToFirst() ){
|
||||
return parse( cursor );
|
||||
@ -205,8 +204,8 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList< SavedAccount > loadAccountList(LogCategory log){
|
||||
|
||||
public static ArrayList< SavedAccount > loadAccountList( LogCategory log ){
|
||||
ArrayList< SavedAccount > result = new ArrayList<>();
|
||||
|
||||
try{
|
||||
@ -225,17 +224,37 @@ public class SavedAccount extends TootAccount implements LinkClickContext{
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getFullAcct(TootAccount who ){
|
||||
return who==null ? "@?" : getFullAcct( who.acct );
|
||||
public String getFullAcct( TootAccount who ){
|
||||
return getFullAcct( who == null ? null : who.acct );
|
||||
}
|
||||
|
||||
public String getFullAcct( String acct ){
|
||||
if( acct ==null ) return "@?";
|
||||
if( -1 != acct.indexOf( '@' ) ){
|
||||
return "@" + acct;
|
||||
if( acct == null ) return "?";
|
||||
if( - 1 != acct.indexOf( '@' ) ){
|
||||
return acct;
|
||||
}else{
|
||||
return "@"+ acct +"@"+ this.host;
|
||||
return acct + "@" + this.host;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMe( TootAccount who ){
|
||||
int pos = this.acct.indexOf( '@' );
|
||||
String this_user = this.acct.substring( 0, pos );
|
||||
//
|
||||
if( ! this_user.equals( who.username ) ) return false;
|
||||
//
|
||||
pos = who.acct.indexOf( '@' );
|
||||
return pos == - 1 || this.host.equalsIgnoreCase( who.acct.substring( pos + 1 ) );
|
||||
}
|
||||
|
||||
public boolean isMe( String who_acct ){
|
||||
int pos = this.acct.indexOf( '@' );
|
||||
String this_user = this.acct.substring( 0, pos );
|
||||
//
|
||||
pos = who_acct.indexOf( '@' );
|
||||
if( pos == - 1 ) return this_user.equals( who_acct );
|
||||
//
|
||||
return this_user.equals( who_acct.substring( 0, pos ) )
|
||||
&& this.host.equalsIgnoreCase( who_acct.substring( pos + 1 ) );
|
||||
}
|
||||
}
|
||||
|
@ -155,4 +155,5 @@
|
||||
<string name="back_button_action">戻るボタンの動作</string>
|
||||
<string name="prior_local_url_when_open_attachment">添付画像を開く時に自タンスURLを重視</string>
|
||||
<string name="disable_fast_scroller">FastScrollerを無効にする(アプリ再起動が必要)</string>
|
||||
<string name="delete_succeeded">削除できました</string>
|
||||
</resources>
|
||||
|
@ -154,4 +154,5 @@
|
||||
<string name="back_button_action">back button action</string>
|
||||
<string name="prior_local_url_when_open_attachment">prior local URL when open attachment</string>
|
||||
<string name="disable_fast_scroller">disable fast scroller (app restart required)</string>
|
||||
<string name="delete_succeeded">delete succeeded</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user