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

Commit 25b8081

Browse files
committed
feat(): add example
1 parent f501f60 commit 25b8081

File tree

127 files changed

+2830
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+2830
-0
lines changed

example/.gitignore

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Specifies intentionally untracked files to ignore when using Git
2+
# http://git-scm.com/docs/gitignore
3+
4+
*~
5+
*.sw[mnpcod]
6+
*.log
7+
*.tmp
8+
*.tmp.*
9+
log.txt
10+
*.sublime-project
11+
*.sublime-workspace
12+
.vscode/
13+
npm-debug.log*
14+
15+
.idea/
16+
.ionic/
17+
.sourcemaps/
18+
.sass-cache/
19+
.tmp/
20+
.versions/
21+
coverage/
22+
node_modules/
23+
tmp/
24+
temp/
25+
platforms/
26+
plugins/
27+
plugins/android.json
28+
plugins/ios.json
29+
$RECYCLE.BIN/
30+
31+
.DS_Store
32+
Thumbs.db
33+
UserInterfaceState.xcuserstate
34+
35+
36+
.gradle

example/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# capacitor-twitter-example
2+
3+
Working sample for the [capacitor-twitter](https://github.com/capacitor-community/twitter) plugin
4+
5+
## Setup
6+
7+
- git clone this repo
8+
- cd example
9+
- npm install
10+
- change the `consumerKey` and `consumerSecret` at `capacitor.config.json` [create one here](https://developer.twitter.com)
11+
- add callback urls on twitter dev site [(more info here)](https://github.com/capacitor-community/twitter)
12+
13+
Relevant code is located at `src/app/home`
14+
15+
## license
16+
17+
MIT

example/android/.gitignore

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# NPM renames .gitignore to .npmignore
2+
# In order to prevent that, we remove the initial "."
3+
# And the CLI then renames it
4+
5+
# Using Android gitignore template: https://github.com/github/gitignore/blob/master/Android.gitignore
6+
7+
# Built application files
8+
*.apk
9+
*.ap_
10+
11+
# Files for the ART/Dalvik VM
12+
*.dex
13+
14+
# Java class files
15+
*.class
16+
17+
# Generated files
18+
bin/
19+
gen/
20+
out/
21+
22+
# Gradle files
23+
.gradle/
24+
build/
25+
26+
# Local configuration file (sdk path, etc)
27+
local.properties
28+
29+
# Proguard folder generated by Eclipse
30+
proguard/
31+
32+
# Log Files
33+
*.log
34+
35+
# Android Studio Navigation editor temp files
36+
.navigation/
37+
38+
# Android Studio captures folder
39+
captures/
40+
41+
# IntelliJ
42+
*.iml
43+
.idea/workspace.xml
44+
.idea/tasks.xml
45+
.idea/gradle.xml
46+
.idea/dictionaries
47+
.idea/libraries
48+
49+
# Keystore files
50+
# Uncomment the following line if you do not want to check your keystore files in.
51+
#*.jks
52+
53+
# External native build folder generated in Android Studio 2.2 and later
54+
.externalNativeBuild
55+
56+
# Google Services (e.g. APIs or Firebase)
57+
google-services.json
58+
59+
# Freeline
60+
freeline.py
61+
freeline/
62+
freeline_project_description.json
63+
64+
# fastlane
65+
fastlane/report.xml
66+
fastlane/Preview.html
67+
fastlane/screenshots
68+
fastlane/test_output
69+
fastlane/readme.md
70+
71+
# Cordova plugins for Capacitor
72+
capacitor-cordova-android-plugins
73+
74+
# Copied web assets
75+
app/src/main/assets/public

example/android/app/.npmignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build/*
2+
!/build/.npmkeep

example/android/app/build.gradle

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 29
5+
defaultConfig {
6+
applicationId "io.ionic.starter"
7+
minSdkVersion 21
8+
targetSdkVersion 29
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
repositories {
22+
maven {
23+
url "https://dl.bintray.com/ionic-team/capacitor"
24+
}
25+
flatDir{
26+
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
27+
}
28+
}
29+
30+
dependencies {
31+
implementation "androidx.appcompat:appcompat:1.3.0-alpha01"
32+
implementation project(':capacitor-android')
33+
testImplementation "junit:junit:4.12"
34+
androidTestImplementation "androidx.test.ext:junit:1.1.1"
35+
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
36+
implementation project(':capacitor-cordova-android-plugins')
37+
implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
38+
}
39+
40+
apply from: 'capacitor.build.gradle'
41+
42+
try {
43+
def servicesJSON = file('google-services.json')
44+
if (servicesJSON.text) {
45+
apply plugin: 'com.google.gms.google-services'
46+
}
47+
} catch(Exception e) {
48+
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
49+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
2+
3+
android {
4+
compileOptions {
5+
sourceCompatibility JavaVersion.VERSION_1_8
6+
targetCompatibility JavaVersion.VERSION_1_8
7+
}
8+
}
9+
10+
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
11+
dependencies {
12+
implementation project(':capacitor-community-twitter')
13+
14+
}
15+
16+
17+
if (hasProperty('postBuildExtras')) {
18+
postBuildExtras()
19+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.getcapacitor.myapp;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.getcapacitor.app", appContext.getPackageName());
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="io.ionic.starter">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
13+
<activity
14+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
15+
android:name="io.ionic.starter.MainActivity"
16+
android:label="@string/title_activity_main"
17+
android:theme="@style/AppTheme.NoActionBarLaunch">
18+
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
24+
<intent-filter>
25+
<action android:name="android.intent.action.VIEW" />
26+
<category android:name="android.intent.category.DEFAULT" />
27+
<category android:name="android.intent.category.BROWSABLE" />
28+
<data android:scheme="@string/custom_url_scheme" />
29+
</intent-filter>
30+
31+
</activity>
32+
33+
<provider
34+
android:name="androidx.core.content.FileProvider"
35+
android:authorities="${applicationId}.fileprovider"
36+
android:exported="false"
37+
android:grantUriPermissions="true">
38+
<meta-data
39+
android:name="android.support.FILE_PROVIDER_PATHS"
40+
android:resource="@xml/file_paths"></meta-data>
41+
</provider>
42+
</application>
43+
44+
<!-- Permissions -->
45+
46+
<uses-permission android:name="android.permission.INTERNET" />
47+
<!-- Camera, Photos, input file -->
48+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
49+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
50+
<!-- Geolocation API -->
51+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
52+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
53+
<uses-feature android:name="android.hardware.location.gps" />
54+
<!-- Network API -->
55+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
56+
<!-- Navigator.getUserMedia -->
57+
<!-- Video -->
58+
<uses-permission android:name="android.permission.CAMERA" />
59+
<!-- Audio -->
60+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
61+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
62+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"appId": "io.ionic.starter",
3+
"appName": "capacitor-twitter-example",
4+
"bundledWebRuntime": false,
5+
"webDir": "www",
6+
"plugins": {
7+
"TwitterPlugin": {
8+
"consumerKey": "XXX",
9+
"consumerSecret": "YYY"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.ionic.starter;
2+
3+
import android.os.Bundle;
4+
5+
import com.getcapacitor.BridgeActivity;
6+
import com.getcapacitor.Plugin;
7+
8+
import java.util.ArrayList;
9+
10+
import com.getcapacitor.community.twitter.TwitterPlugin;
11+
12+
public class MainActivity extends BridgeActivity {
13+
@Override
14+
public void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
17+
// Initializes the Bridge
18+
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
19+
// Additional plugins you've installed go here
20+
// Ex: add(TotallyAwesomePlugin.class);
21+
//
22+
// add the plugin to capacitor
23+
add(TwitterPlugin.class);
24+
}});
25+
}
26+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeColor="#00000000"
11+
android:strokeWidth="1">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0" />
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0" />
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeColor="#00000000"
33+
android:strokeWidth="1" />
34+
</vector>

0 commit comments

Comments
 (0)