mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-05 08:03:47 -04:00
UI touch ups
This commit is contained in:
@@ -71,13 +71,14 @@ public class ManageGroupActivity extends CatimaAppCompatActivity implements Mana
|
||||
private EditText mGroupNameText;
|
||||
private TextView mGroupNameLabel;
|
||||
private ActionBar mActionBar;
|
||||
private FloatingActionButton mSaveButton;
|
||||
|
||||
private HashMap<Integer, Boolean> mAdapterState;
|
||||
private String mCurrentGroupName;
|
||||
|
||||
private boolean mGroupNameNotInUse;
|
||||
|
||||
private boolean mDarkMode;
|
||||
private int mGroupNameInputTextColor;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle inputSavedInstanceState)
|
||||
@@ -91,9 +92,10 @@ public class ManageGroupActivity extends CatimaAppCompatActivity implements Mana
|
||||
mNoMatchingCardsText = findViewById(R.id.noMatchingCardsText);
|
||||
mNoGroupCardsText = findViewById(R.id.noGroupCardsText);
|
||||
mCardList = findViewById(R.id.list);
|
||||
mSaveButton = findViewById(R.id.fabSave);
|
||||
|
||||
mGroupNameText = findViewById(R.id.editTextGroupName);
|
||||
mGroupNameLabel = findViewById(R.id.textViewEditGroupName);
|
||||
mGroupNameInputTextColor = mGroupNameText.getCurrentTextColor();
|
||||
|
||||
Intent intent = getIntent();
|
||||
String groupId = intent.getStringExtra("group");
|
||||
@@ -109,8 +111,6 @@ public class ManageGroupActivity extends CatimaAppCompatActivity implements Mana
|
||||
mCardList.setAdapter(mAdapter);
|
||||
registerForContextMenu(mCardList);
|
||||
|
||||
mDarkMode = Utils.isDarkModeEnabled(getApplicationContext());
|
||||
|
||||
if (inputSavedInstanceState != null) {
|
||||
ManageGroupActivityInGroupState adapterState = inputSavedInstanceState.getParcelable("mAdapterState");
|
||||
if (adapterState != null) {
|
||||
@@ -125,14 +125,37 @@ public class ManageGroupActivity extends CatimaAppCompatActivity implements Mana
|
||||
}
|
||||
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||
mActionBar.setDisplayShowHomeEnabled(true);
|
||||
|
||||
mSaveButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String currentGroupName = mGroupNameText.getText().toString();
|
||||
if(!currentGroupName.trim().equals(mGroup._id)){
|
||||
if(!mGroupNameNotInUse) {
|
||||
Toast toast = Toast.makeText(getApplicationContext(), R.string.group_name_already_in_use, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
return;
|
||||
}
|
||||
if(currentGroupName.trim().length() == 0){
|
||||
Toast toast = Toast.makeText(getApplicationContext(), R.string.group_name_is_empty, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter.commitToDatabase(getApplicationContext());
|
||||
Toast toast = Toast.makeText(getApplicationContext(), R.string.group_updated, Toast.LENGTH_SHORT);
|
||||
if(!currentGroupName.trim().equals(mGroup._id)){
|
||||
mDB.updateGroup(mGroup._id, currentGroupName.trim());
|
||||
}
|
||||
toast.show();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void resetGroupNameTextColor() {
|
||||
if (mDarkMode) {
|
||||
mGroupNameText.setTextColor(Color.WHITE);
|
||||
} else{
|
||||
mGroupNameText.setTextColor(Color.BLACK);
|
||||
}
|
||||
mGroupNameText.setTextColor(mGroupNameInputTextColor);
|
||||
}
|
||||
|
||||
private void checkIfGroupNameIsInUse(){
|
||||
@@ -246,26 +269,11 @@ public class ManageGroupActivity extends CatimaAppCompatActivity implements Mana
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu inputMenu)
|
||||
{
|
||||
this.mMenu = inputMenu;
|
||||
|
||||
getMenuInflater().inflate(R.menu.manage_group_menu, inputMenu);
|
||||
|
||||
MenuItem confirmButton = inputMenu.findItem(R.id.action_confirm);
|
||||
Drawable icon = confirmButton.getIcon();
|
||||
icon.mutate();
|
||||
icon.setTint(Color.WHITE);
|
||||
confirmButton.setIcon(icon);
|
||||
return super.onCreateOptionsMenu(inputMenu);
|
||||
}
|
||||
|
||||
private void leaveWithoutSaving(){
|
||||
if (hasChanged()){
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ManageGroupActivity.this);
|
||||
builder.setTitle(R.string.discard_changes);
|
||||
builder.setMessage(R.string.discard_changes_confirm);
|
||||
builder.setTitle(R.string.leaveWithoutSaveTitle);
|
||||
builder.setMessage(R.string.leaveWithoutSaveConfirmation);
|
||||
builder.setPositiveButton(R.string.confirm, (dialog, which) -> finish());
|
||||
builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
|
||||
AlertDialog dialog = builder.create();
|
||||
@@ -275,39 +283,6 @@ public class ManageGroupActivity extends CatimaAppCompatActivity implements Mana
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem inputItem)
|
||||
{
|
||||
int id = inputItem.getItemId();
|
||||
|
||||
if (id == R.id.action_confirm)
|
||||
{
|
||||
String currentGroupName = mGroupNameText.getText().toString();
|
||||
if(!currentGroupName.trim().equals(mGroup._id)){
|
||||
if(!mGroupNameNotInUse) {
|
||||
Toast toast = Toast.makeText(getApplicationContext(), R.string.group_name_already_in_use, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
return true;
|
||||
}
|
||||
if(currentGroupName.trim().length() == 0){
|
||||
Toast toast = Toast.makeText(getApplicationContext(), R.string.group_name_is_empty, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter.commitToDatabase(getApplicationContext());
|
||||
Toast toast = Toast.makeText(getApplicationContext(), R.string.group_updated, Toast.LENGTH_SHORT);
|
||||
if(!currentGroupName.trim().equals(mGroup._id)){
|
||||
mDB.updateGroup(mGroup._id, currentGroupName.trim());
|
||||
}
|
||||
toast.show();
|
||||
finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(inputItem);
|
||||
}
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
|
||||
@@ -7,7 +7,14 @@
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="protect.card_locker.ManageGroupActivity">
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/fabSave"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
app:srcCompat="@drawable/save_24dp"
|
||||
android:contentDescription="@string/save"
|
||||
android:layout_margin="16dp" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -34,18 +41,20 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewEditGroupName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/enter_group_name" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editTextGroupName"
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/storeNameField"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName" />
|
||||
android:hint="@string/storeName">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/editTextGroupName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
|
||||
<include
|
||||
android:id="@+id/include"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="protect.card_locker.ManageGroupActivity">
|
||||
<item
|
||||
android:id="@+id/action_confirm"
|
||||
android:icon="@drawable/ic_done"
|
||||
android:title="@string/action_search"
|
||||
app:showAsAction="always|collapseActionView" />
|
||||
</menu>
|
||||
@@ -130,9 +130,9 @@
|
||||
<item quantity="one"><xliff:g>%d</xliff:g> card</item>
|
||||
<item quantity="other"><xliff:g>%d</xliff:g> cards</item>
|
||||
</plurals>
|
||||
<string name="group_name_already_in_use">Group name already in use!</string>
|
||||
<string name="group_name_is_empty">Group name cannot be empty!</string>
|
||||
<string name="group_updated">Group updated!</string>
|
||||
<string name="group_name_already_in_use">Group name already in use</string>
|
||||
<string name="group_name_is_empty">Group name cannot be empty</string>
|
||||
<string name="group_updated">Group updated</string>
|
||||
<string name="all">All</string>
|
||||
<string name="deleteConfirmationGroup">Delete group?</string>
|
||||
<string name="failedOpeningFileManager">Install a file manager first.</string>
|
||||
@@ -249,6 +249,4 @@
|
||||
<string name="rate_this_app">Rate this app</string>
|
||||
<string name="on_google_play">on Google Play</string>
|
||||
<string name="report_error">Report Error</string>
|
||||
<string name="discard_changes">Discard Changes</string>
|
||||
<string name="discard_changes_confirm">There are unsaved changes that were made, do you wish to leave without saving?</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user