Commit ad50e8d5 authored by Amit Kumar's avatar Amit Kumar
Browse files

Initial commit

parents
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/BlissLauncherO.iml" filepath="$PROJECT_DIR$/BlissLauncherO.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "org.indin.blisslauncher"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:gridlayout-v7:26.0.0'
compile 'com.github.droidlibrarian:horizontalpager:v2.0'
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true;
}
testCompile 'junit:junit:4.12'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/simple/Android/Sdk/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 *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package org.indin.blisslaunchero;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("org.indin.blisslaunchero", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.indin.blisslaunchero">
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".BlissLauncher">
<activity android:name=".MainActivity"
android:theme="@style/HomeScreenTheme"
android:launchMode="singleTask"
android:screenOrientation="nosensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="8fcf342f1b8ac74d6980872082b7216ef4682a29"
/>
</application>
</manifest>
package org.indin.blisslaunchero;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import java.util.ArrayList;
import java.util.List;
public class AppItem {
private CharSequence label;
private String packageName;
private Drawable icon;
private Intent intent;
private String componentName;
private boolean iconFromIconPack;
// Folder specific
private boolean belongsToFolder;
private boolean isFolder;
private String folderID;
private List<AppItem> subApps;
public AppItem(CharSequence label, String packageName, Drawable icon,
Intent intent, String componentName, boolean iconFromIconPack) {
this.label = label;
this.packageName = packageName;
this.icon = icon;
this.intent = intent;
this.componentName = componentName;
this.iconFromIconPack = iconFromIconPack;
}
public CharSequence getLabel() {
return label;
}
public void setLabel(CharSequence label) {
this.label = label;
}
public String getPackageName() {
return packageName;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public Drawable getIcon() {
return icon;
}
public void setIcon(Drawable icon) {
this.icon = icon;
}
public Intent getIntent() {
return intent;
}
public void setIntent(Intent intent) {
this.intent = intent;
}
public String getComponentName() {
return componentName;
}
public void setComponentName(String componentName) {
this.componentName = componentName;
}
public boolean isIconFromIconPack() {
return iconFromIconPack;
}
public void setIconFromIconPack(boolean iconFromIconPack) {
this.iconFromIconPack = iconFromIconPack;
}
public boolean isFolder() {
return isFolder;
}
public void setFolder(boolean folder) {
isFolder = folder;
}
public String getFolderID() {
return folderID;
}
public void setFolderID(String folderID) {
this.folderID = folderID;
}
public List<AppItem> getSubApps() {
if(subApps == null)
subApps = new ArrayList<>();
return subApps;
}
public void setSubApps(List<AppItem> subApps) {
this.subApps = subApps;
}
public boolean isBelongsToFolder() {
return belongsToFolder;
}
public void setBelongsToFolder(boolean belongsToFolder) {
this.belongsToFolder = belongsToFolder;
}
}
package org.indin.blisslaunchero;
import android.app.ActivityOptions;
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.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class AppUtil {
/**
* Uses the PackageManager to find all launchable apps.
* @param context
* @return
*/
public static List<AppItem> loadLaunchableApps(Context context) {
PackageManager packageManager = context.getPackageManager();
List<ApplicationInfo> apps = packageManager.getInstalledApplications(0);
List<AppItem> launchableApps = new ArrayList<>();
for(ApplicationInfo app: apps) {
String packageName = app.packageName;
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
if(intent != null) {
String componentName = intent.getComponent().toString();
boolean iconFromIconPack = true;
Drawable appIcon;
// Load icon from icon pack if present
if(IconPackUtil.iconPackPresent) {
appIcon = IconPackUtil.getIconFromIconPack(context, componentName);
if(appIcon == null) {
appIcon = app.loadIcon(packageManager);
iconFromIconPack = false;
appIcon = GraphicsUtil.scaleImage(context, appIcon, 1f);
appIcon = GraphicsUtil.maskImage(context, appIcon);
}
} else {
appIcon = app.loadIcon(packageManager);
iconFromIconPack = false;
}
AppItem launchableApp = new AppItem(
app.loadLabel(packageManager),
packageName,
appIcon,
intent,
componentName,
iconFromIconPack
);
launchableApps.add(launchableApp);
}
}
Collections.sort(launchableApps, new Comparator<AppItem>() {
@Override
public int compare(AppItem app1, AppItem app2) {
Collator collator = Collator.getInstance();
return collator.compare(app1.getLabel(), app2.getLabel());
}
});
return launchableApps;
}
/**
* Currently picks four apps for the dock (Phone, SMS, Browser, Camera)
*
* @param context
* @param launchableApps
* @return
*/
public static List<AppItem> getPinnedApps(Context context, List<AppItem> launchableApps) {
PackageManager pm = context.getPackageManager();
Intent[] intents = {
new Intent(Intent.ACTION_DIAL),
new Intent(Intent.ACTION_VIEW, Uri.parse("sms:")),
new Intent(Intent.ACTION_VIEW, Uri.parse("http:")),
new Intent(MediaStore.ACTION_IMAGE_CAPTURE)
};
List<AppItem> pinnedApps = new ArrayList<>();
for(Intent intent:intents) {
String packageName = getPackageNameForIntent(intent, pm);
for(AppItem app:launchableApps) {
if(app.getPackageName().equals(packageName)) {
pinnedApps.add(app);
break;
}
}
}
return pinnedApps;
}
@Nullable
private static String getPackageNameForIntent(Intent intent, PackageManager pm) {
List<ResolveInfo> activities = pm.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
if(activities.size() == 0) return null;
return activities.get(0).activityInfo.packageName;
}
public static void startActivityWithAnimation(Context context, Intent intent) {
Bundle bundle = ActivityOptions.makeCustomAnimation(
context, R.anim.enter, R.anim.leave).toBundle();
context.startActivity(intent, bundle);
}
/**
* Create an AppItem object given just a package name
* @param context
* @param packageName
* @return
*/
public static AppItem createAppItem(Context context, String packageName) {
try {
PackageManager packageManager = context.getPackageManager();
ApplicationInfo appInfo = packageManager.getApplicationInfo(packageName, 0);
Intent intent = packageManager.getLaunchIntentForPackage(packageName);
if(intent == null)
return null;
String componentName = intent.getComponent().toString();
Drawable appIcon;
boolean iconFromIconPack = true;
if(IconPackUtil.iconPackPresent) {
appIcon = IconPackUtil.getIconFromIconPack(context, componentName);
if(appIcon == null) {
appIcon = appInfo.loadIcon(packageManager);
iconFromIconPack = false;
appIcon = GraphicsUtil.scaleImage(context, appIcon, 1f);
appIcon = GraphicsUtil.maskImage(context, appIcon);
}
} else {
appIcon = appInfo.loadIcon(packageManager);
iconFromIconPack = false;
}
AppItem appItem = new AppItem(appInfo.loadLabel(packageManager),
packageName,
appIcon,
intent,
componentName,
iconFromIconPack);
return appItem;
} catch (PackageManager.NameNotFoundException e) {
return null;
}
}
}
\ No newline at end of file
package org.indin.blisslaunchero;
import android.content.Context;
import android.util.AttributeSet;
import android.view.DragEvent;
import android.widget.EditText;
public class BlissInput extends EditText {
public BlissInput(Context context) {
super(context);
}
public BlissInput(Context context, AttributeSet attrs) {
super(context, attrs);
}
public BlissInput(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public BlissInput(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public boolean onDragEvent(DragEvent event) {
// Without this drag/drop apps won't work on API <24.
// EditTexts seem to interfere with drag/drop.
return false;
}
}
package org.indin.blisslaunchero;
import android.app.Application;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
public class BlissLauncher extends Application {
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
}
}
package org.indin.blisslaunchero;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import android.util.Log;
public class GraphicsUtil {
private static final String TAG = "BLISS_GRAPHICS";
public static Bitmap blur(Context context, Bitmap image) {
int width = Math.round(image.getWidth() * 0.2f);