MainActivity.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package de.tu_darmstadt.informatik.tk.olir;
  2. import android.content.Intent;
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.util.TypedValue;
  6. import android.view.KeyEvent;
  7. import android.view.View;
  8. public class MainActivity extends AppCompatActivity {
  9. public static String stringFalse = "";
  10. public static String stringTrue = "";
  11. private static DrawView drawView;
  12. private float scale;
  13. @Override
  14. protected void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16. setContentView(R.layout.activity_main);
  17. //FROM http://stackoverflow.com/questions/8656968/convert-mm-to-pixels 17.3.17 16.30
  18. scale = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 1,
  19. getResources().getDisplayMetrics());
  20. /*drawView = (DrawView) this.findViewById(R.id.drawView);
  21. drawView.setScale(scale);
  22. drawView.setBackgroundColor(Color.WHITE);
  23. this.findViewById(R.id.button2).setOnTouchListener(new View.OnTouchListener() {
  24. @Override
  25. public boolean onTouch(View v, MotionEvent event) {
  26. if (event.getAction() == MotionEvent.ACTION_DOWN ) {
  27. changeText(v);
  28. return true;
  29. }
  30. return false;
  31. }
  32. });*/
  33. }
  34. public void addObject(View view) {
  35. Intent intent = new Intent(this, ObjectsActivity.class);
  36. startActivity(intent);
  37. }
  38. public void changeText(View view) {
  39. /*TextView text = (TextView)this.findViewById(R.id.textView2);
  40. text.setText(stringTrue);
  41. text.setTextColor(Color.RED);*/
  42. }
  43. @Override
  44. public boolean onKeyDown(int keyCode, KeyEvent event) {
  45. if (keyCode == KeyEvent.KEYCODE_BACK
  46. && event.getRepeatCount() == 0) {
  47. this.finishAffinity();
  48. return true;
  49. }
  50. return super.onKeyDown(keyCode, event);
  51. }
  52. }