Skip to content
Browse files

Bugfix where subreddit name wasn't always filled in when submitting p…

…osts
  • Loading branch information...
1 parent 470345a commit 1567e6893f15461179b8106a14d8b5f828632407 @QuantumBadger committed Jun 20, 2013
View
1 assets/changelog.txt
@@ -1,6 +1,7 @@
38/1.7.4
Bugfix for user profile dialog crash
Minor appearance improvement
+Bugfix where subreddit name wasn't always filled in when submitting posts
37/1.7.3
Bugfix for users with saved comments
View
2 src/main/java/org/quantumbadger/redreader/activities/MainActivity.java
@@ -446,7 +446,7 @@ public void onPastPosts() {
public void onSubmitPost() {
final Intent intent = new Intent(this, PostSubmitActivity.class);
- intent.putExtra("subreddit", postListingController.getSubreddit().display_name);
+ intent.putExtra("subreddit", postListingController.getSubreddit().url);
startActivity(intent);
}
View
2 src/main/java/org/quantumbadger/redreader/activities/PostListingActivity.java
@@ -153,7 +153,7 @@ public void onPastPosts() {
public void onSubmitPost() {
final Intent intent = new Intent(this, PostSubmitActivity.class);
- intent.putExtra("subreddit", controller.getSubreddit().display_name);
+ intent.putExtra("subreddit", controller.getSubreddit().url);
startActivity(intent);
}
View
8 src/main/java/org/quantumbadger/redreader/activities/PostSubmitActivity.java
@@ -75,7 +75,7 @@ protected void onCreate(Bundle savedInstanceState) {
if(getIntent() != null && getIntent().hasExtra("subreddit")) {
final String subreddit = getIntent().getStringExtra("subreddit");
- if(subreddit != null && subreddit.length() > 0 && !subreddit.equals("all") && subreddit.matches("\\w+")) {
+ if(subreddit != null && subreddit.length() > 0 && !subreddit.matches("/?(r/)?all/?") && subreddit.matches("/?(r/)?\\w+/?")) {
subredditEdit.setText(subreddit);
}
@@ -254,12 +254,16 @@ public void run() {
final RedditAccount selectedAccount = RedditAccountManager.getInstance(this).getAccount((String) usernameSpinner.getSelectedItem());
- final String subreddit = subredditEdit.getText().toString();
+ String subreddit = subredditEdit.getText().toString();
final String title = titleEdit.getText().toString();
final String text = textEdit.getText().toString();
final String captchaId = data.getStringExtra("captchaId");
final String captchaText = data.getStringExtra("captchaText");
+ while(subreddit.startsWith("/")) subreddit = subreddit.substring(1);
+ while(subreddit.startsWith("r/")) subreddit = subreddit.substring(2);
+ while(subreddit.endsWith("/")) subreddit = subreddit.substring(0, subreddit.length() - 1);
+
RedditAPI.submit(cm, handler, selectedAccount, is_self, subreddit, title, text, captchaId, captchaText, this);
progressDialog.show();

0 comments on commit 1567e68

Please sign in to comment.
Something went wrong with that request. Please try again.