Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Multireddit dropdown list in drawer #3066

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ public void run() {
if (Authentication.isLoggedIn) {
new AsyncNotificationBadge().executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR);
new SyncMultiReddits().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
if (!Reddit.appRestart.getString(CheckForMail.SUBS_TO_GET, "").isEmpty()) {
new CheckForMail.AsyncGetSubs(MainActivity.this).executeOnExecutor(
Expand Down Expand Up @@ -1482,21 +1483,14 @@ public void doDrawer() {
if (Authentication.isLoggedIn && Authentication.didOnline) {

header = inflater.inflate(R.layout.drawer_loggedin, drawerSubList, false);
RelativeLayout multiReddits = header.findViewById(R.id.multi);
headerMain = header;
hea = header.findViewById(R.id.back);

drawerSubList.addHeaderView(header, null, false);
((TextView) header.findViewById(R.id.name)).setText(Authentication.name);
header.findViewById(R.id.multi).setOnClickListener(new OnSingleClickListener() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this removed it's not possible to open the regular MultiredditOverview

@Override
public void onSingleClick(View view) {
if (runAfterLoad == null) {
Intent inte = new Intent(MainActivity.this, MultiredditOverview.class);
MainActivity.this.startActivity(inte);
}
}
});
header.findViewById(R.id.multi).setOnLongClickListener(new View.OnLongClickListener() {

multiReddits.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
new MaterialDialog.Builder(MainActivity.this).inputRange(3, 20)
Expand Down Expand Up @@ -1529,6 +1523,23 @@ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which)
return true;
}
});
LinearLayout multireddits_area = header.findViewById(R.id.expand_multireddits);

findViewById(R.id.godown_multireddits).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (multireddits_area.getVisibility() == View.GONE) {
expand(multireddits_area);
flipAnimator(false, header.findViewById(R.id.godown_multireddits)).start();
header.findViewById(R.id.godown_multireddits).setContentDescription(getResources().getString(R.string.btn_collapse));
} else {
collapse(multireddits_area);
flipAnimator(true, header.findViewById(R.id.godown_multireddits)).start();
header.findViewById(R.id.godown_multireddits).setContentDescription(getResources().getString(R.string.btn_expand));
}

}
});

header.findViewById(R.id.discover).setOnClickListener(new OnSingleClickListener() {
@Override
Expand Down Expand Up @@ -1820,6 +1831,7 @@ public void onSingleClick(View view) {

} else if (Authentication.didOnline) {
header = inflater.inflate(R.layout.drawer_loggedout, drawerSubList, false);
LinearLayout multiReddits = header.findViewById(R.id.multi);
drawerSubList.addHeaderView(header, null, false);
headerMain = header;
hea = header.findViewById(R.id.back);
Expand Down Expand Up @@ -1973,7 +1985,7 @@ public void onSingleClick(View view) {
});
headerMain = header;

header.findViewById(R.id.multi).setOnClickListener(new View.OnClickListener() {
multiReddits.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new MaterialDialog.Builder(MainActivity.this).inputRange(3, 20)
Expand Down Expand Up @@ -4832,6 +4844,35 @@ protected Subreddit doInBackground(String... params) {
}
}

public class SyncMultiReddits extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
UserSubscriptions.syncMultiReddits(MainActivity.this);
return null;
}

@Override
protected void onPostExecute(Void aVoid) {
LinearLayout multiredditsArea = headerMain.findViewById(R.id.expand_multireddits);

for (MultiReddit multiReddit : UserSubscriptions.multireddits) {
final View t =
getLayoutInflater().inflate(R.layout.multireddit_textview_white, multiredditsArea,
false);
((TextView) t.findViewById(R.id.name)).setText(multiReddit.getDisplayName());

t.setOnClickListener(v -> {
Intent intent = new Intent(MainActivity.this, MultiredditOverview.class);

intent.putExtra(MultiredditOverview.EXTRA_MULTI, multiReddit.getFullName());
startActivity(intent);
});

multiredditsArea.addView(t);
}
}
}

public class AsyncNotificationBadge extends AsyncTask<Void, Void, Void> {
int count;

Expand Down
43 changes: 38 additions & 5 deletions app/src/main/res/layout/drawer_loggedin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -407,32 +407,65 @@
</LinearLayout>
</RelativeLayout>

<LinearLayout
android:id="@+id/multi"
<RelativeLayout
android:id="@+id/multi"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal"
android:paddingStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?android:selectableItemBackground"
android:orientation="horizontal"
android:paddingStart="0dp">

<ImageView
<ImageView
android:layout_width="26dp"
android:layout_height="match_parent"
android:layout_marginEnd="26dp"
android:layout_marginStart="16dp"
android:tint="?attr/tintColor"
app:srcCompat="@drawable/collection"/>

<TextView
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="@string/title_multireddits"
android:textColor="?attr/fontColor"
android:textSize="14sp"
android:textStyle="bold"/>
</LinearLayout>



</LinearLayout>
<ImageView
android:id="@+id/godown_multireddits"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_marginEnd="2dp"
android:gravity="center"
android:padding="14dp"
android:textSize="14sp"
android:textStyle="bold"
android:theme="@style/Ripple.List"
android:tint="?attr/tintColor"
android:contentDescription="@string/btn_expand"
app:srcCompat="@drawable/down" />
</RelativeLayout>
<LinearLayout
android:id="@+id/expand_multireddits"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/activity_background"
android:orientation="vertical"
android:visibility="gone">
</LinearLayout>
<LinearLayout
android:id="@+id/support"
android:layout_width="match_parent"
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/res/layout/multireddit_textview_white.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="48dp"
android:paddingStart="18dp"
android:paddingEnd="18dp">

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:text="multireddit"
android:textColor="#fff"
android:textSize="14sp" />
</RelativeLayout>
philippTheCat marked this conversation as resolved.
Show resolved Hide resolved