Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Light-ePaper-Launcher - init from Collinux's fork of minimalist-launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
postapczuk committed Jul 6, 2020
1 parent 1a159ad commit 7946a21
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

Minimalistic App Launcher for Android
Copyright (C) 2018 Collinux
Copyright (C) 2018 Collinux, postapczuk

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "launcher.simple.com.simplelauncher"
applicationId "com.github.postapczuk.leplauncher"
minSdkVersion 4
targetSdkVersion 27
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="launcher.minimalist.com">
package="com.github.postapczuk.leplauncher">

<application
android:icon="@android:drawable/ic_menu_sort_by_size"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package launcher.minimalist.com;
package com.github.postapczuk.leplauncher;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -29,22 +32,42 @@ public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Setup UI elements
createListView();
setContentView(listView);

fillAppNames();
assignClickListeners();
fetchAppList();
}

private void createListView() {
listView = new ListView(this);
listView.setVerticalScrollBarEnabled(false);
listView.setId(android.R.id.list);
listView.setDivider(null);
setContentView(listView);
ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) listView.getLayoutParams();
p.setMargins(100, 0, 0, 0);
listView.setBackgroundColor(Color.WHITE);
int pxToDp = (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
60,
getApplicationContext().getResources().getDisplayMetrics());
listView.setPadding(pxToDp, pxToDp, pxToDp, pxToDp);
}

// Get a list of all the apps installed
private void fillAppNames() {
packageManager = getPackageManager();
adapter = new ArrayAdapter<String>(
this, android.R.layout.simple_list_item_1, new ArrayList<String>());
this, android.R.layout.simple_list_item_1,
new ArrayList<String>()) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView textView = (TextView) view.findViewById(android.R.id.text1);
textView.setTextColor(Color.BLACK);
return view;
}
};
packageNames = new ArrayList<>();
}

// Tap on an item in the list to launch the app
private void assignClickListeners() {
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Expand All @@ -56,7 +79,6 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
}
});

// Long press on an item in the list to open the app settings
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
Expand All @@ -71,27 +93,20 @@ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, l
return false;
}
});
fetchAppList();
}

private void fetchAppList() {
// Start from a clean adapter when refreshing the list
adapter.clear();
packageNames.clear();

// Query the package manager for all apps
List<ResolveInfo> activities = packageManager.queryIntentActivities(
new Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER), 0);

// Sort the applications by alphabetical order and add them to the list
Collections.sort(activities, new ResolveInfo.DisplayNameComparator(packageManager));
for (ResolveInfo resolver : activities) {

// Exclude the settings app and this launcher from the list of apps shown
String appName = (String) resolver.loadLabel(packageManager);
if (appName.equals("Settings") || appName.equals("Minimalist Launcher"))
if (appName.equals("Settings") || appName.equals("Light Android Launcher"))
continue;

adapter.add(appName);
packageNames.add(resolver.activityInfo.packageName);
}
Expand All @@ -100,7 +115,6 @@ private void fetchAppList() {

@Override
public void onBackPressed() {
// Prevent the back button from closing the activity.
fetchAppList();
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':MinimalistLauncher'
include ':LightEpaperLauncher'

0 comments on commit 7946a21

Please sign in to comment.