| @@ -0,0 +1,13 @@ | |||
| package de.erich.railcontrol; | |||
| import android.app.Application; | |||
| import android.test.ApplicationTestCase; | |||
| /** | |||
| * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | |||
| */ | |||
| public class ApplicationTest extends ApplicationTestCase<Application> { | |||
| public ApplicationTest() { | |||
| super(Application.class); | |||
| } | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | |||
| package="de.erich.railcontrol" > | |||
| <uses-permission android:name="android.permission.INTERNET" /> | |||
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |||
| <application | |||
| android:allowBackup="true" | |||
| android:icon="@drawable/th" | |||
| android:label="@string/app_name" | |||
| android:theme="@style/AppTheme" > | |||
| <activity | |||
| android:name=".MyActivity" | |||
| android:label="@string/app_name" > | |||
| <intent-filter> | |||
| <action android:name="android.intent.action.MAIN" /> | |||
| <category android:name="android.intent.category.LAUNCHER" /> | |||
| </intent-filter> | |||
| </activity> | |||
| <activity | |||
| android:name=".EditLok" | |||
| android:label="@string/title_activity_edit_lok" > | |||
| </activity> | |||
| </application> | |||
| </manifest> | |||
| @@ -0,0 +1,43 @@ | |||
| package de.erich.railcontrol; | |||
| import android.app.Fragment; | |||
| import android.os.Bundle; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.Button; | |||
| import android.widget.EditText; | |||
| public class AddLok extends Fragment { | |||
| public static Button btn_addlok_save; | |||
| static EditText et_addlok_name; | |||
| static EditText et_addlok_adresse; | |||
| static EditText et_addlok_maxspeed; | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| } | |||
| @Override | |||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| View frag = inflater.inflate(R.layout.fragment_addlok, container, false); | |||
| btn_addlok_save = (Button) frag.findViewById(R.id.btn_addlok_save); | |||
| et_addlok_name = (EditText) frag.findViewById(R.id.et_addlok_name); | |||
| et_addlok_adresse = (EditText) frag.findViewById(R.id.et_addlok_adresse); | |||
| et_addlok_maxspeed = (EditText) frag.findViewById(R.id.et_addlok_maxspeed); | |||
| btn_addlok_save.setOnClickListener(new btn_listeners()); | |||
| return frag; | |||
| } | |||
| @Override | |||
| public void onActivityCreated(Bundle savedInstanceState) { | |||
| super.onActivityCreated(savedInstanceState); | |||
| } | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package de.erich.railcontrol; | |||
| import android.app.Fragment; | |||
| import android.os.Bundle; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.Button; | |||
| import android.widget.EditText; | |||
| public class EditLok extends Fragment { | |||
| public static Button btn_editLok_save; | |||
| public static Button btn_editLok_delete; | |||
| public static EditText et_editLok_name; | |||
| public static EditText et_editLok_adresse; | |||
| public static EditText et_editLok_maxspeed; | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| } | |||
| @Override | |||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| System.out.println("onCreateView"); | |||
| View frag = inflater.inflate(R.layout.fragment_edit_lok, container, false); | |||
| btn_editLok_save = (Button) frag.findViewById(R.id.btn_editLok_save); | |||
| btn_editLok_delete = (Button) frag.findViewById(R.id.btn_editLok_delete); | |||
| et_editLok_adresse = (EditText) frag.findViewById(R.id.et_editLok_adresse); | |||
| et_editLok_name = (EditText) frag.findViewById(R.id.et_editLok_name); | |||
| et_editLok_maxspeed = (EditText) frag.findViewById(R.id.et_editLok_maxspeed); | |||
| btn_editLok_save.setOnClickListener(new MyActivity()); | |||
| btn_editLok_delete.setOnClickListener(new MyActivity()); | |||
| return frag; | |||
| } | |||
| @Override | |||
| public void onActivityCreated(Bundle savedInstanceState) { | |||
| super.onActivityCreated(savedInstanceState); | |||
| } | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| package de.erich.railcontrol; | |||
| import android.app.Fragment; | |||
| import android.os.Bundle; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.Button; | |||
| import android.widget.EditText; | |||
| import android.widget.TextView; | |||
| public class Konfiguration extends Fragment { | |||
| public static Button btn_accept; | |||
| public static TextView tv_ip; | |||
| public static TextView tv_port; | |||
| public static EditText et_ip; | |||
| public static EditText et_port; | |||
| public static Button btn_add_lok; | |||
| public static Button btn_saveConfig; | |||
| public static String ip_cfg; | |||
| public static int port_cfg = 0; | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| } | |||
| @Override | |||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| View frag = inflater.inflate(R.layout.fragment_config, container, false); | |||
| btn_accept = (Button) frag.findViewById(R.id.btn_accept); | |||
| tv_ip = (TextView) frag.findViewById(R.id.tv_ip); | |||
| tv_port = (TextView) frag.findViewById(R.id.tv_port); | |||
| et_ip = (EditText) frag.findViewById(R.id.et_ip); | |||
| et_port = (EditText) frag.findViewById(R.id.et_port); | |||
| btn_add_lok = (Button) frag.findViewById(R.id.btn_add_lok); | |||
| btn_saveConfig = (Button) frag.findViewById(R.id.btn_saveConfig); | |||
| btn_accept.setOnClickListener(new btn_listeners()); | |||
| btn_add_lok.setOnClickListener(new btn_listeners()); | |||
| btn_saveConfig.setOnClickListener(new btn_listeners()); | |||
| System.out.println("Ip: " + ParseLoksConfiguration.ip + ", port: " + ParseLoksConfiguration.port); | |||
| if(!(ParseLoksConfiguration.ip.equals("") || ParseLoksConfiguration.port == 0)) { | |||
| et_ip.setText(ParseLoksConfiguration.ip); | |||
| String string_port = String.valueOf(ParseLoksConfiguration.port); | |||
| et_port.setText(string_port); | |||
| } | |||
| return frag; | |||
| } | |||
| @Override | |||
| public void onActivityCreated(Bundle savedInstanceState) { | |||
| super.onActivityCreated(savedInstanceState); | |||
| } | |||
| } | |||
| @@ -0,0 +1,75 @@ | |||
| package de.erich.railcontrol; | |||
| import android.app.Activity; | |||
| import android.app.Fragment; | |||
| import android.app.FragmentManager; | |||
| import android.app.FragmentTransaction; | |||
| import android.net.Uri; | |||
| import android.os.Bundle; | |||
| import android.view.LayoutInflater; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.Button; | |||
| import android.widget.CheckBox; | |||
| import android.widget.SeekBar; | |||
| import android.widget.TextView; | |||
| import org.w3c.dom.Text; | |||
| public class Lok1 extends Fragment { | |||
| public static Button btn_richtung; | |||
| public static SeekBar speed; | |||
| public static CheckBox funktion_1; | |||
| public static CheckBox funktion_2; | |||
| public static CheckBox funktion_3; | |||
| public static CheckBox funktion_4; | |||
| public static TextView tv_direction; | |||
| TextView tv_lokName; | |||
| FragmentManager fragManager; | |||
| FragmentTransaction fragTransaction; | |||
| zug fragsLok; | |||
| Lok1 fragment; | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| } | |||
| @Override | |||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| System.out.println("onCreateView"); | |||
| View frag = inflater.inflate(R.layout.fragment_lok1, container, false); | |||
| btn_richtung = (Button) frag.findViewById(R.id.btn_richtung); | |||
| btn_richtung.setOnClickListener(new btn_listeners()); | |||
| speed = (SeekBar) frag.findViewById(R.id.seekBar); | |||
| speed.setMax(fragsLok.maxspeed); | |||
| speed.setOnSeekBarChangeListener(new btn_listeners()); | |||
| funktion_1 = (CheckBox) frag.findViewById(R.id.funktion_1); | |||
| funktion_2 = (CheckBox) frag.findViewById(R.id.funktion_2); | |||
| funktion_3 = (CheckBox) frag.findViewById(R.id.funktion_3); | |||
| funktion_4 = (CheckBox) frag.findViewById(R.id.funktion_4); | |||
| tv_lokName = (TextView) frag.findViewById(R.id.lok_name); | |||
| tv_direction = (TextView) frag.findViewById(R.id.tv_direction); | |||
| System.out.println(fragsLok); | |||
| tv_lokName.setText(fragsLok.name); | |||
| if(fragsLok.direction == 0) { | |||
| tv_direction.setText("\u2192"); | |||
| } else if (fragsLok.direction == 1) { | |||
| tv_direction.setText("\u2190"); | |||
| } | |||
| return frag; | |||
| } | |||
| @Override | |||
| public void onActivityCreated(Bundle savedInstanceState) { | |||
| super.onActivityCreated(savedInstanceState); | |||
| } | |||
| public void initFragment(zug Zug) { | |||
| fragsLok = Zug; | |||
| } | |||
| } | |||
| @@ -0,0 +1,25 @@ | |||
| package de.erich.railcontrol; | |||
| import java.io.IOException; | |||
| public class MainCall { | |||
| /** | |||
| * @param args | |||
| */ | |||
| static ParseLoksConfiguration lConf = new ParseLoksConfiguration(); | |||
| public MainCall(String directory) throws IOException { | |||
| lConf.parseConfiguration(directory + "/configuration.txt"); | |||
| /*try { | |||
| lConf.printConfiguration(directory + "/configuration.out"); | |||
| } catch (IOException e) { | |||
| System.out.println("Error: " + e); | |||
| System.exit(0); | |||
| } */ | |||
| } | |||
| } | |||
| @@ -0,0 +1,366 @@ | |||
| package de.erich.railcontrol; | |||
| import android.app.Activity; | |||
| import android.app.ActionBar; | |||
| import android.app.Fragment; | |||
| import android.app.FragmentManager; | |||
| import android.app.FragmentTransaction; | |||
| import android.os.Bundle; | |||
| import android.view.LayoutInflater; | |||
| import android.view.Menu; | |||
| import android.view.MenuItem; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.support.v4.widget.DrawerLayout; | |||
| import android.widget.Button; | |||
| import android.widget.CheckBox; | |||
| import android.widget.Switch; | |||
| import android.widget.Toast; | |||
| import java.io.IOException; | |||
| public class MyActivity extends Activity | |||
| implements NavigationDrawerFragment.NavigationDrawerCallbacks, View.OnClickListener { | |||
| public Konfiguration fragm_config; | |||
| public FragmentManager fragManager; | |||
| public FragmentTransaction fragTransaction; | |||
| public static zug E_10 = new zug(10, "E 12", 28); | |||
| public zug E_12 = new zug(200, "Hans", 28); | |||
| public static Lok1 currentFrag; | |||
| public Lok1 [] loks = new Lok1[10]; | |||
| public static zug [] zuege = new zug[10]; | |||
| public zug BR_86 = new zug(86, "BR 86" , 28); | |||
| static String defaultDataDir; | |||
| static boolean power; | |||
| /** | |||
| * Fragment managing the behaviors, interactions and presentation of the navigation drawer. | |||
| */ | |||
| private NavigationDrawerFragment mNavigationDrawerFragment; | |||
| /** | |||
| * Used to store the last screen title. For use in {@link #restoreActionBar()}. | |||
| */ | |||
| private CharSequence mTitle; | |||
| @Override | |||
| protected void onCreate(Bundle savedInstanceState) { | |||
| System.out.println("OnCreate"); | |||
| defaultDataDir = "/data/data/" + getPackageName(); | |||
| try { | |||
| MainCall maincall = new MainCall(defaultDataDir); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| /*zuege[0] = E_10; | |||
| zuege[1] = E_12; | |||
| zuege[2] = BR_86; */ | |||
| int zuegeLength = 0; | |||
| for (int i = 0; i < MyActivity.zuege.length; i++) { | |||
| if(!(MyActivity.zuege[i] == null)) { | |||
| zuegeLength++; | |||
| } | |||
| } | |||
| NavigationDrawerFragment.titles = new String[zuegeLength + 3]; | |||
| System.out.println("Anzahl Züge: " + zuegeLength); | |||
| NavigationDrawerFragment.titles[0] = getString(R.string.title_section1); | |||
| NavigationDrawerFragment.titles[1] = getString(R.string.title_section2); | |||
| NavigationDrawerFragment.titles[2] = "Neue Lok"; | |||
| for (int i = 3; i < zuege.length; i++) { | |||
| if(!(MyActivity.zuege[i - 3] == null)) { | |||
| NavigationDrawerFragment.titles[i] = zuege[i - 3].name; | |||
| System.out.println("Created: " + i); | |||
| } | |||
| else { | |||
| System.out.println("Something is null."); | |||
| } | |||
| } | |||
| super.onCreate(savedInstanceState); | |||
| setContentView(R.layout.activity_my); | |||
| mNavigationDrawerFragment = (NavigationDrawerFragment) | |||
| getFragmentManager().findFragmentById(R.id.navigation_drawer); | |||
| mTitle = getTitle(); | |||
| // Set up the drawer. | |||
| mNavigationDrawerFragment.setUp( | |||
| R.id.navigation_drawer, | |||
| (DrawerLayout) findViewById(R.id.drawer_layout)); | |||
| fragm_config = (Konfiguration) Fragment.instantiate(this, Konfiguration.class.getName(), null); | |||
| } | |||
| @Override | |||
| public void onNavigationDrawerItemSelected(int position) { | |||
| // update the main content by replacing fragments | |||
| FragmentManager fragmentManager = getFragmentManager(); | |||
| fragmentManager.beginTransaction() | |||
| .replace(R.id.container, PlaceholderFragment.newInstance(position + 1)) | |||
| .commit(); | |||
| System.out.println(position); | |||
| } | |||
| public void onSectionAttached(int number) { | |||
| System.out.println("onSectionAttached: "+number); | |||
| switch (number) { | |||
| case 1: | |||
| mTitle = getString(R.string.title_section1); | |||
| System.out.println("Section Attached"); | |||
| break; | |||
| case 2: | |||
| mTitle = getString(R.string.title_section2); | |||
| fragManager = getFragmentManager(); | |||
| fragTransaction = fragManager.beginTransaction(); | |||
| fragTransaction.replace(R.id.container,fragm_config); | |||
| fragTransaction.commit(); | |||
| break; | |||
| case 3: | |||
| mTitle = "Lok hinzufügen"; | |||
| AddLok addlok = new AddLok(); | |||
| fragManager = getFragmentManager(); | |||
| fragTransaction = fragManager.beginTransaction(); | |||
| fragTransaction.replace(R.id.container, addlok); | |||
| fragTransaction.commit(); | |||
| System.out.println("Lok hinzufügen - Fragment"); | |||
| break; | |||
| default: | |||
| System.out.println("Section: " + number); | |||
| if(loks[number-4] == null) { | |||
| Lok1 lok1 = new Lok1(); | |||
| loks[number-4] = lok1; | |||
| lok1.initFragment(zuege[number-4]); | |||
| } | |||
| Lok1 lok1 = loks[number-4]; | |||
| fragManager = getFragmentManager(); | |||
| fragTransaction = fragManager.beginTransaction(); | |||
| fragTransaction.replace(R.id.container, lok1); | |||
| fragTransaction.commit(); | |||
| mTitle = lok1.fragsLok.name; | |||
| //lok1.initFragment(E_10); | |||
| currentFrag = lok1; | |||
| break; | |||
| } | |||
| } | |||
| public void restoreActionBar() { | |||
| ActionBar actionBar = getActionBar(); | |||
| actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); | |||
| actionBar.setDisplayShowTitleEnabled(true); | |||
| actionBar.setTitle(mTitle); | |||
| } | |||
| @Override | |||
| public boolean onCreateOptionsMenu(Menu menu) { | |||
| System.out.println("OnCreateOptionsMenu"); | |||
| /* try { | |||
| MySAXApp.initReader(); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } */ | |||
| if (!mNavigationDrawerFragment.isDrawerOpen()) { | |||
| // Only show items in the action bar relevant to this screen | |||
| // if the drawer is not showing. Otherwise, let the drawer | |||
| // decide what to show in the action bar. | |||
| getMenuInflater().inflate(R.menu.my, menu); | |||
| restoreActionBar(); | |||
| return true; | |||
| } | |||
| return super.onCreateOptionsMenu(menu); | |||
| } | |||
| @Override | |||
| public boolean onOptionsItemSelected(MenuItem item) { | |||
| // Handle action bar item clicks here. The action bar will | |||
| // automatically handle clicks on the Home/Up button, so long | |||
| // as you specify a parent activity in AndroidManifest.xml. | |||
| int id = item.getItemId(); | |||
| if (id == R.id.action_settings) { | |||
| if(currentFrag == null) { | |||
| System.out.println("Erst Lok auswählen"); | |||
| Toast.makeText(this, "Erst Lok auswählen", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| else { | |||
| mTitle = "Lok ändern"; | |||
| EditLok editlok = new EditLok(); | |||
| fragManager = getFragmentManager(); | |||
| fragTransaction = fragManager.beginTransaction(); | |||
| fragTransaction.replace(R.id.container, editlok); | |||
| fragTransaction.commit(); | |||
| } | |||
| return true; | |||
| } | |||
| return super.onOptionsItemSelected(item); | |||
| } | |||
| /*@Override | |||
| public void onDestroy() { | |||
| System.out.println("OnDestroy"); | |||
| try { | |||
| MainCall.lConf.printConfiguration(defaultDataDir + "/configuration.txt"); | |||
| } catch (IOException e) { | |||
| System.out.println("Error: " + e); | |||
| System.exit(0); | |||
| } | |||
| }*/ | |||
| public void onCheckboxClicked(View view) { | |||
| int status = 0; | |||
| boolean checked = ((CheckBox) view).isChecked(); | |||
| if(checked) { | |||
| status = 1; | |||
| } | |||
| else if(!checked) { | |||
| status = 0; | |||
| } | |||
| if(view == Lok1.funktion_1) { | |||
| currentFrag.fragsLok.setFunction(1, status); | |||
| } | |||
| else if(view == Lok1.funktion_2) { | |||
| currentFrag.fragsLok.setFunction(2, status); | |||
| } | |||
| else if(view == Lok1.funktion_3) { | |||
| currentFrag.fragsLok.setFunction(3, status); | |||
| } | |||
| else if(view == Lok1.funktion_4) { | |||
| currentFrag.fragsLok.setFunction(4, status); | |||
| } | |||
| } | |||
| @Override | |||
| public void onClick(View view) { | |||
| if(view == EditLok.btn_editLok_save) { | |||
| int number = 100; | |||
| String name = EditLok.et_editLok_name.getText().toString(); | |||
| int adresse; | |||
| int maxspeed; | |||
| try { | |||
| adresse = Integer.parseInt(EditLok.et_editLok_adresse.getText().toString()); | |||
| maxspeed = Integer.parseInt(EditLok.et_editLok_maxspeed.getText().toString()); | |||
| } catch (NumberFormatException e) { | |||
| adresse = 0; | |||
| maxspeed = 0; | |||
| } | |||
| for (int i = 0;i < MyActivity.zuege.length; i++) { | |||
| if (MyActivity.zuege[i].equals(MyActivity.currentFrag.fragsLok)) { | |||
| number = i; | |||
| i = MyActivity.zuege.length; | |||
| System.out.println("Runned"); | |||
| } | |||
| } | |||
| if(!(name.equals("") || adresse == 0 || maxspeed == 0)) { | |||
| System.out.println("Setzen der Werte, Number :"+number); | |||
| MyActivity.currentFrag.fragsLok.name = name; | |||
| MyActivity.currentFrag.fragsLok.adresse = adresse; | |||
| MyActivity.currentFrag.fragsLok.maxspeed = maxspeed; | |||
| if(!(number == 100)) { | |||
| System.out.println("Nicht 100"); | |||
| MyActivity.zuege[number].name = name; | |||
| MyActivity.zuege[number].adresse = adresse; | |||
| MyActivity.zuege[number].maxspeed = maxspeed; | |||
| System.out.println("Gespeichert"); | |||
| Toast.makeText(EditLok.btn_editLok_save.getContext(), "Lok gespeichert", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| else { | |||
| System.out.println("Error occurred, EditLok"); | |||
| Toast.makeText(EditLok.btn_editLok_save.getContext(), "Es ist ein Fehler aufgetreten :(", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| else { | |||
| System.out.println("Fehlende Eingaben"); | |||
| Toast.makeText(EditLok.btn_editLok_save.getContext(), "Fehlende/Fehlerhafte Eingaben", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| else if (view == EditLok.btn_editLok_delete) { | |||
| int number = 100; | |||
| for (int i = 0;i < MyActivity.zuege.length; i++) { | |||
| if (MyActivity.zuege[i].equals(MyActivity.currentFrag.fragsLok)) { | |||
| number = i; | |||
| i = MyActivity.zuege.length; | |||
| } | |||
| } | |||
| MyActivity.zuege[number] = null; | |||
| /*for (int i = number; i < MyActivity.zuege.length; i++) { | |||
| if(i == number) { | |||
| System.out.println("Lok selber hihihi"); | |||
| } | |||
| else { | |||
| MyActivity.zuege[i - 1] = MyActivity.zuege[i]; | |||
| } | |||
| }*/ | |||
| System.out.println(MyActivity.zuege[number]); | |||
| Toast.makeText(EditLok.btn_editLok_save.getContext(), "Lok gelöscht", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| /** | |||
| * A placeholder fragment containing a simple view. | |||
| */ | |||
| public static class PlaceholderFragment extends Fragment { | |||
| public static Button btn_connect; | |||
| public static Button btn_quit; | |||
| public static Switch ip_selector; | |||
| /** | |||
| * The fragment argument representing the section number for this | |||
| * fragment. | |||
| */ | |||
| private static final String ARG_SECTION_NUMBER = "section_number"; | |||
| /** | |||
| * Returns a new instance of this fragment for the given section | |||
| * number. | |||
| */ | |||
| public static PlaceholderFragment newInstance(int sectionNumber) { | |||
| PlaceholderFragment fragment = new PlaceholderFragment(); | |||
| Bundle args = new Bundle(); | |||
| args.putInt(ARG_SECTION_NUMBER, sectionNumber); | |||
| fragment.setArguments(args); | |||
| return fragment; | |||
| } | |||
| public PlaceholderFragment() { | |||
| } | |||
| @Override | |||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| View rootView = inflater.inflate(R.layout.fragment_my, container, false); | |||
| this.btn_quit = (Button) rootView.findViewById(R.id.btn_quit); | |||
| this.btn_connect = (Button) rootView.findViewById(R.id.btn_connect); | |||
| System.out.println("Buttons gesetzt"); | |||
| System.out.println(this.btn_connect + ", " + this.btn_quit); | |||
| btn_quit.setOnClickListener(new btn_listeners()); | |||
| btn_connect.setOnClickListener(new btn_listeners()); | |||
| ip_selector = (Switch) rootView.findViewById(R.id.select_ip); | |||
| return rootView; | |||
| } | |||
| @Override | |||
| public void onAttach(Activity activity) { | |||
| super.onAttach(activity); | |||
| ((MyActivity) activity).onSectionAttached( | |||
| getArguments().getInt(ARG_SECTION_NUMBER)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,310 @@ | |||
| package de.erich.railcontrol; | |||
| import android.app.Activity; | |||
| import android.app.ActionBar; | |||
| import android.app.Fragment; | |||
| import android.support.v4.app.ActionBarDrawerToggle; | |||
| import android.support.v4.view.GravityCompat; | |||
| import android.support.v4.widget.DrawerLayout; | |||
| import android.content.SharedPreferences; | |||
| import android.content.res.Configuration; | |||
| import android.os.Bundle; | |||
| import android.preference.PreferenceManager; | |||
| import android.view.LayoutInflater; | |||
| import android.view.Menu; | |||
| import android.view.MenuInflater; | |||
| import android.view.MenuItem; | |||
| import android.view.View; | |||
| import android.view.ViewGroup; | |||
| import android.widget.AdapterView; | |||
| import android.widget.ArrayAdapter; | |||
| import android.widget.ListView; | |||
| import android.widget.Toast; | |||
| import java.io.IOException; | |||
| /** | |||
| * Fragment used for managing interactions for and presentation of a navigation drawer. | |||
| * See the <a href="https://developer.android.com/design/patterns/navigation-drawer.html#Interaction"> | |||
| * design guidelines</a> for a complete explanation of the behaviors implemented here. | |||
| */ | |||
| public class NavigationDrawerFragment extends Fragment { | |||
| /** | |||
| * Remember the position of the selected item. | |||
| */ | |||
| private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position"; | |||
| /** | |||
| * Per the design guidelines, you should show the drawer on launch until the user manually | |||
| * expands it. This shared preference tracks this. | |||
| */ | |||
| private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; | |||
| /** | |||
| * A pointer to the current callbacks instance (the Activity). | |||
| */ | |||
| private NavigationDrawerCallbacks mCallbacks; | |||
| /** | |||
| * Helper component that ties the action bar to the navigation drawer. | |||
| */ | |||
| private ActionBarDrawerToggle mDrawerToggle; | |||
| private DrawerLayout mDrawerLayout; | |||
| private ListView mDrawerListView; | |||
| private View mFragmentContainerView; | |||
| private int mCurrentSelectedPosition = 0; | |||
| private boolean mFromSavedInstanceState; | |||
| private boolean mUserLearnedDrawer; | |||
| public static String titles[]; | |||
| public NavigationDrawerFragment() { | |||
| } | |||
| @Override | |||
| public void onCreate(Bundle savedInstanceState) { | |||
| super.onCreate(savedInstanceState); | |||
| // Read in the flag indicating whether or not the user has demonstrated awareness of the | |||
| // drawer. See PREF_USER_LEARNED_DRAWER for details. | |||
| SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); | |||
| mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); | |||
| if (savedInstanceState != null) { | |||
| mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); | |||
| mFromSavedInstanceState = true; | |||
| } | |||
| // Select either the default item (0) or the last selected item. | |||
| selectItem(mCurrentSelectedPosition); | |||
| } | |||
| @Override | |||
| public void onActivityCreated (Bundle savedInstanceState) { | |||
| super.onActivityCreated(savedInstanceState); | |||
| // Indicate that this fragment would like to influence the set of actions in the action bar. | |||
| setHasOptionsMenu(true); | |||
| } | |||
| @Override | |||
| public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
| Bundle savedInstanceState) { | |||
| System.out.println("NavDrawerOnCreateView"); | |||
| mDrawerListView = (ListView) inflater.inflate( | |||
| R.layout.fragment_navigation_drawer, container, false); | |||
| mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |||
| @Override | |||
| public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |||
| selectItem(position); | |||
| } | |||
| }); | |||
| mDrawerListView.setAdapter(new ArrayAdapter<String>( | |||
| getActionBar().getThemedContext(), | |||
| android.R.layout.simple_list_item_activated_1, | |||
| android.R.id.text1, titles | |||
| /*new String[]{ | |||
| getString(R.string.title_section1), | |||
| getString(R.string.title_section2), | |||
| getString(R.string.title_section3), | |||
| "Test", | |||
| }*/ | |||
| )); | |||
| mDrawerListView.setItemChecked(mCurrentSelectedPosition, true); | |||
| return mDrawerListView; | |||
| } | |||
| public boolean isDrawerOpen() { | |||
| return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView); | |||
| } | |||
| /** | |||
| * Users of this fragment must call this method to set up the navigation drawer interactions. | |||
| * | |||
| * @param fragmentId The android:id of this fragment in its activity's layout. | |||
| * @param drawerLayout The DrawerLayout containing this fragment's UI. | |||
| */ | |||
| public void setUp(int fragmentId, DrawerLayout drawerLayout) { | |||
| mFragmentContainerView = getActivity().findViewById(fragmentId); | |||
| mDrawerLayout = drawerLayout; | |||
| // set a custom shadow that overlays the main content when the drawer opens | |||
| mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); | |||
| // set up the drawer's list view with items and click listener | |||
| ActionBar actionBar = getActionBar(); | |||
| actionBar.setDisplayHomeAsUpEnabled(true); | |||
| actionBar.setHomeButtonEnabled(true); | |||
| // ActionBarDrawerToggle ties together the the proper interactions | |||
| // between the navigation drawer and the action bar app icon. | |||
| mDrawerToggle = new ActionBarDrawerToggle( | |||
| getActivity(), /* host Activity */ | |||
| mDrawerLayout, /* DrawerLayout object */ | |||
| R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ | |||
| R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ | |||
| R.string.navigation_drawer_close /* "close drawer" description for accessibility */ | |||
| ) { | |||
| @Override | |||
| public void onDrawerClosed(View drawerView) { | |||
| super.onDrawerClosed(drawerView); | |||
| if (!isAdded()) { | |||
| return; | |||
| } | |||
| getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() | |||
| } | |||
| @Override | |||
| public void onDrawerOpened(View drawerView) { | |||
| super.onDrawerOpened(drawerView); | |||
| if (!isAdded()) { | |||
| return; | |||
| } | |||
| if (!mUserLearnedDrawer) { | |||
| // The user manually opened the drawer; store this flag to prevent auto-showing | |||
| // the navigation drawer automatically in the future. | |||
| mUserLearnedDrawer = true; | |||
| SharedPreferences sp = PreferenceManager | |||
| .getDefaultSharedPreferences(getActivity()); | |||
| sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); | |||
| } | |||
| getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() | |||
| } | |||
| }; | |||
| // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, | |||
| // per the navigation drawer design guidelines. | |||
| if (!mUserLearnedDrawer && !mFromSavedInstanceState) { | |||
| mDrawerLayout.openDrawer(mFragmentContainerView); | |||
| } | |||
| // Defer code dependent on restoration of previous instance state. | |||
| mDrawerLayout.post(new Runnable() { | |||
| @Override | |||
| public void run() { | |||
| mDrawerToggle.syncState(); | |||
| } | |||
| }); | |||
| mDrawerLayout.setDrawerListener(mDrawerToggle); | |||
| } | |||
| private void selectItem(int position) { | |||
| mCurrentSelectedPosition = position; | |||
| if (mDrawerListView != null) { | |||
| mDrawerListView.setItemChecked(position, true); | |||
| } | |||
| if (mDrawerLayout != null) { | |||
| mDrawerLayout.closeDrawer(mFragmentContainerView); | |||
| } | |||
| if (mCallbacks != null) { | |||
| mCallbacks.onNavigationDrawerItemSelected(position); | |||
| } | |||
| } | |||
| @Override | |||
| public void onAttach(Activity activity) { | |||
| super.onAttach(activity); | |||
| try { | |||
| mCallbacks = (NavigationDrawerCallbacks) activity; | |||
| } catch (ClassCastException e) { | |||
| throw new ClassCastException("Activity must implement NavigationDrawerCallbacks."); | |||
| } | |||
| } | |||
| @Override | |||
| public void onDetach() { | |||
| super.onDetach(); | |||
| mCallbacks = null; | |||
| } | |||
| @Override | |||
| public void onSaveInstanceState(Bundle outState) { | |||
| super.onSaveInstanceState(outState); | |||
| outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition); | |||
| } | |||
| @Override | |||
| public void onConfigurationChanged(Configuration newConfig) { | |||
| super.onConfigurationChanged(newConfig); | |||
| // Forward the new configuration the drawer toggle component. | |||
| mDrawerToggle.onConfigurationChanged(newConfig); | |||
| } | |||
| @Override | |||
| public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { | |||
| // If the drawer is open, show the global app actions in the action bar. See also | |||
| // showGlobalContextActionBar, which controls the top-left area of the action bar. | |||
| if (mDrawerLayout != null && isDrawerOpen()) { | |||
| inflater.inflate(R.menu.global, menu); | |||
| showGlobalContextActionBar(); | |||
| } | |||
| super.onCreateOptionsMenu(menu, inflater); | |||
| } | |||
| @Override | |||
| public boolean onOptionsItemSelected(MenuItem item) { | |||
| if (mDrawerToggle.onOptionsItemSelected(item)) { | |||
| return true; | |||
| } | |||
| if (item.getItemId() == R.id.action_example) { | |||
| if(!(btn_listeners.client == null || btn_listeners.client.connected == false)) { | |||
| if (MyActivity.power == true) { | |||
| try { | |||
| btn_listeners.client.sendMessage("SET 1 POWER OFF"); | |||
| MyActivity.power = false; | |||
| Toast.makeText(getActivity(), "Strom aus", Toast.LENGTH_SHORT).show(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } else { | |||
| try { | |||
| btn_listeners.client.sendMessage("SET 1 POWER ON"); | |||
| MyActivity.power = true; | |||
| Toast.makeText(getActivity(), "Strom an", Toast.LENGTH_SHORT).show(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| } else { | |||
| Toast.makeText(getActivity(), "Nicht Verbunden!", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| return true; | |||
| } | |||
| return super.onOptionsItemSelected(item); | |||
| } | |||
| /** | |||
| * Per the navigation drawer design guidelines, updates the action bar to show the global app | |||
| * 'context', rather than just what's in the current screen. | |||
| */ | |||
| private void showGlobalContextActionBar() { | |||
| ActionBar actionBar = getActionBar(); | |||
| actionBar.setDisplayShowTitleEnabled(true); | |||
| actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); | |||
| actionBar.setTitle(R.string.app_name); | |||
| } | |||
| private ActionBar getActionBar() { | |||
| return getActivity().getActionBar(); | |||
| } | |||
| /** | |||
| * Callbacks interface that all activities using this fragment must implement. | |||
| */ | |||
| public static interface NavigationDrawerCallbacks { | |||
| /** | |||
| * Called when an item in the navigation drawer is selected. | |||
| */ | |||
| void onNavigationDrawerItemSelected(int position); | |||
| } | |||
| } | |||
| @@ -0,0 +1,109 @@ | |||
| package de.erich.railcontrol; | |||
| import android.util.Log; | |||
| import java.io.BufferedReader; | |||
| import java.io.FileInputStream; | |||
| //import java.io.FileReader; | |||
| import java.io.FileNotFoundException; | |||
| import java.io.FileWriter; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.InputStreamReader; | |||
| public class ParseLoksConfiguration { | |||
| static String ip; | |||
| static int port; | |||
| static int numLoks = 0; | |||
| public enum Section { | |||
| NONE, CONFIGURATION, GENERAL, LOKS | |||
| } | |||
| public void parseConfiguration(String fileName) throws IOException { | |||
| try{ | |||
| InputStream fis=new FileInputStream(fileName); | |||
| BufferedReader br=new BufferedReader(new InputStreamReader(fis)); | |||
| String Line = br.readLine(); | |||
| Section sec = Section.NONE; | |||
| while(Line != null){ | |||
| String[] words=Line.split("\t"); | |||
| if ( words[0].equalsIgnoreCase("/>")) { | |||
| sec = Section.NONE; | |||
| } else if ( words[0].equalsIgnoreCase("<General")) { | |||
| sec = Section.GENERAL; | |||
| } else if ( words[0].equalsIgnoreCase("<Lok")) { | |||
| sec = Section.LOKS; | |||
| MyActivity.zuege[numLoks] = new zug(); | |||
| numLoks++; | |||
| } else if ( words[0].equalsIgnoreCase("") ) {//&& words.length > 3) { | |||
| if ( words.length > 1 ) { | |||
| if (sec == Section.GENERAL) { | |||
| if ( words[1].equalsIgnoreCase("ip:")) ip = words[2]; | |||
| else if (words[1].equalsIgnoreCase("port:")) | |||
| port = Integer.parseInt(words[2]); | |||
| } else if (sec == Section.LOKS) { | |||
| MyActivity.zuege[numLoks-1].setProperty(words); | |||
| } | |||
| } | |||
| } | |||
| try { | |||
| Line = br.readLine(); | |||
| } catch (Exception e){ | |||
| System.err.println("Error in Parseloop: " + e); | |||
| } | |||
| } | |||
| br.close(); | |||
| } | |||
| catch(FileNotFoundException e){ | |||
| this.printConfiguration(fileName); | |||
| } | |||
| Log.d("printConfig", "Parsed Configuration"); | |||
| } | |||
| public void printConfiguration(String fileName ) throws IOException { | |||
| FileWriter outStream = null; | |||
| /* | |||
| try { | |||
| Runtime.getRuntime().exec("cp " + fileName + " " + fileName + ".bck"); | |||
| } catch (Exception e) { | |||
| System.out.println("Error: " + e); | |||
| System.exit(0); | |||
| } | |||
| */ | |||
| try { | |||
| outStream = new FileWriter(fileName); | |||
| } catch (IOException e) { | |||
| System.out.println("Error " + e); | |||
| } | |||
| outStream.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | |||
| outStream.write("<Configuration>\n"); | |||
| outStream.write("<General\n"); | |||
| outStream.write("\tip:\t" + ip + "\n\tport:\t" + port + "\n"); | |||
| outStream.write("/>\n"); | |||
| if ( MyActivity.zuege != null ) { | |||
| for (int i = 0; i < numLoks; i++) { | |||
| if(MyActivity.zuege[i] != null) { | |||
| MyActivity.zuege[i].printConfiguration(outStream); | |||
| } | |||
| } | |||
| } | |||
| outStream.write("</Configuration>\n"); | |||
| // if (outStream != null) { | |||
| outStream.close(); | |||
| Log.d("printConfig", "Printed Configuration"); | |||
| // } | |||
| } | |||
| } | |||
| @@ -0,0 +1,75 @@ | |||
| package de.erich.railcontrol; | |||
| import java.io.*; | |||
| import java.net.*; | |||
| class CommunicationClient | |||
| { | |||
| String sentence; | |||
| String modifiedSentence; | |||
| Socket clientSocket; | |||
| InputStreamReader isr; | |||
| BufferedReader inFromStdIn; | |||
| DataOutputStream outToServer; | |||
| boolean connected; | |||
| public CommunicationClient() { | |||
| Thread thread = new Thread(new Runnable() { | |||
| @Override | |||
| public void run() { | |||
| String ip; | |||
| int port; | |||
| isr = new InputStreamReader(System.in); | |||
| inFromStdIn = new BufferedReader(isr); | |||
| if(MyActivity.PlaceholderFragment.ip_selector.isChecked()) { | |||
| System.out.println("Online"); | |||
| if(ParseLoksConfiguration.ip == null || ParseLoksConfiguration.port == 0) { | |||
| ip = "192.168.4.29"; | |||
| port = 4303; | |||
| } else { | |||
| ip = ParseLoksConfiguration.ip; | |||
| port = ParseLoksConfiguration.port; | |||
| } | |||
| } else { | |||
| System.out.println("Default"); | |||
| ip = "192.168.4.24"; | |||
| port = 6789; | |||
| } | |||
| System.out.println(ip + " " + port); | |||
| try { | |||
| clientSocket = new Socket(ip, port); | |||
| System.out.println("Verbunden"); | |||
| connected = true; | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| connected = false; | |||
| } | |||
| } | |||
| }); | |||
| thread.setPriority(1); | |||
| thread.start(); | |||
| } | |||
| public void sendMessage(String message) throws IOException { | |||
| System.out.printf("Enter: "); | |||
| outToServer = new DataOutputStream(clientSocket.getOutputStream()); | |||
| //BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); | |||
| sentence = message; | |||
| outToServer.writeBytes(sentence + '\n'); | |||
| //modifiedSentence = inFromServer.readLine(); | |||
| System.out.println("FROM SERVER: " + modifiedSentence); | |||
| } | |||
| public void killClient() throws IOException { | |||
| System.out.println("Kill Client"); | |||
| sendMessage("." + "\n"); | |||
| clientSocket.close(); | |||
| System.out.println("CLient killed"); | |||
| } | |||
| } | |||
| @@ -0,0 +1,156 @@ | |||
| package de.erich.railcontrol; | |||
| import android.app.FragmentManager; | |||
| import android.app.FragmentTransaction; | |||
| import android.content.Intent; | |||
| import android.view.View; | |||
| import android.widget.SeekBar; | |||
| import android.widget.Toast; | |||
| import java.io.IOException; | |||
| public class btn_listeners implements View.OnClickListener, SeekBar.OnSeekBarChangeListener { | |||
| public static CommunicationClient client; | |||
| String ip; | |||
| String port; | |||
| int progress; | |||
| FragmentManager fragManager; | |||
| FragmentTransaction fragTransaction; | |||
| @Override | |||
| public void onClick(View view) { | |||
| if(view == MyActivity.PlaceholderFragment.btn_quit) { | |||
| System.out.println(this.client); | |||
| if(!(client == null)) { | |||
| if(this.client.connected) { | |||
| try { | |||
| client.sendMessage("SET 1 POWER OFF"); | |||
| MyActivity.power = false; | |||
| client.killClient(); | |||
| client.connected = false; | |||
| Toast.makeText(MyActivity.PlaceholderFragment.btn_quit.getContext(), "Verbindung getrennt", Toast.LENGTH_SHORT).show(); | |||
| for(int i = 0; i < MyActivity.zuege.length; i++){ | |||
| if(MyActivity.zuege[i] != null) { | |||
| MyActivity.zuege[i].initialized = false; | |||
| MyActivity.zuege[i].firstTime = true; | |||
| } | |||
| } | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| else { | |||
| System.out.println("Nicht Verbunden"); | |||
| Toast.makeText(MyActivity.PlaceholderFragment.btn_quit.getContext(), "Nicht Verbunden!", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| } | |||
| else { | |||
| System.out.println("Nicht Verbunden. Client nicht generiert."); | |||
| Toast.makeText(MyActivity.PlaceholderFragment.btn_quit.getContext(), "Nicht Verbunden. Client nicht generiert.", Toast.LENGTH_LONG).show(); | |||
| } | |||
| } | |||
| else if(view == MyActivity.PlaceholderFragment.btn_connect) { | |||
| this.client = new CommunicationClient(); | |||
| try { | |||
| Thread.sleep(1000); | |||
| } catch (InterruptedException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| if (client.connected) { | |||
| try { | |||
| client.sendMessage("GO"); | |||
| client.sendMessage("SET 1 POWER ON"); | |||
| MyActivity.power = true; | |||
| Toast.makeText(MyActivity.PlaceholderFragment.btn_quit.getContext(), "Verbunden", Toast.LENGTH_SHORT).show(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } else { | |||
| Toast.makeText(MyActivity.PlaceholderFragment.btn_quit.getContext(), "Fehler bei der Verbindung!", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| System.out.println(client); | |||
| } | |||
| else if(view == Lok1.btn_richtung) { | |||
| int i = MyActivity.currentFrag.fragsLok.changeDirection(); | |||
| if (i == 0) { | |||
| Lok1.tv_direction.setText("\u2192"); | |||
| } else if(i == 1) { | |||
| Lok1.tv_direction.setText("\u2190"); | |||
| } | |||
| //MyActivity.E_10.changeDirection(); | |||
| } | |||
| else if(view == Konfiguration.btn_accept) { | |||
| ParseLoksConfiguration.ip = Konfiguration.et_ip.getText().toString(); | |||
| try { | |||
| ParseLoksConfiguration.port = Integer.parseInt(Konfiguration.et_port.getText().toString()); | |||
| } catch (NumberFormatException e) { | |||
| Toast.makeText(Konfiguration.btn_accept.getContext(), "Port keine Zahl!", Toast.LENGTH_SHORT).show(); | |||
| return; | |||
| } | |||
| System.out.println("Ip: " + ParseLoksConfiguration.ip); | |||
| System.out.println("Gespeichert"); | |||
| Toast.makeText(Konfiguration.btn_accept.getContext(), "Gespeichert", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| else if (view == AddLok.btn_addlok_save) { | |||
| System.out.println("btn listener: btnAddlokSave"); | |||
| String name = AddLok.et_addlok_name.getText().toString(); | |||
| int adresse = 0; | |||
| int maxspeed = 0; | |||
| try { | |||
| adresse = Integer.parseInt(AddLok.et_addlok_adresse.getText().toString()); | |||
| } catch(Exception e) { | |||
| System.out.println("Fehler: " + e); | |||
| Toast.makeText(AddLok.btn_addlok_save.getContext(), "Adresse keine Zahl!", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| try { | |||
| maxspeed = Integer.parseInt(AddLok.et_addlok_maxspeed.getText().toString()); | |||
| } catch(Exception e) { | |||
| System.out.println("Fehler: " + e); | |||
| Toast.makeText(AddLok.btn_addlok_save.getContext(), "Geschwindigkeitsstufen keine Zahl!", Toast.LENGTH_SHORT).show(); | |||
| } | |||
| if(!(adresse == 0 || maxspeed == 0 || name == null || name.equals(""))) { | |||
| MyActivity.zuege[ParseLoksConfiguration.numLoks] = new zug(adresse, name, maxspeed); | |||
| ParseLoksConfiguration.numLoks++; | |||
| Toast.makeText(AddLok.btn_addlok_save.getContext(), "Lok erstellt", Toast.LENGTH_SHORT).show(); | |||
| System.out.println("Lok erstellt"); | |||
| AddLok.et_addlok_maxspeed.setText("28"); | |||
| AddLok.et_addlok_adresse.setText(""); | |||
| AddLok.et_addlok_name.setText(""); | |||
| } else { | |||
| Toast.makeText(AddLok.btn_addlok_save.getContext(), "Fehlende/Fehlerhafte Eingaben", Toast.LENGTH_SHORT).show(); | |||
| System.out.println("Fehlerhafte Eingaben"); | |||
| } | |||
| } else if (view == Konfiguration.btn_saveConfig) { | |||
| System.out.println("btn listener: btn_SaveConfig"); | |||
| try { | |||
| MainCall.lConf.printConfiguration(MyActivity.defaultDataDir + "/configuration.txt"); | |||
| Toast.makeText(Konfiguration.btn_saveConfig.getContext(), "Konfiguration gespeichert. Neustart erforderlich!", Toast.LENGTH_SHORT).show(); | |||
| } catch (IOException e) { | |||
| System.out.println("Error: " + e); | |||
| System.exit(0); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public void onProgressChanged(SeekBar seekBar, int i, boolean b) { | |||
| if(seekBar == Lok1.speed) { | |||
| progress = i; | |||
| System.out.println(progress); | |||
| MyActivity.currentFrag.fragsLok.setSpeed(progress); | |||
| } | |||
| } | |||
| @Override | |||
| public void onStartTrackingTouch(SeekBar seekBar) { | |||
| } | |||
| @Override | |||
| public void onStopTrackingTouch(SeekBar seekBar) { | |||
| } | |||
| } | |||
| @@ -0,0 +1,141 @@ | |||
| package de.erich.railcontrol; | |||
| import android.widget.Toast; | |||
| import java.io.FileWriter; | |||
| import java.io.IOException; | |||
| public class zug { | |||
| int adresse; | |||
| int direction; | |||
| int speed; | |||
| String name; | |||
| int maxspeed; | |||
| boolean initialized; | |||
| boolean firstTime; | |||
| int funktion_1; | |||
| int funktion_2; | |||
| int funktion_3; | |||
| int funktion_4; | |||
| public zug(int adresse, String name, int maxspeed) { | |||
| this.adresse = adresse; | |||
| this.name = name; | |||
| this.maxspeed = maxspeed; | |||
| this.initialized = false; | |||
| firstTime = true; | |||
| } | |||
| public zug() { | |||
| this.initialized = false; | |||
| firstTime = true; | |||
| } | |||
| public boolean initZug() { | |||
| if(btn_listeners.client == null) { | |||
| if(firstTime) { | |||
| Toast.makeText(Lok1.btn_richtung.getContext(), "Noch nicht verbunden!", Toast.LENGTH_SHORT).show(); | |||
| firstTime = false; | |||
| } | |||
| return false; | |||
| } | |||
| try { | |||
| btn_listeners.client.sendMessage("INIT 1 GL " + this.adresse + " N 1 " + maxspeed +" 4"); | |||
| initialized = true; | |||
| return true; | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| return false; | |||
| } | |||
| } | |||
| public void setSpeed(int speed) { | |||
| if(!(this.initialized)) { | |||
| if(!(this.initZug())) { | |||
| return; | |||
| } | |||
| } | |||
| try { | |||
| btn_listeners.client.sendMessage("SET 1 GL " + this.adresse + " " + this.direction + " " + speed + " " + maxspeed + " " + funktion_1 + " "+ funktion_2 + " "+ funktion_3 + " " + funktion_4); | |||
| this.speed = speed; | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public void setDirection(int direction) { | |||
| this.direction = direction; | |||
| } | |||
| public int changeDirection() { | |||
| if(!(this.initialized)) { | |||
| if(!(this.initZug())) { | |||
| return this.direction; | |||
| } | |||
| } | |||
| if(this.direction == 0) { | |||
| this.direction = 1; | |||
| } | |||
| else if(this.direction == 1) { | |||
| this.direction = 0; | |||
| } | |||
| if(this.speed == 0) { | |||
| try { | |||
| btn_listeners.client.sendMessage("SET 1 GL " + this.adresse + " " + this.direction + " 0 28 " + funktion_1 + " "+ funktion_2 + " "+ funktion_3 + " " + funktion_4); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } else { | |||
| Lok1.speed.setProgress(0); | |||
| } | |||
| return this.direction; | |||
| } | |||
| public void setFunction(int function, int status) { | |||
| if(!(this.initialized)) { | |||
| if(!(this.initZug())) { | |||
| return; | |||
| } | |||
| } | |||
| switch(function) { | |||
| case 1: | |||
| funktion_1 = status; | |||
| break; | |||
| case 2: | |||
| funktion_2 = status; | |||
| break; | |||
| case 3: | |||
| funktion_3 = status; | |||
| break; | |||
| case 4: | |||
| funktion_4 = status; | |||
| break; | |||
| } | |||
| try { | |||
| btn_listeners.client.sendMessage("SET 1 GL " + this.adresse + " " + this.direction + " " + this.speed + " " + maxspeed + " " + funktion_1 + " "+ funktion_2 + " "+ funktion_3 + " " + funktion_4); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| public void printConfiguration(FileWriter outStream) throws IOException { | |||
| outStream.write("<Lok\n"); | |||
| outStream.write("\tname:\t" + name + "\n\tadresse:\t" + adresse + "\n"); | |||
| outStream.write("\tmaxspeed:\t" + maxspeed + "\n"); | |||
| outStream.write("/>\n"); | |||
| } | |||
| public void setProperty(String[] words) { | |||
| if ( words[1].equalsIgnoreCase("name:")) name = words[2]; | |||
| else if (words[1].equalsIgnoreCase("adresse:")) | |||
| adresse = Integer.parseInt(words[2]); | |||
| else if (words[1].equalsIgnoreCase("maxspeed:")) | |||
| maxspeed = Integer.parseInt(words[2]); | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <Configuration> | |||
| <General | |||
| ip: teuton.local | |||
| port: 1234 | |||
| /> | |||
| <Lok | |||
| name: Tenter | |||
| adresse: 10 | |||
| maxspeed: 99 | |||
| /> | |||
| <Lok | |||
| name: Willi | |||
| adresse: 22 | |||
| maxspeed: 200 | |||
| /> | |||
| </Configuration> | |||
| @@ -0,0 +1,38 @@ | |||
| <!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. --> | |||
| <android.support.v4.widget.DrawerLayout | |||
| xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:id="@+id/drawer_layout" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| tools:context=".MyActivity"> | |||
| <!-- As the main content view, the view below consumes the entire | |||
| space available using match_parent in both dimensions. --> | |||
| <FrameLayout | |||
| android:id="@+id/container" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" > | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/tv_ip" | |||
| android:layout_gravity="right|bottom" /> | |||
| </FrameLayout> | |||
| <!-- android:layout_gravity="start" tells DrawerLayout to treat | |||
| this as a sliding drawer on the left side for left-to-right | |||
| languages and on the right side for right-to-left languages. | |||
| If you're not building against API 17 or higher, use | |||
| android:layout_gravity="left" instead. --> | |||
| <!-- The drawer is given a fixed width in dp and extends the full height of | |||
| the container. --> | |||
| <fragment android:id="@+id/navigation_drawer" | |||
| android:layout_width="@dimen/navigation_drawer_width" | |||
| android:layout_height="match_parent" | |||
| android:layout_gravity="start" | |||
| android:name="de.erich.railcontrol.NavigationDrawerFragment" | |||
| tools:layout="@layout/fragment_navigation_drawer" /> | |||
| </android.support.v4.widget.DrawerLayout> | |||
| @@ -0,0 +1,68 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:layout_width="match_parent" android:layout_height="match_parent"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/tv_addlok_name" | |||
| android:id="@+id/tv_addlok_name" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginTop="39dp" | |||
| android:textSize="20sp"/> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/tv_addlok_adresse" | |||
| android:id="@+id/tv_addlok_adresse" | |||
| android:layout_marginTop="88dp" | |||
| android:layout_below="@+id/tv_addlok_name" | |||
| android:layout_centerHorizontal="true" | |||
| android:textSize="20sp"/> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/tv_addlok_maxspeed" | |||
| android:id="@+id/tv_addlok_maxspeed" | |||
| android:layout_centerVertical="true" | |||
| android:layout_centerHorizontal="true" | |||
| android:textSize="20sp"/> | |||
| <EditText | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/et_addlok_name" | |||
| android:layout_below="@+id/tv_addlok_name" | |||
| android:layout_centerHorizontal="true" /> | |||
| <EditText | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/et_addlok_adresse" | |||
| android:layout_below="@+id/tv_addlok_adresse" | |||
| android:layout_centerHorizontal="true" | |||
| android:inputType="phone"/> | |||
| <EditText | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/et_addlok_maxspeed" | |||
| android:layout_below="@+id/tv_addlok_maxspeed" | |||
| android:layout_centerHorizontal="true" | |||
| android:text="@string/et_addlok_maxspeed" | |||
| android:inputType="phone"/> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/btn_addlok_save" | |||
| android:id="@+id/btn_addlok_save" | |||
| android:layout_alignParentBottom="true" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginBottom="73dp" /> | |||
| </RelativeLayout> | |||
| @@ -0,0 +1,66 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:layout_width="match_parent" android:layout_height="match_parent"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/tv_ip" | |||
| android:id="@+id/tv_ip" | |||
| android:layout_marginTop="52dp" | |||
| android:textSize="24dp" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_centerHorizontal="true" /> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/tv_port" | |||
| android:id="@+id/tv_port" | |||
| android:textSize="24dp" | |||
| android:layout_marginTop="43dp" | |||
| android:layout_below="@+id/et_ip" | |||
| android:layout_centerHorizontal="true" /> | |||
| <EditText | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/et_ip" | |||
| android:layout_below="@+id/tv_ip" | |||
| android:layout_centerHorizontal="true" /> | |||
| <EditText | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/et_port" | |||
| android:layout_below="@+id/tv_port" | |||
| android:layout_centerHorizontal="true"/> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/btn_accept" | |||
| android:id="@+id/btn_accept" | |||
| android:layout_below="@+id/et_port" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginTop="48dp"/> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/btn_add_lok" | |||
| android:id="@+id/btn_add_lok" | |||
| android:layout_below="@+id/btn_accept" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginTop="43dp" /> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/btn_saveConfig" | |||
| android:id="@+id/btn_saveConfig" | |||
| android:layout_below="@+id/btn_add_lok" | |||
| android:layout_centerHorizontal="true" /> | |||
| </RelativeLayout> | |||
| @@ -0,0 +1,81 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:paddingLeft="@dimen/activity_horizontal_margin" | |||
| android:paddingRight="@dimen/activity_horizontal_margin" | |||
| android:paddingTop="@dimen/activity_vertical_margin" | |||
| android:paddingBottom="@dimen/activity_vertical_margin"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:textAppearance="?android:attr/textAppearanceLarge" | |||
| android:text="@string/tv_editLok_name" | |||
| android:id="@+id/tv_editLok_name" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginTop="43dp" /> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:textAppearance="?android:attr/textAppearanceLarge" | |||
| android:text="@string/tv_editLok_adresse" | |||
| android:id="@+id/tv_editLok_adresse" | |||
| android:layout_marginTop="65dp" | |||
| android:layout_below="@+id/tv_editLok_name" | |||
| android:layout_alignLeft="@+id/tv_editLok_name" | |||
| android:layout_alignStart="@+id/tv_editLok_name" | |||
| android:layout_centerHorizontal="true"/> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:textAppearance="?android:attr/textAppearanceLarge" | |||
| android:text="@string/tv_editLok_maxspeed" | |||
| android:id="@+id/tv_editLok_maxspeed" | |||
| android:layout_centerVertical="true" | |||
| android:layout_centerHorizontal="true" /> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/btn_addlok_save" | |||
| android:id="@+id/btn_editLok_save" | |||
| android:layout_marginTop="63dp" | |||
| android:layout_below="@+id/et_editLok_maxspeed" | |||
| android:layout_centerHorizontal="true" /> | |||
| <EditText | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/et_editLok_name" | |||
| android:layout_below="@+id/tv_editLok_name" | |||
| android:layout_centerHorizontal="true" /> | |||
| <EditText | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/et_editLok_adresse" | |||
| android:layout_below="@+id/tv_editLok_adresse" | |||
| android:layout_centerHorizontal="true" /> | |||
| <EditText | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/et_editLok_maxspeed" | |||
| android:layout_below="@+id/tv_editLok_maxspeed" | |||
| android:layout_centerHorizontal="true" /> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/delete_Lok" | |||
| android:id="@+id/btn_editLok_delete" | |||
| android:layout_below="@+id/btn_editLok_save" | |||
| android:layout_centerHorizontal="true" /> | |||
| </RelativeLayout> | |||
| @@ -0,0 +1,86 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <RelativeLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| xmlns:android="http://schemas.android.com/apk/res/android" | |||
| android:background="#ff9bffc5"> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/btn_richtung_text" | |||
| android:id="@+id/btn_richtung" | |||
| android:layout_marginBottom="58dp" | |||
| android:layout_alignParentBottom="true" | |||
| android:layout_centerHorizontal="true" /> | |||
| <SeekBar | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:id="@+id/seekBar" | |||
| android:rotation="270" | |||
| android:minWidth="250dp" | |||
| android:layout_below="@+id/lok_name" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginTop="131dp" /> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/lok_name" | |||
| android:id="@+id/lok_name" | |||
| android:layout_alignParentTop="true" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginTop="41dp" | |||
| android:textSize="30sp" /> | |||
| <CheckBox | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/funktion_1" | |||
| android:id="@+id/funktion_1" | |||
| android:layout_below="@+id/lok_name" | |||
| android:layout_toLeftOf="@+id/lok_name" | |||
| android:layout_marginTop="45dp" | |||
| android:onClick="onCheckboxClicked" /> | |||
| <CheckBox | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/funktion_3" | |||
| android:id="@+id/funktion_3" | |||
| android:layout_alignTop="@+id/funktion_1" | |||
| android:layout_toRightOf="@+id/lok_name" | |||
| android:onClick="onCheckboxClicked" /> | |||
| <CheckBox | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/funktion_2" | |||
| android:id="@+id/funktion_2" | |||
| android:layout_alignTop="@+id/seekBar" | |||
| android:layout_alignLeft="@+id/funktion_1" | |||
| android:layout_alignStart="@+id/funktion_1" | |||
| android:onClick="onCheckboxClicked" /> | |||
| <CheckBox | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/funktion_4" | |||
| android:id="@+id/funktion_4" | |||
| android:layout_alignTop="@+id/seekBar" | |||
| android:layout_alignLeft="@+id/funktion_3" | |||
| android:layout_alignStart="@+id/funktion_3" | |||
| android:onClick="onCheckboxClicked" /> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:textAppearance="?android:attr/textAppearanceLarge" | |||
| android:text="Large Text" | |||
| android:id="@+id/tv_direction" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginTop="470dp"/> | |||
| </RelativeLayout> | |||
| @@ -0,0 +1,45 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:paddingLeft="@dimen/activity_horizontal_margin" | |||
| android:paddingRight="@dimen/activity_horizontal_margin" | |||
| android:paddingTop="@dimen/activity_vertical_margin" | |||
| android:paddingBottom="@dimen/activity_vertical_margin" | |||
| tools:context=".MyActivity$PlaceholderFragment"> | |||
| <TextView | |||
| android:id="@+id/section_label" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" /> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/btn_connect_text" | |||
| android:id="@+id/btn_connect" | |||
| android:layout_below="@+id/section_label" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginTop="67dp" /> | |||
| <Button | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/btn_quit_text" | |||
| android:id="@+id/btn_quit" | |||
| android:layout_alignParentBottom="true" | |||
| android:layout_centerHorizontal="true" | |||
| android:layout_marginBottom="105dp" /> | |||
| <Switch | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="@string/select_ip_txt" | |||
| android:id="@+id/select_ip" | |||
| android:layout_centerVertical="true" | |||
| android:layout_centerHorizontal="true" | |||
| android:textSize="24dp" /> | |||
| </RelativeLayout> | |||
| @@ -0,0 +1,9 @@ | |||
| <ListView xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:choiceMode="singleChoice" | |||
| android:divider="@android:color/transparent" | |||
| android:dividerHeight="0dp" | |||
| android:background="#cccc" | |||
| tools:context=".NavigationDrawerFragment" /> | |||
| @@ -0,0 +1,8 @@ | |||
| <menu xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| tools:context="de.erich.railcontrol.EditLok" > | |||
| <item android:id="@+id/action_settings" | |||
| android:title="@string/action_settings" | |||
| android:orderInCategory="100" | |||
| android:showAsAction="never" /> | |||
| </menu> | |||
| @@ -0,0 +1,6 @@ | |||
| <menu xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <item android:id="@+id/action_settings" | |||
| android:title="@string/action_settings" | |||
| android:orderInCategory="100" | |||
| android:showAsAction="never" /> | |||
| </menu> | |||
| @@ -0,0 +1,11 @@ | |||
| <menu xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| tools:context=".MyActivity" > | |||
| <item android:id="@+id/action_example" | |||
| android:title="@string/action_example" | |||
| android:showAsAction="withText|ifRoom" /> | |||
| <item android:id="@+id/action_settings" | |||
| android:title="@string/action_settings" | |||
| android:orderInCategory="100" | |||
| android:showAsAction="never" /> | |||
| </menu> | |||
| @@ -0,0 +1,6 @@ | |||
| <resources> | |||
| <!-- Example customization of dimensions originally defined in res/values/dimens.xml | |||
| (such as screen margins) for screens with more than 820dp of available width. This | |||
| would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | |||
| <dimen name="activity_horizontal_margin">64dp</dimen> | |||
| </resources> | |||
| @@ -0,0 +1,9 @@ | |||
| <resources> | |||
| <!-- Default screen margins, per the Android Design guidelines. --> | |||
| <dimen name="activity_horizontal_margin">16dp</dimen> | |||
| <dimen name="activity_vertical_margin">16dp</dimen> | |||
| <!-- Per the design guidelines, navigation drawers should be between 240dp and 320dp: | |||
| https://developer.android.com/design/patterns/navigation-drawer.html --> | |||
| <dimen name="navigation_drawer_width">240dp</dimen> | |||
| </resources> | |||
| @@ -0,0 +1,42 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <resources> | |||
| <string name="app_name">Railcontrol</string> | |||
| <string name="title_section1">Startseite</string> | |||
| <string name="title_section2">Konfiguration</string> | |||
| <string name="title_section3">E 10</string> | |||
| <string name="navigation_drawer_open">Open navigation drawer</string> | |||
| <string name="navigation_drawer_close">Close navigation drawer</string> | |||
| <string name="action_example">Strom</string> | |||
| <string name="action_settings">Lok ändern</string> | |||
| <string name="btn_connect_text">Verbinden</string> | |||
| <string name="btn_send_text">Senden</string> | |||
| <string name="btn_quit_text">Trennen</string> | |||
| <string name="btn_richtung_text">Richtungswechsel</string> | |||
| <string name="hello_blank_fragment">Hello blank fragment</string> | |||
| <string name="lok_name">E 10</string> | |||
| <string name="funktion_1">Funktion 1</string> | |||
| <string name="funktion_2">Funktion 2</string> | |||
| <string name="funktion_3">Funktion 3</string> | |||
| <string name="funktion_4">Funktion 4</string> | |||
| <string name="select_ip_txt">Online</string> | |||
| <string name="tv_ip">IP - Adresse</string> | |||
| <string name="tv_port">Port</string> | |||
| <string name="btn_accept">Speichern</string> | |||
| <string name="btn_add_lok">Lok hinzufügen</string> | |||
| <string name="tv_addlok_name">Name</string> | |||
| <string name="tv_addlok_adresse">Adresse</string> | |||
| <string name="tv_addlok_maxspeed">Geschwindigkeitsstufen</string> | |||
| <string name="btn_addlok_save">Speichern</string> | |||
| <string name="et_addlok_maxspeed">28</string> | |||
| <string name="btn_addlok_cancel">Abbrechen</string> | |||
| <string name="btn_saveConfig">Konfiguration speichern</string> | |||
| <string name="btn_editLok">Lok ändern</string> | |||
| /> <string name="title_activity_edit_lok">EditLokActivity</string> | |||
| <string name="hello_world">Hello world!</string> | |||
| <string name="tv_editLok_name">Name</string> | |||
| <string name="tv_editLok_adresse">Adresse</string> | |||
| <string name="tv_editLok_maxspeed">Geschwindigkeitsstufen</string> | |||
| <string name="delete_Lok">Lok löschen</string> | |||
| </resources> | |||
| @@ -0,0 +1,8 @@ | |||
| <resources> | |||
| <!-- Base application theme. --> | |||
| <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar"> | |||
| <!-- Customize your theme here. --> | |||
| </style> | |||
| </resources> | |||