Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 635536f

Browse files
committed
Added a DialogFragment for the list of Realms
1 parent 9f2ed02 commit 635536f

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.zulip.android;
2+
import android.app.AlertDialog;
3+
import android.app.Dialog;
4+
import android.app.ProgressDialog;
5+
import android.content.Context;
6+
import android.content.DialogInterface;
7+
import android.content.Intent;
8+
import android.os.Bundle;
9+
import android.support.annotation.NonNull;
10+
import android.support.v4.app.DialogFragment;
11+
import android.util.Log;
12+
import android.view.LayoutInflater;
13+
import android.view.View;
14+
import android.widget.AdapterView;
15+
import android.widget.ArrayAdapter;
16+
import android.widget.ListView;
17+
import android.widget.Toast;
18+
import java.util.ArrayList;
19+
import java.util.Collections;
20+
import java.util.HashSet;
21+
import java.util.List;
22+
public class RealmDialog extends DialogFragment {
23+
ZulipApp app;
24+
ListView listView;
25+
ArrayAdapter<String> realmsAdapter;
26+
Context context;
27+
public static RealmDialog newInstance() {
28+
RealmDialog d = new RealmDialog();
29+
return d;
30+
}
31+
public RealmDialog() {
32+
}
33+
List<String> realmsList;
34+
@NonNull
35+
@Override
36+
public Dialog onCreateDialog(Bundle savedInstanceState) {
37+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
38+
LayoutInflater inflater = getActivity().getLayoutInflater();
39+
builder.setTitle(R.string.realm_title);
40+
View rootView = inflater.inflate(R.layout.realm_dialog_list, null);
41+
realmsList = new ArrayList<>();
42+
context = getActivity();
43+
app = ZulipApp.get();
44+
listView = (ListView) rootView.findViewById(R.id.realmListView);
45+
realmsList = new ArrayList<String>(app.serverStringSet);
46+
realmsAdapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, realmsList);
47+
listView.setAdapter(realmsAdapter);
48+
return builder.create();
49+
}
50+
}

app/src/main/java/com/zulip/android/ZulipActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ public void onClick(
527527
}
528528
openCompose(MessageType.PRIVATE_MESSAGE, null, null, recipient);
529529
break;
530+
case R.id.menu_realm:
531+
FragmentManager fm = getSupportFragmentManager();
532+
RealmDialog dialogFragment = RealmDialog.newInstance();
533+
dialogFragment.show(fm, "fragment_realm");
534+
break;
530535
case R.id.refresh:
531536
Log.w("menu", "Refreshed manually by user. We shouldn't need this.");
532537
onRefresh();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:id="@+id/realmListView"
6+
android:layout_height="match_parent"
7+
android:padding="16dp"
8+
tools:context=".RealmDialog">
9+
</ListView>

0 commit comments

Comments
 (0)