Skip to content

Instantly share code, notes, and snippets.

View luboganev's full-sized avatar

Lyubomir Ganev luboganev

View GitHub Profile
@luboganev
luboganev / CustomInteractionState
Created December 5, 2023 18:38
Jetpack Compose custom focus and other interaction states
/**
* A convenience wrapper around the [Interaction] types
*/
@Immutable
data class CustomInteraction(
val enabled: Boolean = false,
val hovered: Boolean = false,
val pressed: Boolean = false,
val focused: Boolean = false,
@luboganev
luboganev / pr_template.md
Created September 10, 2022 08:13
PR template

🎯 Scope

A broad summary of the changes or new functionality that this PR brings.

🛠 Details

A detailed list of changes and new functionality. You can be very technical and specific in this section.

🖼 Screenshots and videos

@luboganev
luboganev / lollipop.java
Created January 8, 2017 23:10 — forked from plateaukao/lollipop.java
How to detect foreground process name in Android with Lollipop
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static String getForegroundProcess(Context context) {
String topPackageName = null;
UsageStatsManager usage = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
long time = System.currentTimeMillis();
List<UsageStats> stats = usage.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 1000*1000, time);
if (stats != null) {
SortedMap<Long, UsageStats> runningTask = new TreeMap<Long,UsageStats>();
for (UsageStats usageStats : stats) {
runningTask.put(usageStats.getLastTimeUsed(), usageStats);
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@luboganev
luboganev / gist:8687562
Created January 29, 2014 13:08
Android Search compat action item collapse/expand
MenuItemCompat.setOnActionExpandListener(search, new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem menuItem) {
Toast.makeText(getApplicationContext(), "Expand", Toast.LENGTH_SHORT).show();
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
Toast.makeText(getApplicationContext(), "Collapse", Toast.LENGTH_SHORT).show();
package com.example.scalpeldrawer;
import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;