-
Notifications
You must be signed in to change notification settings - Fork 8
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
0 parents
commit 2df0721
Showing
985 changed files
with
77,668 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,6 @@ | ||
.idea | ||
.gradle | ||
/local.properties | ||
.DS_Store | ||
/build | ||
*.iml |
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,25 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 21 | ||
buildToolsVersion "21.1.2" | ||
|
||
defaultConfig { | ||
applicationId "com.example.android.apis" | ||
minSdkVersion 14 | ||
targetSdkVersion 21 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:21.0.3' | ||
} |
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 C:\develop\ASAndroidSDK/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# 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 *; | ||
#} |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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,3 @@ | ||
This text is stored in a raw Asset. | ||
|
||
It was read and placed into the TextView here. |
150 changes: 150 additions & 0 deletions
150
app/src/main/java/com/example/android/apis/ApiDemos.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,150 @@ | ||
/* | ||
* Copyright (C) 2007 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.example.android.apis; | ||
|
||
import android.app.ListActivity; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.ResolveInfo; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ListView; | ||
import android.widget.SimpleAdapter; | ||
|
||
import java.text.Collator; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Comparator; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ApiDemos extends ListActivity { | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
Intent intent = getIntent(); | ||
String path = intent.getStringExtra("com.example.android.apis.Path"); | ||
|
||
if (path == null) { | ||
path = ""; | ||
} | ||
|
||
setListAdapter(new SimpleAdapter(this, getData(path), | ||
android.R.layout.simple_list_item_1, new String[] { "title" }, | ||
new int[] { android.R.id.text1 })); | ||
getListView().setTextFilterEnabled(true); | ||
} | ||
|
||
protected List<Map<String, Object>> getData(String prefix) { | ||
List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>(); | ||
|
||
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); | ||
mainIntent.addCategory(Intent.CATEGORY_SAMPLE_CODE); | ||
|
||
PackageManager pm = getPackageManager(); | ||
List<ResolveInfo> list = pm.queryIntentActivities(mainIntent, 0); | ||
|
||
if (null == list) | ||
return myData; | ||
|
||
String[] prefixPath; | ||
String prefixWithSlash = prefix; | ||
|
||
if (prefix.equals("")) { | ||
prefixPath = null; | ||
} else { | ||
prefixPath = prefix.split("/"); | ||
prefixWithSlash = prefix + "/"; | ||
} | ||
|
||
int len = list.size(); | ||
|
||
Map<String, Boolean> entries = new HashMap<String, Boolean>(); | ||
|
||
for (int i = 0; i < len; i++) { | ||
ResolveInfo info = list.get(i); | ||
CharSequence labelSeq = info.loadLabel(pm); | ||
String label = labelSeq != null | ||
? labelSeq.toString() | ||
: info.activityInfo.name; | ||
|
||
if (prefixWithSlash.length() == 0 || label.startsWith(prefixWithSlash)) { | ||
|
||
String[] labelPath = label.split("/"); | ||
|
||
String nextLabel = prefixPath == null ? labelPath[0] : labelPath[prefixPath.length]; | ||
|
||
if ((prefixPath != null ? prefixPath.length : 0) == labelPath.length - 1) { | ||
addItem(myData, nextLabel, activityIntent( | ||
info.activityInfo.applicationInfo.packageName, | ||
info.activityInfo.name)); | ||
} else { | ||
if (entries.get(nextLabel) == null) { | ||
addItem(myData, nextLabel, browseIntent(prefix.equals("") ? nextLabel : prefix + "/" + nextLabel)); | ||
entries.put(nextLabel, true); | ||
} | ||
} | ||
} | ||
} | ||
|
||
Collections.sort(myData, sDisplayNameComparator); | ||
|
||
return myData; | ||
} | ||
|
||
private final static Comparator<Map<String, Object>> sDisplayNameComparator = | ||
new Comparator<Map<String, Object>>() { | ||
private final Collator collator = Collator.getInstance(); | ||
|
||
public int compare(Map<String, Object> map1, Map<String, Object> map2) { | ||
return collator.compare(map1.get("title"), map2.get("title")); | ||
} | ||
}; | ||
|
||
protected Intent activityIntent(String pkg, String componentName) { | ||
Intent result = new Intent(); | ||
result.setClassName(pkg, componentName); | ||
return result; | ||
} | ||
|
||
protected Intent browseIntent(String path) { | ||
Intent result = new Intent(); | ||
result.setClass(this, ApiDemos.class); | ||
result.putExtra("com.example.android.apis.Path", path); | ||
return result; | ||
} | ||
|
||
protected void addItem(List<Map<String, Object>> data, String name, Intent intent) { | ||
Map<String, Object> temp = new HashMap<String, Object>(); | ||
temp.put("title", name); | ||
temp.put("intent", intent); | ||
data.add(temp); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
protected void onListItemClick(ListView l, View v, int position, long id) { | ||
Map<String, Object> map = (Map<String, Object>)l.getItemAtPosition(position); | ||
|
||
Intent intent = new Intent((Intent) map.get("intent")); | ||
intent.addCategory(Intent.CATEGORY_SAMPLE_CODE); | ||
startActivity(intent); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/example/android/apis/ApiDemosApplication.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,36 @@ | ||
/* | ||
* Copyright (C) 2007 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.example.android.apis; | ||
|
||
import android.app.Application; | ||
|
||
/** | ||
* This is an example of a {@link android.app.Application} class. This can | ||
* be used as a central repository for per-process information about your app; | ||
* however it is recommended to use singletons for that instead rather than merge | ||
* all of these globals from across your application into one place here. | ||
* | ||
* In this case, we have not defined any specific work for this Application. | ||
* | ||
* See samples/ApiDemos/tests/src/com.example.android.apis/ApiDemosApplicationTests for an example | ||
* of how to perform unit tests on an Application object. | ||
*/ | ||
public class ApiDemosApplication extends Application { | ||
@Override | ||
public void onCreate() { | ||
} | ||
} |
Oops, something went wrong.