mirror of
https://github.com/databurn-in/PrivacyBreacher
synced 2024-11-24 02:40:25 +01:00
added switch button
This commit is contained in:
parent
f301b1e1f5
commit
49baca4145
@ -6,13 +6,18 @@ import android.app.ActivityManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
|
import android.widget.Switch;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -66,6 +71,21 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//service switch
|
||||||
|
Switch serviceSwitch = findViewById(R.id.serviceSwitch);
|
||||||
|
serviceSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
Log.i(TAG, "onCheckedChanged: isChecked: "+isChecked);
|
||||||
|
if(isChecked){
|
||||||
|
Log.i(TAG, "onCheckedChanged: start foreground and stop background service");
|
||||||
|
Toast.makeText(getApplicationContext(), "Starting Foreground Service", Toast.LENGTH_LONG).show();
|
||||||
|
}else{
|
||||||
|
Log.i(TAG, "onCheckedChanged: start background and stop foreground service");
|
||||||
|
Toast.makeText(getApplicationContext(), "Starting Background Service", Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showPopup(View v) {
|
public void showPopup(View v) {
|
||||||
|
@ -34,12 +34,50 @@
|
|||||||
android:src="@drawable/privacy_breacher"></ImageView>
|
android:src="@drawable/privacy_breacher"></ImageView>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/mainTitle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/logo"
|
android:layout_below="@id/logo"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_marginTop="35dp"
|
||||||
android:text="PrivacyBreacher"
|
android:text="PrivacyBreacher"
|
||||||
android:textColor="@color/colorPrimaryDark" />
|
android:textColor="@color/colorPrimaryDark" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/mainTitle"
|
||||||
|
android:layout_marginTop="15dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Background Service"
|
||||||
|
android:textColor="@color/colorPrimaryDark" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/serviceSwitch"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:textOff="OFF"
|
||||||
|
android:textOn="ON" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Foreground Service"
|
||||||
|
android:textColor="@color/colorPrimaryDark" />
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
Loading…
Reference in New Issue
Block a user