11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | Floating Info
2 | =========
3 |
4 | Floating Info is an Android application that displays the following in a system overlay window:
5 |
6 | * The application name, package name and process id of the application which is currently in the device's foreground
7 | * The Global CPU utilisation with a per-core breakdown - This is not foreground application specific.
8 | * Memory usage breakdown for the currently foregrounded process (read the [notes](#notes) for the caveats).
9 | * Network information like connection type, proxy status and IP addresses. Both IPv4 and IPv6
10 | * Device Locale Information
11 |
12 | ## Limitations
13 | Since Nougat it is not possible to get the process id of an app different than the one making the request.
14 | As a result it no longer possible to get the memory utilisation of other applications.
15 |
16 | SE Linux can interfere with getting CPU information as files in the /proc/ folder may not be globally readable.
17 |
18 |
19 |
21 |
22 |
23 | ## Screenshots
24 | Click to see in full size:
25 |
26 |
27 |
28 |
29 |
30 |
31 | ## Changelog
32 | * 1.0: First public release
33 | * 2.0: Conversion to Android Studio, Lollipop support, network info, onboarding
34 | * 2.1: Added Locale info, Oreo support
35 |
36 | # Notes and Caveats
37 | * The application will show the memory allocation of the currently foregrounded process which it gets by getting the Process Id of the currently foregrounded activity. This means that if an application has spawned multiple processes, this application will only show the memory utilisation of the main process.
38 | * The Memory information displayed come via a [Debug.MemoryInfo](http://developer.android.com/reference/android/os/Debug.MemoryInfo.html) object, while using reflection to expose a number of hidden [fields](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/os/Debug.java).
39 | * Data updates happen approximately every 1 second.
40 |
41 | # Android Memory Usage
42 | Memory management on Android is pretty complex and the easiest way to get started with understanding it is reading [this](https://developer.android.com/tools/debugging/debugging-memory.html) article - especially the "Viewing Overall Memory Allocations" section.
43 |
44 | ## Credits
45 | Author: [Alexandros Schillings](https://github.com/alt236)
46 |
47 | Based on [GhostLog](https://github.com/jgilfelt/GhostLog) by [Jeff Gilfelt](https://github.com/jgilfelt)
48 |
49 | The icon was adapted from [this](http://www.clker.com/clipart-duck-silhouette.html) one.
50 |
51 | ## License
52 | Copyright (C) 2017 Alexandros Schillings
53 |
54 | Licensed under the Apache License, Version 2.0 (the "License");
55 | you may not use this file except in compliance with the License.
56 | You may obtain a copy of the License at
57 |
58 | http://www.apache.org/licenses/LICENSE-2.0
59 |
60 | Unless required by applicable law or agreed to in writing, software
61 | distributed under the License is distributed on an "AS IS" BASIS,
62 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
63 | See the License for the specific language governing permissions and
64 | limitations under the License.
65 |
--------------------------------------------------------------------------------
/apkdetails.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 | set -o xtrace
5 | java -jar ./buildsystem/apkdetails/apkdetails-1.2.2.jar "$@"
6 | set +o xtrace
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | id 'kotlin-android-extensions'
5 | id 'com.github.triplet.play' version '2.8.0'
6 | }
7 |
8 | apply from: "${project.rootDir}/buildsystem/android-defaults.gradle"
9 |
10 | android {
11 |
12 | final int buildNumber = getBuildNumber()
13 | final int versionMajor = 2
14 | final int versionMinor = 0
15 | final int versionPatch = buildNumber
16 | final int androidVersionCode = buildNumber
17 |
18 | final String semanticVersion = "${versionMajor}.${versionMinor}.${versionPatch}"
19 |
20 | signingConfigs {
21 | release {
22 | storeFile file(System.getenv("ANDROID_KEYSTORE") ?: "[KEY_NOT_DEFINED]")
23 | storePassword System.getenv("KEYSTORE_PASSWORD")
24 | keyAlias System.getenv("KEY_ALIAS")
25 | keyPassword System.getenv("KEY_PASSWORD")
26 | }
27 |
28 | debug {
29 | storeFile file("${project.rootDir}/buildsystem/signing_keys/debug.keystore")
30 | keyAlias 'androiddebugkey'
31 | keyPassword 'android'
32 | storePassword 'android'
33 | }
34 | }
35 |
36 | defaultConfig {
37 | versionCode androidVersionCode
38 | versionName semanticVersion
39 | }
40 |
41 | buildTypes {
42 | release {
43 | minifyEnabled false
44 | resValue "string", "app_name", "Floating Info"
45 | if (isRunningOnCi()) {
46 | signingConfig signingConfigs.release
47 | }
48 | }
49 |
50 | debug {
51 | minifyEnabled false
52 | applicationIdSuffix ".debug"
53 | signingConfig signingConfigs.debug
54 |
55 | resValue "string", "app_name", "Debug Floating Info"
56 | }
57 | }
58 |
59 | compileOptions {
60 | sourceCompatibility JavaVersion.VERSION_1_8
61 | targetCompatibility JavaVersion.VERSION_1_8
62 | }
63 |
64 | }
65 |
66 | dependencies {
67 | implementation project(":common")
68 | implementation project(":inforeader")
69 | implementation project(":overlay")
70 |
71 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
72 | implementation "androidx.core:core:$androidx_core_version"
73 | implementation "androidx.core:core-ktx:$androidx_core_version"
74 | implementation "androidx.appcompat:appcompat:$androidx_appcompat_version"
75 | implementation "androidx.annotation:annotation:$androidx_annotation_version"
76 |
77 | implementation "io.github.dreierf:material-intro-screen:$material_intro_screen_version"
78 |
79 | testImplementation "junit:junit:$junit_version"
80 | testImplementation "org.mockito:mockito-core:$mockito_version"
81 |
82 | androidTestImplementation "androidx.test:core:$andoridx_test_runner_version"
83 | androidTestImplementation "androidx.test:runner:$andoridx_test_runner_version"
84 | }
85 |
86 | play {
87 | def credentialsPath = System.getenv("GPLAY_DEPLOY_KEY") ?: "[KEY_NOT_DEFINED]"
88 | def lastCommitMessage = getLastGitCommitMessage().take(50)
89 |
90 | logger.warn("GPP Config: $credentialsPath")
91 | logger.warn("Release Name: '$lastCommitMessage'")
92 |
93 | if (isRunningOnCi()) {
94 | enabled = true
95 | track = "internal"
96 | //userFraction = 1.0
97 | releaseStatus = "completed"
98 | serviceAccountCredentials = file(credentialsPath)
99 | releaseName = lastCommitMessage
100 | artifactDir = file("${project.rootDir}/app/build/outputs/apk/release/")
101 | } else {
102 | enabled = false
103 | }
104 | }
105 | repositories {
106 | mavenCentral()
107 | }
108 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
13 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/assets/licenses.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
18 |
19 |
Floating Info
20 |
Copyright (C) 2014 Alexandros Schillings.
21 |
22 | Licensed under the Apache License, Version 2.0 (the "License");
23 | you may not use this file except in compliance with the License.
24 | You may obtain a copy of the License at
25 |
26 | http://www.apache.org/licenses/LICENSE-2.0
27 |
28 | Unless required by applicable law or agreed to in writing, software
29 | distributed under the License is distributed on an "AS IS" BASIS,
30 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 | See the License for the specific language governing permissions and
32 | limitations under the License.
33 |
34 |
Android Open Source Project
35 |
Copyright (C) 2013 The Android Open Source Project
36 |
37 | Licensed under the Apache License, Version 2.0 (the "License");
38 | you may not use this file except in compliance with the License.
39 | You may obtain a copy of the License at
40 |
41 | http://www.apache.org/licenses/LICENSE-2.0
42 |
43 | Unless required by applicable law or agreed to in writing, software
44 | distributed under the License is distributed on an "AS IS" BASIS,
45 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46 | See the License for the specific language governing permissions and
47 | limitations under the License.
48 |
49 |
Ghost Log
50 |
Copyright (C) 2014 readyState Software Ltd.
51 |
52 | Licensed under the Apache License, Version 2.0 (the "License");
53 | you may not use this file except in compliance with the License.
54 | You may obtain a copy of the License at
55 |
56 | http://www.apache.org/licenses/LICENSE-2.0
57 |
58 | Unless required by applicable law or agreed to in writing, software
59 | distributed under the License is distributed on an "AS IS" BASIS,
60 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
61 | See the License for the specific language governing permissions and
62 | limitations under the License.
63 |
64 |
libsuperuser
65 |
Copyright (C) 2013 The Android Open Source Project
66 |
67 | Licensed under the Apache License, Version 2.0 (the "License");
68 | you may not use this file except in compliance with the License.
69 | You may obtain a copy of the License at
70 |
71 | http://www.apache.org/licenses/LICENSE-2.0
72 |
73 | Unless required by applicable law or agreed to in writing, software
74 | distributed under the License is distributed on an "AS IS" BASIS,
75 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76 | See the License for the specific language governing permissions and
77 | limitations under the License.
78 |
79 |
Android Open Source Project
80 |
Copyright (C) 2013 The Android Open Source Project
81 |
82 | Licensed under the Apache License, Version 2.0 (the "License");
83 | you may not use this file except in compliance with the License.
84 | You may obtain a copy of the License at
85 |
86 | http://www.apache.org/licenses/LICENSE-2.0
87 |
88 | Unless required by applicable law or agreed to in writing, software
89 | distributed under the License is distributed on an "AS IS" BASIS,
90 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
91 | See the License for the specific language governing permissions and
92 | limitations under the License.
93 |
94 |
95 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/data/access/BaseProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.data.access;
17 |
18 | import android.app.Service;
19 | import android.content.BroadcastReceiver;
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.content.IntentFilter;
23 |
24 | import androidx.annotation.IntegerRes;
25 | import androidx.annotation.StringRes;
26 |
27 | public abstract class BaseProvider {
28 | private final Service mService;
29 |
30 |
31 | public BaseProvider(final Service service) {
32 | mService = service;
33 | }
34 |
35 | public abstract void stop();
36 |
37 | public Context getApplicationContext() {
38 | return mService.getApplicationContext();
39 | }
40 |
41 | public Context getContext() {
42 | return mService;
43 | }
44 |
45 | public int getInteger(@IntegerRes final int resId) {
46 | return mService.getResources().getInteger(resId);
47 | }
48 |
49 | public String getString(@StringRes final int resId) {
50 | return mService.getString(resId);
51 | }
52 |
53 | public Object getSystemService(final String name) {
54 | return mService.getSystemService(name);
55 | }
56 |
57 | protected void registerReceiver(final BroadcastReceiver receiver, final IntentFilter filter) {
58 | getContext().registerReceiver(receiver, filter);
59 | }
60 |
61 | public abstract boolean start();
62 |
63 | protected void startActivity(final Intent intent) {
64 | getContext().startActivity(intent);
65 | }
66 |
67 | protected void unregisterReceiver(final BroadcastReceiver receiver) {
68 | getContext().unregisterReceiver(receiver);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/data/access/generalinfo/GeneralInfoReceiver.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.data.access.generalinfo
17 |
18 | import android.content.BroadcastReceiver
19 | import android.content.Context
20 | import android.content.Intent
21 | import android.content.IntentFilter
22 |
23 | class GeneralInfoReceiver(private val mCallbacks: Callbacks) : BroadcastReceiver() {
24 | val intentFilter: IntentFilter
25 | get() {
26 | val f = IntentFilter()
27 | f.addAction(ACTION_PLAY)
28 | f.addAction(ACTION_PAUSE)
29 | f.addAction(ACTION_CLEAR)
30 | f.addAction(ACTION_SHARE)
31 | return f
32 | }
33 |
34 | override fun onReceive(context: Context, intent: Intent) {
35 | val action = intent.action
36 | when {
37 | ACTION_PLAY == action -> mCallbacks.onLogResume()
38 | ACTION_PAUSE == action -> mCallbacks.onLogPause()
39 | ACTION_CLEAR == action -> mCallbacks.onLogClear()
40 | ACTION_SHARE == action -> mCallbacks.onLogShare()
41 | }
42 | }
43 |
44 | interface Callbacks {
45 | fun onLogPause()
46 | fun onLogResume()
47 | fun onLogClear()
48 | fun onLogShare()
49 | }
50 |
51 | companion object {
52 | @JvmField
53 | val ACTION_PLAY = GeneralInfoReceiver::class.java.name + ".ACTION_PLAY"
54 |
55 | @JvmField
56 | val ACTION_PAUSE = GeneralInfoReceiver::class.java.name + ".ACTION_PAUSE"
57 |
58 | @JvmField
59 | val ACTION_CLEAR = GeneralInfoReceiver::class.java.name + ".ACTION_CLEAR"
60 |
61 | @JvmField
62 | val ACTION_SHARE = GeneralInfoReceiver::class.java.name + ".ACTION_SHARE"
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/data/access/generalinfo/PrefsChangeListener.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.data.access.generalinfo
17 |
18 | import android.content.Context
19 | import android.content.SharedPreferences
20 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener
21 | import android.preference.PreferenceManager
22 | import uk.co.alt236.floatinginfo.R
23 | import uk.co.alt236.floatinginfo.overlay.OverlayManager
24 |
25 | /*package*/
26 | internal class PrefsChangeListener(private val mContext: Context,
27 | private val mOverlayManager: OverlayManager) : OnSharedPreferenceChangeListener {
28 |
29 | private val mPrefs: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext)
30 |
31 | override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
32 | when (key) {
33 | mContext.getString(R.string.pref_key_bg_opacity) -> {
34 | mOverlayManager.updateBackground()
35 | }
36 | mContext.getString(R.string.pref_key_text_alpha) -> {
37 | mOverlayManager.updateTextColor()
38 | }
39 | mContext.getString(R.string.pref_key_text_size) -> {
40 | mOverlayManager.updateTextSize()
41 | }
42 | mContext.getString(R.string.pref_key_text_color_red) -> {
43 | mOverlayManager.updateTextColor()
44 | }
45 | mContext.getString(R.string.pref_key_text_color_green) -> {
46 | mOverlayManager.updateTextColor()
47 | }
48 | mContext.getString(R.string.pref_key_text_color_blue) -> {
49 | mOverlayManager.updateTextColor()
50 | }
51 | mContext.getString(R.string.pref_key_screen_position) -> {
52 | mOverlayManager.updateAlignment()
53 | }
54 | }
55 | }
56 |
57 | fun register() {
58 | mPrefs.registerOnSharedPreferenceChangeListener(this)
59 | }
60 |
61 | fun unRegister() {
62 | mPrefs.unregisterOnSharedPreferenceChangeListener(this)
63 | }
64 |
65 | }
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/data/access/generalinfo/SystemWindowLayoutParamsFactory.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.data.access.generalinfo
17 |
18 | import android.graphics.PixelFormat
19 | import android.os.Build
20 | import android.view.ViewGroup
21 | import android.view.WindowManager
22 |
23 | /*package*/
24 | internal class SystemWindowLayoutParamsFactory {
25 | val params: ViewGroup.LayoutParams
26 | get() {
27 | val windowType = windowType
28 | val flags = (WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
29 | or WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
30 | or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
31 | return WindowManager.LayoutParams(
32 | ViewGroup.LayoutParams.MATCH_PARENT,
33 | ViewGroup.LayoutParams.MATCH_PARENT,
34 | windowType,
35 | flags,
36 | PixelFormat.TRANSLUCENT
37 | )
38 | }
39 |
40 | private val windowType = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
41 | WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
42 | } else {
43 | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/data/access/generalinfo/monitortask/ProcessMonitor.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.data.access.generalinfo.monitortask
17 |
18 | import android.content.Context
19 | import android.os.AsyncTask
20 | import uk.co.alt236.floatinginfo.common.prefs.EnabledInfoPrefs
21 |
22 | class ProcessMonitor(context: Context,
23 | prefs: EnabledInfoPrefs) {
24 | private val mContext: Context = context.applicationContext
25 | private val mEnabledInfoPrefs: EnabledInfoPrefs = prefs
26 | private var mTask: InnerTask? = null
27 |
28 | fun start(callback: UpdateCallback) {
29 | mTask = InnerTask(mContext, mEnabledInfoPrefs, callback)
30 | mTask!!.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
31 | }
32 |
33 | fun stop() {
34 | if (mTask != null) {
35 | mTask!!.cancel(true)
36 | mTask = null
37 | }
38 | }
39 |
40 | interface UpdateCallback {
41 | fun onUpdate(update: Update)
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/data/access/generalinfo/monitortask/Update.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.data.access.generalinfo.monitortask
17 |
18 | import uk.co.alt236.floatinginfo.common.data.model.CpuData
19 | import uk.co.alt236.floatinginfo.common.data.model.ForegroundAppData
20 | import uk.co.alt236.floatinginfo.common.data.model.LocaleData
21 | import uk.co.alt236.floatinginfo.common.data.model.MemoryData
22 | import uk.co.alt236.floatinginfo.common.data.model.bt.BluetoothData
23 | import uk.co.alt236.floatinginfo.common.data.model.net.NetData
24 |
25 | data class Update(val foregroundAppData: ForegroundAppData,
26 | val netData: NetData?,
27 | val memoryData: MemoryData?,
28 | val cpuData: CpuData?,
29 | val generalData: LocaleData?,
30 | val bluetoothData: BluetoothData?)
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/notifications/NotificationChannelFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.notifications;
18 |
19 | import android.app.NotificationChannel;
20 | import android.app.NotificationManager;
21 | import android.content.Context;
22 |
23 | import androidx.annotation.NonNull;
24 | import uk.co.alt236.floatinginfo.R;
25 |
26 | /*package*/ class NotificationChannelFactory {
27 | private static final String CHANNEL_ID = "floating_info_control";
28 |
29 | @NonNull
30 | public NotificationChannelWrapper create(final Context context) {
31 | final NotificationChannel channel = createChannel(context, CHANNEL_ID);
32 | return new NotificationChannelWrapper(channel, CHANNEL_ID);
33 | }
34 |
35 | private NotificationChannel createChannel(final Context context,
36 | final String id) {
37 | final String channelName = context.getString(R.string.notification_channel_name);
38 | final String description = context.getString(R.string.notification_channel_description);
39 |
40 | final NotificationChannel channel;
41 | if (isAtLeastOreo()) {
42 | final int importance = NotificationManager.IMPORTANCE_LOW;
43 | channel = new NotificationChannel(id, channelName, importance);
44 | channel.setName(channelName);
45 | channel.setDescription(description);
46 | channel.setImportance(importance);
47 | channel.setSound(null, null);
48 | channel.enableVibration(false);
49 | } else {
50 | channel = null;
51 | }
52 |
53 | return channel;
54 | }
55 |
56 | private static boolean isAtLeastOreo() {
57 | return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O;
58 | }
59 |
60 | public static class NotificationChannelWrapper {
61 | private final NotificationChannel mChannel;
62 | private final String mChannelName;
63 |
64 | public NotificationChannelWrapper(final NotificationChannel mChannel, final String mChannelName) {
65 | this.mChannel = mChannel;
66 | this.mChannelName = mChannelName;
67 | }
68 |
69 | public NotificationChannel getChannel() {
70 | return mChannel;
71 | }
72 |
73 | public String getChannelName() {
74 | return mChannelName;
75 | }
76 |
77 | public boolean hasChannel() {
78 | return mChannel != null;
79 | }
80 |
81 | public void register(final NotificationManager manager) {
82 | if (isAtLeastOreo()) {
83 | manager.createNotificationChannel(mChannel);
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/permissions/AndroidPermissionChecker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.permissions;
18 |
19 | import android.content.Context;
20 | import android.content.pm.PackageInfo;
21 | import android.content.pm.PackageManager;
22 |
23 | import androidx.annotation.NonNull;
24 | import androidx.core.app.ActivityCompat;
25 |
26 | public class AndroidPermissionChecker implements PermissionChecker {
27 |
28 | private final Context mContext;
29 |
30 | public AndroidPermissionChecker(final Context context) {
31 | mContext = context.getApplicationContext();
32 | }
33 |
34 | private boolean hasAllPermissions(@NonNull String[] permissions) {
35 | boolean hasAllPermissions = true;
36 | for (String perm : permissions) {
37 | hasAllPermissions &= ActivityCompat.checkSelfPermission(mContext, perm)
38 | == PackageManager.PERMISSION_GRANTED;
39 | }
40 | return hasAllPermissions;
41 | }
42 |
43 | @NonNull
44 | public String[] getRequiredPermissions() {
45 | final String packageName = mContext.getPackageName();
46 | final PackageManager packageManager = mContext.getPackageManager();
47 |
48 | try {
49 | final String[] permissions;
50 |
51 | final PackageInfo info = packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS);
52 | if (info.requestedPermissions != null) {
53 | permissions = info.requestedPermissions;
54 | } else {
55 | permissions = new String[0];
56 | }
57 |
58 | return permissions;
59 | } catch (PackageManager.NameNotFoundException e) {
60 | throw new IllegalStateException(e.getMessage(), e);
61 | }
62 | }
63 |
64 | @Override
65 | public boolean isNeeded() {
66 | final String[] permissions = getRequiredPermissions();
67 | return hasAllPermissions(permissions);
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/permissions/OverlayPermissionChecker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.permissions;
18 |
19 | import android.content.Context;
20 | import android.os.Build;
21 | import android.provider.Settings;
22 |
23 | public class OverlayPermissionChecker implements PermissionChecker {
24 | private final Context mContext;
25 |
26 | public OverlayPermissionChecker(final Context context) {
27 | mContext = context.getApplicationContext();
28 | }
29 |
30 | @Override
31 | public boolean isNeeded() {
32 | final boolean retVal;
33 |
34 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
35 | retVal = !Settings.canDrawOverlays(mContext);
36 | } else {
37 | retVal = false;
38 | }
39 |
40 | return retVal;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/permissions/PermissionChecker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.permissions;
18 |
19 | public interface PermissionChecker {
20 | boolean isNeeded();
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/permissions/PermissionCheckerWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.permissions;
18 |
19 | import android.app.Activity;
20 |
21 | import java.util.Arrays;
22 | import java.util.List;
23 |
24 | public class PermissionCheckerWrapper {
25 |
26 | private final List mPermisionLogicList;
27 |
28 | public PermissionCheckerWrapper(final Activity activity) {
29 | mPermisionLogicList = Arrays.asList(
30 | new AndroidPermissionChecker(activity),
31 | new OverlayPermissionChecker(activity),
32 | new UsageStatsPermissionChecker(activity)
33 | );
34 | }
35 |
36 | public boolean needToAsk() {
37 | boolean retVal = false;
38 |
39 | for (final PermissionChecker logic : mPermisionLogicList) {
40 | if (logic.isNeeded()) {
41 | retVal = true;
42 | break;
43 | }
44 | }
45 |
46 | return retVal;
47 | }
48 |
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/permissions/UsageStatsPermissionChecker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.permissions;
18 |
19 | import android.app.usage.UsageStats;
20 | import android.app.usage.UsageStatsManager;
21 | import android.content.Context;
22 | import android.os.Build;
23 |
24 | import java.util.List;
25 |
26 | public class UsageStatsPermissionChecker implements PermissionChecker {
27 | private final Context mContext;
28 |
29 | public UsageStatsPermissionChecker(final Context context) {
30 | mContext = context.getApplicationContext();
31 | }
32 |
33 | @SuppressWarnings("WrongConstant")
34 | @Override
35 | public boolean isNeeded() {
36 | final boolean retVal;
37 |
38 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
39 | final UsageStatsManager usageStatsManager = (UsageStatsManager) mContext.getSystemService("usagestats");
40 | final List queryUsageStats = usageStatsManager.queryUsageStats(
41 | UsageStatsManager.INTERVAL_DAILY,
42 | 0,
43 | System.currentTimeMillis());
44 |
45 | retVal = queryUsageStats == null || queryUsageStats.isEmpty();
46 | } else {
47 | retVal = false;
48 | }
49 |
50 | return retVal;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/service/FloatingInfoService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.service;
17 |
18 | import android.app.Service;
19 | import android.content.Intent;
20 | import android.os.IBinder;
21 |
22 | import uk.co.alt236.floatinginfo.data.access.BaseProvider;
23 | import uk.co.alt236.floatinginfo.data.access.generalinfo.GeneralInfoProvider;
24 |
25 | public class FloatingInfoService extends Service {
26 |
27 | private static boolean sIsRunning = false;
28 | private BaseProvider mMonitor;
29 | private ScreenStateListener mScreenStateListener;
30 |
31 | @Override
32 | public IBinder onBind(final Intent intent) {
33 | throw new UnsupportedOperationException("Not implemented");
34 | }
35 |
36 | @Override
37 | public void onCreate() {
38 | super.onCreate();
39 | mMonitor = new GeneralInfoProvider(this);
40 |
41 | final ScreenStateListener.OnScreenStateListener listener = new ScreenStateListener.OnScreenStateListener() {
42 | @Override
43 | public void onScreenOn() {
44 | startMonitor();
45 | }
46 |
47 | @Override
48 | public void onScreenOff() {
49 | stopMonitor();
50 | }
51 | };
52 |
53 | mScreenStateListener = new ScreenStateListener(this, listener);
54 | mScreenStateListener.register();
55 | }
56 |
57 | @Override
58 | public void onDestroy() {
59 | super.onDestroy();
60 | mScreenStateListener.unregister();
61 | stopMonitor();
62 | sIsRunning = false;
63 | }
64 |
65 | @Override
66 | public int onStartCommand(final Intent intent, final int flags, final int startId) {
67 | sIsRunning = true;
68 | startMonitor();
69 | return Service.START_STICKY;
70 | }
71 |
72 | private void startMonitor() {
73 | mMonitor.start();
74 | }
75 |
76 | private void stopMonitor() {
77 | mMonitor.stop();
78 | }
79 |
80 | public static boolean isRunning() {
81 | return sIsRunning;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/service/ScreenStateListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.service;
18 |
19 | import android.content.BroadcastReceiver;
20 | import android.content.Context;
21 | import android.content.Intent;
22 | import android.content.IntentFilter;
23 | import android.util.Log;
24 |
25 | /*package*/ class ScreenStateListener {
26 |
27 | private final Context mContext;
28 | private final IntentFilter mFilter;
29 | private final BroadcastReceiver mReceiver;
30 |
31 | public ScreenStateListener(final Context context,
32 | final OnScreenStateListener listener) {
33 | mContext = context;
34 |
35 | mFilter = new IntentFilter();
36 | mFilter.addAction(Intent.ACTION_SCREEN_ON);
37 | mFilter.addAction(Intent.ACTION_SCREEN_OFF);
38 |
39 | mReceiver = new ScreenReceiver(listener);
40 | }
41 |
42 | public void register() {
43 | mContext.registerReceiver(mReceiver, mFilter);
44 | }
45 |
46 | public void unregister() {
47 | mContext.unregisterReceiver(mReceiver);
48 | }
49 |
50 | public interface OnScreenStateListener {
51 | void onScreenOn();
52 |
53 | void onScreenOff();
54 | }
55 |
56 | private static class ScreenReceiver extends BroadcastReceiver {
57 | private final OnScreenStateListener mListener;
58 |
59 | public ScreenReceiver(final OnScreenStateListener listener) {
60 | mListener = listener;
61 | }
62 |
63 | @Override
64 | public void onReceive(Context context, Intent intent) {
65 | Log.d(ScreenStateListener.class.getSimpleName(), "Screen state changed: " + intent);
66 | if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {
67 | mListener.onScreenOff();
68 | } else if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {
69 | mListener.onScreenOn();
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/base/ValidFragments.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.base;
18 |
19 | import java.util.HashSet;
20 | import java.util.Set;
21 |
22 | import uk.co.alt236.floatinginfo.ui.activity.main.AppearancePreferenceFragment;
23 | import uk.co.alt236.floatinginfo.ui.activity.main.EnabledInfoPreferenceFragment;
24 | import uk.co.alt236.floatinginfo.ui.activity.main.InfoPreferenceFragment;
25 |
26 | /*package*/ class ValidFragments {
27 | private final Set validClasses;
28 |
29 | public ValidFragments() {
30 | validClasses = new HashSet<>();
31 | validClasses.add(AppearancePreferenceFragment.class.getName());
32 | validClasses.add(EnabledInfoPreferenceFragment.class.getName());
33 | validClasses.add(InfoPreferenceFragment.class.getName());
34 | }
35 |
36 | public boolean isValidFragment(final String name) {
37 | return validClasses.contains(name);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/main/AppearancePreferenceFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.main;
18 |
19 | import android.os.Bundle;
20 | import android.preference.PreferenceFragment;
21 |
22 | import uk.co.alt236.floatinginfo.R;
23 |
24 | /**
25 | *
26 | */
27 | public class AppearancePreferenceFragment extends PreferenceFragment {
28 | @Override
29 | public void onCreate(final Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | // Load the preferences from an XML resource
32 | addPreferencesFromResource(R.xml.pref_appearance);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/main/EnabledInfoPreferenceFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.main;
18 |
19 | import android.os.Bundle;
20 | import android.preference.PreferenceFragment;
21 |
22 | import uk.co.alt236.floatinginfo.R;
23 |
24 | /**
25 | *
26 | */
27 | public class EnabledInfoPreferenceFragment extends PreferenceFragment {
28 | @Override
29 | public void onCreate(final Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | // Load the preferences from an XML resource
32 | addPreferencesFromResource(R.xml.pref_enabled_info);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/main/InfoPreferenceFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.main;
18 |
19 | import android.os.Bundle;
20 | import android.preference.PreferenceFragment;
21 |
22 | import uk.co.alt236.floatinginfo.R;
23 |
24 | /**
25 | *
26 | */
27 | public class InfoPreferenceFragment extends PreferenceFragment {
28 | @Override
29 | public void onCreate(final Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | // Load the preferences from an XML resource
32 | addPreferencesFromResource(R.xml.pref_info);
33 | PrefsUtils.setupOpenSourceInfoPreference(getActivity(), findPreference(getString(R.string.pref_key_info_open_source)));
34 | PrefsUtils.setupVersionPref(getActivity(), findPreference(getString(R.string.pref_key_version)));
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/main/PrefsUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.main;
18 |
19 | import android.app.Activity;
20 | import android.app.DialogFragment;
21 | import android.app.Fragment;
22 | import android.app.FragmentManager;
23 | import android.app.FragmentTransaction;
24 | import android.preference.Preference;
25 |
26 | import uk.co.alt236.floatinginfo.ui.activity.main.dialogs.AboutDialog;
27 | import uk.co.alt236.floatinginfo.ui.activity.main.dialogs.OpenSourceLicensesDialog;
28 |
29 | /*package*/ final class PrefsUtils {
30 |
31 | private static final String DIALOG_TAG = "dialog";
32 |
33 | private PrefsUtils() {
34 | // NOOP
35 | }
36 |
37 | public static void setupOpenSourceInfoPreference(final Activity activity, final Preference preference) {
38 | preference.setOnPreferenceClickListener(preference1 -> {
39 | replace(activity.getFragmentManager(), new OpenSourceLicensesDialog());
40 | return true;
41 | });
42 | }
43 |
44 | public static void setupVersionPref(final Activity activity, final Preference preference) {
45 | preference.setOnPreferenceClickListener(preference1 -> {
46 | replace(activity.getFragmentManager(), new AboutDialog());
47 | return true;
48 | });
49 | }
50 |
51 |
52 | private static void replace(final FragmentManager fm, final DialogFragment dialog) {
53 | final FragmentTransaction ft = fm.beginTransaction();
54 | final Fragment prev = fm.findFragmentByTag(DIALOG_TAG);
55 | if (prev != null) {
56 | ft.remove(prev);
57 | }
58 | ft.addToBackStack(null);
59 | dialog.show(ft, DIALOG_TAG);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/main/dialogs/AboutDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.main.dialogs;
18 |
19 | import android.app.AlertDialog;
20 | import android.app.Dialog;
21 | import android.app.DialogFragment;
22 | import android.content.Context;
23 | import android.os.Bundle;
24 | import android.view.LayoutInflater;
25 | import android.view.View;
26 | import android.widget.TextView;
27 |
28 | import uk.co.alt236.floatinginfo.BuildConfig;
29 | import uk.co.alt236.floatinginfo.R;
30 |
31 | public class AboutDialog extends DialogFragment {
32 |
33 | public AboutDialog() {
34 | }
35 |
36 | @Override
37 | public Dialog onCreateDialog(final Bundle savedInstanceState) {
38 | final LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
39 |
40 | final View content = inflater.inflate(R.layout.dialog_about, null, false);
41 | final TextView version = content.findViewById(R.id.version);
42 |
43 | final String name = BuildConfig.VERSION_NAME;
44 | version.setText(getString(R.string.version) + " " + name);
45 |
46 | return new AlertDialog.Builder(getActivity())
47 | .setTitle(R.string.app_name)
48 | .setView(content)
49 | .setPositiveButton(R.string.ok, (dialog, whichButton) -> dialog.dismiss())
50 | .create();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/main/dialogs/OpenSourceLicensesDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.main.dialogs;
18 |
19 | import android.app.AlertDialog;
20 | import android.app.Dialog;
21 | import android.app.DialogFragment;
22 | import android.os.Bundle;
23 | import android.webkit.WebView;
24 |
25 | import uk.co.alt236.floatinginfo.R;
26 |
27 | public class OpenSourceLicensesDialog extends DialogFragment {
28 |
29 | public static final String LICENSES_FILE = "file:///android_asset/licenses.html";
30 |
31 | public OpenSourceLicensesDialog() {
32 | }
33 |
34 | @Override
35 | public Dialog onCreateDialog(final Bundle savedInstanceState) {
36 | final WebView webView = new WebView(getActivity());
37 | webView.loadUrl(LICENSES_FILE);
38 |
39 | return new AlertDialog.Builder(getActivity())
40 | .setTitle(R.string.open_source_licences)
41 | .setView(webView)
42 | .setPositiveButton(R.string.ok, (dialog, whichButton) -> dialog.dismiss())
43 | .create();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/onboarding/OnBoardingActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.onboarding;
18 |
19 | import android.os.Bundle;
20 | import android.util.Log;
21 |
22 | import java.util.List;
23 |
24 | import androidx.annotation.Nullable;
25 | import io.github.dreierf.materialintroscreen.MaterialIntroActivity;
26 | import io.github.dreierf.materialintroscreen.SlideFragment;
27 | import uk.co.alt236.floatinginfo.ui.activity.onboarding.pagefactory.PageFactory;
28 |
29 | public class OnBoardingActivity extends MaterialIntroActivity {
30 | private static final String TAG = OnBoardingActivity.class.getSimpleName();
31 |
32 | @Override
33 | protected void onCreate(@Nullable Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 |
36 | final List pages = new PageFactory(this).getPages();
37 | Log.d(TAG, "Number of pages: " + pages.size());
38 |
39 | if (pages.isEmpty()) {
40 | finish();
41 | } else {
42 | for (final SlideFragment page : pages) {
43 | addSlide(page);
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/onboarding/pagefactory/OverlayPermsissionPage.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.ui.activity.onboarding.pagefactory;
18 |
19 | import android.content.Context;
20 | import android.content.Intent;
21 | import android.net.Uri;
22 | import android.os.Build;
23 | import android.os.Bundle;
24 | import android.provider.Settings;
25 | import android.view.LayoutInflater;
26 | import android.view.View;
27 | import android.view.ViewGroup;
28 | import android.widget.Button;
29 | import android.widget.TextView;
30 |
31 | import androidx.annotation.NonNull;
32 | import androidx.annotation.Nullable;
33 | import io.github.dreierf.materialintroscreen.SlideFragment;
34 | import uk.co.alt236.floatinginfo.BuildConfig;
35 | import uk.co.alt236.floatinginfo.R;
36 | import uk.co.alt236.floatinginfo.permissions.OverlayPermissionChecker;
37 | import uk.co.alt236.floatinginfo.permissions.PermissionChecker;
38 |
39 | public class OverlayPermsissionPage extends SlideFragment {
40 |
41 | private PermissionChecker mLogic;
42 |
43 | public void onAttach(@NonNull Context context) {
44 | super.onAttach(context);
45 | mLogic = new OverlayPermissionChecker(context);
46 | }
47 |
48 | @Nullable
49 | @Override
50 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
51 | final View view = inflater.inflate(R.layout.fragment_onboard_slide, container, false);
52 | final TextView title = view.findViewById(R.id.txt_title_slide);
53 | final TextView text = view.findViewById(R.id.txt_description_slide);
54 | final Button button = view.findViewById(R.id.button);
55 |
56 | title.setText(R.string.slide_overlay_title);
57 | text.setText(R.string.slide_overlay_description);
58 |
59 | button.setText(R.string.button_click_to_grant);
60 | button.setOnClickListener(v -> ask());
61 |
62 | return view;
63 | }
64 |
65 | @Override
66 | public int backgroundColor() {
67 | return R.color.colorPrimary;
68 | }
69 |
70 | @Override
71 | public int buttonsColor() {
72 | return R.color.colorAccent;
73 | }
74 |
75 | @Override
76 | public boolean canMoveFurther() {
77 | return !mLogic.isNeeded();
78 | }
79 |
80 | @Override
81 | public String cantMoveFurtherErrorMessage() {
82 | return getString(R.string.message_access_needed);
83 | }
84 |
85 | private void ask() {
86 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
87 | /** check if we already have permission to draw over other apps */
88 | if (mLogic.isNeeded()) {
89 | /** if not construct intent to request permission */
90 | final Intent intent = new Intent(
91 | Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
92 | Uri.parse("package:" + BuildConfig.APPLICATION_ID));
93 | /** request permission via start activity for result */
94 | getActivity().startActivityForResult(intent, 1337);
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/ui/activity/share/ShareActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.ui.activity.share
17 |
18 | import android.app.Activity
19 | import android.content.Intent
20 | import android.os.Bundle
21 | import uk.co.alt236.floatinginfo.data.access.generalinfo.GeneralInfoReceiver
22 |
23 | class ShareActivity : Activity() {
24 | // this activity exists so we can launch the share chooser
25 | // from a notification action - see LogService.onLogShare()
26 | override fun onCreate(savedInstanceState: Bundle) {
27 | super.onCreate(savedInstanceState)
28 | // simply post the share event and finish
29 | val intent = Intent(GeneralInfoReceiver.ACTION_SHARE)
30 | sendBroadcast(intent)
31 | finish()
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/app/src/main/java/uk/co/alt236/floatinginfo/util/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.util;
17 |
18 | public class Constants {
19 | public static final int PROC_MONITOR_SLEEP = 1000;
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_stat_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-hdpi/ic_stat_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_stat_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-hdpi/ic_stat_main.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_stat_pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-hdpi/ic_stat_pause.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_stat_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-hdpi/ic_stat_play.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_stat_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-hdpi/ic_stat_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_stat_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-mdpi/ic_stat_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_stat_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-mdpi/ic_stat_main.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_stat_pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-mdpi/ic_stat_pause.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_stat_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-mdpi/ic_stat_play.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_stat_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-mdpi/ic_stat_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_stat_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xhdpi/ic_stat_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_stat_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xhdpi/ic_stat_main.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_stat_pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xhdpi/ic_stat_pause.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_stat_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xhdpi/ic_stat_play.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_stat_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xhdpi/ic_stat_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_stat_clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xxhdpi/ic_stat_clear.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_stat_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xxhdpi/ic_stat_main.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_stat_pause.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xxhdpi/ic_stat_pause.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_stat_play.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xxhdpi/ic_stat_play.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_stat_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xxhdpi/ic_stat_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_stat_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/drawable-xxxhdpi/ic_stat_main.png
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/fragment_onboard_slide.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
28 |
29 |
35 |
36 |
44 |
45 |
53 |
54 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
16 |
17 |
24 |
25 |
31 |
32 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_onboard_slide.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
31 |
32 |
40 |
41 |
50 |
51 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
14 |
15 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #259b24
4 | #0a7e07
5 | #5af158
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 | 16dp
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/values/stylesBase.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_appearance.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
11 |
12 |
17 |
18 |
23 |
24 |
29 |
30 |
35 |
36 |
41 |
42 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_blank.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_enabled_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
13 |
18 |
19 |
23 |
24 |
28 |
29 |
33 |
34 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_headers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/assets/Floating Info-feature-graphic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/assets/Floating Info-feature-graphic.png
--------------------------------------------------------------------------------
/assets/icons/duck-attribution.txt:
--------------------------------------------------------------------------------
1 | Large duck: http://www.clker.com/clipart-duck-silhouette.html
2 |
--------------------------------------------------------------------------------
/assets/icons/duck-silhouette.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/assets/icons/web_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/assets/icons/web_icon.png
--------------------------------------------------------------------------------
/assets/screenshots/image1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/assets/screenshots/image1.png
--------------------------------------------------------------------------------
/assets/screenshots/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/assets/screenshots/image2.png
--------------------------------------------------------------------------------
/assets/screenshots/image3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/assets/screenshots/image3.png
--------------------------------------------------------------------------------
/assets/screenshots/image4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/assets/screenshots/image4.png
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | apply from: "${project.rootDir}/buildconstants/android-sdk-versions.gradle"
4 | apply from: "${project.rootDir}/buildconstants/dependency-versions.gradle"
5 |
6 | repositories {
7 | google()
8 | jcenter()
9 | }
10 |
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:4.0.0'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | mavenCentral()
21 | jcenter()
22 | }
23 |
24 | tasks.withType(Test) {
25 | testLogging {
26 | exceptionFormat "full"
27 | showCauses true
28 | showExceptions true
29 | showStackTraces true
30 | showStandardStreams true
31 | events = ["passed", "skipped", "failed"]
32 |
33 | // This line is left here to make test debugging easier
34 | // events = ["passed", "skipped", "failed", "standardError", "standardOut"]
35 | }
36 | }
37 |
38 | apply from: "${project.rootDir}/buildconstants/android-sdk-versions.gradle"
39 | apply from: "${project.rootDir}/buildconstants/dependency-versions.gradle"
40 | apply from: "${project.rootDir}/buildsystem/common-methods.gradle"
41 | }
--------------------------------------------------------------------------------
/buildconstants/android-sdk-versions.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | min_sdk_version = 17
3 | target_sdk_version = 28
4 | compile_sdk_version = 28
5 | build_tools_version = "29.0.2"
6 | kotlin_version = '1.3.72'
7 | }
--------------------------------------------------------------------------------
/buildconstants/dependency-versions.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | // androidx libraries
3 | androidx_appcompat_version = "1.1.0"
4 | androidx_annotation_version = "1.1.0"
5 | androidx_core_version = "1.3.0"
6 | andoridx_test_runner_version = "1.2.0"
7 |
8 | // testing
9 | mockito_version = "3.3.3"
10 | junit_version = "4.13"
11 |
12 | // code quality
13 | jacoco_version = "0.8.5"
14 |
15 | // Other
16 | dexter_version = "6.1.2"
17 | material_intro_screen_version = "0.0.6"
18 | libsuperuser_version = "1.0.0.201704021214"
19 | }
20 |
--------------------------------------------------------------------------------
/buildsystem/apkdetails/apkdetails-1.2.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/buildsystem/apkdetails/apkdetails-1.2.2.jar
--------------------------------------------------------------------------------
/buildsystem/codequality/lint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/buildsystem/common-methods.gradle:
--------------------------------------------------------------------------------
1 | def execGitHashShort() {
2 | return cleanString('git rev-parse --short HEAD'.execute().text)
3 | }
4 |
5 | def execGitHash() {
6 | return cleanString('git rev-parse HEAD'.execute().text)
7 | }
8 |
9 | def execGitBranch() {
10 | return cleanString('git show -s --pretty=%d HEAD'.execute().text)
11 | }
12 |
13 | def execGitCommitDate() {
14 | final String cmd = "git show -s --format=%ci " + this.execGitHash()
15 | return cleanString(cmd.execute().text)
16 | }
17 |
18 | def execGitLog(int items) {
19 | final String cmd = "git log -n " + items + " --abbrev-commit --pretty=oneline"
20 | return cmd.execute().text
21 | }
22 |
23 | def getBuildNumber() {
24 | def buildNumberVariable = "CIRCLE_BUILD_NUM"
25 | def buildNumberValue = System.getenv(buildNumberVariable)
26 |
27 | if (buildNumberValue != null && !buildNumberValue.isEmpty()) {
28 | return buildNumberValue as Integer
29 | } else {
30 | return 1
31 | }
32 | }
33 |
34 | def isRunningOnCi() {
35 | def envVariable = "CI"
36 | return Boolean.parseBoolean(System.getenv(envVariable) ?: "false")
37 | }
38 |
39 | def cleanString(final String text) {
40 | return text.trim().replaceAll('/', '_').replaceAll('-', '_')
41 | }
42 |
43 | def quoteString(final String str) {
44 | final String quote = "\""
45 |
46 | if (str.length() > 0) {
47 | if (str.startsWith(quote) && str.endsWith(quote)) {
48 | return str
49 | } else {
50 | return quote + str + quote
51 | }
52 | } else {
53 | return quote + quote
54 | }
55 | }
56 |
57 |
58 | def getLastGitCommitMessage() {
59 | return 'git log -1 --pretty=%B'.execute().text.trim()
60 | }
61 |
62 | def collectCommonProguardRules() {
63 | def proguardFileDirectory = "${project.rootDir}/buildsystem/proguard-rules/"
64 |
65 | def proguardFileSet = fileTree(proguardFileDirectory).filter { it.isFile() }.files
66 | if (proguardFileSet.isEmpty()) {
67 | throw new IllegalStateException("No proguard rules found in $proguardFileDirectory")
68 | }
69 |
70 | return proguardFileSet.toList().sort()
71 | }
72 |
73 |
74 | def getPropertySafe(prop, fallback) {
75 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
76 | }
77 |
78 | ext {
79 | execGitHashShort = this.&execGitHashShort
80 | execGitHash = this.&execGitHash
81 | execGitBranch = this.&execGitBranch
82 | execGitCommitDate = this.&execGitCommitDate
83 | execGitLog = this.&execGitLog
84 | isRunningOnCi = this.&isRunningOnCi
85 | getLibVersions = this.&getLibVersions
86 | quoteString = this."eString
87 | getBuildNumber = this.&getBuildNumber
88 | getLastGitCommitMessage = this.&getLastGitCommitMessage
89 | shouldSkipFlakyRobolectricTests = this.&shouldSkipFlakyRobolectricTests
90 | collectCommonProguardRules = this.&collectCommonProguardRules
91 | getPropertySafe = this.&getPropertySafe
92 | }
--------------------------------------------------------------------------------
/buildsystem/generate_dependency_hashfile.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # This script scans the directory passed as the first parameter and hashes all gradlefiles it finds/
5 | # It then outputs the hashes into the file passed as the second parameter
6 | #
7 |
8 | SOURCE_DIR=$1
9 | HASH_FILE=$2
10 | REGEX_PATTERN_GRADLE="*\.gradle"
11 | REGEX_PATTERN_ROBOLECTRIC="*robolectric.properties"
12 |
13 | find ${SOURCE_DIR} -type f \( -iname "$REGEX_PATTERN_GRADLE" -o -iname "$REGEX_PATTERN_ROBOLECTRIC" \) -exec md5sum {} \; | sort -k2 -b > ${HASH_FILE}
14 |
15 |
--------------------------------------------------------------------------------
/buildsystem/jacocoxml/jacocoxmlparser-1.0.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/buildsystem/jacocoxml/jacocoxmlparser-1.0.0.jar
--------------------------------------------------------------------------------
/buildsystem/multidex/multidex.pro:
--------------------------------------------------------------------------------
1 | -keep class **Test { *; }
2 | -keep class **Module { *; }
--------------------------------------------------------------------------------
/buildsystem/proguard-rules/dagger2-rules.pro:
--------------------------------------------------------------------------------
1 | -dontwarn com.google.errorprone.annotations.**
--------------------------------------------------------------------------------
/buildsystem/proguard-rules/gson-rules.pro:
--------------------------------------------------------------------------------
1 | # Source: https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg
2 |
3 | ##---------------Begin: proguard configuration for Gson ----------
4 | # Gson uses generic type information stored in a class file when working with fields. Proguard
5 | # removes such information by default, so configure it to keep all of it.
6 | -keepattributes Signature
7 |
8 | # For using GSON @Expose annotation
9 | -keepattributes *Annotation*
10 |
11 | # Gson specific classes
12 | -dontwarn sun.misc.**
13 | #-keep class com.google.gson.stream.** { *; }
14 |
15 | # Application classes that will be serialized/deserialized over Gson
16 | -keep class com.google.gson.examples.android.model.** { *; }
17 |
18 | # Prevent proguard from stripping interface information from TypeAdapterFactory,
19 | # JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
20 | -keep class * implements com.google.gson.TypeAdapterFactory
21 | -keep class * implements com.google.gson.JsonSerializer
22 | -keep class * implements com.google.gson.JsonDeserializer
23 |
24 | ##---------------End: proguard configuration for Gson ----------
--------------------------------------------------------------------------------
/buildsystem/proguard-rules/kotlin-rules.pro:
--------------------------------------------------------------------------------
1 | -keep class kotlin.reflect.jvm.internal.** { *; }
2 | -keep class kotlin.Metadata { *; }
--------------------------------------------------------------------------------
/buildsystem/signing_keys/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/buildsystem/signing_keys/debug.keystore
--------------------------------------------------------------------------------
/common/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/common/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | id 'kotlin-android-extensions'
5 | }
6 |
7 | apply from: "${project.rootDir}/buildsystem/android-defaults.gradle"
8 |
9 | android {
10 | final int buildNumber = getBuildNumber()
11 | final int versionMajor = 1
12 | final int versionMinor = 0
13 | final int versionPatch = buildNumber
14 | final int androidVersionCode = buildNumber
15 |
16 | final String semanticVersion = "${versionMajor}.${versionMinor}.${versionPatch}"
17 |
18 | defaultConfig {
19 | versionCode androidVersionCode
20 | versionName semanticVersion
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | }
27 | }
28 |
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 | }
34 |
35 | dependencies {
36 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
37 | implementation "androidx.core:core:$androidx_core_version"
38 | implementation "androidx.core:core-ktx:$androidx_core_version"
39 | implementation "androidx.annotation:annotation:$androidx_annotation_version"
40 |
41 | testImplementation "junit:junit:$junit_version"
42 | testImplementation "org.mockito:mockito-core:$mockito_version"
43 |
44 | androidTestImplementation "androidx.test:core:$andoridx_test_runner_version"
45 | androidTestImplementation "androidx.test:runner:$andoridx_test_runner_version"
46 | }
47 | repositories {
48 | mavenCentral()
49 | }
--------------------------------------------------------------------------------
/common/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/common/consumer-rules.pro
--------------------------------------------------------------------------------
/common/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/common/src/androidTest/java/uk/co/alt236/floatinginfo/common/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.common;
18 |
19 | import android.content.Context;
20 |
21 | import org.junit.Test;
22 | import org.junit.runner.RunWith;
23 |
24 | import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
25 | import androidx.test.platform.app.InstrumentationRegistry;
26 |
27 | import static org.junit.Assert.assertEquals;
28 |
29 | /**
30 | * Instrumented test, which will execute on an Android device.
31 | *
32 | * @see Testing documentation
33 | */
34 | @RunWith(AndroidJUnit4ClassRunner.class)
35 | public class ExampleInstrumentedTest {
36 | @Test
37 | public void useAppContext() {
38 | // Context of the app under test.
39 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
40 |
41 | assertEquals("uk.co.alt236.floatinginfo.common.test", appContext.getPackageName());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/common/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
19 |
20 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/InfoStore.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.data
17 |
18 | import uk.co.alt236.floatinginfo.common.data.model.CpuData
19 | import uk.co.alt236.floatinginfo.common.data.model.ForegroundAppData
20 | import uk.co.alt236.floatinginfo.common.data.model.LocaleData
21 | import uk.co.alt236.floatinginfo.common.data.model.MemoryData
22 | import uk.co.alt236.floatinginfo.common.data.model.bt.BluetoothData
23 | import uk.co.alt236.floatinginfo.common.data.model.net.NetData
24 | import java.util.*
25 |
26 | class InfoStore {
27 | private val mLock = Any()
28 | private val mStore: MutableMap = EnumMap(Key::class.java)
29 |
30 | val netData: NetData?
31 | get() = get(Key.NET_DATA) as NetData?
32 |
33 | val localeData: LocaleData?
34 | get() = get(Key.GENERAL) as LocaleData?
35 |
36 | val cpuInfo: CpuData?
37 | get() = get(Key.CPU_INFO) as CpuData?
38 |
39 | val foregroundProcessInfo: ForegroundAppData
40 | get() = get(Key.PROCESS_INFO) as ForegroundAppData
41 |
42 | val memoryInfo: MemoryData?
43 | get() = get(Key.MEMORY_INFO) as MemoryData?
44 |
45 | val bluetoothInfo: BluetoothData?
46 | get() = get(Key.BT_DATA) as BluetoothData?
47 |
48 | fun set(value: CpuData?) {
49 | put(Key.CPU_INFO, value)
50 | }
51 |
52 | fun set(value: BluetoothData?) {
53 | put(Key.BT_DATA, value)
54 | }
55 |
56 | fun set(value: LocaleData?) {
57 | put(Key.GENERAL, value)
58 | }
59 |
60 | fun set(value: ForegroundAppData?) {
61 | put(Key.PROCESS_INFO, value)
62 | }
63 |
64 | fun set(value: MemoryData?) {
65 | put(Key.MEMORY_INFO, value)
66 | }
67 |
68 | fun set(value: NetData?) {
69 | put(Key.NET_DATA, value)
70 | }
71 |
72 | private operator fun get(key: Key): Any? {
73 | synchronized(mLock) { return mStore[key] }
74 | }
75 |
76 | private fun put(key: Key, value: Any?) {
77 | synchronized(mLock) { mStore.put(key, value) }
78 | }
79 |
80 | private enum class Key {
81 | PROCESS_INFO, CPU_INFO, MEMORY_INFO, NET_DATA, GENERAL, BT_DATA
82 | }
83 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/CpuData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.data.model
17 |
18 | import java.util.*
19 |
20 | data class CpuData constructor(val statFile: String, val overallCpu: Int, private val perCpuUtilisation: List, val hasError: Boolean) {
21 |
22 | constructor(statFile: String, overallCpu: Int, perCpuUtilisation: List) : this(statFile, overallCpu, perCpuUtilisation, false)
23 | constructor(statFile: String, error: Boolean) : this(statFile, -1, emptyList(), error)
24 |
25 | fun getPerCpuUtilisation(): List {
26 | return Collections.unmodifiableList(perCpuUtilisation)
27 | }
28 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/ForegroundAppData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.data.model
17 |
18 | data class ForegroundAppData(
19 | val pid: Int,
20 | val packageName: String,
21 | val appName: CharSequence)
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/LocaleData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.data.model
17 |
18 | import java.util.*
19 |
20 | data class LocaleData(val defaultLocale: Locale, val contextLocales: List)
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/bt/BluetoothData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.common.data.model.bt
18 |
19 | data class BluetoothData(
20 | val address: String,
21 | val enabled: Boolean,
22 | val scanMode: ScanMode,
23 | val bondedDevices: List) {
24 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/bt/BondState.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.common.data.model.bt
18 |
19 | import android.bluetooth.BluetoothDevice
20 |
21 | enum class BondState(private val androidState: Int) {
22 | NONE(BluetoothDevice.BOND_NONE),
23 | BONDING(BluetoothDevice.BOND_BONDING),
24 | BONDED((BluetoothDevice.BOND_BONDED));
25 |
26 | companion object {
27 | fun fromAndroidState(androidState: Int): BondState {
28 | return values().find { it.androidState == androidState } ?: NONE
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/bt/LightBluetoothDevice.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.common.data.model.bt
18 |
19 | data class LightBluetoothDevice(val name: String, val address: String, val bondState: BondState) {
20 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/bt/ScanMode.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.common.data.model.bt
18 |
19 | import android.bluetooth.BluetoothAdapter
20 |
21 | enum class ScanMode(private val androidMode: Int) {
22 | NONE(BluetoothAdapter.SCAN_MODE_NONE),
23 | CONNECTABLE(BluetoothAdapter.SCAN_MODE_CONNECTABLE),
24 | CONNECTABLE_DISCOVERABLE(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
25 |
26 | companion object {
27 | fun fromAndroidState(androidMode: Int): ScanMode {
28 | return values().find { it.androidMode == androidMode } ?: NONE
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/net/Interface.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.data.model.net
17 |
18 | data class Interface(val name: String, val addresses: List)
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/net/IpAddress.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.data.model.net
17 |
18 | data class IpAddress(val version: Int, val address: String)
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/data/model/net/NetData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.data.model.net
17 |
18 | import android.net.NetworkInfo
19 | import android.net.wifi.WifiInfo
20 |
21 | /**
22 | *
23 | */
24 | data class NetData(val networkInfo: NetworkInfo?,
25 | val wifiInfo: WifiInfo?,
26 | val proxy: String,
27 | val interfaces: List)
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/prefs/Alignment.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.prefs
17 |
18 | enum class Alignment(private val key: String) {
19 | TOP_LEFT("TOP_LEFT"),
20 | TOP_CENTER("TOP_CENTER"),
21 | TOP_RIGHT("TOP_RIGHT"),
22 | CENTER_LEFT("CENTER_LEFT"),
23 | CENTER_CENTER("CENTER_CENTER"),
24 | CENTER_RIGHT("CENTER_RIGHT"),
25 | BOTTOM_LEFT("BOTTOM_LEFT"),
26 | BOTTOM_CENTER("BOTTOM_CENTER"),
27 | BOTTOM_RIGHT("BOTTOM_RIGHT");
28 |
29 | companion object {
30 | @JvmStatic
31 | fun fromString(value: String?): Alignment? {
32 | var retVal: Alignment? = null
33 | for (alignment in values()) {
34 | if (alignment.key.equals(value, ignoreCase = true)) {
35 | retVal = alignment
36 | break
37 | }
38 | }
39 | return retVal
40 | }
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/prefs/EnabledInfoPrefs.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.prefs
17 |
18 | import android.content.Context
19 | import android.content.SharedPreferences
20 | import android.content.res.Resources
21 | import android.preference.PreferenceManager
22 | import androidx.annotation.StringRes
23 | import uk.co.alt236.floatinginfo.common.R
24 |
25 | class EnabledInfoPrefs(context: Context) {
26 | private val prefs: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
27 | private val resources: Resources = context.resources
28 |
29 | val isNetInfoEnabled: Boolean
30 | get() {
31 | val defValue = resources.getBoolean(R.bool.default_enabled_info_value)
32 | return getBoolean(R.string.pref_key_show_net_info, defValue)
33 | }
34 |
35 | val isIpInfoEnabled: Boolean
36 | get() {
37 | val defValue = resources.getBoolean(R.bool.default_enabled_info_value)
38 | return getBoolean(R.string.pref_key_show_ip_info, defValue)
39 | }
40 |
41 | val isCpuInfoEnabled: Boolean
42 | get() {
43 | val defValue = resources.getBoolean(R.bool.default_enabled_info_value)
44 | return getBoolean(R.string.pref_key_show_cpu_info, defValue)
45 | }
46 |
47 | val isLocaleInfoEnabled: Boolean
48 | get() {
49 | val defValue = resources.getBoolean(R.bool.default_enabled_info_value)
50 | return getBoolean(R.string.pref_key_show_locale_info, defValue)
51 | }
52 |
53 | val isMemoryInfoEnabled: Boolean
54 | get() {
55 | val defValue = resources.getBoolean(R.bool.default_enabled_info_value)
56 | return getBoolean(R.string.pref_key_show_memory_info, defValue)
57 | }
58 |
59 | val isBluetoothInfoEnabled: Boolean
60 | get() {
61 | val defValue = resources.getBoolean(R.bool.default_enabled_info_value)
62 | return getBoolean(R.string.pref_key_show_bluetooth_info, defValue)
63 | }
64 |
65 | fun showZeroMemoryItems(): Boolean {
66 | val defValue = resources.getBoolean(R.bool.default_enabled_info_value)
67 | return getBoolean(R.string.pref_key_show_zero_memory_items, defValue)
68 | }
69 |
70 | private fun getBoolean(@StringRes resId: Int, defVal: Boolean): Boolean {
71 | val key = resources.getString(resId)
72 | return prefs.getBoolean(key, defVal)
73 | }
74 |
75 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/prefs/OverlayPrefs.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.prefs
17 |
18 | import android.content.Context
19 | import android.content.SharedPreferences
20 | import android.content.res.Resources
21 | import android.graphics.Color
22 | import android.preference.PreferenceManager
23 | import uk.co.alt236.floatinginfo.common.R
24 | import uk.co.alt236.floatinginfo.common.prefs.Alignment.Companion.fromString
25 |
26 | class OverlayPrefs(context: Context) {
27 | private val prefs: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
28 | private val resources: Resources = context.resources
29 |
30 | val textColor: Int
31 | get() {
32 | val alpha = prefs.getInt(
33 | resources.getString(R.string.pref_key_text_alpha),
34 | resources.getInteger(R.integer.default_text_alpha))
35 | val red = prefs.getInt(
36 | resources.getString(R.string.pref_key_text_color_red),
37 | resources.getInteger(R.integer.default_text_red))
38 | val green = prefs.getInt(
39 | resources.getString(R.string.pref_key_text_color_green),
40 | resources.getInteger(R.integer.default_text_green))
41 | val blue = prefs.getInt(
42 | resources.getString(R.string.pref_key_text_color_blue),
43 | resources.getInteger(R.integer.default_text_blue))
44 | return Color.argb(alpha, red, green, blue)
45 | }
46 |
47 | val backgroundColor: Int
48 | get() {
49 | val v = prefs.getInt(
50 | resources.getString(R.string.pref_key_bg_opacity),
51 | resources.getInteger(R.integer.background_opacity_default))
52 | val level = 0
53 | val retVal: Int
54 | retVal = if (v > 0) {
55 | val a = (v.toFloat() / 100f * 255).toInt()
56 | Color.argb(a, level, level, level)
57 | } else {
58 | 0
59 | }
60 | return retVal
61 | }
62 |
63 | val textSize: Float
64 | get() {
65 | val baseValue = resources.getDimension(R.dimen.text_size_base)
66 | val prefsValue = prefs.getInt(resources.getString(R.string.pref_key_text_size), 0).toFloat()
67 | return baseValue + prefsValue
68 | }
69 |
70 | val alignment: Alignment
71 | get() {
72 | val key = resources.getString(R.string.pref_key_screen_position)
73 | val value = prefs.getString(key, null)
74 | val alignment = fromString(value)
75 | return alignment ?: Alignment.TOP_LEFT
76 | }
77 |
78 | }
--------------------------------------------------------------------------------
/common/src/main/java/uk/co/alt236/floatinginfo/common/string/HumanReadable.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.common.string
17 |
18 | import java.util.*
19 |
20 | @Suppress("MemberVisibilityCanBePrivate")
21 | object HumanReadable {
22 |
23 | @JvmStatic
24 | fun getHumanReadableKiloByteCount(kbytes: Long, si: Boolean): String {
25 | return getHumanReadableByteCount(kbytes * 1024, si)
26 | }
27 |
28 | @JvmStatic
29 | fun getHumanReadableByteCount(bytes: Long, si: Boolean): String {
30 | val unit = if (si) 1000 else 1024
31 | if (bytes < unit) {
32 | return "$bytes B"
33 | }
34 | val exp = (Math.log(bytes.toDouble()) / Math.log(unit.toDouble())).toInt()
35 | val pre = (if (si) "kMGTPE" else "KMGTPE")[exp - 1].toString() + if (si) "" else "i"
36 | return String.format(Locale.US, "%.1f %sB", bytes / Math.pow(unit.toDouble(), exp.toDouble()), pre)
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/common/src/main/res/layout/screen_overlay.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
10 |
--------------------------------------------------------------------------------
/common/src/main/res/values/preference_keys.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | pref_key_screen_position
5 | pref_bg_opacity
6 | pref_info_open_source
7 | pref_text_color_blue
8 | pref_text_color_green
9 | pref_text_color_red
10 | pref_text_opacity
11 | pref_text_size
12 | pref_version
13 | pref_show_net_info
14 | pref_show_ip_info
15 | pref_show_cpu_info
16 | pref_key_show_locale_info
17 | pref_show_memory_info
18 | pref_key_show_bluetooth_info
19 | pref_key_show_zero_memory_items
20 |
21 |
--------------------------------------------------------------------------------
/common/src/main/res/values/values.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 8sp
4 | 2
5 | 20
6 |
7 | 35
8 | 75
9 |
10 | 128
11 | 250
12 | 250
13 | 250
14 |
15 | true
16 |
17 |
18 | TOP_LEFT
19 | TOP_CENTER
20 | TOP_RIGHT
21 | CENTER_LEFT
22 | CENTER_CENTER
23 | CENTER_RIGHT
24 | BOTTOM_LEFT
25 | BOTTOM_CENTER
26 | BOTTOM_RIGHT
27 |
28 |
--------------------------------------------------------------------------------
/common/src/test/java/uk/co/alt236/floatinginfo/common/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.common;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 |
23 | /**
24 | * Example local unit test, which will execute on the development machine (host).
25 | *
26 | * @see Testing documentation
27 | */
28 | public class ExampleUnitTest {
29 | @Test
30 | public void addition_isCorrect() {
31 | assertEquals(4, 2 + 2);
32 | }
33 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2020 Alexandros Schillings
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # http://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 | android.enableJetifier=true
17 | android.useAndroidX=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Nov 12 09:45:59 GMT 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/import-summary.txt:
--------------------------------------------------------------------------------
1 | ECLIPSE ANDROID PROJECT IMPORT SUMMARY
2 | ======================================
3 |
4 | Ignored Files:
5 | --------------
6 | The following files were *not* copied into the new Gradle project; you
7 | should evaluate whether these are still needed in your project and if
8 | so manually move them:
9 |
10 | * .gitignore
11 | * LICENSE-2.0.html
12 | * Readme.md
13 | * ic_launcher-web.png
14 | * proguard-project.txt
15 | * screenshots/
16 | * screenshots/screenshot_1.png
17 | * screenshots/screenshot_1_full.png
18 | * screenshots/screenshot_2.png
19 | * screenshots/screenshot_2_full.png
20 | * screenshots/screenshot_3.png
21 | * screenshots/screenshot_3_full.png
22 | * screenshots/screenshot_4.png
23 | * screenshots/screenshot_4_full.png
24 | * screenshots/screenshot_tablet_10inch_1_full.png
25 |
26 | Replaced Jars with Dependencies:
27 | --------------------------------
28 | The importer recognized the following .jar files as third party
29 | libraries and replaced them with Gradle dependencies instead. This has
30 | the advantage that more explicit version information is known, and the
31 | libraries can be updated automatically. However, it is possible that
32 | the .jar file in your project was of an older version than the
33 | dependency we picked, which could render the project not compileable.
34 | You can disable the jar replacement in the import wizard and try again:
35 |
36 | android-support-v4.jar => com.android.support:support-v4:19.1.0
37 |
38 | Moved Files:
39 | ------------
40 | Android Gradle projects use a different directory structure than ADT
41 | Eclipse projects. Here's how the projects were restructured:
42 |
43 | * AndroidManifest.xml => app/src/main/AndroidManifest.xml
44 | * assets/ => app/src/main/assets/
45 | * res/ => app/src/main/res/
46 | * src/ => app/src/main/java/
47 |
48 | Next Steps:
49 | -----------
50 | You can now build the project. The Gradle project needs network
51 | connectivity to download dependencies.
52 |
53 | Bugs:
54 | -----
55 | If for some reason your project does not build, and you determine that
56 | it is due to a bug or limitation of the Eclipse to Gradle importer,
57 | please file a bug at http://b.android.com with category
58 | Component-Tools.
59 |
60 | (This import summary is for your information only, and can be deleted
61 | after import once you are satisfied with the results.)
62 |
--------------------------------------------------------------------------------
/inforeader/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/inforeader/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | id 'kotlin-android-extensions'
5 | }
6 |
7 | apply from: "${project.rootDir}/buildsystem/android-defaults.gradle"
8 |
9 | android {
10 | final int buildNumber = getBuildNumber()
11 | final int versionMajor = 1
12 | final int versionMinor = 0
13 | final int versionPatch = buildNumber
14 | final int androidVersionCode = buildNumber
15 |
16 | final String semanticVersion = "${versionMajor}.${versionMinor}.${versionPatch}"
17 |
18 | defaultConfig {
19 | versionCode androidVersionCode
20 | versionName semanticVersion
21 |
22 | buildConfigField "String", "STAT_FILE", "\"/proc/stat\""
23 | }
24 |
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | }
29 | }
30 |
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 | }
36 | dependencies {
37 | implementation project(":common")
38 |
39 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
40 | implementation "androidx.core:core:$androidx_core_version"
41 | implementation "androidx.core:core-ktx:$androidx_core_version"
42 | implementation "androidx.annotation:annotation:$androidx_annotation_version"
43 |
44 | implementation "eu.chainfire:libsuperuser:$libsuperuser_version"
45 |
46 | testImplementation "junit:junit:$junit_version"
47 | testImplementation "org.mockito:mockito-core:$mockito_version"
48 |
49 | androidTestImplementation "androidx.test:core:$andoridx_test_runner_version"
50 | androidTestImplementation "androidx.test:runner:$andoridx_test_runner_version"
51 | }
--------------------------------------------------------------------------------
/inforeader/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/inforeader/consumer-rules.pro
--------------------------------------------------------------------------------
/inforeader/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/inforeader/src/androidTest/java/uk/co/alt236/floatinginfo/inforeader/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.inforeader
18 |
19 | import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
20 | import androidx.test.platform.app.InstrumentationRegistry
21 | import org.junit.Assert.assertEquals
22 | import org.junit.Test
23 | import org.junit.runner.RunWith
24 |
25 | /**
26 | * Instrumented test, which will execute on an Android device.
27 | *
28 | * See [testing documentation](http://d.android.com/tools/testing).
29 | */
30 | @RunWith(AndroidJUnit4ClassRunner::class)
31 | class ExampleInstrumentedTest {
32 | @Test
33 | fun useAppContext() {
34 | // Context of the app under test.
35 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
36 | assertEquals("uk.co.alt236.floatiinginfo.inforeader.test", appContext.packageName)
37 | }
38 | }
--------------------------------------------------------------------------------
/inforeader/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
20 |
21 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/bt/BluetoothInfoReader.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.inforeader.bt
18 |
19 | import android.annotation.SuppressLint
20 | import android.bluetooth.BluetoothAdapter
21 | import android.bluetooth.BluetoothDevice
22 | import android.content.Context
23 | import uk.co.alt236.floatinginfo.common.data.model.bt.BluetoothData
24 | import uk.co.alt236.floatinginfo.common.data.model.bt.BondState
25 | import uk.co.alt236.floatinginfo.common.data.model.bt.LightBluetoothDevice
26 | import uk.co.alt236.floatinginfo.common.data.model.bt.ScanMode
27 |
28 |
29 | class BluetoothInfoReader(context: Context) {
30 | var data: BluetoothData? = null
31 | private set
32 |
33 | @SuppressLint("HardwareIds")
34 | fun update() {
35 | data = BluetoothAdapter.getDefaultAdapter()?.let {
36 | val mac = it.address
37 | val isEnabled = it.isEnabled
38 | val scanMode = ScanMode.fromAndroidState(it.scanMode)
39 | val bonded = toList(it.bondedDevices)
40 |
41 | BluetoothData(
42 | address = mac,
43 | enabled = isEnabled,
44 | scanMode = scanMode,
45 | bondedDevices = bonded
46 | )
47 | }
48 | }
49 |
50 | private fun toList(devices: Collection?): List {
51 | if (devices.isNullOrEmpty()) {
52 | return emptyList()
53 | }
54 |
55 | return devices.map {
56 | LightBluetoothDevice(
57 | name = it.name ?: "",
58 | address = it.address ?: "",
59 | bondState = BondState.fromAndroidState(it.bondState))
60 | }
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/cpu/CpuInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.inforeader.cpu;
18 |
19 | class CpuInfo {
20 | private int mUsage;
21 | private long mLastTotal;
22 | private long mLastIdle;
23 |
24 | public CpuInfo() {
25 | mUsage = 0;
26 | mLastTotal = 0;
27 | mLastIdle = 0;
28 | }
29 |
30 | public int getUsage() {
31 | return mUsage;
32 | }
33 |
34 | public void update(final String[] parts) {
35 | // the columns are:
36 | //
37 | // 0 "cpu": the string "cpu" that identifies the line
38 | // 1 user: normal processes executing in user mode
39 | // 2 nice: niced processes executing in user mode
40 | // 3 system: processes executing in kernel mode
41 | // 4 idle: twiddling thumbs
42 | // 5 iowait: waiting for I/O to complete
43 | // 6 irq: servicing interrupts
44 | // 7 softirq: servicing softirqs
45 | //
46 | final long idle = Long.parseLong(parts[4], 10);
47 | long total = 0;
48 | boolean head = true;
49 | for (final String part : parts) {
50 | if (head) {
51 | head = false;
52 | continue;
53 | }
54 | total += Long.parseLong(part, 10);
55 | }
56 | final long diffIdle = idle - mLastIdle;
57 | final long diffTotal = total - mLastTotal;
58 | mUsage = (int) ((float) (diffTotal - diffIdle) / diffTotal * 100);
59 | mLastTotal = total;
60 | mLastIdle = idle;
61 | //Log.i(TAG, "CPU total=" + total + "; idle=" + idle + "; usage=" + mUsage);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/fgappinfo/FgAppDiscovery.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.fgappinfo
17 |
18 | import android.content.Context
19 | import android.content.pm.ApplicationInfo
20 | import android.content.pm.PackageManager
21 | import uk.co.alt236.floatinginfo.common.data.model.ForegroundAppData
22 |
23 | /**
24 | *
25 | */
26 | /*package*/
27 | internal abstract class FgAppDiscovery(context: Context) {
28 | private val mPackageManager: PackageManager = context.applicationContext.packageManager
29 |
30 | protected fun getAppName(packageName: String?): CharSequence {
31 | val ai: ApplicationInfo? = try {
32 | mPackageManager.getApplicationInfo(packageName, 0)
33 | } catch (e: PackageManager.NameNotFoundException) {
34 | null
35 | }
36 |
37 | return if (ai != null) mPackageManager.getApplicationLabel(ai) else UNKNOWN_APP_NAME
38 | }
39 |
40 | abstract fun getForegroundAppData(): ForegroundAppData
41 |
42 | internal companion object {
43 | const val UNKNOWN_APP_NAME = "???"
44 | const val UNKNOWN_PKG_NAME = "???"
45 |
46 | @JvmStatic
47 | val FALLBACK_APP_INFO = ForegroundAppData(-1, UNKNOWN_PKG_NAME, UNKNOWN_APP_NAME)
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/fgappinfo/FgAppDiscovery21.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.fgappinfo
17 |
18 | import android.annotation.SuppressLint
19 | import android.annotation.TargetApi
20 | import android.app.usage.UsageStats
21 | import android.app.usage.UsageStatsManager
22 | import android.content.Context
23 | import android.os.Build
24 | import android.util.Log
25 | import uk.co.alt236.floatinginfo.common.data.model.ForegroundAppData
26 | import java.util.*
27 |
28 | /**
29 | *
30 | */
31 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
32 | internal class FgAppDiscovery21(context: Context) : FgAppDiscovery(context) {
33 | private val usageStatsManager = getUsageStatsManager(context)
34 | private val processStore: ProcessStore = ProcessStore()
35 |
36 | override fun getForegroundAppData(): ForegroundAppData {
37 | if (usageStatsManager == null) {
38 | Log.i("FgAppDiscovery21", "manager is null")
39 | return FALLBACK_APP_INFO
40 | }
41 |
42 | val time = System.currentTimeMillis()
43 | val appList = getUsageStats(time)
44 |
45 | if (appList.isEmpty()) {
46 | return FALLBACK_APP_INFO
47 | }
48 |
49 | val sortedMap: SortedMap = TreeMap()
50 | for (usageStats in appList) {
51 | sortedMap[usageStats.lastTimeUsed] = usageStats
52 | }
53 |
54 | return if (sortedMap.isEmpty()) {
55 | FALLBACK_APP_INFO
56 | } else {
57 | processStore.update()
58 | val currentApp = sortedMap[sortedMap.lastKey()]
59 | val packageName = currentApp!!.packageName
60 | val pid = processStore.getPidFromName(packageName)
61 | ForegroundAppData(pid, packageName, getAppName(packageName))
62 | }
63 | }
64 |
65 |
66 | private fun getUsageStats(endTime: Long): List {
67 | val beginTime = endTime - TIME_WINDOW
68 | return usageStatsManager?.queryUsageStats(
69 | UsageStatsManager.INTERVAL_DAILY,
70 | beginTime,
71 | endTime) ?: emptyList()
72 | }
73 |
74 | companion object {
75 | private const val TIME_WINDOW = 1000 * 1000.toLong()
76 |
77 | @SuppressLint("WrongConstant")
78 | private fun getUsageStatsManager(context: Context): UsageStatsManager? {
79 | return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
80 | // intentionally using string value as Context.USAGE_STATS_SERVICE was
81 | // strangely only added in API 22 (LOLLIPOP_MR1)
82 | context.getSystemService("usagestats") as UsageStatsManager
83 | } else {
84 | null
85 | }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/fgappinfo/FgAppDiscoveryLegacy.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.fgappinfo
17 |
18 | import android.app.ActivityManager
19 | import android.app.ActivityManager.RunningAppProcessInfo
20 | import android.content.Context
21 | import uk.co.alt236.floatinginfo.common.data.model.ForegroundAppData
22 |
23 | /*package*/
24 | internal class FgAppDiscoveryLegacy(context: Context) : FgAppDiscovery(context) {
25 | private val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
26 |
27 | override fun getForegroundAppData(): ForegroundAppData {
28 | val foregroundTaskInfo = activityManager.getRunningTasks(1)[0]
29 |
30 | val pkg = foregroundTaskInfo.topActivity.packageName
31 | val appProcesses = activityManager.runningAppProcesses
32 |
33 | for (appProcess in appProcesses) {
34 | if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
35 | for (ap in appProcess.pkgList) {
36 | if (ap == pkg) {
37 | return ForegroundAppData(
38 | appProcess.pid,
39 | pkg,
40 | getAppName(pkg))
41 | }
42 | }
43 | }
44 | }
45 |
46 | return ForegroundAppData(0, pkg, FgAppDiscovery.Companion.UNKNOWN_APP_NAME)
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/fgappinfo/ForegroundAppDiscovery.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.fgappinfo
17 |
18 | import android.content.Context
19 | import android.os.Build
20 |
21 | class ForegroundAppDiscovery(context: Context) {
22 | private var appDiscovery: FgAppDiscovery
23 |
24 | init {
25 | val appContext = context.applicationContext
26 | appDiscovery = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
27 | FgAppDiscovery21(appContext)
28 | } else {
29 | FgAppDiscoveryLegacy(appContext)
30 | }
31 | }
32 |
33 | fun getForegroundAppData() = appDiscovery.getForegroundAppData()
34 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/fgappinfo/ProcessStore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.inforeader.fgappinfo;
18 |
19 | import java.util.HashMap;
20 | import java.util.List;
21 | import java.util.Map;
22 | import java.util.regex.Pattern;
23 |
24 | import eu.chainfire.libsuperuser.Shell;
25 |
26 | /*package*/ class ProcessStore {
27 | public static final int INVALID_PID = -1;
28 | private static final Pattern LINE_SPLIT_PATTERN = Pattern.compile("\\s+");
29 | private final Map mPidToName = new HashMap<>();
30 | private final Map mNameToPid = new HashMap<>();
31 |
32 | public void update() {
33 | mPidToName.clear();
34 | mNameToPid.clear();
35 |
36 | final List stdout = Shell.SH.run("ps");
37 |
38 | int lineNo = 0;
39 | String[] arr;
40 | int pid;
41 | String processName;
42 | for (final String line : stdout) {
43 | if (lineNo > 0) { // the first line is the header
44 | arr = LINE_SPLIT_PATTERN.split(line);
45 | pid = extractPid(arr);
46 | processName = extractProcessName(arr);
47 | mPidToName.put(pid, processName);
48 | mNameToPid.put(processName, pid);
49 | }
50 | lineNo++;
51 | }
52 | }
53 |
54 | public int getPidFromName(final String name) {
55 | final Integer pid = mNameToPid.get(name);
56 | if (pid == null) {
57 | return INVALID_PID;
58 | } else {
59 | return pid;
60 | }
61 | }
62 |
63 | public String getNameFromPid(final int pid) {
64 | return mPidToName.get(pid);
65 | }
66 |
67 | private static int extractPid(final String[] line) {
68 | return Integer.parseInt(line[1]);
69 | }
70 |
71 | private static String extractProcessName(final String[] line) {
72 | return line[line.length - 1].split(":")[0];
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/general/LocaleInfoReader.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.general
17 |
18 | import android.content.Context
19 | import android.os.Build
20 | import uk.co.alt236.floatinginfo.common.data.model.LocaleData
21 | import java.util.*
22 |
23 | class LocaleInfoReader(private val context: Context) {
24 | var data: LocaleData? = null
25 | private set
26 |
27 | override fun toString(): String {
28 | val buf = StringBuilder()
29 |
30 | data?.let {
31 | buf.append("Default Locale : ")
32 | buf.append(it.defaultLocale)
33 | }
34 |
35 | return buf.toString()
36 | }
37 |
38 | fun update() {
39 | val defaultLocale = Locale.getDefault()
40 | data = LocaleData(
41 | defaultLocale,
42 | localeList)
43 | }
44 |
45 | private val localeList: List
46 | get() {
47 | val retVal: MutableList = ArrayList()
48 | val configuration = context.resources.configuration
49 |
50 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
51 | val localeList = configuration.locales
52 | for (i in 0 until localeList.size()) {
53 | retVal.add(localeList[i])
54 | }
55 | } else {
56 | val locale = configuration.locale
57 | retVal.add(locale)
58 | }
59 |
60 | return retVal
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/memory/MemoryInfoReader.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.memory
17 |
18 | import android.app.ActivityManager
19 | import android.content.Context
20 | import uk.co.alt236.floatinginfo.common.data.model.MemoryData
21 |
22 | class MemoryInfoReader(context: Context) {
23 | private val mActivityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
24 | var info: MemoryData? = null
25 | private set
26 |
27 | fun update(pid: Int) {
28 | info = if (pid > 0) {
29 | val mi = mActivityManager.getProcessMemoryInfo(intArrayOf(pid))[0]
30 | MemoryData(pid, mi)
31 | } else {
32 | MemoryData.getBlank(pid)
33 | }
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/network/NetDataReader.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.network
17 |
18 | import android.content.Context
19 | import uk.co.alt236.floatinginfo.common.data.model.net.NetData
20 |
21 | /**
22 | *
23 | */
24 | class NetDataReader(context: Context) {
25 | private val proxyInfoReader = ProxyInfoReader(context.applicationContext)
26 | private val networkInfoReader = NetworkInfoReader(context.applicationContext)
27 | private val interfaceReader = InterfaceReader()
28 |
29 | var netData: NetData? = null
30 | private set
31 |
32 | fun update() {
33 | val proxyInfo = proxyInfoReader.proxyUrl
34 | val wifiInfo = networkInfoReader.currentWifiInfo
35 | val networkInfo = networkInfoReader.activeNetInfo
36 | val interfaces = interfaceReader.interfaces
37 | println("interfaces: $interfaces")
38 | netData = NetData(networkInfo, wifiInfo, proxyInfo, interfaces)
39 | }
40 |
41 | init {
42 | update()
43 | }
44 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/network/NetworkInfoReader.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.network
17 |
18 | import android.app.Application
19 | import android.content.Context
20 | import android.net.ConnectivityManager
21 | import android.net.NetworkInfo
22 | import android.net.wifi.WifiInfo
23 | import android.net.wifi.WifiManager
24 |
25 | /*package*/
26 | internal class NetworkInfoReader(context: Context) {
27 | private val mConnectivityManager: ConnectivityManager?
28 | private val mWifiManager: WifiManager?
29 |
30 | init {
31 | val application = context.applicationContext as Application
32 | mConnectivityManager = application.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager?
33 | mWifiManager = application.getSystemService(Context.WIFI_SERVICE) as WifiManager?
34 | }
35 |
36 | val currentWifiInfo: WifiInfo?
37 | get() = mWifiManager?.connectionInfo
38 |
39 |
40 | val activeNetInfo: NetworkInfo?
41 | get() = mConnectivityManager?.activeNetworkInfo
42 |
43 | }
--------------------------------------------------------------------------------
/inforeader/src/main/java/uk/co/alt236/floatinginfo/inforeader/network/ProxyInfoReader.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.inforeader.network
17 |
18 | import android.content.Context
19 | import android.net.ConnectivityManager
20 | import android.os.Build
21 |
22 | /*package*/
23 | internal class ProxyInfoReader(context: Context) {
24 | private val mConnectivityManager: ConnectivityManager?
25 | val proxyUrl: String
26 | get() {
27 | var proxyHost: String? = null
28 | var proxyPort: String? = null
29 |
30 | try {
31 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
32 | if (mConnectivityManager != null) {
33 | val proxyInfo = mConnectivityManager.defaultProxy
34 | if (proxyInfo != null) {
35 | proxyHost = proxyInfo.host
36 | proxyPort = proxyInfo.port.toString()
37 | }
38 | }
39 | } else {
40 | proxyHost = System.getProperty("http.proxyHost")
41 | proxyPort = System.getProperty("http.proxyPort")
42 | }
43 | } catch (ex: Exception) {
44 | proxyHost = null
45 | proxyPort = null
46 | }
47 |
48 | return if (proxyHost != null) {
49 | "$proxyHost:$proxyPort"
50 | } else {
51 | ""
52 | }
53 | }
54 |
55 | init {
56 | val appContext = context.applicationContext
57 | mConnectivityManager = appContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
58 | }
59 | }
--------------------------------------------------------------------------------
/inforeader/src/test/java/uk/co/alt236/floatinginfo/inforeader/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.inforeader
18 |
19 | import org.junit.Assert.assertEquals
20 | import org.junit.Test
21 |
22 | /**
23 | * Example local unit test, which will execute on the development machine (host).
24 | *
25 | * See [testing documentation](http://d.android.com/tools/testing).
26 | */
27 | class ExampleUnitTest {
28 | @Test
29 | fun addition_isCorrect() {
30 | assertEquals(4, 2 + 2)
31 | }
32 | }
--------------------------------------------------------------------------------
/overlay/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/overlay/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | id 'kotlin-android-extensions'
5 | }
6 |
7 | apply from: "${project.rootDir}/buildsystem/android-defaults.gradle"
8 |
9 | android {
10 | final int buildNumber = getBuildNumber()
11 | final int versionMajor = 1
12 | final int versionMinor = 0
13 | final int versionPatch = buildNumber
14 | final int androidVersionCode = buildNumber
15 |
16 | final String semanticVersion = "${versionMajor}.${versionMinor}.${versionPatch}"
17 |
18 | defaultConfig {
19 | versionCode androidVersionCode
20 | versionName semanticVersion
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | }
27 | }
28 |
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 | }
34 |
35 | dependencies {
36 | implementation project(":common")
37 |
38 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
39 | implementation "androidx.appcompat:appcompat:$androidx_appcompat_version"
40 | implementation "androidx.annotation:annotation:$androidx_annotation_version"
41 | implementation "androidx.core:core:$androidx_core_version"
42 | implementation "androidx.core:core-ktx:$androidx_core_version"
43 |
44 | testImplementation "junit:junit:$junit_version"
45 | testImplementation "org.mockito:mockito-core:$mockito_version"
46 |
47 | androidTestImplementation "androidx.test:core:$andoridx_test_runner_version"
48 | androidTestImplementation "androidx.test:runner:$andoridx_test_runner_version"
49 | }
50 |
51 | repositories {
52 | mavenCentral()
53 | }
--------------------------------------------------------------------------------
/overlay/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alt236/Floating-Info---Android/81239735ea9e1e477dbf1ba57f4acea5621fa2ac/overlay/consumer-rules.pro
--------------------------------------------------------------------------------
/overlay/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/overlay/src/androidTest/java/uk/co/alt236/floatinginfo/overlay/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.overlay;
18 |
19 | import android.content.Context;
20 |
21 | import org.junit.Test;
22 | import org.junit.runner.RunWith;
23 |
24 | import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
25 | import androidx.test.platform.app.InstrumentationRegistry;
26 |
27 | import static org.junit.Assert.assertEquals;
28 |
29 | /**
30 | * Instrumented test, which will execute on an Android device.
31 | *
32 | * @see Testing documentation
33 | */
34 | @RunWith(AndroidJUnit4ClassRunner.class)
35 | public class ExampleInstrumentedTest {
36 | @Test
37 | public void useAppContext() {
38 | // Context of the app under test.
39 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
40 |
41 | assertEquals("uk.co.alt236.floatinginfo.overlay.test", appContext.getPackageName());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/overlay/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/OverlayManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay;
17 |
18 | import android.view.LayoutInflater;
19 | import android.view.View;
20 |
21 | import uk.co.alt236.floatinginfo.common.data.InfoStore;
22 | import uk.co.alt236.floatinginfo.common.prefs.EnabledInfoPrefs;
23 | import uk.co.alt236.floatinginfo.common.prefs.OverlayPrefs;
24 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper;
25 | import uk.co.alt236.floatinginfo.overlay.writers.TextWriter;
26 | import uk.co.alt236.floatinginfo.overlay.writers.TextWriterWrapper;
27 |
28 | public class OverlayManager {
29 | private final InfoStore mInfoStore;
30 | private final TextOverlayController mTextOverlayController;
31 | private final TextWriter mTextWriter;
32 |
33 | public OverlayManager(final LayoutInflater layoutInflater,
34 | final InfoStore store,
35 | final OverlayPrefs overlayPrefs,
36 | final EnabledInfoPrefs enabledInfoPrefs) {
37 | mInfoStore = store;
38 | mTextWriter = new TextWriterWrapper(enabledInfoPrefs);
39 | mTextOverlayController = new TextOverlayController(layoutInflater, overlayPrefs);
40 |
41 | updateBackground();
42 | updateTextSize();
43 | updateTextColor();
44 | updateAlignment();
45 | }
46 |
47 | public void clearPeakUsage() {
48 | mTextWriter.clear();
49 | }
50 |
51 | private CharSequence getInfoText() {
52 | final StringBuilderHelper sb = new StringBuilderHelper();
53 | mTextWriter.writeText(mInfoStore, sb);
54 | return sb.toString().trim();
55 | }
56 |
57 | public CharSequence getSharePayload() {
58 | return getInfoText();
59 | }
60 |
61 | public View getView() {
62 | return mTextOverlayController.getView();
63 | }
64 |
65 | public void updateBackground() {
66 | mTextOverlayController.updateBackground();
67 | }
68 |
69 | public void updateTextColor() {
70 | mTextOverlayController.updateTextColor();
71 | }
72 |
73 | public void updateAlignment() {
74 | mTextOverlayController.updateAlignment();
75 | }
76 |
77 | public void updateTextSize() {
78 | mTextOverlayController.updateTextSize();
79 | }
80 |
81 | public void update() {
82 | mTextOverlayController.setText(getInfoText());
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/BluetoothTextWriter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers
17 |
18 | import uk.co.alt236.floatinginfo.common.data.model.bt.BluetoothData
19 | import uk.co.alt236.floatinginfo.common.data.model.bt.LightBluetoothDevice
20 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
21 |
22 | /**
23 | *
24 | */
25 | /*package*/
26 | internal class BluetoothTextWriter : TextWriter {
27 | override fun writeText(input: BluetoothData?, sb: StringBuilderHelper) {
28 | if (input == null) {
29 | return
30 | }
31 |
32 | sb.appendBold("Bluetooth Info")
33 | sb.startKeyValueSection()
34 | sb.append("Enabled", input.enabled)
35 | //sb.append("Address", input.address.pretty())
36 | sb.append("Scan Mode", input.scanMode.toString())
37 | sb.endKeyValueSection()
38 | //addCurrentDevices(sb, input.bondedDevices)
39 | sb.appendNewLine()
40 | }
41 |
42 | private fun addCurrentDevices(sb: StringBuilderHelper, devices: List) {
43 | if (devices.isEmpty()) {
44 | return;
45 | }
46 | sb.appendBold("Current Devices")
47 | sb.startKeyValueSection()
48 | for (device in devices) {
49 | sb.append(device.name.pretty(), device.address.pretty())
50 | }
51 | sb.endKeyValueSection()
52 | }
53 |
54 | private fun String?.pretty(): String {
55 | return if (this.isNullOrBlank()) {
56 | "n/a"
57 | } else {
58 | this
59 | }
60 | }
61 |
62 | override fun clear() {
63 | // NOOP
64 | }
65 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/CpuTextWriter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers
17 |
18 | import uk.co.alt236.floatinginfo.common.data.model.CpuData
19 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
20 |
21 | /*package*/
22 | internal class CpuTextWriter : TextWriter {
23 |
24 | override fun writeText(input: CpuData?, sb: StringBuilderHelper) {
25 | if (input == null) {
26 | return
27 | }
28 | sb.appendBold("Global CPU Utilisation")
29 | sb.startKeyValueSection()
30 | if (input.hasError) {
31 | sb.append("Error", "Failed to open " + input.statFile)
32 | } else {
33 | sb.append("Total", input.overallCpu.toString() + "%")
34 | val list = input.getPerCpuUtilisation()
35 |
36 | for ((count, value) in list.withIndex()) {
37 | sb.append("CPU$count", "$value%")
38 | }
39 | }
40 | sb.endKeyValueSection()
41 | sb.appendNewLine()
42 | }
43 |
44 | override fun clear() {
45 | // NOOP
46 | }
47 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/FgProcessTextWriter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers
17 |
18 | import uk.co.alt236.floatinginfo.common.data.model.ForegroundAppData
19 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
20 |
21 | /**
22 | *
23 | */
24 | /*package*/
25 | internal class FgProcessTextWriter : TextWriter {
26 |
27 | override fun writeText(input: ForegroundAppData?, sb: StringBuilderHelper) {
28 | if (input == null) {
29 | return
30 | }
31 | sb.appendBold("Foreground Application Info")
32 | sb.startKeyValueSection()
33 | sb.append("App Name", input.appName.toString())
34 | sb.append("Package", input.packageName)
35 | sb.append("PID", input.pid.toLong())
36 | sb.endKeyValueSection()
37 | sb.appendNewLine()
38 | }
39 |
40 | override fun clear() {
41 | // NOOP
42 | }
43 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/LocaleDataTextWriter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers
17 |
18 | import uk.co.alt236.floatinginfo.common.data.model.LocaleData
19 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
20 | import java.util.*
21 |
22 | /**
23 | *
24 | */
25 | /*package*/
26 | internal class LocaleDataTextWriter : TextWriter {
27 | override fun writeText(input: LocaleData?, sb: StringBuilderHelper) {
28 | if (input == null) {
29 | return
30 | }
31 | sb.appendBold("Locale Info")
32 | sb.startKeyValueSection()
33 | sb.append("Def Locale", input.defaultLocale.toString())
34 | sb.append("Context Locale", toString(input.contextLocales))
35 | sb.endKeyValueSection()
36 | sb.appendNewLine()
37 | }
38 |
39 | private fun toString(contextLocales: List?): String {
40 | val sb = StringBuilder()
41 | if (contextLocales == null || contextLocales.isEmpty()) {
42 | sb.append("")
43 | } else {
44 | for (i in contextLocales.indices) {
45 | if (sb.length > 0) {
46 | sb.append(", ")
47 | }
48 | sb.append(contextLocales[i])
49 | }
50 | }
51 | return sb.toString()
52 | }
53 |
54 | override fun clear() {
55 | // NOOP
56 | }
57 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/TextWriter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers
17 |
18 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
19 |
20 | /**
21 | *
22 | */
23 | interface TextWriter {
24 | fun writeText(input: T?,
25 | sb: StringBuilderHelper)
26 |
27 | fun clear()
28 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/TextWriterWrapper.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers
17 |
18 | import uk.co.alt236.floatinginfo.common.data.InfoStore
19 | import uk.co.alt236.floatinginfo.common.prefs.EnabledInfoPrefs
20 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
21 | import uk.co.alt236.floatinginfo.overlay.writers.net.InterfaceWriter
22 | import uk.co.alt236.floatinginfo.overlay.writers.net.NetDataTextWriter
23 |
24 | class TextWriterWrapper(private val mEnabledInfoPrefs: EnabledInfoPrefs) : TextWriter {
25 | private val cpuTextWriter = CpuTextWriter()
26 | private val fgProcessTextWriter = FgProcessTextWriter()
27 | private val interfaceWriter = InterfaceWriter()
28 | private val localeDataWriter = LocaleDataTextWriter()
29 | private val memoryTextWriter = MemoryTextWriter(mEnabledInfoPrefs)
30 | private val netDataTextWriter = NetDataTextWriter()
31 | private val bluetoothTextWriter = BluetoothTextWriter()
32 |
33 | override fun writeText(input: InfoStore?, sb: StringBuilderHelper) {
34 | if (input == null) {
35 | return
36 | }
37 |
38 | writeProcessInfo(input, sb)
39 | writeLocaleInfo(input, sb)
40 | writeNetInfo(input, sb)
41 | writeBluetoothInfo(input, sb)
42 | writeCpuInfo(input, sb)
43 | writeMemoryInfo(input, sb)
44 | }
45 |
46 | override fun clear() {
47 | cpuTextWriter.clear()
48 | memoryTextWriter.clear()
49 | fgProcessTextWriter.clear()
50 | }
51 |
52 | private fun writeProcessInfo(input: InfoStore, sb: StringBuilderHelper) {
53 | val info = input.foregroundProcessInfo
54 | fgProcessTextWriter.writeText(info, sb)
55 | }
56 |
57 | private fun writeLocaleInfo(input: InfoStore, sb: StringBuilderHelper) {
58 | if (mEnabledInfoPrefs.isLocaleInfoEnabled) {
59 | val data = input.localeData
60 | localeDataWriter.writeText(data, sb)
61 | }
62 | }
63 |
64 | private fun writeNetInfo(input: InfoStore, sb: StringBuilderHelper) {
65 | if (mEnabledInfoPrefs.isNetInfoEnabled) {
66 | val netData = input.netData
67 | netDataTextWriter.writeText(netData, sb)
68 | if (mEnabledInfoPrefs.isIpInfoEnabled && netData != null) {
69 | interfaceWriter.writeText(netData.interfaces, sb)
70 | }
71 | }
72 | }
73 |
74 | private fun writeCpuInfo(input: InfoStore, sb: StringBuilderHelper) {
75 | if (mEnabledInfoPrefs.isCpuInfoEnabled) {
76 | val info = input.cpuInfo
77 | cpuTextWriter.writeText(info, sb)
78 | }
79 | }
80 |
81 | private fun writeMemoryInfo(input: InfoStore, sb: StringBuilderHelper) {
82 | if (mEnabledInfoPrefs.isMemoryInfoEnabled) {
83 | val info = input.memoryInfo
84 | memoryTextWriter.writeText(info, sb)
85 | }
86 | }
87 |
88 | private fun writeBluetoothInfo(input: InfoStore, sb: StringBuilderHelper) {
89 | if (mEnabledInfoPrefs.isBluetoothInfoEnabled) {
90 | val info = input.bluetoothInfo
91 | bluetoothTextWriter.writeText(info, sb)
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/net/InterfaceWriter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers.net
17 |
18 | import uk.co.alt236.floatinginfo.common.data.model.net.Interface
19 | import uk.co.alt236.floatinginfo.common.data.model.net.IpAddress
20 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
21 | import uk.co.alt236.floatinginfo.overlay.writers.TextWriter
22 |
23 | /*package*/
24 | internal class InterfaceWriter : TextWriter> {
25 |
26 | override fun writeText(input: List?, sb: StringBuilderHelper) {
27 | if (input.isNullOrEmpty()) {
28 | return
29 | }
30 |
31 | sb.appendBold("Interfaces")
32 | for ((name, addresses) in sortInterfaces(input)) {
33 | sb.appendBold(name)
34 | sb.startKeyValueSection()
35 |
36 | for (address in sortAddresses(addresses)) {
37 | sb.append("IP v" + address.version, address.address)
38 | }
39 | sb.endKeyValueSection()
40 | }
41 |
42 | sb.appendNewLine()
43 | }
44 |
45 | private fun sortInterfaces(input: List): List {
46 | return input.sortedWith(interfaceComparator)
47 | }
48 |
49 | private fun sortAddresses(input: List): List {
50 | return input.sortedWith(ipAddressComparator)
51 | }
52 |
53 | override fun clear() {
54 | // NOOP
55 | }
56 |
57 | private companion object {
58 | val interfaceComparator = java.util.Comparator { o1, o2 -> o1.name.compareTo(o2.name, ignoreCase = true) }
59 | val ipAddressComparator = java.util.Comparator { o1, o2 -> o1.address.compareTo(o2.address, ignoreCase = true) }
60 | }
61 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/net/NetDataTextWriter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers.net
17 |
18 | import android.net.ConnectivityManager
19 | import android.text.TextUtils
20 | import uk.co.alt236.floatinginfo.common.data.model.net.NetData
21 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
22 | import uk.co.alt236.floatinginfo.overlay.writers.TextWriter
23 | import java.util.*
24 |
25 | /**
26 | *
27 | */
28 | internal class NetDataTextWriter : TextWriter {
29 | private val wifiInfoTextWriter = WifiInfoTextWriter()
30 |
31 | override fun writeText(input: NetData?, sb: StringBuilderHelper) {
32 | if (input == null) {
33 | return
34 | }
35 |
36 | val netInfo = input.networkInfo
37 | sb.appendBold("Network Info")
38 | sb.startKeyValueSection()
39 |
40 | if (netInfo == null) {
41 | sb.append("State", "Offline")
42 | } else {
43 | val resolver = NetInfoConstantResolver()
44 | sb.append("Type", resolver.getNetworkType(netInfo))
45 | sb.append("State", netInfo.state.toString().toLowerCase(Locale.US))
46 | if (netInfo.type == ConnectivityManager.TYPE_WIFI) {
47 | wifiInfoTextWriter.writeText(input.wifiInfo, sb)
48 | }
49 | sb.append("Proxy", getProxy(input))
50 | }
51 |
52 | sb.endKeyValueSection()
53 | sb.appendNewLine()
54 | }
55 |
56 | private fun getProxy(input: NetData): String {
57 | return if (TextUtils.isEmpty(input.proxy)) "OFF" else input.proxy
58 | }
59 |
60 | override fun clear() {
61 | // NOOP
62 | }
63 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/net/NetInfoConstantResolver.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers.net
17 |
18 | import android.net.ConnectivityManager
19 | import android.net.NetworkInfo
20 | import android.telephony.TelephonyManager
21 |
22 | /**
23 | *
24 | */
25 | /*package*/
26 | internal class NetInfoConstantResolver {
27 |
28 | fun getNetworkType(info: NetworkInfo): String {
29 | return when (info.type) {
30 | ConnectivityManager.TYPE_BLUETOOTH -> "BLUETOOTH"
31 | ConnectivityManager.TYPE_DUMMY -> "DUMMY"
32 | ConnectivityManager.TYPE_ETHERNET -> "ETHERNET"
33 | ConnectivityManager.TYPE_MOBILE -> getMobileType(info)
34 | ConnectivityManager.TYPE_MOBILE_DUN -> "MOBILE DUN"
35 | ConnectivityManager.TYPE_MOBILE_HIPRI -> "MOBILE HIPRI"
36 | ConnectivityManager.TYPE_MOBILE_MMS -> "MOBILE MMS"
37 | ConnectivityManager.TYPE_VPN -> "VPN"
38 | ConnectivityManager.TYPE_WIFI -> "WIFI"
39 | ConnectivityManager.TYPE_WIMAX -> "WIMAX"
40 | else -> "???"
41 | }
42 | }
43 |
44 | private fun getMobileType(info: NetworkInfo): String {
45 | val subtypeAsString = when (info.subtype) {
46 | TelephonyManager.NETWORK_TYPE_1xRTT -> "1xRTT"
47 | TelephonyManager.NETWORK_TYPE_CDMA -> "CDMA"
48 | TelephonyManager.NETWORK_TYPE_EDGE -> "EDGE"
49 | TelephonyManager.NETWORK_TYPE_EHRPD -> "EHRPD"
50 | TelephonyManager.NETWORK_TYPE_EVDO_0 -> "EVDO_0"
51 | TelephonyManager.NETWORK_TYPE_EVDO_A -> "EVDO_A"
52 | TelephonyManager.NETWORK_TYPE_EVDO_B -> "EVDO_B"
53 | TelephonyManager.NETWORK_TYPE_GPRS -> "GPRS"
54 | TelephonyManager.NETWORK_TYPE_GSM -> "GSM"
55 | TelephonyManager.NETWORK_TYPE_HSDPA -> "HSDPA"
56 | TelephonyManager.NETWORK_TYPE_HSPA -> "HSPA"
57 | TelephonyManager.NETWORK_TYPE_HSPAP -> "HSPAP"
58 | TelephonyManager.NETWORK_TYPE_HSUPA -> "HSUPA"
59 | TelephonyManager.NETWORK_TYPE_IDEN -> "IDEN"
60 | TelephonyManager.NETWORK_TYPE_IWLAN -> "IWLAN"
61 | TelephonyManager.NETWORK_TYPE_LTE -> "LTE"
62 | TelephonyManager.NETWORK_TYPE_TD_SCDMA -> "TD_SCDMA"
63 | TelephonyManager.NETWORK_TYPE_UMTS -> "UMTS"
64 | TelephonyManager.NETWORK_TYPE_UNKNOWN -> "UNKNOWN"
65 | else -> "???"
66 | }
67 |
68 | val prefix = "MOBILE/"
69 | return if (info.isRoaming) {
70 | "$prefix$subtypeAsString/ROAMING"
71 | } else {
72 | prefix + subtypeAsString
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/overlay/src/main/java/uk/co/alt236/floatinginfo/overlay/writers/net/WifiInfoTextWriter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package uk.co.alt236.floatinginfo.overlay.writers.net
17 |
18 | import android.net.wifi.WifiInfo
19 | import android.net.wifi.WifiManager
20 | import android.os.Build
21 | import uk.co.alt236.floatinginfo.common.string.StringBuilderHelper
22 | import uk.co.alt236.floatinginfo.overlay.writers.TextWriter
23 | import java.util.*
24 |
25 | internal class WifiInfoTextWriter : TextWriter {
26 |
27 | override fun writeText(input: WifiInfo?, sb: StringBuilderHelper) {
28 | if (input == null) {
29 | return
30 | }
31 |
32 | val bssid = input.bssid
33 | val ssid = input.ssid
34 | val linkSpeed = input.linkSpeed
35 |
36 | sb.append("SSID", pretty(ssid))
37 | sb.append("BSSID", pretty(bssid))
38 | sb.append("RSSI", getRssi(input))
39 | sb.append("Speed", String.format(Locale.US, NUMBER_WITH_UNIT, linkSpeed, WifiInfo.LINK_SPEED_UNITS))
40 |
41 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
42 | val freq = input.frequency
43 | sb.append("Freq", String.format(Locale.US, NUMBER_WITH_UNIT, freq, WifiInfo.FREQUENCY_UNITS))
44 | }
45 | }
46 |
47 | private fun getRssi(wifiInfo: WifiInfo): String {
48 | val rssi = wifiInfo.rssi
49 | val humanValue = WifiManager.calculateSignalLevel(rssi, RSSI_LEVELS)
50 | return String.format(Locale.US, RSSI, rssi, "dBm", humanValue, RSSI_LEVELS)
51 | }
52 |
53 | private fun pretty(string: String?): String {
54 | return string ?: "n/a"
55 | }
56 |
57 | override fun clear() {
58 | // NOOP
59 | }
60 |
61 | companion object {
62 | private const val NUMBER_WITH_UNIT = "%d %s"
63 | private const val RSSI = "%d %s (%d/%d)"
64 | private const val RSSI_LEVELS = 5
65 | }
66 | }
--------------------------------------------------------------------------------
/overlay/src/test/java/uk/co/alt236/floatinginfo/overlay/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 Alexandros Schillings
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package uk.co.alt236.floatinginfo.overlay;
18 |
19 | import org.junit.Test;
20 |
21 | import static org.junit.Assert.assertEquals;
22 |
23 | /**
24 | * Example local unit test, which will execute on the development machine (host).
25 | *
26 | * @see Testing documentation
27 | */
28 | public class ExampleUnitTest {
29 | @Test
30 | public void addition_isCorrect() {
31 | assertEquals(4, 2 + 2);
32 | }
33 | }
--------------------------------------------------------------------------------
/print_codecov.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PATTERN='jacoco*.xml'
4 | JAR_FILE='./buildsystem/jacocoxml/jacocoxmlparser-1.0.0.jar'
5 | COLOR_FLAG=''
6 |
7 | if which tput > /dev/null 2>&1 && [[ $(tput -T${TERM} colors) -ge 8 ]]; then
8 | COLOR_FLAG='--color'
9 | fi
10 |
11 | find -iname ${PATTERN} -print0 \
12 | | sort -z \
13 | | xargs -0 -I '{}' java -jar ${JAR_FILE} ${COLOR_FLAG} --global-stats -i '{}'
14 |
15 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':inforeader'
2 | include ':app'
3 | include ':overlay'
4 | include ':common'
5 |
--------------------------------------------------------------------------------