Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

Commit

Permalink
fixed position, bubbles, crash; removed unused resources
Browse files Browse the repository at this point in the history
  • Loading branch information
gerc99 committed Jun 8, 2014
1 parent e14ddcc commit 7b42492
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 1,732 deletions.
1,627 changes: 0 additions & 1,627 deletions assets/cities.txt

This file was deleted.

Binary file removed assets/clients.bin
Binary file not shown.
Binary file removed assets/clients.png
Binary file not shown.
Binary file removed assets/facebook-status.png
Binary file not shown.
Binary file removed assets/gtalk-status.png
Binary file not shown.
Binary file removed assets/happy.png
Binary file not shown.
Binary file removed assets/icq-status.png
Binary file not shown.
Binary file removed assets/icq-xstatus.png
Binary file not shown.
Binary file removed assets/livejournal-status.png
Binary file not shown.
Binary file removed assets/mrim-clients.png
Binary file not shown.
33 changes: 0 additions & 33 deletions assets/mrim-clients.txt

This file was deleted.

Binary file removed assets/mrim-status.png
Binary file not shown.
Binary file removed assets/mrim-xstatus.png
Binary file not shown.
Binary file removed assets/ok-status.png
Binary file not shown.
Binary file removed assets/privatestatuses.png
Binary file not shown.
Binary file removed assets/qip-status.png
Binary file not shown.
Binary file removed assets/ya-status.png
Binary file not shown.
34 changes: 33 additions & 1 deletion src/ru/sawim/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class Options {
public static final String OPTION_HISTORY = "history";
public static final String OPTION_BRING_UP = "bring_up";
public static final String OPTION_ANTISPAM_ENABLE = "antispam_enable";
public static final String OPTION_HIDE_ICONS_CLIENTS = "hide_icons_clients";
public static final String OPTION_SORT_UP_WITH_MSG = "sort_up_with_msg";
public static final String OPTION_ALARM = "alarm";
public static final String OPTION_SHOW_STATUS_LINE = "show_status_line";
Expand All @@ -52,12 +51,45 @@ public class Options {
public static void init() {
preferences = PreferenceManager.getDefaultSharedPreferences(SawimApplication.getContext());
editor = preferences.edit();
if (preferences.getAll().isEmpty()) {
setDefaults();
}
}

public static void safeSave() {
editor.commit();
}

private static void setDefaults() {
setString(Options.UNAVAILABLE_NESSAGE, "I'll be back");
setInt(Options.OPTION_CURRENT_PAGE, 0);
setInt(Options.OPTION_CL_SORT_BY, 0);
setBoolean(Options.OPTION_SORT_UP_WITH_MSG, true);
setBoolean(Options.OPTION_CL_HIDE_OFFLINE, false);
setBoolean(Options.OPTION_HIDE_ICONS_CLIENTS, true);
setBoolean(Options.OPTION_HIDE_KEYBOARD, true);
setBoolean(Options.OPTION_MESS_NOTIF, true);
setString(Options.OPTION_MESS_RINGTONE, "content://settings/system/notification_sound");
setInt(Options.OPTION_TYPING_MODE, 0);
setBoolean(Options.OPTION_BLOG_NOTIFY, true);
setBoolean(Options.OPTION_NOTIFY_IN_AWAY, true);
setString(Options.OPTION_MAX_MSG_COUNT, "100");
setString(Options.OPTION_ANTISPAM_KEYWORDS, "http sms www @conf");
setBoolean(Options.OPTION_ANSWERER, false);
setBoolean(Options.OPTION_USER_GROUPS, true);
setBoolean(Options.OPTION_HISTORY, false);
setInt(Options.OPTION_COLOR_SCHEME, 1);
setInt(Options.OPTION_FONT_SCHEME, 16);
setInt(Options.OPTION_AA_TIME, 15);
setBoolean(Options.OPTION_SHOW_STATUS_LINE, false);
setInt(Options.OPTION_VISIBILITY_ID, 0);

setBoolean(Options.OPTION_BRING_UP, false);
setBoolean(OPTION_ALARM, true);

safeSave();
}

public static String getString(String key) {
return preferences.getString(key, "");
}
Expand Down
61 changes: 0 additions & 61 deletions src/ru/sawim/SawimNotification.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package ru.sawim;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import ru.sawim.activities.SawimActivity;
import ru.sawim.chat.ChatHistory;
import ru.sawim.comm.JLocale;
import ru.sawim.roster.RosterHelper;

import java.util.HashMap;

Expand All @@ -28,61 +25,6 @@ public class SawimNotification {
public static final int NOTIFY_ID = 1;
private static final HashMap<String, Integer> idsMap = new HashMap<String, Integer>();

public static Notification get(Context context, boolean silent) {
int unread = ChatHistory.instance.getPersonalUnreadMessageCount(false);
int allUnread = ChatHistory.instance.getPersonalUnreadMessageCount(true);
CharSequence stateMsg = "";

final int icon;
if (0 < allUnread) {
icon = R.drawable.ic_tray_msg;
} else if (RosterHelper.getInstance().isConnected()) {
icon = R.drawable.ic_tray_on;
stateMsg = context.getText(R.string.online);
} else {
icon = R.drawable.ic_tray_off;
if (RosterHelper.getInstance().isConnecting()) {
stateMsg = context.getText(R.string.connecting);
} else {
stateMsg = context.getText(R.string.offline);
}
}

long when = 0;
NotificationCompat.Builder notification = new NotificationCompat.Builder(context);
Intent notificationIntent = new Intent(context, SawimActivity.class);
notificationIntent.setAction(SawimActivity.NOTIFY);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
if (0 < unread) {
notification.setLights(0xff00ff00, 300, 1000);
if (Options.getBoolean(Options.OPTION_MESS_NOTIF) && silent) {
if (Options.getBoolean(Options.OPTION_VIBRATION)) {
int dat = 70;
long[] pattern = {0,3 * dat, dat, dat};
notification.setVibrate(pattern);
}
String ringtone = Options.getString(Options.OPTION_MESS_RINGTONE);
if (ringtone != null) {
notification.setSound(Uri.parse(ringtone));
}
}
}
if (0 < allUnread) {
notification.setNumber(unread);
stateMsg = String.format((String) context.getText(R.string.unread_messages), unread);
}
stateMsg = ChatHistory.instance.getLastMessage(stateMsg.toString());
notification.setAutoCancel(true);
notification.setWhen(when);
//notification.setDefaults(android.app.Notification.DEFAULT_ALL);
notification.setContentIntent(contentIntent);
notification.setContentTitle(context.getString(R.string.app_name));
notification.setContentText(stateMsg);
notification.setSmallIcon(icon);
return notification.build();
}

public static void alarm(String processedText) {
}

Expand Down Expand Up @@ -167,9 +109,6 @@ public static void sendNotify(Context context, final String title, final String
notification.setVibrate(pattern);
}
String ringtone = Options.getString(Options.OPTION_MESS_RINGTONE);
if (ringtone == null) {
ringtone = "content://settings/system/notification_sound";
}
notification.setSound(Uri.parse(ringtone));
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/ru/sawim/Scheme.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ru.sawim;

import android.util.Log;
import ru.sawim.comm.Config;
import ru.sawim.comm.Util;

Expand Down Expand Up @@ -63,6 +62,7 @@ private Scheme() {
private static int[][] themeColors;
private static String[] themeNames;
private static int oldTheme;
private static boolean isChangeTheme;

public static void load() {
setColorScheme(baseTheme);
Expand Down Expand Up @@ -150,14 +150,19 @@ public static int getThemeId(String theme) {
return 0;
}

public static boolean isChangeTheme(int newTheme) {
public static boolean setChangeTheme(int newTheme) {
if (oldTheme != newTheme) {
oldTheme = newTheme;
isChangeTheme = true;
return true;
}
return false;
}

public static boolean isChangeTheme() {
return isChangeTheme;
}

public static int getColor(byte color) {
return 0xff000000 | getScheme()[color];
}
Expand Down
2 changes: 1 addition & 1 deletion src/ru/sawim/modules/history/HistoryStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public int getHistorySize() {
return num;
}

public int getStartHistorySize() {
public int getFirstMessageCount() {
return startHistorySize;
}

Expand Down
16 changes: 10 additions & 6 deletions src/ru/sawim/view/ChatView.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,24 +507,28 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}

private void setPosition(int unreadMessageCount) {
boolean hasHistory = chat.getHistory() != null && chat.getHistory().getStartHistorySize() > 0 && !chat.isBlogBot();
int position = chat.getMessData().size() - unreadMessageCount;
int historySize = chat.getHistory() == null ? 0 : chat.getHistory().getFirstMessageCount();
boolean hasHistory = historySize > 0 && !chat.isBlogBot();
boolean isBottomScroll = chat.lastVisiblePosition == chat.dividerPosition;
adapter.setPosition(chat.dividerPosition);
if (chat.dividerPosition == -1) {
/*if (contact.isConference() || !(contact.isConference() && hasHistory)) {
int position = historySize - unreadMessageCount + 1;
if (contact.isConference() || !(contact.isConference() && hasHistory)) {
chatListView.setSelection(0);
} else */if (hasHistory) {
} else if (hasHistory) {
adapter.setPosition(position);
chatListView.setSelection(position);
}
} else {
int position = chat.getMessData().size() - unreadMessageCount;
if (isBottomScroll && unreadMessageCount == 0) {
chatListView.setSelectionFromTop(chat.firstVisiblePosition, -chat.offset);
} else if (unreadMessageCount == 0) {
} else if (unreadMessageCount == 0 || !isBottomScroll) {
chatListView.setSelectionFromTop(chat.firstVisiblePosition + 1, chat.offset);
} else {
chatListView.setSelectionFromTop(position, offsetNewMessage);
if (isBottomScroll) {
chatListView.setSelectionFromTop(position, offsetNewMessage);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ru/sawim/view/RosterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public void onPause() {
public void onResume() {
super.onResume();
resume();
if (!SawimApplication.isManyPane() && Scheme.isChangeTheme(Scheme.getThemeId(Options.getString(Options.OPTION_COLOR_SCHEME)))) {
if (!SawimApplication.isManyPane() && Scheme.setChangeTheme(Scheme.getThemeId(Options.getString(Options.OPTION_COLOR_SCHEME)))) {
((SawimActivity) getActivity()).recreateActivity();
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/ru/sawim/widget/chat/MessageItemView.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public class MessageItemView extends View {

public MessageItemView(Context context) {
super(context);
if (Scheme.isChangeTheme()) {
backgroundDrawableIn = null;
backgroundDrawableOut = null;
}
if (backgroundDrawableIn == null) {
backgroundDrawableIn = context.getResources().getDrawable(Scheme.isBlack() ? R.drawable.msg_in_dark : R.drawable.msg_in);
backgroundDrawableOut = context.getResources().getDrawable(Scheme.isBlack() ? R.drawable.msg_out_dark : R.drawable.msg_out);
Expand Down

0 comments on commit 7b42492

Please sign in to comment.