diff --git a/app/src/main/java/de/jg_cody/Teraplex/ui/Terminal/TerminalFragment.java b/app/src/main/java/de/jg_cody/Teraplex/ui/Terminal/TerminalFragment.java
index a38e908..550e9d6 100644
--- a/app/src/main/java/de/jg_cody/Teraplex/ui/Terminal/TerminalFragment.java
+++ b/app/src/main/java/de/jg_cody/Teraplex/ui/Terminal/TerminalFragment.java
@@ -41,7 +41,7 @@ public class TerminalFragment extends Fragment {
}
- return true;
+ return false;
}
});
terminal_textView = (TextView) root.findViewById(R.id.terminal_textView);
@@ -50,7 +50,7 @@ public class TerminalFragment extends Fragment {
terminal = new Terminal();
while (true) {
try {
- getActivity().runOnUiThread(new Runnable() {
+ requireActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
diff --git a/app/src/main/java/de/jg_cody/Teraplex/ui/intro/IntroFragment.java b/app/src/main/java/de/jg_cody/Teraplex/ui/intro/IntroFragment.java
index 1274b5d..0efa770 100644
--- a/app/src/main/java/de/jg_cody/Teraplex/ui/intro/IntroFragment.java
+++ b/app/src/main/java/de/jg_cody/Teraplex/ui/intro/IntroFragment.java
@@ -51,18 +51,10 @@ public class IntroFragment extends Fragment {
videoBG.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
- float videoRatio = mediaPlayer.getVideoWidth() / (float) mediaPlayer.getVideoHeight();
- float screenRatio = videoBG.getWidth() / (float)
- videoBG.getHeight();
- float scaleX = videoRatio / screenRatio;
- if (scaleX >= 1f) {
- videoBG.setScaleX(scaleX);
- } else {
- videoBG.setScaleY(1f / scaleX);
- }
+ setDimension();
mMediaPlayer = mediaPlayer;
// We want our video to play over and over so we set looping to true.
- mMediaPlayer.setLooping(true);
+ mMediaPlayer.setLooping(false);
// We then seek to the current position if it has been set and play the video.
if (mCurrentVideoPosition != 0) {
mMediaPlayer.seekTo(mCurrentVideoPosition);
@@ -99,4 +91,30 @@ public class IntroFragment extends Fragment {
mMediaPlayer.release();
mMediaPlayer = null;
}
+ private void setDimension() {
+ // Adjust the size of the video
+ // so it fits on the screen
+ float videoProportion = getVideoProportion();
+ int screenWidth = getResources().getDisplayMetrics().widthPixels;
+ int screenHeight = getResources().getDisplayMetrics().heightPixels;
+ float screenProportion = (float) screenHeight / (float) screenWidth;
+ android.view.ViewGroup.LayoutParams lp = videoBG.getLayoutParams();
+
+ if (videoProportion < screenProportion) {
+ lp.height= screenHeight;
+ lp.width = (int) ((float) screenHeight / videoProportion);
+ } else {
+ lp.width = screenWidth;
+ lp.height = (int) ((float) screenWidth * videoProportion);
+ }
+ videoBG.setLayoutParams(lp);
+ }
+
+ // This method gets the proportion of the video that you want to display.
+// I already know this ratio since my video is hardcoded, you can get the
+// height and width of your video and appropriately generate the proportion
+// as :height/width
+ private float getVideoProportion(){
+ return 2.22f;
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_intro.xml b/app/src/main/res/layout/fragment_intro.xml
index 1bd4ed9..aa017a8 100644
--- a/app/src/main/res/layout/fragment_intro.xml
+++ b/app/src/main/res/layout/fragment_intro.xml
@@ -12,9 +12,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="0.0" />
+ app:layout_constraintTop_toTopOf="parent" />
\ No newline at end of file
diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml
index 1831727..d149365 100644
--- a/app/src/main/res/menu/activity_main_drawer.xml
+++ b/app/src/main/res/menu/activity_main_drawer.xml
@@ -16,7 +16,7 @@
+ android:title="@string/menu_terminal" />
BENUTZERNAME
PASSWORT
HOME
- KONSOLE
+ TERMINAL
KÜCHE
ZEITSTEUERUNG
SCHLAFZIMMER
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d62503e..d798896 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -61,7 +61,7 @@
IN COOPERATION WITH
HOME
- CONSOLE
+ TERMINAL
KITCHEN
TIME-CONTROL
BEDROOM