Permalink
Browse files

status dialog: remember old status messages

  • Loading branch information...
ge0rg committed Apr 28, 2014
1 parent 6fd8f03 commit 011f6c66de294d154738fb41b82046e638f1ca12
@@ -21,7 +21,7 @@
android:prompt="@string/setStatusTitle"
android:layout_marginBottom="15dp"
/>
<EditText android:id="@+id/statusview_message"
<AutoCompleteTextView android:id="@+id/statusview_message"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="@string/setStatusmsgHint"
@@ -577,16 +577,19 @@ public StatusMode getStatusMode() {
return StatusMode.fromString(mConfig.statusMode);
}
public String getStatusMessage() {
return mConfig.statusMessage;
}
public void setAndSaveStatus(StatusMode statusMode, String message) {
SharedPreferences.Editor prefedit = PreferenceManager
.getDefaultSharedPreferences(this).edit();
// do not save "offline" to prefs, or else!
if (statusMode != StatusMode.offline)
prefedit.putString(PreferenceConstants.STATUS_MODE, statusMode.name());
if (!message.equals(mConfig.statusMessage)) {
List<String> smh = new ArrayList<String>(java.util.Arrays.asList(mConfig.statusMessageHistory));
if (!smh.contains(message))
smh.add(message);
String smh_joined = android.text.TextUtils.join("\036", smh);
prefedit.putString(PreferenceConstants.STATUS_MESSAGE_HISTORY, smh_joined);
}
prefedit.putString(PreferenceConstants.STATUS_MESSAGE, message);
prefedit.commit();
@@ -673,7 +676,8 @@ private boolean applyMainMenuChoice(com.actionbarsherlock.view.MenuItem item) {
case android.R.id.home:
case R.id.menu_status:
new ChangeStatusDialog(this).show();
new ChangeStatusDialog(this, StatusMode.fromString(mConfig.statusMode),
mConfig.statusMessage, mConfig.statusMessageHistory).show();
return true;
case R.id.menu_exit:
@@ -53,6 +53,7 @@
public String statusMode;
public String statusMessage;
public String[] statusMessageHistory;
public boolean isLEDNotify;
public String vibraNotify;
@@ -152,9 +153,10 @@ private void loadPrefs(SharedPreferences prefs) {
false);
this.statusMode = prefs.getString(PreferenceConstants.STATUS_MODE, "available");
this.statusMessage = prefs.getString(PreferenceConstants.STATUS_MESSAGE, "");
this.theme = prefs.getString(PreferenceConstants.THEME, "dark");
this.chatFontSize = prefs.getString("setSizeChat", "18");
this.showOffline = prefs.getBoolean(PreferenceConstants.SHOW_OFFLINE, false);
this.statusMessageHistory = prefs.getString(PreferenceConstants.STATUS_MESSAGE_HISTORY, statusMessage).split("\036");
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 {
@@ -20,16 +20,18 @@
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.AutoCompleteTextView;
public class ChangeStatusDialog extends AlertDialog {
private final Spinner mStatus;
private final EditText mMessage;
private final AutoCompleteTextView mMessage;
private final MainWindow mContext;
public ChangeStatusDialog(final MainWindow context) {
public ChangeStatusDialog(final MainWindow context, final StatusMode status_mode,
final String status_message, final String[] status_message_history) {
super(context);
mContext = context;
@@ -57,13 +59,16 @@ public int compare(StatusMode object1, StatusMode object2) {
mStatus.setAdapter(mStatusAdapter);
for (int i = 0; i < modes.size(); i++) {
if (modes.get(i).equals(context.getStatusMode())) {
if (modes.get(i).equals(status_mode)) {
mStatus.setSelection(i);
}
}
mMessage = (EditText) group.findViewById(R.id.statusview_message);
mMessage.setText(context.getStatusMessage());
mMessage = (AutoCompleteTextView) group.findViewById(R.id.statusview_message);
mMessage.setText(status_message);
mMessage.setAdapter(new ArrayAdapter<String>(context,
android.R.layout.simple_dropdown_item_1line, status_message_history));
mMessage.setThreshold(1);
setTitle(R.string.statuspopup_name);
setView(group);
@@ -23,5 +23,6 @@
public final static String REQUIRE_SSL = "require_ssl";
public final static String STATUS_MODE = "status_mode";
public final static String STATUS_MESSAGE = "status_message";
public static final String STATUS_MESSAGE_HISTORY = "status_message_history";
public final static String THEME = "theme";
}

0 comments on commit 011f6c6

Please sign in to comment.