diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/impl/MastodonStatus.java b/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/impl/MastodonStatus.java index 4a69b1ee..3c421ac1 100644 --- a/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/impl/MastodonStatus.java +++ b/app/src/main/java/org/nuclearfog/twidda/backend/api/mastodon/impl/MastodonStatus.java @@ -377,9 +377,6 @@ public class MastodonStatus implements Status { if (embeddedStatus instanceof MastodonStatus) { ((MastodonStatus) embeddedStatus).setRepost(reposted); } - if (!reposted && reblogCount > 0) { - reblogCount--; - } } /** @@ -390,9 +387,6 @@ public class MastodonStatus implements Status { if (embeddedStatus instanceof MastodonStatus) { ((MastodonStatus) embeddedStatus).setFavorite(favorited); } - if (!favorited && favoriteCount > 0) { - favoriteCount--; - } } /** diff --git a/app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java b/app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java index 38110c96..d6cdbb7f 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/AppDatabase.java @@ -369,7 +369,7 @@ public class AppDatabase { // delete old favorits String[] delArgs = {Long.toString(ownerId)}; db.delete(FavoriteTable.TABLE, FAVORITE_SELECT_OWNER, delArgs); - + // add new favorits if (!statuses.isEmpty()) { for (Status status : statuses) { saveStatus(status, db, 0); @@ -389,10 +389,10 @@ public class AppDatabase { public void saveBookmarkTimeline(Statuses statuses, long ownerId) { synchronized (adapter) { SQLiteDatabase db = adapter.getDbWrite(); - // delete old favorits + // delete old bookmarks String[] delArgs = {Long.toString(ownerId)}; db.delete(BookmarkTable.TABLE, BOOKMARK_SELECT_OWNER, delArgs); - + // add new bookmarks if (!statuses.isEmpty()) { for (Status status : statuses) { saveStatus(status, db, 0); @@ -1206,7 +1206,7 @@ public class AppDatabase { @Nullable private Media getMedia(SQLiteDatabase db, String key) { String[] args = {key}; - Cursor c = db.query(MediaTable.TABLE, DatabaseMedia.PROJECTION, MEDIA_SELECT, args, null, null, null, SINGLE_ITEM); + Cursor c = db.query(MediaTable.TABLE, DatabaseMedia.COLUMNS, MEDIA_SELECT, args, null, null, null, SINGLE_ITEM); Media result = null; if (c.moveToFirst()) result = new DatabaseMedia(c); diff --git a/app/src/main/java/org/nuclearfog/twidda/database/DatabaseAdapter.java b/app/src/main/java/org/nuclearfog/twidda/database/DatabaseAdapter.java index eed776a0..20d509d2 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/DatabaseAdapter.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/DatabaseAdapter.java @@ -89,20 +89,20 @@ public class DatabaseAdapter { + TagTable.LOCATION + " INTEGER," + TagTable.INDEX + " INTEGER," + TagTable.VOL + " INTEGER," - + TagTable.TAG_NAME + " TEXT);"; + + TagTable.TAG_NAME + " TEXT NOT NULL);"; /** * SQL query to create a table for user logins */ private static final String TABLE_ACCOUNTS = "CREATE TABLE IF NOT EXISTS " + AccountTable.TABLE + "(" - + AccountTable.ID + " INTEGER," + + AccountTable.ID + " INTEGER NOT NULL," + AccountTable.DATE + " INTEGER," + AccountTable.USERNAME + " TEXT," + AccountTable.IMAGE + " TEXT," + AccountTable.ACCESS_TOKEN + " TEXT," + AccountTable.TOKEN_SECRET + " TEXT," - + AccountTable.HOSTNAME + " TEXT," + + AccountTable.HOSTNAME + " TEXT NOT NULL," + AccountTable.API + " INTEGER," + AccountTable.CLIENT_ID + " TEXT," + AccountTable.CLIENT_SECRET + " TEXT," diff --git a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseAccount.java b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseAccount.java index f9b0a2d9..6029c326 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseAccount.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseAccount.java @@ -26,14 +26,14 @@ public class DatabaseAccount implements Account, AccountTable { private long userId; private long loginDate; private int apiType; - private String accessToken = ""; - private String tokenSecret = ""; - private String consumerToken = ""; - private String consumerSecret = ""; - private String bearerToken = ""; - private String host = ""; - private String screenName = ""; - private String profileImage = ""; + private String accessToken; + private String tokenSecret; + private String consumerToken; + private String consumerSecret; + private String bearerToken; + private String hostname; + private String screenName; + private String profileImage; /** * @param cursor database cursor using this {@link #COLUMNS} @@ -42,31 +42,14 @@ public class DatabaseAccount implements Account, AccountTable { userId = cursor.getLong(0); apiType = cursor.getInt(1); loginDate = cursor.getLong(2); - String accessToken = cursor.getString(3); - String tokenSecret = cursor.getString(4); - String consumerToken = cursor.getString(5); - String consumerSecret = cursor.getString(6); - String bearerToken = cursor.getString(7); - String host = cursor.getString(8); - String name = cursor.getString(9); - String image = cursor.getString(10); - - if (accessToken != null) - this.accessToken = accessToken; - if (tokenSecret != null) - this.tokenSecret = tokenSecret; - if (consumerToken != null) - this.consumerToken = consumerToken; - if (consumerSecret != null) - this.consumerSecret = consumerSecret; - if (bearerToken != null) - this.bearerToken = bearerToken; - if (host != null) - this.host = host; - if (image != null) - this.profileImage = image; - if (name != null) - this.screenName = name; + accessToken = cursor.getString(3); + tokenSecret = cursor.getString(4); + consumerToken = cursor.getString(5); + consumerSecret = cursor.getString(6); + bearerToken = cursor.getString(7); + hostname = cursor.getString(8); + screenName = cursor.getString(9); + profileImage = cursor.getString(10); } @@ -126,7 +109,7 @@ public class DatabaseAccount implements Account, AccountTable { @Override public String getHostname() { - return host; + return hostname; } diff --git a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseEmoji.java b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseEmoji.java index c3a2e87d..8802cc78 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseEmoji.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseEmoji.java @@ -22,23 +22,17 @@ public class DatabaseEmoji implements Emoji, EmojiTable { */ public static final String[] PROJECTION = {CODE, URL, CATEGORY}; - private String code = ""; - private String url = ""; - private String category = ""; + private String code; + private String url; + private String category; /** * @param cursor database cursor */ public DatabaseEmoji(Cursor cursor) { - String code = cursor.getString(0); - String url = cursor.getString(1); - String category = cursor.getString(2); - if (code != null) - this.code = code; - if (url != null) - this.url = url; - if (category != null) - this.category = category; + code = cursor.getString(0); + url = cursor.getString(1); + category = cursor.getString(2); } diff --git a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseLocation.java b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseLocation.java index 6da1ff46..146897d2 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseLocation.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseLocation.java @@ -23,26 +23,18 @@ public class DatabaseLocation implements Location, LocationTable { public static final String[] PROJECTION = {ID, PLACE, COUNTRY, FULLNAME, COORDINATES}; private long id; - private String name = ""; - private String coordinates = ""; - private String country = ""; - private String place = ""; + private String name; + private String coordinates; + private String country; + private String place; public DatabaseLocation(Cursor cursor) { id = cursor.getLong(0); - String place = cursor.getString(1); - String country = cursor.getString(2); - String name = cursor.getString(3); - String coordinates = cursor.getString(4); - if (name != null) - this.name = name; - if (coordinates != null) - this.coordinates = coordinates; - if (country != null) - this.country = country; - if (place != null) - this.place = place; + place = cursor.getString(1); + country = cursor.getString(2); + name = cursor.getString(3); + coordinates = cursor.getString(4); } diff --git a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseMedia.java b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseMedia.java index 8a46fc13..f6cfa26d 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseMedia.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseMedia.java @@ -20,36 +20,25 @@ public class DatabaseMedia implements Media, MediaTable { /** * */ - public static final String[] PROJECTION = {KEY, URL, PREVIEW, TYPE, DESCRIPTION, BLUR}; + public static final String[] COLUMNS = {KEY, URL, PREVIEW, TYPE, DESCRIPTION, BLUR}; private int mediaType; - private String key = ""; - private String url = ""; - private String preview = ""; - private String description = ""; - private String blurHash = ""; - + private String key; + private String url; + private String preview; + private String description; + private String blurHash; /** - * @param cursor database cursor containing media table + * @param cursor database cursor containing this {@link #COLUMNS} */ public DatabaseMedia(Cursor cursor) { - String key = cursor.getString(0); - String url = cursor.getString(1); - String preview = cursor.getString(2); - String description = cursor.getString(3); - String blurHash = cursor.getString(4); + key = cursor.getString(0); + url = cursor.getString(1); + preview = cursor.getString(2); + description = cursor.getString(3); + blurHash = cursor.getString(4); mediaType = cursor.getInt(3); - if (key != null) - this.key = key; - if (url != null) - this.url = url; - if (preview != null) - this.preview = preview; - if (description != null) - this.description = description; - if (blurHash != null) - this.blurHash = blurHash; } diff --git a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseStatus.java b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseStatus.java index 71cf2f6c..96e73826 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseStatus.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseStatus.java @@ -41,12 +41,12 @@ public class DatabaseStatus implements Status, StatusTable, StatusPropertiesTabl private Media[] medias = {}; private Emoji[] emojis = {}; private Card[] cards = {}; - private String replyName = ""; - private String text = ""; - private String source = ""; - private String userMentions = ""; - private String statusUrl = ""; - private String language = ""; + private String replyName; + private String text; + private String source; + private String userMentions; + private String statusUrl; + private String language; /** * @param cursor database cursor @@ -66,14 +66,14 @@ public class DatabaseStatus implements Status, StatusTable, StatusPropertiesTabl embeddedId = cursor.getLong(cursor.getColumnIndexOrThrow(EMBEDDED)); myRepostId = cursor.getLong(cursor.getColumnIndexOrThrow(REPOST_ID)); editedAt = cursor.getLong(cursor.getColumnIndexOrThrow(EDITED_AT)); - String statusUrl = cursor.getString(cursor.getColumnIndexOrThrow(URL)); - String language = cursor.getString(cursor.getColumnIndexOrThrow(LANGUAGE)); + statusUrl = cursor.getString(cursor.getColumnIndexOrThrow(URL)); + language = cursor.getString(cursor.getColumnIndexOrThrow(LANGUAGE)); + source = cursor.getString(cursor.getColumnIndexOrThrow(SOURCE)); + text = cursor.getString(cursor.getColumnIndexOrThrow(TEXT)); + replyName = cursor.getString(cursor.getColumnIndexOrThrow(REPLYNAME)); + userMentions = cursor.getString(cursor.getColumnIndexOrThrow(MENTIONS)); String mediaKeys = cursor.getString(cursor.getColumnIndexOrThrow(MEDIA)); String emojiKeys = cursor.getString(cursor.getColumnIndexOrThrow(EMOJI)); - String source = cursor.getString(cursor.getColumnIndexOrThrow(SOURCE)); - String text = cursor.getString(cursor.getColumnIndexOrThrow(TEXT)); - String replyName = cursor.getString(cursor.getColumnIndexOrThrow(REPLYNAME)); - String userMentions = cursor.getString(cursor.getColumnIndexOrThrow(MENTIONS)); int register = cursor.getInt(cursor.getColumnIndexOrThrow(REGISTER)); favorited = (register & MASK_STATUS_FAVORITED) != 0; @@ -91,22 +91,12 @@ public class DatabaseStatus implements Status, StatusTable, StatusPropertiesTabl visibility = VISIBLE_UNLISTED; else visibility = VISIBLE_PUBLIC; - if (mediaKeys != null && !mediaKeys.isEmpty()) + if (mediaKeys != null && !mediaKeys.isEmpty()) { this.mediaKeys = KEY_SEPARATOR.split(mediaKeys); - if (emojiKeys != null && !emojiKeys.isEmpty()) + } + if (emojiKeys != null && !emojiKeys.isEmpty()) { this.emojiKeys = KEY_SEPARATOR.split(emojiKeys); - if (statusUrl != null) - this.statusUrl = statusUrl; - if (language != null) - this.language = language; - if (replyName != null) - this.replyName = replyName; - if (source != null) - this.source = source; - if (text != null) - this.text = text; - if (userMentions != null) - this.userMentions = userMentions; + } } diff --git a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseTag.java b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseTag.java index 98af59ef..bac0935f 100644 --- a/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseTag.java +++ b/app/src/main/java/org/nuclearfog/twidda/database/impl/DatabaseTag.java @@ -22,7 +22,7 @@ public class DatabaseTag implements Tag, TagTable { */ public static final String[] COLUMNS = {TAG_NAME, VOL, INDEX, LOCATION, ID}; - private String name = ""; + private String name; private int popularity; private int rank; private long id; @@ -32,14 +32,11 @@ public class DatabaseTag implements Tag, TagTable { * @param cursor database cursor using this {@link #COLUMNS} projection */ public DatabaseTag(Cursor cursor) { - String name = cursor.getString(0); + name = cursor.getString(0); popularity = cursor.getInt(1); rank = cursor.getInt(2); locationId = cursor.getLong(3); id = cursor.getLong(4); - if (name != null) { - this.name = name; - } } diff --git a/app/src/main/java/org/nuclearfog/twidda/ui/activities/MainActivity.java b/app/src/main/java/org/nuclearfog/twidda/ui/activities/MainActivity.java index 7e1df578..d437d023 100644 --- a/app/src/main/java/org/nuclearfog/twidda/ui/activities/MainActivity.java +++ b/app/src/main/java/org/nuclearfog/twidda/ui/activities/MainActivity.java @@ -444,7 +444,7 @@ public class MainActivity extends AppCompatActivity implements ActivityResultCal @Override - public void onResult(CredentialsLoader.Result result) { + public void onResult(@NonNull CredentialsLoader.Result result) { setCurrentUser(result.user); } diff --git a/app/src/main/java/org/nuclearfog/twidda/ui/activities/SearchActivity.java b/app/src/main/java/org/nuclearfog/twidda/ui/activities/SearchActivity.java index da5a5ed7..87422e52 100644 --- a/app/src/main/java/org/nuclearfog/twidda/ui/activities/SearchActivity.java +++ b/app/src/main/java/org/nuclearfog/twidda/ui/activities/SearchActivity.java @@ -23,8 +23,6 @@ import org.nuclearfog.twidda.R; import org.nuclearfog.twidda.backend.api.ConnectionException; import org.nuclearfog.twidda.backend.async.AsyncExecutor.AsyncCallback; import org.nuclearfog.twidda.backend.async.TagAction; -import org.nuclearfog.twidda.backend.async.TagAction.Param; -import org.nuclearfog.twidda.backend.async.TagAction.Result; import org.nuclearfog.twidda.backend.utils.AppStyles; import org.nuclearfog.twidda.backend.utils.ErrorUtils; import org.nuclearfog.twidda.config.GlobalSettings; @@ -40,7 +38,7 @@ import java.io.Serializable; * * @author nuclearfog */ -public class SearchActivity extends AppCompatActivity implements OnClickListener, OnTabSelectedListener, OnQueryTextListener, AsyncCallback { +public class SearchActivity extends AppCompatActivity implements OnClickListener, OnTabSelectedListener, OnQueryTextListener, AsyncCallback { /** * Key for the search query, required @@ -97,7 +95,7 @@ public class SearchActivity extends AppCompatActivity implements OnClickListener } else if (query != null) { search = query; if (search.matches("^#\\S+") && !search.matches("^#\\d+")) { - Param param = new Param(Param.LOAD, search); + TagAction.Param param = new TagAction.Param(TagAction.Param.LOAD, search); tagAction.execute(param, this); } } @@ -205,11 +203,11 @@ public class SearchActivity extends AppCompatActivity implements OnClickListener // follow/unfollow tag else if (item.getItemId() == R.id.search_tag) { if (tag != null && tagAction.isIdle()) { - Param param; + TagAction.Param param; if (tag.following()) - param = new Param(Param.UNFOLLOW, tag.getName()); + param = new TagAction.Param(TagAction.Param.UNFOLLOW, tag.getName()); else - param = new Param(Param.FOLLOW, tag.getName()); + param = new TagAction.Param(TagAction.Param.FOLLOW, tag.getName()); tagAction.execute(param, this); } } @@ -256,21 +254,21 @@ public class SearchActivity extends AppCompatActivity implements OnClickListener @Override - public void onResult(@NonNull Result result) { + public void onResult(@NonNull TagAction.Result result) { if (result.tag != null) { this.tag = result.tag; invalidateMenu(); } switch (result.mode) { - case Result.FOLLOW: + case TagAction.Result.FOLLOW: Toast.makeText(getApplicationContext(), R.string.info_tag_followed, Toast.LENGTH_SHORT).show(); break; - case Result.UNFOLLOW: + case TagAction.Result.UNFOLLOW: Toast.makeText(getApplicationContext(), R.string.info_tag_unfollowed, Toast.LENGTH_SHORT).show(); break; - case Result.ERROR: + case TagAction.Result.ERROR: if (result.exception == null || result.exception.getErrorCode() != ConnectionException.HTTP_FORBIDDEN) ErrorUtils.showErrorMessage(this, result.exception); break; diff --git a/app/src/main/java/org/nuclearfog/twidda/ui/adapter/recyclerview/holder/AccountHolder.java b/app/src/main/java/org/nuclearfog/twidda/ui/adapter/recyclerview/holder/AccountHolder.java index 468f44dc..5f76b755 100644 --- a/app/src/main/java/org/nuclearfog/twidda/ui/adapter/recyclerview/holder/AccountHolder.java +++ b/app/src/main/java/org/nuclearfog/twidda/ui/adapter/recyclerview/holder/AccountHolder.java @@ -24,7 +24,6 @@ import org.nuclearfog.twidda.backend.utils.AppStyles; import org.nuclearfog.twidda.backend.utils.StringUtils; import org.nuclearfog.twidda.config.GlobalSettings; import org.nuclearfog.twidda.model.Account; -import org.nuclearfog.twidda.model.User; import jp.wasabeef.picasso.transformations.RoundedCornersTransformation; diff --git a/app/src/main/res/layout/item_account.xml b/app/src/main/res/layout/item_account.xml index d9ba8f08..68f6a9a1 100644 --- a/app/src/main/res/layout/item_account.xml +++ b/app/src/main/res/layout/item_account.xml @@ -21,18 +21,6 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" /> - - @@ -52,10 +40,10 @@ android:layout_height="wrap_content" android:textSize="@dimen/login_date_textsize" android:layout_marginStart="@dimen/login_layout_margin" + android:layout_marginTop="@dimen/login_layout_margin" android:layout_marginEnd="@dimen/login_layout_margin" app:layout_constraintStart_toEndOf="@id/item_account_profile" app:layout_constraintTop_toBottomOf="@id/item_account_screenname" - app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@id/item_account_remove" /> Follow Icon Kompakte Profilansicht Filter löschen? - \'unbenannt\' Blocklisten \@name stummschalten \@name blockieren diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 1d450097..5830b676 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -245,7 +245,6 @@ Traducido por:\u0020 Idioma:\u0020 ¿Eliminar cuenta de la lista? - \'sinnombre\' Usuario marcando como favorito este estado Usuario le está gustando este estado Ahora diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index ced15834..14a01af1 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -117,7 +117,6 @@ 12sp - 14sp 12sp 11sp 8dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 491144b6..a5c39351 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -13,7 +13,6 @@ 2. 3. 4. - User ID: Userlist removed @@ -315,7 +314,6 @@ accept follow request? remove account from list? delete filter? - \'unnamed\' User favoriting this status User liking this status now