Skip to content

Commit

Permalink
Renamed QPackageManager to QuteLauncher, UIValues to ScreenValues, Up…
Browse files Browse the repository at this point in the history
…date UI
  • Loading branch information
Iktwo committed Apr 18, 2015
1 parent e44c461 commit 07861ae
Show file tree
Hide file tree
Showing 14 changed files with 241 additions and 356 deletions.
2 changes: 1 addition & 1 deletion src/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<manifest package="com.iktwo.qutelauncher" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.01" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="qutelauncher" android:theme="@style/AppTheme">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="com.iktwo.qutelauncher.QPackageManager" android:label="Qutelauncher" android:screenOrientation="unspecified" android:launchMode="singleInstance">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="com.iktwo.qutelauncher.QuteLauncher" android:label="Qutelauncher" android:screenOrientation="unspecified" android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.HOME"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public void onReceive(final Context context, Intent intent) {
final String action = intent.getAction();

if (action.equals("android.intent.action.PACKAGE_ADDED")) {
if (QPackageManager.isApplaunchable(packageName))
jpackageAdded(QPackageManager.getApplicationLabel(packageName), packageName, qtObject);
if (QuteLauncher.isApplaunchable(packageName))
jpackageAdded(QuteLauncher.getApplicationLabel(packageName), packageName, qtObject);
} else if (action.equals("android.intent.action.PACKAGE_REMOVED")) {
jpackageRemoved(packageName, qtObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,27 @@
import android.graphics.drawable.BitmapDrawable;
import android.app.WallpaperManager;
import android.provider.Settings;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetProviderInfo;
import android.appwidget.AppWidgetHostView;
import android.util.DisplayMetrics;

import com.iktwo.qutelauncher.R;

public class QPackageManager extends org.qtproject.qt5.android.bindings.QtActivity {
public class QuteLauncher extends org.qtproject.qt5.android.bindings.QtActivity {
final int APPWIDGET_HOST_ID = 2048;
final int REQUEST_PICK_APPWIDGET = 0;
final int REQUEST_CREATE_APPWIDGET = 5;

// AppWidgetManager appWidgetManager;
// AppWidgetHost appWidgetHost;

private static final String TAG = "QPackageManager";
private static final String TAG = "QuteLauncher";
private static ConnectivityManager cm;
private static QPackageManager m_instance;
private static QuteLauncher m_instance;
private static WallpaperManager wm;
private static int mIconDpi;

private static PackageManager mPm;

public static String connectionType() {
cm = (ConnectivityManager) m_instance.getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo.getTypeName();
cm = (ConnectivityManager) m_instance.getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo.getTypeName();
}

@Override
Expand All @@ -73,130 +66,26 @@ public static boolean isApplaunchable(String packageName) {
}

public static int getDPI()
{
DisplayMetrics dm = m_instance.getResources().getDisplayMetrics();
return dm.densityDpi;
}

public static boolean isTablet()
{
return m_instance.getResources().getBoolean(R.bool.isTablet);
}


// @Override
// protected void onRestart() {
// super.onStart();
// m_instance = this;
// }

// @Override
// protected void onConfigurationChanged() {
// super.onConfigurationChanged();

// }
{
DisplayMetrics dm = m_instance.getResources().getDisplayMetrics();
return dm.densityDpi;
}

/// TODO: fix this horrible bug
// @Override
// protected void onPause() {
// finish();
// super.onPause();
// }
public static boolean isTablet()
{
return m_instance.getResources().getBoolean(R.bool.isTablet);
}

@Override
protected void onDestroy() {
System.exit(0);
}




// @Override
// protected void onStart() {
// super.onStart();
// appWidgetManager = AppWidgetManager.getInstance(this);
// appWidgetHost = new AppWidgetHost(this, APPWIDGET_HOST_ID);

// // Start listening to pending intents from the widgets
// appWidgetHost.startListening();
// }

// @Override
// protected void onStop() {
// super.onStop();
// appWidgetHost.stopListening();
// }

// public void selectWidget()
// {
// int appWidgetId = this.appWidgetHost.allocateAppWidgetId();
// Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
// pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
// addEmptyData(pickIntent);
// startActivityForResult(pickIntent, REQUEST_PICK_APPWIDGET);
// }

// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if (resultCode == RESULT_OK) {
// if (requestCode == REQUEST_PICK_APPWIDGET) {
// configureWidget(data);
// } else if (requestCode == REQUEST_CREATE_APPWIDGET) {
// createWidget(data);
// }
// } else if (resultCode == RESULT_CANCELED && data != null) {
// int appWidgetId =
// data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
// if (appWidgetId != -1) {
// appWidgetHost.deleteAppWidgetId(appWidgetId);
// }
// }
// }

// // Show configuration activity of the widget picked by the user
// private void configureWidget(Intent data) {
// Bundle extras = data.getExtras();
// int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
// AppWidgetProviderInfo appWidgetInfo =
// appWidgetManager.getAppWidgetInfo(appWidgetId);
// if (appWidgetInfo.configure != null) {
// Intent intent =
// new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
// intent.setComponent(appWidgetInfo.configure);
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
// startActivityForResult(intent, REQUEST_CREATE_APPWIDGET);
// } else {
// createWidget(data);
// }
// }

// // Get an instance of the selected widget as a AppWidgetHostView
// public void createWidget(Intent data) {
// Bundle extras = data.getExtras();
// int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
// AppWidgetProviderInfo appWidgetInfo = appWidgetManager.getAppWidgetInfo(appWidgetId);

// AppWidgetHostView hostView = appWidgetHost.createView(this, appWidgetId, appWidgetInfo);
// hostView.setAppWidget(appWidgetId, appWidgetInfo);
// // Add it on the layout you want
// //myLayout.addView(hostView);
// }


// For some reason you have to add this empty data, else it won't work
public void addEmptyData(Intent pickIntent)
{
ArrayList<AppWidgetProviderInfo> customInfo = new ArrayList<AppWidgetProviderInfo>();
pickIntent.putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_INFO, customInfo);
ArrayList<Bundle> customExtras = new ArrayList<Bundle>();
pickIntent.putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_EXTRAS, customExtras);
}

public static QPackageManager getInstance() {
public static QuteLauncher getInstance() {
return m_instance;
}

public QPackageManager() {
public QuteLauncher() {
m_instance = this;
}

Expand Down
70 changes: 30 additions & 40 deletions src/qml/ApplicationGrid.qml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0
import com.iktwo.qutelauncher 1.0

GridView {
id: root

property int highlightedItem

maximumFlickVelocity: height * 2.5
cacheBuffer: height * 5
cacheBuffer: Math.max(0, height * 5)

add: Transition {
NumberAnimation { properties: "opacity"; from: 0; to: 1; duration: 450 }
Expand All @@ -20,75 +22,63 @@ GridView {
NumberAnimation { property: "scale"; to: 1.0 }
}

clip: true
visible: false
interactive: visible

cellHeight: height / 5
cellHeight: height / 6
cellWidth: width / 4

delegate: Item {
id: itemDelegate

property var rect: mapToItem(root.parent)

height: GridView.view.cellHeight
width: GridView.view.cellWidth

onXChanged: rect = mapToItem(root.parent)
onYChanged: rect = mapToItem(root.parent)
onHeightChanged: rect = mapToItem(root.parent)
onWidthChanged: rect = mapToItem(root.parent)

Item {
ColumnLayout {
id: container

anchors {
fill: parent
margins: dpi * 0.04
}

Label {
anchors {
left: parent.left; leftMargin: dpi * 0.02
right: parent.right; rightMargin: dpi * 0.02
bottom: parent.bottom; bottomMargin: dpi * 0.03
}

text: model.name

elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.NoWrap
maximumLineCount: 2

font {
pointSize: 14
}

color: "white"
top: parent.top
left: parent.left
right: parent.right
}

Image {
id: icon

anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top; topMargin: parent.height * 0.2
}
anchors.horizontalCenter: parent.horizontalCenter

Layout.preferredHeight: Math.round(59 * ScreenValues.dp)
Layout.preferredWidth: Math.round(59 * ScreenValues.dp)

antialiasing: true
height: parent.height * 0.6
width: parent.width * 0.6
asynchronous: true
fillMode: Image.PreserveAspectFit
source: "image://icon/" + model.packageName
}

Label {
anchors.horizontalCenter: parent.horizontalCenter

Layout.preferredWidth: parent.width * 0.90

text: model.name

elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.NoWrap
maximumLineCount: 1

font.pixelSize: 12 * ScreenValues.dp

color: "#666666"
}
}

MouseArea {
anchors.fill: parent
onClicked: packageManager.launchApplication(model.packageName)
onClicked: PackageManager.launchApplication(model.packageName)
}
}
}
34 changes: 26 additions & 8 deletions src/qml/main.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import com.iktwo.qutelauncher 1.0

ApplicationWindow {
id: applicationWindow
Expand All @@ -26,14 +27,13 @@ ApplicationWindow {

Rectangle {
anchors.fill: parent
color: "black"
color: "#000000"
}

Image {
id: imageBackground

anchors.fill: parent
opacity: 0.5

fillMode: Image.PreserveAspectCrop

Expand All @@ -43,13 +43,31 @@ ApplicationWindow {
source: "image://wallpaper/"
}

ApplicationGrid {
id: applicationGrid
Rectangle {
anchors {
fill: parent
leftMargin: 8 * ScreenValues.dp
rightMargin: 8 * ScreenValues.dp
topMargin: 6 * ScreenValues.dp
bottomMargin: 38 * ScreenValues.dp
}

visible: true
model: packageManager
color: "#f5f5f5"
radius: 2 * ScreenValues.dp

anchors.fill: parent
ApplicationGrid {
id: applicationGrid

visible: true
model: PackageManager

anchors.fill: parent
}
}

BusyIndicator {
anchors.centerIn: parent
running: imageBackground.status !== Image.Error && imageBackground.status !== Image.Ready
}

FocusScope {
Expand All @@ -64,6 +82,6 @@ ApplicationWindow {
Timer {
interval: 550
running: true
onTriggered: packageManager.registerBroadcast()
onTriggered: PackageManager.registerBroadcast()
}
}
Loading

0 comments on commit 07861ae

Please sign in to comment.