Delete action

This commit is contained in:
MrLetsplay 2023-06-20 21:57:08 +02:00
parent 80ae3dfad0
commit 6fdb62c538
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
4 changed files with 38 additions and 18 deletions

View File

@ -73,11 +73,11 @@ public class MainActivity extends AppCompatActivity {
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present. // Inflate the menu; this adds items to the action bar if it is present.
if(NavigationUtil.getCurrentFragment(this) instanceof DynamicFragment) { /*if(NavigationUtil.getCurrentFragment(this) instanceof DynamicFragment) { TODO: vs. fabs?
//getMenuInflater().inflate(R.menu.menu_dynamic, menu); //getMenuInflater().inflate(R.menu.menu_dynamic, menu);
getMenuInflater().inflate(R.menu.menu_dynamic, menu); getMenuInflater().inflate(R.menu.menu_dynamic, menu);
return true; return true;
} }*/
getMenuInflater().inflate(R.menu.menu_main, menu); getMenuInflater().inflate(R.menu.menu_main, menu);
return true; return true;

View File

@ -11,6 +11,7 @@ import android.widget.Button;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.cringe_studios.cringe_authenticator.R; import com.cringe_studios.cringe_authenticator.R;
@ -40,7 +41,18 @@ public class MenuFragment extends Fragment {
bundle.putString("tab", item); bundle.putString("tab", item);
NavigationUtil.navigate(this, DynamicFragment.class, bundle); NavigationUtil.navigate(this, DynamicFragment.class, bundle);
}); });
binding.menuItems.addView(itemBinding.getRoot(), 0); itemBinding.button.setOnLongClickListener(view -> {
new AlertDialog.Builder(getContext())
.setTitle("Delete?")
.setMessage("Delete this?")
.setPositiveButton("Yes", (dialog, which) -> itemBinding.button.setVisibility(View.GONE))
.setNegativeButton("No", (dialog, which) -> {})
.show();
// TODO: better method?
// TODO: actually delete
return true;
});
binding.menuItems.addView(itemBinding.getRoot());
} }
binding.editSwitch.setOnCheckedChangeListener((view, checked) -> { binding.editSwitch.setOnCheckedChangeListener((view, checked) -> {

View File

@ -1,21 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/rectangle" android:background="@drawable/rectangle"
android:layout_margin="5dp"
android:padding="5dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/displayName" android:id="@+id/displayName"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="My TOTP" android:text="My TOTP"
android:textAlignment="center" /> android:textAlignment="center"
android:textSize="16sp" />
<TextView <TextView
android:id="@+id/totpCode" android:id="@+id/totpCode"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="000000" android:text="000000"
android:textAlignment="center" /> android:textAlignment="center"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -8,5 +8,5 @@
android:id="@+id/button" android:id="@+id/button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Button" /> android:text="Button"/>
</LinearLayout> </LinearLayout>