From af458ce6c68e512d00591966080b9ad78d2a5bcc Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 4 Aug 2020 17:59:36 -0400 Subject: [PATCH] turkish, plus lgtm & compability fixes --- .../main/java/awais/instagrabber/MainHelper.java | 6 +++--- .../instagrabber/activities/PostViewer.java | 16 ++++++++-------- .../instagrabber/activities/StoryViewer.java | 2 +- .../adapters/MessageItemsAdapter.java | 3 ++- .../awais/instagrabber/asyncs/PostsFetcher.java | 1 - .../java/awais/instagrabber/utils/DataBox.java | 6 ++---- .../awais/instagrabber/utils/LocaleUtils.java | 1 + app/src/main/res/values/arrays.xml | 1 + 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/MainHelper.java b/app/src/main/java/awais/instagrabber/MainHelper.java index 0cf7c0ad..776686d4 100755 --- a/app/src/main/java/awais/instagrabber/MainHelper.java +++ b/app/src/main/java/awais/instagrabber/MainHelper.java @@ -218,9 +218,10 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { @Override public void onResult(final FeedStoryModel[] result) { feedStoriesAdapter.setData(result); - if (result != null && result.length > 0) + if (result != null && result.length > 0) { main.mainBinding.feedStories.setVisibility(View.VISIBLE); stories = result; + } } }; private final MentionClickListener mentionClickListener = new MentionClickListener() { @@ -976,14 +977,13 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener { currentlyExecuting = new LocationFetcher(main.userQuery.split("/")[0], locationModel -> { main.locationModel = locationModel; - main.mainBinding.toolbar.toolbar.setTitle(locationModel.getName()); - if (locationModel == null) { main.mainBinding.swipeRefreshLayout.setRefreshing(false); Toast.makeText(main, R.string.error_loading_profile, Toast.LENGTH_SHORT).show(); main.mainBinding.toolbar.toolbar.setTitle(R.string.app_name); return; } + main.mainBinding.toolbar.toolbar.setTitle(locationModel.getName()); final String profileId = locationModel.getId(); diff --git a/app/src/main/java/awais/instagrabber/activities/PostViewer.java b/app/src/main/java/awais/instagrabber/activities/PostViewer.java index 78650450..bbdbe72b 100755 --- a/app/src/main/java/awais/instagrabber/activities/PostViewer.java +++ b/app/src/main/java/awais/instagrabber/activities/PostViewer.java @@ -632,23 +632,23 @@ public final class PostViewer extends BaseLanguageActivity { postModel.setBookmark(viewerPostModel.getBookmark()); if (viewerPostModel.getLike() == true) { viewerBinding.btnLike.setText(resources.getString(R.string.unlike, viewerPostModel.getLikes())); - viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( - R.color.btn_pink_background, null))); + viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( + getApplicationContext(), R.color.btn_pink_background))); } else { viewerBinding.btnLike.setText(resources.getString(R.string.like, viewerPostModel.getLikes())); - viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( - R.color.btn_lightpink_background, null))); + viewerBinding.btnLike.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( + getApplicationContext(), R.color.btn_lightpink_background))); } if (viewerPostModel.getBookmark() == true) { viewerBinding.btnBookmark.setText(R.string.unbookmark); - viewerBinding.btnBookmark.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( - R.color.btn_orange_background, null))); + viewerBinding.btnBookmark.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( + getApplicationContext(), R.color.btn_orange_background))); } else { viewerBinding.btnBookmark.setText(R.string.bookmark); - viewerBinding.btnBookmark.setBackgroundTintList(ColorStateList.valueOf(resources.getColor( - R.color.btn_lightorange_background, null))); + viewerBinding.btnBookmark.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor( + getApplicationContext(), R.color.btn_lightorange_background))); } } diff --git a/app/src/main/java/awais/instagrabber/activities/StoryViewer.java b/app/src/main/java/awais/instagrabber/activities/StoryViewer.java index e735199a..f9304001 100755 --- a/app/src/main/java/awais/instagrabber/activities/StoryViewer.java +++ b/app/src/main/java/awais/instagrabber/activities/StoryViewer.java @@ -479,7 +479,7 @@ public final class StoryViewer extends BaseLanguageActivity { storyViewerBinding.mention.setTag(mentions); quiz = currentStory.getQuiz(); - storyViewerBinding.quiz.setVisibility((quiz != null && mentions.length > 0) ? View.VISIBLE : View.GONE); + storyViewerBinding.quiz.setVisibility(quiz != null ? View.VISIBLE : View.GONE); storyViewerBinding.quiz.setTag(quiz); releasePlayer(); diff --git a/app/src/main/java/awais/instagrabber/adapters/MessageItemsAdapter.java b/app/src/main/java/awais/instagrabber/adapters/MessageItemsAdapter.java index 3a467d0d..998cd61d 100755 --- a/app/src/main/java/awais/instagrabber/adapters/MessageItemsAdapter.java +++ b/app/src/main/java/awais/instagrabber/adapters/MessageItemsAdapter.java @@ -389,9 +389,10 @@ public final class MessageItemsAdapter extends RecyclerView.Adapter { final boolean isHashTag = id.charAt(0) == '#'; final boolean isSaved = id.charAt(0) == '$'; final boolean isTagged = id.charAt(0) == '%'; - //final boolean isLiked = id.charAt(0) == '^'; final boolean isLocation = id.contains("/"); final String url; diff --git a/app/src/main/java/awais/instagrabber/utils/DataBox.java b/app/src/main/java/awais/instagrabber/utils/DataBox.java index 6e52a8ba..9458d1fe 100755 --- a/app/src/main/java/awais/instagrabber/utils/DataBox.java +++ b/app/src/main/java/awais/instagrabber/utils/DataBox.java @@ -86,12 +86,10 @@ public final class DataBox extends SQLiteOpenHelper { try (final SQLiteDatabase db = getWritableDatabase()) { db.beginTransaction(); try { - final int rowsDeleted = db.delete(TABLE_FAVORITES, KEY_QUERY_TEXT + "=? AND " - + KEY_DATE_ADDED + "=?", + final int rowsDeleted = db.delete(TABLE_FAVORITES, "query_text=? AND date_added=?", new String[]{query, Long.toString(favoriteModel.getDate())}); - final int rowsDeletedTwo = db.delete(TABLE_FAVORITES, KEY_QUERY_TEXT + "=? AND " - + KEY_DATE_ADDED + "=?", + final int rowsDeletedTwo = db.delete(TABLE_FAVORITES, "query_text=? AND date_added=?", new String[]{query.replaceAll("@", ""), Long.toString(favoriteModel.getDate())}); if (rowsDeleted > 0 || rowsDeletedTwo > 0) db.setTransactionSuccessful(); diff --git a/app/src/main/java/awais/instagrabber/utils/LocaleUtils.java b/app/src/main/java/awais/instagrabber/utils/LocaleUtils.java index a6fd1194..bb118b09 100755 --- a/app/src/main/java/awais/instagrabber/utils/LocaleUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/LocaleUtils.java @@ -65,6 +65,7 @@ public final class LocaleUtils { if (appLanguageIndex == 6) return "it"; if (appLanguageIndex == 7) return "de"; if (appLanguageIndex == 8) return "pl"; + if (appLanguageIndex == 9) return "tr"; return null; } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index f892b849..c4154ef2 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -10,6 +10,7 @@ Italian [Thanks to @RAR_Ramar (Telegram)] German [Thanks to @peterge1998 (GitHub)] Polish [Thanks to @Lego8486 (GitHub)] + Turkish [Thanks to @faydin90 (Telegram)] Auto / Follow System