Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.deltaforce.siliconcupcake.x11screenrecorder">

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -16,6 +17,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".FloatingIcon" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package com.deltaforce.siliconcupcake.x11screenrecorder;

import android.app.Service;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class FloatingIcon extends Service {
Boolean isRec;
ImageView stop,start;
LinearLayout startRec;
LinearLayout stopRec;
private int initialX;
private int initialY;
private float initialTouchX;
private float initialTouchY;
WindowManager mWindowManager;
View floatingView;
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
public FloatingIcon()
{

}
@Override
public void onCreate() {
isRec = false;
super.onCreate();


final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);

params.x = 0;
params.y = 0;

floatingView = LayoutInflater.from(this).inflate(R.layout.layout_floating_icon, null);

startRec = floatingView.findViewById(R.id.start_layout);
stopRec = floatingView.findViewById(R.id.stop_layout);
stop = floatingView.findViewById(R.id.stop);
start = floatingView.findViewById(R.id.start);

startRec.setVisibility(View.VISIBLE);
stopRec.setVisibility(View.GONE);

floatingView.findViewById(R.id.loc).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:

initialX = params.x;
initialY = params.y;

initialTouchX = event.getRawX();
initialTouchY = event.getRawY();
return true;
case MotionEvent.ACTION_MOVE:
params.x = initialX + (int) (event.getRawX() - initialTouchX);
params.y = initialY + (int) (event.getRawY() - initialTouchY);

mWindowManager.updateViewLayout(floatingView, params);
return true;
}
return false;
}
});
floatingView.findViewById(R.id.loc1).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:

initialX = params.x;
initialY = params.y;

initialTouchX = event.getRawX();
initialTouchY = event.getRawY();
return true;
case MotionEvent.ACTION_MOVE:
params.x = initialX + (int) (event.getRawX() - initialTouchX);
params.y = initialY + (int) (event.getRawY() - initialTouchY);

mWindowManager.updateViewLayout(floatingView, params);
return true;
}
return false;
}
});
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Start Recording
isRec = true;
startRec.setVisibility(View.GONE);
stopRec.setVisibility(View.VISIBLE);
}
});

stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Stop Recording
isRec = false;
stopRec.setVisibility(View.GONE);
startRec.setVisibility(View.VISIBLE);
}
});
floatingView.findViewById(R.id.exit1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//exit
}
});
floatingView.findViewById(R.id.exit2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//exit
}
});
mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
mWindowManager.addView(floatingView, params);


}
@Override
public void onDestroy(){
super.onDestroy();
if(floatingView!=null)
mWindowManager.removeViewImmediate(floatingView);
}

}

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.deltaforce.siliconcupcake.x11screenrecorder;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

Expand All @@ -9,5 +10,9 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


startService(new Intent(MainActivity.this,FloatingIcon.class));
finish();
}
}
68 changes: 68 additions & 0 deletions app/src/main/res/layout/layout_floating_icon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<RelativeLayout
android:id="@+id/root"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:ignore="UselessParent">

<LinearLayout
android:id="@+id/start_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/loc1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_mylocation" />

<ImageView
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:src="@android:drawable/ic_media_play" />

<ImageView
android:id="@+id/exit1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_dialog" />

</LinearLayout>

<LinearLayout
android:id="@+id/stop_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:id="@+id/loc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_mylocation" />

<ImageView
android:id="@+id/stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:src="@android:drawable/ic_media_pause" />

<ImageView
android:id="@+id/exit2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_dialog" />

</LinearLayout>

</RelativeLayout>
</FrameLayout>