Skip to content
Permalink
Browse files

first build of gogo.tattoo android app :) it is already useful: gener…

…ates qr codes for tattoo urls and also toml file
  • Loading branch information...
Roman Tronenko
Roman Tronenko committed Feb 25, 2017
0 parents commit 11414921f23bfd36944dc3b0f5c9d92be1096265
Showing with 5,213 additions and 0 deletions.
  1. +9 −0 .gitignore
  2. +22 −0 .idea/compiler.xml
  3. +3 −0 .idea/copyright/profiles_settings.xml
  4. +6 −0 .idea/encodings.xml
  5. +18 −0 .idea/gradle.xml
  6. +46 −0 .idea/misc.xml
  7. +9 −0 .idea/modules.xml
  8. +12 −0 .idea/runConfigurations.xml
  9. +1 −0 app/.gitignore
  10. +35 −0 app/build.gradle
  11. +17 −0 app/proguard-rules.pro
  12. +26 −0 app/src/androidTest/java/tattoo/gogo/app/gogo_android/ExampleInstrumentedTest.java
  13. +23 −0 app/src/main/AndroidManifest.xml
  14. +80 −0 app/src/main/java/com/moandjiezana/toml/ArrayValueReader.java
  15. +65 −0 app/src/main/java/com/moandjiezana/toml/ArrayValueWriter.java
  16. +48 −0 app/src/main/java/com/moandjiezana/toml/BooleanValueReaderWriter.java
  17. +122 −0 app/src/main/java/com/moandjiezana/toml/Container.java
  18. +19 −0 app/src/main/java/com/moandjiezana/toml/Context.java
  19. +22 −0 app/src/main/java/com/moandjiezana/toml/DatePolicy.java
  20. +160 −0 app/src/main/java/com/moandjiezana/toml/DateValueReaderWriter.java
  21. +266 −0 app/src/main/java/com/moandjiezana/toml/Identifier.java
  22. +62 −0 app/src/main/java/com/moandjiezana/toml/IdentifierConverter.java
  23. +30 −0 app/src/main/java/com/moandjiezana/toml/IndentationPolicy.java
  24. +77 −0 app/src/main/java/com/moandjiezana/toml/InlineTableValueReader.java
  25. +69 −0 app/src/main/java/com/moandjiezana/toml/Keys.java
  26. +42 −0 app/src/main/java/com/moandjiezana/toml/LiteralStringValueReader.java
  27. +98 −0 app/src/main/java/com/moandjiezana/toml/MapValueWriter.java
  28. +51 −0 app/src/main/java/com/moandjiezana/toml/MultilineLiteralStringValueReader.java
  29. +56 −0 app/src/main/java/com/moandjiezana/toml/MultilineStringValueReader.java
  30. +105 −0 app/src/main/java/com/moandjiezana/toml/NumberValueReaderWriter.java
  31. +73 −0 app/src/main/java/com/moandjiezana/toml/ObjectValueWriter.java
  32. +54 −0 app/src/main/java/com/moandjiezana/toml/PrimitiveArrayValueWriter.java
  33. +295 −0 app/src/main/java/com/moandjiezana/toml/Results.java
  34. +128 −0 app/src/main/java/com/moandjiezana/toml/StringValueReaderWriter.java
  35. +32 −0 app/src/main/java/com/moandjiezana/toml/TableArrayValueWriter.java
  36. +429 −0 app/src/main/java/com/moandjiezana/toml/Toml.java
  37. +65 −0 app/src/main/java/com/moandjiezana/toml/TomlParser.java
  38. +161 −0 app/src/main/java/com/moandjiezana/toml/TomlWriter.java
  39. +21 −0 app/src/main/java/com/moandjiezana/toml/ValueReader.java
  40. +37 −0 app/src/main/java/com/moandjiezana/toml/ValueReaders.java
  41. +9 −0 app/src/main/java/com/moandjiezana/toml/ValueWriter.java
  42. +37 −0 app/src/main/java/com/moandjiezana/toml/ValueWriters.java
  43. +145 −0 app/src/main/java/com/moandjiezana/toml/WriterContext.java
  44. +789 −0 app/src/main/java/tattoo/gogo/app/gogo_android/ImprovedTagsEditText.java
  45. +49 −0 app/src/main/java/tattoo/gogo/app/gogo_android/MainActivity.java
  46. +131 −0 app/src/main/java/tattoo/gogo/app/gogo_android/MainActivityFragment.java
  47. +282 −0 app/src/main/java/tattoo/gogo/app/gogo_android/NewTattooFragment.java
  48. +137 −0 app/src/main/java/tattoo/gogo/app/gogo_android/Tattoo.java
  49. +8 −0 app/src/main/res/anim/fadein.xml
  50. +8 −0 app/src/main/res/anim/fadeout.xml
  51. BIN app/src/main/res/drawable/doge.png
  52. +12 −0 app/src/main/res/drawable/tag.xml
  53. +41 −0 app/src/main/res/layout/activity_main.xml
  54. +9 −0 app/src/main/res/layout/content_main.xml
  55. +44 −0 app/src/main/res/layout/fragment_main.xml
  56. +221 −0 app/src/main/res/layout/fragment_new_tattoo.xml
  57. +10 −0 app/src/main/res/menu/menu_main.xml
  58. BIN app/src/main/res/mipmap-hdpi/ic_launcher.png
  59. BIN app/src/main/res/mipmap-mdpi/ic_launcher.png
  60. BIN app/src/main/res/mipmap-xhdpi/ic_launcher.png
  61. BIN app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  62. BIN app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  63. +9 −0 app/src/main/res/values-v21/styles.xml
  64. +6 −0 app/src/main/res/values-w820dp/dimens.xml
  65. +11 −0 app/src/main/res/values/colors.xml
  66. +6 −0 app/src/main/res/values/dimens.xml
  67. +19 −0 app/src/main/res/values/strings.xml
  68. +20 −0 app/src/main/res/values/styles.xml
  69. +17 −0 app/src/test/java/tattoo/gogo/app/gogo_android/ExampleUnitTest.java
  70. +25 −0 build.gradle
  71. +17 −0 gradle.properties
  72. BIN gradle/wrapper/gradle-wrapper.jar
  73. +6 −0 gradle/wrapper/gradle-wrapper.properties
  74. +160 −0 gradlew
  75. +90 −0 gradlew.bat
  76. +1 −0 settings.gradle
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
@@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/gogo-android.iml" filepath="$PROJECT_DIR$/gogo-android.iml" />
</modules>
</component>
</project>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
@@ -0,0 +1 @@
/build
@@ -0,0 +1,35 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "tattoo.gogo.app.gogo_android"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.github.kenglxn.QRGen:android:2.2.0'
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
testCompile 'junit:junit:4.12'
compile 'com.github.mabbas007:TagsEditText:v1.0.4'
compile 'com.google.code.gson:gson:2.3.1'
}
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/delirium/workspace/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -0,0 +1,26 @@
package tattoo.gogo.app.gogo_android;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("tattoo.gogo.app.gogo_android", appContext.getPackageName());
}
}
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="tattoo.gogo.app.gogo_android"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
@@ -0,0 +1,80 @@
package com.moandjiezana.toml;

