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

View File

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

View File

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

View File

@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import de.jg_cody.Teraplex.MainActivity;
import de.jg_cody.Teraplex.R; import de.jg_cody.Teraplex.R;
public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHolder> { 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) { public void bindView(View view, ListItem item) {
String[] strings = item.getStrings(); String[] strings = item.getStrings();
ImageView Remove = view.findViewById(R.id.image_remove); 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() { Remove.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -20,14 +20,6 @@
app:layout_anchor="@+id/include" app:layout_anchor="@+id/include"
app:layout_anchorGravity="center" /> 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" android:id="@+id/include"
layout="@layout/content_main" /> 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 <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

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

View File

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