-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ben
authored and
Ben
committed
Dec 27, 2013
1 parent
77f0368
commit 60beb0e
Showing
30 changed files
with
961 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.gradle | ||
/local.properties | ||
/.idea | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4"> | ||
<component name="FacetManager"> | ||
<facet type="android" name="Android"> | ||
<configuration> | ||
<option name="SELECTED_BUILD_VARIANT" value="debug" /> | ||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" /> | ||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" /> | ||
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" /> | ||
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" /> | ||
<option name="ALLOW_USER_CONFIGURATION" value="false" /> | ||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" /> | ||
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" /> | ||
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" /> | ||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" /> | ||
</configuration> | ||
</facet> | ||
<facet type="android-gradle" name="Android-Gradle"> | ||
<configuration> | ||
<option name="GRADLE_PROJECT_PATH" value=":app" /> | ||
</configuration> | ||
</facet> | ||
</component> | ||
<component name="NewModuleRootManager" inherit-compiler-output="false"> | ||
<output url="file://$MODULE_DIR$/build/classes/debug" /> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/debug" isTestSource="false" generated="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/debug" isTestSource="false" generated="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/debug" isTestSource="false" generated="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/debug" isTestSource="false" generated="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/debug" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/source/r/test/debug" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/source/aidl/test/debug" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/source/buildConfig/test/debug" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/source/rs/test/debug" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/build/res/rs/test/debug" type="java-test-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/aidl" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/assets" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/java" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/jni" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/rs" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/res" type="java-test-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/instrumentTest/resources" type="java-test-resource" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/apk" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/assets" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/bundles" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/classes" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/incremental" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/libs" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/manifests" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/res" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/symbols" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" /> | ||
</content> | ||
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" exported="" name="support-v4-18.0.0" level="project" /> | ||
</component> | ||
</module> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:0.7.+' | ||
} | ||
} | ||
apply plugin: 'android' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
android { | ||
compileSdkVersion 19 | ||
buildToolsVersion "19.0.0" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 19 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
buildTypes { | ||
release { | ||
runProguard false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:support-v4:18.0.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /opt/android-studio/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the ProGuard | ||
# include property in project.properties. | ||
# | ||
# 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 *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.sismics.docs" > | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" > | ||
<activity | ||
android:name="com.sismics.docs.DocListActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name="com.sismics.docs.DocDetailActivity" | ||
android:label="@string/title_doc_detail" | ||
android:parentActivityName="com.sismics.docs.DocListActivity" > | ||
<meta-data | ||
android:name="android.support.PARENT_ACTIVITY" | ||
android:value="com.sismics.docs.DocListActivity" /> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
67 changes: 67 additions & 0 deletions
67
docs-android/app/src/main/java/com/sismics/docs/DocDetailActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.sismics.docs; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v4.app.FragmentActivity; | ||
import android.support.v4.app.NavUtils; | ||
import android.view.MenuItem; | ||
|
||
/** | ||
* An activity representing a single Doc detail screen. This | ||
* activity is only used on handset devices. On tablet-size devices, | ||
* item details are presented side-by-side with a list of items | ||
* in a {@link DocListActivity}. | ||
* <p> | ||
* This activity is mostly just a 'shell' activity containing nothing | ||
* more than a {@link DocDetailFragment}. | ||
*/ | ||
public class DocDetailActivity extends FragmentActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_doc_detail); | ||
|
||
// Show the Up button in the action bar. | ||
getActionBar().setDisplayHomeAsUpEnabled(true); | ||
|
||
// savedInstanceState is non-null when there is fragment state | ||
// saved from previous configurations of this activity | ||
// (e.g. when rotating the screen from portrait to landscape). | ||
// In this case, the fragment will automatically be re-added | ||
// to its container so we don't need to manually add it. | ||
// For more information, see the Fragments API guide at: | ||
// | ||
// http://developer.android.com/guide/components/fragments.html | ||
// | ||
if (savedInstanceState == null) { | ||
// Create the detail fragment and add it to the activity | ||
// using a fragment transaction. | ||
Bundle arguments = new Bundle(); | ||
arguments.putString(DocDetailFragment.ARG_ITEM_ID, | ||
getIntent().getStringExtra(DocDetailFragment.ARG_ITEM_ID)); | ||
DocDetailFragment fragment = new DocDetailFragment(); | ||
fragment.setArguments(arguments); | ||
getSupportFragmentManager().beginTransaction() | ||
.add(R.id.doc_detail_container, fragment) | ||
.commit(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
int id = item.getItemId(); | ||
if (id == android.R.id.home) { | ||
// This ID represents the Home or Up button. In the case of this | ||
// activity, the Up button is shown. Use NavUtils to allow users | ||
// to navigate up one level in the application structure. For | ||
// more details, see the Navigation pattern on Android Design: | ||
// | ||
// http://developer.android.com/design/patterns/navigation.html#up-vs-back | ||
// | ||
NavUtils.navigateUpTo(this, new Intent(this, DocListActivity.class)); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
docs-android/app/src/main/java/com/sismics/docs/DocDetailFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.sismics.docs; | ||
|
||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import com.sismics.docs.dummy.DummyContent; | ||
|
||
/** | ||
* A fragment representing a single Doc detail screen. | ||
* This fragment is either contained in a {@link DocListActivity} | ||
* in two-pane mode (on tablets) or a {@link DocDetailActivity} | ||
* on handsets. | ||
*/ | ||
public class DocDetailFragment extends Fragment { | ||
/** | ||
* The fragment argument representing the item ID that this fragment | ||
* represents. | ||
*/ | ||
public static final String ARG_ITEM_ID = "item_id"; | ||
|
||
/** | ||
* The dummy content this fragment is presenting. | ||
*/ | ||
private DummyContent.DummyItem mItem; | ||
|
||
/** | ||
* Mandatory empty constructor for the fragment manager to instantiate the | ||
* fragment (e.g. upon screen orientation changes). | ||
*/ | ||
public DocDetailFragment() { | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
if (getArguments().containsKey(ARG_ITEM_ID)) { | ||
// Load the dummy content specified by the fragment | ||
// arguments. In a real-world scenario, use a Loader | ||
// to load content from a content provider. | ||
mItem = DummyContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID)); | ||
} | ||
} | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, | ||
Bundle savedInstanceState) { | ||
View rootView = inflater.inflate(R.layout.fragment_doc_detail, container, false); | ||
|
||
// Show the dummy content as text in a TextView. | ||
if (mItem != null) { | ||
((TextView) rootView.findViewById(R.id.doc_detail)).setText(mItem.content); | ||
} | ||
|
||
return rootView; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
docs-android/app/src/main/java/com/sismics/docs/DocListActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.sismics.docs; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v4.app.FragmentActivity; | ||
|
||
|
||
/** | ||
* An activity representing a list of Docs. This activity | ||
* has different presentations for handset and tablet-size devices. On | ||
* handsets, the activity presents a list of items, which when touched, | ||
* lead to a {@link DocDetailActivity} representing | ||
* item details. On tablets, the activity presents the list of items and | ||
* item details side-by-side using two vertical panes. | ||
* <p> | ||
* The activity makes heavy use of fragments. The list of items is a | ||
* {@link DocListFragment} and the item details | ||
* (if present) is a {@link DocDetailFragment}. | ||
* <p> | ||
* This activity also implements the required | ||
* {@link DocListFragment.Callbacks} interface | ||
* to listen for item selections. | ||
*/ | ||
public class DocListActivity extends FragmentActivity | ||
implements DocListFragment.Callbacks { | ||
|
||
/** | ||
* Whether or not the activity is in two-pane mode, i.e. running on a tablet | ||
* device. | ||
*/ | ||
private boolean mTwoPane; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_doc_list); | ||
|
||
if (findViewById(R.id.doc_detail_container) != null) { | ||
// The detail container view will be present only in the | ||
// large-screen layouts (res/values-large and | ||
// res/values-sw600dp). If this view is present, then the | ||
// activity should be in two-pane mode. | ||
mTwoPane = true; | ||
|
||
// In two-pane mode, list items should be given the | ||
// 'activated' state when touched. | ||
((DocListFragment) getSupportFragmentManager() | ||
.findFragmentById(R.id.doc_list)) | ||
.setActivateOnItemClick(true); | ||
} | ||
|
||
// TODO: If exposing deep links into your app, handle intents here. | ||
} | ||
|
||
/** | ||
* Callback method from {@link DocListFragment.Callbacks} | ||
* indicating that the item with the given ID was selected. | ||
*/ | ||
@Override | ||
public void onItemSelected(String id) { | ||
if (mTwoPane) { | ||
// In two-pane mode, show the detail view in this activity by | ||
// adding or replacing the detail fragment using a | ||
// fragment transaction. | ||
Bundle arguments = new Bundle(); | ||
arguments.putString(DocDetailFragment.ARG_ITEM_ID, id); | ||
DocDetailFragment fragment = new DocDetailFragment(); | ||
fragment.setArguments(arguments); | ||
getSupportFragmentManager().beginTransaction() | ||
.replace(R.id.doc_detail_container, fragment) | ||
.commit(); | ||
|
||
} else { | ||
// In single-pane mode, simply start the detail activity | ||
// for the selected item ID. | ||
Intent detailIntent = new Intent(this, DocDetailActivity.class); | ||
detailIntent.putExtra(DocDetailFragment.ARG_ITEM_ID, id); | ||
startActivity(detailIntent); | ||
} | ||
} | ||
} |
Oops, something went wrong.