mirror of https://github.com/M66B/FairEmail.git
Replaced listviews by spinners
This commit is contained in:
parent
2d7fc092a6
commit
478cde3e0e
|
@ -82,7 +82,6 @@ import android.widget.CompoundButton;
|
|||
import android.widget.EditText;
|
||||
import android.widget.FilterQueryProvider;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.MultiAutoCompleteTextView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
@ -146,7 +145,9 @@ import javax.mail.internet.AddressException;
|
|||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import static android.app.Activity.RESULT_CANCELED;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.widget.AdapterView.INVALID_POSITION;
|
||||
|
||||
public class FragmentCompose extends FragmentBase {
|
||||
private enum State {NONE, LOADING, LOADED}
|
||||
|
@ -3334,7 +3335,7 @@ public class FragmentCompose extends FragmentBase {
|
|||
final long working = getArguments().getLong("working");
|
||||
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_contact_group, null);
|
||||
final ListView lvGroup = dview.findViewById(R.id.lvGroup);
|
||||
final Spinner spGroup = dview.findViewById(R.id.spGroup);
|
||||
final Spinner spTarget = dview.findViewById(R.id.spTarget);
|
||||
|
||||
Cursor groups = getContext().getContentResolver().query(
|
||||
|
@ -3350,26 +3351,23 @@ public class FragmentCompose extends FragmentBase {
|
|||
ContactsContract.Groups.TITLE
|
||||
);
|
||||
|
||||
final SimpleCursorAdapter adapter = new SimpleCursorAdapter(
|
||||
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
|
||||
getContext(),
|
||||
R.layout.spinner_item1_dropdown,
|
||||
groups,
|
||||
new String[]{ContactsContract.Groups.TITLE},
|
||||
new int[]{android.R.id.text1},
|
||||
0);
|
||||
spGroup.setAdapter(adapter);
|
||||
|
||||
lvGroup.setAdapter(adapter);
|
||||
|
||||
final AlertDialog dialog = new AlertDialog.Builder(getContext())
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(dview)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
|
||||
lvGroup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int target = spTarget.getSelectedItemPosition();
|
||||
Cursor cursor = (Cursor) adapter.getItem(position);
|
||||
Cursor cursor = (Cursor) spGroup.getSelectedItem();
|
||||
if (target != INVALID_POSITION && cursor != null) {
|
||||
long group = cursor.getLong(0);
|
||||
|
||||
Bundle args = getArguments();
|
||||
|
@ -3377,12 +3375,13 @@ public class FragmentCompose extends FragmentBase {
|
|||
args.putInt("target", target);
|
||||
args.putLong("group", group);
|
||||
|
||||
sendResult(Activity.RESULT_OK);
|
||||
dismiss();
|
||||
sendResult(RESULT_OK);
|
||||
} else
|
||||
sendResult(RESULT_CANCELED);
|
||||
}
|
||||
});
|
||||
|
||||
return dialog;
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,14 +66,13 @@ import android.view.animation.TranslateAnimation;
|
|||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -4642,27 +4641,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_identity, null);
|
||||
ListView lvIdentity = dview.findViewById(R.id.lvIdentity);
|
||||
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
Button btnFix = dview.findViewById(R.id.btnFix);
|
||||
Group grpIdentities = dview.findViewById(R.id.grpIdentities);
|
||||
Group grpNoIdentities = dview.findViewById(R.id.grpNoIdentities);
|
||||
ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
|
||||
|
||||
lvIdentity.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
TupleIdentityEx identity = (TupleIdentityEx) lvIdentity.getAdapter().getItem(position);
|
||||
|
||||
startActivity(new Intent(getContext(), ActivityCompose.class)
|
||||
.putExtra("action", "new")
|
||||
.putExtra("account", identity.account)
|
||||
.putExtra("identity", identity.id)
|
||||
);
|
||||
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
final Spinner spIdentity = dview.findViewById(R.id.spIdentity);
|
||||
final CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
|
||||
final Button btnFix = dview.findViewById(R.id.btnFix);
|
||||
final Group grpIdentities = dview.findViewById(R.id.grpIdentities);
|
||||
final Group grpNoIdentities = dview.findViewById(R.id.grpNoIdentities);
|
||||
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
|
||||
|
||||
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
@ -4677,7 +4661,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
public void onClick(View v) {
|
||||
startActivity(new Intent(getContext(), ActivitySetup.class));
|
||||
getActivity().finish();
|
||||
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
@ -4705,7 +4688,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
@Override
|
||||
protected void onExecuted(Bundle args, List<TupleIdentityEx> identities) {
|
||||
AdapterIdentitySelect iadapter = new AdapterIdentitySelect(getContext(), identities);
|
||||
lvIdentity.setAdapter(iadapter);
|
||||
spIdentity.setAdapter(iadapter);
|
||||
|
||||
grpIdentities.setVisibility(identities.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
grpNoIdentities.setVisibility(identities.size() > 0 ? View.GONE : View.VISIBLE);
|
||||
|
@ -4719,6 +4702,18 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
return new AlertDialog.Builder(getContext())
|
||||
.setView(dview)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
TupleIdentityEx identity = (TupleIdentityEx) spIdentity.getSelectedItem();
|
||||
if (identity != null)
|
||||
startActivity(new Intent(getContext(), ActivityCompose.class)
|
||||
.putExtra("action", "new")
|
||||
.putExtra("account", identity.account)
|
||||
.putExtra("identity", identity.id)
|
||||
);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
|
|
|
@ -3,20 +3,29 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp">
|
||||
android:padding="24dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvGroup"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title_insert_contact_group"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Large"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spTarget"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:entries="@array/targetNames"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@id/tvGroup" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lvGroup"
|
||||
<Spinner
|
||||
android:id="@+id/spGroup"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
|
|
|
@ -25,11 +25,12 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvIdentity" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lvIdentity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="180dp"
|
||||
<Spinner
|
||||
android:id="@+id/spIdentity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/pbWait" />
|
||||
|
||||
|
@ -41,7 +42,7 @@
|
|||
android:text="@string/title_no_ask_again"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/lvIdentity" />
|
||||
app:layout_constraintTop_toBottomOf="@id/spIdentity" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvNoIdenties"
|
||||
|
@ -66,7 +67,7 @@
|
|||
android:id="@+id/grpIdentities"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:constraint_referenced_ids="lvIdentity,cbNotAgain" />
|
||||
app:constraint_referenced_ids="spIdentity,cbNotAgain" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpNoIdentities"
|
||||
|
|
Loading…
Reference in New Issue