huge code-cleanup

This commit is contained in:
JG-Cody 2021-08-14 15:33:52 +02:00
parent 5c4c96357d
commit 3961a880f1
29 changed files with 13 additions and 295 deletions

View File

@ -86,10 +86,6 @@ public class AddButtonDialogSingle extends DialogFragment {
{ {
this.frag = frag; this.frag = frag;
} }
public TabsFragment getFragment()
{
return frag;
}
@Override @Override
public void onAttach(@NotNull Context context) { public void onAttach(@NotNull Context context) {

View File

@ -80,10 +80,6 @@ public class AddButtonsDialogDouble extends DialogFragment {
this.frag = frag; this.frag = frag;
} }
public TabsFragment getFragment() {
return frag;
}
@Override @Override
public void onAttach(@NotNull Context context) { public void onAttach(@NotNull Context context) {
super.onAttach(context); super.onAttach(context);

View File

@ -8,7 +8,6 @@ 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;
@ -23,7 +22,7 @@ public class AddHeadlineDialog extends DialogFragment {
private EditText editText_name; private EditText editText_name;
private TabsFragment frag; private TabsFragment frag;
ImageView delete;
/** /**
* *
* @param savedInstanceState * @param savedInstanceState
@ -77,10 +76,6 @@ public class AddHeadlineDialog extends DialogFragment {
{ {
this.frag = frag; this.frag = frag;
} }
public TabsFragment getFragment()
{
return frag;
}
@Override @Override
public void onAttach(@NotNull Context context) { public void onAttach(@NotNull Context context) {

View File

@ -6,13 +6,10 @@ import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.ui.AppBarConfiguration;
public class IntroActivity extends AppCompatActivity { public class IntroActivity extends AppCompatActivity {
private AppBarConfiguration mAppBarConfiguration;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View File

@ -13,7 +13,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.media.MediaPlayer; import android.media.MediaPlayer;
@ -599,14 +598,5 @@ public class MainActivity extends AppCompatActivity {
return dest; return dest;
} }
public static Bitmap createImage(int width, int height, int color) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColor(color);
canvas.drawRect(0F, 0F, (float) width, (float) height, paint);
return bitmap;
}
} }

View File

@ -122,10 +122,6 @@ public class MovableFloatingActionButton extends FloatingActionButton implements
} }
public void setCustomClickListener(CustomClickListener customClickListener) {
this.customClickListener = customClickListener;
}
public interface CustomClickListener { public interface CustomClickListener {
void onClick(View view); void onClick(View view);
} }

View File

@ -13,19 +13,16 @@ import android.widget.ImageView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import de.jg_cody.Teraplex.MainActivity; import de.jg_cody.Teraplex.MainActivity;
import de.jg_cody.Teraplex.R; import de.jg_cody.Teraplex.R;
public class CreditsFragment extends Fragment { public class CreditsFragment extends Fragment {
private CreditsViewModel creditsViewModel;
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
creditsViewModel =
new ViewModelProvider(this).get(CreditsViewModel.class);
View root = inflater.inflate(R.layout.fragment_credits, container, false); View root = inflater.inflate(R.layout.fragment_credits, container, false);
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE); SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
String Background = p.getString("Background", null); String Background = p.getString("Background", null);

View File

@ -1,8 +0,0 @@
package de.jg_cody.Teraplex.ui.credits;
import androidx.lifecycle.ViewModel;
public class CreditsViewModel extends ViewModel {
}

View File

@ -26,7 +26,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import com.jcraft.jsch.Channel; import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSch;
@ -51,15 +50,10 @@ public class HomeFragment extends Fragment {
Button shutdown_Button; Button shutdown_Button;
Button loginButton; Button loginButton;
Button logoutButton; Button logoutButton;
Terminal terminal;
Button wlan_aus_Button;
Button wlan_an_Button;
Button kodian;
Button kodiaus;
ImageView togglepassword; ImageView togglepassword;
private HomeViewModel homeViewModel;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
@ -69,8 +63,6 @@ public class HomeFragment extends Fragment {
password = prefs.getString("password", null); password = prefs.getString("password", null);
ip = prefs.getString("ip", null); ip = prefs.getString("ip", null);
homeViewModel =
new ViewModelProvider(this).get(HomeViewModel.class);
View root = inflater.inflate(R.layout.fragment_home, container, false); View root = inflater.inflate(R.layout.fragment_home, container, false);
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE); SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
String Background = p.getString("Background", null); String Background = p.getString("Background", null);

View File

@ -1,7 +0,0 @@
package de.jg_cody.Teraplex.ui.home;
import androidx.lifecycle.ViewModel;
public class HomeViewModel extends ViewModel {
}

View File

@ -10,7 +10,6 @@ import android.widget.VideoView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import de.jg_cody.Teraplex.R; import de.jg_cody.Teraplex.R;
@ -22,12 +21,10 @@ public class IntroFragment extends Fragment {
MediaPlayer mMediaPlayer; MediaPlayer mMediaPlayer;
int mCurrentVideoPosition; int mCurrentVideoPosition;
private IntroViewModel introViewModel;
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
introViewModel =
new ViewModelProvider(this).get(IntroViewModel.class);
View root = inflater.inflate(R.layout.fragment_intro, container, false); View root = inflater.inflate(R.layout.fragment_intro, container, false);
// Hook up the VideoView to our UI. // Hook up the VideoView to our UI.

View File

@ -1,19 +0,0 @@
package de.jg_cody.Teraplex.ui.intro;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class IntroViewModel extends ViewModel {
private MutableLiveData<String> mText;
public IntroViewModel() {
mText = new MutableLiveData<>();
mText.setValue("INTRO");
}
public LiveData<String> getText() {
return mText;
}
}

View File

@ -22,7 +22,6 @@ import android.widget.ImageView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import java.util.Locale; import java.util.Locale;
import java.util.Objects; import java.util.Objects;
@ -35,12 +34,11 @@ import static android.content.Context.MODE_PRIVATE;
public class SettingsFragment extends Fragment { public class SettingsFragment extends Fragment {
private EditText editExportFile_name; private EditText editExportFile_name;
private SettingsViewModel settingsViewModel;
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
settingsViewModel =
new ViewModelProvider(this).get(SettingsViewModel.class);
View root = inflater.inflate(R.layout.fragment_settings, container, false); View root = inflater.inflate(R.layout.fragment_settings, container, false);
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE); SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
String Background = p.getString("Background", null); String Background = p.getString("Background", null);

View File

@ -1,8 +0,0 @@
package de.jg_cody.Teraplex.ui.settings;
import androidx.lifecycle.ViewModel;
public class SettingsViewModel extends ViewModel {
}

View File

@ -4,5 +4,6 @@ import android.view.View;
public interface IViewHolder { public interface IViewHolder {
abstract public String getCommand(); abstract public String getCommand();
abstract public View[] getViews(); abstract public View[] getViews();
} }

View File

@ -29,7 +29,6 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.ListItemViewHo
private AddButtonsDialogDouble.AddButtonsDialogListenerDouble listener; private AddButtonsDialogDouble.AddButtonsDialogListenerDouble listener;
private EditText editText_name, editText_command, editText_command1, editText_button1, editText_command2, editText_button2, editText_button_name; private EditText editText_name, editText_command, editText_command1, editText_button1, editText_command2, editText_button2, editText_button_name;
private TabsFragment frag;
ListAdapter listAdapter; ListAdapter listAdapter;

View File

@ -7,15 +7,6 @@ public class ListItemHeadline extends ListItem{
super( ListAdapter.HEADLINE); super( ListAdapter.HEADLINE);
this.name = name; this.name = name;
} }
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
@Override @Override

View File

@ -12,30 +12,6 @@ public class ListItemSingle extends ListItem{
this.command = command; this.command = command;
} }
public void setButtonName(String buttonName)
{
this.buttonName = buttonName;
}
public void setName(String name)
{
this.name = name;
}
public String getButtonName()
{
return buttonName;
}
public String getName()
{
return name;
}
public void setCommand(String command)
{
this.command = command;
}
public String getCommand()
{
return command;
}
@Override @Override
public String[] getStrings() { public String[] getStrings() {

View File

@ -16,7 +16,6 @@ import android.widget.ImageView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -41,7 +40,6 @@ import static android.content.Context.MODE_PRIVATE;
public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddButtonDialogListenerSingle, AddButtonsDialogDouble.AddButtonsDialogListenerDouble, AddHeadlineDialog.AddHeadlineDialogListener { public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddButtonDialogListenerSingle, AddButtonsDialogDouble.AddButtonsDialogListenerDouble, AddHeadlineDialog.AddHeadlineDialogListener {
private TabsViewModel tabsViewModel;
String[] commands = {"Hello1", "Hello2", "Hello3", "Hello4", "Hello5"}; String[] commands = {"Hello1", "Hello2", "Hello3", "Hello4", "Hello5"};
int[] type = {0, 1, 0, 0, 1}; int[] type = {0, 1, 0, 0, 1};
@ -53,7 +51,6 @@ public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddB
ArrayList<ListItem> items; ArrayList<ListItem> items;
String tabname; String tabname;
@ -64,8 +61,7 @@ public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddB
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
tabsViewModel =
new ViewModelProvider(this).get(TabsViewModel.class);
View root = inflater.inflate(R.layout.fragment_tabs, container, false); View root = inflater.inflate(R.layout.fragment_tabs, container, false);
SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE); SharedPreferences p = requireContext().getSharedPreferences("appsettings", Activity.MODE_PRIVATE);
String Background = p.getString("Background", null); String Background = p.getString("Background", null);
@ -249,7 +245,7 @@ public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddB
JSONObject item = listItems2.getJSONObject(i); JSONObject item = listItems2.getJSONObject(i);
listAdapter.add(ListItem.fromJson(item)); listAdapter.add(ListItem.fromJson(item));
} }
;
} }
public static void save(String tabname, Context context, ListAdapter listAdapter) throws JSONException { public static void save(String tabname, Context context, ListAdapter listAdapter) throws JSONException {
@ -261,6 +257,7 @@ public class TabsFragment extends Fragment implements AddButtonDialogSingle.AddB
editor.putString("listItems." + tabname, listItems2.toString()); editor.putString("listItems." + tabname, listItems2.toString());
editor.apply(); editor.apply();
} }
public void save() throws JSONException { public void save() throws JSONException {
save(tabname, requireContext(), listAdapter); save(tabname, requireContext(), listAdapter);
} }

View File

@ -1,19 +0,0 @@
package de.jg_cody.Teraplex.ui.tabs;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class TabsViewModel extends ViewModel {
private MutableLiveData<String> mText;
public TabsViewModel() {
mText = new MutableLiveData<>();
mText.setValue("TABS");
}
public LiveData<String> getText() {
return mText;
}
}

View File

@ -2,34 +2,11 @@ package de.jg_cody.Teraplex.ui.tabs;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.Toast;
public class ViewHolderDoubleButton implements IViewHolder{ public class ViewHolderDoubleButton implements IViewHolder{
String commandL; String commandL;
String commandR;
Button bLeft, bRight; Button bLeft, bRight;
public ViewHolderDoubleButton(Button bLeft, Button bRight, String commandL, String commandR) {
this.bLeft = bLeft;
this.bRight = bRight;
this.commandL = commandL;
this.commandR = commandR;
bLeft.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(bLeft.getContext(),commandL + " ON",Toast.LENGTH_SHORT).show();
}
});
bRight.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(bRight.getContext(),commandR + " OFF",Toast.LENGTH_SHORT).show();
}
});
}
@Override @Override
public String getCommand() { public String getCommand() {
return commandL; return commandL;

View File

@ -2,27 +2,13 @@ package de.jg_cody.Teraplex.ui.tabs;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.Toast;
public class ViewHolderSingleButton implements IViewHolder { public class ViewHolderSingleButton implements IViewHolder {
String command; String command;
Button bRun; Button bRun;
public ViewHolderSingleButton(Button bRun, String command) { @Override
this.bRun = bRun;
this.command = command;
bRun.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(bRun.getContext(),command + " ON",Toast.LENGTH_SHORT).show();
}
});
}
@Override
public String getCommand() { public String getCommand() {
return command; return command;
} }

View File

@ -17,7 +17,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import java.util.Objects; import java.util.Objects;
@ -34,12 +33,11 @@ public class TerminalFragment extends Fragment {
ScrollView scrollView; ScrollView scrollView;
public static String user, password, ip; public static String user, password, ip;
private TerminalViewModel terminalViewModel;
public View onCreateView(@NonNull LayoutInflater inflater, public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) { ViewGroup container, Bundle savedInstanceState) {
terminalViewModel =
new ViewModelProvider(this).get(TerminalViewModel.class);
View root = inflater.inflate(R.layout.fragment_terminal, container, false); View root = inflater.inflate(R.layout.fragment_terminal, container, false);
SharedPreferences prefs = requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE); SharedPreferences prefs = requireContext().getSharedPreferences("appsettings", Context.MODE_PRIVATE);
user = prefs.getString("user", null); user = prefs.getString("user", null);

View File

@ -1,8 +0,0 @@
package de.jg_cody.Teraplex.ui.terminal;
import androidx.lifecycle.ViewModel;
public class TerminalViewModel extends ViewModel {
}

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.drawerlayout.widget.DrawerLayout 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" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout" android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -1,6 +1,5 @@
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation = "vertical" android:orientation = "vertical"

View File

@ -2,7 +2,6 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height" android:layout_height="@dimen/nav_header_height"
android:gravity="bottom" android:gravity="bottom"

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardBackgroundColor="@color/white"
android:layout_margin="5dp">
<LinearLayout
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/text_cricketer_name"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cricketer Name"
android:textSize="18sp"
android:textColor="@color/black"></TextView>
<TextView
android:id="@+id/text_team_name"
android:layout_marginLeft="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team Name"
android:textSize="14sp"
android:textColor="@color/black"></TextView>
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.rarepebble.colorpicker.ColorPreference
android:key="simplePreference"
android:title="@string/pref_title"
android:defaultValue="#f00"
/>
<com.rarepebble.colorpicker.ColorPreference
android:key="optionalColor"
android:title="@string/pref_optional_color"
app:colorpicker_noneSelectedSummaryText="@string/no_color_selected"
android:summary="@string/pref_optional_color_summary"
app:colorpicker_selectNoneButtonText="@string/no_color"
/>
<com.rarepebble.colorpicker.ColorPreference
android:key="optionalColorWithDefault"
android:title="@string/pref_default_color"
android:summary="@string/pref_default_color_summary"
android:defaultValue="#f0f"
app:colorpicker_selectNoneButtonText="@string/default_color"
/>
<com.rarepebble.colorpicker.ColorPreference
android:key="opaquePreference"
android:title="@string/pref_no_alpha"
android:summary="@string/pref_no_alpha_summary"
app:colorpicker_showAlpha="false"
android:defaultValue="#00f"
/>
<com.rarepebble.colorpicker.ColorPreference
android:key="opaquePreferenceNoHex"
android:title="@string/pref_title_minimal"
android:summary="@string/pref_title_minimal_summary"
app:colorpicker_showAlpha="false"
app:colorpicker_showHex="false"
android:defaultValue="@color/example_color_resource"
/>
<PreferenceScreen
android:title="@string/pref_show_view_usage_demo">
<intent
android:action="android.intent.action.VIEW"
android:targetClass="com.rarepebble.colorpickerdemo.ViewDemoActivity"
android:targetPackage="com.rarepebble.colorpickerdemo" />
</PreferenceScreen>
</PreferenceScreen>