import static com.moandjiezana.toml.ValueReaders.VALUE_READERS;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

class ArrayValueReader implements ValueReader {

static final ArrayValueReader ARRAY_VALUE_READER = new ArrayValueReader();

@Override
public boolean canRead(String s) {
return s.startsWith("[");
}

@Override
public Object read(String s, AtomicInteger index, Context context) {
AtomicInteger line = context.line;
int startLine = line.get();
int startIndex = index.get();
List<Object> arrayItems = new ArrayList<Object>();
boolean terminated = false;
boolean inComment = false;
Results.Errors errors = new Results.Errors();

for (int i = index.incrementAndGet(); i < s.length(); i = index.incrementAndGet()) {

char c = s.charAt(i);

if (c == '#' && !inComment) {
inComment = true;
} else if (c == '\n') {
inComment = false;
line.incrementAndGet();
} else if (inComment || Character.isWhitespace(c) || c == ',') {
continue;
} else if (c == '[') {
Object converted = read(s, index, context);
if (converted instanceof Results.Errors) {
errors.add((Results.Errors) converted);
} else if (!isHomogenousArray(converted, arrayItems)) {
errors.heterogenous(context.identifier.getName(), line.get());
} else {
arrayItems.add(converted);
}
continue;
} else if (c == ']') {
terminated = true;
break;
} else {
Object converted = VALUE_READERS.convert(s, index, context);
if (converted instanceof Results.Errors) {
errors.add((Results.Errors) converted);
} else if (!isHomogenousArray(converted, arrayItems)) {
errors.heterogenous(context.identifier.getName(), line.get());
} else {
arrayItems.add(converted);
}
}
}

if (!terminated) {
errors.unterminated(context.identifier.getName(), s.substring(startIndex, s.length()), startLine);
}

if (errors.hasErrors()) {
return errors;
}

return arrayItems;
}

private boolean isHomogenousArray(Object o, List<?> values) {
return values.isEmpty() || values.get(0).getClass().isAssignableFrom(o.getClass()) || o.getClass().isAssignableFrom(values.get(0).getClass());
}

private ArrayValueReader() {}
}
@@ -0,0 +1,65 @@
package com.moandjiezana.toml;


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;

import static com.moandjiezana.toml.ValueWriters.WRITERS;

abstract class ArrayValueWriter implements ValueWriter {
static protected boolean isArrayish(Object value) {
return value instanceof Collection || value.getClass().isArray();
}

@Override
public boolean isPrimitiveType() {
return false;
}

static boolean isArrayOfPrimitive(Object array) {
Object first = peek(array);
if (first != null) {
ValueWriter valueWriter = WRITERS.findWriterFor(first);
return valueWriter.isPrimitiveType() || isArrayish(first);
}

return true;
}

@SuppressWarnings("unchecked")
protected Collection<?> normalize(Object value) {
Collection<Object> collection;

if (value.getClass().isArray()) {
// Arrays.asList() interprets an array as a single element,
// so convert it to a list by hand
collection = new ArrayList<Object>(Array.getLength(value));
for (int i = 0; i < Array.getLength(value); i++) {
Object elem = Array.get(value, i);
collection.add(elem);
}
} else {
collection = (Collection<Object>) value;
}

return collection;
}

private static Object peek(Object value) {
if (value.getClass().isArray()) {
if (Array.getLength(value) > 0) {
return Array.get(value, 0);
} else {
return null;
}
} else {
Collection<?> collection = (Collection<?>) value;
if (collection.size() > 0) {
return collection.iterator().next();
}
}

return null;
}
}

0 comments on commit 1141492

Please sign in to comment.
You can’t perform that action at this time.