attempt to add a third-party storyviewer, plus logout without removing accounts
renovate/org.robolectric-robolectric-4.x
-
48app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java
-
27app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
-
30app/src/main/java/awais/instagrabber/fragments/settings/AboutFragment.java
-
56app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java
-
20app/src/main/java/awais/instagrabber/fragments/settings/SettingsPreferencesFragment.java
-
20app/src/main/java/awais/instagrabber/models/enums/StoryViewerChoice.java
-
18app/src/main/java/awais/instagrabber/repositories/thirdparty/AloRepository.java
-
15app/src/main/java/awais/instagrabber/repositories/thirdparty/InstadpRepository.java
-
5app/src/main/java/awais/instagrabber/utils/Constants.java
-
6app/src/main/java/awais/instagrabber/utils/CookieUtils.java
-
1app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java
-
24app/src/main/java/awais/instagrabber/utils/SettingsHelper.java
-
92app/src/main/java/awais/instagrabber/webservices/AloService.java
-
29app/src/main/java/awais/instagrabber/webservices/FriendshipService.java
-
10app/src/main/res/drawable-anydpi/ic_delete.xml
-
10app/src/main/res/drawable-anydpi/ic_logout.xml
-
BINapp/src/main/res/drawable-hdpi/ic_delete.png
-
BINapp/src/main/res/drawable-hdpi/ic_logout.png
-
BINapp/src/main/res/drawable-mdpi/ic_delete.png
-
BINapp/src/main/res/drawable-mdpi/ic_logout.png
-
BINapp/src/main/res/drawable-xhdpi/ic_delete.png
-
BINapp/src/main/res/drawable-xhdpi/ic_logout.png
-
BINapp/src/main/res/drawable-xxhdpi/ic_delete.png
-
BINapp/src/main/res/drawable-xxhdpi/ic_logout.png
-
6app/src/main/res/values/arrays.xml
-
4app/src/main/res/values/strings.xml
@ -0,0 +1,20 @@ |
|||
package awais.instagrabber.models.enums; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
public enum StoryViewerChoice implements Serializable { |
|||
NONE(0), |
|||
STORIESIG(1), |
|||
ALOINSTAGRAM(2), |
|||
INSTADP(3); |
|||
|
|||
private int value; |
|||
|
|||
StoryViewerChoice(int value) { |
|||
this.value = value; |
|||
} |
|||
|
|||
public String getValue() { |
|||
return String.valueOf(value); |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
package awais.instagrabber.repositories.thirdparty; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import retrofit2.Call; |
|||
import retrofit2.http.POST; |
|||
import retrofit2.http.Field; |
|||
import retrofit2.http.FormUrlEncoded; |
|||
import retrofit2.http.Header; |
|||
import retrofit2.http.Url; |
|||
|
|||
public interface AloRepository { |
|||
|
|||
@FormUrlEncoded |
|||
@POST("myfile/show.php") |
|||
Call<String> getUserStory(@Header("User-Agent") String userAgent, |
|||
@Field("storyonId") String id); |
|||
} |
@ -0,0 +1,15 @@ |
|||
package awais.instagrabber.repositories.thirdparty; |
|||
|
|||
import java.util.Map; |
|||
|
|||
import retrofit2.Call; |
|||
import retrofit2.http.Header; |
|||
import retrofit2.http.GET; |
|||
import retrofit2.http.QueryMap; |
|||
|
|||
public interface InstadpRepository { |
|||
|
|||
@GET("stories/{username}") |
|||
Call<String> getUserStory(@Header("User-Agent") String userAgent, |
|||
@QueryMap(encoded = true) Map<String, String> variables); |
|||
} |
@ -0,0 +1,92 @@ |
|||
package awais.instagrabber.webservices; |
|||
|
|||
import android.util.Log; |
|||
|
|||
import androidx.annotation.NonNull; |
|||
|
|||
import org.jsoup.Jsoup; |
|||
import org.jsoup.nodes.Document; |
|||
import org.jsoup.nodes.Element; |
|||
import org.jsoup.select.Elements; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import awais.instagrabber.models.ProfileModel; |
|||
import awais.instagrabber.models.StoryModel; |
|||
import awais.instagrabber.models.enums.MediaItemType; |
|||
import awais.instagrabber.repositories.thirdparty.AloRepository; |
|||
import awais.instagrabber.utils.Constants; |
|||
import awais.instagrabber.utils.ResponseBodyUtils; |
|||
import retrofit2.Call; |
|||
import retrofit2.Callback; |
|||
import retrofit2.Response; |
|||
import retrofit2.Retrofit; |
|||
|
|||
public class AloService extends BaseService { |
|||
private static final String TAG = "AloService"; |
|||
|
|||
private final AloRepository repository; |
|||
|
|||
private static AloService instance; |
|||
|
|||
private AloService() { |
|||
final Retrofit retrofit = getRetrofitBuilder() |
|||
.baseUrl("https://aloinstagram.com") |
|||
.build(); |
|||
repository = retrofit.create(AloRepository.class); |
|||
} |
|||
|
|||
public static AloService getInstance() { |
|||
if (instance == null) { |
|||
instance = new AloService(); |
|||
} |
|||
return instance; |
|||
} |
|||
|
|||
public void getUserStory(final String id, |
|||
final String username, |
|||
final boolean highlight, |
|||
final ServiceCallback<List<StoryModel>> callback) { |
|||
final Call<String> userStoryCall = repository.getUserStory(Constants.A_USER_AGENT, id); |
|||
userStoryCall.enqueue(new Callback<String>() { |
|||
@Override |
|||
public void onResponse(@NonNull final Call<String> call, @NonNull final Response<String> response) { |
|||
final String body = response.body(); |
|||
if (body == null) { |
|||
Log.e(TAG, "body is null"); |
|||
return; |
|||
} |
|||
final Document data = Jsoup.parse(body); |
|||
final Elements media = data.select(".mySpan > a"); |
|||
|
|||
Log.d("austin_debug", id+ ": "+body); |
|||
|
|||
if (data != null && media != null) { |
|||
final int mediaLen = media.size(); |
|||
final List<StoryModel> models = new ArrayList<>(); |
|||
for (Element story : media) { |
|||
|
|||
final StoryModel model = new StoryModel(null, |
|||
story.absUrl("href"), |
|||
story.selectFirst("video") != null ? MediaItemType.MEDIA_TYPE_VIDEO : MediaItemType.MEDIA_TYPE_IMAGE, |
|||
-1, // doesn't exist, to handle |
|||
username, |
|||
id, |
|||
false); |
|||
|
|||
models.add(model); |
|||
} |
|||
callback.onSuccess(models); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onFailure(@NonNull final Call<String> call, @NonNull final Throwable t) { |
|||
callback.onFailure(t); |
|||
} |
|||
}); |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:viewportWidth="24" |
|||
android:viewportHeight="24" |
|||
android:tint="?attr/colorControlNormal"> |
|||
<path |
|||
android:fillColor="@android:color/white" |
|||
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/> |
|||
</vector> |
@ -0,0 +1,10 @@ |
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:viewportWidth="24" |
|||
android:viewportHeight="24" |
|||
android:tint="?attr/colorControlNormal"> |
|||
<path |
|||
android:fillColor="@android:color/white" |
|||
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/> |
|||
</vector> |
After Width: 36 | Height: 36 | Size: 199 B |
After Width: 36 | Height: 36 | Size: 159 B |
After Width: 24 | Height: 24 | Size: 135 B |
After Width: 24 | Height: 24 | Size: 122 B |
After Width: 48 | Height: 48 | Size: 196 B |
After Width: 48 | Height: 48 | Size: 176 B |
After Width: 72 | Height: 72 | Size: 236 B |
After Width: 72 | Height: 72 | Size: 256 B |