1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-23 05:16:58 +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.View;
import android.widget.AutoCompleteTextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -546,11 +547,16 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
.create();
alertDialog.show();
new PostFetcher(shortCode, feedModel -> {
final PostViewV2Fragment fragment = PostViewV2Fragment
.builder(feedModel)
.build();
fragment.setOnShowListener(dialog -> alertDialog.dismiss());
fragment.show(getSupportFragmentManager(), "post_view");
if (feedModel != null) {
final PostViewV2Fragment fragment = PostViewV2Fragment
.builder(feedModel)
.build();
fragment.setOnShowListener(dialog -> alertDialog.dismiss());
fragment.show(getSupportFragmentManager(), "post_view");
}
else {
Toast.makeText(getApplicationContext(), R.string.post_not_found, Toast.LENGTH_SHORT).show();
}
}).execute();
}

View File

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

View File

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

View File

@ -1,12 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:alpha="0.8"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<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
M7,6 L8.9,6 v2 h-2z" />
</vector>

View File

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

View File

@ -309,6 +309,7 @@
<string name="show_grid_gap">Show grid gap</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="post_not_found">Post not found!</string>
<plurals name="likes_count">
<item quantity="one">%d like</item>
<item quantity="other">%d likes</item>