1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 22:57:29 +00:00

close #306 and close #310

This commit is contained in:
Austin Huang 2020-11-30 12:29:41 -05:00
parent 9887547363
commit b2e784deb8
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
6 changed files with 25 additions and 13 deletions

View File

@ -21,6 +21,7 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -546,11 +547,16 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
.create(); .create();
alertDialog.show(); alertDialog.show();
new PostFetcher(shortCode, feedModel -> { new PostFetcher(shortCode, feedModel -> {
final PostViewV2Fragment fragment = PostViewV2Fragment if (feedModel != null) {
.builder(feedModel) final PostViewV2Fragment fragment = PostViewV2Fragment
.build(); .builder(feedModel)
fragment.setOnShowListener(dialog -> alertDialog.dismiss()); .build();
fragment.show(getSupportFragmentManager(), "post_view"); fragment.setOnShowListener(dialog -> alertDialog.dismiss());
fragment.show(getSupportFragmentManager(), "post_view");
}
else {
Toast.makeText(getApplicationContext(), R.string.post_not_found, Toast.LENGTH_SHORT).show();
}
}).execute(); }).execute();
} }

View File

@ -15,11 +15,13 @@ import awais.instagrabber.BuildConfig;
import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.interfaces.FetchListener;
import awais.instagrabber.models.ProfileModel; import awais.instagrabber.models.ProfileModel;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.CookieUtils;
import awais.instagrabber.utils.NetworkUtils; import awais.instagrabber.utils.NetworkUtils;
import awais.instagrabber.utils.TextUtils; import awais.instagrabber.utils.TextUtils;
import awaisomereport.LogCollector; import awaisomereport.LogCollector;
import static awais.instagrabber.utils.Utils.logCollector; import static awais.instagrabber.utils.Utils.logCollector;
import static awais.instagrabber.utils.Utils.settingsHelper;
public final class ProfileFetcher extends AsyncTask<Void, Void, ProfileModel> { public final class ProfileFetcher extends AsyncTask<Void, Void, ProfileModel> {
private final FetchListener<ProfileModel> fetchListener; private final FetchListener<ProfileModel> fetchListener;
@ -43,21 +45,23 @@ public final class ProfileFetcher extends AsyncTask<Void, Void, ProfileModel> {
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
final JSONObject user = new JSONObject(NetworkUtils.readFromConnection(conn)).getJSONObject("graphql").getJSONObject(Constants.EXTRAS_USER); final JSONObject user = new JSONObject(NetworkUtils.readFromConnection(conn)).getJSONObject("graphql").getJSONObject(Constants.EXTRAS_USER);
final String cookie = settingsHelper.getString(Constants.COOKIE);
boolean isPrivate = user.getBoolean("is_private"); boolean isPrivate = user.getBoolean("is_private");
boolean reallyPrivate = isPrivate; final String id = user.getString(Constants.EXTRAS_ID);
final String uid = CookieUtils.getUserIdFromCookie(cookie);
final JSONObject timelineMedia = user.getJSONObject("edge_owner_to_timeline_media"); final JSONObject timelineMedia = user.getJSONObject("edge_owner_to_timeline_media");
if (timelineMedia.has("edges")) { if (timelineMedia.has("edges")) {
final JSONArray edges = timelineMedia.getJSONArray("edges"); final JSONArray edges = timelineMedia.getJSONArray("edges");
if (edges.length() > 0 && timelineMedia.getLong("count") > 0L) reallyPrivate = false;
} }
String url = user.optString("external_url"); String url = user.optString("external_url");
if (TextUtils.isEmpty(url)) url = null; if (TextUtils.isEmpty(url)) url = null;
result = new ProfileModel(isPrivate, result = new ProfileModel(isPrivate,
reallyPrivate, user.optBoolean("followed_by_viewer") ? false : (id.equals(uid) ? false : isPrivate),
user.getBoolean("is_verified"), user.getBoolean("is_verified"),
user.getString(Constants.EXTRAS_ID), id,
userName, userName,
user.getString("full_name"), user.getString("full_name"),
user.getString("biography"), user.getString("biography"),

View File

@ -13,6 +13,7 @@ import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan; import android.text.style.StyleSpan;
import android.util.Log; import android.util.Log;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -477,6 +478,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
binding.privatePage2.setText(R.string.no_acc); binding.privatePage2.setText(R.string.no_acc);
final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) binding.privatePage.getLayoutParams(); final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) binding.privatePage.getLayoutParams();
layoutParams.topMargin = 0; layoutParams.topMargin = 0;
layoutParams.gravity = Gravity.CENTER;
binding.privatePage.setLayoutParams(layoutParams); binding.privatePage.setLayoutParams(layoutParams);
binding.privatePage.setVisibility(View.VISIBLE); binding.privatePage.setVisibility(View.VISIBLE);
return; return;

View File

@ -1,12 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:alpha="0.8"
android:tint="?attr/colorControlNormal" android:tint="?attr/colorControlNormal"
android:viewportWidth="24" android:viewportWidth="24"
android:viewportHeight="24"> android:viewportHeight="24">
<path <path
android:fillColor="@android:color/white" android:fillColor="#000"
android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z M18,8 h-1 L17,6 c0,-2.76 -2.24,-5 -5,-5 S7,3.24 7,6 h1.9c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1 v2 L6,8 c-1.1,0 -2,0.9 -2,2 v10 c0,1.1 0.9,2 2,2 h12 c1.1,0 2,-0.9 2,-2 L20,10 c0,-1.1 -0.9,-2 -2,-2z M18,20L6,20L6,10h12v10z android:pathData="M12,17c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2z M18,8 h-1 L17,6 c0,-2.76 -2.24,-5 -5,-5 S7,3.24 7,6 h1.9c0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0 3.1,1.39 3.1,3.1 v2 L6,8 c-1.1,0 -2,0.9 -2,2 v10 c0,1.1 0.9,2 2,2 h12 c1.1,0 2,-0.9 2,-2 L20,10 c0,-1.1 -0.9,-2 -2,-2z M18,20L6,20L6,10h12v10z
M7,6 L8.9,6 v2 h-2z" /> M7,6 L8.9,6 v2 h-2z" />
</vector> </vector>

View File

@ -41,12 +41,12 @@
android:id="@+id/privatePage" android:id="@+id/privatePage"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="top"
android:layout_marginTop="@dimen/private_page_margins" android:layout_marginTop="@dimen/private_page_margins"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone" android:visibility="gone"
tools:visibility="gone"> tools:visibility="visible">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/privatePage1" android:id="@+id/privatePage1"

View File

@ -309,6 +309,7 @@
<string name="show_grid_gap">Show grid gap</string> <string name="show_grid_gap">Show grid gap</string>
<string name="disable_animation">Disable animation</string> <string name="disable_animation">Disable animation</string>
<string name="follower_wait_to_load">Please wait for the current task to complete first!</string> <string name="follower_wait_to_load">Please wait for the current task to complete first!</string>
<string name="post_not_found">Post not found!</string>
<plurals name="likes_count"> <plurals name="likes_count">
<item quantity="one">%d like</item> <item quantity="one">%d like</item>
<item quantity="other">%d likes</item> <item quantity="other">%d likes</item>