Skip to content

Commit 2cc00a7

Browse files
committed
Solve issues with orientation changes
1 parent b9e7123 commit 2cc00a7

File tree

12 files changed

+39
-14
lines changed

12 files changed

+39
-14
lines changed

Android/MMEAndroid/app/src/main/AndroidManifest.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
android:exported="true" />
2626

2727
<activity
28-
android:label="Mental Model Elicitation"
28+
android:label="Mental Model Mapping"
2929
android:name=".StartActivity">
3030
<intent-filter>
3131
<action android:name="android.intent.action.MAIN"/>
@@ -54,9 +54,12 @@
5454

5555
</activity>
5656

57+
<!-- Set config change to prevent webview from reloading on orientation change -->
5758
<activity
5859
android:label="Model Mapping"
5960
android:name=".MainActivity"
61+
android:screenOrientation="landscape"
62+
android:configChanges="keyboardHidden|orientation|screenSize|layoutDirection|uiMode"
6063
android:parentActivityName=".HomeActivity" >
6164
<meta-data
6265
android:name="android.support.PARENT_ACTIVITY"

Android/MMEAndroid/app/src/main/java/com/example/mmeandroid/MainActivity.kt

+19-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.app.DownloadManager
55
import android.content.ContentValues
66
import android.content.Context
77
import android.content.pm.PackageManager
8+
import android.content.res.Configuration
89
import android.media.AudioManager
910
import android.net.Uri
1011
import android.os.Bundle
@@ -43,16 +44,18 @@ class MainActivity : AppCompatActivity() {
4344
actionBar.setDisplayShowTitleEnabled(false)
4445

4546
webView = findViewById(R.id.webView)
46-
webView!!.setDownloadListener { url, _, _, _, _ -> onDownload(url) }
4747

48-
webView!!.setWebViewClient(object : WebViewClient() {
49-
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
50-
webView!!.loadUrl(url)
51-
return true
52-
}
53-
})
5448

5549
if (savedInstanceState == null) {
50+
webView!!.setDownloadListener { url, _, _, _, _ -> onDownload(url) }
51+
52+
webView!!.setWebViewClient(object : WebViewClient() {
53+
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
54+
webView!!.loadUrl(url)
55+
return true
56+
}
57+
})
58+
5659
webView!!.settings.javaScriptEnabled = true
5760
webView!!.settings.databaseEnabled = true
5861
webView!!.settings.domStorageEnabled = true
@@ -70,8 +73,17 @@ class MainActivity : AppCompatActivity() {
7073
webView!!.settings.mediaPlaybackRequiresUserGesture = false
7174
}
7275
}
76+
else {
77+
webView!!.restoreState(savedInstanceState)
78+
}
7379
}
7480

81+
82+
public override fun onConfigurationChanged(newConfig: Configuration) {
83+
super.onConfigurationChanged(newConfig)
84+
}
85+
86+
7587
public override fun onPause() {
7688
webView!!.onPause()
7789
webView!!.pauseTimers()

Android/MMEAndroid/app/src/main/java/com/example/mmeandroid/UploadActivity.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ class UploadActivity : AppCompatActivity() {
145145
listView[fileType] = ArrayAdapter(this, R.layout.list_row, ArrayList<String>())
146146
val list = findViewById<ListView>(viewID)
147147
list.adapter = listView[fileType]
148+
149+
list.isFastScrollAlwaysVisible = true
150+
148151
}
149152

150153

@@ -214,7 +217,7 @@ class UploadActivity : AppCompatActivity() {
214217
}
215218
catch (e: Exception) {
216219
Dialog(this@UploadActivity).showInformation(tag, warningOnImportFailure)
217-
throw java.lang.Exception("Failure while reading file $fileName!")
220+
throw java.lang.Exception("Failure while reading media sources file $fileName!")
218221
}
219222

220223
return fileContent
@@ -249,15 +252,15 @@ class UploadActivity : AppCompatActivity() {
249252
val prefix = content.substringBefore("{")
250253

251254
if (json.trimmedLength() < 1 || prefix.trimmedLength() < 1) {
252-
throw java.lang.Exception("Content of mediaSources.js have format 'mediaSources = JSONOBJECT'.")
255+
throw java.lang.Exception("Content of media sources file must have format 'mediaSources = JSONOBJECT'.")
253256
}
254257

255258
mediaListPrefix = prefix
256259
try {
257260
mediaList = JSONObject(json)
258261
}
259262
catch (e: ClassCastException) {
260-
throw java.lang.Exception( "Content of mediaSources.js must have format 'mediaSources = JSONOBJECT'.")
263+
throw java.lang.Exception( "Content of media sources file must have format 'mediaSources = JSONOBJECT'.")
261264

262265
}
263266
try {
@@ -268,6 +271,7 @@ class UploadActivity : AppCompatActivity() {
268271
catch (e: ClassCastException) {
269272
throw java.lang.Exception("Properties 'audio', 'video' and 'images' must exist in JSON object and contain a list of file names.")
270273
}
274+
271275
}
272276

273277

Android/MMEAndroid/app/src/main/res/layout/activity_upload.xml

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
android:paddingStart="20dp"
101101
android:divider="@null"
102102
android:dividerHeight="0dp"
103+
android:scrollbars="vertical"
104+
android:scrollbarAlwaysDrawVerticalTrack="true"
103105
android:fastScrollEnabled="true"/>
104106

105107
</LinearLayout>
@@ -136,6 +138,8 @@
136138
android:paddingStart="20dp"
137139
android:divider="@null"
138140
android:dividerHeight="0dp"
141+
android:scrollbars="vertical"
142+
android:scrollbarAlwaysDrawVerticalTrack="true"
139143
android:fastScrollEnabled="true"/>
140144

141145
</LinearLayout>
@@ -172,6 +176,8 @@
172176
android:paddingStart="20dp"
173177
android:divider="@null"
174178
android:dividerHeight="0dp"
179+
android:scrollbars="vertical"
180+
android:scrollbarAlwaysDrawVerticalTrack="true"
175181
android:fastScrollEnabled="true"/>
176182

177183
</LinearLayout>

Android/MMEAndroid/app/src/main/res/layout/toolbar.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
xmlns:android="http://schemas.android.com/apk/res/android"
99
xmlns:app="http://schemas.android.com/apk/res-auto"
1010
android:background="@drawable/banner_gradient_small"
11-
app:theme="@style/ToolBarStyle">
11+
android:theme="@style/ToolBarStyle">
1212
<ImageView
1313
android:id="@+id/bannerImage"
1414
android:layout_width="wrap_content"

Android/MMEAndroid/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.31'
4+
ext.kotlin_version = '1.3.61'
55
repositories {
66
google()
77
jcenter()
88

99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.5.2'
11+
classpath 'com.android.tools.build:gradle:3.5.3'
1212
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1313
}
1414
}

resources/M-TOOL_narrow_small.png

47.3 KB
Loading
2.98 KB
Loading

resources/M-Tool_wide.png

72.1 KB
Loading

resources/banner_narrow.png

-107 KB
Binary file not shown.

resources/banner_wide.png

-146 KB
Binary file not shown.

www/video/Introduction.mp4

29.2 MB
Binary file not shown.

0 commit comments

Comments
 (0)