fixed app crash on Server API call while offline usage

also changed minor things like app themes and SDK-compile version
This commit is contained in:
SLINIcraftet204 2022-04-21 15:36:31 +02:00
parent 63605096bb
commit 93a469d24d
10 changed files with 30 additions and 27 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@
.externalNativeBuild .externalNativeBuild
.cxx .cxx
local.properties local.properties
/.idea

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="adb-ce0616067bf09a2e02-5tRobR._adb-tls-connect._tcp" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-04-17T21:07:10.610502500Z" />
</component>
</project>

6
.idea/misc.xml generated
View File

@ -3,7 +3,13 @@
<component name="DesignSurface"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <map>
<entry key="..\:/Users/Fuitsu/AndroidStudioProjects/PointsALike/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.126" />
<entry key="..\:/Users/Fuitsu/AndroidStudioProjects/PointsALike/app/src/main/res/drawable/ic_launcher_background.xml" value="0.126" />
<entry key="..\:/Users/Fuitsu/AndroidStudioProjects/PointsALike/app/src/main/res/layout/activity_app_bar_bottom.xml" value="0.11510416666666666" />
<entry key="..\:/Users/Fuitsu/AndroidStudioProjects/PointsALike/app/src/main/res/layout/activity_main.xml" value="0.2" /> <entry key="..\:/Users/Fuitsu/AndroidStudioProjects/PointsALike/app/src/main/res/layout/activity_main.xml" value="0.2" />
<entry key="..\:/Users/Fuitsu/AndroidStudioProjects/PointsALike/app/src/main/res/layout/menu.xml" value="0.16354166666666667" />
<entry key="..\:/Users/Fuitsu/AndroidStudioProjects/PointsALike/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" value="0.2265" />
<entry key="..\:/Users/Fuitsu/AndroidStudioProjects/PointsALike/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" value="0.2265" />
</map> </map>
</option> </option>
</component> </component>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -4,7 +4,7 @@ plugins {
} }
android { android {
compileSdk 32 compileSdk 29
defaultConfig { defaultConfig {
applicationId "de.slini_haeher.pointsalike" applicationId "de.slini_haeher.pointsalike"
@ -34,9 +34,10 @@ android {
dependencies { dependencies {
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.4.0' implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.compose.material3:material3:1.0.0-alpha09'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

View File

@ -5,6 +5,7 @@ import android.os.Bundle
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import java.net.URL import java.net.URL
import java.net.UnknownHostException
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@ -24,13 +25,16 @@ private class DownloadFilesTask(private var m: MainActivity) : AsyncTask<String?
//val text: TextView = m.findViewById(R.id.textcount) //val text: TextView = m.findViewById(R.id.textcount)
//tv1.text = "Hello my New Project" //tv1.text = "Hello my New Project"
//val text = m.findViewById(0) as TextView //val text = m.findViewById(0) as TextView
if(session_id == "" || session_id == "Offline" || session_id == "not found")
session_id = URL("http://mc.chaos-craft.de:24000/pointsalike/login?user=noroot&pw=o7nq4L2zaK3QLYjryscFB5RvxR2HG7zN4sLwKSMjEMy4CXU3Smd4pT4BXpeCm7V2").readText() session_id = URL("http://mc.chaos-craft.de:24000/pointsalike/login?user=noroot&pw=o7nq4L2zaK3QLYjryscFB5RvxR2HG7zN4sLwKSMjEMy4CXU3Smd4pT4BXpeCm7V2").readText()
val t = "ID: " + session_id
//text.setText(t)
url = URL("http://mc.chaos-craft.de:24000/pointsalike/getCount?user=noroot&sessionId="+session_id+"").readText() url = URL("http://mc.chaos-craft.de:24000/pointsalike/getCount?user=noroot&sessionId="+session_id+"").readText()
} catch (e: java.io.FileNotFoundException){ } catch (e: java.io.FileNotFoundException){
e.printStackTrace() e.printStackTrace()
url = "not found" url = "not found"
session_id = "not available"
} catch (e: UnknownHostException){
url = "You are Offline"
session_id = "Offline"
} }
return 10L return 10L
} }
@ -40,7 +44,7 @@ private class DownloadFilesTask(private var m: MainActivity) : AsyncTask<String?
override fun onPostExecute(result: Long) { override fun onPostExecute(result: Long) {
val text = m.findViewById(R.id.textcount) as TextView val text = m.findViewById(R.id.textcount) as TextView
val t = "Points: " + url.substring(2, url.length-3) val t = "Points: " + url
text.setText(t) text.setText(t)
} }
} }

View File

@ -3,7 +3,7 @@
<style name="Theme.PointsALike" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <style name="Theme.PointsALike" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. --> <!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item> <item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorPrimaryVariant">@color/cyan_800</item>
<item name="colorOnPrimary">@color/black</item> <item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. --> <!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item> <item name="colorSecondary">@color/teal_200</item>

View File

@ -7,4 +7,5 @@
<color name="teal_700">#FF018786</color> <color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="cyan_800">#00838F</color>
</resources> </resources>

View File

@ -3,7 +3,7 @@
<style name="Theme.PointsALike" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <style name="Theme.PointsALike" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. --> <!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item> <item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorPrimaryVariant">@color/cyan_800</item>
<item name="colorOnPrimary">@color/white</item> <item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. --> <!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item> <item name="colorSecondary">@color/teal_200</item>

View File

@ -15,6 +15,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# Android operating system, and which are packaged with your app"s APK # Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn # https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete": # Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the # Enables namespacing of each library's R class so that its R class includes only the