Permalink
Browse files

Disable groups option in the settings. All contacts will be shown in …

…a single group.
  • Loading branch information...
caspermeijn authored and ge0rg committed Mar 21, 2014
1 parent e0aae23 commit 2be323d81aa7254d5df0a0f25a7802378b22a7c5
View
@@ -54,7 +54,7 @@
android:title="@string/showOffline_title"
android:summary="@string/showOffline_summ"
android:defaultValue="true"
/>
/>
<CheckBoxPreference
android:id="@+id/foregroundService"
android:key="foregroundService"
@@ -80,6 +80,13 @@
android:dialogTitle="@string/FontChat_dialog"
android:defaultValue="18"
/>
<CheckBoxPreference
android:id="@+id/enableGroups"
android:key="enableGroups"
android:title="@string/enableGroups_title"
android:summary="@string/enableGroups_summ"
android:defaultValue="true"
/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/preftitle_debug">
<CheckBoxPreference
View
@@ -59,6 +59,8 @@
<string name="statuspopup_name">Set your status</string>
<string name="showOffline_summ">Always show all contacts in the roster</string>
<string name="showOffline_title">Show offline contacts</string>
<string name="enableGroups_summ">Arrange your contacts by their groups</string>
<string name="enableGroups_title">Show contact groups</string>
<string name="foregroundService_summ">Keep yaxim in memory to ensure always-on connection (foreground service)</string>
<string name="foregroundService_title">Statusbar icon</string>
@@ -270,6 +272,7 @@
<!-- default roster group with no name -->
<string name="default_group">General</string>
<string name="all_contacts_group">All contacts</string>
<!-- SEND listener popup -->
<string name="chooseContact">Choose contact</string>
@@ -955,6 +955,18 @@ private void registerCrashReporter() {
RosterConstants.GROUP,
"(" + countAvailableMembers + ") || '/' || (" + countMembers + ") AS members"
};
final String countAvailableMembersTotals =
"SELECT COUNT() FROM " + RosterProvider.TABLE_ROSTER + " inner_query" +
" WHERE inner_query." + OFFLINE_EXCLUSION;
final String countMembersTotals =
"SELECT COUNT() FROM " + RosterProvider.TABLE_ROSTER;
final String[] GROUPS_QUERY_CONTACTS_DISABLED = new String[] {
RosterConstants._ID,
"'' AS " + RosterConstants.GROUP,
"(" + countAvailableMembersTotals + ") || '/' || (" + countMembersTotals + ") AS members"
};
private static final String[] GROUPS_FROM = new String[] {
RosterConstants.GROUP,
"members"
@@ -1027,8 +1039,13 @@ public void requery() {
String selectWhere = null;
if (!mConfig.showOffline)
selectWhere = OFFLINE_EXCLUSION;
String[] query = GROUPS_QUERY_COUNTED;
if(!mConfig.enableGroups) {
query = GROUPS_QUERY_CONTACTS_DISABLED;
}
Cursor cursor = getContentResolver().query(RosterProvider.GROUPS_URI,
GROUPS_QUERY_COUNTED, selectWhere, null, RosterConstants.GROUP);
query, selectWhere, null, RosterConstants.GROUP);
Cursor oldCursor = getCursor();
changeCursor(cursor);
stopManagingCursor(oldCursor);
@@ -1037,22 +1054,28 @@ public void requery() {
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
// Given the group, we return a cursor for all the children within that group
String selectWhere;
int idx = groupCursor.getColumnIndex(RosterConstants.GROUP);
String groupname = groupCursor.getString(idx);
String selectWhere = RosterConstants.GROUP + " = ?";
if (!mConfig.showOffline)
selectWhere += " AND " + OFFLINE_EXCLUSION;
String[] args = null;
if(!mConfig.enableGroups) {
selectWhere = mConfig.showOffline ? "" : OFFLINE_EXCLUSION;
} else {
selectWhere = mConfig.showOffline ? "" : OFFLINE_EXCLUSION + " AND ";
selectWhere += RosterConstants.GROUP + " = ?";
args = new String[] { groupname };
}
return getContentResolver().query(RosterProvider.CONTENT_URI, ROSTER_QUERY,
selectWhere, new String[] { groupname }, null);
selectWhere, args, null);
}
@Override
protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) {
super.bindGroupView(view, context, cursor, isExpanded);
if (cursor.getString(cursor.getColumnIndexOrThrow(RosterConstants.GROUP)).length() == 0) {
TextView groupname = (TextView)view.findViewById(R.id.groupname);
groupname.setText(R.string.default_group);
groupname.setText(mConfig.enableGroups ? R.string.default_group : R.string.all_contacts_group);
}
}
@@ -63,6 +63,7 @@
public String theme;
public String chatFontSize;
public boolean showOffline;
public boolean enableGroups;
public boolean reconnect_required = false;
public boolean presence_required = false;
@@ -154,6 +155,7 @@ private void loadPrefs(SharedPreferences prefs) {
this.theme = prefs.getString(PreferenceConstants.THEME, "dark");
this.chatFontSize = prefs.getString("setSizeChat", "18");
this.showOffline = prefs.getBoolean(PreferenceConstants.SHOW_OFFLINE, false);
this.enableGroups = prefs.getBoolean(PreferenceConstants.ENABLE_GROUPS, true);
try {
splitAndSetJabberID(XMPPHelper.verifyJabberID(jabberID));
@@ -12,6 +12,7 @@
public final static String CONN_STARTUP = "connstartup";
public final static String MESSAGE_CARBONS = "carbons";
public final static String SHOW_OFFLINE = "showOffline";
public final static String ENABLE_GROUPS = "enableGroups";
public final static String LEDNOTIFY = "led";
public final static String VIBRATIONNOTIFY = "vibration_list";
public final static String RINGTONENOTIFY= "ringtone";

0 comments on commit 2be323d

Please sign in to comment.