Commit bc458cf9 authored by Grigory Fedorov's avatar Grigory Fedorov

Status editor layout changed. Footer clear status button added. Bottom toolbar removed.

parent 9ee523db
......@@ -20,6 +20,7 @@ import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
......@@ -44,7 +45,7 @@ import com.xabber.android.ui.helper.ActionBarPainter;
import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R;
public class StatusEditor extends ManagedListActivity implements OnItemClickListener, Toolbar.OnMenuItemClickListener {
public class StatusEditor extends ManagedListActivity implements OnItemClickListener, Toolbar.OnMenuItemClickListener, View.OnClickListener {
private static final String SAVED_TEXT = "com.xabber.android.ui.StatusEditor.SAVED_TEXT";
private static final String SAVED_MODE = "com.xabber.android.ui.StatusEditor.SAVED_MODE";
......@@ -56,7 +57,6 @@ public class StatusEditor extends ManagedListActivity implements OnItemClickList
private SavedStatus actionWithItem;
private StatusEditorAdapter adapter;
private View savedStatusesTextView;
private Toolbar bottomToolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -74,16 +74,11 @@ public class StatusEditor extends ManagedListActivity implements OnItemClickList
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp);
getSupportActionBar().setTitle(null);
bottomToolbar = (Toolbar) findViewById(R.id.bottom_toolbar);
bottomToolbar.inflateMenu(R.menu.clear_status_history);
bottomToolbar.setOnMenuItemClickListener(this);
Intent intent = getIntent();
account = StatusEditor.getAccount(intent);
if (account != null) {
ActionBarPainter actionBarPainter = new ActionBarPainter(this);
actionBarPainter.updateWithAccountName(account);
bottomToolbar.setBackgroundColor(actionBarPainter.getAccountColor(account));
}
ListView listView = getListView();
......@@ -92,6 +87,10 @@ public class StatusEditor extends ManagedListActivity implements OnItemClickList
adapter = new StatusEditorAdapter(this);
setListAdapter(adapter);
View footerView = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.status_history_footer, null, false);
footerView.findViewById(R.id.clear_status_history_button).setOnClickListener(this);
listView.addFooterView(footerView);
statusTextView = (EditText) findViewById(R.id.status_text);
statusModeView = (Spinner) findViewById(R.id.status_icon);
statusModeView.setAdapter(new StatusModeAdapter(this));
......@@ -160,7 +159,6 @@ public class StatusEditor extends ManagedListActivity implements OnItemClickList
getListView().setVisibility(visibility);
savedStatusesTextView.setVisibility(visibility);
bottomToolbar.setVisibility(visibility);
}
@Override
......@@ -179,14 +177,18 @@ public class StatusEditor extends ManagedListActivity implements OnItemClickList
return true;
case R.id.action_clear_status_history:
AccountManager.getInstance().clearSavedStatuses();
adapter.onChange();
setStatusHistoryVisibility();
clearStatusHistory();
return true;
}
return false;
}
private void clearStatusHistory() {
AccountManager.getInstance().clearSavedStatuses();
adapter.onChange();
setStatusHistoryVisibility();
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
......@@ -247,4 +249,13 @@ public class StatusEditor extends ManagedListActivity implements OnItemClickList
public boolean onMenuItemClick(MenuItem menuItem) {
return onOptionsItemSelected(menuItem);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.clear_status_history_button:
clearStatusHistory();
default:
}
}
}
......@@ -12,12 +12,11 @@
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:layout_height="match_parent">
<include layout="@layout/toolbar_default"
android:layout_height="wrap_content"
......@@ -26,19 +25,10 @@
android:id="@+id/top_toolbar"
/>
<include layout="@layout/toolbar_default"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:id="@+id/bottom_toolbar"
/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/top_toolbar"
android:layout_above="@id/bottom_toolbar"
android:padding="8dp"
>
......@@ -56,14 +46,23 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/new_status"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?attr/colorPrimary"
android:paddingLeft="8dp"
android:textStyle="bold" />
<Spinner
android:id="@+id/status_icon"
android:prompt="@string/status_editor"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/status_message"
android:layout_marginLeft="34dp"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<EditText
......@@ -71,7 +70,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/status_text_hint"
android:paddingLeft="34dp"
android:layout_marginLeft="32dp"
android:singleLine="true"
/>
......@@ -79,23 +78,23 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/saved_statuses"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/saved_statuses_textview"
/>
android:textColor="?attr/colorPrimary"
android:paddingLeft="8dp"
android:layout_marginTop="16dp"
android:textStyle="bold" />
</LinearLayout>
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/top_panel"
/>
tools:listitem="@layout/status_editor_item"
tools:listfooter="@layout/status_history_footer" />
</RelativeLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/clear_status_history"
android:id="@+id/clear_status_history_button"
/>
</LinearLayout>
\ No newline at end of file
......@@ -36,4 +36,5 @@
<string name="new_status">Новый статус</string>
<string name="saved_statuses">Сохранённые статусы</string>
<string name="clear_status_history">Очистить историю статусов</string>
<string name="status_message">Статус-сообщение</string>
</resources>
\ No newline at end of file
......@@ -36,5 +36,6 @@
<string name="new_status">New status</string>
<string name="saved_statuses">Saved statuses</string>
<string name="clear_status_history">Clear status history</string>
<string name="status_message">Status message</string>
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment