aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPostService.java (renamed from app/src/main/java/ml/docilealligator/infinityforreddit/PostMediaService.java)8
6 files changed, 49 insertions, 41 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 6dca6581..3f93717a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -25,5 +25,5 @@ interface AppComponent {
void inject(FlairBottomSheetFragment flairBottomSheetFragment);
void inject(RulesActivity rulesActivity);
void inject(CommentsListingFragment commentsListingFragment);
- void inject(PostMediaService postMediaService);
+ void inject(SubmitPostService submitPostService);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java
index 5dd8934f..74e19f3a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostImageActivity.java
@@ -349,14 +349,14 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
subredditName = subreditNameTextView.getText().toString();
}
- Intent intent = new Intent(this, PostMediaService.class);
+ Intent intent = new Intent(this, SubmitPostService.class);
intent.setData(imageUri);
- intent.putExtra(PostMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
- intent.putExtra(PostMediaService.EXTRA_TITLE, titleEditText.getText().toString());
- intent.putExtra(PostMediaService.EXTRA_FLAIR, flair);
- intent.putExtra(PostMediaService.EXTRA_IS_SPOILER, isSpoiler);
- intent.putExtra(PostMediaService.EXTRA_IS_NSFW, isNSFW);
- intent.putExtra(PostMediaService.EXTRA_POST_TYPE, PostMediaService.EXTRA_POST_TYPE_IMAGE);
+ intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
+ intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
+ intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
+ intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_IMAGE);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java
index bbbd5540..ed537d78 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostLinkActivity.java
@@ -97,6 +97,8 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
ButterKnife.bind(this);
+ EventBus.getDefault().register(this);
+
((Infinity) getApplication()).getmAppComponent().inject(this);
setSupportActionBar(toolbar);
@@ -241,8 +243,8 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
getMenuInflater().inflate(R.menu.post_link_activity, menu);
mMemu = menu;
if(isPosting) {
- mMemu.findItem(R.id.action_send_post_image_activity).setEnabled(false);
- mMemu.findItem(R.id.action_send_post_image_activity).getIcon().setAlpha(130);
+ mMemu.findItem(R.id.action_send_post_link_activity).setEnabled(false);
+ mMemu.findItem(R.id.action_send_post_link_activity).getIcon().setAlpha(130);
}
return true;
}
@@ -259,6 +261,8 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
return true;
}
+ isPosting = true;
+
item.setEnabled(false);
item.getIcon().setAlpha(130);
Snackbar postingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
@@ -271,15 +275,16 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
subredditName = subredditNameTextView.getText().toString();
}
- Intent intent = new Intent(this, PostMediaService.class);
- intent.putExtra(PostMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
- intent.putExtra(PostMediaService.EXTRA_TITLE, titleEditText.getText().toString());
- intent.putExtra(PostMediaService.EXTRA_CONTENT, contentEditText.getText().toString());
- intent.putExtra(PostMediaService.EXTRA_KIND, RedditUtils.KIND_LINK);
- intent.putExtra(PostMediaService.EXTRA_FLAIR, flair);
- intent.putExtra(PostMediaService.EXTRA_IS_SPOILER, isSpoiler);
- intent.putExtra(PostMediaService.EXTRA_IS_NSFW, isNSFW);
- intent.putExtra(PostMediaService.EXTRA_POST_TYPE, PostMediaService.EXTRA_POST_TYPE_IMAGE);
+ Intent intent = new Intent(this, SubmitPostService.class);
+ intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_KIND, RedditUtils.KIND_LINK);
+ intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
+ intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
+ intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
+ intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TEXT_OR_LINK);
+ startService(intent);
return true;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java
index fd485e4b..d96dddc6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostTextActivity.java
@@ -248,8 +248,8 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
getMenuInflater().inflate(R.menu.post_text_activity, menu);
mMemu = menu;
if(isPosting) {
- mMemu.findItem(R.id.action_send_post_image_activity).setEnabled(false);
- mMemu.findItem(R.id.action_send_post_image_activity).getIcon().setAlpha(130);
+ mMemu.findItem(R.id.action_send_post_text_activity).setEnabled(false);
+ mMemu.findItem(R.id.action_send_post_text_activity).getIcon().setAlpha(130);
}
return true;
}
@@ -266,6 +266,8 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
return true;
}
+ isPosting = true;
+
item.setEnabled(false);
item.getIcon().setAlpha(130);
mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
@@ -278,15 +280,16 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
subredditName = subreditNameTextView.getText().toString();
}
- Intent intent = new Intent(this, PostMediaService.class);
- intent.putExtra(PostMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
- intent.putExtra(PostMediaService.EXTRA_TITLE, titleEditText.getText().toString());
- intent.putExtra(PostMediaService.EXTRA_CONTENT, contentEditText.getText().toString());
- intent.putExtra(PostMediaService.EXTRA_KIND, RedditUtils.KIND_SELF);
- intent.putExtra(PostMediaService.EXTRA_FLAIR, flair);
- intent.putExtra(PostMediaService.EXTRA_IS_SPOILER, isSpoiler);
- intent.putExtra(PostMediaService.EXTRA_IS_NSFW, isNSFW);
- intent.putExtra(PostMediaService.EXTRA_POST_TYPE, PostMediaService.EXTRA_POST_TYPE_IMAGE);
+ Intent intent = new Intent(this, SubmitPostService.class);
+ intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_KIND, RedditUtils.KIND_SELF);
+ intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
+ intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
+ intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
+ intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TEXT_OR_LINK);
+ startService(intent);
return true;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java
index 9f3f14fb..6df6134a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostVideoActivity.java
@@ -345,14 +345,14 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
subredditName = subreditNameTextView.getText().toString();
}
- Intent intent = new Intent(this, PostMediaService.class);
+ Intent intent = new Intent(this, SubmitPostService.class);
intent.setData(videoUri);
- intent.putExtra(PostMediaService.EXTRA_SUBREDDIT_NAME, subredditName);
- intent.putExtra(PostMediaService.EXTRA_TITLE, titleEditText.getText().toString());
- intent.putExtra(PostMediaService.EXTRA_FLAIR, flair);
- intent.putExtra(PostMediaService.EXTRA_IS_SPOILER, isSpoiler);
- intent.putExtra(PostMediaService.EXTRA_IS_NSFW, isNSFW);
- intent.putExtra(PostMediaService.EXTRA_POST_TYPE, PostMediaService.EXTRA_POST_TYPE_VIDEO);
+ intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
+ intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
+ intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
+ intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_VIDEO);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostMediaService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPostService.java
index 21f12cd4..b78f4ab2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostMediaService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubmitPostService.java
@@ -32,7 +32,7 @@ import javax.inject.Named;
import retrofit2.Retrofit;
-public class PostMediaService extends Service {
+public class SubmitPostService extends Service {
static final String EXTRA_SUBREDDIT_NAME = "ESN";
static final String EXTRA_TITLE = "ET";
static final String EXTRA_CONTENT = "EC";
@@ -65,7 +65,7 @@ public class PostMediaService extends Service {
@Named("auth_info")
SharedPreferences sharedPreferences;
- public PostMediaService() {
+ public SubmitPostService() {
}
@Override
@@ -158,7 +158,7 @@ public class PostMediaService extends Service {
@Override
public void submitSuccessful(Post post) {
EventBus.getDefault().post(new SubmitImagePostEvent(true, null));
- Toast.makeText(PostMediaService.this, R.string.image_is_processing, Toast.LENGTH_SHORT).show();
+ Toast.makeText(SubmitPostService.this, R.string.image_is_processing, Toast.LENGTH_SHORT).show();
stopForeground(true);
stopSelf();
@@ -202,7 +202,7 @@ public class PostMediaService extends Service {
@Override
public void submitSuccessful(Post post) {
EventBus.getDefault().post(new SubmitVideoPostEvent(true, false, null));
- Toast.makeText(PostMediaService.this, R.string.video_is_processing, Toast.LENGTH_SHORT).show();
+ Toast.makeText(SubmitPostService.this, R.string.video_is_processing, Toast.LENGTH_SHORT).show();
stopForeground(true);
stopSelf();