Browse Source

init

master
pl0301 3 weeks ago
commit
2167050f40
  1. BIN
      .gradle/7.5.1/checksums/checksums.lock
  2. BIN
      .gradle/7.5.1/checksums/md5-checksums.bin
  3. BIN
      .gradle/7.5.1/checksums/sha1-checksums.bin
  4. BIN
      .gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock
  5. 0
      .gradle/7.5.1/dependencies-accessors/gc.properties
  6. BIN
      .gradle/7.5.1/executionHistory/executionHistory.bin
  7. BIN
      .gradle/7.5.1/executionHistory/executionHistory.lock
  8. BIN
      .gradle/7.5.1/fileChanges/last-build.bin
  9. BIN
      .gradle/7.5.1/fileHashes/fileHashes.bin
  10. BIN
      .gradle/7.5.1/fileHashes/fileHashes.lock
  11. BIN
      .gradle/7.5.1/fileHashes/resourceHashesCache.bin
  12. 0
      .gradle/7.5.1/gc.properties
  13. BIN
      .gradle/8.7/checksums/checksums.lock
  14. BIN
      .gradle/8.7/checksums/md5-checksums.bin
  15. BIN
      .gradle/8.7/checksums/sha1-checksums.bin
  16. 0
      .gradle/8.7/dependencies-accessors/gc.properties
  17. BIN
      .gradle/8.7/executionHistory/executionHistory.bin
  18. BIN
      .gradle/8.7/executionHistory/executionHistory.lock
  19. BIN
      .gradle/8.7/fileChanges/last-build.bin
  20. BIN
      .gradle/8.7/fileHashes/fileHashes.bin
  21. BIN
      .gradle/8.7/fileHashes/fileHashes.lock
  22. BIN
      .gradle/8.7/fileHashes/resourceHashesCache.bin
  23. 0
      .gradle/8.7/gc.properties
  24. BIN
      .gradle/buildOutputCleanup/buildOutputCleanup.lock
  25. 2
      .gradle/buildOutputCleanup/cache.properties
  26. BIN
      .gradle/buildOutputCleanup/outputFiles.bin
  27. 2
      .gradle/config.properties
  28. BIN
      .gradle/file-system.probe
  29. 0
      .gradle/vcs-1/gc.properties
  30. 3
      .idea/.gitignore
  31. 6
      .idea/AndroidProjectSystem.xml
  32. 1041
      .idea/caches/deviceStreaming.xml
  33. 6
      .idea/compiler.xml
  34. 6
      .idea/copilot.data.migration.agent.xml
  35. 6
      .idea/copilot.data.migration.ask.xml
  36. 6
      .idea/copilot.data.migration.ask2agent.xml
  37. 6
      .idea/copilot.data.migration.edit.xml
  38. 18
      .idea/deploymentTargetSelector.xml
  39. 13
      .idea/deviceManager.xml
  40. 19
      .idea/gradle.xml
  41. 25
      .idea/jarRepositories.xml
  42. 10
      .idea/migrations.xml
  43. 70
      .idea/misc.xml
  44. 17
      .idea/runConfigurations.xml
  45. 6
      .idea/vcs.xml
  46. 12
      app/build/generated/source/buildConfig/debug/com/likesoft/mdedal/BuildConfig.java
  47. 129
      app/src/main/AndroidManifest.xml
  48. BIN
      app/src/main/ic_new_button-web.png
  49. 72
      app/src/main/java/com/likesoft/mdedal/Alarm.java
  50. 141
      app/src/main/java/com/likesoft/mdedal/AsyncCallChangeDate.java
  51. 19
      app/src/main/java/com/likesoft/mdedal/AutoStart.java
  52. 1400
      app/src/main/java/com/likesoft/mdedal/CalendarActivity.java
  53. 122
      app/src/main/java/com/likesoft/mdedal/DatePickerFragment.java
  54. 4803
      app/src/main/java/com/likesoft/mdedal/DedalActivity.java
  55. 616
      app/src/main/java/com/likesoft/mdedal/DedalDownloadService.java
  56. 538
      app/src/main/java/com/likesoft/mdedal/DedalHelper.java
  57. 418
      app/src/main/java/com/likesoft/mdedal/DedalHttpConnection.java
  58. 108
      app/src/main/java/com/likesoft/mdedal/DedalSSLSocketFactory.java
  59. 1680
      app/src/main/java/com/likesoft/mdedal/DedalService.java
  60. 655
      app/src/main/java/com/likesoft/mdedal/DokumentyKollektoActivity.java
  61. 266
      app/src/main/java/com/likesoft/mdedal/DokumentyKollektoService.java
  62. 331
      app/src/main/java/com/likesoft/mdedal/FragmentMainActivity.java
  63. 252
      app/src/main/java/com/likesoft/mdedal/GPSTracker.java
  64. 374
      app/src/main/java/com/likesoft/mdedal/KPActivity.java
  65. 267
      app/src/main/java/com/likesoft/mdedal/KPWplatyActivity.java
  66. 3473
      app/src/main/java/com/likesoft/mdedal/ListActivity.java
  67. 179
      app/src/main/java/com/likesoft/mdedal/Log.java
  68. 1373
      app/src/main/java/com/likesoft/mdedal/MainActivity.java
  69. 410
      app/src/main/java/com/likesoft/mdedal/MyXMLSerializer.java
  70. 295
      app/src/main/java/com/likesoft/mdedal/PreferActivity.java
  71. 294
      app/src/main/java/com/likesoft/mdedal/RefreshLayoutAndThread.java
  72. 817
      app/src/main/java/com/likesoft/mdedal/TableHeadersActivity.java
  73. 99
      app/src/main/java/com/likesoft/mdedal/TimePickerFragment.java
  74. 45
      app/src/main/java/com/likesoft/mdedal/gui/BorderLinearLayout.java
  75. 38
      app/src/main/java/com/likesoft/mdedal/gui/BorderTextView.java
  76. 20
      app/src/main/java/com/likesoft/mdedal/gui/ButtonDate.java
  77. 28
      app/src/main/java/com/likesoft/mdedal/gui/MLinearLayout.java
  78. 25
      app/src/main/java/com/likesoft/mdedal/gui/MTextView.java
  79. 7
      app/src/main/java/com/likesoft/mdedaldemo/test.java
  80. BIN
      app/src/main/res/drawable-hdpi/ic_button_zen.png
  81. BIN
      app/src/main/res/drawable-hdpi/ic_dedal.png
  82. BIN
      app/src/main/res/drawable-hdpi/ic_launcher.png
  83. BIN
      app/src/main/res/drawable-ldpi/logo.png
  84. BIN
      app/src/main/res/drawable-mdpi/ic_button_zen.png
  85. BIN
      app/src/main/res/drawable-mdpi/ic_dedal.png
  86. BIN
      app/src/main/res/drawable-mdpi/ic_launcher.png
  87. BIN
      app/src/main/res/drawable-xhdpi/ic_button_zen.png
  88. BIN
      app/src/main/res/drawable-xhdpi/ic_dedal.png
  89. BIN
      app/src/main/res/drawable-xhdpi/ic_launcher.png
  90. BIN
      app/src/main/res/drawable-xxhdpi/ic_button_zen.png
  91. BIN
      app/src/main/res/drawable-xxhdpi/ic_dedal.png
  92. BIN
      app/src/main/res/drawable-xxhdpi/ic_launcher.png
  93. 12
      app/src/main/res/layout/activity_calendar.xml
  94. 50
      app/src/main/res/layout/activity_list.xml
  95. 30
      app/src/main/res/layout/activity_main.xml
  96. 112
      app/src/main/res/layout/activity_prefer.xml
  97. 21
      app/src/main/res/layout/activity_tableheaders.xml
  98. 8
      app/src/main/res/layout/jakis_fragment.xml
  99. 15
      app/src/main/res/layout/listrow.xml
  100. 9
      app/src/main/res/menu/list.xml
  101. Some files were not shown because too many files have changed in this diff Show More

BIN
.gradle/7.5.1/checksums/checksums.lock

Binary file not shown.

BIN
.gradle/7.5.1/checksums/md5-checksums.bin

Binary file not shown.

BIN
.gradle/7.5.1/checksums/sha1-checksums.bin

Binary file not shown.

BIN
.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock

Binary file not shown.

0
.gradle/7.5.1/dependencies-accessors/gc.properties

BIN
.gradle/7.5.1/executionHistory/executionHistory.bin

Binary file not shown.

BIN
.gradle/7.5.1/executionHistory/executionHistory.lock

Binary file not shown.

BIN
.gradle/7.5.1/fileChanges/last-build.bin

Binary file not shown.

BIN
.gradle/7.5.1/fileHashes/fileHashes.bin

Binary file not shown.

BIN
.gradle/7.5.1/fileHashes/fileHashes.lock

Binary file not shown.

BIN
.gradle/7.5.1/fileHashes/resourceHashesCache.bin

Binary file not shown.

0
.gradle/7.5.1/gc.properties

BIN
.gradle/8.7/checksums/checksums.lock

Binary file not shown.

BIN
.gradle/8.7/checksums/md5-checksums.bin

Binary file not shown.

BIN
.gradle/8.7/checksums/sha1-checksums.bin

Binary file not shown.

0
.gradle/8.7/dependencies-accessors/gc.properties

BIN
.gradle/8.7/executionHistory/executionHistory.bin

Binary file not shown.

BIN
.gradle/8.7/executionHistory/executionHistory.lock

Binary file not shown.

BIN
.gradle/8.7/fileChanges/last-build.bin

Binary file not shown.

BIN
.gradle/8.7/fileHashes/fileHashes.bin

Binary file not shown.

BIN
.gradle/8.7/fileHashes/fileHashes.lock

Binary file not shown.

BIN
.gradle/8.7/fileHashes/resourceHashesCache.bin

Binary file not shown.

0
.gradle/8.7/gc.properties

BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock

Binary file not shown.

2
.gradle/buildOutputCleanup/cache.properties

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
#Mon Nov 10 14:27:14 CET 2025
gradle.version=8.7

BIN
.gradle/buildOutputCleanup/outputFiles.bin

Binary file not shown.

2
.gradle/config.properties

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
#Sat Apr 26 00:35:27 CEST 2025
java.home=/home/darek/.jdks/jbr-17.0.14

BIN
.gradle/file-system.probe

Binary file not shown.

0
.gradle/vcs-1/gc.properties

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

6
.idea/AndroidProjectSystem.xml

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

1041
.idea/caches/deviceStreaming.xml

File diff suppressed because it is too large Load Diff

6
.idea/compiler.xml

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

6
.idea/copilot.data.migration.agent.xml

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

6
.idea/copilot.data.migration.ask.xml

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AskMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

6
.idea/copilot.data.migration.ask2agent.xml

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Ask2AgentMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

6
.idea/copilot.data.migration.edit.xml

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EditMigrationStateService">
<option name="migrationStatus" value="COMPLETED" />
</component>
</project>

18
.idea/deploymentTargetSelector.xml

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-11-10T20:03:10.979497202Z">
<Target type="DEFAULT_BOOT">
<handle>
<DeviceId pluginId="LocalEmulator" identifier="path=/home/darek/.android/avd/Pixel_3a_API_34_extension_level_7_x86_64.avd" />
</handle>
</Target>
</DropdownSelection>
<DialogSelection />
</SelectionState>
</selectionStates>
</component>
</project>

13
.idea/deviceManager.xml

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DeviceTable">
<option name="columnSorters">
<list>
<ColumnSorterState>
<option name="column" value="Name" />
<option name="order" value="ASCENDING" />
</ColumnSorterState>
</list>
</option>
</component>
</project>

19
.idea/gradle.xml

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

25
.idea/jarRepositories.xml

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://maven.google.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
</component>
</project>

10
.idea/migrations.xml

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

70
.idea/misc.xml

@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="SvnBranchConfigurationManager">
<option name="myConfigurationMap">
<map>
<entry key="$PROJECT_DIR$">
<value>
<SvnBranchConfiguration>
<option name="branchUrls">
<list>
<option value="http://wiki.likesoft.pl/svn/likesoft/CENEO%20narzedzia" />
<option value="http://wiki.likesoft.pl/svn/likesoft/Ceneo" />
<option value="http://wiki.likesoft.pl/svn/likesoft/Nowy%20folder" />
<option value="http://wiki.likesoft.pl/svn/likesoft/Polcan" />
<option value="http://wiki.likesoft.pl/svn/likesoft/Program%20lojalno%C5%9Bciowy" />
<option value="http://wiki.likesoft.pl/svn/likesoft/SMD" />
<option value="http://wiki.likesoft.pl/svn/likesoft/SmsGate" />
<option value="http://wiki.likesoft.pl/svn/likesoft/SmsGateServer" />
<option value="http://wiki.likesoft.pl/svn/likesoft/bramka.likesoft.pl" />
<option value="http://wiki.likesoft.pl/svn/likesoft/branches" />
<option value="http://wiki.likesoft.pl/svn/likesoft/conf" />
<option value="http://wiki.likesoft.pl/svn/likesoft/cukiernia-lasuch.pl" />
<option value="http://wiki.likesoft.pl/svn/likesoft/d%C4%99bina" />
<option value="http://wiki.likesoft.pl/svn/likesoft/db" />
<option value="http://wiki.likesoft.pl/svn/likesoft/dsmnet" />
<option value="http://wiki.likesoft.pl/svn/likesoft/emailer" />
<option value="http://wiki.likesoft.pl/svn/likesoft/faktury" />
<option value="http://wiki.likesoft.pl/svn/likesoft/foodandwood" />
<option value="http://wiki.likesoft.pl/svn/likesoft/gastronet" />
<option value="http://wiki.likesoft.pl/svn/likesoft/gastronet-ceneo" />
<option value="http://wiki.likesoft.pl/svn/likesoft/hooks" />
<option value="http://wiki.likesoft.pl/svn/likesoft/joga" />
<option value="http://wiki.likesoft.pl/svn/likesoft/kCMS" />
<option value="http://wiki.likesoft.pl/svn/likesoft/kmemo" />
<option value="http://wiki.likesoft.pl/svn/likesoft/komputery.szukam.co" />
<option value="http://wiki.likesoft.pl/svn/likesoft/locks" />
<option value="http://wiki.likesoft.pl/svn/likesoft/loyaltyshop.likesoft.pl" />
<option value="http://wiki.likesoft.pl/svn/likesoft/mmoffice" />
<option value="http://wiki.likesoft.pl/svn/likesoft/mmpartners" />
<option value="http://wiki.likesoft.pl/svn/likesoft/modu%C5%82y%20Prestashopa" />
<option value="http://wiki.likesoft.pl/svn/likesoft/morgulec.com" />
<option value="http://wiki.likesoft.pl/svn/likesoft/onlym" />
<option value="http://wiki.likesoft.pl/svn/likesoft/proxy_webservice" />
<option value="http://wiki.likesoft.pl/svn/likesoft/sitempap" />
<option value="http://wiki.likesoft.pl/svn/likesoft/skaner%20MaxComputers" />
<option value="http://wiki.likesoft.pl/svn/likesoft/skanerOfertCeneo" />
<option value="http://wiki.likesoft.pl/svn/likesoft/skanerOfertCeneoNajnowszaWersja" />
<option value="http://wiki.likesoft.pl/svn/likesoft/skrypty.bash" />
<option value="http://wiki.likesoft.pl/svn/likesoft/tools" />
<option value="http://wiki.likesoft.pl/svn/likesoft/ulepszeniaDlaSkanera" />
</list>
</option>
<option name="trunkUrl" value="http://wiki.likesoft.pl/svn/likesoft/trunk" />
</SvnBranchConfiguration>
</value>
</entry>
</map>
</option>
</component>
</project>

17
.idea/runConfigurations.xml

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>

6
.idea/vcs.xml

@ -0,0 +1,6 @@ @@ -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>

12
app/build/generated/source/buildConfig/debug/com/likesoft/mdedal/BuildConfig.java

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.likesoft.mdedal;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.likesoft.mdedal";
public static final String BUILD_TYPE = "debug";
public static final int VERSION_CODE = 54;
public static final String VERSION_NAME = "2.2.2";
}

129
app/src/main/AndroidManifest.xml

@ -0,0 +1,129 @@ @@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="54"
android:versionName="2.2.2" >
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Android 11+ All files access (requires user grant) -->
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- <uses-permission android:name="android.permission.WRITE_SETTINGS" />-->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.CAMERA "/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application
android:allowBackup="false"
android:icon="@drawable/ic_dedal"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
tools:targetApi="29">
<activity
android:name="com.likesoft.mdedal.MainActivity"
android:label="@string/sprawa"
android:screenOrientation="landscape"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".ListActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/title_activity_list"
android:screenOrientation="landscape"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!--<activity-->
<!--android:name="com.likesoft.mdedal.SettingsActivity"-->
<!--android:label="@string/title_activity_settings" >-->
<!--</activity>-->
<activity
android:name=".PreferActivity"
android:label="@string/title_activity_prefer" >
</activity>
<activity
android:name="com.likesoft.mdedal.TableHeadersActivity"
android:label="@string/title_activity_table_headers"
android:screenOrientation="landscape" >
</activity>
<activity
android:name="com.likesoft.mdedal.DokumentyKollektoActivity"
android:label="@string/title_activity_dokumenty_kollekto" >
</activity>
<activity
android:name="com.likesoft.mdedal.FragmentMainActivity"
android:screenOrientation="landscape"
android:label="@string/title_activity_fragment" >
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<service
android:name="com.likesoft.mdedal.DedalService"
android:enabled="true"
android:exported="true" >
</service>
<service
android:name="com.likesoft.mdedal.DedalDownloadService"
android:enabled="true"
android:exported="true" >
</service>
<service
android:name="com.likesoft.mdedal.DokumentyKollektoService"
android:enabled="true"
android:exported="true" >
</service>
<receiver
android:name="com.likesoft.mdedal.Alarm"
android:enabled="true"
android:exported="false"
android:process=":remote" />
<receiver
android:name="com.likesoft.mdedal.AutoStart"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<activity
android:name="com.likesoft.mdedal.CalendarActivity"
android:label="@string/title_activity_calendar"
android:screenOrientation="landscape" >
</activity>
<activity
android:name="com.likesoft.mdedal.KPActivity"
android:label="@string/title_activity_kp" >
</activity>
<activity
android:name="com.likesoft.mdedal.KPWplatyActivity"
android:label="@string/title_activity_kp_wplaty" >
</activity>
</application>
</manifest>

BIN
app/src/main/ic_new_button-web.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

72
app/src/main/java/com/likesoft/mdedal/Alarm.java

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
package com.likesoft.mdedal;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import java.util.Calendar;
public class Alarm extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Calendar cal_curr = Calendar.getInstance();
cal_curr.getTime();
int curr_hour = cal_curr.get(Calendar.HOUR_OF_DAY);
int START_WAKING_HOUR = 6;
int STOP_WAKING_HOUR = 21;
//int START_WAKING_HOUR = 0;
//int STOP_WAKING_HOUR = 24;
Log.d("my_debug", "curr_hour: "+curr_hour);
//Log.d("my_debug", "cal_curr: "+sdf.format( cal_curr.getTime())+", cal_start_waking: "+ sdf.format( cal_start_waking.getTime())+", cal_stop_waking: "+ sdf.format( cal_stop_waking.getTime()) );
if( curr_hour >= START_WAKING_HOUR && curr_hour < STOP_WAKING_HOUR ) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "mDedal:Alarm");
wl.acquire();
Log.d("my_debug", "Alarm, start service !");
// wystartuj/obudz serwis
Intent service = new Intent(context, DedalService.class);
context.startService(service);
wl.release();
}
}
public void SetAlarm(Context context)
{
AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i = new Intent(context, Alarm.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_IMMUTABLE);
// Resources res = getResources();
// int values[] = res.getIntArray(R.array.pref_sync_frequency_values);
//int sleepTime =values[refreshPos]*1000;
//long sleepTime = 1000L * 30L; // 5s
long sleepTime = 1000L * 3600L; // 1h
Log.d("my_debug", "setAlarm, sleepTime: "+sleepTime);
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + sleepTime, sleepTime, pi); // Millisec * Second * Minute
}
public void CancelAlarm(Context context)
{
Intent intent = new Intent(context, Alarm.class);
PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(sender);
}
}

141
app/src/main/java/com/likesoft/mdedal/AsyncCallChangeDate.java

