Skip to content

Commit

Permalink
add "archived" switch to topic info
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Sep 12, 2019
1 parent 719c2d7 commit a25d072
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/co/tinode/tindroid/TopicInfoFragment.java
Expand Up @@ -127,6 +127,20 @@ public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked)
}
});

final Switch archived = view.findViewById(R.id.switchArchived);
archived.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked) {
try {
mTopic.updateArchived(isChecked);
} catch (NotConnectedException ignored) {
archived.setChecked(!isChecked);
Toast.makeText(activity, R.string.no_connection, Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
archived.setChecked(!isChecked);
}
}
});

view.findViewById(R.id.permissions).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -662,6 +676,8 @@ private void notifyContentChanged() {
}

((Switch) activity.findViewById(R.id.switchMuted)).setChecked(mTopic.isMuted());
((Switch) activity.findViewById(R.id.switchArchived)).setChecked(mTopic.isArchived());

Acs acs = mTopic.getAccessMode();
((TextView) activity.findViewById(R.id.permissions)).setText(acs == null ? "" : acs.getMode());

Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/layout/fragment_topic_info.xml
Expand Up @@ -120,6 +120,26 @@

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
style="@style/textPrimary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:text="@string/topic_archived"/>

<Switch
android:id="@+id/switchArchived"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"/>

</LinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
Expand Down

0 comments on commit a25d072

Please sign in to comment.