Skip to content

Commit ad29e21

Browse files
committed
Initial files
1 parent 1306cd9 commit ad29e21

File tree

23 files changed

+435
-0
lines changed

23 files changed

+435
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.iml
2+
.gradle
3+
/gradle
4+
/gradlew
5+
/gradlew.bat
6+
/local.properties
7+
/.idea
8+
.DS_Store
9+
/build
10+
/captures

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.2"
6+
7+
defaultConfig {
8+
applicationId "ca.carleton.gcrc.n2android_mobile1"
9+
minSdkVersion 15
10+
targetSdkVersion 23
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
packagingOptions {
21+
exclude 'META-INF/ASL2.0'
22+
exclude 'META-INF/LICENSE'
23+
exclude 'META-INF/NOTICE'
24+
}
25+
}
26+
27+
dependencies {
28+
compile fileTree(dir: 'libs', include: ['*.jar'])
29+
testCompile 'junit:junit:4.12'
30+
compile 'com.android.support:appcompat-v7:23.2.0'
31+
compile 'com.android.support:support-v4:23.2.0'
32+
33+
compile 'com.couchbase.lite:couchbase-lite-android:0.0.0-577'
34+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /extra/jpfiset/src/adt-bundle-linux-x86_64-20140702/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ca.carleton.gcrc.n2android_mobile1;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/src/main/AndroidManifest.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="ca.carleton.gcrc.n2android_mobile1">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity
12+
android:name=".MainActivity"
13+
android:configChanges="orientation|keyboardHidden|screenSize"
14+
android:label="@string/app_name"
15+
android:theme="@style/FullscreenTheme">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
<activity
23+
android:name=".SecondActivity"
24+
android:configChanges="orientation|keyboardHidden|screenSize"
25+
android:label="@string/activity_2_name"
26+
android:theme="@style/FullscreenTheme"
27+
android:parentActivityName=".MainActivity">
28+
</activity>
29+
</application>
30+
31+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package ca.carleton.gcrc.n2android_mobile1;
2+
3+
import android.annotation.SuppressLint;
4+
import android.content.Intent;
5+
import android.support.v7.app.ActionBar;
6+
import android.support.v7.app.AppCompatActivity;
7+
import android.os.Bundle;
8+
import android.os.Handler;
9+
import android.view.MotionEvent;
10+
import android.view.View;
11+
import android.widget.Toast;
12+
13+
import com.couchbase.lite.Database;
14+
import com.couchbase.lite.DatabaseOptions;
15+
import com.couchbase.lite.Document;
16+
import com.couchbase.lite.Emitter;
17+
import com.couchbase.lite.LiveQuery;
18+
import com.couchbase.lite.Manager;
19+
import com.couchbase.lite.Mapper;
20+
import com.couchbase.lite.SavedRevision;
21+
import com.couchbase.lite.android.AndroidContext;
22+
import com.couchbase.lite.util.Log;
23+
24+
import java.util.HashMap;
25+
import java.util.Map;
26+
27+
/**
28+
* An example full-screen activity that shows and hides the system UI (i.e.
29+
* status bar and navigation/system bar) with user interaction.
30+
*/
31+
public class MainActivity extends AppCompatActivity {
32+
33+
public static String TAG = "NunaliitMobile";
34+
35+
// constants
36+
public static final String DATABASE_NAME = "connections";
37+
public static final String designDocName = "local";
38+
39+
// couchdb internals
40+
protected static Manager manager;
41+
private Database database;
42+
private LiveQuery liveQuery;
43+
44+
@Override
45+
protected void onCreate(Bundle savedInstanceState) {
46+
super.onCreate(savedInstanceState);
47+
48+
setContentView(R.layout.activity_main);
49+
50+
try {
51+
startCouchDb();
52+
} catch(Exception e) {
53+
Toast
54+
.makeText(getApplicationContext(), "Error Initializing CouchDB, see logs for details", Toast.LENGTH_LONG)
55+
.show();
56+
Log.e(TAG, "Error initializing CouchDB", e);
57+
}
58+
}
59+
60+
@Override
61+
protected void onPostCreate(Bundle savedInstanceState) {
62+
super.onPostCreate(savedInstanceState);
63+
}
64+
65+
protected void onDestroy() {
66+
if(manager != null) {
67+
manager.close();
68+
manager = null;
69+
}
70+
super.onDestroy();
71+
}
72+
73+
protected void startCouchDb() throws Exception {
74+
75+
Manager.enableLogging(TAG, Log.VERBOSE);
76+
Manager.enableLogging(Log.TAG, Log.VERBOSE);
77+
Manager.enableLogging(Log.TAG_SYNC_ASYNC_TASK, Log.VERBOSE);
78+
Manager.enableLogging(Log.TAG_SYNC, Log.VERBOSE);
79+
Manager.enableLogging(Log.TAG_QUERY, Log.VERBOSE);
80+
Manager.enableLogging(Log.TAG_VIEW, Log.VERBOSE);
81+
Manager.enableLogging(Log.TAG_DATABASE, Log.VERBOSE);
82+
83+
manager = new Manager(new AndroidContext(getApplicationContext()), Manager.DEFAULT_OPTIONS);
84+
85+
// install a view definition needed by the application
86+
DatabaseOptions options = new DatabaseOptions();
87+
options.setCreate(true);
88+
database = manager.openDatabase(DATABASE_NAME, options);
89+
90+
Document doc = database.getDocument("testDoc");
91+
SavedRevision currentRevision = doc.getCurrentRevision();
92+
if( null == currentRevision ){
93+
Log.i(TAG, "testDoc does not exist");
94+
Map<String,Object> props = new HashMap<String,Object>();
95+
props.put("nunaliit_test","allo");
96+
doc.putProperties(props);
97+
} else {
98+
Log.i(TAG, "testDoc revision: "+currentRevision.getProperties().get("_rev"));
99+
}
100+
// com.couchbase.lite.View viewItemsByDate = database.getView(String.format("%s/%s", designDocName, byDateViewName));
101+
// viewItemsByDate.setMap(new Mapper() {
102+
// @Override
103+
// public void map(Map<String, Object> document, Emitter emitter) {
104+
// Object createdAt = document.get("created_at");
105+
// if (createdAt != null) {
106+
// emitter.emit(createdAt.toString(), null);
107+
// }
108+
// }
109+
// }, "1.0");
110+
//
111+
// initItemListAdapter();
112+
//
113+
// startLiveQuery(viewItemsByDate);
114+
//
115+
// startSync();
116+
117+
}
118+
119+
public void startActivity2(View view){
120+
Intent intent = new Intent(this, SecondActivity.class);
121+
startActivity(intent);
122+
}
123+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package ca.carleton.gcrc.n2android_mobile1;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.view.View;
6+
import android.widget.Toast;
7+
8+
import com.couchbase.lite.util.Log;
9+
10+
/**
11+
* Created by jpfiset on 3/7/16.
12+
*/
13+
public class SecondActivity extends AppCompatActivity {
14+
@Override
15+
protected void onCreate(Bundle savedInstanceState) {
16+
super.onCreate(savedInstanceState);
17+
18+
setContentView(R.layout.activity_second);
19+
20+
}
21+
}
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:background="#0099cc"
6+
tools:context="ca.carleton.gcrc.n2android_mobile1.MainActivity">
7+
8+
<!-- The primary full-screen view. This can be replaced with whatever view
9+
is needed to present your content, e.g. VideoView, SurfaceView,
10+
TextureView, etc. -->
11+
<TextView
12+
android:id="@+id/fullscreen_content"
13+
android:layout_width="match_parent"
14+
android:layout_height="match_parent"
15+
android:gravity="center"
16+
android:keepScreenOn="true"
17+
android:text="@string/dummy_content"
18+
android:textColor="#33b5e5"
19+
android:textSize="50sp"
20+
android:textStyle="bold" />
21+
22+
<!-- This FrameLayout insets its children based on system windows using
23+
android:fitsSystemWindows. -->
24+
<FrameLayout
25+
android:layout_width="match_parent"
26+
android:layout_height="match_parent"
27+
android:fitsSystemWindows="true">
28+
29+
<LinearLayout
30+
android:id="@+id/fullscreen_content_controls"
31+
style="?metaButtonBarStyle"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
android:layout_gravity="bottom|center_horizontal"
35+
android:background="@color/black_overlay"
36+
android:orientation="horizontal"
37+
tools:ignore="UselessParent">
38+
39+
<Button
40+
android:id="@+id/activty_2_button"
41+
style="?metaButtonBarButtonStyle"
42+
android:layout_width="0dp"
43+
android:layout_height="wrap_content"
44+
android:layout_weight="1"
45+
android:text="@string/activity_2_button"
46+
android:onClick="startActivity2"/>
47+
48+
</LinearLayout>
49+
</FrameLayout>
50+
51+
</FrameLayout>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:background="#0099cc"
7+
tools:context="ca.carleton.gcrc.n2android_mobile1.SecondActivity">
8+
9+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
10+
android:layout_width="match_parent"
11+
android:layout_height="match_parent">
12+
13+
<TextView
14+
android:layout_width="wrap_content"
15+
android:layout_height="wrap_content"
16+
android:text="Just a test"
17+
android:id="@+id/textView"
18+
android:gravity="center_vertical|center_horizontal" />
19+
</LinearLayout>
20+
21+
</FrameLayout>
3.34 KB
Loading
2.15 KB
Loading
4.73 KB
Loading
7.54 KB
Loading
10.2 KB
Loading

app/src/main/res/values/attrs.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<resources>
2+
3+
<!-- Declare custom theme attributes that allow changing which styles are
4+
used for button bars depending on the API level.
5+
?android:attr/buttonBarStyle is new as of API 11 so this is
6+
necessary to support previous API levels. -->
7+
<declare-styleable name="ButtonBarContainerTheme">
8+
<attr name="metaButtonBarStyle" format="reference" />
9+
<attr name="metaButtonBarButtonStyle" format="reference" />
10+
</declare-styleable>
11+
12+
</resources>

app/src/main/res/values/colors.xml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#3F51B5</color>
4+
<color name="colorPrimaryDark">#303F9F</color>
5+
<color name="colorAccent">#FF4081</color>
6+
7+
<color name="black_overlay">#66000000</color>
8+
</resources>

app/src/main/res/values/strings.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<resources>
2+
<string name="app_name">n2android_mobile1</string>
3+
4+
<string name="dummy_button">Dummy Button</string>
5+
<string name="dummy_content">DUMMY\nCONTENT</string>
6+
7+
<string name="activity_2_name">Second Activity</string>
8+
<string name="activity_2_button">Activity 2</string>
9+
</resources>

app/src/main/res/values/styles.xml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
<item name="colorPrimary">@color/colorPrimary</item>
7+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8+
<item name="colorAccent">@color/colorAccent</item>
9+
</style>
10+
11+
<style name="FullscreenTheme" parent="AppTheme">
12+
<item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
13+
<item name="android:windowActionBarOverlay">true</item>
14+
<item name="android:windowBackground">@null</item>
15+
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
16+
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
17+
</style>
18+
19+
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
20+
<item name="android:background">@color/black_overlay</item>
21+
</style>
22+
23+
</resources>

0 commit comments

Comments
 (0)