movableactionbutton removed

addbutton is now movable
This commit is contained in:
JG-Cody 2021-07-02 21:37:18 +02:00
parent 746ec62e2f
commit 451292076b
8 changed files with 41 additions and 58 deletions

View File

@ -7,6 +7,7 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import androidx.fragment.app.DialogFragment;
@ -17,7 +18,7 @@ public class AddHeadlineDialog extends DialogFragment {
private EditText editText_name;
private FlurFragment frag;
ImageView delete;
/**
*
* @param savedInstanceState
@ -45,6 +46,7 @@ public class AddHeadlineDialog extends DialogFragment {
AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(R.drawable.button_round);
return mDialog;
}

View File

@ -1,9 +1,7 @@
package de.jg_cody.Teraplex;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@ -22,7 +20,6 @@ import android.os.Bundle;
import android.provider.MediaStore;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
@ -30,6 +27,7 @@ import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Switch;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
@ -41,7 +39,6 @@ import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.navigation.NavigationView;
import java.io.ByteArrayOutputStream;
@ -54,18 +51,16 @@ import java.util.Objects;
import de.jg_cody.Teraplex.ui.Credits.CreditsFragment;
import de.jg_cody.Teraplex.ui.Einstellungen.EinstellungenFragment;
import de.jg_cody.Teraplex.ui.Konsole.KonsoleFragment;
import de.jg_cody.Teraplex.ui.home.HomeFragment;
import de.jg_cody.Teraplex.ui.rooms.ListAdapter;
import de.jg_cody.Teraplex.ui.rooms.ListItem;
import de.jg_cody.Teraplex.ui.rooms.ListItemDouble;
import de.jg_cody.Teraplex.ui.rooms.ListItemSingle;
public class MainActivity extends AppCompatActivity {
public static int RESULT_LOAD_IMAGE = 0;
private AppBarConfiguration mAppBarConfiguration;
public static boolean editmode = false;
ListAdapter listAdapter;
ListView listView;
@ -122,17 +117,7 @@ public class MainActivity extends AppCompatActivity {
setSupportActionBar(toolbar);
FloatingActionButton mfab = findViewById(R.id.fab);
mfab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
Log.d("I", "ACTION BUTTON CLICKED");
SSH_connection.executeRemoteCommand(HomeFragment.ip, HomeFragment.user, HomeFragment.password, KonsoleFragment.command);
} catch (Exception e) {
}
}
});
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
@ -145,20 +130,19 @@ public class MainActivity extends AppCompatActivity {
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
Switch switcheditmode = findViewById(R.id.switch_editmode);
editmode = switcheditmode.isChecked();
switcheditmode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
editmode = switcheditmode.isChecked();
}
});
}
/*static public class DemoPreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
@ -209,14 +193,13 @@ public class MainActivity extends AppCompatActivity {
}
public void menurighttopeinstellungen(MenuItem i) {
EinstellungenFragment pef = new EinstellungenFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.nav_host_fragment, pef).setPrimaryNavigationFragment(pef);
transaction.addToBackStack(null);
transaction.commit();
getSupportActionBar().setTitle(R.string.menu_einstellungen);
Objects.requireNonNull(getSupportActionBar()).setTitle(R.string.menu_einstellungen);
}
public void menurighttopcredits(MenuItem i) {
@ -225,7 +208,7 @@ public class MainActivity extends AppCompatActivity {
transaction.replace(R.id.nav_host_fragment, pef).setPrimaryNavigationFragment(pef);
transaction.addToBackStack(null);
transaction.commit();
getSupportActionBar().setTitle(R.string.menu_über);
Objects.requireNonNull(getSupportActionBar()).setTitle(R.string.menu_über);
}
public void menurighttopdocumentation(MenuItem i) {
@ -242,7 +225,6 @@ public class MainActivity extends AppCompatActivity {
}
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@ -250,8 +232,10 @@ public class MainActivity extends AppCompatActivity {
if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) {
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
assert selectedImage != null;
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
assert cursor != null;
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
@ -262,7 +246,9 @@ public class MainActivity extends AppCompatActivity {
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
int len;
byte[] buf = new byte[1024];
while ((len = Background.read(buf)) > 0) {
while (true) {
assert Background != null;
if (!((len = Background.read(buf)) > 0)) break;
bOut.write(buf, 0, len);
}
Background.close();

View File

@ -118,7 +118,7 @@ public class FlurFragment extends Fragment implements AddButtonDialogSingle.AddB
});
h.attachToRecyclerView(listView);
FloatingActionButton addfab = root.findViewById(R.id.addbutton_fab);
FloatingActionButton addfab = root.findViewById(R.id.fab);
addfab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import de.jg_cody.Teraplex.MainActivity;
import de.jg_cody.Teraplex.R;
public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHolder> {
@ -103,6 +104,15 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
public void bindView(View view, ListItem item) {
String[] strings = item.getStrings();
ImageView Remove = view.findViewById(R.id.image_remove);
if (MainActivity.editmode == true) {
Remove.setVisibility(View.VISIBLE);
}
else {
Remove.setVisibility(View.GONE);
}
Remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View File

@ -20,14 +20,6 @@
app:layout_anchor="@+id/include"
app:layout_anchorGravity="center" />
<de.jg_cody.Teraplex.MovableFloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="?android:attr/fingerprintAuthDrawable" />

View File

@ -18,13 +18,6 @@
android:id="@+id/include"
layout="@layout/content_main" />
<de.jg_cody.Teraplex.MovableFloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"

View File

@ -15,13 +15,13 @@
android:scaleType="centerCrop"
android:src="@drawable/fog_background" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/addbutton_fab"
<de.jg_cody.Teraplex.MovableFloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:layout_gravity="bottom|end"
android:layout_marginHorizontal="16dp"
android:layout_marginVertical="70dp"
android:layout_marginVertical="16dp"
android:background="@drawable/button_round"
android:hapticFeedbackEnabled="true"
android:src="@drawable/add_black_24dp" />

View File

@ -4,8 +4,8 @@
android:layout_height="match_parent">
<Switch
android:id="@+id/switch_editmode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
android:layout_centerInParent="true" />
</RelativeLayout>