Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
markusfisch committed Jul 12, 2016
0 parents commit 4d1497b
Show file tree
Hide file tree
Showing 19 changed files with 989 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.swp
.gradle
.idea
build
local.properties
gradle.properties
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
PACKAGE = de.markusfisch.android.pielauncher
APK = app/build/outputs/apk/app-debug.apk

all: debug install start

debug:
./gradlew assembleDebug

lint:
./gradlew lintDebug

findbugs:
./gradlew findBugs

release:
@./gradlew \
assembleRelease \
-Pandroid.injected.signing.store.file=$(ANDROID_KEYFILE) \
-Pandroid.injected.signing.store.password=$(ANDROID_STORE_PASSWORD) \
-Pandroid.injected.signing.key.alias=$(ANDROID_KEY_ALIAS) \
-Pandroid.injected.signing.key.password=$(ANDROID_KEY_PASSWORD)

install:
adb $(TARGET) install -r $(APK)

start:
adb $(TARGET) shell 'am start -n $(PACKAGE)/.activity.HomeActivity'

uninstall:
adb $(TARGET) uninstall $(PACKAGE)

clean:
./gradlew clean
30 changes: 30 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apply plugin: 'com.android.application'
apply plugin: 'findbugs'

android {
compileSdkVersion 24
buildToolsVersion "23.0.3"

defaultConfig {
minSdkVersion 9
targetSdkVersion 24
}
}

dependencies {
compile 'com.android.support:appcompat-v7:24.0.0'
}

task findbugs(type: FindBugs, dependsOn: assembleDebug) {
excludeFilter = file('./findbugs-exclude.xml')
source = fileTree('src/main/java/')
classes = files("${project.rootDir}/app/build/intermediates/classes")
classpath = files()

effort = 'max'

reports {
xml.enabled = false
html.enabled = true
}
}
11 changes: 11 additions & 0 deletions app/findbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<FindBugsFilter>
<Match>
<Class name="~.*R\$.*"/>
</Match>
<Match>
<Class name="~.*Manifest\$.*"/>
</Match>
<Match>
<Class name="~.android.support.*"/>
</Match>
</FindBugsFilter>
32 changes: 32 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="de.markusfisch.android.pielauncher"
android:versionCode="1"
android:versionName="0.0.0"
android:installLocation="auto">
<supports-screens
android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>
<application
tools:ignore="UnusedAttribute"
android:allowBackup="true"
android:fullBackupContent="true"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".activity.HomeActivity"
android:label="@string/app_name"
android:theme="@style/HomeTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package de.markusfisch.android.pielauncher.activity;

import de.markusfisch.android.pielauncher.content.AppMenu;
import de.markusfisch.android.pielauncher.widget.PieLauncherSurfaceView;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Bundle;
import android.os.Build;
import android.view.View;
import android.view.Window;

public class HomeActivity extends Activity
{
private PieLauncherSurfaceView surfaceView;

@Override
public void onBackPressed()
{
// ignore back on home screen
}

@Override
protected void onCreate( Bundle state )
{
super.onCreate( state );

surfaceView = new PieLauncherSurfaceView(
new AppMenu( this ) );

setContentView( surfaceView );
setTransparentSystemBars( getWindow() );
}

@Override
protected void onResume()
{
super.onResume();
surfaceView.onResume();
}

@Override
protected void onPause()
{
super.onPause();
surfaceView.onPause();
}

@TargetApi( Build.VERSION_CODES.LOLLIPOP )
private static boolean setTransparentSystemBars( Window window )
{
if( window == null ||
Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP )
return false;

window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN );
window.setStatusBarColor( 0 );
window.setNavigationBarColor( 0 );

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package de.markusfisch.android.pielauncher.content;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

import java.util.List;

public class AppMenu extends PieMenu
{
private Context context;

public AppMenu( Context context )
{
this.context = context;
load();
}

public Context getContext()
{
return context;
}

public void fire()
{
if( selectedIcon > -1 )
((AppMenu.Icon)icons.get( selectedIcon )).launch( context );
}

private void load()
{
icons.clear();

PackageManager pm = context.getPackageManager();
List<PackageInfo> packs = pm.getInstalledPackages( 0 );

for( int n = 0, len = packs.size();
n < len;
++n )
{
PackageInfo p = packs.get( n );
Intent intent;

if( p == null ||
(intent = pm.getLaunchIntentForPackage(
p.packageName )) == null )
continue;

Icon icon = new Icon();

icon.appName = p.applicationInfo.loadLabel( pm ).toString();
icon.packageName = p.packageName;
icon.icon = p.applicationInfo.loadIcon( pm );
icon.intent = intent;

icons.add( icon );
}

numberOfIcons = icons.size();
}

public static class Icon extends PieMenu.Icon
{
public String appName;
public String packageName;
public Drawable icon;
public Intent intent;

public void launch( Context context )
{
if( intent == null )
return;

context.startActivity( intent );
}

public void draw( Canvas canvas )
{
int s = ((int)size)>>1<<1;

if( s < 1 )
return;

int half = s/2;
int left = x-half;
int top = y-half;

icon.setBounds( left, top, left+s, top+s );
icon.draw( canvas );
}
}
}
Loading

0 comments on commit 4d1497b

Please sign in to comment.