Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

Commit f501f60

Browse files
committed
fix(android): update capacitor and change java import to match community standard
1 parent 2a8e3dc commit f501f60

File tree

24 files changed

+78
-138
lines changed

24 files changed

+78
-138
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ dist
2222

2323
build
2424

25-
package-lock.json
25+
package-lock.json
26+
android_

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ npx cap sync
5656
## Usage
5757

5858
```js
59-
import { Twitter } from "@capacitor-community/twitter";
59+
import { Twitter } from '@capacitor-community/twitter';
6060
const twitter = new Twitter();
6161

6262
twitter
@@ -128,7 +128,7 @@ Then you should be set to go. Run `ionic cap run ios --livereload` to start the
128128
- at twitter developer site, add this callback url: `twittersdk://`
129129
- `[extra step]` in android case we need to tell Capacitor to initialise the plugin:
130130

131-
> on your `MainActivity.java` file add `import io.stewan.capacitor.twitter.TwitterPlugin;` and then inside the init callback `add(TwitterPlugin.class);`
131+
> on your `MainActivity.java` file add `import com.getcapacitor.community.twitter.TwitterPlugin;` and then inside the init callback `add(TwitterPlugin.class);`
132132
133133
Now you should be set to go. Try `ionic cap run android --livereload` to start the server and play/debug it through Android Studio
134134

@@ -157,6 +157,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
157157

158158
<!-- markdownlint-enable -->
159159
<!-- prettier-ignore-end -->
160+
160161
<!-- ALL-CONTRIBUTORS-LIST:END -->
161162

162163
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

android/.idea/gradle.xml

-18
This file was deleted.

android/.idea/misc.xml

-25
This file was deleted.

android/.idea/modules.xml

-9
This file was deleted.

android/.idea/runConfigurations.xml

-12
This file was deleted.

android/.npmignore

-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
1-
*.iml
2-
.gradle
3-
/local.properties
4-
/.idea/workspace.xml
5-
/.idea/libraries
6-
.DS_Store
71
/build
8-
/captures
9-
.externalNativeBuild

android/build.gradle

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
ext {
2+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
3+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
4+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
5+
}
6+
7+
buildscript {
8+
repositories {
9+
google()
10+
jcenter()
11+
}
12+
dependencies {
13+
classpath 'com.android.tools.build:gradle:3.6.1'
14+
}
15+
}
16+
17+
apply plugin: 'com.android.library'
18+
19+
android {
20+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 29
21+
defaultConfig {
22+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 21
23+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 29
24+
versionCode 1
25+
versionName "1.0"
26+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
27+
}
28+
buildTypes {
29+
release {
30+
minifyEnabled false
31+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
32+
}
33+
}
34+
lintOptions {
35+
abortOnError false
36+
}
37+
}
38+
39+
repositories {
40+
google()
41+
jcenter()
42+
mavenCentral()
43+
}
44+
45+
46+
dependencies {
47+
implementation fileTree(dir: 'libs', include: ['*.jar'])
48+
implementation project(':capacitor-android')
49+
testImplementation "junit:junit:$junitVersion"
50+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
51+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
52+
implementation 'com.android.support:appcompat-v7:27.1.1'
53+
implementation 'com.twitter.sdk.android:twitter-core:3.1.1'
54+
}

android/capacitor-twitter/.npmignore

-1
This file was deleted.

android/capacitor-twitter/build.gradle

-49
This file was deleted.

android/capacitor-twitter/src/main/AndroidManifest.xml

-5
This file was deleted.

android/gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ org.gradle.jvmargs=-Xmx1536m
1515
# This option should only be used with decoupled projects. More details, visit
1616
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1717
# org.gradle.parallel=true
18+
19+
# Supports AndroidX
20+
android.useAndroidX=true
21+
android.enableJetifier=true

android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
File renamed without changes.

android/scripts/release.sh

Whitespace-only changes.

android/settings.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include ':capacitor-android'
2+
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')

android/capacitor-twitter/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.getcapacitor.android;
22

33
import android.content.Context;
4-
import android.support.test.InstrumentationRegistry;
5-
import android.support.test.runner.AndroidJUnit4;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
import androidx.test.ext.junit.runners.AndroidJUnit4;
67

78
import org.junit.Test;
89
import org.junit.runner.RunWith;
@@ -19,7 +20,7 @@ public class ExampleInstrumentedTest {
1920
@Test
2021
public void useAppContext() throws Exception {
2122
// Context of the app under test.
22-
Context appContext = InstrumentationRegistry.getTargetContext();
23+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
2324

2425
assertEquals("com.getcapacitor.android", appContext.getPackageName());
2526
}

android/src/main/AndroidManifest.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.getcapacitor.community.twitter.twitter">
4+
</manifest>
5+

android/capacitor-twitter/src/main/java/io/stewan/capacitor/twitter/TwitterPlugin.java android/src/main/java/com/getcapacitor/community/twitter/TwitterPlugin.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
package io.stewan.capacitor.twitter;
2-
1+
package com.getcapacitor.community.twitter;
32
import android.content.Intent;
43
import android.util.Log;
54

@@ -30,8 +29,8 @@ public class TwitterPlugin extends Plugin {
3029

3130
@Override()
3231
public void load() {
33-
String consumerKey = Config.getString(CONFIG_KEY_PREFIX + "consumerKey", "ADD_IN_CAPACITOR_CONFIG_JSON");
34-
String consumerSecret = Config.getString(CONFIG_KEY_PREFIX + "consumerSecret", "ADD_IN_CAPACITOR_CONFIG_JSON");
32+
String consumerKey = this.bridge.getConfig().getString(CONFIG_KEY_PREFIX + "consumerKey", "ADD_IN_CAPACITOR_CONFIG_JSON");
33+
String consumerSecret = this.bridge.getConfig().getString(CONFIG_KEY_PREFIX + "consumerSecret", "ADD_IN_CAPACITOR_CONFIG_JSON");
3534

3635
//
3736
// initialize twitter

0 commit comments

Comments
 (0)