Compare commits
19 Commits
0.0.12-alp
...
master
Author | SHA1 | Date | |
---|---|---|---|
3a385ba8fa | |||
223f1d7af2 | |||
82dcfacab4 | |||
cf7afdce16 | |||
753f779d75 | |||
a36799800a | |||
0c8cfff737 | |||
9aea984e4c | |||
9297211785 | |||
d69baed0cf | |||
08f997ff48 | |||
6532cd4697 | |||
38eaf4e25f | |||
5cccd03e2f | |||
aca666cdf1 | |||
763422f7dd | |||
08bbf1d236 | |||
89a09f1b88 | |||
692a7268d7 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,3 +7,4 @@
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
|
/app/release/
|
||||||
|
|
148
.idea/assetWizardSettings.xml
Normal file
148
.idea/assetWizardSettings.xml
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="WizardSettings">
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="imageWizard">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="imageAssetPanel">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="actionbar">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="clipArt">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="values">
|
||||||
|
<map>
|
||||||
|
<entry key="color" value="000000" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
<option name="values">
|
||||||
|
<map>
|
||||||
|
<entry key="theme" value="HOLO_DARK" />
|
||||||
|
<entry key="themeColor" value="ffffff" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="launcher">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="foregroundClipArt">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="values">
|
||||||
|
<map>
|
||||||
|
<entry key="color" value="000000" />
|
||||||
|
<entry key="scalingPercent" value="59" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="foregroundClipartAsset">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="values">
|
||||||
|
<map>
|
||||||
|
<entry key="url" value="jar:file:/home/peter/Desktop/android-studio/plugins/android/lib/android.jar!/images/material_design_icons/content/ic_create_black_24dp.xml" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="foregroundImage">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="values">
|
||||||
|
<map>
|
||||||
|
<entry key="color" value="000000" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
<option name="values">
|
||||||
|
<map>
|
||||||
|
<entry key="foregroundAssetType" value="CLIP_ART" />
|
||||||
|
<entry key="foregroundLayerName" value="ic_plugin" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="launcherLegacy">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="clipArt">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="values">
|
||||||
|
<map>
|
||||||
|
<entry key="color" value="000000" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
<entry key="notification">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="children">
|
||||||
|
<map>
|
||||||
|
<entry key="clipArt">
|
||||||
|
<value>
|
||||||
|
<PersistentState>
|
||||||
|
<option name="values">
|
||||||
|
<map>
|
||||||
|
<entry key="color" value="000000" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</PersistentState>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
BIN
.idea/caches/build_file_checksums.ser
Normal file
BIN
.idea/caches/build_file_checksums.ser
Normal file
Binary file not shown.
29
.idea/codeStyles/Project.xml
Normal file
29
.idea/codeStyles/Project.xml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<Objective-C-extensions>
|
||||||
|
<file>
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
|
||||||
|
</file>
|
||||||
|
<class>
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
|
||||||
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
|
||||||
|
</class>
|
||||||
|
<extensions>
|
||||||
|
<pair source="cpp" header="h" fileNamingConvention="NONE" />
|
||||||
|
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||||
|
</extensions>
|
||||||
|
</Objective-C-extensions>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding">
|
|
||||||
<file url="PROJECT" charset="UTF-8" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,30 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="NullableNotNullManager">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||||
<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="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -6,9 +6,9 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "eu.stuifzand.micropub"
|
applicationId "eu.stuifzand.micropub"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 26
|
targetSdkVersion 27
|
||||||
versionCode 12
|
versionCode 21
|
||||||
versionName '0.0.12-alpha'
|
versionName '0.1.6-alpha'
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -39,30 +39,34 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
implementation 'com.android.support:design:26.1.0'
|
implementation 'com.android.support:design:26.1.0'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
|
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||||
testImplementation 'com.squareup.okhttp3:mockwebserver:3.9.1';
|
testImplementation 'com.squareup.okhttp3:mockwebserver:3.9.1'
|
||||||
testImplementation "org.robolectric:robolectric:3.7.1"
|
testImplementation 'org.robolectric:robolectric:3.7.1'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
apply plugin: 'kotlin-android-extensions'
|
||||||
// Logging
|
// Logging
|
||||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
|
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
|
||||||
// ViewModel and LiveData
|
// ViewModel and LiveData
|
||||||
implementation 'android.arch.lifecycle:extensions:1.1.0'
|
implementation 'android.arch.lifecycle:extensions:1.1.1'
|
||||||
annotationProcessor "android.arch.lifecycle:compiler:1.1.0"
|
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
|
||||||
// Java8 support for Lifecycles
|
// Java8 support for Lifecycles
|
||||||
implementation 'android.arch.lifecycle:common-java8:1.1.0'
|
implementation 'android.arch.lifecycle:common-java8:1.1.1'
|
||||||
|
// jsoup
|
||||||
implementation 'org.jsoup:jsoup:1.11.2'
|
implementation 'org.jsoup:jsoup:1.11.2'
|
||||||
implementation 'com.google.code.gson:gson:2.8.2'
|
implementation 'com.google.code.gson:gson:2.8.2'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
implementation 'com.parse.bolts:bolts-tasks:1.4.0'
|
||||||
|
implementation 'com.android.support:support-annotations:28.0.0'
|
||||||
implementation 'com.android.support:support-annotations:27.0.0'
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
|
||||||
|
def room_version = "1.1.1"
|
||||||
implementation "io.reactivex.rxjava2:rxjava:2.1.12"
|
implementation "android.arch.persistence.room:runtime:$room_version"
|
||||||
|
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
|
||||||
|
// Test helpers
|
||||||
|
testImplementation "android.arch.persistence.room:testing:$room_version"
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
package eu.stuifzand.micropub;
|
|
||||||
|
|
||||||
import android.support.test.filters.LargeTest;
|
|
||||||
import android.support.test.rule.ActivityTestRule;
|
|
||||||
import android.support.test.runner.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import static android.support.test.espresso.Espresso.onView;
|
|
||||||
import static android.support.test.espresso.action.ViewActions.typeText;
|
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
@LargeTest
|
|
||||||
public class HelloWorldEspressoTest {
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ActivityTestRule<MainActivity> mActivityRule =
|
|
||||||
new ActivityTestRule(MainActivity.class);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void createPost() throws Exception {
|
|
||||||
onView(withId(R.id.content)).perform(typeText("This is a test message"));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -47,18 +47,16 @@
|
||||||
<activity android:name=".auth.WebSigninActivity" />
|
<activity android:name=".auth.WebSigninActivity" />
|
||||||
<activity android:name=".auth.AuthenticationActivity"
|
<activity android:name=".auth.AuthenticationActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleInstance">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data android:scheme="wrimini" />
|
<data android:scheme="https" android:host="wrimini.net" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name=".auth.AccountsActivity" />
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".auth.AuthenticatorService"
|
android:name=".auth.AuthenticatorService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
|
|
@ -32,7 +32,6 @@ public class LikeActivity extends AppCompatActivity {
|
||||||
private AccountManager accountManager;
|
private AccountManager accountManager;
|
||||||
|
|
||||||
private Account selectedAccount;
|
private Account selectedAccount;
|
||||||
private String authToken;
|
|
||||||
private Client client;
|
private Client client;
|
||||||
private PostViewModel postModel;
|
private PostViewModel postModel;
|
||||||
|
|
||||||
|
@ -53,7 +52,6 @@ public class LikeActivity extends AppCompatActivity {
|
||||||
if (accounts.length == 0)
|
if (accounts.length == 0)
|
||||||
return;
|
return;
|
||||||
selectedAccount = accounts[0];
|
selectedAccount = accounts[0];
|
||||||
authToken = token;
|
|
||||||
|
|
||||||
String micropubBackend = accountManager.getUserData(selectedAccount, "micropub");
|
String micropubBackend = accountManager.getUserData(selectedAccount, "micropub");
|
||||||
if (micropubBackend == null) return;
|
if (micropubBackend == null) return;
|
||||||
|
@ -87,13 +85,8 @@ public class LikeActivity extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
AuthError onError = (msg) -> {
|
AuthError onError = (msg) -> LikeActivity.this.runOnUiThread(() -> Toast.makeText(LikeActivity.this, msg, Toast.LENGTH_LONG).show());
|
||||||
LikeActivity.this.runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(LikeActivity.this, msg, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
accountManager.getAuthTokenByFeatures(
|
accountManager.getAuthTokenByFeatures(
|
||||||
"Indieauth",
|
"Indieauth",
|
||||||
"token",
|
"token",
|
||||||
|
@ -117,15 +110,13 @@ public class LikeActivity extends AppCompatActivity {
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
Log.i("micropub", intent.toString());
|
Log.i("micropub", intent.toString());
|
||||||
if (intent != null) {
|
String urlOrNote = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
String urlOrNote = intent.getStringExtra(Intent.EXTRA_TEXT);
|
if (urlOrNote != null) {
|
||||||
if (urlOrNote != null) {
|
HttpUrl url = HttpUrl.parse(urlOrNote);
|
||||||
HttpUrl url = HttpUrl.parse(urlOrNote);
|
if (url != null) {
|
||||||
if (url != null) {
|
postModel.likeOf.set(urlOrNote);
|
||||||
postModel.likeOf.set(urlOrNote);
|
} else {
|
||||||
} else {
|
postModel.findLikeOf(urlOrNote);
|
||||||
postModel.findLikeOf(urlOrNote);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +147,7 @@ public class LikeActivity extends AppCompatActivity {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPost(View view) {
|
private void sendPost(View view) {
|
||||||
AccountManager am = AccountManager.get(this);
|
AccountManager am = AccountManager.get(this);
|
||||||
Bundle options = new Bundle();
|
Bundle options = new Bundle();
|
||||||
|
|
||||||
|
@ -170,13 +161,7 @@ public class LikeActivity extends AppCompatActivity {
|
||||||
Post post = postModel.getPost();
|
Post post = postModel.getPost();
|
||||||
client.createPost(post, token, HttpUrl.parse(micropubBackend));
|
client.createPost(post, token, HttpUrl.parse(micropubBackend));
|
||||||
};
|
};
|
||||||
AuthError onError = (msg) -> {
|
AuthError onError = (msg) -> LikeActivity.this.runOnUiThread(() -> Toast.makeText(LikeActivity.this, msg, Toast.LENGTH_LONG).show());
|
||||||
LikeActivity.this.runOnUiThread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(LikeActivity.this, msg, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
accountManager.getAuthTokenByFeatures("Indieauth", "token", null, this, options, null, new OnTokenAcquired(this, callback, onError), null);
|
accountManager.getAuthTokenByFeatures("Indieauth", "token", null, this, options, null, new OnTokenAcquired(this, callback, onError), null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ListAdapter extends BaseAdapter {
|
||||||
return binding.getRoot();
|
return binding.getRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BindingAdapter("app:list")
|
@BindingAdapter("list")
|
||||||
public static void bindList(ListView view, ObservableArrayList<Syndication> list) {
|
public static void bindList(ListView view, ObservableArrayList<Syndication> list) {
|
||||||
assert list != null;
|
assert list != null;
|
||||||
ListAdapter adapter = new ListAdapter(list);
|
ListAdapter adapter = new ListAdapter(list);
|
||||||
|
|
|
@ -62,8 +62,14 @@ public class MainActivity extends AppCompatActivity {
|
||||||
Account[] accounts = accountManager.getAccountsByType(accountType);
|
Account[] accounts = accountManager.getAccountsByType(accountType);
|
||||||
if (accounts.length == 0)
|
if (accounts.length == 0)
|
||||||
return;
|
return;
|
||||||
selectedAccount = accounts[0];
|
for (int i = 0; i < accounts.length; i++) {
|
||||||
authToken = token;
|
Log.i("micropub", "accounts["+i+"] = " + accounts[i].name + " " + accounts[i].type);
|
||||||
|
if (accounts[i].type.equals(accountType)&&accounts[i].name.equals(accountName)) {
|
||||||
|
selectedAccount = accounts[i];
|
||||||
|
authToken = token;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String micropubBackend = accountManager.getUserData(selectedAccount, "micropub");
|
String micropubBackend = accountManager.getUserData(selectedAccount, "micropub");
|
||||||
if (micropubBackend == null) return;
|
if (micropubBackend == null) return;
|
||||||
|
@ -161,11 +167,6 @@ public class MainActivity extends AppCompatActivity {
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
//noinspection SimplifiableIfStatement
|
|
||||||
if (id == R.id.action_settings) {
|
|
||||||
// TODO: implement some settings
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (id == R.id.action_send) {
|
if (id == R.id.action_send) {
|
||||||
InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager inputManager = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
if (this.getCurrentFocus() != null && inputManager != null) {
|
if (this.getCurrentFocus() != null && inputManager != null) {
|
||||||
|
@ -207,7 +208,11 @@ public class MainActivity extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
accountManager.getAuthTokenByFeatures("Indieauth", "token", null, this, options, null, new OnTokenAcquired(this, callback, onError), null);
|
if (selectedAccount == null || authToken == null) {
|
||||||
|
accountManager.getAuthTokenByFeatures("Indieauth", "token", null, this, options, null, new OnTokenAcquired(this, callback, onError), null);
|
||||||
|
} else {
|
||||||
|
callback.tokenReady(selectedAccount.type, selectedAccount.name, authToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void galleryIntent(View view) {
|
public void galleryIntent(View view) {
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package eu.stuifzand.micropub.auth;
|
||||||
|
|
||||||
|
import android.arch.persistence.room.Database;
|
||||||
|
import android.arch.persistence.room.RoomDatabase;
|
||||||
|
|
||||||
|
@Database(entities = {Auth.class}, version = 2, exportSchema = false)
|
||||||
|
public abstract class AppDatabase extends RoomDatabase {
|
||||||
|
public abstract AuthDao authDao();
|
||||||
|
}
|
47
app/src/main/java/eu/stuifzand/micropub/auth/Auth.java
Normal file
47
app/src/main/java/eu/stuifzand/micropub/auth/Auth.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package eu.stuifzand.micropub.auth;
|
||||||
|
|
||||||
|
import android.arch.persistence.room.ColumnInfo;
|
||||||
|
import android.arch.persistence.room.Entity;
|
||||||
|
import android.arch.persistence.room.PrimaryKey;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Auth {
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "state")
|
||||||
|
private String state;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "me")
|
||||||
|
private String me;
|
||||||
|
|
||||||
|
//private String authorization_endpoint;
|
||||||
|
public Auth(String state, String me) {
|
||||||
|
this.state = state;
|
||||||
|
this.me = me;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(String state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMe() {
|
||||||
|
return me;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMe(String me) {
|
||||||
|
this.me = me;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
18
app/src/main/java/eu/stuifzand/micropub/auth/AuthDao.java
Normal file
18
app/src/main/java/eu/stuifzand/micropub/auth/AuthDao.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package eu.stuifzand.micropub.auth;
|
||||||
|
|
||||||
|
import android.arch.persistence.room.Dao;
|
||||||
|
import android.arch.persistence.room.Delete;
|
||||||
|
import android.arch.persistence.room.Insert;
|
||||||
|
import android.arch.persistence.room.Query;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface AuthDao {
|
||||||
|
@Query("SELECT * FROM auth WHERE state = :state")
|
||||||
|
Auth load(String state);
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
void save(Auth auth);
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
void delete(Auth auth);
|
||||||
|
}
|
|
@ -4,8 +4,10 @@ import android.accounts.Account;
|
||||||
import android.accounts.AccountAuthenticatorActivity;
|
import android.accounts.AccountAuthenticatorActivity;
|
||||||
import android.accounts.AccountAuthenticatorResponse;
|
import android.accounts.AccountAuthenticatorResponse;
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
|
import android.arch.persistence.room.Room;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
|
@ -19,6 +21,7 @@ import android.webkit.WebViewClient;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import eu.stuifzand.micropub.R;
|
import eu.stuifzand.micropub.R;
|
||||||
|
import eu.stuifzand.micropub.utils.RandomStringUtils;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
public class AuthenticationActivity extends AccountAuthenticatorActivity {
|
public class AuthenticationActivity extends AccountAuthenticatorActivity {
|
||||||
|
@ -46,18 +49,70 @@ public class AuthenticationActivity extends AccountAuthenticatorActivity {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
bundle = intent.getExtras();
|
bundle = intent.getExtras();
|
||||||
|
|
||||||
|
if ("android.intent.action.VIEW".equals(intent.getAction())) {
|
||||||
|
Log.i("micropub", intent.toString());
|
||||||
|
Uri uri = intent.getData();
|
||||||
|
String code = uri.getQueryParameter("code");
|
||||||
|
String state = uri.getQueryParameter("state"); // @TODO: check/use state
|
||||||
|
|
||||||
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "auth").build();
|
||||||
|
new AsyncTask<String, Void, Auth>() {
|
||||||
|
@Override
|
||||||
|
protected Auth doInBackground(String... strings) {
|
||||||
|
String state = strings[0];
|
||||||
|
Auth auth = db.authDao().load(state);
|
||||||
|
db.close();
|
||||||
|
return auth;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Auth auth) {
|
||||||
|
if (auth != null) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(AccountManager.KEY_ACCOUNT_TYPE, "Indieauth");
|
||||||
|
bundle.putString(AccountManager.KEY_ACCOUNT_NAME, auth.getMe());
|
||||||
|
bundle.putString(AuthenticationActivity.PARAM_USER_PASS, code);
|
||||||
|
|
||||||
|
Intent loginIntent = new Intent();
|
||||||
|
loginIntent.putExtras(bundle);
|
||||||
|
finishLogin(loginIntent);
|
||||||
|
}
|
||||||
|
}.execute(state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String endpoint = bundle.getString("authorization_endpoint");
|
String endpoint = bundle.getString("authorization_endpoint");
|
||||||
String me = bundle.getString(WebsigninTask.ME);
|
String me = bundle.getString(WebsigninTask.ME);
|
||||||
AccountAuthenticatorResponse response = bundle.getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
|
AccountAuthenticatorResponse response = bundle.getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
|
||||||
|
|
||||||
|
String state = RandomStringUtils.randomString(16);
|
||||||
|
|
||||||
HttpUrl.Builder builder = HttpUrl.parse(endpoint).newBuilder();
|
HttpUrl.Builder builder = HttpUrl.parse(endpoint).newBuilder();
|
||||||
builder.setQueryParameter("me", me)
|
builder.setQueryParameter("me", me)
|
||||||
.setQueryParameter("client_id", "https://stuifzand.eu/micropub")
|
.setQueryParameter("client_id", "https://wrimini.net")
|
||||||
.setQueryParameter("redirect_uri", "wrimini://oauth")
|
.setQueryParameter("redirect_uri", "https://wrimini.net/oauth/callback")
|
||||||
.setQueryParameter("response_type", "code")
|
.setQueryParameter("response_type", "code")
|
||||||
.setQueryParameter("state", "1234") // @TODO use random states, check the state later
|
.setQueryParameter("state", state)
|
||||||
.setQueryParameter("scope", "create"); // @TODO use different scope
|
.setQueryParameter("scope", "create"); // @TODO use different scope
|
||||||
|
|
||||||
|
AppDatabase db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "auth")
|
||||||
|
.fallbackToDestructiveMigration()
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Auth auth = new Auth(state, me);
|
||||||
|
|
||||||
|
new AsyncTask<Auth, Void, Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Auth... auths) {
|
||||||
|
db.authDao().save(auths[0]);
|
||||||
|
db.close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}.execute(auth);
|
||||||
|
|
||||||
String url = builder.toString();
|
String url = builder.toString();
|
||||||
Log.i("micropub", "LoadUrl: " + url);
|
Log.i("micropub", "LoadUrl: " + url);
|
||||||
Intent webIntent = new Intent(Intent.ACTION_VIEW);
|
Intent webIntent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
|
|
@ -75,8 +75,8 @@ public class Authenticator extends AbstractAccountAuthenticator {
|
||||||
if (TextUtils.isEmpty(authToken)) {
|
if (TextUtils.isEmpty(authToken)) {
|
||||||
RequestBody formBody = new FormBody.Builder()
|
RequestBody formBody = new FormBody.Builder()
|
||||||
.add("code", am.getPassword(account))
|
.add("code", am.getPassword(account))
|
||||||
.add("redirect_uri", "wrimini://oauth")
|
.add("client_id", "https://wrimini.net")
|
||||||
.add("client_id", "https://stuifzand.eu/micropub")
|
.add("redirect_uri", "https://wrimini.net/oauth/callback")
|
||||||
.add("me", account.name)
|
.add("me", account.name)
|
||||||
.add("grant_type", "authorization_code")
|
.add("grant_type", "authorization_code")
|
||||||
.build();
|
.build();
|
||||||
|
@ -99,6 +99,7 @@ public class Authenticator extends AbstractAccountAuthenticator {
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
JsonObject element = parser.parse(body.string()).getAsJsonObject();
|
JsonObject element = parser.parse(body.string()).getAsJsonObject();
|
||||||
authToken = element.get("access_token").getAsString();
|
authToken = element.get("access_token").getAsString();
|
||||||
|
am.setAuthToken(account, authTokenType, authToken);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e("micropub", "Failed getting token response", e);
|
Log.e("micropub", "Failed getting token response", e);
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package eu.stuifzand.micropub.utils;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
public class RandomStringUtils {
|
||||||
|
public static String randomString(int n) {
|
||||||
|
Random r = new Random();
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
sb.append((char)('a'+r.nextInt(('z'-'a')+1)));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,22 +15,21 @@
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:id="@+id/scrollView_bookmark"
|
android:id="@+id/scrollView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
tools:context="eu.stuifzand.micropub.BookmarkActivity"
|
tools:context="eu.stuifzand.micropub.MainActivity"
|
||||||
tools:showIn="@layout/activity_bookmark">
|
tools:showIn="@layout/activity_main">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:padding="8dp">
|
|
||||||
|
|
||||||
<android.support.constraint.ConstraintLayout
|
<android.support.constraint.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="574dp"
|
android:layout_height="match_parent"
|
||||||
android:overScrollMode="always"
|
android:overScrollMode="always"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:scrollbars="vertical">
|
android:scrollbars="vertical">
|
||||||
|
@ -39,54 +38,26 @@
|
||||||
android:id="@+id/editBookmarkOfTextLayout"
|
android:id="@+id/editBookmarkOfTextLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/editNameLayout"
|
app:layout_constraintBottom_toTopOf="@+id/editNameLayout"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="1.0"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_chainStyle="spread_inside">
|
app:layout_constraintVertical_chainStyle="spread_inside">
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
<android.support.design.widget.TextInputEditText
|
||||||
android:id="@+id/editBookmarkOfText"
|
android:id="@+id/editBookmarkOfText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="Bookmark of"
|
android:hint="@string/bookmark_of"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="@={viewModel.bookmarkOf}" />
|
android:text="@={viewModel.bookmarkOf}" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/contentLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:hint="@string/content"
|
|
||||||
app:counterEnabled="true"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/editCategoryLayout"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/editNameLayout">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="100sp"
|
|
||||||
android:ems="10"
|
|
||||||
android:gravity="top"
|
|
||||||
android:imeOptions="actionNext"
|
|
||||||
android:inputType="textMultiLine|textCapSentences|textAutoComplete"
|
|
||||||
android:lines="5"
|
|
||||||
android:nextFocusForward="@id/editCategory"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
android:text="@={viewModel.content}"
|
|
||||||
tools:layout_editor_absoluteY="101dp" />
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/editNameLayout"
|
android:id="@+id/editNameLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:hint="@string/name"
|
android:hint="@string/name"
|
||||||
app:counterEnabled="false"
|
app:counterEnabled="false"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/contentLayout"
|
app:layout_constraintBottom_toTopOf="@+id/contentLayout"
|
||||||
|
@ -111,6 +82,61 @@
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputLayout
|
||||||
|
android:id="@+id/contentLayout"
|
||||||
|
android:layout_height="110dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:hint="@string/content"
|
||||||
|
app:counterEnabled="true"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/editCategoryLayout"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/editNameLayout"
|
||||||
|
android:layout_width="match_parent">
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputEditText
|
||||||
|
android:id="@+id/content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="100sp"
|
||||||
|
android:ems="10"
|
||||||
|
android:gravity="top"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:inputType="textMultiLine|textCapSentences|textAutoComplete"
|
||||||
|
android:lines="5"
|
||||||
|
android:nextFocusForward="@id/editCategory"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:text="@={viewModel.content}"
|
||||||
|
tools:layout_editor_absoluteY="101dp" />
|
||||||
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputLayout
|
||||||
|
android:id="@+id/editCategoryLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:hint="@string/categories"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/listLayout"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/contentLayout">
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputEditText
|
||||||
|
android:id="@+id/editCategory"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:inputType="text"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@={viewModel.category}" />
|
||||||
|
|
||||||
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/listLayout"
|
android:id="@+id/listLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -118,8 +144,10 @@
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:gravity="top|fill"
|
android:gravity="top|fill"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/editCategoryLayout"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
tools:layout_editor_absoluteX="16dp">
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/editCategoryLayout">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView2"
|
android:id="@+id/textView2"
|
||||||
|
@ -139,37 +167,7 @@
|
||||||
app:multipleItems="@{client.syndicates}" />
|
app:multipleItems="@{client.syndicates}" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
|
||||||
android:id="@+id/editCategoryLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="55dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:hint="@string/categories"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/contentLayout"
|
|
||||||
tools:layout_editor_absoluteX="0dp">
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputEditText
|
|
||||||
android:id="@+id/editCategory"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:ems="10"
|
|
||||||
android:imeOptions="actionNext"
|
|
||||||
android:inputType="text"
|
|
||||||
android:lines="1"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="@={viewModel.category}" />
|
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
|
||||||
|
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="50dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -139,37 +139,6 @@
|
||||||
|
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/listLayout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="top|fill"
|
|
||||||
android:orientation="vertical"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/editPhotoLayout">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="@string/syndication"
|
|
||||||
android:textSize="16sp" />
|
|
||||||
|
|
||||||
<ListView
|
|
||||||
android:id="@+id/listSyndication"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="69dp"
|
|
||||||
android:isScrollContainer="false"
|
|
||||||
app:list="@{client.syndicates}" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<android.support.design.widget.TextInputLayout
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/editPhotoLayout"
|
android:id="@+id/editPhotoLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -194,6 +163,37 @@
|
||||||
android:text="@={viewModel.photo}" />
|
android:text="@={viewModel.photo}" />
|
||||||
</android.support.design.widget.TextInputLayout>
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/listLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:gravity="top|fill"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/editPhotoLayout">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/syndication"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/listSyndication"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:multipleItems="@{client.syndicates}" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,6 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context="eu.stuifzand.micropub.MainActivity">
|
tools:context="eu.stuifzand.micropub.MainActivity">
|
||||||
<item
|
|
||||||
android:id="@+id/action_settings"
|
|
||||||
android:orderInCategory="100"
|
|
||||||
android:title="@string/action_settings"
|
|
||||||
app:showAsAction="never" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_photo"
|
android:id="@+id/action_photo"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#ddeeff</color>
|
<color name="colorPrimary">#8BC34A</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#4CAF50</color>
|
||||||
<color name="colorAccent">#FF4081</color>
|
<color name="colorAccent">#F44336</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -18,4 +18,5 @@
|
||||||
<string name="like">Like</string>
|
<string name="like">Like</string>
|
||||||
<string name="bookmark">Bookmark</string>
|
<string name="bookmark">Bookmark</string>
|
||||||
<string name="title_activity_bookmark">BookmarkActivity</string>
|
<string name="title_activity_bookmark">BookmarkActivity</string>
|
||||||
|
<string name="bookmark_of">Bookmark of</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package eu.stuifzand.micropub;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import eu.stuifzand.micropub.client.MicropubConfigResponseCallback;
|
||||||
|
import eu.stuifzand.micropub.client.Syndication;
|
||||||
|
|
||||||
|
public class MicropubConfigTest {
|
||||||
|
@Test public void testConfigParse(){
|
||||||
|
String configJson = "{\"syndicate-to\":[{\"uid\":\"bridgy-publish_twitter\",\"name\":\"Twitter via Bridgy Publish\"},{\"uid\":\"bridgy-publish_facebook\",\"name\":\"Facebook via Bridgy Publish\"},{\"uid\":\"bridgy-publish_github\",\"name\":\"Github via Bridgy Publish\"}]}";
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonElement configElement = parser.parse(configJson);
|
||||||
|
|
||||||
|
ArrayList<Syndication> syndicates = new ArrayList<>();
|
||||||
|
|
||||||
|
// Media endpoint
|
||||||
|
JsonObject config = configElement.getAsJsonObject();
|
||||||
|
JsonElement elem = config.get("media-endpoint");
|
||||||
|
if (elem != null) {
|
||||||
|
Assert.fail("media endpoint not available");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Syndications.
|
||||||
|
JsonArray arr = config.getAsJsonArray("syndicate-to");
|
||||||
|
if (arr != null) {
|
||||||
|
syndicates.clear();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
JsonObject syn = arr.get(i).getAsJsonObject();
|
||||||
|
syndicates.add(new Syndication(syn.get("uid").getAsString(), syn.get("name").getAsString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertEquals(syndicates.get(0).name.get(), "Twitter via Bridgy Publish");
|
||||||
|
Assert.assertEquals(syndicates.get(0).uid.get(), "bridgy-publish_twitter");
|
||||||
|
|
||||||
|
Assert.assertEquals(syndicates.get(1).name.get(), "Facebook via Bridgy Publish");
|
||||||
|
Assert.assertEquals(syndicates.get(1).uid.get(), "bridgy-publish_facebook");
|
||||||
|
|
||||||
|
Assert.assertEquals(syndicates.get(2).name.get(), "Github via Bridgy Publish");
|
||||||
|
Assert.assertEquals(syndicates.get(2).uid.get(), "bridgy-publish_github");
|
||||||
|
}
|
||||||
|
}
|
19
app/src/test/java/eu/stuifzand/micropub/UrlTest.java
Normal file
19
app/src/test/java/eu/stuifzand/micropub/UrlTest.java
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.stuifzand.micropub;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import okhttp3.HttpUrl;
|
||||||
|
|
||||||
|
public class UrlTest {
|
||||||
|
@Test
|
||||||
|
public void testBuildUrl() {
|
||||||
|
String configKey = "config";
|
||||||
|
HttpUrl micropubBackend = HttpUrl.parse("https://tiny.n9n.us/?micropub=endpoint");
|
||||||
|
HttpUrl backend = micropubBackend.newBuilder()
|
||||||
|
.setQueryParameter("q", configKey)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Assert.assertEquals(backend.toString(), "https://tiny.n9n.us/?micropub=endpoint&q=config");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.31'
|
ext.kotlin_version = '1.3.11'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.1.0'
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
#Tue Mar 27 07:29:19 CEST 2018
|
#Wed Jan 23 22:16:00 CET 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
||||||
|
|
Loading…
Reference in New Issue
Block a user