@ -0,0 +1,141 @@ @@ -0,0 +1,141 @@
package com.likesoft.mdedal;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.widget.LinearLayout;
import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Created by darek on 2016-01-25.
*/
abstract class AsyncCallChangeDate extends AsyncTask<String, Void, Void> {
private Activity calendarActivity;
ProgressDialog progressDialog;
String response;
String id_zlecenia;
String kod_pola;
String wartosc;
LinearLayout movingEl;
public AsyncCallChangeDate(Activity calendarActivity, String id_zlecenia, String kod_pola, String wartosc) {
this.calendarActivity = calendarActivity;
//this.progressDialog = new ProgressDialog();
this.id_zlecenia = id_zlecenia;
this.kod_pola = kod_pola;
this.wartosc = wartosc;
//this.progressDialog = new ProgressDialog();
}
@Override
protected Void doInBackground(String... params) {
android.util.Log.d("my_debug", "doInBackground");
DedalHttpConnection con = new DedalHttpConnection(calendarActivity.getApplicationContext());
Map<String, String> params_post = new HashMap<String, String>();
params_post.put("id_zlecenia", id_zlecenia);
params_post.put("kod_pola", kod_pola);
params_post.put("wartosc", wartosc);
response = con.sendPost("public/ajax/zmien_wartosc_zlecenie_pole_stale.php", params_post);
return null;
}
@Override
protected void onPostExecute(Void result) {
android.util.Log.d("my_debug", "onPostExecute");
//this.progressDialog.dismiss();
Log.d("CalAct", "resp: "+response);
if( response != null && "true".equals(response) ) {
JSONObject jZlecenie = null;
try {
// read file
Context context = calendarActivity.getApplicationContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
File dLista = new File(prefs.getString("dir", "") + "/baza/lista.profil");
String sJson = DedalHelper.getFileContent(dLista.getAbsolutePath());
JSONObject jFile = new JSONObject(sJson);
JSONObject jProfiles = jFile.getJSONObject("profile");
Iterator keys = jProfiles.keys();
while (keys.hasNext()) {
String id_profilu_curr = (String) keys.next();
try {
JSONObject jProfil = jProfiles.getJSONObject(id_profilu_curr);
// if( !jProfil.has("zlecenia") || !"[]".equals(jProfil.getString("zlecenia")) ) {
// continue;
// }
JSONObject jZlecenia_local = jProfil.getJSONObject("zlecenia");
if (!jZlecenia_local.has(id_zlecenia))
continue;
jZlecenie = jZlecenia_local.getJSONObject(id_zlecenia);
//change value
if (jZlecenie.has(kod_pola)) {
jZlecenie.put(kod_pola, wartosc);
Log.d("CalAct", "kod_pola: " + kod_pola + "wartosc: " + wartosc);
}
}
catch (JSONException e) {
Log.e("DEDAL", "onPostExecute", e);
}
}
// save file
DedalHelper.putFileContent(prefs.getString("dir", "") + "/baza/lista.profil", jFile.toString());
// Toast.makeText(CalendarActivity.this, "Uaktualniono poprawnie",
// Toast.LENGTH_LONG).show();
loadInputs();
// movingEl.removeAllViews();
// movingEl.addView(getZlecenieElement(jZlecenie, jKolumny));
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
else {
reloadContent();
Toast.makeText(calendarActivity, "Wystąpił błąd podczas uaktulaniania, zmiany zostały cofnięte",
Toast.LENGTH_LONG).show();
Log.d("CalAct", "Błąd przy połaćzeniu do zmien_wartosc_zlecenie_pole_stale.php");
}
}
protected abstract void reloadContent();
abstract public void loadInputs();
@Override
protected void onPreExecute() {
android.util.Log.d("my_debug", "onPreExecute");
// Toast.makeText(CalendarActivity.this, "Rozpoczynam uaktualnianie ...",
// Toast.LENGTH_LONG).show();
}
@Override
protected void onProgressUpdate(Void... values) {
android.util.Log.i("my_debug", "onProgressUpdate");
}
}

19
app/src/main/java/com/likesoft/mdedal/AutoStart.java

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
package com.likesoft.mdedal;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class AutoStart extends BroadcastReceiver
{
Alarm alarm = new Alarm();
@Override
public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
{
Log.d("my_debug", "Autostart");
alarm.SetAlarm(context);
}
}
}

1400
app/src/main/java/com/likesoft/mdedal/CalendarActivity.java

File diff suppressed because it is too large Load Diff

122
app/src/main/java/com/likesoft/mdedal/DatePickerFragment.java

@ -0,0 +1,122 @@ @@ -0,0 +1,122 @@
package com.likesoft.mdedal;
import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.TextView;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* Created by darek on 2016-01-25.
*/
public class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
public Integer nr_zlecenia;
public Activity act;
public String data_walidacja_do = null;
public TextView tv = null;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
//<MWK> - jawne tworzenie obiektu - żeby przed return dodać DatePickerMode
// Create a new instance of DatePickerDialog and return it
DatePickerDialog dDlg = new DatePickerDialog(getActivity(), this, year, month, day);
dDlg.getDatePicker().setCalendarViewShown(true); //<MWK> - false -> true
dDlg.getDatePicker().setSpinnersShown(false); //<MWK> - cała linijka
return dDlg;
//</MWK>
}
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
Log.d("my_debug", "Wybrano edycje daty wizyty nr: " + nr_zlecenia + " nowy rok: " + year);
Calendar c = new GregorianCalendar(year, month, day);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String date_string = sdf.format(c.getTime());
//tv.setText(date_string);
TimePickerFragment newFragment_time = new TimePickerFragment();
newFragment_time.act = act;
newFragment_time.nr_zlecenia = nr_zlecenia;
newFragment_time.data_walidacja_do = data_walidacja_do;
newFragment_time.tv = tv;
newFragment_time.setDate = c;
newFragment_time.show(getFragmentManager(), "timePicker");
// ListActivity.this.finish();
// final Intent intent = new Intent();
// intent.setAction("blah");
// getActivity().sendBroadcast(intent);
// dismiss();
/*
Calendar c = new GregorianCalendar(year, month, day);
Calendar cToday = new GregorianCalendar();
Calendar data_walidacja_do_cal = null;
if( data_walidacja_do != null ) {
try {
data_walidacja_do_cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
data_walidacja_do_cal.setTime(sdf.parse(data_walidacja_do));// all done
} catch (ParseException e) {
e.printStackTrace();
}
}
if( cToday.compareTo(c)>0){
Toast.makeText(act.getApplicationContext(),
"Nie można wybrać daty wstecznej dla wizyty nr: " + nr_zlecenia,
Toast.LENGTH_LONG).show();
}
else if( data_walidacja_do_cal != null && c.compareTo(data_walidacja_do_cal)>0 ) {
Toast.makeText(act.getApplicationContext(),
"Nie można wybrać daty przekraczającej datę obsługi: " + data_walidacja_do,
Toast.LENGTH_LONG).show();
}
else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String cString = sdf.format(c.getTime());
AsyncCallChangeDate task = new AsyncCallChangeDate(act, nr_zlecenia + "", DATA_KOD, cString) {
@Override
protected void reloadContent() {
// drawContent();
final Intent intent = new Intent();
intent.setAction("blah");
getActivity().sendBroadcast(intent);
dismiss();
}
@Override
public void loadInputs() {
// loadJsons();
}
}; // week_day_dates[id_drop]);
task.execute();
}
*/
}
}

4803
app/src/main/java/com/likesoft/mdedal/DedalActivity.java

File diff suppressed because it is too large Load Diff

616
app/src/main/java/com/likesoft/mdedal/DedalDownloadService.java

