tootsearchカラムでCWとNSFWが複数トゥートを変更してしまう問題の修正。colorpickerライブラリをソースツリーに取り込み。

This commit is contained in:
tateisu 2017-12-22 21:59:52 +09:00
parent 8fafc8a9b0
commit 3820dd730b
8 changed files with 42 additions and 20 deletions

View File

@ -9,6 +9,7 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/colorpicker" />
<option value="$PROJECT_DIR$/exif" />
</set>
</option>

View File

@ -4,6 +4,7 @@
<modules>
<module fileurl="file://$PROJECT_DIR$/SubwayTooter.iml" filepath="$PROJECT_DIR$/SubwayTooter.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/colorpicker/colorpicker.iml" filepath="$PROJECT_DIR$/colorpicker/colorpicker.iml" />
<module fileurl="file://$PROJECT_DIR$/exif/exif.iml" filepath="$PROJECT_DIR$/exif/exif.iml" />
</modules>
</component>

View File

@ -57,6 +57,8 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':exif')
compile project(':colorpicker')
compile 'com.android.support:support-v4:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
@ -70,9 +72,8 @@ dependencies {
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.github.woxthebox:draglistview:1.5.1'
compile 'com.github.omadahealth:swipy:1.2.3@aar'
compile 'com.jrummyapps:colorpicker:2.1.7'
// compile 'com.jrummyapps:colorpicker:2.1.7'
compile 'com.github.kenglxn.QRGen:android:2.3.0'
compile project(':exif')
compile 'com.squareup.okhttp3:okhttp:3.9.1'
@ -95,7 +96,8 @@ dependencies {
implementation 'com.google.android.exoplayer:exoplayer:r2.5.4'
}
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
}
apply plugin: 'com.google.gms.google-services'

View File

@ -86,7 +86,7 @@ public abstract class TootStatusLike extends TootId {
}
public long getIdAccessOrOriginal(){
return id;
return id; // id != -1L ? id : parseStatusId();
}
public String getBusyKey(){
@ -130,6 +130,12 @@ public abstract class TootStatusLike extends TootId {
// ActivityPub 2
static final Pattern reTootUriAP2 = Pattern.compile( "https?://([^/]+)/@[A-Za-z0-9_]+/(\\d+)" );
// 投稿元タンスでのステータスIDを調べる
public long parseStatusId(){
return TootStatusLike.parseStatusId(this);
}
// 投稿元タンスでのステータスIDを調べる
public static long parseStatusId( @NonNull TootStatusLike status ){
String uri;

View File

@ -57,12 +57,17 @@ public class TSToot extends TootStatusLike {
dst.uri = Utils.optStringX( src, "uri" );
dst.host_original = dst.account.getAcctHost();
dst.host_access = "?";
dst.id = - 1L; // Utils.optLongX( src, "id", - 1L );
if( TextUtils.isEmpty( dst.url ) || TextUtils.isEmpty( dst.host_original ) ){
log.e( "missing status url or host or id" );
if( TextUtils.isEmpty( dst.uri )
|| TextUtils.isEmpty( dst.url )
|| TextUtils.isEmpty( dst.host_original )
){
log.e( "missing status uri or url or host or id" );
return null;
}
// uri から投稿元タンスでのIDを調べる
dst.id = TootStatusLike.parseStatusId( dst );
dst.created_at = Utils.optStringX( src, "created_at" );
dst.time_created_at = TootStatus.parseTime( dst.created_at );
@ -82,6 +87,8 @@ public class TSToot extends TootStatusLike {
.setLinkTag( dst )
.decodeHTML( context, access_info, dst.content );
return dst;
}

View File

@ -7,6 +7,7 @@ import android.support.annotation.NonNull;
import jp.juggler.subwaytooter.App1;
import jp.juggler.subwaytooter.api.entity.TootStatusLike;
import jp.juggler.subwaytooter.api_tootsearch.entity.TSToot;
import jp.juggler.subwaytooter.util.LogCategory;
public class ContentWarning {
@ -19,7 +20,7 @@ public class ContentWarning {
private static final String COL_TIME_SAVE = "time_save";
public static void onDBCreate( SQLiteDatabase db ){
log.d("onDBCreate!");
log.d( "onDBCreate!" );
db.execSQL(
"create table if not exists " + table
+ "(_id INTEGER PRIMARY KEY"
@ -36,15 +37,18 @@ public class ContentWarning {
public static void onDBUpgrade( SQLiteDatabase db, int oldVersion, int newVersion ){
if( oldVersion < 5 && newVersion >= 5 ){
db.execSQL( "drop table if exists "+table);
db.execSQL( "drop table if exists " + table );
onDBCreate( db );
}
}
private static final String[] projection_shown = new String[]{COL_SHOWN};
public static boolean isShown( @NonNull TootStatusLike status , boolean default_value ){
private static final String[] projection_shown = new String[]{ COL_SHOWN };
public static boolean isShown( @NonNull TootStatusLike status, boolean default_value ){
try{
Cursor cursor = App1.getDB().query( table, projection_shown, "h=? and si=?", new String[]{status.getHostAccessOrOriginal(), Long.toString(status.getIdAccessOrOriginal()) }, null, null, null );
Cursor cursor = App1.getDB().query( table, projection_shown, "h=? and si=?", new String[]{
status.getHostAccessOrOriginal(), Long.toString( status.getIdAccessOrOriginal() )
}, null, null, null );
try{
if( cursor.moveToFirst() ){
int iv = cursor.getInt( cursor.getColumnIndex( COL_SHOWN ) );
@ -56,24 +60,23 @@ public class ContentWarning {
}catch( Throwable ex ){
log.e( ex, "load failed." );
}
return default_value ;
return default_value;
}
public static void save( @NonNull TootStatusLike status ,boolean is_shown ){
public static void save( @NonNull TootStatusLike status, boolean is_shown ){
try{
long now = System.currentTimeMillis();
ContentValues cv = new ContentValues();
cv.put( COL_HOST, status.getHostAccessOrOriginal() );
cv.put( COL_STATUS_ID, status.getIdAccessOrOriginal() );
cv.put( COL_SHOWN, is_shown ? 1:0 );
cv.put( COL_SHOWN, is_shown ? 1 : 0 );
cv.put( COL_TIME_SAVE, now );
App1.getDB().replace( table, null, cv );
// 古いデータを掃除する
long expire = now - 86400000L * 365;
App1.getDB().delete( table,COL_TIME_SAVE+"<?",new String[]{Long.toString(expire)});
App1.getDB().delete( table, COL_TIME_SAVE + "<?", new String[]{ Long.toString( expire ) } );
}catch( Throwable ex ){
log.e( ex, "save failed." );

View File

@ -15,6 +15,8 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
}
}

View File

@ -1 +1 @@
include ':app', ':exif'
include ':app', ':exif', ':colorpicker'