aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-03-17 22:53:46 +0100
committerChristian Schneppe <christian@pix-art.de>2018-03-17 22:53:46 +0100
commit89552e226a883d2ea3c63b6aed994ea0c3021a93 (patch)
tree5507b65b86a4c1300e4ab8d428ee7a5add7da384 /src
parent168f36a319861f446daaccb274e868c6d5d61a69 (diff)
ported presence activity to cardview
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/SetPresenceActivity.java80
-rw-r--r--src/main/res/layout/activity_change_password.xml78
-rw-r--r--src/main/res/layout/activity_set_presence.xml131
3 files changed, 138 insertions, 151 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/SetPresenceActivity.java b/src/main/java/de/pixart/messenger/ui/SetPresenceActivity.java
index 18d28914e..d4bddb534 100644
--- a/src/main/java/de/pixart/messenger/ui/SetPresenceActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/SetPresenceActivity.java
@@ -1,6 +1,7 @@
package de.pixart.messenger.ui;
import android.content.Intent;
+import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.os.Handler;
import android.util.Pair;
@@ -9,18 +10,13 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.ScrollView;
-import android.widget.Spinner;
import android.widget.TextView;
import java.util.List;
import de.pixart.messenger.R;
+import de.pixart.messenger.databinding.ActivitySetPresenceBinding;
import de.pixart.messenger.entities.Account;
import de.pixart.messenger.entities.ListItem;
import de.pixart.messenger.entities.Presence;
@@ -33,12 +29,8 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
protected Account mAccount;
private List<PresenceTemplate> mTemplates;
- //UI Elements
- protected ScrollView mScrollView;
- protected EditText mStatusMessage;
- protected Spinner mShowSpinner;
- protected CheckBox mAllAccounts;
- protected LinearLayout mTemplatesView;
+ private ActivitySetPresenceBinding binding;
+
private Pair<Integer, Intent> mPostponedActivityResult;
private Runnable onPresenceChanged = new Runnable() {
@@ -50,24 +42,13 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_set_presence);
- mScrollView = findViewById(R.id.scroll_view);
- mShowSpinner = findViewById(R.id.presence_show);
+ this.binding = DataBindingUtil.setContentView(this, R.layout.activity_set_presence);
ArrayAdapter adapter = ArrayAdapter.createFromResource(this,
R.array.presence_show_options,
R.layout.simple_list_item);
- mShowSpinner.setAdapter(adapter);
- mShowSpinner.setSelection(1);
- mStatusMessage = findViewById(R.id.presence_status_message);
- mAllAccounts = findViewById(R.id.all_accounts);
- mTemplatesView = findViewById(R.id.templates);
- final Button changePresence = findViewById(R.id.change_presence);
- changePresence.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- executeChangePresence();
- }
- });
+ this.binding.presenceShow.setAdapter(adapter);
+ this.binding.presenceShow.setSelection(1);
+ this.binding.changePresence.setOnClickListener(v -> executeChangePresence());
}
@Override
@@ -105,8 +86,8 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
private void executeChangePresence() {
Presence.Status status = getStatusFromSpinner();
- boolean allAccounts = mAllAccounts.isChecked();
- String statusMessage = mStatusMessage.getText().toString().trim();
+ boolean allAccounts = this.binding.allAccounts.isChecked();
+ String statusMessage = this.binding.presenceStatusMessage.getText().toString().trim();
if (allAccounts && noAccountUsesPgp()) {
xmppConnectionService.changeStatus(status, statusMessage);
finish();
@@ -122,7 +103,7 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
}
private Presence.Status getStatusFromSpinner() {
- switch (mShowSpinner.getSelectedItemPosition()) {
+ switch (this.binding.presenceShow.getSelectedItemPosition()) {
case 0:
return Presence.Status.CHAT;
case 2:
@@ -139,19 +120,19 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
private void setStatusInSpinner(Presence.Status status) {
switch (status) {
case AWAY:
- mShowSpinner.setSelection(2);
+ this.binding.presenceShow.setSelection(2);
break;
case XA:
- mShowSpinner.setSelection(3);
+ this.binding.presenceShow.setSelection(3);
break;
case CHAT:
- mShowSpinner.setSelection(0);
+ this.binding.presenceShow.setSelection(0);
break;
case DND:
- mShowSpinner.setSelection(4);
+ this.binding.presenceShow.setSelection(4);
break;
default:
- mShowSpinner.setSelection(1);
+ this.binding.presenceShow.setSelection(1);
break;
}
}
@@ -167,29 +148,29 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
if (mAccount != null) {
setStatusInSpinner(mAccount.getPresenceStatus());
String message = mAccount.getPresenceStatusMessage();
- if (mStatusMessage.getText().length() == 0 && message != null) {
- mStatusMessage.append(message);
+ if (this.binding.presenceStatusMessage.getText().length() == 0 && message != null) {
+ this.binding.presenceStatusMessage.append(message);
}
mTemplates = xmppConnectionService.getPresenceTemplates(mAccount);
if (this.mPostponedActivityResult != null) {
this.onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second);
}
boolean e = noAccountUsesPgp();
- mAllAccounts.setEnabled(e);
- mAllAccounts.setTextColor(e ? getPrimaryTextColor() : getSecondaryTextColor());
+ this.binding.allAccounts.setEnabled(e);
+ this.binding.allAccounts.setTextColor(e ? getPrimaryTextColor() : getSecondaryTextColor());
}
redrawTemplates();
}
private void redrawTemplates() {
if (mTemplates == null || mTemplates.size() == 0) {
- mTemplatesView.setVisibility(View.GONE);
+ this.binding.templates.setVisibility(View.GONE);
} else {
- mTemplatesView.removeAllViews();
- mTemplatesView.setVisibility(View.VISIBLE);
+ this.binding.templates.removeAllViews();
+ this.binding.templates.setVisibility(View.VISIBLE);
LayoutInflater inflater = getLayoutInflater();
for (PresenceTemplate template : mTemplates) {
- View templateLayout = inflater.inflate(R.layout.presence_template, mTemplatesView, false);
+ View templateLayout = inflater.inflate(R.layout.presence_template, this.binding.templates, false);
templateLayout.setTag(template);
setListItemBackgroundOnView(templateLayout);
templateLayout.setOnClickListener(this);
@@ -202,7 +183,7 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
status.setText(tag.getName());
status.setBackgroundColor(tag.getColor());
message.setText(template.getStatusMessage());
- mTemplatesView.addView(templateLayout);
+ this.binding.templates.addView(templateLayout);
}
}
}
@@ -215,14 +196,9 @@ public class SetPresenceActivity extends XmppActivity implements View.OnClickLis
}
if (v.getId() == R.id.presence_template) {
setStatusInSpinner(template.getStatus());
- mStatusMessage.getEditableText().clear();
- mStatusMessage.getEditableText().append(template.getStatusMessage());
- new Handler().post(new Runnable() {
- @Override
- public void run() {
- mScrollView.smoothScrollTo(0, 0);
- }
- });
+ this.binding.presenceStatusMessage.getEditableText().clear();
+ this.binding.presenceStatusMessage.getEditableText().append(template.getStatusMessage());
+ new Handler().post(() -> this.binding.scrollView.smoothScrollTo(0,0));
} else if (v.getId() == R.id.delete_button) {
xmppConnectionService.databaseBackend.deletePresenceTemplate(template);
mTemplates.remove(template);
diff --git a/src/main/res/layout/activity_change_password.xml b/src/main/res/layout/activity_change_password.xml
index de1ad216d..ab2535281 100644
--- a/src/main/res/layout/activity_change_password.xml
+++ b/src/main/res/layout/activity_change_password.xml
@@ -3,65 +3,67 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/grey200">
+ android:background="?attr/color_background_secondary">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/button_bar">
- <LinearLayout
+ <android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
- android:layout_marginTop="@dimen/activity_vertical_margin"
- android:background="@drawable/infocard_border"
- android:orientation="vertical"
- android:padding="@dimen/infocard_padding">
+ android:layout_marginTop="@dimen/activity_vertical_margin">
- <android.support.design.widget.TextInputLayout
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
- app:passwordToggleEnabled="true"
- app:passwordToggleTint="?attr/color_text_secondary">
+ android:orientation="vertical"
+ android:padding="@dimen/infocard_padding">
- <android.support.design.widget.TextInputEditText
- android:id="@+id/current_password"
+ <android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_marginBottom="8dp"
- android:hint="@string/current_password"
- android:inputType="textPassword"
- android:textColor="?attr/color_text_primary"
- android:textColorHint="?attr/color_text_secondary"
- android:textSize="?attr/TextSizeBody" />
- </android.support.design.widget.TextInputLayout>
+ app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
+ app:passwordToggleEnabled="true"
+ app:passwordToggleTint="?attr/color_text_secondary">
- <android.support.design.widget.TextInputLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
- app:passwordToggleEnabled="true"
- app:passwordToggleTint="?attr/color_text_secondary">
+ <android.support.design.widget.TextInputEditText
+ android:id="@+id/current_password"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:hint="@string/current_password"
+ android:inputType="textPassword"
+ android:textColor="?attr/color_text_primary"
+ android:textColorHint="?attr/color_text_secondary"
+ android:textSize="?attr/TextSizeBody" />
+ </android.support.design.widget.TextInputLayout>
- <android.support.design.widget.TextInputEditText
- android:id="@+id/new_password"
+ <android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_marginBottom="8dp"
- android:hint="@string/new_password"
- android:inputType="textPassword"
- android:textColor="?attr/color_text_primary"
- android:textColorHint="?attr/color_text_secondary"
- android:textSize="?attr/TextSizeBody" />
- </android.support.design.widget.TextInputLayout>
- </LinearLayout>
+ app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
+ app:passwordToggleEnabled="true"
+ app:passwordToggleTint="?attr/color_text_secondary">
+
+ <android.support.design.widget.TextInputEditText
+ android:id="@+id/new_password"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:hint="@string/new_password"
+ android:inputType="textPassword"
+ android:textColor="?attr/color_text_primary"
+ android:textColorHint="?attr/color_text_secondary"
+ android:textSize="?attr/TextSizeBody" />
+ </android.support.design.widget.TextInputLayout>
+ </LinearLayout>
+ </android.support.v7.widget.CardView>
</ScrollView>
<LinearLayout
@@ -85,7 +87,7 @@
android:layout_height="fill_parent"
android:layout_marginBottom="7dp"
android:layout_marginTop="7dp"
- android:background="@color/black12" />
+ android:background="?attr/divider" />
<Button
android:id="@+id/right_button"
diff --git a/src/main/res/layout/activity_set_presence.xml b/src/main/res/layout/activity_set_presence.xml
index 5910431df..b3fc6f26e 100644
--- a/src/main/res/layout/activity_set_presence.xml
+++ b/src/main/res/layout/activity_set_presence.xml
@@ -1,76 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@color/grey200"
- android:id="@+id/scroll_view">
-
- <LinearLayout
+<layout xmlns:android="http://schemas.android.com/apk/res/android">
+ <ScrollView
+ android:id="@+id/scroll_view"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical">
+ android:layout_height="fill_parent"
+ android:background="?attr/color_background_secondary">
<LinearLayout
- android:layout_width="match_parent"
+ android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/activity_horizontal_margin"
- android:layout_marginRight="@dimen/activity_horizontal_margin"
- android:layout_marginTop="@dimen/activity_vertical_margin"
- android:layout_marginBottom="@dimen/activity_vertical_margin"
- android:background="@drawable/infocard_border"
- android:padding="@dimen/infocard_padding"
android:orientation="vertical">
- <android.support.text.emoji.widget.EmojiAppCompatEditText
+ <android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:inputType="textMultiLine"
- android:hint="@string/status_message"
- android:id="@+id/presence_status_message"
- android:textColor="@color/black87"
- android:layout_marginBottom="8dp"
- android:textSize="?attr/TextSizeBody" />
+ android:layout_marginBottom="@dimen/activity_vertical_margin"
+ android:layout_marginLeft="@dimen/activity_horizontal_margin"
+ android:layout_marginRight="@dimen/activity_horizontal_margin"
+ android:layout_marginTop="@dimen/activity_vertical_margin">
- <Spinner
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/presence_show"
- android:layout_gravity="center_horizontal" />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="@dimen/infocard_padding">
- <CheckBox
- android:layout_marginTop="16dp"
- android:layout_marginBottom="16dp"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/all_accounts_on_this_device"
- android:id="@+id/all_accounts"
- android:textColor="@color/black87"
- android:textSize="?attr/TextSizeBody"
- android:visibility="gone" />
+ <android.support.text.emoji.widget.EmojiAppCompatEditText
+ android:id="@+id/presence_status_message"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:hint="@string/status_message"
+ android:inputType="textMultiLine"
+ android:textColor="?attr/color_text_primary"
+ android:textSize="?attr/TextSizeBody"/>
+
+ <Spinner
+ android:id="@+id/presence_show"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"/>
+
+ <CheckBox
+ android:id="@+id/all_accounts"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:layout_marginTop="16dp"
+ android:text="@string/all_accounts_on_this_device"
+ android:textColor="?attr/color_text_primary"
+ android:textSize="?attr/TextSizeBody"/>
- <Button
- android:id="@+id/change_presence"
- style="?android:attr/borderlessButtonStyle"
- android:layout_width="wrap_content"
+ <Button
+ android:id="@+id/change_presence"
+ style="?android:attr/borderlessButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right"
+ android:layout_marginBottom="-8dp"
+ android:layout_marginRight="-8dp"
+ android:text="@string/change_presence"
+ android:textColor="@color/accent"/>
+ </LinearLayout>
+ </android.support.v7.widget.CardView>
+
+ <android.support.v7.widget.CardView
+ android:id="@+id/templates_card"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="right"
- android:text="@string/change_presence"
- android:textColor="@color/accent" />
- </LinearLayout>
+ android:layout_marginBottom="@dimen/activity_vertical_margin"
+ android:layout_marginLeft="@dimen/activity_horizontal_margin"
+ android:layout_marginRight="@dimen/activity_horizontal_margin"
+ android:layout_marginTop="@dimen/activity_vertical_margin">
- <LinearLayout
- android:id="@+id/templates"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/activity_horizontal_margin"
- android:layout_marginRight="@dimen/activity_horizontal_margin"
- android:layout_marginTop="@dimen/activity_vertical_margin"
- android:layout_marginBottom="@dimen/activity_vertical_margin"
- android:background="@drawable/infocard_border"
- android:padding="@dimen/infocard_padding"
- android:orientation="vertical"
- android:divider="?android:dividerHorizontal"
- android:showDividers="middle">
+ <LinearLayout
+ android:id="@+id/templates"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="@dimen/infocard_padding"/>
+ </android.support.v7.widget.CardView>
</LinearLayout>
- </LinearLayout>
-</ScrollView> \ No newline at end of file
+ </ScrollView>
+</layout> \ No newline at end of file