@ -0,0 +1,616 @@ @@ -0,0 +1,616 @@
package com.likesoft.mdedal;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
//mport com.likesoft.mdedal.DedalDownloadService.WorkingThread;
public class DedalDownloadService extends Service{
private static final String SRV = "DedalDownloadService";
SharedPreferences prefs;
String hostPath = "";
String login = "";//prefs.getString("user", "");
String pass = "";//prefs.getString("password", "");
String gzip = "true";
private static void trustAllHosts() {
X509TrustManager easyTrustManager = new X509TrustManager() {
public void checkClientTrusted(
X509Certificate[] chain,
String authType) throws CertificateException {
// Oh, I am easy!
}
public void checkServerTrusted(
X509Certificate[] chain,
String authType) throws CertificateException {
Log.d("certyfikat", "Download -serverTrusted: " + Arrays.toString(chain));
// Oh, I am easy!
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {easyTrustManager};
// Install the all-trusting trust manager
try {
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
Log.e(SRV, "", e);
}
}
class WorkingDownloadThread implements Runnable {
WorkingThread _wt;
public WorkingDownloadThread(WorkingThread wt) {
// TODO Auto-generated constructor stub
_wt = wt;
}
@Override
public void run() {
// TODO Auto-generated method stub
_wt.pobierzZleceniaPrio();
File f=_wt.getNextFile() ;
while( f != null){
Log.d(SRV, "Watek pobiera zlecenie: " + f.getName());
_wt.pobierzZlecenie(f);
f=_wt.getNextFile() ;
}
}
}
@SuppressLint("DefaultLocale")
class WorkingThread implements Runnable {
public synchronized File getNextFile(){
File f = null;
if( curPosition < files.length){
f = files[curPosition];
curPosition++;
}
return f;
}
public void pobierzZleceniaPrio() {
File d_prio = new File(prefs.getString("dir", "") + "/queue_prio");//getApplicationContext().getFilesDir();
if( d_prio.isDirectory() ) {
String sf_prio = d_prio.getAbsolutePath();
Log.d(SRV,sf_prio);
File files_prio[] = d_prio.listFiles();
// pętla po priorytetowych (jeśli są)
for (int j = 0; j < files_prio.length; j++) {
String id_zlecenia_prio = files_prio[j].getName();
try {
Log.d(SRV, "zacznam pobierac: " + id_zlecenia_prio);
loadToDisk(id_zlecenia_prio);
files_prio[j].delete();
} catch (MalformedURLException e) {
Log.e("DEDAL", "Niepoprawny URL", e);
}
}
}
}
File files[];
int curPosition = 0;
public final int threadsNo = 10;
Thread wdt[] = new Thread[threadsNo];
@Override
public void run() {
Context context = getApplicationContext();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
hostPath = prefs.getString("hostName", "");
login = prefs.getString("user", "");
pass = DedalHelper.decodeB64(prefs.getString("password", ""));
File d = new File(prefs.getString("dir", "") + "/queue");//getApplicationContext().getFilesDir();
String sf = d.getAbsolutePath();
Log.d(SRV,sf);
files = d.listFiles();
// odpal watki
Log.d(SRV, "Start watkow pobierajacych zlecenia");
for( int i =0; i < threadsNo; i++){
wdt[i] = new Thread(new WorkingDownloadThread( this));
wdt[i].start();
}
// czekaj na zakonczenie
for( int i =0; i < threadsNo; i++){
try {
wdt[i].join();
} catch (InterruptedException e) {
Log.e(SRV, "przerwano watek", e);
}
}
Log.d(SRV,"Sleep");
}
public void pobierzZlecenie(File curFile) {
String id_zlecenia = "";
id_zlecenia = curFile.getName();
// PRIORYTETOWE
pobierzZleceniaPrio();
// ZWYKŁE
try {
File f_queue = new File(prefs.getString("dir", "") + "/queue/"+id_zlecenia);
if( f_queue.exists() ) {
Log.d(SRV, "zacznam pobierac: " + id_zlecenia);
loadToDisk(id_zlecenia);
File d_prio = new File(prefs.getString("dir", "") + "/queue_prio");//getApplicationContext().getFilesDir();
if( d_prio.isDirectory() ) {
File f_queue_prio = new File(prefs.getString("dir", "") + "/queue_prio/"+id_zlecenia);
if( f_queue_prio.exists() ) {
f_queue_prio.delete();
}
}
curFile.delete();
}
else {
Log.d(SRV, "plik: " + id_zlecenia + " nie istnieje w queue");
}
} catch (MalformedURLException e) {
Log.e("DEDAL", "Niepoprawny URL", e);
}
}
}
void loadToDisk(String m_id) throws MalformedURLException {
DedalHttpConnection con = new DedalHttpConnection(getApplicationContext());
Map<String, String> params_post = new HashMap<String, String>();
params_post.put("id_zlecenia", m_id);
params_post.put("gzip", gzip);
params_post.put("json", "true");
String sPost = con.sendPost("xml/getZlecenieXml.php", params_post);
Log.d(SRV, "loadToDisk odczytany bufor, size: " + sPost.length());
File myFileMod = new File(prefs.getString("dir", "") + "/baza/"+m_id+".mod");
if( myFileMod.exists()){
myFileMod.delete();
}
DedalHelper.putFileContent(prefs.getString("dir", "") + "/baza/"+m_id+".json", sPost);
// load fotos:
// 1. parse json
// usun wpis z tego zlecenia w pliku pliki_kollekto/statuses.json
String statPath = prefs.getString("dir", "") + "/pliki_kollekto/statuses.json";
String statJsString = readFileFromPath(statPath);
if( statJsString != null && !"".equals(statJsString) ) {
try {
JSONObject statJs = new JSONObject(statJsString);
if(statJs.has(m_id)) {
statJs.remove(m_id);
//writeFileToPath(statPath, statJs.toString());
DedalHelper.putFileContent(statPath, statJs.toString());
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
try {
JSONObject js = new JSONObject(sPost);
// 3. download files
JSONObject params = js.getJSONObject("param");
if( params.has("status") && ( params.getString("status").equals("przydz_nie_odeb") || params.getString("status").equals("przydz_odeb") ) ){
saveAttach(js, m_id);
Log.d("my_debug", "zapisuje pliki, zlecenie: "+m_id);
saveDokumentyKollekto(js, m_id);
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
void saveDokumentyKollekto ( JSONObject js, String m_id){
JSONArray dokumenty_kollekto;
File dir_pliki_kollekto = new File(prefs.getString("dir", "") + "/pliki_kollekto");
//Log.d("my_debug", "saveDokumentyKollekto");
if(!dir_pliki_kollekto.isDirectory()) {
//Log.d("my_debug", "tworze dir: pliki_kollekto");
if (!dir_pliki_kollekto.mkdirs()) {
}
}
try {
dokumenty_kollekto = js.getJSONArray("dokumenty_kollekto");
JSONObject dokument;
String fileName;
String data_pobrania;
String url;
String path;
for ( int i=0; i<dokumenty_kollekto.length(); i++){
dokument = dokumenty_kollekto.getJSONObject(i);
fileName = dokument.getString("nazwa_pliku");
data_pobrania = dokument.getString("data_pobrania");
url = "data/pliki_kollekto/"+login+"/"+m_id;
path = prefs.getString("dir", "") + "/pliki_kollekto/"+m_id;
// jeśli data_pobrania jest null znaczy że pliku nie ma na serwerze. Wtedy jeśli jest na tablecie to trzeba go usunąć. I nic nie ściągamy.
if( "null".equals(data_pobrania) ) {
File myFile = new File(path+"/"+ fileName);
if( myFile.exists()) {
Log.d("my_debug", "usuwam dokument kollektu: "+path+"/"+fileName);
myFile.delete();
}
}
else {
downloadFile(url, path, fileName);
}
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
void saveAttach( JSONObject js, String m_id){
JSONObject pola;
try {
pola = js.getJSONObject("pola");
Iterator k = pola.keys();
while (k.hasNext()) {
// JSONObject jo = (JSONObject) pola.get(i);
String key = (String) k.next();
JSONObject jo = pola.getJSONObject(key);
SaveAttachPole( jo, m_id);
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
void SaveAttachPole( JSONObject jo, String m_id){
String typ_danych;
try {
try{
typ_danych = jo.getString("typ_danych");
}catch(JSONException jeTyp){
return; // dlaczego nie ma typu danych?
}
if(typ_danych.equals("attach")){
String folder = jo.getString("kod");
Vector v = new Vector<String>();
JSONArray jFiles = jo.getJSONArray("files");
if( jFiles != null && jFiles.length()>0){
for( int i=0; i<jFiles.length(); i++){
String fileName = jFiles.getString(i);
SavePicture( m_id, folder, fileName);
v.add(fileName);
}
}
//usun cached pliki
File fFolder = new File(prefs.getString("dir", "") + "/mDedal/"+m_id+"/"+folder);
if( fFolder.isDirectory()){
File files[] = fFolder.listFiles();
for( int z=0; z<files.length; z++){
String name = files[z].getName();
if( ! v.contains(name)){
Log.d(SRV, "Usunięto zdjęcie: " + name);
files[z].delete();
}
}
}
//jFiles.
}else if(typ_danych.equals("attach_powtarzalny")){
String folder = jo.getString("id");
JSONArray jFiles = jo.getJSONArray("files");
if( jFiles != null && jFiles.length()>0){
for( int i=0; i<jFiles.length(); i++){
String fileName = jFiles.getString(i);
SavePicture( m_id, folder, fileName);
}
}
}else if(typ_danych.equals("foto")){
String fileName = jo.getString("wartosc");
SavePicture( m_id, "foto_typ", fileName);
}
} catch (JSONException e1) {
Log.e("DEDAL", "JSON", e1);
Log.d(SRV, "brakuje typ_danych: json: " + jo.toString());
}
// sprawdz dzieci
JSONArray ja;
try {
ja = jo.getJSONArray("childs");
if( ja!= null && ja.length()>0){
for ( int i=0; i<ja.length(); i++){
SaveAttachPole( ja.getJSONObject(i), m_id);
}
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
void downloadFile (String url, String path, String fileName) {
Log.d("my_debug", "downloadFile: url: "+url+" path: "+path+" fileName: "+fileName);
try {
File fId = new File(path);
if(!fId.isDirectory()) {
if (!fId.mkdirs()) {
}
}
File myFile = new File(path+"/"+ fileName);
if( !myFile.exists()) {
DedalHttpConnection con = new DedalHttpConnection(getApplicationContext());
byte [] sPost = con.getBytePost(url, null); //+"/"+fileName);
if( sPost!= null) {
myFile.createNewFile();
FileOutputStream fos = new FileOutputStream(myFile);
fos.write(DedalHelper.encodeFile(sPost));
fos.flush();
fos.close();
}else{
Log.e("downloadFile", "file not downloaded: "+ url);
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
Log.e(SRV, "", e);
} catch (IOException e) {
// TODO Auto-generated catch block
Log.e(SRV, "", e);
} catch (Exception e) {
Log.e(SRV, "", e);
}
}
void SavePicture( String m_id, String folder, String fileName){
Log.d(SRV, "Save picture: " + fileName);
if( fileName == null || fileName.trim().length()==0)
{
return;
}
File myFileDir = new File(prefs.getString("dir", "") + "/mDedal/"+m_id+"/"+folder);
if( !myFileDir.isDirectory()){
myFileDir.mkdirs();
}
SavePictureThumb(m_id, folder, fileName);
URL urlF;
String urlS;
String path;
path = prefs.getString("dir", "") + "/mDedal/"+m_id+"/"+folder;
//thumb
File myFile = new File(path+"/"+ fileName);
if( !myFile.exists()){
//myFile.createNewFile();
if( folder.equals("foto_typ") ) {
urlS = "public/getFile.php?id_zlecenia="+m_id+"&folder=&file="+fileName+"&type=images";//"data/images/"+m_id;
}
else {
urlS = "public/getFile.php?id_zlecenia="+m_id+"&folder="+folder+"&file="+fileName+"&type=images"; //urlS = "data/images/"+m_id+"/"+folder;
}
downloadFile (urlS, path, fileName);
}else { //jest juz plik
// nic nie rob
}
}
void SavePictureThumb( String m_id, String folder, String fileName){
URL urlF;
try {
File myFile = new File(prefs.getString("dir", "") + "/mDedal/"+m_id+"/"+folder+"/"+ fileName);
if( !myFile.exists()){
String url = "";
if( folder.equals("foto_typ") ) {
url = "public/getFile.php?id_zlecenia="+m_id+"&folder=thumb&file="+fileName+"&type=images"; //
}
else {
url = "public/getFile.php?id_zlecenia="+m_id+"&folder="+folder+"/thumbnail&file="+fileName+"&type=images"; //
}
DedalHttpConnection con = new DedalHttpConnection(getApplicationContext());
byte [] sPost = con.getBytePost(url, null);
if( sPost != null) {
File fId = new File(prefs.getString("dir", "") + "/mDedal/" + m_id + "/" + folder);
if (!fId.isDirectory()) {
if (!fId.mkdirs()) {
}
}
myFile.createNewFile();
FileOutputStream fos = new FileOutputStream(myFile);
fos.write(DedalHelper.encodeFile(sPost));
fos.flush();
fos.close();
}else{
Log.e( "Download", "Thumb niepobrany: " + url);
}
}else { //jest juz plik
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
Log.e(SRV, "", e);
} catch (IOException e) {
// TODO Auto-generated catch block
Log.e(SRV, "", e);
} catch (Exception e) {
Log.e(SRV, "", e);
}
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Log.d(SRV, "Service onStartCommand called.");
Log.d(SRV, "Intent: " + intent + ", flags: " + flags + ", startId: " + startId);
Context context = getApplicationContext();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
Log.setFileName(prefs.getString("dir", ""));
Log.setEH();
DokumentyKollektoService.stopService = true;
if( thread == null){
// temporary HTTPS!!! EOS pre-produkcja
// utworzyć strukturę katalogów
File d = new File(prefs.getString("dir", "") + "/baza");
d.mkdirs();
d = new File(prefs.getString("dir", "") + "/upload");
d.mkdirs();
d = new File(prefs.getString("dir", "") + "/mDedal");
d.mkdirs();
d = new File(prefs.getString("dir", "") + "/mDedalCam");
d.mkdirs();
startThread();
}else{
File fNext = new File(prefs.getString("dir", "") + "dedalsrv.continue");
try {
fNext.createNewFile();
} catch (IOException e) {
Log.e(SRV, "", e);
}
if( thread.isAlive()){
thread.interrupt();
}else{
Log.d(SRV, "Watek serwisu byl zatrzymany. Restart watku");
startThread();
}
}
return super.onStartCommand(intent, flags, startId);
}
Thread thread = null;
private void startThread(){
Log.d(SRV, "Start watku Serwisu.");
thread = new Thread(new WorkingThread());
thread.start();
}
String readFile(InputStream in) throws IOException {
StringBuffer sb = new StringBuffer();
byte buffer[] = new byte[10000];
int s = 0;
while ((s = in.read(buffer)) > 0) {
String st =new String(buffer, 0, s);
//Log.d(SRV, "i=" + s +", data:" + st);
sb.append(st);
}
return sb.toString();
}
public String readFileFromPath(String path) {
String content = "";
File myFile = new File(path);
if( myFile.isFile()){
content = DedalHelper.getFileContent(myFile.getAbsolutePath());
}
return content;
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
}

538
app/src/main/java/com/likesoft/mdedal/DedalHelper.java

@ -0,0 +1,538 @@ @@ -0,0 +1,538 @@
package com.likesoft.mdedal;
import android.content.SharedPreferences;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.util.Base64;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Key;
import java.security.KeyStore;
import java.security.SecureRandom;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.SecretKeySpec;
public class DedalHelper {
static HashMap<String, String> statusy;
static {
statusy = new HashMap<String, String>();
statusy.put("wypelniane", "WYPE<EFBFBD>NIANE");
statusy.put("nie_przydz", "NIEPRZYDZIELONE");
statusy.put("przydz_nie_odeb", "PRZYDZIELONE");
statusy.put("przydz_odeb", "REALIZACJA");
statusy.put("wykonane", "WYKONANE");
statusy.put("wykonane_zaak", "ZAAKCEPTOWANE");
statusy.put("odrzucone", "ODRZUCONE");
statusy.put("anulowane", "ANULOWANE");
statusy.put("anulowane_zaak", "ANULOWANE_ZAAKCEPTOWANE");
statusy.put("zawieszona", "ZAWIESZONA");
}
// static DedalHelper obj = new DedalHelper();
// public DedalHelper(){
// }
public static String getStatusDesc( String s){
if( statusy.containsKey(s)){
return statusy.get(s);
}else{
return s;
}
}
//
// static HashMap<String, String> sts;
// static {
// sts = new HashMap<String, String>();
// sts.put("wypelniane", "WYPE<EFBFBD>NIANE");
// sts.put("nie_przydz", "NIEPRZYDZIELONE");
// sts.put("przydz_nie_odeb", "PRZYDZIELONE");
// sts.put("przydz_odeb", "ODEBRANE");
// sts.put("wykonane", "WYKONANE");
// sts.put("wykonane_zaak", "ZAAKCEPTOWANE");
// sts.put("odrzucone", "ODRZUCONE");
// sts.put("anulowane", "ANULOWANE");
// sts.put("anulowane_zaak", "ANULOWANE_ZAAKCEPTOWANE");
// sts.put("zawieszona", "ZAWIESZONA");
// }
// public static String getStatusDescShort( String s){
// if( statusy.containsKey(s)){
// return statusy.get(s);
// }else{
// return s;
// }
// }
// Input a double latitude or longitude in the decimal format
// e.g. -79.982195
public static String decimalToDMS(double coord) {
String output, degrees, minutes, seconds;
// gets the modulus the coordinate divided by one (MOD1).
// in other words gets all the numbers after the decimal point.
// e.g. mod := -79.982195 % 1 == 0.982195
//
// next get the integer part of the coord. On other words the whole number part.
// e.g. intPart := -79
double mod = coord % 1;
int intPart = (int)coord;
//set degrees to the value of intPart
//e.g. degrees := "-79"
degrees = String.valueOf(intPart);
// next times the MOD1 of degrees by 60 so we can find the integer part for minutes.
// get the MOD1 of the new coord to find the numbers after the decimal point.
// e.g. coord := 0.982195 * 60 == 58.9317
// mod := 58.9317 % 1 == 0.9317
//
// next get the value of the integer part of the coord.
// e.g. intPart := 58
coord = mod * 60;
mod = coord % 1;
intPart = (int)coord;
if (intPart < 0) {
// Convert number to positive if it's negative.
intPart *= -1;
}
// set minutes to the value of intPart.
// e.g. minutes = "58"
minutes = String.valueOf(intPart);
//do the same again for minutes
//e.g. coord := 0.9317 * 60 == 55.902
//e.g. intPart := 55
coord = mod * 60;
intPart = (int)coord;
if (intPart < 0) {
// Convert number to positive if it's negative.
intPart *= -1;
}
// set seconds to the value of intPart.
// e.g. seconds = "55"
seconds = String.valueOf(intPart);
// I used this format for android but you can change it
// to return in whatever format you like
// e.g. output = "-79/1,58/1,56/1"
output = degrees + "/1," + minutes + "/1," + seconds + "/1";
//Standard output of D°M′S″
//output = degrees + "°" + minutes + "'" + seconds + "\"";
return output;
}
/*
* Conversion DMS to decimal
*
* Input: latitude or longitude in the DMS format ( example: W 79° 58' 55.903")
* Return: latitude or longitude in decimal format
* hemisphereOUmeridien => {W,E,S,N}
*
*/
public static double DMSToDecimal(String hemisphereOUmeridien,double degres,double minutes,double secondes)
{
double LatOrLon=0;
double signe=1.0;
if((hemisphereOUmeridien.equals("W"))||(hemisphereOUmeridien.equals("S"))) {signe=-1.0;}
LatOrLon = signe*(Math.floor(degres) + Math.floor(minutes)/60.0 + secondes/3600.0);
return(LatOrLon);
}
public static String getValueFromKod(String kod, JSONObject jZlecenie) {
String value = "";
try{
if( kod.equals("tworca")){
value = jZlecenie.getString("tworca_login");//id_tworca
}else if( kod.equals("inspektor")){
//Log.d("Helper", "kod,")
value = jZlecenie.getString("inspektor_login");
}else if( kod.equals("info_alert")){
value = jZlecenie.getString("data_alert");
}else if( kod.equals("nr_sprawy-link")){
value = jZlecenie.getString("nr_sprawy");
}else if( kod.equals("status")){
value = DedalHelper.getStatusDesc(jZlecenie.getString("status"));
//tw.setText(DedalHelper.getStatusDescShort(jZlecenie.getString("status")));
// }else if( kod.equals("")){
}else if( kod.startsWith("data_")){
String s = jZlecenie.getString(kod);
if( s.length()>=10){
value = jZlecenie.getString(kod).substring(0, 10);
}else{
value = s;
}
}else{
if( !jZlecenie.isNull(kod)){
value = jZlecenie.getString(kod);
}
}
}catch( JSONException jE){
Log.d("ListActivity", jE.getMessage());
}
return value;
}
public static String getCurrentDate() {
return getCurrentDate("yyyy-MM-dd HH:mm:ss");
}
public static String getCurrentDate(String format) {
DateFormat dateFormat = new SimpleDateFormat(format);
Calendar c = Calendar.getInstance();
return dateFormat.format(c.getTime());
}
public static String getFileContent(String file_path) {
return getCryptFileContent(file_path);
}
public static boolean putFileContent(String file_path, String content) {
return putCryptFileContent(file_path, content);
}
/*
public static String getFileContentSimple(String file_path) {
String return_str = "";
File ffile = new File(file_path);
if( !ffile.exists() ) {
return return_str;
}
int length = (int) ffile.length();
byte[] bytes = new byte[length];
FileInputStream in = null;
try {
in = new FileInputStream(ffile);
try {
in.read(bytes);
} finally {
in.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return_str = new String(bytes);
return return_str;
} */
public static byte [] key;
public static byte[] generateKey() throws Exception
{
if( key != null){
return key;
}
byte[] keyStart = "likesoft".getBytes("UTF-8");
String pass = "HasloD0Maga7nu";
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
File f = new File(Environment.getExternalStorageDirectory()+ "/dedal/truststore.jks");
if( f.isFile()) {
trustStore.load(new FileInputStream(f.getAbsolutePath()), pass.toCharArray());
}else{
trustStore.load(null, null);
}
Key klucz = trustStore.getKey("dedal", pass.toCharArray());
if( klucz!= null ){
return klucz.getEncoded();
}else { // zapisz do store nowy:
KeyGenerator kgen = KeyGenerator.getInstance("AES");
//SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1").getProvider();
// SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
SecureRandom sr = new SecureRandom();
sr.setSeed(keyStart);
kgen.init(128, sr);
SecretKey skey = kgen.generateKey();
trustStore.setKeyEntry("dedal", skey, pass.toCharArray(), null);
FileOutputStream out = new FileOutputStream(f.getAbsolutePath());
trustStore.store(out, pass.toCharArray());
out.close();
key = skey.getEncoded();
}
return key;
}
public static byte[] encodeFile( byte[] fileData) throws Exception
{
if( key == null){
key = generateKey();
}
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(fileData);
return encrypted;
}
public static String encodeB64( String fileData)
{
try{
byte[] e = encodeFile(fileData.getBytes());
return Base64.encodeToString(e, Base64.DEFAULT);
}catch (Exception ex){
Log.e("CRYPT", "decodeB64 problem");
}
return fileData;
}
public static byte[] decodeFile( byte[] fileData) throws Exception
{
if( key == null){
key = generateKey();
}
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
try {
byte[] decrypted = cipher.doFinal(fileData);
return decrypted;
}catch( Exception e){
Log.e("CRYPT", "nie udało się odszyfrować bytes ", e);
return fileData;
}
}
//Base64.decode(input, Base64.DEFAULT)
public static String decodeB64( String fileData)
{
try {
byte[] e = decodeFile(Base64.decode(fileData, Base64.DEFAULT));
return new String(e);
}catch (Exception ex){
Log.e("CRYPT", "decodeB64 problem");
}
return fileData;
}
public static void copyEncode(File src, File dst) throws IOException {
if( !src.exists() ) {
return ;
}
int length = (int) src.length();
byte[] bytes = new byte[length];
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
try {
in.read(bytes);
} finally {
in.close();
}
try {
byte[] coded = new byte[0];
try {
coded = encodeFile(bytes);
} catch (Exception e) {
Log.e("CRYPT", "problem z kodowaniem", e);
}
out.write(coded);
} finally {
out.close();
}
}
public static String getCryptFileContent(String file_path) {
String return_str = "";
File ffile = new File(file_path);
if( !ffile.exists() ) {
return return_str;
}
int length = (int) ffile.length();
byte[] bytes = new byte[length];
FileInputStream in = null;
try {
in = new FileInputStream(ffile);
try {
in.read(bytes);
} finally {
in.close();
}
} catch (FileNotFoundException e) {
Log.e("DEDAL", "File not found", e);
} catch (IOException e) {
Log.e("DEDAL", "IO", e);
}
byte[] ret = new byte[0];
try {
ret = decodeFile(bytes);
return_str = new String(ret);
} catch (Exception e) {
Log.e("CRYPT", "nie udało się odszyfrować: " + file_path, e);
//jeśli nie udało sie odkodować, zwróć plik
return_str = new String(bytes);
}
return return_str;
}
public static byte[] getCryptFileBytes(String file_path) {
File ffile = new File(file_path);
if( !ffile.exists() ) {
return null;
}
int length = (int) ffile.length();
byte[] bytes = new byte[length];
FileInputStream in = null;
try {
in = new FileInputStream(ffile);
try {
in.read(bytes);
} finally {
in.close();
}
} catch (FileNotFoundException e) {
Log.e("DEDAL", "File not found", e);
} catch (IOException e) {
Log.e("DEDAL", "IO", e);
}
byte[] ret;
try {
ret = decodeFile(bytes);
return ret;
} catch (Exception e) {
Log.e("CRYPT", "nie udało się odszyfrować: " + file_path, e);
//jeśli nie udało sie odkodować, zwróć plik
return bytes;
}
}
public static boolean putCryptFileContent(String file_path, String content) {
File ffile = new File(file_path);
FileOutputStream stream = null;
try {
stream = new FileOutputStream(ffile);
try {
byte[] coded = encodeFile(content.getBytes());
stream.write(coded);
} finally {
stream.close();
return true;
}
} catch (FileNotFoundException e) {
Log.e("DEDAL", "File not found", e);
} catch (IOException e) {
Log.e("DedalHelper", "File can't be saved"+ file_path, e);
// System.exit(0);
}
return false;
}
/*
public static boolean putFileContentSimple(String file_path, String content) {
File ffile = new File(file_path);
FileOutputStream stream = null;
try {
stream = new FileOutputStream(ffile);
try {
stream.write(content.getBytes());
} finally {
stream.close();
return true;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
Log.e("DedalHelper", "File can't be saved"+ file_path, e);
// getActivity().finish();
System.exit(0);
}
return false;
}
*/
public static boolean deleteFile(String file_path) {
File file = new File(file_path);
if( file.exists() ) {
return file.delete();
}
return false;
}
public static String getModOrJsonFileName(String fileNameJson) {
String fileNameJson_mod = fileNameJson.replace(".json", ".mod");
File file = new File(fileNameJson_mod);
if(file.exists()) {
return fileNameJson_mod;
}
return fileNameJson;
}
public static String datetime2date(String datetime) {
String date = null;
try {
SimpleDateFormat sdf_date_time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
SimpleDateFormat sdf_date = new SimpleDateFormat("yyyy-MM-dd");
Date dat = sdf_date_time.parse(datetime);
date = sdf_date.format(dat);
} catch (ParseException e) {
Log.e("DEDAL", "Parse date", e);
}
return date;
}
// public static int findInArrayList(ArrayList al, String content) {
// int j = -1;
// for( int i = 0 ; i < al.size() ; i++ ) {
// if( content.equals(al.get(i)) ) {
// j = i;
// break;
// }
// }
// return j;
// }
}

418
app/src/main/java/com/likesoft/mdedal/DedalHttpConnection.java

@ -0,0 +1,418 @@ @@ -0,0 +1,418 @@
package com.likesoft.mdedal;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyStore;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.scheme.SocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Base64;
import android.util.Log;
public class DedalHttpConnection {
private static final String SRV = "MyHttpConnection";
private String login;
private String pass;
private String hostPath;
public static String certSerialNumber="";
public static String certOdcisk="";
private DefaultHttpClient mHttpClient;
public static Context context;
public DedalHttpConnection(Context context) {
//hostPath = "http://192.168.1.106/svn_home/SmsGateServer/src";
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
hostPath = sharedPrefs.getString("hostName", "");
login = sharedPrefs.getString("user", "");
pass = DedalHelper.decodeB64(sharedPrefs.getString("password", ""));
certSerialNumber = sharedPrefs.getString("certSerialNumber", "");
//String cert64 = Base64.decode(sharedPrefs.getString("certOdcisk"));
try {
certOdcisk = new String(DedalHelper.decodeFile(Base64.decode(sharedPrefs.getString("certOdcisk", ""), Base64.DEFAULT)));
} catch (Exception e) {
e.printStackTrace();
}
Log.d("my_debug", "Create MyHttpConnection. hostPath: "+hostPath+", login: "+login); //+", pass: "+pass
this.context = context;
}
public String sendPost(String scriptName) {
return sendPost(scriptName, null);
}
public String sendPost(String scriptName, Map<String, String> params) {
Log.d("my_debug", "sendPost, scriptName: "+scriptName+", params: "+params );
ServerCommunication();
if( mHttpClient == null){
Log.e("SECURITY", "Network not initialized");
return null;
}
//Log.d("my_debug", "getSms");
HttpPost httppost = new HttpPost( hostPath + "/" + scriptName); //sms_send_download.php");
//
httppost.setHeader(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
httppost.setHeader(new BasicHeader("charset", "UTF-8"));
//
//
List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>();
parameters.add(new BasicNameValuePair("login", login));
parameters.add(new BasicNameValuePair("pass", pass));
if( params != null ) {
Iterator iterator = params.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry mapEntry = (Map.Entry) iterator.next();
String key = (String) mapEntry.getKey();
String value = (String) mapEntry.getValue();
//Log.d("my_debug", "The key is: " + key + ",value is :" + value);
parameters.add(new BasicNameValuePair(key, value));
}
}
try {
httppost.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
HttpResponse response = mHttpClient.execute(httppost);
if( response != null){
HttpEntity r_entity = response.getEntity();
String responseString = EntityUtils.toString(r_entity);
Log.d("my_debug", "sendPost, response from "+scriptName+": "+responseString);
//httppost.completed();
//response.body().close();
mHttpClient.getConnectionManager().closeExpiredConnections();
int sC = response.getStatusLine().getStatusCode();
if( sC == 200 ) {
return responseString;
}else{
String ctv = r_entity.getContentType().getValue();
Log.d( "sendPost", "http code: " + sC + ", content type: " + ctv);
return null;
}
}
} catch (UnsupportedEncodingException e) {
com.likesoft.mdedal.Log.e("DEDAL", "Encoding", e);
} catch (ClientProtocolException e) {
com.likesoft.mdedal.Log.e("DEDAL", "Client protocol", e);
} catch (IOException e) {
com.likesoft.mdedal.Log.e("DEDAL", "IO", e);
}
return null;
//Log.d(SRV, "Entity BasicNameValuePair za<EFBFBD>adowane");
}
public byte [] getBytePost(String scriptName, Map<String, String> params) {
Log.d("my_debug", "sendPost, scriptName: "+scriptName+", params: "+params );
ServerCommunication();
if( mHttpClient == null){
Log.e("SECURITY", "Network not initialized");
return null;
}
//Log.d("my_debug", "getSms");
HttpPost httppost = new HttpPost( hostPath + "/" + scriptName); //sms_send_download.php");
//
httppost.setHeader(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
httppost.setHeader(new BasicHeader("charset", "UTF-8"));
//
//
List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>();
parameters.add(new BasicNameValuePair("login", login));
parameters.add(new BasicNameValuePair("pass", pass));
if( params != null ) {
Iterator iterator = params.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry mapEntry = (Map.Entry) iterator.next();
String key = (String) mapEntry.getKey();
String value = (String) mapEntry.getValue();
//Log.d("my_debug", "The key is: " + key + ",value is :" + value);
parameters.add(new BasicNameValuePair(key, value));
}
}
try {
httppost.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
HttpResponse response = mHttpClient.execute(httppost);
if( response != null){
HttpEntity r_entity = response.getEntity();
byte[] buffer = EntityUtils.toByteArray(r_entity); //new byte[in.available()];
mHttpClient.getConnectionManager().shutdown();
int sC = response.getStatusLine().getStatusCode();
if( sC == 200 ) {
return buffer;
}else{
String ctv = r_entity.getContentType().getValue();
Log.d( "sendPost", "http code: " + sC + ", content type: " + ctv);
return null;
}
}
} catch (UnsupportedEncodingException e) {
Log.e("getInputStream", "nieudane pobranie", e);
} catch (ClientProtocolException e) {
Log.e("getInputStream", "nieudane pobranie", e);
} catch (IOException e) {
Log.e("getInputStream", "nieudane pobranie", e);
}
return null;
}
//image/jpeg Content type
public byte[] getPicture(String url) {
Log.d("my_debug", "getPicture, url: "+url);
ServerCommunication();
if( mHttpClient == null){
Log.e("SECURITY", "Network not initialized");
return null;
}
//Log.d("my_debug", "getSms");
HttpPost httppost = new HttpPost( hostPath + "/" + url); //sms_send_download.php");
httppost.setHeader(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
httppost.setHeader(new BasicHeader("charset", "UTF-8"));
List<BasicNameValuePair> parameters = new ArrayList<BasicNameValuePair>();
parameters.add(new BasicNameValuePair("login", login));
parameters.add(new BasicNameValuePair("pass", pass));
try {
httppost.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
HttpResponse response = mHttpClient.execute(httppost);
if( response != null){
HttpEntity r_entity = response.getEntity();
byte[] buffer = EntityUtils.toByteArray(r_entity); //new byte[in.available()];
//response.getStatusLine().
Header ct = r_entity.getContentType();
String ctv = r_entity.getContentType().getValue();
int sC = response.getStatusLine().getStatusCode();
mHttpClient.getConnectionManager().shutdown();
if( sC == 200 && ctv.toLowerCase().contains("jpg")) {
return buffer;
}else{
Log.d( "GET_PICTURE", "http code: " + sC + ", content type: " + ctv);
return null;
}
}
} catch (UnsupportedEncodingException e) {
com.likesoft.mdedal.Log.e("DEDAL", "Unsupported Encoding", e);
} catch (ClientProtocolException e) {
com.likesoft.mdedal.Log.e("DEDAL", "Client protocol", e);
} catch (IOException e) {
com.likesoft.mdedal.Log.e("DEDAL", "IO", e);
}
return null;
//Log.d(SRV, "Entity BasicNameValuePair za<EFBFBD>adowane");
}
//todo: do poprawy - chyba nie działa pobieranie plików z Kollekto...
/**
* @deprecated
* @param url
* @param path
* @param fileName
*/
void downloadFile (String url, String path, String fileName) {
Log.d("my_debug", "downloadFile: url: "+url+" path: "+path+" fileName: "+fileName);
try {
url = hostPath + "/" + url;
File fId = new File(path);
if(!fId.isDirectory()) {
if (!fId.mkdirs()) {
}
}
File myFile = new File(path+"/"+ fileName);
if( !myFile.exists()) {
myFile.createNewFile();
URL urlF = new URL(url+"/"+fileName);
HttpURLConnection urlConnectionF;
if (urlF.getProtocol().toLowerCase().equals("https")) {
// trustAllHosts();
HttpsURLConnection urlHttpsConnection = (HttpsURLConnection) urlF.openConnection();
urlHttpsConnection.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
urlConnectionF = urlHttpsConnection;
} else {
urlConnectionF = (HttpURLConnection) urlF.openConnection();
}
InputStream inF = new BufferedInputStream(urlConnectionF.getInputStream());
FileOutputStream fosF;
fosF = new FileOutputStream(myFile);
byte buffer[] = new byte[10000];
int x = 0;
while( (x = inF.read(buffer)) >0){
fosF.write(buffer, 0, x);
Log.d(SRV, "Picture - czytam znaków: " + x);
}
fosF.flush();
fosF.close();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
Log.e(SRV, "", e);
} catch (IOException e) {
// TODO Auto-generated catch block
Log.e(SRV, "", e);
}
}
/*
private static void trustAllHosts() {
X509TrustManager easyTrustManager = new X509TrustManager() {
public void checkClientTrusted(
X509Certificate[] chain,
String authType) throws CertificateException {
// Oh, I am easy!
}
public void checkServerTrusted(
X509Certificate[] chain,
String authType) throws CertificateException {
com.likesoft.mdedal.Log.d("certyfikat", "MyHttpConnection -serverTrusted23: " + Arrays.toString(chain));
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {easyTrustManager};
// Install the all-trusting trust manager
try {
// SSLContext sc = SSLContext.getInstance("SSL");
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
//
// SSLSocketFactory factory =sc.getSocketFactory();
// SSLSocket socket =(SSLSocket)factory.createSocket("dedal.eos-ksi.pl", 443);
// socket.startHandshake();
// SSLSession session = socket.getSession();
// java.security.cert.Certificate[] servercerts = session.getPeerCertificates();
// for (int i = 0; i < servercerts.length; i++) {
// System.out.print("-----BEGIN CERTIFICATE-----\n");
// //System.out.print(Base64.encodeBytes().encode(servercerts[i].getEncoded()));
// // System.out.print(Base64.getEncoder().encode(servercerts[i].getEncoded()));
// byte[] e = servercerts[i].getEncoded();
// System.out.print(Base64.encodeToString(e, 0));
// System.out.print(servercerts[i].getEncoded());
// System.out.print("\n-----END CERTIFICATE-----\n");
// }
// socket.close();
//
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
e.printStackTrace();
Log.d("my_debug", "");
}
}
*/
public static DefaultHttpClient getNewHttpClient() {
try {
// trustAllHosts();
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
org.apache.http.conn.ssl.SSLSocketFactory sf = new DedalSSLSocketFactory(trustStore);
if(BuildConfig.DEBUG) {
sf.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
}else {
sf.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
// sf.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
}
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
SchemeRegistry registry = new SchemeRegistry();
if(BuildConfig.DEBUG) {
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
}
registry.register(new Scheme("https", (SocketFactory) sf, 443));
ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
return new DefaultHttpClient(ccm, params);
} catch (Exception e) {
Log.e("my_debug", "catch", e);
// return new DefaultHttpClient();
return null;
}
}
public void ServerCommunication() {
mHttpClient = DedalHttpConnection.getNewHttpClient();
}
}

108
app/src/main/java/com/likesoft/mdedal/DedalSSLSocketFactory.java

@ -0,0 +1,108 @@ @@ -0,0 +1,108 @@
package com.likesoft.mdedal;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Base64;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class DedalSSLSocketFactory extends org.apache.http.conn.ssl.SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
public DedalSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super(truststore);
TrustManager tm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
com.likesoft.mdedal.Log.d("certyfikat", "MySSLSocketFactory -checkClientTrusted: " + Arrays.toString(chain));
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
// com.likesoft.mdedal.Log.d("certyfikat", "MySSLSocketFactory -serverTrusted AA: " + Arrays.toString(chain));
// for (int i = 0; i < chain.length; i++) {
// // android.util.Log.d("cert Serial Number" + i + ":", chain[i].getSerialNumber().toString());
// //Log.d( "cert", "validity: " + chain[0].checkValidity());
// Collection<List<?>> aN = chain[i].getSubjectAlternativeNames();
// if( aN != null) {
//
// Object[] a = aN.toArray();
// android.util.Log.d("cert AN", Arrays.toString(a));
// }
// // Oh, I am easy!
// }
if( chain.length>0){
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(DedalHttpConnection.context);
if( DedalHttpConnection.certSerialNumber.length()==0) { //init
SharedPreferences.Editor e = prefs.edit();
e.putString("certSerialNumber", chain[0].getSerialNumber().toString());
e.commit();
}else { //check
if( !chain[0].getSerialNumber().toString().equals(prefs.getString("certSerialNumber", "") )){
// security problem
android.util.Log.e("SECURITY", "Cert Serial Number incorrect");
throw new CertificateException("Cert Serial Number incorrect");
}
}
if( DedalHttpConnection.certSerialNumber.length()==0) { //init, gdy nie było jeszcze serial number
SharedPreferences.Editor e = prefs.edit();
byte[] sig;
try {
sig = DedalHelper. encodeFile(chain[0].getSignature());
e.putString("certOdcisk", Base64.encodeToString(sig, Base64.DEFAULT));
e.commit();
} catch (Exception ex) {
android.util.Log.e("SECURITY", "Cert Signature encode incorrect");
throw new CertificateException("Cert Signature incorrect");
}
}else { //check
String chainSig = new String(chain[0].getSignature());
if( !chainSig.equals(DedalHttpConnection.certOdcisk )){
// security problem
android.util.Log.e("SECURITY", "Cert Signature incorrect");
throw new CertificateException("Cert Signature incorrect");
}
}
}
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
sslContext.init(null, new TrustManager[] { tm }, null);
}
@Override
public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
}
@Override
public Socket createSocket() throws IOException {
return sslContext.getSocketFactory().createSocket();
}
}

1680
app/src/main/java/com/likesoft/mdedal/DedalService.java

File diff suppressed because it is too large Load Diff

655
app/src/main/java/com/likesoft/mdedal/DokumentyKollektoActivity.java

@ -0,0 +1,655 @@ @@ -0,0 +1,655 @@
package com.likesoft.mdedal;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningServiceInfo;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class DokumentyKollektoActivity extends Activity {
LinearLayout lMain;
String id_zlecenia;
JSONArray dkJson;
SharedPreferences prefs;
boolean refreshingLista = true;
private final class rowOpenFileListener implements OnClickListener {
File file;
public rowOpenFileListener (File file) {
this.file = file;
}
@Override
public void onClick(View v) {
try {
openFile(getApplicationContext(), file);
} catch (IOException e) {
Log.e("DEDAL", "IO", e);
}
}
}
private final class rowDownloadFileListener implements OnClickListener {
String fileName;
public rowDownloadFileListener (String fileName) {
this.fileName = fileName;
}
@Override
public void onClick(View v) {
// obłsuga pliku do komunikacji z serwerem
//String commPath = prefs.getString("dir", "") + "/pliki_kollekto/communication.json";
//File myFile = new File(commPath);
Long time = (System.currentTimeMillis());
String ts = Long.toString(time);
String commPath = prefs.getString("dir", "") + "/pliki_kollekto/comm_"+ts+".json";
//File myFile = new File(commPath);
String commJsString = readFile(commPath);
JSONObject commJs = null;
if( "".equals(commJsString) ) {
commJs = new JSONObject();
}
else {
try {
commJs = new JSONObject(commJsString);
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
try {
JSONObject zlecJs;
if( commJs.has(id_zlecenia) ) {
zlecJs = commJs.getJSONObject(id_zlecenia);
}
else {
zlecJs = new JSONObject();
}
zlecJs.put(fileName, "get");
commJs.put(id_zlecenia, zlecJs);
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
writeFile(commPath, commJs.toString());
// obsługa pliku zawierającym statusy
String statPath = prefs.getString("dir", "") + "/pliki_kollekto/statuses.json";
File myFile = new File(statPath);
String statJsString = readFile(statPath);
JSONObject statJs = null;
if( "".equals(statJsString) ) {
statJs = new JSONObject();
}
else {
try {
statJs = new JSONObject(statJsString);
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
//zlecJs = new JSONObject();
try {
JSONObject zlecJs;
if( statJs.has(id_zlecenia) ) {
zlecJs = statJs.getJSONObject(id_zlecenia);
}
else {
zlecJs = new JSONObject();
}
zlecJs.put(fileName, "Żądanie pobrania");
statJs.put(id_zlecenia, zlecJs);
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
writeFile(statPath, statJs.toString());
//wystartuj/obudz servis
startDokumentyKollektoService();
DokumentyKollektoActivity.this.recreate();
}
}
private final class btnDeleteFileListener implements OnClickListener {
String fileName;
public btnDeleteFileListener (String fileName) {
this.fileName = fileName;
}
@Override
public void onClick(View v) {
try {
File myFile = new File(prefs.getString("dir", "") + "/pliki_kollekto/"+id_zlecenia+"/"+fileName);
if( myFile.exists() ) {
myFile.delete();
}
//String commPath = prefs.getString("dir", "") + "/pliki_kollekto/communication.json";
Long time = (System.currentTimeMillis());
String ts = Long.toString(time);
String commPath = prefs.getString("dir", "") + "/pliki_kollekto/comm_"+ts+".json";
//String commJsString = readFile(commPath);
JSONObject commJs = new JSONObject();
JSONObject zlJs;
if( commJs.has(id_zlecenia) ) {
zlJs = commJs.getJSONObject(id_zlecenia);
}
else {
zlJs = new JSONObject();
}
//JSONObject zlJs = commJs.getJSONObject(id_zlecenia);
//if( zlJs.has(fileName) ) {
zlJs.put(fileName, "delete");
commJs.put(id_zlecenia, zlJs);
writeFile(commPath, commJs.toString());
// obsługa pliku zawierającym statusy
String statPath = prefs.getString("dir", "") + "/pliki_kollekto/statuses.json";
String statJsString = readFile(statPath);
JSONObject statJs = null;
//if( "".equals(statJsString) ) {
statJs = new JSONObject(statJsString);
//zlJs = statJs.getJSONObject(id_zlecenia);
if( statJs.has(id_zlecenia) ) {
zlJs = statJs.getJSONObject(id_zlecenia);
}
else {
zlJs = new JSONObject();
}
zlJs.put(fileName, "Do pobrania");
statJs.put(id_zlecenia, zlJs);
writeFile(statPath, statJs.toString());
//}
//wystartuj/obudz servis
startDokumentyKollektoService();
DokumentyKollektoActivity.this.recreate();
//}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Context context = getApplicationContext();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
Log.setFileName(prefs.getString("dir", ""));
Log.setEH();
refreshingLista = true;
upServiceIfNeeded();
HorizontalScrollView lMainScroll = new HorizontalScrollView(this);
lMain = new LinearLayout(this);
lMain.setOrientation(LinearLayout.VERTICAL);
ScrollView vertScroll = new ScrollView(this);
lMainScroll.addView(vertScroll);
vertScroll.addView(lMain);
Bundle extras = getIntent().getExtras();
if (extras != null) {
id_zlecenia = extras.getString("id_zlecenia");
try {
dkJson = new JSONArray(extras.getString("dkJson"));
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
Log.d("my_debug", "dokumentyKollektoActivity, id_zlecenia: "+id_zlecenia+", dkJson: "+dkJson.toString());
}
//TextView tv = new TextView(this);
//tv.setText("Dostępne dokumenty");
//lMain.addView(tv);
wyswietlListe();
setContentView(lMainScroll);
this.setTitle("Dokumenty Kollekto, id_zlecenia: "+id_zlecenia);
// wtatek który sprawdza czy zmienil sie plik: statuses.json. Jesli tak to odswiez liste.
Thread t =new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Long lastMod = null;
Long lastStatMod = null;
while( true ){
if( !refreshingLista ) {
break;
}
try {
File dLista = new File(prefs.getString("dir", "") + "/pliki_kollekto/statuses.json");
if( dLista.isFile()){
lastMod = dLista.lastModified();
if (lastStatMod == null) { lastStatMod = lastMod; continue; }
//Log.d("my_debug", lastStatMod+ " | " +lastMod);
if ( !lastStatMod.equals(lastMod) ) {
lastStatMod = lastMod;
Log.d("my_debug", "DokumentyKollektoActivity: odswieżam liste");
//DokumentyKollektoActivity.this.recreate();
//DokumentyKollektoActivity.this.reload();
lMain.post(new Runnable() {
@Override
public void run() {
wyswietlListe();
}
});
}
}
Thread.sleep(1000);
} catch (InterruptedException e) {
break;
}
}
}
});
t.start();
}
private void wyswietlListe(){
lMain.removeAllViews();
int colNum = 5;
TableLayout tl = new TableLayout(DokumentyKollektoActivity.this);
lMain.addView(tl);
tl.setPadding(0, 15, 0, 0);
TableRow rowHeader = new TableRow(DokumentyKollektoActivity.this);
tl.addView(rowHeader);
rowHeader.setBackgroundColor(Color.parseColor("#FFA500"));
TextView[] tvHeaders = new TextView[colNum];
for(int i = 0; i < colNum; i++) {
tvHeaders[i] = new TextView(DokumentyKollektoActivity.this);
rowHeader.addView(tvHeaders[i]);
tvHeaders[i].setPadding(5, 3, 5, 2);
tvHeaders[i].setTextSize(25);
//tvHeaders[i].setBackgroundColor(Color.parseColor("#FFA500"));
}
tvHeaders[0].setText("Nazwa pliku");
tvHeaders[1].setText("Typ");
tvHeaders[2].setText("Opis");
tvHeaders[3].setText("Rozmiar");
tvHeaders[4].setText("Status");
String statPath = prefs.getString("dir", "") + "/pliki_kollekto/statuses.json";
//File statFile = new File(statPath);
String statJsString = readFile(statPath);
JSONObject statJs = null;
JSONObject zlecStatJs = null;
try {
if( !"".equals(statJsString) ) {
statJs = new JSONObject(statJsString);
if( statJs.has(id_zlecenia) ) {
zlecStatJs = statJs.getJSONObject(id_zlecenia);
}
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
JSONObject oneDokJson;
try {
// lista plików
for( int i=0 ; i < dkJson.length() ; i++) {
boolean pobrany = false;
boolean btnUsunBool = false;
oneDokJson = dkJson.getJSONObject(i);
TableRow rowDok = new TableRow(DokumentyKollektoActivity.this);
tl.addView(rowDok);
TextView[] tvDok = new TextView[colNum];
for(int j = 0; j < colNum; j++) {
tvDok[j] = new TextView(DokumentyKollektoActivity.this);
tvDok[j].setPadding(5, 3, 5, 2);
tvDok[j].setTextSize(25);
rowDok.addView(tvDok[j]);
}
String fileName = oneDokJson.getString("nazwa_pliku");
tvDok[0].setText(fileName);
tvDok[1].setText(oneDokJson.getString("typ"));
tvDok[2].setText(oneDokJson.getString("opis"));
tvDok[3].setText(oneDokJson.getString("rozmiar"));
String status = "";
// czytam status z pliku statuses.json
if( zlecStatJs != null && zlecStatJs.has(fileName) ) {
status = zlecStatJs.getString(fileName);
if("Pobrany".equals(status)) {
pobrany = true;
btnUsunBool = true;
}
if("Żądanie pobrania".equals(status)) {
btnUsunBool = true;
}
}
// czytam status ze json'a w zleceniu
else {
// if( "null".equals(oneDokJson.getString("data_pobrania")) ) {
// status = "Do pobrania";
// }
// else {
// btnUsunBool = true;
// pobrany = true;
// }
if( oneDokJson.has("status") ) {
status = oneDokJson.getString("status");
}
else {
if( "null".equals(oneDokJson.getString("data_pobrania")) ) {
status = "Do pobrania";
}
else {
btnUsunBool = true;
pobrany = true;
}
}
if ( !"Do pobrania".equals(status) ) {
btnUsunBool = true;
}
if ( "Pobrany".equals(status) ) {
pobrany = true;
}
}
if( "Do pobrania".equals(status) ) {
rowDok.setOnClickListener(new rowDownloadFileListener(fileName));
rowDok.setBackgroundColor(Color.YELLOW);
}
if( pobrany ) {
String path = prefs.getString("dir", "") + "/pliki_kollekto/"+id_zlecenia;
File myFile = new File(path+"/"+fileName);
if( myFile.exists()) {
status = "Pobrany, zobacz";
rowDok.setOnClickListener(new rowOpenFileListener(myFile));
rowDok.setBackgroundColor(Color.GREEN);
}
else {
status = "Błąd - pobrany, jednak nie ma go na tablecie";
}
}
tvDok[4].setText(status);
if( btnUsunBool ) {
Button btnUsun = new Button(getApplicationContext());
btnUsun.setText("Usuń");
btnUsun.setOnClickListener(new btnDeleteFileListener(fileName));
rowDok.addView(btnUsun);
}
}
//Log.d("my_debug", "Dokumenty kollekto, zlecStatJs: " + statJs.toString());
if( statJs != null && statJs.has("limit") && "true".equals( statJs.getString("limit") ) ) {
Log.d("my_debug", "Dokumenty Kollekto: osiognieto limit");
TextView warningTv = new TextView(DokumentyKollektoActivity.this);
warningTv.setText("Osiągnięto limit ilości dokumentów. Usuń niepotrzebne dokumenty aby pobrać nowe.");
lMain.addView(warningTv);
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
}
private boolean upServiceIfNeeded() {
// TODO Auto-generated method stub
boolean ret = false;
Log.d("my_debug", "upServiceIfNeeded, DokumentyKollektoService.stopService: "+ DokumentyKollektoService.stopService);
if ( DokumentyKollektoService.stopService ) {
try {
// String commPath = prefs.getString("dir", "") + "/pliki_kollekto/communication.json";
// String commJsString = readFile(commPath);
// Log.d("my_debug", "commfile: "+commJsString);
// if ( "".equals(commJsString) || commJsString == null ) {
// return ret;
// }
File dir = new File(prefs.getString("dir", ""));
File fDstf = new File(dir + "/pliki_kollekto");
if( !fDstf.isDirectory()){
fDstf.mkdirs();
}
File files[] = fDstf.listFiles();
String commJsString = "";
boolean keepService = false;
if( fDstf != null) {
for (int i=0; i<files.length; i++){
File comm_file = files[i];
String comm_file_name = comm_file.getName();
//Log.d("my_debug", "file_name: "+comm_file_name+", substring: " + comm_file_name.substring(0,3));
if( !comm_file.isFile() || !"comm_".equals(comm_file_name.substring(0,5)) ){
continue;
}
String commPath = prefs.getString("dir", "") + "/pliki_kollekto/" + comm_file_name;
commJsString = readFile(commPath);
Log.d("my_debug", "commJsString: "+commJsString);
JSONObject commJs = new JSONObject(commJsString);
Iterator pKeys = commJs.keys();
while( pKeys.hasNext()){
String id_zlecenia = (String)pKeys.next();
JSONObject jZlecenie = commJs.getJSONObject(id_zlecenia);
Iterator pKeys2 = jZlecenie.keys();
while( pKeys2.hasNext()){
String nazwa_pliku = (String)pKeys2.next();
String stat = jZlecenie.getString(nazwa_pliku);
if( "get".equals(stat) || "check".equals(stat) ) {
ret = true;
break;
}
}
if( ret ) {
break;
}
}
if( ret ) {
break;
}
}
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
if( ret ) {
//wystartuj/obudz servis
startDokumentyKollektoService();
}
Log.d("my_debug", "upServiceIfNeeded: " + ret);
}
return ret;
}
public static void openFile(Context context, File url) throws IOException {
// Create URI
File file=url;
Uri uri = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
// Check what kind of file you are trying to open, by comparing the url with extensions.
// When the if condition is matched, plugin sets the correct intent (mime) type,
// so Android knew what application to use to open the file
if (url.toString().contains(".doc") || url.toString().contains(".docx")) {
// Word document
intent.setDataAndType(uri, "application/msword");
} else if(url.toString().contains(".pdf")) {
// PDF file
intent.setDataAndType(uri, "application/pdf");
} else if(url.toString().contains(".ppt") || url.toString().contains(".pptx")) {
// Powerpoint file
intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
} else if(url.toString().contains(".xls") || url.toString().contains(".xlsx")) {
// Excel file
intent.setDataAndType(uri, "application/vnd.ms-excel");
} else if(url.toString().contains(".zip") || url.toString().contains(".rar")) {
// WAV audio file
intent.setDataAndType(uri, "application/x-wav");
} else if(url.toString().contains(".rtf")) {
// RTF file
intent.setDataAndType(uri, "application/rtf");
} else if(url.toString().contains(".wav") || url.toString().contains(".mp3")) {
// WAV audio file
intent.setDataAndType(uri, "audio/x-wav");
} else if(url.toString().contains(".gif")) {
// GIF file
intent.setDataAndType(uri, "image/gif");
} else if(url.toString().contains(".jpg") || url.toString().contains(".jpeg") || url.toString().contains(".png")) {
// JPG file
intent.setDataAndType(uri, "image/jpeg");
} else if(url.toString().contains(".txt")) {
// Text file
intent.setDataAndType(uri, "text/plain");
} else if(url.toString().contains(".3gp") || url.toString().contains(".mpg") || url.toString().contains(".mpeg") || url.toString().contains(".mpe") || url.toString().contains(".mp4") || url.toString().contains(".avi")) {
// Video files
intent.setDataAndType(uri, "video/*");
} else {
//if you want you can also define the intent type for any other file
//additionally use else clause below, to manage other unknown extensions
//in this case, Android will show all applications installed on the device
//so you can choose which application to use
intent.setDataAndType(uri, "*/*");
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
public void writeFile(String path, String content) {
DedalHelper.putFileContent(path, content);
}
public String readFile(String path) {
String content = "";
try {
File myFile = new File(path);
if( myFile.isFile()){
BufferedReader buf;
buf = new BufferedReader(new FileReader(myFile));
content = buf.readLine();
buf.close();
}
} catch (IOException e) {
Log.e("DEDAL", "IO", e);
}
return content;
}
public void reload() {
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
}
private boolean isMyServiceRunning(Class<?> serviceClass) {
ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (serviceClass.getName().equals(service.service.getClassName())) {
return true;
}
}
return false;
}
private void startDokumentyKollektoService() {
// wystartuj/obudz serwis
Log.d("my_debug", "startDokumentyKollektoService, DokumentyKollektoService.stopService: "+ DokumentyKollektoService.stopService);
if ( DokumentyKollektoService.stopService ) {
Context context = getApplicationContext();
Intent service = new Intent(context, DokumentyKollektoService.class);
context.startService(service);
}
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
refreshingLista = false;
//DokumentyKollektoService.stopService = true;
super.onDestroy();
//onDestroyD(this);
}
}

266
app/src/main/java/com/likesoft/mdedal/DokumentyKollektoService.java

@ -0,0 +1,266 @@ @@ -0,0 +1,266 @@
package com.likesoft.mdedal;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
import android.preference.PreferenceManager;
public class DokumentyKollektoService extends Service {
public static boolean stopService = true;
SharedPreferences prefs;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
stopService = false;
// TODO Auto-generated method stub
Thread t = new Thread(new Runnable() {
@Override
public void run() {
//tutaj będzie akcja
while ( true ) {
if( stopService ) {
break;
}
try {
Log.d("my_debug", "DokumentyKollektoService");
File dir = new File(prefs.getString("dir", ""));
File fDstf = new File(dir + "/pliki_kollekto");
if( !fDstf.isDirectory()){
fDstf.mkdirs();
}
File files[] = fDstf.listFiles();
String commJsString = "";
boolean keepService = false;
if( fDstf != null) {
for (int i=0; i<files.length; i++){
File comm_file = files[i];
String comm_file_name = comm_file.getName();
Log.d("my_debug", "comm_file_name: " +comm_file_name );
if( !comm_file.isFile() || !"comm_".equals(comm_file_name.substring(0,5)) ){
continue;
}
Log.d("my_debug", "comm_file_name: " +comm_file_name );
String commPath = prefs.getString("dir", "") + "/pliki_kollekto/" + comm_file_name;
commJsString = readFile(commPath);
//String commPath = prefs.getString("dir", "") + "/pliki_kollekto/communication.json";
//String commJsString = readFile(commPath);
if ( "".equals(commJsString) ) {
continue;
}
JSONObject commJs = new JSONObject(commJsString);
// parsowanie pliku, jeśli są wpisy get lub check to wysyłamy posta
//...
// /
DedalHttpConnection conn = new DedalHttpConnection(getApplicationContext());
Map<String, String> params = new HashMap<String, String>();
params.put("json", commJsString);
String responseJsString = conn.sendPost("json/plikiKollekto.php", params);
//Log.d("my_debug", "responseJsString: " + responseJsString);
JSONObject responseJs = new JSONObject(responseJsString); // z tego czytam i tego nie modyfikuje
JSONObject responseJsCopy = new JSONObject(responseJsString); // tutaj robibie zmiany i później to zapisywane jest do pliku
// obsługa pliku zawierającym statusy
String statJsString = readFile(prefs.getString("dir", "") + "/pliki_kollekto/statuses.json");
JSONObject statJs = new JSONObject(statJsString); // z tego czytam
JSONObject statJsCopy = new JSONObject(statJsString);// w tym bede robic zmiany
// parsowanie odpowiedzi z serwera, jeśli jest wpis downloading to znaczy że trzeba pobrać plik
Iterator pKeys = responseJs.keys();
boolean limit = false;
boolean new_comm = false;
boolean save_stats = false;
while( pKeys.hasNext()){
String id_zlecenia = (String)pKeys.next();
JSONObject jZlecenie = responseJs.getJSONObject(id_zlecenia);
JSONObject jZlecenieCopy = responseJsCopy.getJSONObject(id_zlecenia);
JSONObject statZl;
JSONObject statZlCopy = null;
if ( statJs.has(id_zlecenia) ) {
statZl = statJs.getJSONObject(id_zlecenia);
statZlCopy = statJsCopy.getJSONObject(id_zlecenia);
}
else {
statZl = new JSONObject();
statJs.put(id_zlecenia, statZl);
}
Iterator pKeys2 = jZlecenie.keys();
while( pKeys2.hasNext()){
Log.d("my_debug", "temp: "+responseJs.toString());
String nazwa_pliku = (String)pKeys2.next();
Log.d("my_debug", "temp, nazwa_pliku: "+nazwa_pliku);
String stat = jZlecenie.getString(nazwa_pliku);
// zmiany w pliku communication.json
if( "get".equals(stat) || "check".equals(stat) || "delete".equals(stat)) {
keepService = true;
}
if( "deleted".equals(stat) ) {
jZlecenieCopy.remove(nazwa_pliku);
}
if( "aborted".equals(stat) ) {
jZlecenieCopy.remove(nazwa_pliku);
}
if( "limit".equals(stat) ) {
limit = true;
jZlecenieCopy.remove(nazwa_pliku);
// todo: komunikat że osiągnięto limit
statZlCopy.put(nazwa_pliku, "Do pobrania");
// //
}
if( "downloading".equals(stat) ) {
// todo: pobierz zdjęcie fizycznie
String login = prefs.getString("user", "");
conn.downloadFile("data/pliki_kollekto/"+login+"/"+id_zlecenia, prefs.getString("dir", "") + "/pliki_kollekto/"+id_zlecenia, nazwa_pliku);
jZlecenieCopy.remove(nazwa_pliku);
//JSONObject statZl = statJs.getJSONObject(id_zlecenia);
statZlCopy.put(nazwa_pliku, "Pobrany");
//DokumentyKollektoActivity.this.recreate();
// //
}
// zmiany w pliku statuses.json
// if( "downloading".equals(stat) ) {
// statJs
// }
}
}
if(limit) {
statJsCopy.put("limit", "true");
}
else {
if ( statJs.has("limit") ) {
statJsCopy.remove("limit");
}
}
// /
if( !statJs.equals(statJsCopy) ) {
writeFile(prefs.getString("dir", "") + "/pliki_kollekto/statuses.json", statJsCopy.toString());
}
responseJsCopy = cleenResponseJs(responseJsCopy);
// Jesli po przetworzeniu odpowiedzi nadal cos w niej jest (znaczy ze trzeba stworzyc nowy plik z poloczeniem aby znowu byl wyslany(np. pozostal status check))
Log.d("my_debug", "responseJsCopy: " + responseJsCopy.toString()+", respnseJsCopy.length: " + responseJsCopy.length() );
if( responseJsCopy != null && !"".equals(responseJsCopy.toString().trim()) && responseJsCopy.length() > 0 ) {
Long time = (System.currentTimeMillis());
String ts = Long.toString(time);
String newCommPath = prefs.getString("dir", "") + "/pliki_kollekto/comm_"+ts+".json";
Log.d("my_debug", "tworze plik: " + newCommPath);
writeFile(newCommPath, responseJsCopy.toString());
}
// po przetworzeniu nalezy usunac wyslany plik komunikacyjny
File doneCommFile = new File(commPath);
Log.d("my_debug", "should delete: "+commPath);
if( doneCommFile.exists() ) {
Log.d("my_debug", "delete: "+commPath);
doneCommFile.delete();
}
}
}
if( !keepService ) {
stopService = true;
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
try {
int sleepTime = 10000; // 30s
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
Log.d("DEDAL", "Interrupted", e);
}
}
}
private JSONObject cleenResponseJs(JSONObject responseJs) {
Iterator pKeys = responseJs.keys();
boolean limit = false;
try {
while( pKeys.hasNext()){
String id_zlecenia = (String)pKeys.next();
JSONObject jZlecenie = responseJs.getJSONObject(id_zlecenia);
if( jZlecenie.length() == 0 ) {
responseJs.remove(id_zlecenia);
}
}
} catch (JSONException e) {
Log.e("DEDAL", "JSON", e);
}
return responseJs;
}
});
t.start();
return super.onStartCommand(intent, flags, startId);
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
public void writeFile(String path, String content) {
DedalHelper.putFileContent(path, content);
}
public String readFile(String path) {
String content = "";
try {
File myFile = new File(path);
if( myFile.isFile()){
BufferedReader buf;
buf = new BufferedReader(new FileReader(myFile));
content = buf.readLine();
buf.close();
}
} catch (IOException e) {
Log.e("DEDAL", "IO", e);
}
return content;
}
}

331
app/src/main/java/com/likesoft/mdedal/FragmentMainActivity.java

@ -0,0 +1,331 @@ @@ -0,0 +1,331 @@
package com.likesoft.mdedal;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
/**
* Created by darek on 2016-01-10.
*/
public class FragmentMainActivity extends DedalActivity {
@Override
public View.OnClickListener getZapisz_zmiany(JSONObject jo, String typ) {
return null;
}
boolean modified = false;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (data.hasExtra("json") && data.hasExtra("id")) {
// check if radio, find parent to set up value
try {
File dst = new File(prefs.getString("dir", "") + "/baza/" + m_id + ".mod");
String sJson = DedalHelper.getFileContent(dst.getAbsolutePath());
js = new JSONObject(sJson);//fs.read(buffer));
JSONObject jo = find_element_from_Array( js, data.getExtras().getString("id")); //todo check if not null
if( TYPE_RADIOBUTTON.equals(jo.getString(STRUCT_TYP_DANYCH)) ){
// find parent
String parent = jo.getString("parent");
Log.d("my_debug", "szukanie parenta" + parent);//
JSONObject jParent = find_element_from_Array(js, parent);
if( jParent!= null && TYPE_RADIOLISTA.equals(jParent.getString(STRUCT_TYP_DANYCH)) ){
jParent.put(STRUCT_WARTOSC, jo.getInt("id_wiersz_szablonu"));
}
}
// stopAutozapis();
// autoZapisStop = false;
mod_json_files(false);
setModified();
//MainActivity.this.reload();
return;
} catch (JSONException e) {
e.printStackTrace();
}
}
}
@Override
protected void setModified() {
if( !modified) {
llNaglowek.setBackgroundColor(Color.parseColor("#EBA0DD"));
Button bZapisz = new Button(this);
bZapisz.setText("Zapisz");
bZapisz.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (modified) {
komunikat_obowiazkowe="";
komunikat_walidacja="";
zapiszZmiany(jo);
String komunikat = "";
if( !komunikat_obowiazkowe.equals("") || !komunikat_walidacja.equals("") ) {
if( !komunikat_obowiazkowe.equals("") ) {
komunikat = res.getString(R.string.walid_pola_obowiazkowe) + ": \n"+komunikat_obowiazkowe + "\n";
Log.d("my_debug", "Nie wypełniłeś pól obowiązkowych: " + komunikat);
}
if( !komunikat_walidacja.equals("") ) {
komunikat += "\n"+res.getString(R.string.walid_zle_wypelnione)+": \n"+komunikat_walidacja + "\n";
}
}
if(komunikat!= ""){
AlertDialog.Builder alertDialog = new AlertDialog.Builder(FragmentMainActivity.this);
alertDialog.setTitle( "Zapisywanie danych");//res.getString(R.string.zakanczanie_wizyty) ); //todo
alertDialog.setMessage(komunikat);
alertDialog.setPositiveButton("Anuluj", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
mod_json_files(false);
dialog.dismiss();
}
});
alertDialog.show();
return;
}else {
modified = false;
saved = true;
}
}
finish();
}
});
llNaglowek.addView(bZapisz);
}
modified = true;
}
@Override
protected void stopAutozapis() {
zapiszZmiany(jo);
}
@Override
protected void mod_json_files(boolean mod_upload) {
}
@Override
protected void forceDoZapis(String key, String kod) {
}
String tmpFileName = "";
//http://www.vogella.com/tutorials/AndroidIntent/article.html
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
res = getResources();
Context context = getApplicationContext();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
// setContentView(R.layout.activity_main);
LinearLayout.LayoutParams linLayoutParam = new LinearLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
LinearLayout rl = new LinearLayout(this);
rl.setLayoutParams(linLayoutParam);
rl.setOrientation(LinearLayout.VERTICAL);
// rl.setBackgroundColor(Color.YELLOW);
wyswietlNaglowek( rl );
// if( bModified){
// llNaglowek.setBackgroundColor(Color.parseColor("#EBA0DD"));
// }
sw = new ScrollView(this);
rl.addView(sw);
HorizontalScrollView hs = new HorizontalScrollView(this);
hs.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
sw.addView(hs);
LinearLayout llh = new LinearLayout(this);
int x = this.getWindow().getAttributes().width;
int xx = this.getWindowManager().getDefaultDisplay().getWidth(); //getRealSize(p);
Log.d("my_debug", "szerokość ekranu: "+ x+ ", real x: = " + xx);
llh.setLayoutParams( linLayoutParam);
// llh.setBackgroundColor(Color.RED);
hs.addView(llh);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setPadding(20, 5, 5, 5); //zmiana
ll.setLayoutParams( linLayoutParam);
ll.setMinimumWidth(xx);
// ll.setBackgroundColor(Color.GREEN);
llh.addView(ll);
try {
Bundle extras = getIntent().getExtras();
String filePathName = extras.getString("filePathName");
tmpFileName = filePathName;
if( filePathName == null ) return;
String sJson = DedalHelper.getFileContent(filePathName);
js = new JSONObject(sJson);//fs.read(buffer));
params = js.getJSONObject("param");
m_id = params.getString("id_zlecenia");
String id = extras.getString("id");
jo = find_element_from_Array(js, id);
find_powtarzalne(jo, 0);
boolean enabled = true; //
// enabled = Boolean.parseBoolean(extras.getString("enable"));
String sEnable = extras.getString("enable");
if( !"true".equals(sEnable)){
enabled = false;
}
String status_interwencji = null;
if( getIntent().hasExtra("status_interwencji") ) {
status_interwencji = extras.getString("status_interwencji");
}
// wyswietlOpis(ll, jo);
wyswietlOpis(llNaglowek, jo);
Log.d("my_debug", "Fragment, enabled"+enabled);
JSONArray ja = jo.getJSONArray(STRUCT_CHILDS);
if (ja != null && ja.length() > 0) {
for (int i = 0; i < ja.length(); i++) {
wyswietlPole(ll, ja.getJSONObject(i), true, enabled, status_interwencji);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
// TextView view = (TextView) findViewById(R.id.editTextHost);
// view.setText(inputString);
// set LinearLayout as a root element of the screen
// setContentView(rl, linLayoutParam);
setContentView(rl);
if( supportOnLoadReferences != null ) {
supporRadioRef(supportOnLoadReferences, View.GONE);
}
}
JSONObject jo;
boolean saved = false;
LinearLayout llNaglowek;
protected void wyswietlNaglowek(LinearLayout rl) {
LinearLayout ll = new LinearLayout(this);
llNaglowek = ll;
ll.setOrientation(LinearLayout.HORIZONTAL);
ll.setPadding(20, 5, 5, 5);
ll.setBackgroundColor(Color.parseColor("#9BF1F2"));
HorizontalScrollView hw = new HorizontalScrollView(this);
rl.addView(hw);
hw.addView(ll);
Button bAnuluj = new Button(this);
bAnuluj.setText("Anuluj");
bAnuluj.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
modified = false;
finish();
}
});
llNaglowek.addView(bAnuluj);
}
//@Override
public void onCreateFromResource(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_main);
Bundle extras = getIntent().getExtras();
String inputString = extras.getString("json");
try {
js = new JSONObject(inputString);
params = js.getJSONObject("param");
m_id = params.getString("id_zlecenia");
String id = extras.getString("id");
jo = find_element_from_Array(js, id);
find_powtarzalne(jo, 0);
LinearLayout ll = (LinearLayout)findViewById(R.id.linearLayoutMain);
sw = (ScrollView)findViewById(R.id.scrollView1);
boolean enabled = true; // todo: przekazac?
wyswietlPole(ll, jo, true, enabled);
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void finish() {
Intent intent = new Intent();
// EditText editText= (EditText) findViewById(R.id.returnValue);
// String string = editText.getText().toString();
// String string = "aqq";
// if( modified) {
// zapiszZmiany(jo);
// }
if( saved ) {
// intent.putExtra("json", js.toString());
try {
saveToModFile(js);
intent.putExtra("json","true");
} catch (IOException e) {
e.printStackTrace();
}
}
try {
intent.putExtra("id", jo.getString("id"));
intent.putExtra("status", "OK");
intent.putExtra("tmpName",tmpFileName);
} catch (JSONException e) {
e.printStackTrace();
}
setResult(RESULT_OK, intent);
super.finish();
}
}

252
app/src/main/java/com/likesoft/mdedal/GPSTracker.java

@ -0,0 +1,252 @@ @@ -0,0 +1,252 @@
package com.likesoft.mdedal;
import java.util.Iterator;
import android.Manifest;
import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.GpsSatellite;
import android.location.GpsStatus;
import android.location.GpsStatus.Listener;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.IBinder;
import android.provider.Settings;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
//import android.util.Log;
public class GPSTracker extends Service implements LocationListener, Listener {
private final Context mContext;
// flag for GPS status
boolean isGPSEnabled = false;
// flag for network status
boolean isNetworkEnabled = false;
// flag for GPS status
boolean canGetLocation = false;
Location location; // location
double latitude; // latitude
double longitude; // longitude
public int liczbaSatelitow = 0;
// The minimum distance to change Updates in meters
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 5;//10; // 10 meters
// The minimum time between updates in milliseconds
private static final long MIN_TIME_BW_UPDATES = 1000 * 300;// 30sec // 60 * 1; // 1 minute
// Declaring a Location Manager
protected LocationManager locationManager;
public GPSTracker(Context context) {
this.mContext = context;
getLocation();
}
public Location getLocation() {
try {
locationManager = (LocationManager) mContext
.getSystemService(LOCATION_SERVICE);
// Check runtime permissions for Android M+
boolean hasFine = ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
boolean hasCoarse = ContextCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
boolean hasLocation = hasFine || hasCoarse;
// getting GPS status
isGPSEnabled = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
// no network provider is enabled
} else {
this.canGetLocation = true;
// First get location from Network Provider
if (isNetworkEnabled && hasLocation) {
try {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
} catch (SecurityException ignored) { }
if (locationManager != null) {
try {
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
} catch (SecurityException ignored) { }
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
// GPS status listener (no permission required)
try { locationManager.addGpsStatusListener(this); } catch (Exception ignored) { }
if (locationManager != null && hasLocation) {
try {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
} catch (SecurityException ignored) { }
try {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
} catch (SecurityException ignored) { }
}
// if GPS Enabled get lat/long using GPS Services
if (isGPSEnabled && location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return location;
}
/**
* Stop using GPS listener
* Calling this function will stop using GPS in your app
* */
public void stopUsingGPS() {
if (locationManager != null) {
locationManager.removeUpdates(GPSTracker.this);
}
}
/**
* Function to get latitude
* */
public double getLatitude() {
if (location != null) {
latitude = location.getLatitude();
}
// return latitude
return latitude;
}
/**
* Function to get longitude
* */
public double getLongitude() {
if (location != null) {
longitude = location.getLongitude();
}
// return longitude
return longitude;
}
/**
* Function to check GPS/wifi enabled
* @return boolean
* */
public boolean canGetLocation() {
return this.canGetLocation;
}
/**
* Function to show settings alert dialog
* On pressing Settings button will lauch Settings Options
* */
public void showSettingsAlert() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
// Setting Dialog Title
alertDialog.setTitle("GPS jest wymagany");
// Setting Dialog Message
alertDialog.setMessage("GPS jest wyłączony. Czy chcesz go teraz włączyć?");
// On pressing Settings button
alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
}
});
// on pressing cancel button
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
// Showing Alert Message
alertDialog.show();
}
@Override
public void onLocationChanged(Location location) {
this.location = location;
}
@Override
public void onProviderDisabled(String provider) {
isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
@Override
public void onProviderEnabled(String provider) {
isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public void onGpsStatusChanged(int event) {
// TODO Auto-generated method stub
//GpsStatus status = new GpsStatus(n);
// TODO Auto-generated method stub
// int permissionCheckGPS = ContextCompat.checkSelfPermission(getApplicationContext(),
// Manifest.permission.ACCESS_FINE_LOCATION);
//
// if (permissionCheckGPS == PackageManager.PERMISSION_GRANTED) {
Iterable<GpsSatellite> gs = null;
try {
GpsStatus status = locationManager.getGpsStatus(null);
liczbaSatelitow= 0;//status.getMaxSatellites();
if( status == null){
return;
}
gs = status.getSatellites();
} catch (SecurityException ignored) { return; }
if (gs == null) return;
Iterator<GpsSatellite> it = gs.iterator();
while( it.hasNext()){
GpsSatellite g = it.next();
liczbaSatelitow++;
}
// }
}
}

374
app/src/main/java/com/likesoft/mdedal/KPActivity.java

@ -0,0 +1,374 @@ @@ -0,0 +1,374 @@
package com.likesoft.mdedal;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.likesoft.mdedaltest.R;
public class KPActivity extends Activity {
private Map<String, String> STATUS_NAMES = null;
//private LinearLayout lMain = null;
private SharedPreferences prefs = null;
private TableLayout tl = null;
private LinearLayout lCancelReason = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
STATUS_NAMES = new HashMap<String, String>();
STATUS_NAMES.put("aktywne", "Aktywne");
STATUS_NAMES.put("zuzyte", "Zużyte");
STATUS_NAMES.put("anulowane", "Anulowane");
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
LinearLayout lMain = new LinearLayout(this);
lMain.setOrientation(LinearLayout.VERTICAL);
ScrollView vScrollMain = new ScrollView(this);
HorizontalScrollView hScroll = new HorizontalScrollView(this);
vScrollMain.addView(hScroll);
hScroll.addView(lMain);
setContentView(vScrollMain);
LinearLayout footer = new LinearLayout(this);
footer.setOrientation(LinearLayout.HORIZONTAL);
lMain.addView(footer);
Button wyjdz = new Button(this);
wyjdz.setText("Wyjdź");
wyjdz.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
footer.addView(wyjdz);
//lMain.addView(getCancelReason());
lCancelReason = new LinearLayout(this);
lCancelReason.setOrientation(LinearLayout.VERTICAL);
lMain.addView(lCancelReason);
tl = new TableLayout(this);
lMain.addView(tl);
drawTable();
}
private void drawTable() {
String KP_filename = prefs.getString("KP_filename", "");
KP_filename = DedalHelper.getModOrJsonFileName(KP_filename);
String KP_json = DedalHelper.getFileContent(KP_filename);
JSONArray KP_json_arr = null;
try {
KP_json_arr = new JSONArray(KP_json);
} catch (JSONException e) {
e.printStackTrace();
}
//<MWK> obsługa nulla
if ( KP_json_arr != null ) { //</MWK> obsługa nulla
tl.removeAllViews();
tl.setPadding(0, 15, 0, 0);
TableRow tr_head = new TableRow(this);
tl.addView(tr_head);
TextView twH = new TextView(this);
twH.setText("LP");
twH.setPadding(5, 3, 5, 2);
tr_head.addView(twH);
TextView twH2 = new TextView(this);
twH2.setText("KP");
twH2.setPadding(5, 3, 5, 2);
tr_head.addView(twH2);
TextView twH3 = new TextView(this);
twH3.setText("Status");
twH3.setPadding(5, 3, 5, 2);
tr_head.addView(twH3);
TextView twH4 = new TextView(this);
twH4.setText("Operacje");
twH4.setPadding(5, 3, 5, 2);
tr_head.addView(twH4);
for( int i = 0 ; i < KP_json_arr.length() ; i++ ) {
try {
JSONObject KP_obj = KP_json_arr.getJSONObject(i);
String status = KP_obj.getString("status");
TableRow tr = new TableRow(this);
tr.setMinimumHeight(110);
tl.addView(tr);
TextView tw = new TextView(this);
tw.setText(""+(i+1));
tw.setPadding(5, 3, 5, 2);
tr.addView(tw);
TextView tw2 = new TextView(this);
tw2.setText(KP_obj.getString("kp"));
tw2.setPadding(5, 3, 5, 2);
tr.addView(tw2);
TextView tw3 = new TextView(this);
String status_text = STATUS_NAMES.get(status);
if( KP_obj.has("powod_anulowania") && !"".equals(KP_obj.getString("powod_anulowania")) && !"null".equals(KP_obj.getString("powod_anulowania")) ) {
status_text += "\nPowód: "+KP_obj.getString("powod_anulowania");
}
tw3.setText(status_text);
tw3.setPadding(5, 3, 5, 2);
tr.addView(tw3);
Button bt = new Button(this);
bt.setPadding(5, 3, 5, 2);
tr.addView(bt);
if ("aktywne".equals(status) ) {
bt.setText("Anuluj");
bt.setOnClickListener(new ShowCancelReasonOnClickListener(KP_json_arr, KP_obj));
}
else if ("anulowane".equals(status) ) {
bt.setText("Przywróć");
bt.setOnClickListener(new ActionOnClickListener(KP_json_arr, KP_obj, "restore"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
//<MWK> obsługa nulla
}
else {
tl.removeAllViews();
tl.setPadding(0, 15, 0, 0);
TextView label = new TextView(this);
label.setText("Błąd pobierania danych. Sprawdź połączenie z internetem.");
label.setPadding(5, 3, 5, 2);
tl.addView(label);
}//</MWK> obsługa nulla
}
private class spinnerCancelOnItemSelectedListener implements AdapterView.OnItemSelectedListener {
ArrayList<String> items = null;
LinearLayout lInny = null;
EditText etInny = null;
spinnerCancelOnItemSelectedListener(ArrayList<String> items, LinearLayout lInny, EditText etInny) {
this.items = items;
this.lInny = lInny;
this.etInny = etInny;
}
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
if( "inny".equals(items.get(position)) ) {
lInny.post(new Runnable() {
@Override
public void run() {
lInny.removeAllViews();
TextView tv = new TextView(KPActivity.this);
tv.setText("Wpisz: ");
lInny.addView(tv);
lInny.addView(etInny);
}
});
}
else {
lInny.post(new Runnable() {
@Override
public void run() {
lInny.removeAllViews();
}
});
}
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
}
}
private class ShowCancelReasonOnClickListener implements OnClickListener {
JSONObject kp_obj = null;
JSONArray kp_arr = null;
ShowCancelReasonOnClickListener(JSONArray kp_arr, JSONObject kp_obj) {
this.kp_obj = kp_obj;
this.kp_arr = kp_arr;
}
@Override
public void onClick(View v) {
lCancelReason.post(new Runnable() {
@Override
public void run() {
lCancelReason.removeAllViews();
lCancelReason.addView(getCancelReason(kp_arr, kp_obj));
}
});
}
}
private class ActionOnClickListener implements OnClickListener {
JSONObject kp_obj = null;
JSONArray kp_arr = null;
String action = "cancel"; // 'cancel' | 'restore'
Spinner cancelSpin = null;
EditText etInny = null;
ActionOnClickListener(JSONArray kp_arr, JSONObject kp_obj, String action) {
this.kp_obj = kp_obj;
this.kp_arr = kp_arr;
this.action = action;
}
ActionOnClickListener(JSONArray kp_arr, JSONObject kp_obj, String action, Spinner cancelSpin, EditText etInny) {
this.kp_obj = kp_obj;
this.kp_arr = kp_arr;
this.action = action;
this.cancelSpin = cancelSpin;
this.etInny = etInny;
}
@Override
public void onClick(View v) {
try {
if ("cancel".equals(action) ) {
kp_obj.put("status", "anulowane");
if( cancelSpin != null ) {
String powod = cancelSpin.getSelectedItem().toString();
if( etInny != null && !"".equals(etInny.getText().toString().trim()) ) {
powod += ": " + etInny.getText();
}
kp_obj.put("powod_anulowania", powod);
}
}
else if("restore".equals(action)) {
kp_obj.put("status", "aktywne");
kp_obj.put("powod_anulowania", "");
}
String KP_filename = prefs.getString("KP_filename", "");
KP_filename = KP_filename.replace(".json", ".mod");
// copy to .mod
DedalHelper.putFileContent(KP_filename, kp_arr.toString());
//copy to upload folder
String dir_upload = prefs.getString("dir", "");
dir_upload += "/upload_kp";
File fup = new File(dir_upload);
if( !fup.isDirectory()){
fup.mkdirs();
}
//String upload_file_name = KP_filename.replace(".json", "");
String upload_file_name = "kp_"+(new Date()).getTime() + ".mod";
DedalHelper.putFileContent(dir_upload + "/" + upload_file_name, kp_arr.toString());
drawTable();
lCancelReason.post(new Runnable() {
@Override
public void run() {
lCancelReason.removeAllViews();
}
});
//wystartuj/obudź serwis
Context context = getApplicationContext();
Intent service = new Intent(context, DedalService.class);
context.startService(service);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
private LinearLayout getCancelReason(JSONArray KP_json_arr, JSONObject KP_obj){
LinearLayout lCancelReason = new LinearLayout(this);
lCancelReason.setOrientation(LinearLayout.VERTICAL);
//lMain.addView(lCancelReason);
TextView tv = new TextView(this);
tv.setText("Powód: ");
lCancelReason.addView(tv);
Spinner spinCancelReason = new Spinner(this);
lCancelReason.addView(spinCancelReason);
ArrayList<String> items = new ArrayList<String>();
items.add("anulowany");
//items.add("zagubiony");
//items.add("zniszczony");
//items.add("inny");
ArrayAdapter aa = new ArrayAdapter(
this,
android.R.layout.simple_spinner_item,
items.toArray());
aa.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
LinearLayout lInny = new LinearLayout(this);
lCancelReason.addView(lInny);
EditText etInny = new EditText(this);
//spinCancelReason.setOnItemSelectedListener(new CustomOnItemSelectedListener());
spinCancelReason.setOnItemSelectedListener(new spinnerCancelOnItemSelectedListener(items, lInny, etInny));
spinCancelReason.setAdapter(aa);
Button bAnuluj = new Button(this);
bAnuluj.setText("Anuluj KP");
bAnuluj.setOnClickListener(new ActionOnClickListener(KP_json_arr, KP_obj, "cancel", spinCancelReason, etInny));
lCancelReason.addView(bAnuluj);
return lCancelReason;
}
}

267
app/src/main/java/com/likesoft/mdedal/KPWplatyActivity.java

@ -0,0 +1,267 @@ @@ -0,0 +1,267 @@
package com.likesoft.mdedal;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.util.Date;
import java.util.Iterator;
public class KPWplatyActivity extends Activity {
private SharedPreferences prefs = null;
//private LinearLayout lMain = null;
private LinearLayout lContent = null;
private JSONObject KPWplaty_json = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
LinearLayout lMain = new LinearLayout(this);
lMain.setOrientation(LinearLayout.VERTICAL);
//lMain.setPadding(50, 15, 15, 15);
ScrollView vScroll = new ScrollView(this);
vScroll.addView(lMain);
setContentView(vScroll);
LinearLayout footer = new LinearLayout(this);
footer.setOrientation(LinearLayout.HORIZONTAL);
lMain.addView(footer);
Button wyjdz = new Button(this);
wyjdz.setText("Wyjdź");
wyjdz.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
footer.addView(wyjdz);
// REFRESH BUTTON
RefreshLayoutAndThread rlat = new RefreshLayoutAndThread(this) {
@Override
protected void whenThreadNeedToReaoad() {
}
@Override
protected void setLastGPSInfo_abstr() {
}
@Override
protected void onServiceFinisz() {
drawTable();
}
};
LinearLayout refreshLayout = rlat.getRefreshLayout();
refreshLayout.setPadding(10, 0, 0, 0);
TextView textUpload = rlat.getTextUpload();
footer.addView(textUpload);
rlat.setLastUpdateInfo();
rlat.start();
footer.addView(refreshLayout);
lContent = new LinearLayout(this);
lContent.setOrientation(LinearLayout.VERTICAL);
lMain.addView(lContent);
drawTable();
}
private void drawTable() {
String KPWplaty_filename = prefs.getString("KPWplaty_filename", "");
KPWplaty_filename = DedalHelper.getModOrJsonFileName(KPWplaty_filename);
String KPWplaty_json_string = DedalHelper.getFileContent(KPWplaty_filename);
try {
KPWplaty_json = new JSONObject(KPWplaty_json_string);
} catch (JSONException e) {
e.printStackTrace();
}
lContent.removeAllViews();
lContent.setPadding(0, 15, 0, 0);
if( KPWplaty_json == null ) return;
Iterator k = KPWplaty_json.keys();
while (k.hasNext()) {
String id_fundusz = (String) k.next();
try {
JSONObject fundusz_obj = KPWplaty_json.getJSONObject(id_fundusz);
LinearLayout funduszLayout = new LinearLayout(this);
funduszLayout.setOrientation(LinearLayout.VERTICAL);
lContent.addView(funduszLayout);
TextView titleTv = new TextView(this);
titleTv.setText("" + fundusz_obj.getString("nazwa_funduszu") + ", nr karty: " + fundusz_obj.getString("nr_karty"));
titleTv.setTextSize(30);
funduszLayout.addView(titleTv);
TableLayout tl = new TableLayout(this);
funduszLayout.addView(tl);
JSONArray wplatyJson = fundusz_obj.getJSONArray("wplaty");
if( wplatyJson != null && wplatyJson.length() > 0 ) {
// header
TableRow tr_head = new TableRow(this);
tl.addView(tr_head);
TextView twH = new TextView(this);
twH.setText("LP");
twH.setPadding(5, 3, 5, 2);
tr_head.addView(twH);
/*TextView twH2 = new TextView(this);
twH2.setText("Zlecenie");
twH2.setPadding(5, 3, 5, 2);
tr_head.addView(twH2);*/
TextView twH1 = new TextView(this);
twH1.setText("KP");
twH1.setPadding(5, 3, 5, 2);
tr_head.addView(twH1);
TextView twH2 = new TextView(this);
twH2.setText("Nr sprawy");
twH2.setPadding(5, 3, 5, 2);
tr_head.addView(twH2);
TextView twH3 = new TextView(this);
twH3.setText("Kwota");
twH3.setPadding(5, 3, 5, 2);
tr_head.addView(twH3);
for( int i = 0 ; i < wplatyJson.length() ; i++ ) {
JSONObject wplataJson = wplatyJson.getJSONObject(i);
TableRow tr = new TableRow(this);
tl.addView(tr);
TextView tw = new TextView(this);
tw.setText(""+(i+1));
tw.setPadding(5, 3, 5, 2);
tr.addView(tw);
/*TextView tw2 = new TextView(this);
tw2.setText(wplataJson.getString("id_zlecenia"));
tw2.setPadding(5, 3, 5, 2);
tr.addView(tw2);*/
TextView tw1 = new TextView(this);
tw1.setText(wplataJson.getString("kp"));
tw1.setPadding(5, 3, 5, 2);
tr.addView(tw1);
TextView tw2 = new TextView(this);
tw2.setText(wplataJson.getString("nr_sprawy"));
tw2.setPadding(5, 3, 5, 2);
tr.addView(tw2);
TextView tw3 = new TextView(this);
tw3.setText(wplataJson.getString("kwota"));
tw3.setPadding(5, 3, 5, 2);
tr.addView(tw3);
}
TableRow tr = new TableRow(this);
tl.addView(tr);
TextView sumaTvLabel = new TextView(this);
sumaTvLabel.setText("Suma");
sumaTvLabel.setTextSize(30);
sumaTvLabel.setPadding(5, 3, 5, 2);
tr.addView(sumaTvLabel);
TableRow.LayoutParams params = (TableRow.LayoutParams) sumaTvLabel.getLayoutParams();
params.span = 2; //amount of columns you will span
sumaTvLabel.setLayoutParams(params);
TextView sumaTv = new TextView(this);
sumaTv.setText(fundusz_obj.getString("suma")+" zł");
sumaTv.setTextSize(30);
sumaTv.setPadding(5, 3, 5, 2);
tr.addView(sumaTv);
}
if ( fundusz_obj.getString("nr_karty") != null && fundusz_obj.getString("nr_karty").length() > 0 ) { //Mateusz - no display if don't have card
Button bWplacam = new Button(this);
bWplacam.setText("Wpłacam");
bWplacam.setOnClickListener(new WplacamOnClickListener(id_fundusz));
funduszLayout.addView(bWplacam);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
private class WplacamOnClickListener implements OnClickListener {
String id_fundusz = null;
WplacamOnClickListener(String id_fundusz) {
this.id_fundusz = id_fundusz;
}
@Override
public void onClick(View v) {
//copy to upload folder
String dir_upload = prefs.getString("dir", "");
dir_upload += "/upload_kp_wplaty";
File fup = new File(dir_upload);
if( !fup.isDirectory()){
fup.mkdirs();
}
//String upload_file_name = KP_filename.replace(".json", "");
String upload_file_name = "kp_wplaty_"+(new Date()).getTime() + ".mod";
JSONArray ids_wplat = new JSONArray();
try {
JSONObject fundusz_obj = KPWplaty_json.getJSONObject(id_fundusz);
JSONArray wplatyJson = fundusz_obj.getJSONArray("wplaty");
for( int i = 0 ; i < wplatyJson.length() ; i++ ) {
JSONObject wplataJson = wplatyJson.getJSONObject(i);
ids_wplat.put(wplataJson.get("id"));
}
DedalHelper.putFileContent(dir_upload + "/" + upload_file_name, ids_wplat.toString());
} catch (JSONException e) {
e.printStackTrace();
}
//wystartuj/obudź serwis
Context context = getApplicationContext();
Intent service = new Intent(context, DedalService.class);
context.startService(service);
}
}
}

3473
app/src/main/java/com/likesoft/mdedal/ListActivity.java

File diff suppressed because it is too large Load Diff

179
app/src/main/java/com/likesoft/mdedal/Log.java

@ -0,0 +1,179 @@ @@ -0,0 +1,179 @@
package com.likesoft.mdedal;
import android.os.AsyncTask;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class Log {
private static void log(final String lOG, String string) {
AsyncTask<String, Integer, String> fileLog = new AsyncTask(){
@Override
protected Object doInBackground(Object[] objects) {
logRow(objects[0].toString(), objects[1].toString());
return null;
}
};
fileLog.execute(lOG, string);
}
private static void logRow(String lOG, String string) {
if( fileName != null){
PrintWriter pw;
try {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd");
String fName = fileName+"/rt_"+sdf.format(d)+".log";
File f = new File(fName);
if( !f.exists()){
// new date, check if old should be sent to server
File dir = new File( fileName);
String[] fpliki = dir.list(new FilenameFilter(){
@Override
public boolean accept(File dir, String filename) {
// TODO Auto-generated method stub
return filename.startsWith("rt_");
}});
File up = new File(fileName +"/upload/log_file");
if( !up.isDirectory()){
up.mkdirs();
}
if( fpliki != null ) {
for (int i = 0; i < fpliki.length; i++) {
File fi = new File(fileName + "/" + fpliki[i]);
String fi_name = fi.getName();
if ("rt_2014_05_25.log".compareTo(fi_name) > 0) { //create_date < "2014-05-20" ) {
fi.delete();
} else {
Log.zip(fi.getAbsolutePath(), fi.getAbsolutePath() + ".zip");
File fz = new File(fi.getAbsolutePath() + ".zip");
File newF = new File(up.getAbsoluteFile() + "/" + fpliki[i] + ".zip");
if( fz != null && fz.exists() ) {
fz.renameTo(newF);
fi.delete();
}
}
}
}
f.createNewFile();
}
pw = new PrintWriter(
new FileWriter(fName, true));
String prefix = "";
//Date d = new Date();
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
prefix = sdf.format(d) + ":";
pw.write(prefix + lOG + ":" + string+ "\n");
pw.flush();
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void d(String tag, String msg){
if(BuildConfig.DEBUG) {
android.util.Log.d(tag, msg);
StackTraceElement st = new Exception().getStackTrace()[1];
log(tag, "DEBUG:" + st.getClassName() + ":" + st.getMethodName() + "(" + st.getLineNumber() + "):" + msg);
}
}
public static void d(String tag, String msg, Throwable tr){
if(BuildConfig.DEBUG) {
android.util.Log.d(tag, msg, tr);
log(tag, "DEBUG:" + msg + android.util.Log.getStackTraceString(tr));
}
}
public static void e(String tag, String msg ){
{
android.util.Log.e(tag, msg);
}
log(tag, "ERROR:" + msg);
}
public static void e(String tag, String msg, Throwable tr){
{
android.util.Log.e(tag, msg, tr);
}
log(tag, "ERROR:" + msg + android.util.Log.getStackTraceString(tr));
}
public static String fileName = null;
public static void setFileName( String dir){
fileName = dir;// + "/rt.log";
}
public static void setEH(){
if( fileName == null){
return;
}
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
PrintWriter pw;
try {
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd");
pw = new PrintWriter(
new FileWriter(fileName+"/rt_"+sdf.format(d)+".log", true));
pw.write("uncaughtException\n");
ex.printStackTrace(pw);
pw.flush();
pw.close();
ex.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
public static void zip(String _file, String _zipFile) {
try {
BufferedInputStream origin = null;
FileOutputStream dest = new FileOutputStream(_zipFile);
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
int BUFFER = 1024;
byte data[] = new byte[BUFFER];
//for(int i=0; i < _files.length; i++) {
//Log.d("Compress", "Adding: " + _file);
FileInputStream fi = new FileInputStream(_file);
origin = new BufferedInputStream(fi, BUFFER);
ZipEntry entry = new ZipEntry(_file.substring(_file.lastIndexOf("/") + 1));
out.putNextEntry(entry);
int count;
while ((count = origin.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
}
origin.close();
//}
out.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}

1373
app/src/main/java/com/likesoft/mdedal/MainActivity.java

File diff suppressed because it is too large Load Diff

410
app/src/main/java/com/likesoft/mdedal/MyXMLSerializer.java

@ -0,0 +1,410 @@ @@ -0,0 +1,410 @@
package com.likesoft.mdedal;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.xmlpull.v1.XmlSerializer;
/*
* NOT USED CLASS
*/
class MyXMLSerializer implements XmlSerializer{
private class MyXMLSerializerData {
public OutputStream m_os;
public boolean started;
public MyXMLSerializerData(OutputStream m_os, boolean started) {
this.m_os = m_os;
this.started = started;
}
}
MyXMLSerializerData data = new MyXMLSerializerData(null, false);
// dst = new File(getFilesDir().getAbsolutePath() + "/baza/" + genName);
// fos = new FileOutputStream(dst);
// XmlSerializer xmlSerializer = new MyXMLSerializer();
// xmlSerializer.setOutput(fos, "UTF-8");
// zapiszAsXML(js, xmlSerializer);
// fos.flush();
// fos.close();
//http://stackoverflow.com/questions/9869507/how-to-create-an-xml-using-xmlserializer-in-android-app
void zapiszAsXML(JSONObject jo, XmlSerializer xS, String m_id, JSONObject js){
try {
xS.startDocument("UTF-8", true);
// xS.startDocument("UTF_8", true);
// xS.startDocument(Xml.Encoding.UTF_8, true);
//Xml.Encoding UTF_8
// Xml.Encoding.UTF_8
xS.startTag("", "zlecenia");
xS.startTag("", "zlecenie");
xS.startTag("", "id_zlecenia");
xS.text(m_id);
xS.endTag("", "id_zlecenia");
try {
xS.startTag("", "id_szablonu");
JSONObject zlecenie_param = js.getJSONObject("param");
xS.text(zlecenie_param.getString("id_szablonu"));
xS.endTag("", "id_szablonu");
JSONObject pola = js.getJSONObject("pola");
ArrayList<JSONObject> aM = new ArrayList<JSONObject>();
//if()
// for( int i=0; i<pola.length(); i++){
if( pola.length() >0){
xS.startTag("", "childs");
Iterator k = pola.keys();
while (k.hasNext()) {
String key = (String) k.next();
JSONObject joP = pola.getJSONObject(key);
aM.add(joP);
}
sortujKolejnosc(aM);
for( int z=0; z<aM.size(); z++){
JSONObject joP =(JSONObject) aM.get(z);
zapiszPolaXML( joP, xS );
}
xS.endTag("", "childs");
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
xS.endTag("", "zlecenie");
xS.endTag("", "zlecenia");
xS.flush();
xS.endDocument();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// xS.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
//Open Tag <file>
}
private void zapiszPolaXML(JSONObject joP, XmlSerializer xS) {
// TODO Auto-generated method stub
try {
xS.startTag("", "pole");
xS.attribute("", "kod", joP.getString("kod"));
xS.startTag("", "wartosc");
String typ = joP.getString("typ_danych");
if( "radiolista".equals(typ)){
JSONArray ja = joP.getJSONArray("childs");
if( ja!= null && ja.length()>0){
for ( int i=0; i<ja.length(); i++){
if( "on".equals(ja.getJSONObject(i).getString("wartosc"))){
xS.text(ja.getJSONObject(i).getString("kod"));
}
}
}
}else{
xS.text(joP.getString("wartosc"));
}
xS.endTag("", "wartosc");
JSONArray ja = joP.getJSONArray("childs");
if( ja!= null && ja.length()>0){
xS.startTag("", "childs");
for ( int i=0; i<ja.length(); i++){
zapiszPolaXML( ja.getJSONObject(i), xS);
}
xS.endTag("", "childs");
}
xS.endTag("", "pole");
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void sortujKolejnosc(ArrayList<JSONObject> aM) {
Collections.sort(aM, new Comparator<JSONObject>() {
@Override
public int compare(JSONObject lhs, JSONObject rhs) {
// TODO Auto-generated method stub
try {
if( lhs.getInt("kolejnosc") >(rhs.getInt("kolejnosc"))){
return 1;
}else if( lhs.getInt("kolejnosc") < (rhs.getInt("kolejnosc"))){
return -1;
}else{
if( lhs.getInt("id") > (rhs.getInt("id")))
return 1;
else if ( lhs.getInt("id") < (rhs.getInt("id")))
return -1;
return 0;
}
} catch (JSONException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
return 0;
}
});
}
@Override
public void startDocument(String encoding, Boolean standalone)
throws IOException, IllegalArgumentException,
IllegalStateException {
// TODO Auto-generated method stub
data.m_os.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>".getBytes());
}
@Override
public XmlSerializer startTag(String namespace, String name)
throws IOException, IllegalArgumentException,
IllegalStateException {
// TODO Auto-generated method stub
if( data.started){
data.m_os.write(">".getBytes());
data.started = false;
}
StringBuffer b = new StringBuffer();
b.append("<");
b.append(name);
b.append(" ");
data.m_os.write(b.toString().getBytes());
data.started = true;
return this;
}
@Override
public XmlSerializer text(String text) throws IOException,
IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
if( data.started){
data.m_os.write(">".getBytes());
data.started = false;
}
data.m_os.write(text.getBytes());
return this;
}
@Override
public XmlSerializer attribute(String namespace, String name,
String value) throws IOException, IllegalArgumentException,
IllegalStateException {
StringBuffer b = new StringBuffer();
b.append(name);
b.append("=\"");
b.append(value);
b.append("\" ");
data.m_os.write(b.toString().getBytes());
return this;
}
@Override
public XmlSerializer endTag(String namespace, String name)
throws IOException, IllegalArgumentException,
IllegalStateException {
if( data.started){
data.m_os.write(">".getBytes());
data.started = false;
}
StringBuffer b = new StringBuffer();
b.append("</");
b.append(name);
b.append(">");
data.m_os.write(b.toString().getBytes());
return this;
}
@Override
public void setOutput(OutputStream os, String encoding)
throws IOException, IllegalArgumentException,
IllegalStateException {
// TODO Auto-generated method stub
data.m_os = os;
}
@Override
public void cdsect(String text) throws IOException,
IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void comment(String text) throws IOException,
IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void docdecl(String text) throws IOException,
IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void endDocument() throws IOException, IllegalArgumentException,
IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void entityRef(String text) throws IOException,
IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void flush() throws IOException {
// TODO Auto-generated method stub
}
@Override
public int getDepth() {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean getFeature(String name) {
// TODO Auto-generated method stub
return false;
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getNamespace() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getPrefix(String namespace, boolean generatePrefix)
throws IllegalArgumentException {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getProperty(String name) {
// TODO Auto-generated method stub
return null;
}
@Override
public void ignorableWhitespace(String text) throws IOException,
IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void processingInstruction(String text) throws IOException,
IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void setFeature(String name, boolean state)
throws IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void setOutput(Writer writer) throws IOException,
IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void setPrefix(String prefix, String namespace)
throws IOException, IllegalArgumentException,
IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public void setProperty(String name, Object value)
throws IllegalArgumentException, IllegalStateException {
// TODO Auto-generated method stub
}
@Override
public XmlSerializer text(char[] buf, int start, int len)
throws IOException, IllegalArgumentException,
IllegalStateException {
// TODO Auto-generated method stub
return null;
}
}

295
app/src/main/java/com/likesoft/mdedal/PreferActivity.java

@ -0,0 +1,295 @@ @@ -0,0 +1,295 @@
package com.likesoft.mdedal;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.provider.Settings;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
//import com.likesoft.mdedaltest.*;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.likesoft.mdedal.ListActivity.LOG;
public class PreferActivity extends Activity {
private static final int REQ_STORAGE_PERMISSION = 1001;
private static final int REQ_MANAGE_ALL_FILES = 2296;
// EditText hostName;
EditText user;
EditText password;
EditText newpassword;
// CheckBox tablet;
// Spinner refresh;
//TextView version;
TextView textViewHostUrl;
SharedPreferences prefs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_prefer);
// hostName = (EditText) findViewById(R.id.editTextHost);
user = (EditText) findViewById(R.id.editTextUser);
password = (EditText) findViewById(R.id.editTextPassword);
newpassword = (EditText) findViewById(R.id.editTextNewPassword);
// tablet = (CheckBox) findViewById(R.id.checkBoxTablet);
// refresh = (Spinner) findViewById(R.id.spinner_refresh);
//version = (TextView) findViewById(R.id.textViewVersion);
//textViewHostUrl
textViewHostUrl = (TextView) findViewById(R.id.textViewHostUrl);
PackageInfo pinfo;
try {
pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
//versionNumber = pinfo.versionCode;
String versionName = pinfo.versionName;
//version.setText("Wersja aplikacji: "+versionName);
setTitle("Logowanie - Wersja aplikacji: "+versionName);
} catch (PackageManager.NameNotFoundException e2) {
Log.e(LOG, "", e2);
}
Context context = getApplicationContext();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
updateUI();
//Log.d("my_debug", "oncreate prefs");
Button ok = (Button)findViewById(R.id.buttonSave);
ok.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Zanim zapiszemy preferencje, upewnijmy się, że mamy dostęp do pamięci
if (!hasStorageAccess()) {
requestStorageAccess();
Toast.makeText(PreferActivity.this, "Brak uprawnień do zapisu w pamięci. Przyznaj uprawnienie i spróbuj ponownie.", Toast.LENGTH_LONG).show();
return;
}
if( newpassword.getText().toString().length()>0){
savePreferences();
new Thread( new Runnable() {
@Override
public void run() {
DedalHttpConnection con = new DedalHttpConnection(getApplicationContext());
Map<String, String> params_post = new HashMap<String, String>();
params_post.put("oldpass", password.getText().toString());
params_post.put("pass1", newpassword.getText().toString());
params_post.put("pass2", newpassword.getText().toString());
String response = "";
try{
response = con.sendPost("public/mobi.php?page=login_change", params_post);
}catch (Exception e){
Log.e( "BLAD ", "Bląd połączenia");
}
if( response.contains("zmienione") ) {
//jeśli się powiodło:
// password.setText(newpassword.getText());
Editor e = prefs.edit();
e.putString("password", DedalHelper.encodeB64(newpassword.getText().toString()));
e.commit();
Log.d("PASSWORD", "hasło zostało zmienione na: "+ newpassword.getText().toString());
//savePreferences();
Button ok = (Button)findViewById(R.id.buttonSave);
ok.post(new Runnable() {
@Override
public void run() {
Toast.makeText(PreferActivity.this, "Hasło zmienione.", Toast.LENGTH_LONG);
PreferActivity.this.setResult(RESULT_OK);
finish();
}
});
}
else {
Log.d("PASSWORD", "problem ze zmianą hasła, response: " + response);
Toast.makeText(PreferActivity.this, "Problem ze zmianą hasła", Toast.LENGTH_LONG);
}
}
}).start();
}else {
savePreferences();
PreferActivity.this.setResult(RESULT_OK);
finish();
}
}
});
}
private boolean hasStorageAccess() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return Environment.isExternalStorageManager();
} else {
int write = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
int read = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
return write == PackageManager.PERMISSION_GRANTED && read == PackageManager.PERMISSION_GRANTED;
}
}
private void requestStorageAccess() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
try {
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
intent.setData(Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, REQ_MANAGE_ALL_FILES);
} catch (Exception ex) {
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
startActivityForResult(intent, REQ_MANAGE_ALL_FILES);
}
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE},
REQ_STORAGE_PERMISSION);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQ_MANAGE_ALL_FILES) {
if (hasStorageAccess()) {
Toast.makeText(this, "Przyznano dostęp do plików.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Dostęp do plików nadal zablokowany.", Toast.LENGTH_LONG).show();
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQ_STORAGE_PERMISSION) {
boolean granted = true;
if (grantResults == null || grantResults.length == 0) granted = false;
for (int r : grantResults) {
if (r != PackageManager.PERMISSION_GRANTED) { granted = false; break; }
}
if (granted) {
Toast.makeText(this, "Uprawnienia do pamięci przyznane.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Odmówiono uprawnień do pamięci.", Toast.LENGTH_LONG).show();
}
}
}
public static void deleteFiles(String path) {
File file = new File(path);
if (file.exists()) {
String deleteCmd = "rm -r " + path;
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(deleteCmd);
} catch (IOException e) { }
}
}
void savePreferences() {
// TODO Auto-generated method stub
String currentHost = prefs.getString("hostName", "https://dedal.eos-ksi.pl");
Editor e = prefs.edit();
e.putString("hostName", currentHost);
// e.putBoolean("tablet", tablet.isChecked());
String login = user.getText().toString().trim();
if( login.contains("@")){
String loginTable[] = login.split("@");
e.putString("user", loginTable[0]);
if("reset".equals(loginTable[1]) ){
e.putString("certSerialNumber", "");
deleteFiles(Environment.getExternalStorageDirectory()+ "/dedal/");
}else {
if( loginTable[1].startsWith("http")) {
e.putString("hostName", loginTable[1]);
}
}
login = loginTable[0];
}else {
e.putString("user", login);
}
e.putString("password", DedalHelper.encodeB64(password.getText().toString()));
// e.putInt("refresh", refresh.getSelectedItemPosition());
String dirPath = Environment.getExternalStorageDirectory()+ "/dedal/"+ login;
e.putString("dir", dirPath);
e.putBoolean("tablet", true);
e.putInt("refresh", 2);
e.commit();
// Utwórz folder użytkownika jeśli nie istnieje
try {
File dir = new File(dirPath);
if (!dir.exists()) {
boolean ok = dir.mkdirs();
if (!ok) {
Toast.makeText(this, "Nie można utworzyć katalogu:" + dirPath, Toast.LENGTH_LONG).show();
}
}
} catch (Throwable t) {
Log.e(LOG, "Błąd tworzenia katalogu: " + t.getMessage(), t);
}
//usunięcie starej aplikacji:
deleteFiles(Environment.getExternalStorageDirectory()+ "/likesoft");
deleteFiles(Environment.getExternalStorageDirectory()+ "/likesofttest");
File fLockLogin = new File(prefs.getString("dir", "") + "/dedalsrv.wrongLogin");
if( fLockLogin.exists()){
fLockLogin.delete();
}
}
private void updateUI() {
// tablet.setChecked(prefs.getBoolean("tablet", false));
// hostName.setText(prefs.getString("hostName", "http://likesoft/dedal/develop/psql"));
// hostName.setText(prefs.getString("hostName", "https://dedal.eos-ksi.pl"));
user.setText(prefs.getString("user", ""));
password.setText("");
textViewHostUrl.setText(prefs.getString("hostName", "https://dedal.eos-ksi.pl"));
//password.setText(prefs.getString("password", ""));
// refresh.setSelection(prefs.getInt("refresh", 0));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.prefer, menu);
return true;
}
}

294
app/src/main/java/com/likesoft/mdedal/RefreshLayoutAndThread.java

@ -0,0 +1,294 @@ @@ -0,0 +1,294 @@
package com.likesoft.mdedal;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.io.File;
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* Created by Kamil on 2016-02-04.
*/
abstract class RefreshLayoutAndThread extends Thread implements Runnable {
private final static int THREAD_PERIOD = 1000;
public boolean pauseThread = false;
Context context;
SharedPreferences prefs;
LinearLayout refreshLayout;
////
long lastProfileMod = 0;
TextView textDataMod;
TextView textUpload = null;
ProgressBar progress;
String sLastInfo = "";
boolean stare = false;
public RefreshLayoutAndThread(Context context) {
this.context = context;
prefs = PreferenceManager.getDefaultSharedPreferences(context);
textUpload = new TextView(context);
textUpload.setPadding(20, 0, 20, 0);
}
//protected abstract void reloadContent();
protected abstract void whenThreadNeedToReaoad();
protected abstract void setLastGPSInfo_abstr();
protected void onServiceFinisz() {
}
public LinearLayout getRefreshLayout() {
refreshLayout = new LinearLayout(context);
//LinearLayout refreshLayout = new LinearLayout(this);
//filterL.addView(refreshLayout);
textDataMod = new TextView(context);
// = tw;
textDataMod.setTextAppearance(context, R.style.OpisTextLista);
refreshLayout.addView(textDataMod);
progress = new ProgressBar(context);
progress.setProgress(50);
refreshLayout.addView(progress);
AsyncTask at = new AsyncTask() {
@Override
protected Object doInBackground(Object[] objects) {
File dLista = new File(prefs.getString("dir", "") + "/baza/lista.profil");
if( dLista.isFile()){
long lastMod = dLista.lastModified();
lastProfileMod = lastMod;
setLastInfo(lastProfileMod);
}
return null;
}
};
at.execute();
Button b = new Button(context);
b.setText("Odśwież");
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pauseThread = false;
//Context context = getApplicationContext();
Alarm alarm = new Alarm();
alarm.CancelAlarm(context);
alarm.SetAlarm(context);
Intent service = new Intent(context, DedalService.class);
context.startService(service);
//todo: temp commented
//search = "";
//wyswietlListe();
}
});
refreshLayout.addView(b); //refresh button
return refreshLayout;
}
public TextView getTextUpload () {
return textUpload;
}
@Override
public void run() {
// TODO Auto-generated method stub
while( true){
try {
Thread.sleep(THREAD_PERIOD);
if( pauseThread ) {
//Log.d("RefreshLayoutAndThread", "pause");
}
else {
//Log.d("RefreshLayoutAndThread", "thread working");
setLastGPSInfo_abstr();
setLastUpdateInfo();
setLastInfo(lastProfileMod);
File dLista = new File(prefs.getString("dir", "") + "/baza/lista.profil");
if (dLista.isFile()) {
long lastMod = dLista.lastModified();
if (lastProfileMod != lastMod) {
lastProfileMod = lastMod;
// setLastInfo(lastProfileMod);
//
textDataMod.post(new Runnable() {
@Override
public void run() {
whenThreadNeedToReaoad();
// ListActivity.this.recreate();
//ListActivity.this.finish();
}
});
}
}
}
} catch (InterruptedException e) {
Log.d("RefreshLayoutAndThread", "interrupted");
break;
}
}
}
private void setLastInfo(long lastProfileMod){
//gps.isGPSEnabled
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d = new Date(lastProfileMod);
Date dCurrent = new Date();
long c = dCurrent.getTime() - 60*60*1000; //godzina
//Date dCurrent = new Date();
// boolean stare = false;
if( lastProfileMod < c){
// dawno nie było aktualizacji
stare = true;
}else{
stare = false;
}
File dQ = new File(prefs.getString("dir", "") + "/queue");
if( dQ.isDirectory() && dQ.list().length>0 ){
//sAktualizacja = "Trwa pobieranie zleceń ("+dQ.list().length+")...";
sLastInfo = "Trwa pobieranie zleceń ("+dQ.list().length+")... \nPoprzednia:"
+ sdf.format(d);
}
else {
//sAktualizacja = "";
sLastInfo = "Ostatnia aktualizacja:\n";
sLastInfo += sdf.format(d);
// sLastInfo += "\n" + sdf.format(c) + " stare: " + stare;
}
//sLastInfo = "Ostatnia akutalizacja:\n" + sdf.format(d);
textDataMod.post(new Runnable() {
@Override
public void run() {
textDataMod.setText(sLastInfo);
if(stare) {
textDataMod.setBackgroundColor(Color.RED);
}else{
textDataMod.setBackgroundColor(Color.TRANSPARENT);
//textDataMod.setTextAppearance(context, R.style.OpisTextLista);
//textDataMod.setTextAppearance();
}
}
});
}
private int licznikUpdates=0;
private String sAktualizacja = "";
public void setLastUpdateInfo(){
File fLockEnd = new File(prefs.getString("dir", "") + "/dedalsrv.lock");
if( fLockEnd.exists()){
//sAktualizacja = "Aktualizacja\n zleceń ";// + kreciolek[licznikUpdates % 4];
//licznikUpdates++;
licznikUpdates=1;
}else{
licznikUpdates = 0;
// File d = new File(prefs.getString("dir", "") + "/queue");
// if( d.isDirectory() && d.list().length>0 ){
// sAktualizacja = "Trwa pobieranie zleceń ("+d.list().length+")...";
// }
// else {
// sAktualizacja = "";
// }
}
sAktualizacja = "";
File fconn = new File(prefs.getString("dir", "") + "/dedalsrv.connection");
if( fconn.exists()){
sAktualizacja = "!";//Problem z połączeniem! VPN lub błędne hasło.";
}
File fLockCon = new File(prefs.getString("dir", "") + "/dedalsrv.connection_password");
if( fLockCon.exists()){
sAktualizacja = "Zmien hasło, zlecenie NIE zapisane!";
}
File fConnectionStatus = new File(prefs.getString("dir", "") + "/dedal.status");
if( fConnectionStatus.exists()){
String msg = "";
try {
FileInputStream fin = new FileInputStream(fConnectionStatus);
msg = ListActivity.readFile(fin);
}catch (Exception e){
Log.e("ListActivity", e.getMessage(), e);
}
sAktualizacja += msg;
}
File fLockLogin = new File(prefs.getString("dir", "") + "/dedalsrv.wrongLogin");
if( fLockLogin.exists()){
sAktualizacja = "Ustaw login i hasło. ";
if(fLockLogin.exists()){
if( context instanceof ListActivity) {
ListActivity lA = (ListActivity)context;
fLockLogin.delete();
Intent i = new Intent(lA, lA.getPreferActivity());
lA.startActivityForResult(i, lA.SHOW_PREFERENCES);
}
}
}
textUpload.post(new Runnable() {
@Override
public void run() {
textUpload.setText(sAktualizacja);
if( "".equals(sAktualizacja)){
textUpload.setBackgroundColor(Color.parseColor("white"));
}else{
textUpload.setBackgroundColor(Color.parseColor("yellow"));
}
if( licznikUpdates==0){
if( progress.getVisibility() == View.VISIBLE ) {
onServiceFinisz();
}
progress.setVisibility(View.INVISIBLE);
}else{
progress.setVisibility(View.VISIBLE);
}
}
});
}
}

817
app/src/main/java/com/likesoft/mdedal/TableHeadersActivity.java

@ -0,0 +1,817 @@ @@ -0,0 +1,817 @@
package com.likesoft.mdedal;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.likesoft.mdedal.gui.BorderTextView;
import com.likesoft.mdedal.gui.MTextView;
//import com.likesoft.mdedaltest.*;
import com.likesoft.mdedaldemo.*;
import android.app.Activity;
import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Point;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Display;
//import android.util.Log;
import android.view.DragEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.DragShadowBuilder;
import android.view.View.OnClickListener;
import android.view.View.OnDragListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
public class TableHeadersActivity extends Activity {
String id_profilu = null;
String nazwa_profilu = null;
LinearLayout lContent = null;
LinearLayout lContent_nieuzyte = null;
JSONArray jkolumny_all = null;
SharedPreferences prefs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Context context = getApplicationContext();
prefs = PreferenceManager.getDefaultSharedPreferences(context);
Log.setFileName(prefs.getString("dir", ""));
Log.setEH();
Bundle extras = getIntent().getExtras();
if (extras != null) {
id_profilu = extras.getString("id_profilu");
}
File dtemp1 = new File(prefs.getString("dir", "") + "/temp/widok_profil_temp_"+id_profilu+".json");
dtemp1.delete();
loadjKolumny_all();
HorizontalScrollView lMainScroll = new HorizontalScrollView(this);
LinearLayout lMain = new LinearLayout(this);
ScrollView vertScroll = new ScrollView(this);
lMainScroll.addView(vertScroll);
vertScroll.addView(lMain);
lMain.setOrientation(LinearLayout.VERTICAL);
lMain.setOnDragListener(new MyDragListenerBack());
LinearLayout lHeader = new LinearLayout(this);
lHeader.setOrientation(LinearLayout.VERTICAL);
lMain.addView(lHeader);
lContent = new LinearLayout(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(0, 0, 0, 30);
lContent.setLayoutParams(layoutParams);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
lContent.setMinimumWidth(width);
lMain.addView(lContent);
// lContent.setMinimumHeight(30);
lContent.setBackgroundColor(Color.YELLOW);
lContent.setOnDragListener(new MyDragListener_move_end(Color.CYAN, Color.YELLOW));
//lContent.setLayoutParams(new LinearLayout.LayoutParams(300,600));
lContent_nieuzyte = new LinearLayout(this);
lMain.addView(lContent_nieuzyte);
lContent_nieuzyte.setMinimumHeight(55);
lContent_nieuzyte.setBackgroundColor(Color.DKGRAY);
lContent_nieuzyte.setOnDragListener(new MyDragListener_nieuzyte(Color.CYAN, Color.DKGRAY));
lContent_nieuzyte.setLayoutParams(layoutParams);
TextView tw = new TextView(this);
lHeader.addView(tw);
if( id_profilu == null ) {
tw.setText("Nie wykryto id_profilu !");
Log.d("my_debug", "nie wykryto profilu");
setContentView(lMainScroll);
//setContentView(lMain);
return ;
}
//EditText et = new EditText(this);
tw.setTextSize(20);
tw.setPadding(5,5,5,5);
tw.setText("Profil: "+nazwa_profilu);
TextView tw_opis = new TextView(this);
lHeader.addView(tw_opis);
tw_opis.setPadding(5,5,5,15);
tw_opis.setText("Poniżej wyświetlona jest lista nagłówków z tabeli listy zleceń. Poniższy układ jest wczytywany dla profilu: "+nazwa_profilu+".\n" +
"Aby zmienić układ, naciśnij wybrany element, przytrzymaj a następnie przesuń w wybrane miejsce. \n" +
"Aby dany element nie był wyświetlany w tabeli zleceń, przesuń go na dolny szary pasek. \n" +
"Po zakończeniu ustawiania nagłówków, kliknij 'Zapisz układ'. Wtedy nastąpi wysłanie układu na serwer. \n" +
"Zostaniesz przekierowany na listę zleceń i należy poczekać aż lista przeładuje się z nowym układem.\n" +
"UWAGA: Zmiana nagłówków działa tylko w trybie online (wymaga aktywnego połączenia internetowego).\n" +
"Przycisk: 'Przywróć ustawienia domyślne' - skasuje ustawienia nagłówków i przywróci domyślny układ. \n" +
"\tPo naciśnięciu aplikacja przejdzie do listy zleceń. Należy poczekać aż system skomunikuje się z serwerem i przeładuję liste.\n" +
"Przycisk 'Cofnij zmiany' - skasuje aktualne ustawienie\n" +
"Przycisk 'Wyjdź' - skasuje aktualne ustawienie i wyjdzie do listy zleceń");
//////////
drawContent();
LinearLayout footer = new LinearLayout(this);
footer.setOrientation(LinearLayout.HORIZONTAL);
lMain.addView(footer);
Button zapisz = new Button(this);
zapisz.setText("Zapisz układ");
zapisz.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Date d = new Date();
String genName = "widok_profil_"+d.getTime() + ".mod";
File dstDir = new File(prefs.getString("dir", "") + "/upload_widok_profil_mod");
if( !dstDir.isDirectory()){ dstDir.mkdirs(); }
File fMod = new File(prefs.getString("dir", "") + "/upload_widok_profil_mod/" + genName);
File dtemp = new File(prefs.getString("dir", "") + "/temp/widok_profil_temp_"+id_profilu+".json");
if ( dtemp.exists() ) {
JSONObject jFile;
try {
String s = DedalHelper.getFileContent(dtemp.getAbsolutePath());
jFile = new JSONObject(s);
jFile.put("id_profilu", id_profilu);
DedalHelper.putFileContent(dtemp.getAbsolutePath(), jFile.toString());
} catch (JSONException e) {
Log.e("TableHeadersActivity", "", e);
}
}
// wystartuj/obudz serwis
Context context = getApplicationContext();
Intent service = new Intent(context, DedalService.class);
context.startService(service);
finish();
}
});
footer.addView(zapisz);
Button przywroc = new Button(this);
przywroc.setText("Przywróć domyślny układ nagłówków");
przywroc.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
File dtemp1 = new File(prefs.getString("dir", "") + "/temp/widok_profil_temp_"+id_profilu+".json");
dtemp1.delete();
JSONObject jF = new JSONObject();
jF.put("id_profilu", id_profilu);
jF.put("reset", "true");
Date d = new Date();
String genName = "widok_profil_"+d.getTime() + ".mod";
DedalHelper.putFileContent(prefs.getString("dir", "") + "/upload_widok_profil_mod/" + genName, jF.toString());
} catch (JSONException e) {
//e.printStackTrace();
Log.e("TableHeadersActivity", "", e);
}
// wystartuj/obudz serwis
Context context = getApplicationContext();
Intent service = new Intent(context, DedalService.class);
context.startService(service);
finish();
}
});
footer.addView(przywroc);
Button clear = new Button(this);
clear.setText("Cofnij zmiany");
clear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
File dtemp1 = new File(prefs.getString("dir", "") + "/temp/widok_profil_temp_"+id_profilu+".json");
dtemp1.delete();
TableHeadersActivity.this.recreate();
}
});
footer.addView(clear);
Button wyjdz = new Button(this);
wyjdz.setText("Wyjdź");
wyjdz.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
File dtemp1 = new File(prefs.getString("dir", "") + "/temp/widok_profil_temp_"+id_profilu+".json");
dtemp1.delete();
//TableHeadersActivity.this.recreate();
finish();
//drawContent();
}
});
footer.addView(wyjdz);
setContentView(lMainScroll);
this.setTitle("Zarządzanie nagłówkami tabeli");
}
private void loadjKolumny_all() {
BufferedReader buf;
File dLista = new File(prefs.getString("dir", "") + "/baza/lista.profil");
JSONObject jFile;
try {
String sJson = DedalHelper.getFileContent(dLista.getAbsolutePath());
jFile = new JSONObject(sJson);
JSONObject jProfiles = jFile.getJSONObject("profile");
JSONObject jProfil = jProfiles.getJSONObject(id_profilu);
nazwa_profilu = jProfil.getString("nazwa_profilu");
JSONArray jKolumny_uzyte = jProfil.getJSONArray("profil_kolumny");
//if( jProfil.has("kolumny_nieuzyte") && !jProfil.getString("kolumny_nieuzyte").equals("null") && jProfil.getJSONArray("kolumny_nieuzyte") != null ) {
JSONArray jKolumny_nieuzyte = jProfil.getJSONArray("kolumny_nieuzyte");
jkolumny_all = new JSONArray(jKolumny_uzyte.toString());
if( jKolumny_nieuzyte != null && jKolumny_nieuzyte.length() > 0 ) {
for( int i = 0 ; i < jKolumny_nieuzyte.length() ; i++ ) {
jkolumny_all.put( jKolumny_nieuzyte.getJSONObject(i) );
}
}
//}
//Log.d("my_debug", "jkolumny_all: "+jkolumny_all.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("DEDAL", "blad parsowania lista.profil", e);
}
}
private void drawContent() {
try {
//lContent = null;
lContent.removeAllViews();
BufferedReader buf;
JSONArray jKolumny = null;
File dtemp = new File(prefs.getString("dir", "") + "/temp/widok_profil_temp_"+id_profilu+".json");
if ( dtemp.exists() ) {
String sJson = DedalHelper.getFileContent(dtemp.getAbsolutePath());
JSONObject jFile = new JSONObject(sJson);
jKolumny = jFile.getJSONArray("profil_kolumny");
Log.d("my_debug", "1: "+jKolumny.toString());
}
else {
File dLista = new File(prefs.getString("dir", "") + "/baza/lista.profil");
String sJson = DedalHelper.getFileContent(dLista.getAbsolutePath());
JSONObject jFile = new JSONObject(sJson);
JSONObject jProfiles = jFile.getJSONObject("profile");
JSONObject jProfil = jProfiles.getJSONObject(id_profilu);
jKolumny = jProfil.getJSONArray("profil_kolumny");
}
int k = 0;
for( k = 0; k < jKolumny.length(); k++)
{
BorderTextView mtw = new BorderTextView(this);
// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
// params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
// mtw.setLayoutParams(params);
mtw.setTextAppearance(this, R.style.OpisText);
mtw.setPadding(15, 15, 15, 15);
String kod = jKolumny.getJSONObject(k).getString("kod");
mtw.setCode(kod);
mtw.setId(k);
String nazwa = jKolumny.getJSONObject(k).getString("nazwa");
mtw.setText(nazwa);
//tw.setBackgroundColor(Color.parseColor("#AFA5F0"));// #FAFAD2
//mtw.setPadding(5, 3, 5, 2);
// tw.setTextSize(TypedValue.COMPLEX_UNIT_MM, 5);
mtw.setBackgroundColor(Color.GREEN);
mtw.setOnTouchListener(new MyTouchListener());
mtw.setOnDragListener(new MyDragListener(Color.CYAN, Color.GREEN));
lContent.addView(mtw);
}
TextView tw_end = new TextView(this);
tw_end.setPadding(0, 18, 0, 18);
tw_end.setText(" ");
tw_end.setWidth(150);
lContent.addView(tw_end);
lContent_nieuzyte.removeAllViews();
Log.d("my_debug", "Ajkolumny_all: "+jkolumny_all.toString());
boolean cont = false;
for( int m=0; m < jkolumny_all.length(); m++)
{
cont = false;
// sprawdz czy jest używany
for( int l=0; l< jKolumny.length(); l++)
{
//Log.d("my_debug", "uzyty: "+jKolumny.getJSONObject(l).getString("kod")+", all: "+jkolumny_all.getJSONObject(k).getString("kod"));
if( jKolumny.getJSONObject(l).getString("kod").equals(jkolumny_all.getJSONObject(m).getString("kod")) ) {
cont = true;
break;
}
}
if( cont ) {
continue;
}
BorderTextView mtw = new BorderTextView(this);
mtw.setTextAppearance(this, R.style.OpisText);
mtw.setPadding(15, 15, 15, 15);
String kod = jkolumny_all.getJSONObject(m).getString("kod");
mtw.setCode(kod);
k++;
mtw.setId(k);
String nazwa = jkolumny_all.getJSONObject(m).getString("nazwa");
mtw.setText(nazwa);
mtw.setBackgroundColor(Color.RED);
mtw.setOnTouchListener(new MyTouchListener());
//mtw.setOnDragListener(new MyDragListener());
lContent_nieuzyte.addView(mtw);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
class MyDragListenerBack implements OnDragListener {
@Override
public boolean onDrag(View onDropEl, DragEvent event) {
int action = event.getAction();
View movingEl = (View) event.getLocalState();
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
break;
case DragEvent.ACTION_DRAG_ENTERED:
//v.setBackgroundDrawable(enterShape);
//onDropEl.setBackgroundColor(Color.GRAY);
break;
case DragEvent.ACTION_DRAG_EXITED:
//v.setBackgroundDrawable(normalShape);
//onDropEl.setBackgroundColor(Color.RED);
break;
case DragEvent.ACTION_DROP:
// Dropped, reassign View to ViewGroup
movingEl.setVisibility(View.VISIBLE);
movingEl.setAlpha(1);
break;
case DragEvent.ACTION_DRAG_ENDED:
//v.setBackgroundDrawable(normalShape);
default:
break;
}
return true;
}
}
class MyDragListener implements OnDragListener {
int color_entered = 0;
int color_exited = 0;
public MyDragListener(int color_entered, int color_exited) {
this.color_entered = color_entered;
this.color_exited = color_exited;
}
@Override
public boolean onDrag(View onDropEl, DragEvent event) {
int action = event.getAction();
View movingEl = (View) event.getLocalState();
int id_moving = movingEl.getId();
int id_drop = onDropEl.getId();
int side = Math.round(event.getX() - onDropEl.getMeasuredWidth() / 2 ); // side < 0 uposzczone po lewej stronie elementu, side > 0 upuszczone po prawej stronie
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
break;
case DragEvent.ACTION_DRAG_ENTERED:
//v.setBackgroundDrawable(enterShape);
onDropEl.setBackgroundColor(color_entered);
break;
case DragEvent.ACTION_DRAG_EXITED:
//v.setBackgroundDrawable(normalShape);
onDropEl.setBackgroundColor(color_exited);
break;
case DragEvent.ACTION_DROP:
// Dropped, reassign View to ViewGroup
if( id_moving == id_drop ) {
movingEl.setAlpha(1);
movingEl.setBackgroundColor(color_exited);
break;
}
JSONObject jmain = new JSONObject();
JSONArray jprofil = new JSONArray();
// create Json
// float x = event.getX();
// float y = event.getY();
Log.d("my_debug", "side: "+side);
try {
for (int i = 0 ; i < 200 ; i++ ) {
MTextView v = (MTextView)TableHeadersActivity.this.findViewById(i);
if ( v == null) {
break;
}
if( i == id_drop || i == id_moving) {
//if( id_drop < id_moving ) {
if( i == id_drop ) {
//i = id_moving;
MTextView v_temp = null;
JSONObject jcurr = null;
if(side >= 0 ) {
v_temp = (MTextView)TableHeadersActivity.this.findViewById(id_drop);
jcurr = new JSONObject();
jcurr.put("kod", v_temp.getCode());
jcurr.put("nazwa", v_temp.getText());
jprofil.put(jcurr);
v_temp = (MTextView)TableHeadersActivity.this.findViewById(id_moving);
if( v_temp != null ) {
jcurr = new JSONObject();
jcurr.put("kod", v_temp.getCode());
jcurr.put("nazwa", v_temp.getText());
jprofil.put(jcurr);
}
}
else {
v_temp = (MTextView)TableHeadersActivity.this.findViewById(id_moving);
if( v_temp != null ) {
jcurr = new JSONObject();
jcurr.put("kod", v_temp.getCode());
jcurr.put("nazwa", v_temp.getText());
jprofil.put(jcurr);
}
v_temp = (MTextView)TableHeadersActivity.this.findViewById(id_drop);
jcurr = new JSONObject();
jcurr.put("kod", v_temp.getCode());
jcurr.put("nazwa", v_temp.getText());
jprofil.put(jcurr);
}
}
if( i == id_moving ) {
continue;
}
}
else {
JSONObject jcurr = new JSONObject();
jcurr.put("kod", v.getCode());
jcurr.put("nazwa", v.getText());
jprofil.put(jcurr);
}
}
jmain.put("profil_kolumny", jprofil);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
onDropEl.setBackgroundColor(Color.DKGRAY);
movingEl.setVisibility(View.VISIBLE);
String genName = "widok_profil_temp_"+id_profilu+".json";
File dstDir = new File(prefs.getString("dir", "") + "/temp");
if( !dstDir.isDirectory()){ dstDir.mkdirs(); }
File fMod = new File(prefs.getString("dir", "") + "/temp/" + genName);
FileOutputStream fos;
try {
fos = new FileOutputStream(fMod);
fos.write(jmain.toString().getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//TableHeadersActivity.this.recreate();
drawContent();
break;
case DragEvent.ACTION_DRAG_ENDED:
//v.setBackgroundDrawable(normalShape);
default:
break;
}
return true;
}
}
class MyDragListener_move_end implements OnDragListener {
//nieużywane
int color_entered = 0;
int color_exited = 0;
public MyDragListener_move_end(int color_entered, int color_exited) {
this.color_entered = color_entered;
this.color_exited = color_exited;
}
@Override
public boolean onDrag(View onDropEl, DragEvent event) {
int action = event.getAction();
View movingEl = (View) event.getLocalState();
//int side = Math.round(event.getX() - onDropEl.getMeasuredWidth() / 2 ); // side < 0 uposzczone po lewej stronie elementu, side > 0 upuszczone po prawej stronie
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
break;
case DragEvent.ACTION_DRAG_ENTERED:
//v.setBackgroundDrawable(enterShape);
//onDropEl.setBackgroundColor(color_entered);
break;
case DragEvent.ACTION_DRAG_EXITED:
//v.setBackgroundDrawable(normalShape);
//onDropEl.setBackgroundColor(color_exited);
break;
case DragEvent.ACTION_DROP:
// Dropped, reassign View to ViewGroup
int id_moving = movingEl.getId();
int id_drop = onDropEl.getId();
JSONObject jmain = new JSONObject();
JSONArray jprofil = new JSONArray();
// create Json
// float x = event.getX();
// float y = event.getY();
//Log.d("my_debug", "side: "+side);
try {
for (int i = 0 ; i < 200 ; i++ ) {
MTextView v = (MTextView)TableHeadersActivity.this.findViewById(i);
if ( v == null) {
break;
}
if( i == id_moving ) {
continue;
}
else {
JSONObject jcurr = new JSONObject();
jcurr.put("kod", v.getCode());
jcurr.put("nazwa", v.getText());
jprofil.put(jcurr);
}
}
MTextView v_temp = null;
JSONObject jcurr = null;
v_temp = (MTextView)TableHeadersActivity.this.findViewById(id_moving);
if( v_temp != null ) {
jcurr = new JSONObject();
jcurr.put("kod", v_temp.getCode());
jcurr.put("nazwa", v_temp.getText());
jprofil.put(jcurr);
}
jmain.put("profil_kolumny", jprofil);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
onDropEl.setBackgroundColor(Color.YELLOW);
movingEl.setVisibility(View.VISIBLE);
String genName = "widok_profil_temp_"+id_profilu+".json";
File dstDir = new File(prefs.getString("dir", "") + "/temp");
if( !dstDir.isDirectory()){ dstDir.mkdirs(); }
File fMod = new File(prefs.getString("dir", "") + "/temp/" + genName);
FileOutputStream fos;
try {
fos = new FileOutputStream(fMod);
fos.write(jmain.toString().getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//TableHeadersActivity.this.recreate();
drawContent();
break;
case DragEvent.ACTION_DRAG_ENDED:
//v.setBackgroundDrawable(normalShape);
default:
break;
}
return true;
}
}
class MyDragListener_nieuzyte implements OnDragListener {
int color_entered = 0;
int color_exited = 0;
public MyDragListener_nieuzyte(int color_entered, int color_exited) {
this.color_entered = color_entered;
this.color_exited = color_exited;
}
@Override
public boolean onDrag(View onDropEl, DragEvent event) {
int action = event.getAction();
View movingEl = (View) event.getLocalState();
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
break;
case DragEvent.ACTION_DRAG_ENTERED:
//v.setBackgroundDrawable(enterShape);
onDropEl.setBackgroundColor(color_entered);
break;
case DragEvent.ACTION_DRAG_EXITED:
//v.setBackgroundDrawable(normalShape);
onDropEl.setBackgroundColor(color_exited);
break;
case DragEvent.ACTION_DROP:
// Dropped, reassign View to ViewGroup
int id_moving = movingEl.getId();
int id_drop = onDropEl.getId();
JSONObject jmain = new JSONObject();
JSONArray jprofil = new JSONArray();
// create Json
try {
for (int i = 0 ; i < 200 ; i++ ) {
MTextView v = (MTextView)TableHeadersActivity.this.findViewById(i);
if ( v == null) {
break;
}
if( i == id_drop || i == id_moving) {
//if( id_drop < id_moving ) {
if( i == id_drop ) {
//i = id_moving;
MTextView v_temp = null;
JSONObject jcurr = null;
v_temp = (MTextView)TableHeadersActivity.this.findViewById(id_drop);
jcurr = new JSONObject();
jcurr.put("kod", v_temp.getCode());
jcurr.put("nazwa", v_temp.getText());
jprofil.put(jcurr);
v_temp = (MTextView)TableHeadersActivity.this.findViewById(id_moving);
if( v_temp != null ) {
jcurr = new JSONObject();
jcurr.put("kod", v_temp.getCode());
jcurr.put("nazwa", v_temp.getText());
jprofil.put(jcurr);
}
}
if( i == id_moving ) {
continue;
}
}
else {
JSONObject jcurr = new JSONObject();
jcurr.put("kod", v.getCode());
jcurr.put("nazwa", v.getText());
jprofil.put(jcurr);
}
}
jmain.put("profil_kolumny", jprofil);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
onDropEl.setBackgroundColor(Color.DKGRAY);
movingEl.setVisibility(View.VISIBLE);
String genName = "widok_profil_temp_"+id_profilu+".json";
File dstDir = new File(prefs.getString("dir", "") + "/temp");
if( !dstDir.isDirectory()){ dstDir.mkdirs(); }
File fMod = new File(prefs.getString("dir", "") + "/temp/" + genName);
FileOutputStream fos;
try {
fos = new FileOutputStream(fMod);
fos.write(jmain.toString().getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//TableHeadersActivity.this.recreate();
drawContent();
break;
case DragEvent.ACTION_DRAG_ENDED:
//v.setBackgroundDrawable(normalShape);
default:
break;
}
return true;
}
}
private final class MyTouchListener implements OnTouchListener {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
ClipData data = ClipData.newPlainText("", "");
DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
view.startDrag(data, shadowBuilder, view, 0);
//int alpha = 0;
//((TextView) view).setTextColor(Color.argb(alpha, 255, 0, 0));
view.setAlpha((float)0.3);
//view.setBackgroundColor(Color.YELLOW);
//view.setVisibility(View.INVISIBLE);
return true;
} else {
return false;
}
}
}
}

99
app/src/main/java/com/likesoft/mdedal/TimePickerFragment.java

@ -0,0 +1,99 @@ @@ -0,0 +1,99 @@
package com.likesoft.mdedal;
import android.app.Activity;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.TimePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* Created by Kamil on 2016-05-12.
*/
public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
public Integer nr_zlecenia;
public Activity act;
public String data_walidacja_do = null;
public TextView tv = null;
public Calendar setDate = null;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
//int day = c.get(Calendar.DAY_OF_MONTH);
// Create a new instance of DatePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, true);
}
private static final String DATA_KOD = "nast_wizyta_data";
@Override
public void onTimeSet(TimePicker timePicker, int i, int i2) {
setDate.add(Calendar.HOUR, i);
setDate.add(Calendar.MINUTE, i2);
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// String date_string = sdf.format(setDate.getTime());
Calendar c = setDate; //new GregorianCalendar(year, month, day);
Calendar cToday = new GregorianCalendar();
Calendar data_walidacja_do_cal = null;
if( data_walidacja_do != null ) {
try {
data_walidacja_do_cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
data_walidacja_do_cal.setTime(sdf.parse(data_walidacja_do));// all done
} catch (ParseException e) {
e.printStackTrace();
}
}
if( cToday.compareTo(c)>0){
Toast.makeText(act.getApplicationContext(),
"Nie można wybrać daty wstecznej dla wizyty nr: " + nr_zlecenia,
Toast.LENGTH_LONG).show();
}
else if( data_walidacja_do_cal != null && c.compareTo(data_walidacja_do_cal)>0 ) {
Toast.makeText(act.getApplicationContext(),
"Nie można wybrać daty przekraczającej datę obsługi: " + data_walidacja_do,
Toast.LENGTH_LONG).show();
}
else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String cString = sdf.format(c.getTime());
AsyncCallChangeDate task = new AsyncCallChangeDate(act, nr_zlecenia + "", DATA_KOD, cString) {
@Override
protected void reloadContent() {
// drawContent();
final Intent intent = new Intent();
intent.setAction("blah");
getActivity().sendBroadcast(intent);
dismiss();
}
@Override
public void loadInputs() {
// loadJsons();
}
}; // week_day_dates[id_drop]);
task.execute();
}
}
}

45
app/src/main/java/com/likesoft/mdedal/gui/BorderLinearLayout.java

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
package com.likesoft.mdedal.gui;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.widget.LinearLayout;
/**
* Created by Kamil on 2016-01-23.
*/
public class BorderLinearLayout extends LinearLayout {
int color;
public BorderLinearLayout(Context context) {
super(context);
this.color = Color.BLACK;
//setPadding(5, 3, 5, 3);
setWillNotDraw(false) ;
}
public BorderLinearLayout(Context context, int color) {
super(context);
// TODO Auto-generated constructor stub
this.color = color;
//setPadding(5, 3, 5, 3);
setWillNotDraw(false) ;
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
int bottom = getMeasuredHeight()-1;
int right = getMeasuredWidth()-1;
Paint paint = new Paint();
paint.setColor(color);
canvas.drawLine(1, 0, 1, bottom, paint);
canvas.drawLine(0, bottom, right, bottom, paint);
canvas.drawLine(right, bottom, right, 0, paint);
canvas.drawLine(right, 0, 0, 0, paint);
//canvas.drawRect(0, 0, right, bottom, paint);
}
}

38
app/src/main/java/com/likesoft/mdedal/gui/BorderTextView.java

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
package com.likesoft.mdedal.gui;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.widget.TableRow;
import android.widget.TextView;
import com.likesoft.mdedal.R;
public class BorderTextView extends MTextView {
public BorderTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
setPadding(5, 3, 5, 3);
setTextAppearance(context, R.style.OpisText);
// setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
int bottom = getMeasuredHeight()-1;
int right = getMeasuredWidth()-1;
Paint paint = new Paint();
paint.setColor(Color.BLACK);
canvas.drawLine(1, 0, 1, bottom, paint);
canvas.drawLine(0, bottom, right, bottom, paint);
canvas.drawLine(right, bottom, right, 0, paint);
canvas.drawLine(right, 0, 0, 0, paint);
//canvas.drawRect(0, 0, right, bottom, paint);
}
}

20
app/src/main/java/com/likesoft/mdedal/gui/ButtonDate.java

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
package com.likesoft.mdedal.gui;
import android.content.Context;
import android.widget.Button;
import android.widget.EditText;
public class ButtonDate extends Button {
private int edId;
public int getEdId() {
return edId;
}
public void setEdId(int edId) {
this.edId = edId;
}
public ButtonDate(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
}

28
app/src/main/java/com/likesoft/mdedal/gui/MLinearLayout.java

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
package com.likesoft.mdedal.gui;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
public class MLinearLayout extends LinearLayout {
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
int height = getMeasuredHeight();
Paint paint = new Paint();
paint.setColor(Color.BLUE);
canvas.drawLine(0, 0, 0, height, paint);
}
public MLinearLayout(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
}

25
app/src/main/java/com/likesoft/mdedal/gui/MTextView.java

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
package com.likesoft.mdedal.gui;
import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;
public class MTextView extends TextView {
private String code;
public MTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
// this.setMinWidth(60);
// this.setMinimumWidth(120);
// setLayoutParams(new ViewGroup.LayoutParams(
// ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}

7
app/src/main/java/com/likesoft/mdedaldemo/test.java

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
package com.likesoft.mdedaldemo;
/**
* Created by darek on 2015-12-08.
*/
public class test {
}

BIN
app/src/main/res/drawable-hdpi/ic_button_zen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

BIN
app/src/main/res/drawable-hdpi/ic_dedal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
app/src/main/res/drawable-hdpi/ic_launcher.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
app/src/main/res/drawable-ldpi/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

BIN
app/src/main/res/drawable-mdpi/ic_button_zen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

BIN
app/src/main/res/drawable-mdpi/ic_dedal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
app/src/main/res/drawable-mdpi/ic_launcher.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
app/src/main/res/drawable-xhdpi/ic_button_zen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

BIN
app/src/main/res/drawable-xhdpi/ic_dedal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
app/src/main/res/drawable-xhdpi/ic_launcher.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
app/src/main/res/drawable-xxhdpi/ic_button_zen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
app/src/main/res/drawable-xxhdpi/ic_dedal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
app/src/main/res/drawable-xxhdpi/ic_launcher.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

12
app/src/main/res/layout/activity_calendar.xml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<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="com.likesoft.mdedal.CalendarActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

50
app/src/main/res/layout/activity_list.xml

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".ListActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<EditText
android:id="@+id/editTextUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
</LinearLayout>
<EditText
android:id="@+id/editTextHost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</EditText>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_alignParentRight="true"
android:layout_below="@+id/linearLayout1"
android:background="@style/AppTheme"
android:text="TextView" />
</RelativeLayout>

30
app/src/main/res/layout/activity_main.xml

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
<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"
tools:context=".MainActivity"
android:contentDescription="gfd">
<requestFocus android:layout_marginTop="35dp" />
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:scrollbars="horizontal" >
<LinearLayout
android:id="@+id/linearLayoutMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</RelativeLayout>

112
app/src/main/res/layout/activity_prefer.xml

@ -0,0 +1,112 @@ @@ -0,0 +1,112 @@
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".PreferActivity" >
<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="122dp"
android:orientation="vertical" >
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="28dp"
android:text="Login" />
<EditText
android:id="@+id/editTextUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:ems="10" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:text="Hasło:" />
<EditText
android:id="@+id/editTextPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/textViewNewPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:text="Zmień hasło:" />
<EditText
android:id="@+id/editTextNewPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword" />
<TextView
android:id="@+id/textViewHostUrl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:text="URL:" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="133dp"
android:layout_weight="0.16"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
<Button
android:id="@+id/buttonSave"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/horizontalScrollView1"
android:layout_alignRight="@+id/imageView1"
android:layout_below="@+id/horizontalScrollView1"
android:text="Zapisz" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="126dp"
android:layout_alignLeft="@+id/horizontalScrollView1"
android:layout_alignTop="@+id/horizontalScrollView1"
android:layout_marginLeft="332dp"
android:layout_marginTop="22dp"
android:src="@drawable/logo" />
</RelativeLayout>

21
app/src/main/res/layout/activity_tableheaders.xml

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>

8
app/src/main/res/layout/jakis_fragment.xml

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<fragment 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"
tools:layout="@layout/activity_main">
</fragment>

15
app/src/main/res/layout/listrow.xml

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="80px"
android:gravity="center_vertical"
android:paddingLeft="6dip"
/>

9
app/src/main/res/menu/list.xml

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save