-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
1,259 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,14 @@ | ||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
# ========================= | ||
# Operating System Files | ||
# ========================= | ||
|
||
# OSX | ||
# ========================= | ||
|
||
.gradle | ||
/.gradle | ||
/gradle | ||
/.idea | ||
gradlew.bat | ||
gradlew | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
/build | ||
*.iml | ||
local.properties | ||
*.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# FloatingView | ||
|
||
Quick and simple library for creating floating views and activities | ||
|
||
License: | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/build | ||
*.iml | ||
manifest-merger-release-report.txt | ||
*.apk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
repositories { | ||
jcenter() | ||
} | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "24.0.3" | ||
|
||
defaultConfig { | ||
applicationId "com.xlythe.view.floating.sample" | ||
minSdkVersion 14 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile project(':floating-view') | ||
compile 'com.android.support:appcompat-v7:25.0.0' | ||
compile 'com.android.support:recyclerview-v7:25.0.0' | ||
compile 'com.android.support:design:25.0.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\Program Files (x86)\Android\android-studio\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 *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.xlythe.view.floating.sample"> | ||
|
||
<!-- For floating calculator --> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:fullBackupContent="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name"> | ||
<activity | ||
android:name=".CreateActivity" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.CREATE_SHORTCUT" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".OpenActivity" | ||
android:excludeFromRecents="true" | ||
android:exported="true" | ||
android:label="@string/app_name" | ||
android:launchMode="singleInstance" | ||
android:theme="@style/TransparentBackground"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.DEFAULT" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<service android:name=".FloatingNotes" /> | ||
</application> | ||
</manifest> |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/xlythe/view/floating/sample/CreateActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.xlythe.view.floating.sample; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.provider.Settings; | ||
|
||
/** | ||
* Creates the shortcut icon | ||
*/ | ||
public class CreateActivity extends Activity { | ||
private static final int REQUEST_CODE_WINDOW_OVERLAY_PERMISSION = 10001; | ||
|
||
public void onCreate(Bundle state) { | ||
super.onCreate(state); | ||
|
||
if (Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) { | ||
if (android.os.Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(this)) { | ||
startActivityForResult( | ||
new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())), | ||
REQUEST_CODE_WINDOW_OVERLAY_PERMISSION); | ||
} else { | ||
onSuccess(); | ||
} | ||
} | ||
} | ||
|
||
private void onSuccess() { | ||
Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher); | ||
|
||
Intent intent = new Intent(); | ||
Intent launchIntent = new Intent(this, OpenActivity.class); | ||
|
||
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent); | ||
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name)); | ||
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon); | ||
|
||
setResult(RESULT_OK, intent); | ||
finish(); | ||
} | ||
|
||
private void onFailure() { | ||
setResult(RESULT_CANCELED); | ||
finish(); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
if (requestCode == REQUEST_CODE_WINDOW_OVERLAY_PERMISSION) { | ||
if (Build.VERSION.SDK_INT >= 23 && Settings.canDrawOverlays(this)) { | ||
onSuccess(); | ||
} else { | ||
onFailure(); | ||
} | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/xlythe/view/floating/sample/FloatingNotes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.xlythe.view.floating.sample; | ||
|
||
import android.graphics.Point; | ||
import android.support.annotation.NonNull; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.xlythe.view.floating.FloatingView; | ||
|
||
public class FloatingNotes extends FloatingView { | ||
@NonNull | ||
@Override | ||
public View inflateButton(@NonNull ViewGroup parent) { | ||
return LayoutInflater.from(getContext()).inflate(R.layout.floating_icon, parent, false); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public View inflateView(@NonNull ViewGroup parent) { | ||
return LayoutInflater.from(getContext()).inflate(R.layout.floating_notes, parent, false); | ||
} | ||
|
||
@Override | ||
public void onShow() { | ||
|
||
} | ||
|
||
@Override | ||
public void onHide() { | ||
|
||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
app/src/main/java/com/xlythe/view/floating/sample/OpenActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.xlythe.view.floating.sample; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.provider.Settings; | ||
|
||
/** | ||
* When the shortcut icon is pressed, use this Activity to launch the overlay Service | ||
*/ | ||
public class OpenActivity extends Activity { | ||
private static final int REQUEST_CODE_WINDOW_OVERLAY_PERMISSION = 10001; | ||
|
||
public void onCreate(Bundle state) { | ||
super.onCreate(state); | ||
|
||
if (android.os.Build.VERSION.SDK_INT >= 23 && !Settings.canDrawOverlays(this)) { | ||
startActivityForResult( | ||
new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())), | ||
REQUEST_CODE_WINDOW_OVERLAY_PERMISSION); | ||
} else { | ||
onSuccess(); | ||
} | ||
} | ||
|
||
private void onSuccess() { | ||
Intent intent = new Intent(this, FloatingNotes.class); | ||
startService(intent); | ||
finish(); | ||
} | ||
|
||
private void onFailure() { | ||
setResult(RESULT_CANCELED); | ||
finish(); | ||
} | ||
|
||
@Override | ||
public void finish() { | ||
super.finish(); | ||
overridePendingTransition(R.anim.blank, R.anim.blank); | ||
} | ||
|
||
@Override | ||
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
if (requestCode == REQUEST_CODE_WINDOW_OVERLAY_PERMISSION) { | ||
if (android.os.Build.VERSION.SDK_INT >= 23 && Settings.canDrawOverlays(this)) { | ||
onSuccess(); | ||
} else { | ||
onFailure(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="65dp" | ||
android:layout_height="65dp" | ||
android:src="@mipmap/ic_launcher" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="150dp" | ||
android:layout_height="400dp" | ||
android:orientation="vertical" | ||
android:background="#3000fff0"> | ||
|
||
<TextView | ||
android:text="Hello World" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
</LinearLayout> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Floating Notes</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<resources xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<style name="TransparentBackground"> | ||
<item name="android:windowFrame">@null</item> | ||
<item name="android:windowBackground">@android:color/transparent</item> | ||
<item name="android:windowAnimationStyle">@null</item> | ||
<item name="android:backgroundDimEnabled">false</item> | ||
<item name="android:windowIsTranslucent">true</item> | ||
<item name="android:windowNoTitle">true</item> | ||
<item name="android:windowFullscreen">false</item> | ||
</style> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:2.2.2' | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build | ||
*.iml |
Oops, something went wrong.