mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Support viewing imgur albums in-app.
This commit is contained in:
parent
066956971a
commit
13d64eda14
@ -30,6 +30,8 @@ dependencies {
|
|||||||
// Lifecycle components
|
// Lifecycle components
|
||||||
def lifecycleVersion = '2.2.0'
|
def lifecycleVersion = '2.2.0'
|
||||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
|
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
|
||||||
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
annotationProcessor "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
|
annotationProcessor "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
|
||||||
implementation 'androidx.paging:paging-runtime:2.1.2'
|
implementation 'androidx.paging:paging-runtime:2.1.2'
|
||||||
implementation 'androidx.preference:preference:1.1.1'
|
implementation 'androidx.preference:preference:1.1.1'
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
tools:replace="android:label">
|
tools:replace="android:label">
|
||||||
|
<activity
|
||||||
|
android:name=".Activity.ViewImgurMediaActivity"
|
||||||
|
android:configChanges="orientation|screenSize|layoutDirection"
|
||||||
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
|
android:theme="@style/AppTheme.ActionBar.Transparent" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".Activity.ReportActivity"
|
android:name=".Activity.ReportActivity"
|
||||||
android:label="@string/report_activity_label"
|
android:label="@string/report_activity_label"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.API;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
@ -0,0 +1,18 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.API;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Header;
|
||||||
|
import retrofit2.http.Path;
|
||||||
|
|
||||||
|
public interface ImgurAPI {
|
||||||
|
@GET("gallery/{id}")
|
||||||
|
Call<String> getGalleryImages(@Header(APIUtils.AUTHORIZATION_KEY) String clientId, @Path("id") String id);
|
||||||
|
|
||||||
|
@GET("/album/{id}")
|
||||||
|
Call<String> getAlbumImages(@Header(APIUtils.AUTHORIZATION_KEY) String clientId, @Path("id") String id);
|
||||||
|
|
||||||
|
@GET("/image/{id}")
|
||||||
|
Call<String> getImage(@Header(APIUtils.AUTHORIZATION_KEY) String clientId, @Path("id") String id);
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit.API;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -10,8 +10,9 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Account.Account;
|
import ml.docilealligator.infinityforreddit.Account.Account;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import okhttp3.Authenticator;
|
import okhttp3.Authenticator;
|
||||||
import okhttp3.Headers;
|
import okhttp3.Headers;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
@ -33,7 +34,7 @@ class AccessTokenAuthenticator implements Authenticator {
|
|||||||
@Override
|
@Override
|
||||||
public Request authenticate(Route route, @NonNull Response response) {
|
public Request authenticate(Route route, @NonNull Response response) {
|
||||||
if (response.code() == 401) {
|
if (response.code() == 401) {
|
||||||
String accessToken = response.request().header(RedditUtils.AUTHORIZATION_KEY).substring(RedditUtils.AUTHORIZATION_BASE.length());
|
String accessToken = response.request().header(APIUtils.AUTHORIZATION_KEY).substring(APIUtils.AUTHORIZATION_BASE.length());
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
Account account = mRedditDataRoomDatabase.accountDao().getCurrentAccount();
|
Account account = mRedditDataRoomDatabase.accountDao().getCurrentAccount();
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
@ -43,12 +44,12 @@ class AccessTokenAuthenticator implements Authenticator {
|
|||||||
if (accessToken.equals(accessTokenFromDatabase)) {
|
if (accessToken.equals(accessTokenFromDatabase)) {
|
||||||
String newAccessToken = refreshAccessToken(account);
|
String newAccessToken = refreshAccessToken(account);
|
||||||
if (!newAccessToken.equals("")) {
|
if (!newAccessToken.equals("")) {
|
||||||
return response.request().newBuilder().headers(Headers.of(RedditUtils.getOAuthHeader(newAccessToken))).build();
|
return response.request().newBuilder().headers(Headers.of(APIUtils.getOAuthHeader(newAccessToken))).build();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return response.request().newBuilder().headers(Headers.of(RedditUtils.getOAuthHeader(accessTokenFromDatabase))).build();
|
return response.request().newBuilder().headers(Headers.of(APIUtils.getOAuthHeader(accessTokenFromDatabase))).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,15 +62,15 @@ class AccessTokenAuthenticator implements Authenticator {
|
|||||||
RedditAPI api = mRetrofit.create(RedditAPI.class);
|
RedditAPI api = mRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.GRANT_TYPE_KEY, RedditUtils.GRANT_TYPE_REFRESH_TOKEN);
|
params.put(APIUtils.GRANT_TYPE_KEY, APIUtils.GRANT_TYPE_REFRESH_TOKEN);
|
||||||
params.put(RedditUtils.REFRESH_TOKEN_KEY, refreshToken);
|
params.put(APIUtils.REFRESH_TOKEN_KEY, refreshToken);
|
||||||
|
|
||||||
Call<String> accessTokenCall = api.getAccessToken(RedditUtils.getHttpBasicAuthHeader(), params);
|
Call<String> accessTokenCall = api.getAccessToken(APIUtils.getHttpBasicAuthHeader(), params);
|
||||||
try {
|
try {
|
||||||
retrofit2.Response response = accessTokenCall.execute();
|
retrofit2.Response response = accessTokenCall.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
JSONObject jsonObject = new JSONObject((String) response.body());
|
JSONObject jsonObject = new JSONObject((String) response.body());
|
||||||
String newAccessToken = jsonObject.getString(RedditUtils.ACCESS_TOKEN_KEY);
|
String newAccessToken = jsonObject.getString(APIUtils.ACCESS_TOKEN_KEY);
|
||||||
mRedditDataRoomDatabase.accountDao().changeAccessToken(account.getUsername(), newAccessToken);
|
mRedditDataRoomDatabase.accountDao().changeAccessToken(account.getUsername(), newAccessToken);
|
||||||
|
|
||||||
return newAccessToken;
|
return newAccessToken;
|
||||||
|
@ -34,8 +34,8 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
|||||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@ -150,11 +150,11 @@ public class EditCommentActivity extends BaseActivity {
|
|||||||
String content = contentEditText.getText().toString();
|
String content = contentEditText.getText().toString();
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.THING_ID_KEY, mFullName);
|
params.put(APIUtils.THING_ID_KEY, mFullName);
|
||||||
params.put(RedditUtils.TEXT_KEY, content);
|
params.put(APIUtils.TEXT_KEY, content);
|
||||||
|
|
||||||
mOauthRetrofit.create(RedditAPI.class)
|
mOauthRetrofit.create(RedditAPI.class)
|
||||||
.editPostOrComment(RedditUtils.getOAuthHeader(mAccessToken), params)
|
.editPostOrComment(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -36,8 +36,8 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
|||||||
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -153,11 +153,11 @@ public class EditPostActivity extends BaseActivity {
|
|||||||
Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_SHORT).show();
|
Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_SHORT).show();
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.THING_ID_KEY, mFullName);
|
params.put(APIUtils.THING_ID_KEY, mFullName);
|
||||||
params.put(RedditUtils.TEXT_KEY, contentEditText.getText().toString());
|
params.put(APIUtils.TEXT_KEY, contentEditText.getText().toString());
|
||||||
|
|
||||||
mOauthRetrofit.create(RedditAPI.class)
|
mOauthRetrofit.create(RedditAPI.class)
|
||||||
.editPostOrComment(RedditUtils.getOAuthHeader(mAccessToken), params)
|
.editPostOrComment(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -39,6 +39,9 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
private static final String MULTIREDDIT_PATTERN_2 = "/[rR]/(\\w+\\+?)+/?";
|
private static final String MULTIREDDIT_PATTERN_2 = "/[rR]/(\\w+\\+?)+/?";
|
||||||
private static final String REDD_IT_POST_PATTERN = "/\\w+/?";
|
private static final String REDD_IT_POST_PATTERN = "/\\w+/?";
|
||||||
private static final String GFYCAT_PATTERN = "/[\\w-]+$";
|
private static final String GFYCAT_PATTERN = "/[\\w-]+$";
|
||||||
|
private static final String IMGUR_GALLERY_PATTERN = "/gallery/\\w+/?";
|
||||||
|
private static final String IMGUR_ALBUM_PATTERN = "/(album|a)/\\w+/?";
|
||||||
|
private static final String IMGUR_IMAGE_PATTERN = "/\\w+/?";
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default")
|
@Named("default")
|
||||||
@ -162,6 +165,27 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
deepLinkError(uri);
|
deepLinkError(uri);
|
||||||
}
|
}
|
||||||
|
} else if (authority.contains("imgur.com")) {
|
||||||
|
if (path.matches(IMGUR_GALLERY_PATTERN)) {
|
||||||
|
Intent intent = new Intent(this, ViewImgurMediaActivity.class);
|
||||||
|
intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_TYPE, ViewImgurMediaActivity.IMGUR_TYPE_GALLERY);
|
||||||
|
intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_ID, segments.get(1));
|
||||||
|
startActivity(intent);
|
||||||
|
} else if (path.matches(IMGUR_ALBUM_PATTERN)) {
|
||||||
|
Intent intent = new Intent(this, ViewImgurMediaActivity.class);
|
||||||
|
intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_TYPE, ViewImgurMediaActivity.IMGUR_TYPE_ALBUM);
|
||||||
|
intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_ID, segments.get(1));
|
||||||
|
startActivity(intent);
|
||||||
|
} else if (path.matches(IMGUR_IMAGE_PATTERN)) {
|
||||||
|
Intent intent = new Intent(this, ViewImgurMediaActivity.class);
|
||||||
|
intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_TYPE, ViewImgurMediaActivity.IMGUR_TYPE_IMAGE);
|
||||||
|
intent.putExtra(ViewImgurMediaActivity.EXTRA_IMGUR_ID, path.substring(1));
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
deepLinkError(uri);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
deepLinkError(uri);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deepLinkError(uri);
|
deepLinkError(uri);
|
||||||
|
@ -34,9 +34,9 @@ import ml.docilealligator.infinityforreddit.FetchMyInfo;
|
|||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo;
|
import ml.docilealligator.infinityforreddit.ParseAndSaveAccountInfo;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -83,14 +83,14 @@ public class LoginActivity extends BaseActivity {
|
|||||||
webView.getSettings().setJavaScriptEnabled(true);
|
webView.getSettings().setJavaScriptEnabled(true);
|
||||||
webView.getSettings().setDomStorageEnabled(true);
|
webView.getSettings().setDomStorageEnabled(true);
|
||||||
|
|
||||||
Uri baseUri = Uri.parse(RedditUtils.OAUTH_URL);
|
Uri baseUri = Uri.parse(APIUtils.OAUTH_URL);
|
||||||
Uri.Builder uriBuilder = baseUri.buildUpon();
|
Uri.Builder uriBuilder = baseUri.buildUpon();
|
||||||
uriBuilder.appendQueryParameter(RedditUtils.CLIENT_ID_KEY, RedditUtils.CLIENT_ID);
|
uriBuilder.appendQueryParameter(APIUtils.CLIENT_ID_KEY, APIUtils.CLIENT_ID);
|
||||||
uriBuilder.appendQueryParameter(RedditUtils.RESPONSE_TYPE_KEY, RedditUtils.RESPONSE_TYPE);
|
uriBuilder.appendQueryParameter(APIUtils.RESPONSE_TYPE_KEY, APIUtils.RESPONSE_TYPE);
|
||||||
uriBuilder.appendQueryParameter(RedditUtils.STATE_KEY, RedditUtils.STATE);
|
uriBuilder.appendQueryParameter(APIUtils.STATE_KEY, APIUtils.STATE);
|
||||||
uriBuilder.appendQueryParameter(RedditUtils.REDIRECT_URI_KEY, RedditUtils.REDIRECT_URI);
|
uriBuilder.appendQueryParameter(APIUtils.REDIRECT_URI_KEY, APIUtils.REDIRECT_URI);
|
||||||
uriBuilder.appendQueryParameter(RedditUtils.DURATION_KEY, RedditUtils.DURATION);
|
uriBuilder.appendQueryParameter(APIUtils.DURATION_KEY, APIUtils.DURATION);
|
||||||
uriBuilder.appendQueryParameter(RedditUtils.SCOPE_KEY, RedditUtils.SCOPE);
|
uriBuilder.appendQueryParameter(APIUtils.SCOPE_KEY, APIUtils.SCOPE);
|
||||||
|
|
||||||
String url = uriBuilder.toString();
|
String url = uriBuilder.toString();
|
||||||
|
|
||||||
@ -104,16 +104,16 @@ public class LoginActivity extends BaseActivity {
|
|||||||
if (url.contains("&code=") || url.contains("?code=")) {
|
if (url.contains("&code=") || url.contains("?code=")) {
|
||||||
Uri uri = Uri.parse(url);
|
Uri uri = Uri.parse(url);
|
||||||
String state = uri.getQueryParameter("state");
|
String state = uri.getQueryParameter("state");
|
||||||
if (state.equals(RedditUtils.STATE)) {
|
if (state.equals(APIUtils.STATE)) {
|
||||||
authCode = uri.getQueryParameter("code");
|
authCode = uri.getQueryParameter("code");
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.GRANT_TYPE_KEY, "authorization_code");
|
params.put(APIUtils.GRANT_TYPE_KEY, "authorization_code");
|
||||||
params.put("code", authCode);
|
params.put("code", authCode);
|
||||||
params.put("redirect_uri", RedditUtils.REDIRECT_URI);
|
params.put("redirect_uri", APIUtils.REDIRECT_URI);
|
||||||
|
|
||||||
RedditAPI api = mRetrofit.create(RedditAPI.class);
|
RedditAPI api = mRetrofit.create(RedditAPI.class);
|
||||||
Call<String> accessTokenCall = api.getAccessToken(RedditUtils.getHttpBasicAuthHeader(), params);
|
Call<String> accessTokenCall = api.getAccessToken(APIUtils.getHttpBasicAuthHeader(), params);
|
||||||
accessTokenCall.enqueue(new Callback<String>() {
|
accessTokenCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
@ -126,8 +126,8 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSONObject responseJSON = new JSONObject(accountResponse);
|
JSONObject responseJSON = new JSONObject(accountResponse);
|
||||||
String accessToken = responseJSON.getString(RedditUtils.ACCESS_TOKEN_KEY);
|
String accessToken = responseJSON.getString(APIUtils.ACCESS_TOKEN_KEY);
|
||||||
String refreshToken = responseJSON.getString(RedditUtils.REFRESH_TOKEN_KEY);
|
String refreshToken = responseJSON.getString(APIUtils.REFRESH_TOKEN_KEY);
|
||||||
|
|
||||||
FetchMyInfo.fetchAccountInfo(mOauthRetrofit, accessToken, new FetchMyInfo.FetchUserMyListener() {
|
FetchMyInfo.fetchAccountInfo(mOauthRetrofit, accessToken, new FetchMyInfo.FetchUserMyListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,7 +46,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
|||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
|
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, linkEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_CONTENT, linkEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_KIND, RedditUtils.KIND_LINK);
|
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_LINK);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
||||||
|
@ -46,7 +46,7 @@ import ml.docilealligator.infinityforreddit.Infinity;
|
|||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
|
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_KIND, RedditUtils.KIND_SELF);
|
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_SELF);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
|
||||||
|
@ -0,0 +1,307 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Activity;
|
||||||
|
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import ml.docilealligator.infinityforreddit.API.ImgurAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.ContentFontStyle;
|
||||||
|
import ml.docilealligator.infinityforreddit.FontStyle;
|
||||||
|
import ml.docilealligator.infinityforreddit.Fragment.ViewImgurGifFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.Fragment.ViewImgurImageFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.Fragment.ViewImgurVideoFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.ImgurMedia;
|
||||||
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
import ml.docilealligator.infinityforreddit.TitleFontStyle;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
import retrofit2.Call;
|
||||||
|
import retrofit2.Callback;
|
||||||
|
import retrofit2.Response;
|
||||||
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
|
public class ViewImgurMediaActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
public static final String EXTRA_IMGUR_TYPE = "EIT";
|
||||||
|
public static final String EXTRA_IMGUR_ID = "EII";
|
||||||
|
public static final int IMGUR_TYPE_GALLERY = 0;
|
||||||
|
public static final int IMGUR_TYPE_ALBUM = 1;
|
||||||
|
public static final int IMGUR_TYPE_IMAGE = 2;
|
||||||
|
private static final String IMGUR_IMAGES_STATE = "IIS";
|
||||||
|
|
||||||
|
@BindView(R.id.progress_bar_view_imgur_media_activity)
|
||||||
|
ProgressBar progressBar;
|
||||||
|
@BindView(R.id.view_pager_view_imgur_media_activity)
|
||||||
|
ViewPager viewPager;
|
||||||
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
|
private ArrayList<ImgurMedia> images;
|
||||||
|
@Inject
|
||||||
|
@Named("imgur")
|
||||||
|
Retrofit imgurRetrofit;
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
getTheme().applyStyle(R.style.Theme_Normal, true);
|
||||||
|
|
||||||
|
getTheme().applyStyle(FontStyle.valueOf(sharedPreferences
|
||||||
|
.getString(SharedPreferencesUtils.FONT_SIZE_KEY, FontStyle.Normal.name())).getResId(), true);
|
||||||
|
|
||||||
|
getTheme().applyStyle(TitleFontStyle.valueOf(sharedPreferences
|
||||||
|
.getString(SharedPreferencesUtils.TITLE_FONT_SIZE_KEY, TitleFontStyle.Normal.name())).getResId(), true);
|
||||||
|
|
||||||
|
getTheme().applyStyle(ContentFontStyle.valueOf(sharedPreferences
|
||||||
|
.getString(SharedPreferencesUtils.CONTENT_FONT_SIZE_KEY, ContentFontStyle.Normal.name())).getResId(), true);
|
||||||
|
|
||||||
|
setContentView(R.layout.activity_view_imgur_media);
|
||||||
|
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
||||||
|
actionBar.setHomeAsUpIndicator(upArrow);
|
||||||
|
actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.transparentActionBarAndExoPlayerControllerColor)));
|
||||||
|
|
||||||
|
setTitle(" ");
|
||||||
|
|
||||||
|
String imgurId = getIntent().getStringExtra(EXTRA_IMGUR_ID);
|
||||||
|
if (imgurId == null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
images = savedInstanceState.getParcelableArrayList(IMGUR_IMAGES_STATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (images == null) {
|
||||||
|
switch (getIntent().getIntExtra(EXTRA_IMGUR_TYPE, IMGUR_TYPE_IMAGE)) {
|
||||||
|
case IMGUR_TYPE_GALLERY:
|
||||||
|
imgurRetrofit.create(ImgurAPI.class).getGalleryImages(APIUtils.IMGUR_CLIENT_ID, imgurId)
|
||||||
|
.enqueue(new Callback<String>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
new ParseImgurImagesAsyncTask(response.body(), new ParseImgurImagesAsyncTask.ParseImgurImagesAsyncTaskListener() {
|
||||||
|
@Override
|
||||||
|
public void success(ArrayList<ImgurMedia> images) {
|
||||||
|
ViewImgurMediaActivity.this.images = images;
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
setupViewPager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed() {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
Toast.makeText(ViewImgurMediaActivity.this, R.string.error_fetching_imgur_media, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}).execute();
|
||||||
|
} else {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
Toast.makeText(ViewImgurMediaActivity.this, R.string.error_fetching_imgur_media, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
Toast.makeText(ViewImgurMediaActivity.this, R.string.error_fetching_imgur_media, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case IMGUR_TYPE_ALBUM:
|
||||||
|
break;
|
||||||
|
case IMGUR_TYPE_IMAGE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
setupViewPager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupViewPager() {
|
||||||
|
setToolbarTitle(0);
|
||||||
|
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
|
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
switch (images.get(position).getType()) {
|
||||||
|
case ImgurMedia.TYPE_GIF:
|
||||||
|
setTitle("GIF " + (position + 1) + "/" + images.size());
|
||||||
|
break;
|
||||||
|
case ImgurMedia.TYPE_VIDEO:
|
||||||
|
setTitle("Video "+ (position + 1) + "/" + images.size());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setTitle("Image " + (position + 1) + "/" + images.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged(int state) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
viewPager.setAdapter(sectionsPagerAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setToolbarTitle(int position) {
|
||||||
|
switch (images.get(position).getType()) {
|
||||||
|
case ImgurMedia.TYPE_GIF:
|
||||||
|
setTitle("GIF " + (position + 1) + "/" + images.size());
|
||||||
|
break;
|
||||||
|
case ImgurMedia.TYPE_VIDEO:
|
||||||
|
setTitle("Video "+ (position + 1) + "/" + images.size());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setTitle("Image " + (position + 1) + "/" + images.size());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
finish();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putParcelableArrayList(IMGUR_IMAGES_STATE, images);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SectionsPagerAdapter extends FragmentStatePagerAdapter {
|
||||||
|
|
||||||
|
SectionsPagerAdapter(@NonNull FragmentManager fm) {
|
||||||
|
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Fragment getItem(int position) {
|
||||||
|
ImgurMedia imgurMedia = images.get(position);
|
||||||
|
if (imgurMedia.getType() == ImgurMedia.TYPE_VIDEO) {
|
||||||
|
ViewImgurVideoFragment fragment = new ViewImgurVideoFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable(ViewImgurVideoFragment.EXTRA_IMGUR_VIDEO, imgurMedia);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
return fragment;
|
||||||
|
} else if (imgurMedia.getType() == ImgurMedia.TYPE_GIF) {
|
||||||
|
ViewImgurGifFragment fragment = new ViewImgurGifFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable(ViewImgurGifFragment.EXTRA_IMGUR_GIF, imgurMedia);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
return fragment;
|
||||||
|
} else {
|
||||||
|
ViewImgurImageFragment fragment = new ViewImgurImageFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable(ViewImgurImageFragment.EXTRA_IMGUR_IMAGES, imgurMedia);
|
||||||
|
fragment.setArguments(bundle);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return images.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ParseImgurImagesAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
|
||||||
|
private String response;
|
||||||
|
private ArrayList<ImgurMedia> images;
|
||||||
|
private boolean parseFailed = false;
|
||||||
|
private ParseImgurImagesAsyncTaskListener parseImgurImagesAsyncTaskListener;
|
||||||
|
|
||||||
|
interface ParseImgurImagesAsyncTaskListener {
|
||||||
|
void success(ArrayList<ImgurMedia> images);
|
||||||
|
void failed();
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseImgurImagesAsyncTask(String response, ParseImgurImagesAsyncTaskListener parseImgurImagesAsyncTaskListener) {
|
||||||
|
this.response = response;
|
||||||
|
this.parseImgurImagesAsyncTaskListener = parseImgurImagesAsyncTaskListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... voids) {
|
||||||
|
try {
|
||||||
|
JSONArray jsonArray = new JSONObject(response).getJSONObject(JSONUtils.DATA_KEY).getJSONArray(JSONUtils.IMAGES_KEY);
|
||||||
|
images = new ArrayList<>();
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject image = jsonArray.getJSONObject(i);
|
||||||
|
images.add(new ImgurMedia(image.getString(JSONUtils.ID_KEY),
|
||||||
|
image.getString(JSONUtils.TITLE_KEY), image.getString(JSONUtils.DESCRIPTION_KEY),
|
||||||
|
image.getString(JSONUtils.TYPE_KEY), image.getString(JSONUtils.LINK_KEY)));
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
parseFailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
super.onPostExecute(aVoid);
|
||||||
|
if (parseFailed) {
|
||||||
|
parseImgurImagesAsyncTaskListener.failed();
|
||||||
|
} else {
|
||||||
|
parseImgurImagesAsyncTaskListener.success(images);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -80,12 +80,12 @@ import ml.docilealligator.infinityforreddit.Post.ParsePost;
|
|||||||
import ml.docilealligator.infinityforreddit.Post.Post;
|
import ml.docilealligator.infinityforreddit.Post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.ReadMessage;
|
import ml.docilealligator.infinityforreddit.ReadMessage;
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@ -582,10 +582,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
} else {
|
} else {
|
||||||
if (isSingleCommentThreadMode && mSingleCommentId != null) {
|
if (isSingleCommentThreadMode && mSingleCommentId != null) {
|
||||||
postAndComments = mOauthRetrofit.create(RedditAPI.class).getPostAndCommentsSingleThreadByIdOauth(subredditId,
|
postAndComments = mOauthRetrofit.create(RedditAPI.class).getPostAndCommentsSingleThreadByIdOauth(subredditId,
|
||||||
mSingleCommentId, sortType, RedditUtils.getOAuthHeader(mAccessToken));
|
mSingleCommentId, sortType, APIUtils.getOAuthHeader(mAccessToken));
|
||||||
} else {
|
} else {
|
||||||
postAndComments = mOauthRetrofit.create(RedditAPI.class).getPostAndCommentsByIdOauth(subredditId,
|
postAndComments = mOauthRetrofit.create(RedditAPI.class).getPostAndCommentsByIdOauth(subredditId,
|
||||||
sortType, RedditUtils.getOAuthHeader(mAccessToken));
|
sortType, APIUtils.getOAuthHeader(mAccessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
postAndComments.enqueue(new Callback<String>() {
|
postAndComments.enqueue(new Callback<String>() {
|
||||||
@ -976,8 +976,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
params.put(APIUtils.ID_KEY, mPost.getFullName());
|
||||||
mOauthRetrofit.create(RedditAPI.class).markNSFW(RedditUtils.getOAuthHeader(mAccessToken), params)
|
mOauthRetrofit.create(RedditAPI.class).markNSFW(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
@ -1014,8 +1014,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
params.put(APIUtils.ID_KEY, mPost.getFullName());
|
||||||
mOauthRetrofit.create(RedditAPI.class).unmarkNSFW(RedditUtils.getOAuthHeader(mAccessToken), params)
|
mOauthRetrofit.create(RedditAPI.class).unmarkNSFW(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
@ -1052,8 +1052,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
params.put(APIUtils.ID_KEY, mPost.getFullName());
|
||||||
mOauthRetrofit.create(RedditAPI.class).markSpoiler(RedditUtils.getOAuthHeader(mAccessToken), params)
|
mOauthRetrofit.create(RedditAPI.class).markSpoiler(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
@ -1090,8 +1090,8 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, mPost.getFullName());
|
params.put(APIUtils.ID_KEY, mPost.getFullName());
|
||||||
mOauthRetrofit.create(RedditAPI.class).unmarkSpoiler(RedditUtils.getOAuthHeader(mAccessToken), params)
|
mOauthRetrofit.create(RedditAPI.class).unmarkSpoiler(APIUtils.getOAuthHeader(mAccessToken), params)
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
@ -1582,13 +1582,13 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
@Override
|
@Override
|
||||||
public void flairSelected(Flair flair) {
|
public void flairSelected(Flair flair) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.API_TYPE_KEY, RedditUtils.API_TYPE_JSON);
|
params.put(APIUtils.API_TYPE_KEY, APIUtils.API_TYPE_JSON);
|
||||||
params.put(RedditUtils.FLAIR_TEMPLATE_ID_KEY, flair.getId());
|
params.put(APIUtils.FLAIR_TEMPLATE_ID_KEY, flair.getId());
|
||||||
params.put(RedditUtils.LINK_KEY, mPost.getFullName());
|
params.put(APIUtils.LINK_KEY, mPost.getFullName());
|
||||||
params.put(RedditUtils.TEXT_KEY, flair.getText());
|
params.put(APIUtils.TEXT_KEY, flair.getText());
|
||||||
|
|
||||||
mOauthRetrofit.create(RedditAPI.class).selectFlair(mPost.getSubredditNamePrefixed(),
|
mOauthRetrofit.create(RedditAPI.class).selectFlair(mPost.getSubredditNamePrefixed(),
|
||||||
RedditUtils.getOAuthHeader(mAccessToken), params).enqueue(new Callback<String>() {
|
APIUtils.getOAuthHeader(mAccessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
@ -103,7 +103,7 @@ import ml.docilealligator.infinityforreddit.R;
|
|||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter;
|
import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||||
@ -1681,13 +1681,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
if (previousVoteType != 1) {
|
if (previousVoteType != 1) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
mPost.setVoteType(1);
|
mPost.setVoteType(1);
|
||||||
newVoteType = RedditUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mUpvotedColor);
|
mScoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
mPost.setVoteType(0);
|
mPost.setVoteType(0);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -1700,7 +1700,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess() {
|
public void onVoteThingSuccess() {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
mPost.setVoteType(1);
|
mPost.setVoteType(1);
|
||||||
mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mUpvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mUpvotedColor);
|
mScoreTextView.setTextColor(mUpvotedColor);
|
||||||
@ -1755,13 +1755,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
if (previousVoteType != -1) {
|
if (previousVoteType != -1) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
mPost.setVoteType(-1);
|
mPost.setVoteType(-1);
|
||||||
newVoteType = RedditUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mDownvotedColor);
|
mScoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
mPost.setVoteType(0);
|
mPost.setVoteType(0);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
mScoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -1774,7 +1774,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingWithoutPositionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess() {
|
public void onVoteThingSuccess() {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
mPost.setVoteType(-1);
|
mPost.setVoteType(-1);
|
||||||
mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
mDownvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
mScoreTextView.setTextColor(mDownvotedColor);
|
mScoreTextView.setTextColor(mDownvotedColor);
|
||||||
@ -2772,13 +2772,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = RedditUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -2791,7 +2791,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position) {
|
public void onVoteThingSuccess(int position) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
||||||
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
@ -2834,13 +2834,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
||||||
newVoteType = RedditUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -2853,7 +2853,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
||||||
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
@ -43,7 +43,7 @@ import ml.docilealligator.infinityforreddit.Fragment.CommentMoreBottomSheetFragm
|
|||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -256,14 +256,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = RedditUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
((CommentViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -274,7 +274,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position) {
|
public void onVoteThingSuccess(int position) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
||||||
((CommentViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
@ -309,13 +309,13 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
||||||
newVoteType = RedditUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
||||||
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
|
@ -83,7 +83,7 @@ import ml.docilealligator.infinityforreddit.R;
|
|||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
import ml.docilealligator.infinityforreddit.User.UserDao;
|
import ml.docilealligator.infinityforreddit.User.UserDao;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||||
@ -923,14 +923,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
if (previousVoteType != 1) {
|
if (previousVoteType != 1) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
post.setVoteType(1);
|
post.setVoteType(1);
|
||||||
newVoteType = RedditUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
((PostCompactViewHolder) holder).upvoteButton
|
((PostCompactViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((PostCompactViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((PostCompactViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
post.setVoteType(0);
|
post.setVoteType(0);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
((PostCompactViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((PostCompactViewHolder) holder).upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((PostCompactViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
|
((PostCompactViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -940,7 +940,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
post.setVoteType(1);
|
post.setVoteType(1);
|
||||||
((PostCompactViewHolder) holder).upvoteButton
|
((PostCompactViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
@ -994,14 +994,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
if (previousVoteType != -1) {
|
if (previousVoteType != -1) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
post.setVoteType(-1);
|
post.setVoteType(-1);
|
||||||
newVoteType = RedditUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
((PostCompactViewHolder) holder).downvoteButton
|
((PostCompactViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((PostCompactViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((PostCompactViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
post.setVoteType(0);
|
post.setVoteType(0);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
((PostCompactViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((PostCompactViewHolder) holder).downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((PostCompactViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
|
((PostCompactViewHolder) holder).scoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -1011,7 +1011,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
post.setVoteType(-1);
|
post.setVoteType(-1);
|
||||||
((PostCompactViewHolder) holder).downvoteButton
|
((PostCompactViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
@ -1632,14 +1632,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
if (previousVoteType != 1) {
|
if (previousVoteType != 1) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
post.setVoteType(1);
|
post.setVoteType(1);
|
||||||
newVoteType = RedditUtils.DIR_UPVOTE;
|
newVoteType = APIUtils.DIR_UPVOTE;
|
||||||
upvoteButton
|
upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mUpvotedColor);
|
scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
post.setVoteType(0);
|
post.setVoteType(0);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -1649,7 +1649,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
|
||||||
post.setVoteType(1);
|
post.setVoteType(1);
|
||||||
upvoteButton
|
upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
@ -1706,14 +1706,14 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
if (previousVoteType != -1) {
|
if (previousVoteType != -1) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
post.setVoteType(-1);
|
post.setVoteType(-1);
|
||||||
newVoteType = RedditUtils.DIR_DOWNVOTE;
|
newVoteType = APIUtils.DIR_DOWNVOTE;
|
||||||
downvoteButton
|
downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mDownvotedColor);
|
scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
post.setVoteType(0);
|
post.setVoteType(0);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = APIUtils.DIR_UNVOTE;
|
||||||
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
downvoteButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
scoreTextView.setTextColor(mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
@ -1723,7 +1723,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
|
||||||
post.setVoteType(-1);
|
post.setVoteType(-1);
|
||||||
downvoteButton
|
downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
@ -34,6 +34,7 @@ import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActiv
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.ThemePreviewActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ThemePreviewActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewGIFActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewImageActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewImageActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.Activity.ViewImgurMediaActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
||||||
@ -49,6 +50,7 @@ import ml.docilealligator.infinityforreddit.Fragment.SidebarFragment;
|
|||||||
import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Fragment.UserListingFragment;
|
import ml.docilealligator.infinityforreddit.Fragment.UserListingFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.Fragment.ViewImgurVideoFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
|
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
|
||||||
import ml.docilealligator.infinityforreddit.Settings.AdvancedPreferenceFragment;
|
import ml.docilealligator.infinityforreddit.Settings.AdvancedPreferenceFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment;
|
import ml.docilealligator.infinityforreddit.Settings.CustomizeMainPageTabsFragment;
|
||||||
@ -167,4 +169,8 @@ public interface AppComponent {
|
|||||||
void inject(ReportActivity reportActivity);
|
void inject(ReportActivity reportActivity);
|
||||||
|
|
||||||
void inject(CustomizeMainPageTabsFragment customizeMainPageTabsFragment);
|
void inject(CustomizeMainPageTabsFragment customizeMainPageTabsFragment);
|
||||||
|
|
||||||
|
void inject(ViewImgurMediaActivity viewImgurMediaActivity);
|
||||||
|
|
||||||
|
void inject(ViewImgurVideoFragment viewImgurVideoFragment);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import im.ene.toro.exoplayer.MediaSourceBuilder;
|
|||||||
import im.ene.toro.exoplayer.ToroExo;
|
import im.ene.toro.exoplayer.ToroExo;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.CustomThemeSharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import okhttp3.ConnectionPool;
|
import okhttp3.ConnectionPool;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
@ -44,7 +44,7 @@ class AppModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
Retrofit provideOauthRetrofit(OkHttpClient okHttpClient) {
|
Retrofit provideOauthRetrofit(OkHttpClient okHttpClient) {
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
.baseUrl(RedditUtils.OAUTH_API_BASE_URI)
|
.baseUrl(APIUtils.OAUTH_API_BASE_URI)
|
||||||
.client(okHttpClient)
|
.client(okHttpClient)
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
@ -55,7 +55,7 @@ class AppModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
Retrofit provideOauthWithoutAuthenticatorRetrofit() {
|
Retrofit provideOauthWithoutAuthenticatorRetrofit() {
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
.baseUrl(RedditUtils.OAUTH_API_BASE_URI)
|
.baseUrl(APIUtils.OAUTH_API_BASE_URI)
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ class AppModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
Retrofit provideRetrofit() {
|
Retrofit provideRetrofit() {
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
.baseUrl(RedditUtils.API_BASE_URI)
|
.baseUrl(APIUtils.API_BASE_URI)
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ class AppModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
Retrofit provideUploadMediaRetrofit() {
|
Retrofit provideUploadMediaRetrofit() {
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
.baseUrl(RedditUtils.API_UPLOAD_MEDIA_URI)
|
.baseUrl(APIUtils.API_UPLOAD_MEDIA_URI)
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ class AppModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
Retrofit provideUploadVideoRetrofit() {
|
Retrofit provideUploadVideoRetrofit() {
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
.baseUrl(RedditUtils.API_UPLOAD_VIDEO_URI)
|
.baseUrl(APIUtils.API_UPLOAD_VIDEO_URI)
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@ -95,7 +95,17 @@ class AppModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
Retrofit provideGfycatRetrofit() {
|
Retrofit provideGfycatRetrofit() {
|
||||||
return new Retrofit.Builder()
|
return new Retrofit.Builder()
|
||||||
.baseUrl(RedditUtils.GFYCAT_API_BASE_URI)
|
.baseUrl(APIUtils.GFYCAT_API_BASE_URI)
|
||||||
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Named("imgur")
|
||||||
|
@Singleton
|
||||||
|
Retrofit provideImgurRetrofit() {
|
||||||
|
return new Retrofit.Builder()
|
||||||
|
.baseUrl(APIUtils.IMGUR_API_BASE_URI)
|
||||||
.addConverterFactory(ScalarsConverterFactory.create())
|
.addConverterFactory(ScalarsConverterFactory.create())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import android.os.Parcelable;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
|
|
||||||
public class CommentData implements Parcelable {
|
public class CommentData implements Parcelable {
|
||||||
public static final int VOTE_TYPE_NO_VOTE = 0;
|
public static final int VOTE_TYPE_NO_VOTE = 0;
|
||||||
@ -78,7 +78,7 @@ public class CommentData implements Parcelable {
|
|||||||
this.voteType = voteType;
|
this.voteType = voteType;
|
||||||
this.isSubmitter = isSubmitter;
|
this.isSubmitter = isSubmitter;
|
||||||
this.distinguished = distinguished;
|
this.distinguished = distinguished;
|
||||||
this.permalink = RedditUtils.API_BASE_URI + permalink;
|
this.permalink = APIUtils.API_BASE_URI + permalink;
|
||||||
this.awards = awards;
|
this.awards = awards;
|
||||||
this.depth = depth;
|
this.depth = depth;
|
||||||
this.collapsed = collapsed;
|
this.collapsed = collapsed;
|
||||||
|
@ -14,9 +14,10 @@ import org.json.JSONObject;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.Post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -78,10 +79,10 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
commentsCall = api.getUserSavedCommentsOauth(username, PostDataSource.USER_WHERE_SAVED,
|
commentsCall = api.getUserSavedCommentsOauth(username, PostDataSource.USER_WHERE_SAVED,
|
||||||
null, sortType.getType().value, sortType.getTime().value,
|
null, sortType.getType().value, sortType.getTime().value,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
commentsCall = api.getUserSavedCommentsOauth(username, PostDataSource.USER_WHERE_SAVED,
|
commentsCall = api.getUserSavedCommentsOauth(username, PostDataSource.USER_WHERE_SAVED,
|
||||||
null, sortType.getType().value, RedditUtils.getOAuthHeader(accessToken));
|
null, sortType.getType().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (accessToken == null) {
|
if (accessToken == null) {
|
||||||
@ -93,10 +94,10 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
commentsCall = api.getUserCommentsOauth(RedditUtils.getOAuthHeader(accessToken), username,
|
commentsCall = api.getUserCommentsOauth(APIUtils.getOAuthHeader(accessToken), username,
|
||||||
null, sortType.getType().value, sortType.getTime().value);
|
null, sortType.getType().value, sortType.getTime().value);
|
||||||
} else {
|
} else {
|
||||||
commentsCall = api.getUserCommentsOauth(RedditUtils.getOAuthHeader(accessToken), username,
|
commentsCall = api.getUserCommentsOauth(APIUtils.getOAuthHeader(accessToken), username,
|
||||||
null, sortType.getType().value);
|
null, sortType.getType().value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,10 +157,10 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
if (areSavedComments) {
|
if (areSavedComments) {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
commentsCall = api.getUserSavedCommentsOauth(username, PostDataSource.USER_WHERE_SAVED, params.key,
|
commentsCall = api.getUserSavedCommentsOauth(username, PostDataSource.USER_WHERE_SAVED, params.key,
|
||||||
sortType.getType().value, sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getType().value, sortType.getTime().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
commentsCall = api.getUserSavedCommentsOauth(username, PostDataSource.USER_WHERE_SAVED, params.key,
|
commentsCall = api.getUserSavedCommentsOauth(username, PostDataSource.USER_WHERE_SAVED, params.key,
|
||||||
sortType.getType().value, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getType().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (accessToken == null) {
|
if (accessToken == null) {
|
||||||
@ -171,10 +172,10 @@ public class CommentDataSource extends PageKeyedDataSource<String, CommentData>
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
commentsCall = api.getUserCommentsOauth(RedditUtils.getOAuthHeader(accessToken),
|
commentsCall = api.getUserCommentsOauth(APIUtils.getOAuthHeader(accessToken),
|
||||||
username, params.key, sortType.getType().value, sortType.getTime().value);
|
username, params.key, sortType.getType().value, sortType.getTime().value);
|
||||||
} else {
|
} else {
|
||||||
commentsCall = api.getUserCommentsOauth(RedditUtils.getOAuthHeader(accessToken),
|
commentsCall = api.getUserCommentsOauth(APIUtils.getOAuthHeader(accessToken),
|
||||||
username, params.key, sortType.getType().value);
|
username, params.key, sortType.getType().value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -14,8 +15,8 @@ import retrofit2.Retrofit;
|
|||||||
public class DeleteThing {
|
public class DeleteThing {
|
||||||
public static void delete(Retrofit oauthRetrofit, String fullname, String accessToken, DeleteThingListener deleteThingListener) {
|
public static void delete(Retrofit oauthRetrofit, String fullname, String accessToken, DeleteThingListener deleteThingListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, fullname);
|
params.put(APIUtils.ID_KEY, fullname);
|
||||||
oauthRetrofit.create(RedditAPI.class).delete(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).delete(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
@ -5,10 +5,11 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.InsertSubscribedThingsAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
|
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -19,9 +20,9 @@ public class FavoriteThing {
|
|||||||
String accessToken, SubscribedSubredditData subscribedSubredditData,
|
String accessToken, SubscribedSubredditData subscribedSubredditData,
|
||||||
FavoriteThingListener favoriteThingListener) {
|
FavoriteThingListener favoriteThingListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.SR_NAME_KEY, subscribedSubredditData.getName());
|
params.put(APIUtils.SR_NAME_KEY, subscribedSubredditData.getName());
|
||||||
params.put(RedditUtils.MAKE_FAVORITE_KEY, "true");
|
params.put(APIUtils.MAKE_FAVORITE_KEY, "true");
|
||||||
oauthRetrofit.create(RedditAPI.class).favoriteThing(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).favoriteThing(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
@ -43,9 +44,9 @@ public class FavoriteThing {
|
|||||||
String accessToken, SubscribedSubredditData subscribedSubredditData,
|
String accessToken, SubscribedSubredditData subscribedSubredditData,
|
||||||
FavoriteThingListener favoriteThingListener) {
|
FavoriteThingListener favoriteThingListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.SR_NAME_KEY, subscribedSubredditData.getName());
|
params.put(APIUtils.SR_NAME_KEY, subscribedSubredditData.getName());
|
||||||
params.put(RedditUtils.MAKE_FAVORITE_KEY, "false");
|
params.put(APIUtils.MAKE_FAVORITE_KEY, "false");
|
||||||
oauthRetrofit.create(RedditAPI.class).favoriteThing(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).favoriteThing(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
@ -67,9 +68,9 @@ public class FavoriteThing {
|
|||||||
String accessToken, SubscribedUserData subscribedUserData,
|
String accessToken, SubscribedUserData subscribedUserData,
|
||||||
FavoriteThingListener favoriteThingListener) {
|
FavoriteThingListener favoriteThingListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.SR_NAME_KEY, "u_" + subscribedUserData.getName());
|
params.put(APIUtils.SR_NAME_KEY, "u_" + subscribedUserData.getName());
|
||||||
params.put(RedditUtils.MAKE_FAVORITE_KEY, "true");
|
params.put(APIUtils.MAKE_FAVORITE_KEY, "true");
|
||||||
oauthRetrofit.create(RedditAPI.class).favoriteThing(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).favoriteThing(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
@ -91,9 +92,9 @@ public class FavoriteThing {
|
|||||||
String accessToken, SubscribedUserData subscribedUserData,
|
String accessToken, SubscribedUserData subscribedUserData,
|
||||||
FavoriteThingListener favoriteThingListener) {
|
FavoriteThingListener favoriteThingListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.SR_NAME_KEY, "u_" + subscribedUserData.getName());
|
params.put(APIUtils.SR_NAME_KEY, "u_" + subscribedUserData.getName());
|
||||||
params.put(RedditUtils.MAKE_FAVORITE_KEY, "false");
|
params.put(APIUtils.MAKE_FAVORITE_KEY, "false");
|
||||||
oauthRetrofit.create(RedditAPI.class).favoriteThing(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).favoriteThing(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
@ -6,7 +6,8 @@ import androidx.annotation.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -26,10 +27,10 @@ public class FetchComment {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (commentId == null) {
|
if (commentId == null) {
|
||||||
comments = api.getPostAndCommentsByIdOauth(article, sortType, RedditUtils.getOAuthHeader(accessToken));
|
comments = api.getPostAndCommentsByIdOauth(article, sortType, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
comments = api.getPostAndCommentsSingleThreadByIdOauth(article, commentId, sortType,
|
comments = api.getPostAndCommentsSingleThreadByIdOauth(article, commentId, sortType,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ public class FetchComment {
|
|||||||
if (accessToken == null) {
|
if (accessToken == null) {
|
||||||
moreComments = api.getInfo(stringBuilder.toString());
|
moreComments = api.getInfo(stringBuilder.toString());
|
||||||
} else {
|
} else {
|
||||||
moreComments = api.getInfoOauth(stringBuilder.toString(), RedditUtils.getOAuthHeader(accessToken));
|
moreComments = api.getInfoOauth(stringBuilder.toString(), APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
moreComments.enqueue(new Callback<String>() {
|
moreComments.enqueue(new Callback<String>() {
|
||||||
|
@ -9,8 +9,9 @@ import org.json.JSONException;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -20,7 +21,7 @@ public class FetchFlairs {
|
|||||||
public static void fetchFlairsInSubreddit(Retrofit oauthRetrofit, String accessToken, String subredditName, FetchFlairsInSubredditListener fetchFlairsInSubredditListener) {
|
public static void fetchFlairsInSubreddit(Retrofit oauthRetrofit, String accessToken, String subredditName, FetchFlairsInSubredditListener fetchFlairsInSubredditListener) {
|
||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Call<String> flairsCall = api.getFlairs(RedditUtils.getOAuthHeader(accessToken), subredditName);
|
Call<String> flairsCall = api.getFlairs(APIUtils.getOAuthHeader(accessToken), subredditName);
|
||||||
flairsCall.enqueue(new Callback<String>() {
|
flairsCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -7,6 +7,7 @@ import androidx.annotation.NonNull;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.GfycatAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
@ -14,8 +14,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@ -31,7 +32,7 @@ public class FetchMessages {
|
|||||||
|
|
||||||
static void fetchMessagesAsync(Retrofit oauthRetrofit, Locale locale, String accessToken, String where,
|
static void fetchMessagesAsync(Retrofit oauthRetrofit, Locale locale, String accessToken, String where,
|
||||||
String after, FetchMessagesListener fetchMessagesListener) {
|
String after, FetchMessagesListener fetchMessagesListener) {
|
||||||
oauthRetrofit.create(RedditAPI.class).getMessages(RedditUtils.getOAuthHeader(accessToken), where, after)
|
oauthRetrofit.create(RedditAPI.class).getMessages(APIUtils.getOAuthHeader(accessToken), where, after)
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -2,7 +2,8 @@ package ml.docilealligator.infinityforreddit;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -13,7 +14,7 @@ public class FetchMyInfo {
|
|||||||
final FetchUserMyListener fetchUserMyListener) {
|
final FetchUserMyListener fetchUserMyListener) {
|
||||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Call<String> userInfo = api.getMyInfo(RedditUtils.getOAuthHeader(accessToken));
|
Call<String> userInfo = api.getMyInfo(APIUtils.getOAuthHeader(accessToken));
|
||||||
userInfo.enqueue(new Callback<String>() {
|
userInfo.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
|
@ -10,6 +10,7 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
|
@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
|
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
@ -4,10 +4,11 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
|
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
|
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -21,7 +22,7 @@ public class FetchSubscribedThing {
|
|||||||
final FetchSubscribedThingListener fetchSubscribedThingListener) {
|
final FetchSubscribedThingListener fetchSubscribedThingListener) {
|
||||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Call<String> subredditDataCall = api.getSubscribedThing(lastItem, RedditUtils.getOAuthHeader(accessToken));
|
Call<String> subredditDataCall = api.getSubscribedThing(lastItem, APIUtils.getOAuthHeader(accessToken));
|
||||||
subredditDataCall.enqueue(new Callback<String>() {
|
subredditDataCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -4,6 +4,7 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.User.UserData;
|
import ml.docilealligator.infinityforreddit.User.UserData;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
|
@ -0,0 +1,112 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Fragment;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.alexvasilkov.gestures.views.GestureImageView;
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.RequestManager;
|
||||||
|
import com.bumptech.glide.load.DataSource;
|
||||||
|
import com.bumptech.glide.load.engine.GlideException;
|
||||||
|
import com.bumptech.glide.request.RequestListener;
|
||||||
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import ml.docilealligator.infinityforreddit.ImgurMedia;
|
||||||
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
*/
|
||||||
|
public class ViewImgurGifFragment extends Fragment {
|
||||||
|
|
||||||
|
public static final String EXTRA_IMGUR_GIF = "EIG";
|
||||||
|
|
||||||
|
@BindView(R.id.progress_bar_view_imgur_gif_fragment)
|
||||||
|
ProgressBar progressBar;
|
||||||
|
@BindView(R.id.image_view_view_imgur_gif_fragment)
|
||||||
|
GestureImageView imageView;
|
||||||
|
@BindView(R.id.load_image_error_linear_layout_view_imgur_gif_fragment)
|
||||||
|
LinearLayout errorLinearLayout;
|
||||||
|
|
||||||
|
private Activity activity;
|
||||||
|
private RequestManager glide;
|
||||||
|
private ImgurMedia imgurMedia;
|
||||||
|
|
||||||
|
public ViewImgurGifFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
// Inflate the layout for this fragment
|
||||||
|
View rootView = inflater.inflate(R.layout.fragment_view_imgur_gif, container, false);
|
||||||
|
|
||||||
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
imgurMedia = getArguments().getParcelable(EXTRA_IMGUR_GIF);
|
||||||
|
glide = Glide.with(activity);
|
||||||
|
loadGif();
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadGif() {
|
||||||
|
glide.load(imgurMedia.getLink()).listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
errorLinearLayout.setVisibility(View.VISIBLE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).into(imageView);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.view_imgur_image_fragments, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_download_view_imgur_image_fragments:
|
||||||
|
return true;
|
||||||
|
case R.id.action_share_view_imgur_image_fragments:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
activity = (Activity) context;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Fragment;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.alexvasilkov.gestures.views.GestureImageView;
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.RequestManager;
|
||||||
|
import com.bumptech.glide.load.DataSource;
|
||||||
|
import com.bumptech.glide.load.engine.GlideException;
|
||||||
|
import com.bumptech.glide.request.RequestListener;
|
||||||
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import ml.docilealligator.infinityforreddit.ImgurMedia;
|
||||||
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
|
||||||
|
public class ViewImgurImageFragment extends Fragment {
|
||||||
|
|
||||||
|
public static final String EXTRA_IMGUR_IMAGES = "EII";
|
||||||
|
|
||||||
|
@BindView(R.id.progress_bar_view_imgur_image_fragment)
|
||||||
|
ProgressBar progressBar;
|
||||||
|
@BindView(R.id.image_view_view_imgur_image_fragment)
|
||||||
|
GestureImageView imageView;
|
||||||
|
@BindView(R.id.load_image_error_linear_layout_view_imgur_image_fragment)
|
||||||
|
LinearLayout errorLinearLayout;
|
||||||
|
|
||||||
|
private Activity activity;
|
||||||
|
private RequestManager glide;
|
||||||
|
private ImgurMedia imgurMedia;
|
||||||
|
|
||||||
|
public ViewImgurImageFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View rootView = inflater.inflate(R.layout.fragment_view_imgur_images, container, false);
|
||||||
|
|
||||||
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
imgurMedia = getArguments().getParcelable(EXTRA_IMGUR_IMAGES);
|
||||||
|
glide = Glide.with(activity);
|
||||||
|
loadImage();
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadImage() {
|
||||||
|
glide.load(imgurMedia.getLink()).listener(new RequestListener<Drawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
errorLinearLayout.setVisibility(View.VISIBLE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).into(imageView);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.view_imgur_image_fragments, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_download_view_imgur_image_fragments:
|
||||||
|
return true;
|
||||||
|
case R.id.action_share_view_imgur_image_fragments:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
activity = (Activity) context;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,238 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Fragment;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.media.AudioManager;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||||
|
import com.google.android.exoplayer2.Player;
|
||||||
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
|
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
|
||||||
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
|
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
|
||||||
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
|
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
||||||
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
|
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||||
|
import com.google.android.exoplayer2.ui.PlayerView;
|
||||||
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
|
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||||
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import ml.docilealligator.infinityforreddit.ImgurMedia;
|
||||||
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple {@link Fragment} subclass.
|
||||||
|
*/
|
||||||
|
public class ViewImgurVideoFragment extends Fragment {
|
||||||
|
|
||||||
|
public static final String EXTRA_IMGUR_VIDEO = "EIV";
|
||||||
|
private static final String IS_MUTE_STATE = "IMS";
|
||||||
|
private static final String POSITION_STATE = "PS";
|
||||||
|
@BindView(R.id.player_view_view_imgur_video_fragment)
|
||||||
|
PlayerView videoPlayerView;
|
||||||
|
@BindView(R.id.mute_exo_playback_control_view)
|
||||||
|
ImageButton muteButton;
|
||||||
|
private Activity activity;
|
||||||
|
private ImgurMedia imgurMedia;
|
||||||
|
private SimpleExoPlayer player;
|
||||||
|
private DataSource.Factory dataSourceFactory;
|
||||||
|
private boolean wasPlaying = false;
|
||||||
|
private boolean isMute = false;
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences mSharedPreferences;
|
||||||
|
|
||||||
|
public ViewImgurVideoFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View rootView = inflater.inflate(R.layout.fragment_view_imgur_video, container, false);
|
||||||
|
|
||||||
|
((Infinity) activity.getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
|
imgurMedia = getArguments().getParcelable(EXTRA_IMGUR_VIDEO);
|
||||||
|
|
||||||
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT || getResources().getBoolean(R.bool.isTablet)) {
|
||||||
|
//Set player controller bottom margin in order to display it above the navbar
|
||||||
|
int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
|
||||||
|
LinearLayout controllerLinearLayout = rootView.findViewById(R.id.linear_layout_exo_playback_control_view);
|
||||||
|
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
|
||||||
|
params.bottomMargin = getResources().getDimensionPixelSize(resourceId);
|
||||||
|
} else {
|
||||||
|
//Set player controller right margin in order to display it above the navbar
|
||||||
|
int resourceId = getResources().getIdentifier("navigation_bar_height", "dimen", "android");
|
||||||
|
LinearLayout controllerLinearLayout = rootView.findViewById(R.id.linear_layout_exo_playback_control_view);
|
||||||
|
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) controllerLinearLayout.getLayoutParams();
|
||||||
|
params.rightMargin = getResources().getDimensionPixelSize(resourceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
videoPlayerView.setControllerVisibilityListener(visibility -> {
|
||||||
|
switch (visibility) {
|
||||||
|
case View.GONE:
|
||||||
|
activity.getWindow().getDecorView().setSystemUiVisibility(
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||||
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
|
| View.SYSTEM_UI_FLAG_IMMERSIVE);
|
||||||
|
break;
|
||||||
|
case View.VISIBLE:
|
||||||
|
activity.getWindow().getDecorView().setSystemUiVisibility(
|
||||||
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
|
||||||
|
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
|
||||||
|
player = ExoPlayerFactory.newSimpleInstance(activity, trackSelector);
|
||||||
|
videoPlayerView.setPlayer(player);
|
||||||
|
dataSourceFactory = new DefaultDataSourceFactory(activity,
|
||||||
|
Util.getUserAgent(activity, "Infinity"));
|
||||||
|
player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(imgurMedia.getLink())));
|
||||||
|
preparePlayer(savedInstanceState);
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.view_imgur_video_fragment, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.action_download_view_imgur_image_fragments:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void preparePlayer(Bundle savedInstanceState) {
|
||||||
|
player.setRepeatMode(Player.REPEAT_MODE_ALL);
|
||||||
|
wasPlaying = true;
|
||||||
|
|
||||||
|
boolean muteVideo = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_VIDEO, false);
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
long position = savedInstanceState.getLong(POSITION_STATE);
|
||||||
|
if (position > 0) {
|
||||||
|
player.seekTo(position);
|
||||||
|
}
|
||||||
|
isMute = savedInstanceState.getBoolean(IS_MUTE_STATE);
|
||||||
|
if (isMute) {
|
||||||
|
player.setVolume(0f);
|
||||||
|
muteButton.setImageResource(R.drawable.ic_mute_24dp);
|
||||||
|
} else {
|
||||||
|
player.setVolume(1f);
|
||||||
|
muteButton.setImageResource(R.drawable.ic_unmute_24dp);
|
||||||
|
}
|
||||||
|
} else if (muteVideo) {
|
||||||
|
isMute = true;
|
||||||
|
player.setVolume(0f);
|
||||||
|
muteButton.setImageResource(R.drawable.ic_mute_24dp);
|
||||||
|
} else {
|
||||||
|
muteButton.setImageResource(R.drawable.ic_unmute_24dp);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.addListener(new Player.EventListener() {
|
||||||
|
@Override
|
||||||
|
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
|
||||||
|
if (!trackGroups.isEmpty()) {
|
||||||
|
for (int i = 0; i < trackGroups.length; i++) {
|
||||||
|
String mimeType = trackGroups.get(i).getFormat(0).sampleMimeType;
|
||||||
|
if (mimeType != null && mimeType.contains("audio")) {
|
||||||
|
muteButton.setVisibility(View.VISIBLE);
|
||||||
|
muteButton.setOnClickListener(view -> {
|
||||||
|
if (isMute) {
|
||||||
|
isMute = false;
|
||||||
|
player.setVolume(1f);
|
||||||
|
muteButton.setImageResource(R.drawable.ic_unmute_24dp);
|
||||||
|
} else {
|
||||||
|
isMute = true;
|
||||||
|
player.setVolume(0f);
|
||||||
|
muteButton.setImageResource(R.drawable.ic_mute_24dp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
muteButton.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (wasPlaying) {
|
||||||
|
player.setPlayWhenReady(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
wasPlaying = player.getPlayWhenReady();
|
||||||
|
player.setPlayWhenReady(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean(IS_MUTE_STATE, isMute);
|
||||||
|
outState.putLong(POSITION_STATE, player.getCurrentPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
player.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(@NonNull Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
activity = (Activity) context;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
public class ImgurMedia implements Parcelable {
|
||||||
|
public static final int TYPE_IMAGE = 0;
|
||||||
|
public static final int TYPE_GIF = 1;
|
||||||
|
public static final int TYPE_VIDEO = 2;
|
||||||
|
private String id;
|
||||||
|
private String title;
|
||||||
|
private String description;
|
||||||
|
private String link;
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
public ImgurMedia(String id, String title, String description, String type, String link) {
|
||||||
|
this.id = id;
|
||||||
|
this.title = title;
|
||||||
|
this.description = description;
|
||||||
|
if (type.contains("mp4")) {
|
||||||
|
this.type = TYPE_VIDEO;
|
||||||
|
} else if (type.contains("gif")) {
|
||||||
|
this.type = TYPE_GIF;
|
||||||
|
} else {
|
||||||
|
this.type = TYPE_IMAGE;
|
||||||
|
}
|
||||||
|
this.link = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ImgurMedia(Parcel in) {
|
||||||
|
title = in.readString();
|
||||||
|
description = in.readString();
|
||||||
|
link = in.readString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<ImgurMedia> CREATOR = new Creator<ImgurMedia>() {
|
||||||
|
@Override
|
||||||
|
public ImgurMedia createFromParcel(Parcel in) {
|
||||||
|
return new ImgurMedia(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImgurMedia[] newArray(int size) {
|
||||||
|
return new ImgurMedia[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLink() {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel parcel, int i) {
|
||||||
|
parcel.writeString(title);
|
||||||
|
parcel.writeString(description);
|
||||||
|
parcel.writeString(link);
|
||||||
|
}
|
||||||
|
}
|
@ -5,9 +5,9 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -23,9 +23,9 @@ public class CreateMultiReddit {
|
|||||||
String accessToken, String multipath, String model,
|
String accessToken, String multipath, String model,
|
||||||
CreateMultiRedditListener createMultiRedditListener) {
|
CreateMultiRedditListener createMultiRedditListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.MULTIPATH_KEY, multipath);
|
params.put(APIUtils.MULTIPATH_KEY, multipath);
|
||||||
params.put(RedditUtils.MODEL_KEY, model);
|
params.put(APIUtils.MODEL_KEY, model);
|
||||||
oauthRetrofit.create(RedditAPI.class).createMultiReddit(RedditUtils.getOAuthHeader(accessToken),
|
oauthRetrofit.create(RedditAPI.class).createMultiReddit(APIUtils.getOAuthHeader(accessToken),
|
||||||
params).enqueue(new Callback<String>() {
|
params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -3,9 +3,9 @@ package ml.docilealligator.infinityforreddit.MultiReddit;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteMultiredditInDatabaseAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.DeleteMultiredditInDatabaseAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -20,7 +20,7 @@ public class DeleteMultiReddit {
|
|||||||
public static void deleteMultiReddit(Retrofit oauthRetrofit, RedditDataRoomDatabase redditDataRoomDatabase,
|
public static void deleteMultiReddit(Retrofit oauthRetrofit, RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
String accessToken, String accountName, String multipath,
|
String accessToken, String accountName, String multipath,
|
||||||
DeleteMultiRedditListener deleteMultiRedditListener) {
|
DeleteMultiRedditListener deleteMultiRedditListener) {
|
||||||
oauthRetrofit.create(RedditAPI.class).deleteMultiReddit(RedditUtils.getOAuthHeader(accessToken),
|
oauthRetrofit.create(RedditAPI.class).deleteMultiReddit(APIUtils.getOAuthHeader(accessToken),
|
||||||
multipath).enqueue(new Callback<String>() {
|
multipath).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -5,8 +5,8 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -21,9 +21,9 @@ public class EditMultiReddit {
|
|||||||
public static void editMultiReddit(Retrofit oauthRetrofit, String accessToken, String multipath, String model,
|
public static void editMultiReddit(Retrofit oauthRetrofit, String accessToken, String multipath, String model,
|
||||||
EditMultiRedditListener editMultiRedditListener) {
|
EditMultiRedditListener editMultiRedditListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.MULTIPATH_KEY, multipath);
|
params.put(APIUtils.MULTIPATH_KEY, multipath);
|
||||||
params.put(RedditUtils.MODEL_KEY, model);
|
params.put(APIUtils.MODEL_KEY, model);
|
||||||
oauthRetrofit.create(RedditAPI.class).updateMultiReddit(RedditUtils.getOAuthHeader(accessToken),
|
oauthRetrofit.create(RedditAPI.class).updateMultiReddit(APIUtils.getOAuthHeader(accessToken),
|
||||||
params).enqueue(new Callback<String>() {
|
params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -7,9 +7,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.AsyncTask.InsertMultiRedditAsyncTask;
|
import ml.docilealligator.infinityforreddit.AsyncTask.InsertMultiRedditAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -25,10 +25,10 @@ public class FavoriteMultiReddit {
|
|||||||
String accessToken, String accountName, boolean makeFavorite,
|
String accessToken, String accountName, boolean makeFavorite,
|
||||||
MultiReddit multiReddit, FavoriteMultiRedditListener favoriteMultiRedditListener) {
|
MultiReddit multiReddit, FavoriteMultiRedditListener favoriteMultiRedditListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.MULTIPATH_KEY, multiReddit.getPath());
|
params.put(APIUtils.MULTIPATH_KEY, multiReddit.getPath());
|
||||||
params.put(RedditUtils.MAKE_FAVORITE_KEY, String.valueOf(makeFavorite));
|
params.put(APIUtils.MAKE_FAVORITE_KEY, String.valueOf(makeFavorite));
|
||||||
params.put(RedditUtils.API_TYPE_KEY, RedditUtils.API_TYPE_JSON);
|
params.put(APIUtils.API_TYPE_KEY, APIUtils.API_TYPE_JSON);
|
||||||
oauthRetrofit.create(RedditAPI.class).favoriteMultiReddit(RedditUtils.getOAuthHeader(accessToken),
|
oauthRetrofit.create(RedditAPI.class).favoriteMultiReddit(APIUtils.getOAuthHeader(accessToken),
|
||||||
params).enqueue(new Callback<String>() {
|
params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -10,9 +10,9 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -27,7 +27,7 @@ public class FetchMultiRedditInfo {
|
|||||||
|
|
||||||
public static void fetchMultiRedditInfo(Retrofit retrofit, String accessToken, String multipath,
|
public static void fetchMultiRedditInfo(Retrofit retrofit, String accessToken, String multipath,
|
||||||
FetchMultiRedditInfoListener fetchMultiRedditInfoListener) {
|
FetchMultiRedditInfoListener fetchMultiRedditInfoListener) {
|
||||||
retrofit.create(RedditAPI.class).getMultiRedditInfo(RedditUtils.getOAuthHeader(accessToken), multipath).enqueue(new Callback<String>() {
|
retrofit.create(RedditAPI.class).getMultiRedditInfo(APIUtils.getOAuthHeader(accessToken), multipath).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
@ -4,8 +4,8 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -19,7 +19,7 @@ public class FetchMyMultiReddits {
|
|||||||
|
|
||||||
public static void fetchMyMultiReddits(Retrofit oauthRetrofit, String accessToken, FetchMyMultiRedditsListener fetchMyMultiRedditsListener) {
|
public static void fetchMyMultiReddits(Retrofit oauthRetrofit, String accessToken, FetchMyMultiRedditsListener fetchMyMultiRedditsListener) {
|
||||||
oauthRetrofit.create(RedditAPI.class)
|
oauthRetrofit.create(RedditAPI.class)
|
||||||
.getMyMultiReddits(RedditUtils.getOAuthHeader(accessToken)).enqueue(new Callback<String>() {
|
.getMyMultiReddits(APIUtils.getOAuthHeader(accessToken)).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
@ -4,8 +4,8 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -17,7 +17,7 @@ public class FetchPost {
|
|||||||
if (accessToken == null) {
|
if (accessToken == null) {
|
||||||
postCall = retrofit.create(RedditAPI.class).getPost(id);
|
postCall = retrofit.create(RedditAPI.class).getPost(id);
|
||||||
} else {
|
} else {
|
||||||
postCall = retrofit.create(RedditAPI.class).getPostOauth(id, RedditUtils.getOAuthHeader(accessToken));
|
postCall = retrofit.create(RedditAPI.class).getPostOauth(id, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
postCall.enqueue(new Callback<String>() {
|
postCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,8 +5,8 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -16,8 +16,8 @@ public class HidePost {
|
|||||||
public static void hidePost(Retrofit oauthRetrofit, String accessToken, String fullname,
|
public static void hidePost(Retrofit oauthRetrofit, String accessToken, String fullname,
|
||||||
HidePostListener hidePostListener) {
|
HidePostListener hidePostListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, fullname);
|
params.put(APIUtils.ID_KEY, fullname);
|
||||||
oauthRetrofit.create(RedditAPI.class).hide(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).hide(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
@ -37,8 +37,8 @@ public class HidePost {
|
|||||||
public static void unhidePost(Retrofit oauthRetrofit, String accessToken, String fullname,
|
public static void unhidePost(Retrofit oauthRetrofit, String accessToken, String fullname,
|
||||||
HidePostListener hidePostListener) {
|
HidePostListener hidePostListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, fullname);
|
params.put(APIUtils.ID_KEY, fullname);
|
||||||
oauthRetrofit.create(RedditAPI.class).unhide(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).unhide(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
@ -5,7 +5,7 @@ import android.os.Parcelable;
|
|||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by alex on 3/1/18.
|
* Created by alex on 3/1/18.
|
||||||
@ -90,7 +90,7 @@ public class Post implements Parcelable {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
this.previewUrl = previewUrl;
|
this.previewUrl = previewUrl;
|
||||||
this.thumbnailPreviewUrl = thumbnailPreviewUrl;
|
this.thumbnailPreviewUrl = thumbnailPreviewUrl;
|
||||||
this.permalink = RedditUtils.API_BASE_URI + permalink;
|
this.permalink = APIUtils.API_BASE_URI + permalink;
|
||||||
this.score = score;
|
this.score = score;
|
||||||
this.postType = postType;
|
this.postType = postType;
|
||||||
this.voteType = voteType;
|
this.voteType = voteType;
|
||||||
@ -128,7 +128,7 @@ public class Post implements Parcelable {
|
|||||||
this.previewUrl = previewUrl;
|
this.previewUrl = previewUrl;
|
||||||
this.thumbnailPreviewUrl = thumbnailPreviewUrl;
|
this.thumbnailPreviewUrl = thumbnailPreviewUrl;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.permalink = RedditUtils.API_BASE_URI + permalink;
|
this.permalink = APIUtils.API_BASE_URI + permalink;
|
||||||
this.score = score;
|
this.score = score;
|
||||||
this.postType = postType;
|
this.postType = postType;
|
||||||
this.voteType = voteType;
|
this.voteType = voteType;
|
||||||
@ -163,7 +163,7 @@ public class Post implements Parcelable {
|
|||||||
this.postTime = postTime;
|
this.postTime = postTime;
|
||||||
this.postTimeMillis = postTimeMillis;
|
this.postTimeMillis = postTimeMillis;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.permalink = RedditUtils.API_BASE_URI + permalink;
|
this.permalink = APIUtils.API_BASE_URI + permalink;
|
||||||
this.score = score;
|
this.score = score;
|
||||||
this.postType = postType;
|
this.postType = postType;
|
||||||
this.voteType = voteType;
|
this.voteType = voteType;
|
||||||
|
@ -10,9 +10,9 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -212,9 +212,9 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
Call<String> bestPost;
|
Call<String> bestPost;
|
||||||
if(sortType.getTime() != null) {
|
if(sortType.getTime() != null) {
|
||||||
bestPost = api.getBestPosts(sortType.getType().value, sortType.getTime().value, lastItem,
|
bestPost = api.getBestPosts(sortType.getType().value, sortType.getTime().value, lastItem,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
bestPost = api.getBestPosts(sortType.getType().value, lastItem, RedditUtils.getOAuthHeader(accessToken));
|
bestPost = api.getBestPosts(sortType.getType().value, lastItem, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
bestPost.enqueue(new Callback<String>() {
|
bestPost.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
@ -292,9 +292,9 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
Call<String> bestPost;
|
Call<String> bestPost;
|
||||||
if(sortType.getTime() != null) {
|
if(sortType.getTime() != null) {
|
||||||
bestPost = api.getBestPosts(sortType.getType().value, sortType.getTime().value, after,
|
bestPost = api.getBestPosts(sortType.getType().value, sortType.getTime().value, after,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
bestPost = api.getBestPosts(sortType.getType().value, after, RedditUtils.getOAuthHeader(accessToken));
|
bestPost = api.getBestPosts(sortType.getType().value, after, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
bestPost.enqueue(new Callback<String>() {
|
bestPost.enqueue(new Callback<String>() {
|
||||||
@ -351,10 +351,10 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType.getType().value,
|
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType.getType().value,
|
||||||
sortType.getTime().value, lastItem, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getTime().value, lastItem, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType.getType().value,
|
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType.getType().value,
|
||||||
lastItem, RedditUtils.getOAuthHeader(accessToken));
|
lastItem, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getPost.enqueue(new Callback<String>() {
|
getPost.enqueue(new Callback<String>() {
|
||||||
@ -442,10 +442,10 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType.getType().value,
|
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType.getType().value,
|
||||||
sortType.getTime().value, after, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getTime().value, after, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType.getType().value,
|
getPost = api.getSubredditBestPostsOauth(subredditOrUserName, sortType.getType().value,
|
||||||
after, RedditUtils.getOAuthHeader(accessToken));
|
after, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,10 +504,10 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.getUserPostsOauth(subredditOrUserName, userWhere, lastItem, sortType.getType().value,
|
getPost = api.getUserPostsOauth(subredditOrUserName, userWhere, lastItem, sortType.getType().value,
|
||||||
sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getTime().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.getUserPostsOauth(subredditOrUserName, userWhere, lastItem, sortType.getType().value,
|
getPost = api.getUserPostsOauth(subredditOrUserName, userWhere, lastItem, sortType.getType().value,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getPost.enqueue(new Callback<String>() {
|
getPost.enqueue(new Callback<String>() {
|
||||||
@ -575,10 +575,10 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.getUserPostsOauth(subredditOrUserName, userWhere, after, sortType.getType().value,
|
getPost = api.getUserPostsOauth(subredditOrUserName, userWhere, after, sortType.getType().value,
|
||||||
sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getTime().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.getUserPostsOauth(subredditOrUserName, userWhere, after, sortType.getType().value,
|
getPost = api.getUserPostsOauth(subredditOrUserName, userWhere, after, sortType.getType().value,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getPost.enqueue(new Callback<String>() {
|
getPost.enqueue(new Callback<String>() {
|
||||||
@ -636,10 +636,10 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
} else {
|
} else {
|
||||||
if(sortType.getTime() != null) {
|
if(sortType.getTime() != null) {
|
||||||
getPost = api.searchPostsOauth(query, lastItem, sortType.getType().value,
|
getPost = api.searchPostsOauth(query, lastItem, sortType.getType().value,
|
||||||
sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getTime().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.searchPostsOauth(query, lastItem, sortType.getType().value,
|
getPost = api.searchPostsOauth(query, lastItem, sortType.getType().value,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -655,11 +655,11 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query,
|
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query,
|
||||||
sortType.getType().value, sortType.getTime().value, lastItem,
|
sortType.getType().value, sortType.getTime().value, lastItem,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query,
|
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query,
|
||||||
sortType.getType().value, lastItem,
|
sortType.getType().value, lastItem,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -729,9 +729,9 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.searchPostsOauth(query, after, sortType.getType().value,
|
getPost = api.searchPostsOauth(query, after, sortType.getType().value,
|
||||||
sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getTime().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.searchPostsOauth(query, after, sortType.getType().value, RedditUtils.getOAuthHeader(accessToken));
|
getPost = api.searchPostsOauth(query, after, sortType.getType().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -747,10 +747,10 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query,
|
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query,
|
||||||
sortType.getType().value, sortType.getTime().value, after,
|
sortType.getType().value, sortType.getTime().value, after,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query,
|
getPost = api.searchPostsInSpecificSubredditOauth(subredditOrUserName, query,
|
||||||
sortType.getType().value, after, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getType().value, after, APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -808,10 +808,10 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.getMultiRedditPostsOauth(multiRedditPath, lastItem,
|
getPost = api.getMultiRedditPostsOauth(multiRedditPath, lastItem,
|
||||||
sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getTime().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.getMultiRedditPostsOauth(multiRedditPath, lastItem,
|
getPost = api.getMultiRedditPostsOauth(multiRedditPath, lastItem,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -880,10 +880,10 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
} else {
|
} else {
|
||||||
if (sortType.getTime() != null) {
|
if (sortType.getTime() != null) {
|
||||||
getPost = api.getMultiRedditPostsOauth(multiRedditPath, after,
|
getPost = api.getMultiRedditPostsOauth(multiRedditPath, after,
|
||||||
sortType.getTime().value, RedditUtils.getOAuthHeader(accessToken));
|
sortType.getTime().value, APIUtils.getOAuthHeader(accessToken));
|
||||||
} else {
|
} else {
|
||||||
getPost = api.getMultiRedditPostsOauth(multiRedditPath, after,
|
getPost = api.getMultiRedditPostsOauth(multiRedditPath, after,
|
||||||
RedditUtils.getOAuthHeader(accessToken));
|
APIUtils.getOAuthHeader(accessToken));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getPost.enqueue(new Callback<String>() {
|
getPost.enqueue(new Callback<String>() {
|
||||||
|
@ -20,9 +20,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.RedditAPI;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
@ -50,7 +50,7 @@ public class SubmitPost {
|
|||||||
public void uploaded(String imageUrl) {
|
public void uploaded(String imageUrl) {
|
||||||
submitPost(oauthRetrofit, accessToken, locale,
|
submitPost(oauthRetrofit, accessToken, locale,
|
||||||
subredditName, title, imageUrl, flair, isSpoiler, isNSFW,
|
subredditName, title, imageUrl, flair, isSpoiler, isNSFW,
|
||||||
RedditUtils.KIND_IMAGE, null, submitPostListener);
|
APIUtils.KIND_IMAGE, null, submitPostListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,10 +70,10 @@ public class SubmitPost {
|
|||||||
String fileType = mimeType.substring(mimeType.indexOf("/") + 1);
|
String fileType = mimeType.substring(mimeType.indexOf("/") + 1);
|
||||||
|
|
||||||
Map<String, String> uploadImageParams = new HashMap<>();
|
Map<String, String> uploadImageParams = new HashMap<>();
|
||||||
uploadImageParams.put(RedditUtils.FILEPATH_KEY, "post_video." + fileType);
|
uploadImageParams.put(APIUtils.FILEPATH_KEY, "post_video." + fileType);
|
||||||
uploadImageParams.put(RedditUtils.MIMETYPE_KEY, mimeType);
|
uploadImageParams.put(APIUtils.MIMETYPE_KEY, mimeType);
|
||||||
|
|
||||||
Call<String> uploadImageCall = api.uploadImage(RedditUtils.getOAuthHeader(accessToken), uploadImageParams);
|
Call<String> uploadImageCall = api.uploadImage(APIUtils.getOAuthHeader(accessToken), uploadImageParams);
|
||||||
uploadImageCall.enqueue(new Callback<String>() {
|
uploadImageCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
@ -106,11 +106,11 @@ public class SubmitPost {
|
|||||||
if (fileType.equals("gif")) {
|
if (fileType.equals("gif")) {
|
||||||
submitPost(oauthRetrofit, accessToken, locale,
|
submitPost(oauthRetrofit, accessToken, locale,
|
||||||
subredditName, title, url, flair, isSpoiler, isNSFW,
|
subredditName, title, url, flair, isSpoiler, isNSFW,
|
||||||
RedditUtils.KIND_VIDEOGIF, imageUrl, submitPostListener);
|
APIUtils.KIND_VIDEOGIF, imageUrl, submitPostListener);
|
||||||
} else {
|
} else {
|
||||||
submitPost(oauthRetrofit, accessToken, locale,
|
submitPost(oauthRetrofit, accessToken, locale,
|
||||||
subredditName, title, url, flair, isSpoiler, isNSFW,
|
subredditName, title, url, flair, isSpoiler, isNSFW,
|
||||||
RedditUtils.KIND_VIDEO, imageUrl, submitPostListener);
|
APIUtils.KIND_VIDEO, imageUrl, submitPostListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,36 +162,36 @@ public class SubmitPost {
|
|||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.API_TYPE_KEY, RedditUtils.API_TYPE_JSON);
|
params.put(APIUtils.API_TYPE_KEY, APIUtils.API_TYPE_JSON);
|
||||||
params.put(RedditUtils.SR_KEY, subredditName);
|
params.put(APIUtils.SR_KEY, subredditName);
|
||||||
params.put(RedditUtils.TITLE_KEY, title);
|
params.put(APIUtils.TITLE_KEY, title);
|
||||||
params.put(RedditUtils.KIND_KEY, kind);
|
params.put(APIUtils.KIND_KEY, kind);
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case RedditUtils.KIND_SELF:
|
case APIUtils.KIND_SELF:
|
||||||
params.put(RedditUtils.TEXT_KEY, content);
|
params.put(APIUtils.TEXT_KEY, content);
|
||||||
break;
|
break;
|
||||||
case RedditUtils.KIND_LINK:
|
case APIUtils.KIND_LINK:
|
||||||
case RedditUtils.KIND_IMAGE:
|
case APIUtils.KIND_IMAGE:
|
||||||
params.put(RedditUtils.URL_KEY, content);
|
params.put(APIUtils.URL_KEY, content);
|
||||||
break;
|
break;
|
||||||
case RedditUtils.KIND_VIDEOGIF:
|
case APIUtils.KIND_VIDEOGIF:
|
||||||
params.put(RedditUtils.KIND_KEY, RedditUtils.KIND_IMAGE);
|
params.put(APIUtils.KIND_KEY, APIUtils.KIND_IMAGE);
|
||||||
params.put(RedditUtils.URL_KEY, content);
|
params.put(APIUtils.URL_KEY, content);
|
||||||
params.put(RedditUtils.VIDEO_POSTER_URL_KEY, posterUrl);
|
params.put(APIUtils.VIDEO_POSTER_URL_KEY, posterUrl);
|
||||||
break;
|
break;
|
||||||
case RedditUtils.KIND_VIDEO:
|
case APIUtils.KIND_VIDEO:
|
||||||
params.put(RedditUtils.URL_KEY, content);
|
params.put(APIUtils.URL_KEY, content);
|
||||||
params.put(RedditUtils.VIDEO_POSTER_URL_KEY, posterUrl);
|
params.put(APIUtils.VIDEO_POSTER_URL_KEY, posterUrl);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flair != null) {
|
if (flair != null) {
|
||||||
params.put(RedditUtils.FLAIR_TEXT_KEY, flair);
|
params.put(APIUtils.FLAIR_TEXT_KEY, flair);
|
||||||
}
|
}
|
||||||
params.put(RedditUtils.SPOILER_KEY, Boolean.toString(isSpoiler));
|
params.put(APIUtils.SPOILER_KEY, Boolean.toString(isSpoiler));
|
||||||
params.put(RedditUtils.NSFW_KEY, Boolean.toString(isNSFW));
|
params.put(APIUtils.NSFW_KEY, Boolean.toString(isNSFW));
|
||||||
|
|
||||||
Call<String> submitPostCall = api.submit(RedditUtils.getOAuthHeader(accessToken), params);
|
Call<String> submitPostCall = api.submit(APIUtils.getOAuthHeader(accessToken), params);
|
||||||
submitPostCall.enqueue(new Callback<String>() {
|
submitPostCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
@ -221,10 +221,10 @@ public class SubmitPost {
|
|||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Map<String, String> uploadImageParams = new HashMap<>();
|
Map<String, String> uploadImageParams = new HashMap<>();
|
||||||
uploadImageParams.put(RedditUtils.FILEPATH_KEY, "post_image.jpg");
|
uploadImageParams.put(APIUtils.FILEPATH_KEY, "post_image.jpg");
|
||||||
uploadImageParams.put(RedditUtils.MIMETYPE_KEY, "image/jpeg");
|
uploadImageParams.put(APIUtils.MIMETYPE_KEY, "image/jpeg");
|
||||||
|
|
||||||
Call<String> uploadImageCall = api.uploadImage(RedditUtils.getOAuthHeader(accessToken), uploadImageParams);
|
Call<String> uploadImageCall = api.uploadImage(APIUtils.getOAuthHeader(accessToken), uploadImageParams);
|
||||||
uploadImageCall.enqueue(new Callback<String>() {
|
uploadImageCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
@ -308,12 +308,12 @@ public class SubmitPost {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!kind.equals(RedditUtils.KIND_IMAGE) && !kind.equals(RedditUtils.KIND_VIDEO) && !kind.equals(RedditUtils.KIND_VIDEOGIF)) {
|
if (!kind.equals(APIUtils.KIND_IMAGE) && !kind.equals(APIUtils.KIND_VIDEO) && !kind.equals(APIUtils.KIND_VIDEOGIF)) {
|
||||||
String postId = responseObject.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.ID_KEY);
|
String postId = responseObject.getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.ID_KEY);
|
||||||
|
|
||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Call<String> getPostCall = api.getPostOauth(postId, RedditUtils.getOAuthHeader(accessToken));
|
Call<String> getPostCall = api.getPostOauth(postId, APIUtils.getOAuthHeader(accessToken));
|
||||||
getPostCall.enqueue(new Callback<String>() {
|
getPostCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
@ -377,7 +377,7 @@ public class SubmitPost {
|
|||||||
nameValuePairsMap = new HashMap<>();
|
nameValuePairsMap = new HashMap<>();
|
||||||
for (int i = 0; i < nameValuePairs.length(); i++) {
|
for (int i = 0; i < nameValuePairs.length(); i++) {
|
||||||
nameValuePairsMap.put(nameValuePairs.getJSONObject(i).getString(JSONUtils.NAME_KEY),
|
nameValuePairsMap.put(nameValuePairs.getJSONObject(i).getString(JSONUtils.NAME_KEY),
|
||||||
RedditUtils.getRequestBody(nameValuePairs.getJSONObject(i).getString(JSONUtils.VALUE_KEY)));
|
APIUtils.getRequestBody(nameValuePairs.getJSONObject(i).getString(JSONUtils.VALUE_KEY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
successful = true;
|
successful = true;
|
||||||
|
@ -25,11 +25,12 @@ import java.util.Map;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.Account.Account;
|
import ml.docilealligator.infinityforreddit.Account.Account;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -204,7 +205,7 @@ public class PullNotificationWorker extends Worker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Call<String> call = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class)
|
Call<String> call = mOauthWithoutAuthenticatorRetrofit.create(RedditAPI.class)
|
||||||
.getMessages(RedditUtils.getOAuthHeader(account.getAccessToken()),
|
.getMessages(APIUtils.getOAuthHeader(account.getAccessToken()),
|
||||||
FetchMessages.WHERE_UNREAD, null);
|
FetchMessages.WHERE_UNREAD, null);
|
||||||
Response<String> response = call.execute();
|
Response<String> response = call.execute();
|
||||||
|
|
||||||
@ -230,15 +231,15 @@ public class PullNotificationWorker extends Worker {
|
|||||||
RedditAPI api = mRetrofit.create(RedditAPI.class);
|
RedditAPI api = mRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.GRANT_TYPE_KEY, RedditUtils.GRANT_TYPE_REFRESH_TOKEN);
|
params.put(APIUtils.GRANT_TYPE_KEY, APIUtils.GRANT_TYPE_REFRESH_TOKEN);
|
||||||
params.put(RedditUtils.REFRESH_TOKEN_KEY, refreshToken);
|
params.put(APIUtils.REFRESH_TOKEN_KEY, refreshToken);
|
||||||
|
|
||||||
Call<String> accessTokenCall = api.getAccessToken(RedditUtils.getHttpBasicAuthHeader(), params);
|
Call<String> accessTokenCall = api.getAccessToken(APIUtils.getHttpBasicAuthHeader(), params);
|
||||||
try {
|
try {
|
||||||
Response response = accessTokenCall.execute();
|
Response response = accessTokenCall.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
JSONObject jsonObject = new JSONObject(response.body().toString());
|
JSONObject jsonObject = new JSONObject(response.body().toString());
|
||||||
String newAccessToken = jsonObject.getString(RedditUtils.ACCESS_TOKEN_KEY);
|
String newAccessToken = jsonObject.getString(APIUtils.ACCESS_TOKEN_KEY);
|
||||||
mRedditDataRoomDatabase.accountDao().changeAccessToken(account.getUsername(), newAccessToken);
|
mRedditDataRoomDatabase.accountDao().changeAccessToken(account.getUsername(), newAccessToken);
|
||||||
return newAccessToken;
|
return newAccessToken;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -15,8 +16,8 @@ public class ReadMessage {
|
|||||||
public static void readMessage(Retrofit oauthRetrofit, String accessToken, String commaSeparatedFullnames,
|
public static void readMessage(Retrofit oauthRetrofit, String accessToken, String commaSeparatedFullnames,
|
||||||
ReadMessageListener readMessageListener) {
|
ReadMessageListener readMessageListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, commaSeparatedFullnames);
|
params.put(APIUtils.ID_KEY, commaSeparatedFullnames);
|
||||||
oauthRetrofit.create(RedditAPI.class).readMessage(RedditUtils.getOAuthHeader(accessToken), params)
|
oauthRetrofit.create(RedditAPI.class).readMessage(APIUtils.getOAuthHeader(accessToken), params)
|
||||||
.enqueue(new Callback<String>() {
|
.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
|
@ -5,7 +5,8 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -21,19 +22,19 @@ public class ReportThing {
|
|||||||
public static void reportThing(Retrofit oauthRetrofit, String accessToken, String thingFullname,
|
public static void reportThing(Retrofit oauthRetrofit, String accessToken, String thingFullname,
|
||||||
String subredditName, String reasonType, String reason,
|
String subredditName, String reasonType, String reason,
|
||||||
ReportThingListener reportThingListener) {
|
ReportThingListener reportThingListener) {
|
||||||
Map<String, String> header = RedditUtils.getOAuthHeader(accessToken);
|
Map<String, String> header = APIUtils.getOAuthHeader(accessToken);
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.THING_ID_KEY, thingFullname);
|
params.put(APIUtils.THING_ID_KEY, thingFullname);
|
||||||
params.put(RedditUtils.SR_NAME_KEY, subredditName);
|
params.put(APIUtils.SR_NAME_KEY, subredditName);
|
||||||
params.put(reasonType, reason);
|
params.put(reasonType, reason);
|
||||||
if (reasonType.equals(ReportReason.REASON_TYPE_SITE_REASON)) {
|
if (reasonType.equals(ReportReason.REASON_TYPE_SITE_REASON)) {
|
||||||
params.put(RedditUtils.REASON_KEY, ReportReason.REASON_SITE_REASON_SELECTED);
|
params.put(APIUtils.REASON_KEY, ReportReason.REASON_SITE_REASON_SELECTED);
|
||||||
} else if (reasonType.equals(ReportReason.REASON_TYPE_RULE_REASON)) {
|
} else if (reasonType.equals(ReportReason.REASON_TYPE_RULE_REASON)) {
|
||||||
params.put(RedditUtils.REASON_KEY, ReportReason.REASON_RULE_REASON_SELECTED);
|
params.put(APIUtils.REASON_KEY, ReportReason.REASON_RULE_REASON_SELECTED);
|
||||||
} else {
|
} else {
|
||||||
params.put(RedditUtils.REASON_KEY, ReportReason.REASON_OTHER);
|
params.put(APIUtils.REASON_KEY, ReportReason.REASON_OTHER);
|
||||||
}
|
}
|
||||||
params.put(RedditUtils.API_TYPE_KEY, RedditUtils.API_TYPE_JSON);
|
params.put(APIUtils.API_TYPE_KEY, APIUtils.API_TYPE_JSON);
|
||||||
|
|
||||||
oauthRetrofit.create(RedditAPI.class).report(header, params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).report(header, params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,7 +5,8 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -15,8 +16,8 @@ public class SaveThing {
|
|||||||
public static void saveThing(Retrofit oauthRetrofit, String accessToken, String fullname,
|
public static void saveThing(Retrofit oauthRetrofit, String accessToken, String fullname,
|
||||||
SaveThingListener saveThingListener) {
|
SaveThingListener saveThingListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, fullname);
|
params.put(APIUtils.ID_KEY, fullname);
|
||||||
oauthRetrofit.create(RedditAPI.class).save(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).save(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
@ -36,8 +37,8 @@ public class SaveThing {
|
|||||||
public static void unsaveThing(Retrofit oauthRetrofit, String accessToken, String fullname,
|
public static void unsaveThing(Retrofit oauthRetrofit, String accessToken, String fullname,
|
||||||
SaveThingListener saveThingListener) {
|
SaveThingListener saveThingListener) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ID_KEY, fullname);
|
params.put(APIUtils.ID_KEY, fullname);
|
||||||
oauthRetrofit.create(RedditAPI.class).unsave(RedditUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
oauthRetrofit.create(RedditAPI.class).unsave(APIUtils.getOAuthHeader(accessToken), params).enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
|
@ -7,7 +7,8 @@ import java.util.HashMap;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
@ -19,12 +20,12 @@ public class SendComment {
|
|||||||
Locale locale, Retrofit oauthRetrofit, String accessToken,
|
Locale locale, Retrofit oauthRetrofit, String accessToken,
|
||||||
SendCommentListener sendCommentListener) {
|
SendCommentListener sendCommentListener) {
|
||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
Map<String, String> headers = RedditUtils.getOAuthHeader(accessToken);
|
Map<String, String> headers = APIUtils.getOAuthHeader(accessToken);
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.API_TYPE_KEY, "json");
|
params.put(APIUtils.API_TYPE_KEY, "json");
|
||||||
params.put(RedditUtils.RETURN_RTJSON_KEY, "true");
|
params.put(APIUtils.RETURN_RTJSON_KEY, "true");
|
||||||
params.put(RedditUtils.TEXT_KEY, commentMarkdown);
|
params.put(APIUtils.TEXT_KEY, commentMarkdown);
|
||||||
params.put(RedditUtils.THING_ID_KEY, thingFullname);
|
params.put(APIUtils.THING_ID_KEY, thingFullname);
|
||||||
api.sendComment(headers, params);
|
api.sendComment(headers, params);
|
||||||
|
|
||||||
Call<String> sendCommentCall = api.sendComment(headers, params);
|
Call<String> sendCommentCall = api.sendComment(headers, params);
|
||||||
|
@ -7,9 +7,10 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
|
import ml.docilealligator.infinityforreddit.SubredditDatabase.SubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
|
import ml.docilealligator.infinityforreddit.SubscribedSubredditDatabase.SubscribedSubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -38,10 +39,10 @@ public class SubredditSubscription {
|
|||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ACTION_KEY, action);
|
params.put(APIUtils.ACTION_KEY, action);
|
||||||
params.put(RedditUtils.SR_NAME_KEY, subredditName);
|
params.put(APIUtils.SR_NAME_KEY, subredditName);
|
||||||
|
|
||||||
Call<String> subredditSubscriptionCall = api.subredditSubscription(RedditUtils.getOAuthHeader(accessToken), params);
|
Call<String> subredditSubscriptionCall = api.subredditSubscription(APIUtils.getOAuthHeader(accessToken), params);
|
||||||
subredditSubscriptionCall.enqueue(new Callback<String>() {
|
subredditSubscriptionCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
|
@ -7,10 +7,11 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao;
|
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserDao;
|
||||||
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
import ml.docilealligator.infinityforreddit.SubscribedUserDatabase.SubscribedUserData;
|
||||||
import ml.docilealligator.infinityforreddit.User.UserData;
|
import ml.docilealligator.infinityforreddit.User.UserData;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -38,10 +39,10 @@ public class UserFollowing {
|
|||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.ACTION_KEY, action);
|
params.put(APIUtils.ACTION_KEY, action);
|
||||||
params.put(RedditUtils.SR_NAME_KEY, "u_" + username);
|
params.put(APIUtils.SR_NAME_KEY, "u_" + username);
|
||||||
|
|
||||||
Call<String> subredditSubscriptionCall = api.subredditSubscription(RedditUtils.getOAuthHeader(accessToken), params);
|
Call<String> subredditSubscriptionCall = api.subredditSubscription(APIUtils.getOAuthHeader(accessToken), params);
|
||||||
subredditSubscriptionCall.enqueue(new Callback<String>() {
|
subredditSubscriptionCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
|
@ -12,16 +12,18 @@ import okhttp3.RequestBody;
|
|||||||
* Created by alex on 2/23/18.
|
* Created by alex on 2/23/18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class RedditUtils {
|
public class APIUtils {
|
||||||
public static final String OAUTH_URL = "https://www.reddit.com/api/v1/authorize.compact";
|
public static final String OAUTH_URL = "https://www.reddit.com/api/v1/authorize.compact";
|
||||||
public static final String OAUTH_API_BASE_URI = "https://oauth.reddit.com";
|
public static final String OAUTH_API_BASE_URI = "https://oauth.reddit.com";
|
||||||
public static final String API_BASE_URI = "https://www.reddit.com";
|
public static final String API_BASE_URI = "https://www.reddit.com";
|
||||||
public static final String API_UPLOAD_MEDIA_URI = "https://reddit-uploaded-media.s3-accelerate.amazonaws.com";
|
public static final String API_UPLOAD_MEDIA_URI = "https://reddit-uploaded-media.s3-accelerate.amazonaws.com";
|
||||||
public static final String API_UPLOAD_VIDEO_URI = "https://reddit-uploaded-video.s3-accelerate.amazonaws.com";
|
public static final String API_UPLOAD_VIDEO_URI = "https://reddit-uploaded-video.s3-accelerate.amazonaws.com";
|
||||||
public static final String GFYCAT_API_BASE_URI = "https://api.gfycat.com/v1/gfycats/";
|
public static final String GFYCAT_API_BASE_URI = "https://api.gfycat.com/v1/gfycats/";
|
||||||
|
public static final String IMGUR_API_BASE_URI = "https://api.imgur.com/3/";
|
||||||
|
|
||||||
public static final String CLIENT_ID_KEY = "client_id";
|
public static final String CLIENT_ID_KEY = "client_id";
|
||||||
public static final String CLIENT_ID = "";
|
public static final String CLIENT_ID = "";
|
||||||
|
public static final String IMGUR_CLIENT_ID = "";
|
||||||
public static final String RESPONSE_TYPE_KEY = "response_type";
|
public static final String RESPONSE_TYPE_KEY = "response_type";
|
||||||
public static final String RESPONSE_TYPE = "code";
|
public static final String RESPONSE_TYPE = "code";
|
||||||
public static final String STATE_KEY = "state";
|
public static final String STATE_KEY = "state";
|
||||||
@ -89,16 +91,16 @@ public class RedditUtils {
|
|||||||
|
|
||||||
public static Map<String, String> getHttpBasicAuthHeader() {
|
public static Map<String, String> getHttpBasicAuthHeader() {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
String credentials = String.format("%s:%s", RedditUtils.CLIENT_ID, "");
|
String credentials = String.format("%s:%s", APIUtils.CLIENT_ID, "");
|
||||||
String auth = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
|
String auth = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
|
||||||
params.put(RedditUtils.AUTHORIZATION_KEY, auth);
|
params.put(APIUtils.AUTHORIZATION_KEY, auth);
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, String> getOAuthHeader(String accessToken) {
|
public static Map<String, String> getOAuthHeader(String accessToken) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.AUTHORIZATION_KEY, RedditUtils.AUTHORIZATION_BASE + accessToken);
|
params.put(APIUtils.AUTHORIZATION_KEY, APIUtils.AUTHORIZATION_BASE + accessToken);
|
||||||
params.put(RedditUtils.USER_AGENT_KEY, RedditUtils.USER_AGENT);
|
params.put(APIUtils.USER_AGENT_KEY, APIUtils.USER_AGENT);
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
@ -21,12 +21,12 @@ public class JSONUtils {
|
|||||||
public static final String E_KEY = "e";
|
public static final String E_KEY = "e";
|
||||||
public static final String T_KEY = "t";
|
public static final String T_KEY = "t";
|
||||||
public static final String U_KEY = "u";
|
public static final String U_KEY = "u";
|
||||||
|
public static final String LINK_KEY = "link";
|
||||||
public static final String LINK_AUTHOR_KEY = "link_author";
|
public static final String LINK_AUTHOR_KEY = "link_author";
|
||||||
public static final String LINK_FLAIR_RICHTEXT_KEY = "link_flair_richtext";
|
public static final String LINK_FLAIR_RICHTEXT_KEY = "link_flair_richtext";
|
||||||
public static final String SCORE_KEY = "score";
|
public static final String SCORE_KEY = "score";
|
||||||
public static final String LIKES_KEY = "likes";
|
public static final String LIKES_KEY = "likes";
|
||||||
public static final String NSFW_KEY = "over_18";
|
public static final String NSFW_KEY = "over_18";
|
||||||
public static final String GILDED_KEY = "gilded";
|
|
||||||
public static final String PERMALINK_KEY = "permalink";
|
public static final String PERMALINK_KEY = "permalink";
|
||||||
public static final String CREATED_UTC_KEY = "created_utc";
|
public static final String CREATED_UTC_KEY = "created_utc";
|
||||||
public static final String PREVIEW_KEY = "preview";
|
public static final String PREVIEW_KEY = "preview";
|
||||||
@ -109,4 +109,5 @@ public class JSONUtils {
|
|||||||
public static final String GFY_ITEM_KEY = "gfyItem";
|
public static final String GFY_ITEM_KEY = "gfyItem";
|
||||||
public static final String MP4_URL_KEY = "mp4Url";
|
public static final String MP4_URL_KEY = "mp4Url";
|
||||||
public static final String WEBM_URL_KEY = "webmUrl";
|
public static final String WEBM_URL_KEY = "webmUrl";
|
||||||
|
public static final String TYPE_KEY = "type";
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,8 @@ import androidx.annotation.NonNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.RedditUtils;
|
import ml.docilealligator.infinityforreddit.API.RedditAPI;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -25,11 +26,11 @@ public class VoteThing {
|
|||||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.DIR_KEY, point);
|
params.put(APIUtils.DIR_KEY, point);
|
||||||
params.put(RedditUtils.ID_KEY, fullName);
|
params.put(APIUtils.ID_KEY, fullName);
|
||||||
params.put(RedditUtils.RANK_KEY, RedditUtils.RANK);
|
params.put(APIUtils.RANK_KEY, APIUtils.RANK);
|
||||||
|
|
||||||
Call<String> voteThingCall = api.voteThing(RedditUtils.getOAuthHeader(accessToken), params);
|
Call<String> voteThingCall = api.voteThing(APIUtils.getOAuthHeader(accessToken), params);
|
||||||
voteThingCall.enqueue(new Callback<String>() {
|
voteThingCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
@ -55,11 +56,11 @@ public class VoteThing {
|
|||||||
RedditAPI api = retrofit.create(RedditAPI.class);
|
RedditAPI api = retrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put(RedditUtils.DIR_KEY, point);
|
params.put(APIUtils.DIR_KEY, point);
|
||||||
params.put(RedditUtils.ID_KEY, fullName);
|
params.put(APIUtils.ID_KEY, fullName);
|
||||||
params.put(RedditUtils.RANK_KEY, RedditUtils.RANK);
|
params.put(APIUtils.RANK_KEY, APIUtils.RANK);
|
||||||
|
|
||||||
Call<String> voteThingCall = api.voteThing(RedditUtils.getOAuthHeader(accessToken), params);
|
Call<String> voteThingCall = api.voteThing(APIUtils.getOAuthHeader(accessToken), params);
|
||||||
voteThingCall.enqueue(new Callback<String>() {
|
voteThingCall.enqueue(new Callback<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
|
||||||
|
19
app/src/main/res/layout/activity_view_imgur_media.xml
Normal file
19
app/src/main/res/layout/activity_view_imgur_media.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar_view_imgur_media_activity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
|
<androidx.viewpager.widget.ViewPager
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/view_pager_view_imgur_media_activity"
|
||||||
|
tools:context=".Activity.ViewImgurMediaActivity" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
38
app/src/main/res/layout/fragment_view_imgur_gif.xml
Normal file
38
app/src/main/res/layout/fragment_view_imgur_gif.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/constraintLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".Fragment.ViewImgurImageFragment">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar_view_imgur_gif_fragment"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
|
<pl.droidsonroids.gif.GifImageView
|
||||||
|
android:id="@+id/image_view_view_imgur_gif_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/load_image_error_linear_layout_view_imgur_gif_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:drawableTop="@drawable/ic_error_outline_white_24dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:text="@string/error_loading_gif_tap_to_retry"
|
||||||
|
android:textSize="?attr/font_default" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
38
app/src/main/res/layout/fragment_view_imgur_images.xml
Normal file
38
app/src/main/res/layout/fragment_view_imgur_images.xml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/constraintLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".Fragment.ViewImgurImageFragment">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_bar_view_imgur_image_fragment"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true" />
|
||||||
|
|
||||||
|
<com.alexvasilkov.gestures.views.GestureImageView
|
||||||
|
android:id="@+id/image_view_view_imgur_image_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/load_image_error_linear_layout_view_imgur_image_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:drawableTop="@drawable/ic_error_outline_white_24dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:text="@string/error_loading_image_tap_to_retry"
|
||||||
|
android:textSize="?attr/font_default" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
15
app/src/main/res/layout/fragment_view_imgur_video.xml
Normal file
15
app/src/main/res/layout/fragment_view_imgur_video.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
tools:context=".Fragment.ViewImgurVideoFragment">
|
||||||
|
|
||||||
|
<com.google.android.exoplayer2.ui.PlayerView
|
||||||
|
android:id="@+id/player_view_view_imgur_video_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:controller_layout_id="@layout/exo_playback_control_view"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
17
app/src/main/res/menu/view_imgur_image_fragments.xml
Normal file
17
app/src/main/res/menu/view_imgur_image_fragments.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_download_view_imgur_image_fragments"
|
||||||
|
android:orderInCategory="1"
|
||||||
|
android:title="@string/action_download"
|
||||||
|
android:icon="@drawable/ic_file_download_toolbar_white_24dp"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_share_view_imgur_image_fragments"
|
||||||
|
android:orderInCategory="2"
|
||||||
|
android:title="@string/action_share"
|
||||||
|
android:icon="@drawable/ic_share_toolbar_white_24dp"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
</menu>
|
10
app/src/main/res/menu/view_imgur_video_fragment.xml
Normal file
10
app/src/main/res/menu/view_imgur_video_fragment.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_download_view_imgur_image_fragments"
|
||||||
|
android:orderInCategory="1"
|
||||||
|
android:title="@string/action_download"
|
||||||
|
android:icon="@drawable/ic_file_download_toolbar_white_24dp"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
</menu>
|
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<resources>
|
||||||
|
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||||
|
(such as screen margins) for screens with more than 820dp of available width. This
|
||||||
|
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||||
|
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||||
|
</resources>
|
@ -10,4 +10,6 @@
|
|||||||
<dimen name="roundedBottomSheetCornerRadiusLeftPadding">0dp</dimen>
|
<dimen name="roundedBottomSheetCornerRadiusLeftPadding">0dp</dimen>
|
||||||
<dimen name="roundedBottomSheetCornerRadiusRightPadding">0dp</dimen>
|
<dimen name="roundedBottomSheetCornerRadiusRightPadding">0dp</dimen>
|
||||||
<dimen name="staggeredLayoutManagerItemOffset">16dp</dimen>
|
<dimen name="staggeredLayoutManagerItemOffset">16dp</dimen>
|
||||||
|
<dimen name="appbar_padding">16dp</dimen>
|
||||||
|
<dimen name="appbar_padding_top">8dp</dimen>
|
||||||
</resources>
|
</resources>
|
@ -93,7 +93,7 @@
|
|||||||
<string name="nsfw">NSFW</string>
|
<string name="nsfw">NSFW</string>
|
||||||
<string name="karma_info">Karma: %1$d</string>
|
<string name="karma_info">Karma: %1$d</string>
|
||||||
<string name="karma_info_user_detail">Karma:\n%1$d (%2$d + %3$d)</string>
|
<string name="karma_info_user_detail">Karma:\n%1$d (%2$d + %3$d)</string>
|
||||||
<string name="cakeday_info">Cakeday:\n%1$s</string>
|
<string name="cakeday_info">Cake day:\n%1$s</string>
|
||||||
<string name="since">Since:</string>
|
<string name="since">Since:</string>
|
||||||
|
|
||||||
<string name="profile">Profile</string>
|
<string name="profile">Profile</string>
|
||||||
@ -734,4 +734,6 @@
|
|||||||
<string name="fetch_gfycat_video_failed">Fetch Gfycat video failed</string>
|
<string name="fetch_gfycat_video_failed">Fetch Gfycat video failed</string>
|
||||||
<string name="fetching_video_info_please_wait">Fetching video info. Please wait.</string>
|
<string name="fetching_video_info_please_wait">Fetching video info. Please wait.</string>
|
||||||
|
|
||||||
|
<string name="error_fetching_imgur_media">Cannot load images</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -54,16 +54,21 @@
|
|||||||
<style name="MaterialAlertDialogTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
|
<style name="MaterialAlertDialogTheme" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
|
||||||
<item name="android:textSize">?attr/font_default</item>
|
<item name="android:textSize">?attr/font_default</item>
|
||||||
<item name="android:background">?attr/cardViewBackgroundColor</item>
|
<item name="android:background">?attr/cardViewBackgroundColor</item>
|
||||||
<item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle</item>
|
<item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle
|
||||||
|
</item>
|
||||||
<item name="materialAlertDialogBodyTextStyle">@style/MaterialAlertDialogBodyTextStyle</item>
|
<item name="materialAlertDialogBodyTextStyle">@style/MaterialAlertDialogBodyTextStyle</item>
|
||||||
<item name="buttonBarPositiveButtonStyle">@style/MaterialAlertDialogPositiveButtonStyle</item>
|
<item name="buttonBarPositiveButtonStyle">@style/MaterialAlertDialogPositiveButtonStyle
|
||||||
<item name="buttonBarNegativeButtonStyle">@style/MaterialAlertDialogNegativeButtonStyle</item>
|
</item>
|
||||||
|
<item name="buttonBarNegativeButtonStyle">@style/MaterialAlertDialogNegativeButtonStyle
|
||||||
|
</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="CopyTextMaterialAlertDialogTheme">
|
<style name="CopyTextMaterialAlertDialogTheme">
|
||||||
<item name="android:textSize">?attr/font_default</item>
|
<item name="android:textSize">?attr/font_default</item>
|
||||||
<item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle</item>
|
<item name="materialAlertDialogTitleTextStyle">@style/MaterialAlertDialogTitleTextStyle
|
||||||
<item name="buttonBarNegativeButtonStyle">@style/MaterialAlertDialogNegativeButtonStyle</item>
|
</item>
|
||||||
|
<item name="buttonBarNegativeButtonStyle">@style/MaterialAlertDialogNegativeButtonStyle
|
||||||
|
</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="MaterialAlertDialogPositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
|
<style name="MaterialAlertDialogPositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
|
||||||
@ -84,10 +89,13 @@
|
|||||||
|
|
||||||
<style name="PreferenceActivityTheme" parent="AppTheme.NoActionBar">
|
<style name="PreferenceActivityTheme" parent="AppTheme.NoActionBar">
|
||||||
<item name="android:textAppearanceListItem">@style/PreferenceTitleTextStyle</item>
|
<item name="android:textAppearanceListItem">@style/PreferenceTitleTextStyle</item>
|
||||||
<item name="android:textAppearanceListItemSecondary">@style/PreferenceSubtitleTextStyle</item>
|
<item name="android:textAppearanceListItemSecondary">@style/PreferenceSubtitleTextStyle
|
||||||
|
</item>
|
||||||
<item name="android:textColorPrimary">?attr/primaryTextColor</item>
|
<item name="android:textColorPrimary">?attr/primaryTextColor</item>
|
||||||
<item name="buttonBarPositiveButtonStyle">@style/MaterialAlertDialogPositiveButtonStyle</item>
|
<item name="buttonBarPositiveButtonStyle">@style/MaterialAlertDialogPositiveButtonStyle
|
||||||
<item name="buttonBarNegativeButtonStyle">@style/MaterialAlertDialogNegativeButtonStyle</item>
|
</item>
|
||||||
|
<item name="buttonBarNegativeButtonStyle">@style/MaterialAlertDialogNegativeButtonStyle
|
||||||
|
</item>
|
||||||
<item name="alertDialogTheme">@style/ListPreferenceStyle</item>
|
<item name="alertDialogTheme">@style/ListPreferenceStyle</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user