-
Notifications
You must be signed in to change notification settings - Fork 3
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
rbailey
committed
Jan 22, 2014
1 parent
ec65fd3
commit 11503d0
Showing
26 changed files
with
653 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 @@ | ||
/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,22 @@ | ||
apply plugin: 'android' | ||
|
||
android { | ||
compileSdkVersion "Google Inc.:Glass Development Kit Sneak Peek:15" | ||
buildToolsVersion "19.0.0" | ||
|
||
defaultConfig { | ||
minSdkVersion 15 | ||
targetSdkVersion 15 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
runProguard false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
} |
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 /Applications/Android Studio.app/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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.rbware.glassappmanager" > | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_delete_50" | ||
android:label="@string/app_name" > | ||
<activity | ||
android:name="com.rbware.glassappmanager.MainActivity" | ||
android:label="@string/app_name" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
<action android:name="com.google.android.glass.action.VOICE_TRIGGER" /> | ||
</intent-filter> | ||
<meta-data | ||
android:name="com.google.android.glass.VoiceTrigger" | ||
android:resource="@xml/app" /> | ||
|
||
</activity> | ||
</application> | ||
|
||
</manifest> |
180 changes: 180 additions & 0 deletions
180
Application Manager/src/main/java/com/rbware/glassappmanager/MainActivity.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,180 @@ | ||
package com.rbware.glassappmanager; | ||
|
||
import android.app.Activity; | ||
import android.app.ActionBar; | ||
import android.app.Fragment; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.pm.ApplicationInfo; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.ResolveInfo; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.os.Build; | ||
import android.widget.AdapterView; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.google.android.glass.widget.CardScrollAdapter; | ||
import com.google.android.glass.widget.CardScrollView; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MainActivity extends Activity { | ||
|
||
private ArrayList<ApplicationInfo> mPackageNames = new ArrayList(); | ||
|
||
private int mSelectedListing; | ||
private UIListingCardScrollAdapter mAdapter; | ||
private CardScrollView mCardScrollView; | ||
private TextView mNoAppsFound; | ||
|
||
private PackageManager mPackageManager; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
mPackageManager = this.getPackageManager(); | ||
View rootLayout = getLayoutInflater().inflate(R.layout.activity_main, null); | ||
mNoAppsFound = (TextView)rootLayout.findViewById(R.id.noAppsFound); | ||
setupCardList(rootLayout); | ||
setContentView(rootLayout); | ||
} | ||
|
||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
|
||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.main, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
if (id == R.id.action_uninstall) { | ||
String packageName = mPackageNames.get(mSelectedListing).packageName; | ||
Uri packageURI = Uri.parse("package:" + packageName); | ||
Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); | ||
startActivityForResult(uninstallIntent, 0); | ||
|
||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
|
||
if (requestCode == 0){ | ||
mPackageNames.clear(); | ||
setupCardList(null); | ||
} | ||
|
||
super.onActivityResult(requestCode, resultCode, data); | ||
} | ||
|
||
private void setupCardList(View rootLayout){ | ||
|
||
Intent intent = new Intent(Intent.ACTION_MAIN, null); | ||
intent.addCategory(Intent.CATEGORY_LAUNCHER); | ||
|
||
List<ResolveInfo> list = mPackageManager.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED); | ||
for (ResolveInfo rInfo : list) { | ||
if (!rInfo.activityInfo.applicationInfo.loadLabel(mPackageManager).toString().equals("Glass Home") && | ||
!rInfo.activityInfo.applicationInfo.loadLabel(mPackageManager).toString().equals("Glass App Manager")) | ||
mPackageNames.add(rInfo.activityInfo.applicationInfo); | ||
} | ||
|
||
if(!mPackageNames.isEmpty()){ | ||
mAdapter = new UIListingCardScrollAdapter(); | ||
if (mCardScrollView == null){ | ||
mCardScrollView = (CardScrollView)rootLayout.findViewById(R.id.card_scroll_view); | ||
mCardScrollView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||
@Override | ||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | ||
mSelectedListing = position; | ||
MainActivity.super.openOptionsMenu(); | ||
} | ||
}); | ||
} | ||
mCardScrollView.setVisibility(View.VISIBLE); | ||
mCardScrollView.setAdapter(mAdapter); | ||
mCardScrollView.activate(); | ||
} else { | ||
|
||
|
||
mNoAppsFound.setVisibility(View.VISIBLE); | ||
|
||
if(mCardScrollView != null) | ||
mCardScrollView.setVisibility(View.INVISIBLE); | ||
|
||
} | ||
} | ||
|
||
private class UIListingCardScrollAdapter extends CardScrollAdapter { | ||
|
||
@Override | ||
public int findIdPosition(Object id) { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public int findItemPosition(Object item) { | ||
return mPackageNames.indexOf(item); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
Log.d("Tag", "getCount() = " + mPackageNames.size()); | ||
return mPackageNames.size(); | ||
} | ||
|
||
@Override | ||
public Object getItem(int position) { | ||
Log.d("Tag", "getItem(" + position + ") = " + mPackageNames.get(position)); | ||
return mPackageNames.get(position); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
View v = convertView; | ||
LayoutInflater layoutInflater; | ||
|
||
if (v == null) { | ||
layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
v = layoutInflater.inflate(R.layout.application_detail, null); | ||
} | ||
|
||
TextView appName = (TextView)v.findViewById(R.id.applicationName); | ||
TextView appVersion = (TextView)v.findViewById(R.id.applicationVersion); | ||
ImageView appIcon = (ImageView)v.findViewById(R.id.applicationIcon); | ||
|
||
if (!mPackageNames.isEmpty()){ | ||
|
||
ApplicationInfo info = mPackageNames.get(position); | ||
|
||
appName.setText(info.loadLabel(mPackageManager).toString()); | ||
appIcon.setImageDrawable(info.loadIcon(mPackageManager)); | ||
try{ | ||
appVersion.setText(getPackageManager().getPackageInfo(info.loadLabel(mPackageManager).toString(), 0).versionCode); | ||
} catch (PackageManager.NameNotFoundException e){ | ||
|
||
} | ||
} | ||
return v; | ||
} | ||
|
||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/container" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.rbware.glassappmanager.MainActivity" | ||
> | ||
|
||
<com.google.android.glass.widget.CardScrollView | ||
android:id="@+id/card_scroll_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:visibility="invisible" | ||
/> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:text="No applications found" | ||
android:id="@+id/noAppsFound" | ||
android:visibility="invisible" | ||
/> | ||
|
||
</RelativeLayout> |
40 changes: 40 additions & 0 deletions
40
Application Manager/src/main/res/layout/application_detail.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:background="@android:color/black"> | ||
|
||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
android:gravity="center" | ||
> | ||
|
||
|
||
<ImageView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/applicationIcon" | ||
android:layout_marginRight="8dip" | ||
/> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/applicationName" | ||
/> | ||
</LinearLayout> | ||
|
||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/applicationVersion" | ||
/> | ||
|
||
</LinearLayout> |
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,10 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context="com.rbware.glassappmanager.MainActivity" > | ||
|
||
<item android:id="@+id/action_uninstall" | ||
android:title="@string/action_uninstall" | ||
android:orderInCategory="100" | ||
android:icon="@drawable/ic_delete_50" | ||
android:showAsAction="ifRoom" /> | ||
</menu> |
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 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
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 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
|
||
</resources> |
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,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<string name="app_name">Glass App Manager</string> | ||
<string name="action_uninstall">Uninstall</string> | ||
<string name="voice_trigger">uninstall an app</string> | ||
|
||
</resources> |
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,8 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="android:Theme.Holo"> | ||
<!-- Customize your theme here. --> | ||
</style> | ||
|
||
</resources> |
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 @@ | ||
<trigger keyword="@string/voice_trigger"/> |
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,16 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:0.7.+' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
mavenCentral() | ||
} | ||
} |
Oops, something went wrong.
11503d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RBWare nice work, $5 @changetip
11503d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi rbware, kleetus sent you a Bitcoin tip worth 13,316 bits ($5.00), and I'm here to deliver it ➔ collect your tip at ChangeTip.com.
Learn more about ChangeTip