mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-26 02:48:23 +01:00
Searching subreddits to post is available. Use Toolbar instead of ActionBar in various activities. Minor bugs fixed.
This commit is contained in:
parent
44e2987a84
commit
0d1fcecde6
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
BIN
.idea/caches/gradle_models.ser
generated
BIN
.idea/caches/gradle_models.ser
generated
Binary file not shown.
@ -19,6 +19,11 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
|
<activity
|
||||||
|
android:name=".SearchSubredditsResultActivity"
|
||||||
|
android:label="@string/search_subreddits_activity_label"
|
||||||
|
android:parentActivityName=".MainActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity android:name=".LinkResolverActivity">
|
<activity android:name=".LinkResolverActivity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
@ -44,17 +49,17 @@
|
|||||||
android:name=".PostVideoActivity"
|
android:name=".PostVideoActivity"
|
||||||
android:label="@string/post_video_activity_label"
|
android:label="@string/post_video_activity_label"
|
||||||
android:parentActivityName=".MainActivity"
|
android:parentActivityName=".MainActivity"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".PostImageActivity"
|
android:name=".PostImageActivity"
|
||||||
android:label="@string/post_image_activity_label"
|
android:label="@string/post_image_activity_label"
|
||||||
android:parentActivityName=".MainActivity"
|
android:parentActivityName=".MainActivity"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".PostLinkActivity"
|
android:name=".PostLinkActivity"
|
||||||
android:label="@string/post_link_activity_label"
|
android:label="@string/post_link_activity_label"
|
||||||
android:parentActivityName=".MainActivity"
|
android:parentActivityName=".MainActivity"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".SubscribedThingListingActivity"
|
android:name=".SubscribedThingListingActivity"
|
||||||
android:label="@string/subscriptions"
|
android:label="@string/subscriptions"
|
||||||
@ -63,12 +68,14 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".SubredditSelectionActivity"
|
android:name=".SubredditSelectionActivity"
|
||||||
android:label="@string/subreddit_selection_activity_label"
|
android:label="@string/subreddit_selection_activity_label"
|
||||||
android:parentActivityName=".MainActivity" />
|
android:parentActivityName=".MainActivity"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".PostTextActivity"
|
android:name=".PostTextActivity"
|
||||||
android:label="@string/post_text_activity_label"
|
android:label="@string/post_text_activity_label"
|
||||||
android:parentActivityName=".MainActivity"
|
android:parentActivityName=".MainActivity"
|
||||||
android:windowSoftInputMode="adjustResize" />
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:theme="@style/AppTheme.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".CommentActivity"
|
android:name=".CommentActivity"
|
||||||
android:label="@string/comment_activity_label"
|
android:label="@string/comment_activity_label"
|
||||||
|
@ -24,23 +24,24 @@ public class CustomMarkwonView extends MarkwonView {
|
|||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarkdown(@Nullable String markdown, Context conte) {
|
public void setMarkdown(@Nullable String markdown, Context context) {
|
||||||
SpannableConfiguration configuration = SpannableConfiguration.builder(conte).linkResolver((view, link) -> {
|
SpannableConfiguration configuration = SpannableConfiguration.builder(context).linkResolver((view, link) -> {
|
||||||
if(link.startsWith("/u/") || link.startsWith("u/")) {
|
if(link.startsWith("/u/") || link.startsWith("u/")) {
|
||||||
Intent intent = new Intent(conte, ViewUserDetailActivity.class);
|
Intent intent = new Intent(context, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3));
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3));
|
||||||
conte.startActivity(intent);
|
context.startActivity(intent);
|
||||||
} else if(link.startsWith("/r/") || link.startsWith("r/")) {
|
} else if(link.startsWith("/r/") || link.startsWith("r/")) {
|
||||||
Intent intent = new Intent(conte, ViewSubredditDetailActivity.class);
|
Intent intent = new Intent(context, ViewSubredditDetailActivity.class);
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3));
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3));
|
||||||
conte.startActivity(intent);
|
context.startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
|
||||||
// add share action to menu list
|
// add share action to menu list
|
||||||
builder.addDefaultShareMenuItem();
|
builder.addDefaultShareMenuItem();
|
||||||
builder.setToolbarColor(conte.getResources().getColor(R.color.colorPrimary));
|
builder.setToolbarColor(context.getResources().getColor(R.color.colorPrimary));
|
||||||
CustomTabsIntent customTabsIntent = builder.build();
|
CustomTabsIntent customTabsIntent = builder.build();
|
||||||
customTabsIntent.launchUrl(conte, Uri.parse(link));
|
customTabsIntent.intent.setPackage(context.getPackageName());
|
||||||
|
customTabsIntent.launchUrl(context, Uri.parse(link));
|
||||||
}
|
}
|
||||||
}).build();
|
}).build();
|
||||||
|
|
||||||
|
@ -300,6 +300,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
|
|||||||
return true;
|
return true;
|
||||||
case R.id.action_search_main_activity:
|
case R.id.action_search_main_activity:
|
||||||
Intent intent = new Intent(this, SearchActivity.class);
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
|
intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_SUBREDDITS, false);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_refresh_main_activity:
|
case R.id.action_refresh_main_activity:
|
||||||
|
@ -19,8 +19,8 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.content.FileProvider;
|
import androidx.core.content.FileProvider;
|
||||||
@ -69,6 +69,7 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
|
|||||||
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
private static final int CAPTURE_IMAGE_REQUEST_CODE = 2;
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_image_activity) CoordinatorLayout coordinatorLayout;
|
@BindView(R.id.coordinator_layout_post_image_activity) CoordinatorLayout coordinatorLayout;
|
||||||
|
@BindView(R.id.toolbar_post_image_activity) Toolbar toolbar;
|
||||||
@BindView(R.id.subreddit_icon_gif_image_view_post_image_activity) GifImageView iconGifImageView;
|
@BindView(R.id.subreddit_icon_gif_image_view_post_image_activity) GifImageView iconGifImageView;
|
||||||
@BindView(R.id.subreddit_name_text_view_post_image_activity) TextView subreditNameTextView;
|
@BindView(R.id.subreddit_name_text_view_post_image_activity) TextView subreditNameTextView;
|
||||||
@BindView(R.id.rules_button_post_image_activity) Button rulesButton;
|
@BindView(R.id.rules_button_post_image_activity) Button rulesButton;
|
||||||
@ -126,9 +127,8 @@ public class PostImageActivity extends AppCompatActivity implements FlairBottomS
|
|||||||
|
|
||||||
((Infinity) getApplication()).getmAppComponent().inject(this);
|
((Infinity) getApplication()).getmAppComponent().inject(this);
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
setSupportActionBar(toolbar);
|
||||||
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setHomeAsUpIndicator(upArrow);
|
|
||||||
|
|
||||||
mGlide = Glide.with(this);
|
mGlide = Glide.with(this);
|
||||||
mLocale = getResources().getConfiguration().locale;
|
mLocale = getResources().getConfiguration().locale;
|
||||||
|
@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -13,8 +12,8 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
@ -51,6 +50,7 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
|
|||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_link_activity) CoordinatorLayout coordinatorLayout;
|
@BindView(R.id.coordinator_layout_post_link_activity) CoordinatorLayout coordinatorLayout;
|
||||||
|
@BindView(R.id.toolbar_post_link_activity) Toolbar toolbar;
|
||||||
@BindView(R.id.subreddit_icon_gif_image_view_post_link_activity) GifImageView iconGifImageView;
|
@BindView(R.id.subreddit_icon_gif_image_view_post_link_activity) GifImageView iconGifImageView;
|
||||||
@BindView(R.id.subreddit_name_text_view_post_link_activity) TextView subredditNameTextView;
|
@BindView(R.id.subreddit_name_text_view_post_link_activity) TextView subredditNameTextView;
|
||||||
@BindView(R.id.rules_button_post_link_activity) Button rulesButton;
|
@BindView(R.id.rules_button_post_link_activity) Button rulesButton;
|
||||||
@ -95,9 +95,8 @@ public class PostLinkActivity extends AppCompatActivity implements FlairBottomSh
|
|||||||
|
|
||||||
((Infinity) getApplication()).getmAppComponent().inject(this);
|
((Infinity) getApplication()).getmAppComponent().inject(this);
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
setSupportActionBar(toolbar);
|
||||||
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setHomeAsUpIndicator(upArrow);
|
|
||||||
|
|
||||||
mGlide = Glide.with(this);
|
mGlide = Glide.with(this);
|
||||||
mLocale = getResources().getConfiguration().locale;
|
mLocale = getResources().getConfiguration().locale;
|
||||||
|
@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -13,8 +12,8 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
@ -51,6 +50,7 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
|
|||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_text_activity) CoordinatorLayout coordinatorLayout;
|
@BindView(R.id.coordinator_layout_post_text_activity) CoordinatorLayout coordinatorLayout;
|
||||||
|
@BindView(R.id.toolbar_post_text_activity) Toolbar toolbar;
|
||||||
@BindView(R.id.subreddit_icon_gif_image_view_search_activity) GifImageView iconGifImageView;
|
@BindView(R.id.subreddit_icon_gif_image_view_search_activity) GifImageView iconGifImageView;
|
||||||
@BindView(R.id.subreddit_name_text_view_search_activity) TextView subreditNameTextView;
|
@BindView(R.id.subreddit_name_text_view_search_activity) TextView subreditNameTextView;
|
||||||
@BindView(R.id.rules_button_post_text_activity) Button rulesButton;
|
@BindView(R.id.rules_button_post_text_activity) Button rulesButton;
|
||||||
@ -95,9 +95,8 @@ public class PostTextActivity extends AppCompatActivity implements FlairBottomSh
|
|||||||
|
|
||||||
((Infinity) getApplication()).getmAppComponent().inject(this);
|
((Infinity) getApplication()).getmAppComponent().inject(this);
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
setSupportActionBar(toolbar);
|
||||||
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setHomeAsUpIndicator(upArrow);
|
|
||||||
|
|
||||||
mGlide = Glide.with(this);
|
mGlide = Glide.with(this);
|
||||||
mLocale = getResources().getConfiguration().locale;
|
mLocale = getResources().getConfiguration().locale;
|
||||||
|
@ -19,8 +19,8 @@ import android.widget.VideoView;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
|
|
||||||
@ -66,6 +66,7 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
|
|||||||
private static final int CAPTURE_VIDEO_REQUEST_CODE = 2;
|
private static final int CAPTURE_VIDEO_REQUEST_CODE = 2;
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_post_video_activity) CoordinatorLayout coordinatorLayout;
|
@BindView(R.id.coordinator_layout_post_video_activity) CoordinatorLayout coordinatorLayout;
|
||||||
|
@BindView(R.id.toolbar_post_video_activity) Toolbar toolbar;
|
||||||
@BindView(R.id.subreddit_icon_gif_image_view_post_video_activity) GifImageView iconGifImageView;
|
@BindView(R.id.subreddit_icon_gif_image_view_post_video_activity) GifImageView iconGifImageView;
|
||||||
@BindView(R.id.subreddit_name_text_view_post_video_activity) TextView subreditNameTextView;
|
@BindView(R.id.subreddit_name_text_view_post_video_activity) TextView subreditNameTextView;
|
||||||
@BindView(R.id.rules_button_post_video_activity) Button rulesButton;
|
@BindView(R.id.rules_button_post_video_activity) Button rulesButton;
|
||||||
@ -127,9 +128,8 @@ public class PostVideoActivity extends AppCompatActivity implements FlairBottomS
|
|||||||
|
|
||||||
((Infinity) getApplication()).getmAppComponent().inject(this);
|
((Infinity) getApplication()).getmAppComponent().inject(this);
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
setSupportActionBar(toolbar);
|
||||||
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setHomeAsUpIndicator(upArrow);
|
|
||||||
|
|
||||||
mGlide = Glide.with(this);
|
mGlide = Glide.with(this);
|
||||||
mLocale = getResources().getConfiguration().locale;
|
mLocale = getResources().getConfiguration().locale;
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -22,11 +24,15 @@ public class SearchActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
static final String EXTRA_SUBREDDIT_IS_USER = "ESIU";
|
static final String EXTRA_SUBREDDIT_IS_USER = "ESIU";
|
||||||
|
static final String EXTRA_SEARCH_ONLY_SUBREDDITS = "ESOS";
|
||||||
|
static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
|
||||||
|
static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL";
|
||||||
|
|
||||||
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
||||||
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
||||||
|
|
||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
|
private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 1;
|
||||||
|
|
||||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||||
@BindView(R.id.search_view_search_activity) SimpleSearchView simpleSearchView;
|
@BindView(R.id.search_view_search_activity) SimpleSearchView simpleSearchView;
|
||||||
@ -45,6 +51,8 @@ public class SearchActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
|
boolean searchOnlySubreddits = getIntent().getExtras().getBoolean(EXTRA_SEARCH_ONLY_SUBREDDITS);
|
||||||
|
|
||||||
simpleSearchView.setOnSearchViewListener(new SimpleSearchView.SearchViewListener() {
|
simpleSearchView.setOnSearchViewListener(new SimpleSearchView.SearchViewListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSearchViewShown() {
|
public void onSearchViewShown() {
|
||||||
@ -70,19 +78,24 @@ public class SearchActivity extends AppCompatActivity {
|
|||||||
simpleSearchView.setOnQueryTextListener(new SimpleSearchView.OnQueryTextListener() {
|
simpleSearchView.setOnQueryTextListener(new SimpleSearchView.OnQueryTextListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextSubmit(String query) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
|
if(searchOnlySubreddits) {
|
||||||
intent.putExtra(SearchResultActivity.EXTRA_QUERY, query);
|
Intent intent = new Intent(SearchActivity.this, SearchSubredditsResultActivity.class);
|
||||||
if(subredditName != null) {
|
intent.putExtra(SearchSubredditsResultActivity.EXTRA_QUERY, query);
|
||||||
if(subredditIsUser) {
|
startActivityForResult(intent, SUBREDDIT_SEARCH_REQUEST_CODE);
|
||||||
intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
} else {
|
||||||
} else {
|
Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
|
||||||
intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SearchResultActivity.EXTRA_QUERY, query);
|
||||||
|
if(subredditName != null) {
|
||||||
|
if(subredditIsUser) {
|
||||||
|
intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
|
||||||
|
} else {
|
||||||
|
intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
finish();
|
|
||||||
startActivity(intent);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -107,11 +120,15 @@ public class SearchActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subredditNameRelativeLayout.setOnClickListener(view -> {
|
if(searchOnlySubreddits) {
|
||||||
Intent intent = new Intent(this, SubredditSelectionActivity.class);
|
subredditNameRelativeLayout.setVisibility(View.GONE);
|
||||||
intent.putExtra(SubredditSelectionActivity.EXTRA_EXTRA_CLEAR_SELECTION, true);
|
} else {
|
||||||
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
|
subredditNameRelativeLayout.setOnClickListener(view -> {
|
||||||
});
|
Intent intent = new Intent(this, SubredditSelectionActivity.class);
|
||||||
|
intent.putExtra(SubredditSelectionActivity.EXTRA_EXTRA_CLEAR_SELECTION, true);
|
||||||
|
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if(intent.hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if(intent.hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
@ -146,6 +163,16 @@ public class SearchActivity extends AppCompatActivity {
|
|||||||
subredditNameTextView.setText(subredditName);
|
subredditNameTextView.setText(subredditName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {
|
||||||
|
if(resultCode == RESULT_OK) {
|
||||||
|
String name = data.getExtras().getString(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||||
|
String iconUrl = data.getExtras().getString(SearchSubredditsResultActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
||||||
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
@ -149,7 +149,8 @@ public class SearchResultActivity extends AppCompatActivity implements SearchPos
|
|||||||
case 1: {
|
case 1: {
|
||||||
SubredditListingFragment mFragment = new SubredditListingFragment();
|
SubredditListingFragment mFragment = new SubredditListingFragment();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(SubredditListingFragment.QUERY_KEY, mQuery);
|
bundle.putString(SubredditListingFragment.EXTRA_QUERY_KEY, mQuery);
|
||||||
|
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_POSTING, false);
|
||||||
mFragment.setArguments(bundle);
|
mFragment.setArguments(bundle);
|
||||||
return mFragment;
|
return mFragment;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
|
public class SearchSubredditsResultActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
static final String EXTRA_QUERY = "EQ";
|
||||||
|
static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
|
||||||
|
static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL";
|
||||||
|
|
||||||
|
private static final String FRAGMENT_OUT_STATE = "FOS";
|
||||||
|
|
||||||
|
@BindView(R.id.toolbar_search_subreddits_result_activity) Toolbar toolbar;
|
||||||
|
|
||||||
|
Fragment mFragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_search_subreddits_result);
|
||||||
|
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
String query = getIntent().getExtras().getString(EXTRA_QUERY);
|
||||||
|
|
||||||
|
if(savedInstanceState == null) {
|
||||||
|
mFragment = new SubredditListingFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(SubredditListingFragment.EXTRA_QUERY_KEY, query);
|
||||||
|
bundle.putBoolean(SubredditListingFragment.EXTRA_IS_POSTING, true);
|
||||||
|
mFragment.setArguments(bundle);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_subreddits_result_activity, mFragment).commit();
|
||||||
|
} else {
|
||||||
|
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_search_subreddits_result_activity, mFragment).commit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void getSelectedSubreddit(String name, String iconUrl) {
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
||||||
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
if (mFragment != null) {
|
||||||
|
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -33,7 +35,8 @@ import retrofit2.Retrofit;
|
|||||||
*/
|
*/
|
||||||
public class SubredditListingFragment extends Fragment implements FragmentCommunicator {
|
public class SubredditListingFragment extends Fragment implements FragmentCommunicator {
|
||||||
|
|
||||||
static final String QUERY_KEY = "QK";
|
static final String EXTRA_QUERY_KEY = "EQK";
|
||||||
|
static final String EXTRA_IS_POSTING = "EIP";
|
||||||
|
|
||||||
@BindView(R.id.coordinator_layout_subreddit_listing_fragment) CoordinatorLayout mCoordinatorLayout;
|
@BindView(R.id.coordinator_layout_subreddit_listing_fragment) CoordinatorLayout mCoordinatorLayout;
|
||||||
@BindView(R.id.recycler_view_subreddit_listing_fragment) RecyclerView mSubredditListingRecyclerView;
|
@BindView(R.id.recycler_view_subreddit_listing_fragment) RecyclerView mSubredditListingRecyclerView;
|
||||||
@ -44,8 +47,6 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
|
|
||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
|
|
||||||
private String mQuery;
|
|
||||||
|
|
||||||
private SubredditListingRecyclerViewAdapter mAdapter;
|
private SubredditListingRecyclerViewAdapter mAdapter;
|
||||||
|
|
||||||
SubredditListingViewModel mSubredditListingViewModel;
|
SubredditListingViewModel mSubredditListingViewModel;
|
||||||
@ -70,16 +71,19 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View rootView = inflater.inflate(R.layout.fragment_subreddit_listing, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_subreddit_listing, container, false);
|
||||||
|
|
||||||
((Infinity) getActivity().getApplication()).getmAppComponent().inject(this);
|
Activity activity = getActivity();
|
||||||
|
|
||||||
|
((Infinity) activity.getApplication()).getmAppComponent().inject(this);
|
||||||
|
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
mLinearLayoutManager = new LinearLayoutManager(getActivity());
|
mLinearLayoutManager = new LinearLayoutManager(getActivity());
|
||||||
mSubredditListingRecyclerView.setLayoutManager(mLinearLayoutManager);
|
mSubredditListingRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||||
|
|
||||||
mQuery = getArguments().getString(QUERY_KEY);
|
String query = getArguments().getString(EXTRA_QUERY_KEY);
|
||||||
|
boolean isPosting = getArguments().getBoolean(EXTRA_IS_POSTING);
|
||||||
|
|
||||||
SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(mRetrofit, mQuery,
|
SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(mRetrofit, query,
|
||||||
PostDataSource.SORT_TYPE_RELEVANCE, new SubredditListingDataSource.OnSubredditListingDataFetchedCallback() {
|
PostDataSource.SORT_TYPE_RELEVANCE, new SubredditListingDataSource.OnSubredditListingDataFetchedCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void hasSubreddit() {
|
public void hasSubreddit() {
|
||||||
@ -98,7 +102,23 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
|
|||||||
mAdapter = new SubredditListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
|
mAdapter = new SubredditListingRecyclerViewAdapter(getActivity(), mOauthRetrofit, mRetrofit,
|
||||||
mAuthInfoSharedPreferences,
|
mAuthInfoSharedPreferences,
|
||||||
SubscribedSubredditRoomDatabase.getDatabase(getContext()).subscribedSubredditDao(),
|
SubscribedSubredditRoomDatabase.getDatabase(getContext()).subscribedSubredditDao(),
|
||||||
() -> mSubredditListingViewModel.retryLoadingMore());
|
new SubredditListingRecyclerViewAdapter.Callback() {
|
||||||
|
@Override
|
||||||
|
public void retryLoadingMore() {
|
||||||
|
mSubredditListingViewModel.retryLoadingMore();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void subredditSelected(String subredditName, String iconUrl) {
|
||||||
|
if(isPosting) {
|
||||||
|
((SearchSubredditsResultActivity) activity).getSelectedSubreddit(subredditName, iconUrl);
|
||||||
|
} else {
|
||||||
|
Intent intent = new Intent(activity, ViewSubredditDetailActivity.class);
|
||||||
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditName);
|
||||||
|
activity.startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mSubredditListingRecyclerView.setAdapter(mAdapter);
|
mSubredditListingRecyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package ml.docilealligator.infinityforreddit;
|
package ml.docilealligator.infinityforreddit;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -31,8 +30,9 @@ import pl.droidsonroids.gif.GifImageView;
|
|||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<SubredditData, RecyclerView.ViewHolder> {
|
public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<SubredditData, RecyclerView.ViewHolder> {
|
||||||
interface RetryLoadingMoreCallback {
|
interface Callback {
|
||||||
void retryLoadingMore();
|
void retryLoadingMore();
|
||||||
|
void subredditSelected(String subredditName, String iconUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
@ -48,19 +48,19 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
|
|||||||
private SubscribedSubredditDao subscribedSubredditDao;
|
private SubscribedSubredditDao subscribedSubredditDao;
|
||||||
|
|
||||||
private NetworkState networkState;
|
private NetworkState networkState;
|
||||||
private RetryLoadingMoreCallback retryLoadingMoreCallback;
|
private Callback callback;
|
||||||
|
|
||||||
SubredditListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
|
SubredditListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
|
||||||
SharedPreferences authInfoSharedPreferences,
|
SharedPreferences authInfoSharedPreferences,
|
||||||
SubscribedSubredditDao subscribedSubredditDao,
|
SubscribedSubredditDao subscribedSubredditDao,
|
||||||
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
Callback callback) {
|
||||||
super(DIFF_CALLBACK);
|
super(DIFF_CALLBACK);
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.oauthRetrofit = oauthRetrofit;
|
this.oauthRetrofit = oauthRetrofit;
|
||||||
this.retrofit = retrofit;
|
this.retrofit = retrofit;
|
||||||
this.authInfoSharedPreferences = authInfoSharedPreferences;
|
this.authInfoSharedPreferences = authInfoSharedPreferences;
|
||||||
this.subscribedSubredditDao = subscribedSubredditDao;
|
this.subscribedSubredditDao = subscribedSubredditDao;
|
||||||
this.retryLoadingMoreCallback = retryLoadingMoreCallback;
|
this.callback = callback;
|
||||||
glide = Glide.with(context.getApplicationContext());
|
glide = Glide.with(context.getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,11 +95,8 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
|
|||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if(holder instanceof DataViewHolder) {
|
if(holder instanceof DataViewHolder) {
|
||||||
SubredditData subredditData = getItem(position);
|
SubredditData subredditData = getItem(position);
|
||||||
((DataViewHolder) holder).constraintLayout.setOnClickListener(view -> {
|
((DataViewHolder) holder).constraintLayout.setOnClickListener(view ->
|
||||||
Intent intent = new Intent(context, ViewSubredditDetailActivity.class);
|
callback.subredditSelected(subredditData.getName(), subredditData.getIconUrl()));
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, subredditData.getName());
|
|
||||||
context.startActivity(intent);
|
|
||||||
});
|
|
||||||
|
|
||||||
if(!subredditData.getIconUrl().equals("")) {
|
if(!subredditData.getIconUrl().equals("")) {
|
||||||
glide.load(subredditData.getIconUrl())
|
glide.load(subredditData.getIconUrl())
|
||||||
@ -207,7 +204,7 @@ public class SubredditListingRecyclerViewAdapter extends PagedListAdapter<Subred
|
|||||||
ErrorViewHolder(View itemView) {
|
ErrorViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
retryButton.setOnClickListener(view -> retryLoadingMoreCallback.retryLoadingMore());
|
retryButton.setOnClickListener(view -> callback.retryLoadingMore());
|
||||||
errorTextView.setText(R.string.load_comments_failed);
|
errorTextView.setText(R.string.load_comments_failed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,17 @@ package ml.docilealligator.infinityforreddit;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class SubredditSelectionActivity extends AppCompatActivity {
|
public class SubredditSelectionActivity extends AppCompatActivity {
|
||||||
@ -19,6 +22,13 @@ public class SubredditSelectionActivity extends AppCompatActivity {
|
|||||||
static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL";
|
static final String EXTRA_RETURN_SUBREDDIT_ICON_URL = "ERSIURL";
|
||||||
static final String EXTRA_RETURN_SUBREDDIT_IS_USER = "ERSIU";
|
static final String EXTRA_RETURN_SUBREDDIT_IS_USER = "ERSIU";
|
||||||
|
|
||||||
|
private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 0;
|
||||||
|
private static final String FRAGMENT_OUT_STATE = "FOS";
|
||||||
|
|
||||||
|
@BindView(R.id.toolbar_subreddit_selection_activity) Toolbar toolbar;
|
||||||
|
|
||||||
|
private Fragment mFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -26,19 +36,29 @@ public class SubredditSelectionActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
setSupportActionBar(toolbar);
|
||||||
Drawable upArrow = getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setHomeAsUpIndicator(upArrow);
|
|
||||||
|
|
||||||
SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment();
|
if(savedInstanceState == null) {
|
||||||
Bundle bundle = new Bundle();
|
mFragment = new SubscribedSubredditsListingFragment();
|
||||||
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, true);
|
Bundle bundle = new Bundle();
|
||||||
if(getIntent().hasExtra(EXTRA_EXTRA_CLEAR_SELECTION)) {
|
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, true);
|
||||||
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_EXTRA_CLEAR_SELECTION,
|
if(getIntent().hasExtra(EXTRA_EXTRA_CLEAR_SELECTION)) {
|
||||||
getIntent().getExtras().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION));
|
bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_EXTRA_CLEAR_SELECTION,
|
||||||
|
getIntent().getExtras().getBoolean(EXTRA_EXTRA_CLEAR_SELECTION));
|
||||||
|
}
|
||||||
|
mFragment.setArguments(bundle);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit();
|
||||||
|
} else {
|
||||||
|
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
|
||||||
|
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, mFragment).commit();
|
||||||
}
|
}
|
||||||
fragment.setArguments(bundle);
|
}
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_subreddit_selection_activity, fragment).commit();
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.subreddit_selection_activity, menu);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,6 +67,11 @@ public class SubredditSelectionActivity extends AppCompatActivity {
|
|||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_search_subreddit_selection_activity:
|
||||||
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
|
intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_SUBREDDITS, true);
|
||||||
|
startActivityForResult(intent, SUBREDDIT_SEARCH_REQUEST_CODE);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -60,4 +85,29 @@ public class SubredditSelectionActivity extends AppCompatActivity {
|
|||||||
setResult(Activity.RESULT_OK, returnIntent);
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||||
|
if(requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {
|
||||||
|
if(resultCode == RESULT_OK) {
|
||||||
|
String name = data.getExtras().getString(SearchActivity.EXTRA_RETURN_SUBREDDIT_NAME);
|
||||||
|
String iconUrl = data.getExtras().getString(SearchActivity.EXTRA_RETURN_SUBREDDIT_ICON_URL);
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_NAME, name);
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_ICON_URL, iconUrl);
|
||||||
|
returnIntent.putExtra(EXTRA_RETURN_SUBREDDIT_IS_USER, false);
|
||||||
|
setResult(Activity.RESULT_OK, returnIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(@NonNull Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
if (mFragment != null) {
|
||||||
|
getSupportFragmentManager().putFragment(outState, FRAGMENT_OUT_STATE, mFragment);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,6 +312,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
|
|||||||
Intent intent = new Intent(this, SearchActivity.class);
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_IS_USER, false);
|
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_IS_USER, false);
|
||||||
|
intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_SUBREDDITS, false);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case R.id.action_refresh_view_subreddit_detail_activity:
|
case R.id.action_refresh_view_subreddit_detail_activity:
|
||||||
|
@ -328,6 +328,7 @@ public class ViewUserDetailActivity extends AppCompatActivity {
|
|||||||
Intent intent = new Intent(this, SearchActivity.class);
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, userName);
|
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, userName);
|
||||||
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_IS_USER, true);
|
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_IS_USER, true);
|
||||||
|
intent.putExtra(SearchActivity.EXTRA_SEARCH_ONLY_SUBREDDITS, false);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case R.id.action_refresh_view_user_detail_activity:
|
case R.id.action_refresh_view_user_detail_activity:
|
||||||
|
@ -7,10 +7,24 @@
|
|||||||
android:id="@+id/coordinator_layout_post_image_activity"
|
android:id="@+id/coordinator_layout_post_image_activity"
|
||||||
tools:context=".PostImageActivity">
|
tools:context=".PostImageActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_post_image_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:navigationIcon="?attr/homeAsUpIndicator" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -7,10 +7,24 @@
|
|||||||
android:id="@+id/coordinator_layout_post_link_activity"
|
android:id="@+id/coordinator_layout_post_link_activity"
|
||||||
tools:context=".PostTextActivity">
|
tools:context=".PostTextActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_post_link_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:navigationIcon="?attr/homeAsUpIndicator" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -7,10 +7,24 @@
|
|||||||
android:id="@+id/coordinator_layout_post_text_activity"
|
android:id="@+id/coordinator_layout_post_text_activity"
|
||||||
tools:context=".PostTextActivity">
|
tools:context=".PostTextActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_post_text_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:navigationIcon="?attr/homeAsUpIndicator" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -7,10 +7,24 @@
|
|||||||
android:id="@+id/coordinator_layout_post_video_activity"
|
android:id="@+id/coordinator_layout_post_video_activity"
|
||||||
tools:context=".PostImageActivity">
|
tools:context=".PostImageActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_post_video_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:navigationIcon="?attr/homeAsUpIndicator" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fillViewport="true">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".SearchSubredditsResultActivity">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_search_subreddits_result_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:navigationIcon="?attr/homeAsUpIndicator" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frame_layout_search_subreddits_result_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
@ -1,8 +1,29 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/frame_layout_subreddit_selection_activity"
|
tools:context=".SubredditSelectionActivity">
|
||||||
tools:context=".SubredditSelectionActivity" />
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/AppTheme.AppBarOverlay">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar_subreddit_selection_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
app:popupTheme="@style/AppTheme.PopupOverlay"
|
||||||
|
app:navigationIcon="?attr/homeAsUpIndicator" />
|
||||||
|
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frame_layout_subreddit_selection_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
|
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
10
app/src/main/res/menu/subreddit_selection_activity.xml
Normal file
10
app/src/main/res/menu/subreddit_selection_activity.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_search_subreddit_selection_activity"
|
||||||
|
android:orderInCategory="1"
|
||||||
|
android:title="@string/action_search"
|
||||||
|
android:icon="@drawable/ic_search_white_24dp"
|
||||||
|
app:showAsAction="ifRoom" />
|
||||||
|
</menu>
|
@ -10,6 +10,7 @@
|
|||||||
<string name="post_image_activity_label">Image Post</string>
|
<string name="post_image_activity_label">Image Post</string>
|
||||||
<string name="post_video_activity_label">Video Post</string>
|
<string name="post_video_activity_label">Video Post</string>
|
||||||
<string name="rules_activity_label">Rules</string>
|
<string name="rules_activity_label">Rules</string>
|
||||||
|
<string name="search_subreddits_activity_label">Subreddits</string>
|
||||||
|
|
||||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user