Commit 5828a694 authored by Grigory Fedorov's avatar Grigory Fedorov

Several unused adapter and dialog classes removed.

parent a1e95b4f
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.adapter;
import android.widget.EditText;
/**
* Listener for text to be changed.
*
* @author alexander.ivanov
*/
public interface OnTextChangedListener {
void onTextChanged(EditText editText, CharSequence text);
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.adapter;
import android.view.View;
import android.widget.Adapter;
/**
* Adapter that can save state of view on activity paused or on element removed
* from layout.
* <p/>
* Warning: This interface is to be removed.
*
* @author alexander.ivanov
*/
public interface SaveStateAdapter extends Adapter {
/**
* Will be called before view will replaced with another or before activity
* will be paused.
*
* @param view
*/
void saveState(View view);
/**
* Requests to hide pages indicator.
*
* @param view
*/
void hidePages(View view);
/**
* Show pages indicator.
*
* @param view
*/
void showPages(View view);
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.dialog;
import java.util.ArrayList;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.View;
import android.view.ViewGroup;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.AccountChooseAdapter;
public class AccountChooseDialogBuilder extends ListenableDialogBuilder {
private final String user;
private String selected;
public AccountChooseDialogBuilder(Activity activity, int dialogId,
final ConfirmDialogListener listener, String user) {
super(activity, dialogId);
this.user = user;
this.selected = null;
setOnCancelListener(listener);
setOnDeclineListener(listener);
final Adapter adapter = new Adapter(activity);
setSingleChoiceItems(adapter, -1, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
selected = (String) adapter.getItem(which);
dialog.dismiss();
listener.onAccept(AccountChooseDialogBuilder.this);
}
});
}
/**
* @return <code>null</code> can be returned.
*/
public String getSelected() {
return selected;
}
private class Adapter extends AccountChooseAdapter {
public Adapter(Activity activity) {
super(activity);
ArrayList<String> available = new ArrayList<String>();
for (RosterContact check : RosterManager.getInstance()
.getContacts())
if (check.isEnabled() && check.getUser().equals(user))
available.add(check.getAccount());
if (!available.isEmpty()) {
accounts.clear();
accounts.addAll(available);
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return getDropDownView(position, convertView, parent);
}
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.dialog;
import android.app.Activity;
import android.content.DialogInterface;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
public class ExportChatDialogBuilder extends ConfirmDialogBuilder {
private final EditText nameView;
private final CheckBox sendView;
public ExportChatDialogBuilder(Activity activity, int dialogId,
ConfirmDialogListener listener, String account, String user) {
super(activity, dialogId, listener);
setTitle(R.string.export_chat_title);
View layout = activity.getLayoutInflater().inflate(
R.layout.export_chat, null);
nameView = (EditText) layout.findViewById(R.id.name);
sendView = (CheckBox) layout.findViewById(R.id.send);
nameView.setText(activity.getString(R.string.export_chat_mask,
AccountManager.getInstance().getVerboseName(account),
RosterManager.getInstance().getName(account, user)));
setView(layout);
}
@Override
public void onAccept(DialogInterface dialog) {
if ("".equals(getName())) {
Toast.makeText(activity,
activity.getString(R.string.group_is_empty),
Toast.LENGTH_LONG).show();
return;
}
super.onAccept(dialog);
}
public String getName() {
return nameView.getText().toString();
}
public boolean isSendChecked() {
return sendView.isChecked();
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.dialog;
import java.util.Collection;
import android.app.Activity;
import android.content.DialogInterface;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.androiddev.R;
public class GroupAddDialogBuilder extends ConfirmDialogBuilder {
private final Collection<String> groups;
private final EditText nameView;
public GroupAddDialogBuilder(Activity activity, int dialogId,
ConfirmDialogListener listener, Collection<String> groups) {
super(activity, dialogId, listener);
setTitle(R.string.group_add);
this.groups = groups;
View layout = activity.getLayoutInflater().inflate(R.layout.group_name,
null);
nameView = (EditText) layout.findViewById(R.id.group_name);
setView(layout);
}
@Override
public void onAccept(DialogInterface dialog) {
String name = nameView.getText().toString();
if ("".equals(name)) {
Toast.makeText(activity,
activity.getString(R.string.group_is_empty),
Toast.LENGTH_LONG).show();
return;
}
if (groups.contains(name)) {
Toast.makeText(activity, activity.getString(R.string.group_exists),
Toast.LENGTH_LONG).show();
return;
}
super.onAccept(dialog);
}
public String getName() {
return nameView.getText().toString();
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.dialog;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.androiddev.R;
import java.util.ArrayList;
public class GroupAddDialogFragment extends ConfirmDialogFragment {
private static final String GROUPS = "GROUPS";
/**
* @param account can be <code>null</code> to be used for all accounts.
* @param group can be <code>null</code> to be used for "no group".
* @return
*/
public static DialogFragment newInstance(ArrayList<String> groups) {
return new GroupAddDialogFragment().putAgrument(GROUPS, groups);
}
private ArrayList<String> groups;
private EditText nameView;
@Override
protected Builder getBuilder() {
groups = getArguments().getStringArrayList(GROUPS);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.group_add);
View layout = getActivity().getLayoutInflater().inflate(
R.layout.group_name, null);
nameView = (EditText) layout.findViewById(R.id.group_name);
builder.setView(layout);
return builder;
}
@Override
protected boolean onPositiveClick() {
String group = nameView.getText().toString();
if ("".equals(group)) {
Toast.makeText(getActivity(), getString(R.string.group_is_empty),
Toast.LENGTH_LONG).show();
return false;
}
if (groups.contains(group)) {
Toast.makeText(getActivity(), getString(R.string.group_exists),
Toast.LENGTH_LONG).show();
return false;
}
((OnGroupAddConfirmed) getActivity()).onGroupAddConfirmed(group);
return true;
}
public interface OnGroupAddConfirmed {
void onGroupAddConfirmed(String group);
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.dialog;
import android.app.Activity;
import android.content.DialogInterface;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.androiddev.R;
public class GroupRenameDialogBuilder extends ConfirmDialogBuilder {
private final EditText nameView;
public GroupRenameDialogBuilder(Activity activity, int dialogId,
ConfirmDialogListener listener, String group) {
super(activity, dialogId, listener);
setTitle(R.string.group_rename);
View layout = activity.getLayoutInflater().inflate(R.layout.group_name,
null);
nameView = (EditText) layout.findViewById(R.id.group_name);
nameView.setText(group);
setView(layout);
}
@Override
public void onAccept(DialogInterface dialog) {
if ("".equals(getName())) {
Toast.makeText(activity,
activity.getString(R.string.group_is_empty),
Toast.LENGTH_LONG).show();
return;
}
super.onAccept(dialog);
}
public String getName() {
return nameView.getText().toString();
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.widget;
import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import com.xabber.android.data.account.StatusMode;
import com.xabber.androiddev.R;
/**
* Preference to show status mode icon.
*
* @author alexander.ivanov
*/
public class StatusPreference extends Preference {
private StatusMode statusMode;
public StatusPreference(Context context) {
super(context);
init();
}
public StatusPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public StatusPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
setWidgetLayoutResource(R.layout.preference_status_widget);
}
public void setStatusMode(StatusMode statusMode) {
this.statusMode = statusMode;
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
((ImageView) view.findViewById(R.id.status_icon))
.setImageLevel(statusMode.getStatusLevel());
}
}
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