5,595,428 Members 48,206 Now Online
XDA Developers Android and Mobile Development Forum

[Q]Put view over status bar

Tip us?
 
DannyGM16
Old
#11  
DannyGM16's Avatar
Senior Member - OP
Thanks Meter 12
Posts: 131
Join Date: Jul 2013
Quote:
Originally Posted by nikwen View Post
Maybe you can find some hints in the code of the RoundR app which does actually do what you want to achieve: https://github.com/MohammadAdib/Roundr
I don't find the code that I need, Help me please.
This is the code:

MainActivity.java:
Code:
 package mohammad.adib.roundr;

/**
 * Copyright 2013 Mohammad Adib
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

import wei.mark.standout.StandOutWindow;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;

public class MainActivity extends Activity {

/**
 * Main Activity that launches the 4 floating windows (corners)
 * 
 * @author Mohammad Adib <m.a.adib96@gmail.com>
 * 
 *         Contributors: Mark Wei
 * 
 */

ProgressDialog progress;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (!BootReceiver.boot_up || Corner.running) {
Intent i = new Intent(this, SettingsActivity.class);
startActivity(i);
}
if (prefs.getBoolean("enable", true)) {
StandOutWindow.show(this, Corner.class, 0);
StandOutWindow.show(this, Corner.class, 1);
StandOutWindow.show(this, Corner.class, 2);
StandOutWindow.show(this, Corner.class, 3);
}
finish();
}

}
Corner.java:
Code:
 package mohammad.adib.roundr;

/**
 * Copyright 2013 Mohammad Adib
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

import wei.mark.standout.StandOutWindow;
import wei.mark.standout.constants.StandOutFlags;
import wei.mark.standout.ui.Window;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RemoteViews;

public class Corner extends StandOutWindow {

/**
 * The individual floating window that sits at one of the corners of the
 * screen. Window ID corresponds to which corner this goes to.
 * 
 * @author Mohammad Adib <m.a.adib96@gmail.com>
 * 
 *         Contributors: Mark Wei, Jan Metten
 * 
 */

public static final String ACTION_SETTINGS = "SETTINGS";
public static final String BCAST_CONFIGCHANGED = "android.intent.action.CONFIGURATION_CHANGED";
public static final int UPDATE_CODE = 2;
public static final int NOTIFICATION_CODE = 3;
public static final int wildcard = 0;
private SharedPreferences prefs;
public static boolean running = false;

@Override
public String getAppName() {
return "RoundR";
}

@Override
public int getAppIcon() {
return R.drawable.notif_icon;
}

@Override
public void createAndAttachView(int corner, FrameLayout frame) {
// Set the image based on window corner
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
ImageView v = (ImageView) inflater.inflate(R.layout.corner, frame, true).findViewById(R.id.iv);
// Top left by default
v.setImageDrawable(getResources().getDrawable(R.drawable.topleft));
switch (corner) {
case 1:
v.setImageDrawable(getResources().getDrawable(R.drawable.topright));
break;
case 2:
v.setImageDrawable(getResources().getDrawable(R.drawable.bottomleft));
break;
case 3:
v.setImageDrawable(getResources().getDrawable(R.drawable.bottomright));
break;
}
}

private int pxFromDp(double dp) {
return (int) (dp * getResources().getDisplayMetrics().density);
}

/**
 * Corners: 0 = top left; 1 = top right; 2 = bottom left; 3 = bottom right;
 */
@Override
public StandOutLayoutParams getParams(int corner, Window window) {
prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Check if this corner is enabled
if (prefs.getBoolean("corner" + corner, true)) {
int radius = pxFromDp(prefs.getInt("radius", 20));
// Thanks to Jan Metten for rewriting this based on gravity
switch (corner) {
case 0:
return new StandOutLayoutParams(corner, radius, radius, Gravity.TOP | Gravity.LEFT);
case 1:
return new StandOutLayoutParams(corner, radius, radius, Gravity.TOP | Gravity.RIGHT);
case 2:
return new StandOutLayoutParams(corner, radius, radius, Gravity.BOTTOM | Gravity.LEFT);
case 3:
return new StandOutLayoutParams(corner, radius, radius, Gravity.BOTTOM | Gravity.RIGHT);
}
}
// Outside of screen
return new StandOutLayoutParams(corner, 1, 1, -1, -1, 1, 1);

}

@Override
public int getFlags(int corner) {
return super.getFlags(corner) | StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE | StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE;
}

@Override
public String getPersistentNotificationMessage(int corner) {
return "Tap to configure";
}

@Override
public Intent getPersistentNotificationIntent(int corner) {
return new Intent(this, Corner.class).putExtra("id", corner).setAction(ACTION_SETTINGS);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
String action = intent.getAction();
int corner = intent.getIntExtra("id", DEFAULT_ID);
if (corner == ONGOING_NOTIFICATION_ID) {
throw new RuntimeException("ID cannot equals StandOutWindow.ONGOING_NOTIFICATION_ID");
}

if (ACTION_SHOW.equals(action) || ACTION_RESTORE.equals(action)) {
show(corner);
} else if (ACTION_SETTINGS.equals(action)) {
try {
Intent intentS = new Intent(this, SettingsActivity.class);
intentS.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentS);
} catch (Exception e) {
// Addressing this issue: http://i.imgur.com/Op9kfy8.png
}
} else if (ACTION_HIDE.equals(action)) {
hide(corner);
} else if (ACTION_CLOSE.equals(action)) {
close(corner);
} else if (ACTION_CLOSE_ALL.equals(action)) {
closeAll();
} else if (ACTION_SEND_DATA.equals(action)) {
if (isExistingId(corner) || corner == DISREGARD_ID) {
Bundle data = intent.getBundleExtra("wei.mark.standout.data");
int requestCode = intent.getIntExtra("requestCode", 0);
@SuppressWarnings("unchecked")
Class<? extends StandOutWindow> fromCls = (Class<? extends StandOutWindow>) intent.getSerializableExtra("wei.mark.standout.fromCls");
int fromId = intent.getIntExtra("fromId", DEFAULT_ID);
onReceiveData(corner, requestCode, data, fromCls, fromId);
}
}
}
return START_NOT_STICKY;
}

@Override
public boolean onClose(final int corner, final Window window) {
running = false;
return false;
}

@Override
public String getPersistentNotificationTitle(int corner) {
return "Rounded Corners";
}

@SuppressLint({ "InlinedApi", "NewApi" })
@SuppressWarnings("deprecation")
@Override
public Notification getPersistentNotification(int id) {
int icon = getAppIcon();
long when = System.currentTimeMillis();
Context c = getApplicationContext();
String contentTitle = getPersistentNotificationTitle(id);
String contentText = getPersistentNotificationMessage(id);

Intent notificationIntent = getPersistentNotificationIntent(id);

PendingIntent contentIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

// 4.1+ Low priority notification
final int apiLevel = Build.VERSION.SDK_INT;
if (apiLevel >= 16) {
Notification.Builder mBuilder = new Notification.Builder(this).setContent(new RemoteViews(getPackageName(), R.layout.notification)).setSmallIcon(getAppIcon()).setContentTitle(contentTitle).setContentText(contentText).setPriority(Notification.PRIORITY_MIN).setContentIntent(contentIntent);
return mBuilder.build();
}

String tickerText = String.format("%s: %s", contentTitle, contentText);

Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(c, contentTitle, contentText, contentIntent);

return notification;
}

@Override
public boolean onShow(final int corner, final Window window) {
running = true;
return false;
}

@Override
public void onReceiveData(int corner, int requestCode, Bundle data, Class<? extends StandOutWindow> fromCls, int fromId) {
Window window = getWindow(corner);
if (requestCode == UPDATE_CODE) {
// Update the corners when device is rotated
updateViewLayout(3, getParams(3, window));
updateViewLayout(2, getParams(2, window));
updateViewLayout(1, getParams(1, window));
updateViewLayout(0, getParams(0, window));
} else if (requestCode == NOTIFICATION_CODE) {
if (!prefs.getBoolean("notification", true)) {
// Hide Notification Icon (for <= Gingerbread devices only)
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = getPersistentNotification(corner);
notification.icon = wei.mark.standout.R.drawable.nothing;
mNotificationManager.notify(getClass().hashCode() + ONGOING_NOTIFICATION_ID, notification);
Log.d("Hello World", "");
} else {
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = getPersistentNotification(corner);
mNotificationManager.notify(getClass().hashCode() + ONGOING_NOTIFICATION_ID, notification);
}
}
}
}
SeekBarPreference:
Code:
 package mohammad.adib.roundr;

import wei.mark.standout.StandOutWindow;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.preference.Preference;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class SeekBarPreference extends Preference implements OnSeekBarChangeListener {

private final String TAG = getClass().getName();

private static final String ANDROIDNS = "http://schemas.android.com/apk/res/android";
private static final String ROUNDRNS = "roundrprefs";
private static final int DEFAULT_VALUE = 50;

private int mMaxValue = 100;
private int mMinValue = 0;
private int mInterval = 1;
private int mCurrentValue;
private String mUnitsLeft = "";
private String mUnitsRight = "";
private SeekBar mSeekBar;
private Context context;

private TextView mStatusText;

public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
initPreference(context, attrs);
}

public SeekBarPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initPreference(context, attrs);
}

private void initPreference(Context context, AttributeSet attrs) {
setValuesFromXml(attrs);
mSeekBar = new SeekBar(context, attrs);
mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);
}

private void setValuesFromXml(AttributeSet attrs) {
mMaxValue = attrs.getAttributeIntValue(ANDROIDNS, "max", 100);
mMinValue = attrs.getAttributeIntValue(ROUNDRNS, "min", 0);

mUnitsLeft = getAttributeStringValue(attrs, ROUNDRNS, "unitsLeft", "");
String units = getAttributeStringValue(attrs, ROUNDRNS, "units", "");
mUnitsRight = getAttributeStringValue(attrs, ROUNDRNS, "unitsRight", units);

try {
String newInterval = attrs.getAttributeValue(ROUNDRNS, "interval");
if (newInterval != null)
mInterval = Integer.parseInt(newInterval);
} catch (Exception e) {
Log.e(TAG, "Invalid interval value", e);
}

}

private String getAttributeStringValue(AttributeSet attrs, String namespace, String name, String defaultValue) {
String value = attrs.getAttributeValue(namespace, name);
if (value == null)
value = defaultValue;

return value;
}

@Override
protected View onCreateView(ViewGroup parent) {

RelativeLayout layout = null;

try {
LayoutInflater mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

layout = (RelativeLayout) mInflater.inflate(R.layout.seek_bar_preference, parent, false);
} catch (Exception e) {
Log.e(TAG, "Error creating seek bar preference", e);
}

return layout;

}

@Override
public void onBindView(View view) {
super.onBindView(view);

try {
// move our seekbar to the new view we've been given
ViewParent oldContainer = mSeekBar.getParent();
ViewGroup newContainer = (ViewGroup) view.findViewById(R.id.seekBarPrefBarContainer);

if (oldContainer != newContainer) {
// remove the seekbar from the old view
if (oldContainer != null) {
((ViewGroup) oldContainer).removeView(mSeekBar);
}
// remove the existing seekbar (there may not be one) and add
// ours
newContainer.removeAllViews();
newContainer.addView(mSeekBar, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
} catch (Exception ex) {
Log.e(TAG, "Error binding view: " + ex.toString());
}

updateView(view);
}

/**
 * Update a SeekBarPreference view with our current state
 * 
 * @param view
 */
protected void updateView(View view) {

try {
RelativeLayout layout = (RelativeLayout) view;

mStatusText = (TextView) layout.findViewById(R.id.seekBarPrefValue);
mStatusText.setText(String.valueOf(pxFromDp(mCurrentValue)));
mStatusText.setMinimumWidth(30);

mSeekBar.setProgress(mCurrentValue - mMinValue);

} catch (Exception e) {
Log.e(TAG, "Error updating seek bar preference", e);
}

}

private int pxFromDp(double dp) {
return (int) (dp * context.getResources().getDisplayMetrics().density);
}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int newValue = progress + mMinValue;

if (newValue > mMaxValue)
newValue = mMaxValue;
else if (newValue < mMinValue)
newValue = mMinValue;
else if (mInterval != 1 && newValue % mInterval != 0)
newValue = Math.round(((float) newValue) / mInterval) * mInterval;

// change rejected, revert to the previous value
if (!callChangeListener(newValue)) {
seekBar.setProgress(mCurrentValue - mMinValue);
return;
}

// change accepted, store it
mCurrentValue = newValue;
mStatusText.setText(String.valueOf(pxFromDp(newValue)));
persistInt(newValue);
// Refresh the corners to apply the new radius
StandOutWindow.sendData(context, Corner.class, Corner.wildcard, Corner.UPDATE_CODE, new Bundle(), Corner.class, StandOutWindow.DISREGARD_ID);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
notifyChanged();
}

@Override
protected Object onGetDefaultValue(TypedArray ta, int index) {

int defaultValue = ta.getInt(index, DEFAULT_VALUE);
return defaultValue;

}

@Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {

if (restoreValue) {
mCurrentValue = getPersistedInt(mCurrentValue);
} else {
int temp = 0;
try {
temp = (Integer) defaultValue;
} catch (Exception ex) {
Log.e(TAG, "Invalid default value: " + defaultValue.toString());
}

persistInt(temp);
mCurrentValue = temp;
}

}

}
SettingsActivity.java:
Code:
 package mohammad.adib.roundr;

import wei.mark.standout.StandOutWindow;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.WindowManager.LayoutParams;

public class SettingsActivity extends PreferenceActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
/**
 * Handle Preference Changes
 */
// Enable/Disable
((Preference) findPreference("enable")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean isChecked = (Boolean) newValue;
if (isChecked) {
StandOutWindow.show(SettingsActivity.this, Corner.class, 0);
StandOutWindow.show(SettingsActivity.this, Corner.class, 1);
StandOutWindow.show(SettingsActivity.this, Corner.class, 2);
StandOutWindow.show(SettingsActivity.this, Corner.class, 3);
} else {
StandOutWindow.closeAll(SettingsActivity.this, Corner.class);
}
return true;
}
});
// Notification
final int apiLevel = Build.VERSION.SDK_INT;
if (apiLevel >= 16) {
((Preference) findPreference("notification")).setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
new AlertDialog.Builder(SettingsActivity.this).setTitle("Notification").setMessage("The notification prevents Android from killing RoundR in low memory situations.\n\nOn Android 4.1+ devices, it can be disabled via the App Info.").setPositiveButton("Continue", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
showInstalledAppDetails("mohammad.adib.roundr");
}
}).show();
return true;
}
});
}else{
((Preference) findPreference("notification")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
StandOutWindow.sendData(SettingsActivity.this, Corner.class, Corner.wildcard, Corner.NOTIFICATION_CODE, new Bundle(), Corner.class, StandOutWindow.DISREGARD_ID);
return true;
}
});
}
// Enable specific corners
for (int i = 0; i < 4; i++) {
((Preference) findPreference("corner" + i)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
refresh();
return true;
}
});
}
/**
 * Overlap Settings TODO: These are messy
 */
((Preference) findPreference("overlap1")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean isChecked = (Boolean) newValue;
if (isChecked) {
prefs.edit().putInt("type", LayoutParams.TYPE_SYSTEM_OVERLAY).commit();
if (prefs.getBoolean("overlap2", false))
prefs.edit().putInt("flags", LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_LAYOUT_IN_SCREEN).commit();
else
prefs.edit().putInt("flags", LayoutParams.FLAG_SHOW_WHEN_LOCKED).commit();
} else {
prefs.edit().putInt("type", LayoutParams.TYPE_SYSTEM_ALERT).commit();
if (prefs.getBoolean("overlap2", false))
prefs.edit().putInt("flags", LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_LAYOUT_IN_SCREEN).commit();
else
prefs.edit().putInt("flags", LayoutParams.FLAG_NOT_TOUCH_MODAL).commit();
}
new Thread(new Runnable() {

@Override
public void run() {
// Disable and Re-enable the corners
StandOutWindow.closeAll(SettingsActivity.this, Corner.class);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
StandOutWindow.show(SettingsActivity.this, Corner.class, 0);
StandOutWindow.show(SettingsActivity.this, Corner.class, 1);
StandOutWindow.show(SettingsActivity.this, Corner.class, 2);
StandOutWindow.show(SettingsActivity.this, Corner.class, 3);
}

}).start();
return true;
}
});
((Preference) findPreference("overlap2")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean isChecked = (Boolean) newValue;
if (isChecked) {
if (prefs.getBoolean("overlap", true))
prefs.edit().putInt("flags", LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_LAYOUT_IN_SCREEN).commit();
else
prefs.edit().putInt("flags", LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | LayoutParams.FLAG_LAYOUT_IN_SCREEN).commit();
} else {
if (prefs.getBoolean("overlap", true))
prefs.edit().putInt("flags", LayoutParams.FLAG_SHOW_WHEN_LOCKED).commit();
else
prefs.edit().putInt("flags", LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH).commit();
}
new Thread(new Runnable() {

@Override
public void run() {
// Disable and Reenable the corners
StandOutWindow.closeAll(SettingsActivity.this, Corner.class);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
StandOutWindow.show(SettingsActivity.this, Corner.class, 0);
StandOutWindow.show(SettingsActivity.this, Corner.class, 1);
StandOutWindow.show(SettingsActivity.this, Corner.class, 2);
StandOutWindow.show(SettingsActivity.this, Corner.class, 3);
}

}).start();
return true;
}
});
/**
 * TODO: Figure out if Developer Options is enabled. If so, show a
 * GitHub Source Code Link preference:
 * "Seems like you are a developer? Check out the RoundR source code on GitHub!"
 */
}

/*
 * Sends a signal to all the corners to refresh their layout parameters,
 * which in turn refreshes their size.
 */
public void refresh() {
StandOutWindow.sendData(this, Corner.class, Corner.wildcard, Corner.UPDATE_CODE, new Bundle(), Corner.class, StandOutWindow.DISREGARD_ID);
}

@SuppressLint("InlinedApi")
public void showInstalledAppDetails(String packageName) {
Intent intent = new Intent();
intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", packageName, null);
intent.setData(uri);
startActivity(intent);
}
}
preferences.xml:
Code:
 <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:roundr="roundrprefs" >

    <PreferenceCategory android:title="General Settings" >
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="enable"
            android:summary="Enable rounded screen corners"
            android:title="Enable RoundR" />
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="start_on_boot"
            android:summary="Start RoundR automatically on boot"
            android:title="Start on boot" />
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="notification"
            android:summary="The notification is required to keep RoundR running in low memory situations"
            android:title="Visible Notification" />
    </PreferenceCategory>
    <PreferenceCategory android:title="RoundR Settings" >
        <PreferenceScreen
            android:dependency="enable"
            android:persistent="false"
            android:summary="Enable rounding on specific corners"
            android:title="Enabled Corners" >
            <CheckBoxPreference
                android:defaultValue="true"
                android:key="corner0"
                android:title="Top Left" />
            <CheckBoxPreference
                android:defaultValue="true"
                android:key="corner1"
                android:title="Top Right" />
            <CheckBoxPreference
                android:defaultValue="true"
                android:key="corner2"
                android:title="Bottom Left" />
            <CheckBoxPreference
                android:defaultValue="true"
                android:key="corner3"
                android:title="Bottom Right" />
        </PreferenceScreen>

        <mohammad.adib.roundr.SeekBarPreference
            android:defaultValue="10"
            android:key="radius"
            android:max="40"
            android:title="Corner Radius"
            roundr:min="2"
            roundr:unitsLeft=""
            roundr:unitsRight="" />

        <CheckBoxPreference
            android:defaultValue="true"
            android:key="overlap1"
            android:summary="This also constitutes overlaping of the corners on the notification pull-down"
            android:title="Enable on lockscreen" />
        <CheckBoxPreference
            android:defaultValue="false"
            android:key="overlap2"
            android:summary="Allows for the corners to overlap the status bar"
            android:title="Overlap Status Bar" />
    </PreferenceCategory>

</PreferenceScreen>
Can u help me? where is the specific code that i need, i was trying to find it for hours...

Enviado desde mi GT-S5570I usando Tapatalk 2
 
nikwen
Old
#12  
nikwen's Avatar
Recognized Contributor
Thanks Meter 1231
Posts: 2,611
Join Date: Feb 2013
Quote:
Originally Posted by DannyGM16 View Post
I don't find the code that I need, Help me please.
 
This is the code:

MainActivity.java:
Code:
 package mohammad.adib.roundr;

/**
 * Copyright 2013 Mohammad Adib
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

import wei.mark.standout.StandOutWindow;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;

public class MainActivity extends Activity {

/**
 * Main Activity that launches the 4 floating windows (corners)
 * 
 * @author Mohammad Adib <m.a.adib96@gmail.com>
 * 
 *         Contributors: Mark Wei
 * 
 */

ProgressDialog progress;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (!BootReceiver.boot_up || Corner.running) {
Intent i = new Intent(this, SettingsActivity.class);
startActivity(i);
}
if (prefs.getBoolean("enable", true)) {
StandOutWindow.show(this, Corner.class, 0);
StandOutWindow.show(this, Corner.class, 1);
StandOutWindow.show(this, Corner.class, 2);
StandOutWindow.show(this, Corner.class, 3);
}
finish();
}

}
Corner.java:
Code:
 package mohammad.adib.roundr;

/**
 * Copyright 2013 Mohammad Adib
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain a
 * copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

import wei.mark.standout.StandOutWindow;
import wei.mark.standout.constants.StandOutFlags;
import wei.mark.standout.ui.Window;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RemoteViews;

public class Corner extends StandOutWindow {

/**
 * The individual floating window that sits at one of the corners of the
 * screen. Window ID corresponds to which corner this goes to.
 * 
 * @author Mohammad Adib <m.a.adib96@gmail.com>
 * 
 *         Contributors: Mark Wei, Jan Metten
 * 
 */

public static final String ACTION_SETTINGS = "SETTINGS";
public static final String BCAST_CONFIGCHANGED = "android.intent.action.CONFIGURATION_CHANGED";
public static final int UPDATE_CODE = 2;
public static final int NOTIFICATION_CODE = 3;
public static final int wildcard = 0;
private SharedPreferences prefs;
public static boolean running = false;

@Override
public String getAppName() {
return "RoundR";
}

@Override
public int getAppIcon() {
return R.drawable.notif_icon;
}

@Override
public void createAndAttachView(int corner, FrameLayout frame) {
// Set the image based on window corner
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
ImageView v = (ImageView) inflater.inflate(R.layout.corner, frame, true).findViewById(R.id.iv);
// Top left by default
v.setImageDrawable(getResources().getDrawable(R.drawable.topleft));
switch (corner) {
case 1:
v.setImageDrawable(getResources().getDrawable(R.drawable.topright));
break;
case 2:
v.setImageDrawable(getResources().getDrawable(R.drawable.bottomleft));
break;
case 3:
v.setImageDrawable(getResources().getDrawable(R.drawable.bottomright));
break;
}
}

private int pxFromDp(double dp) {
return (int) (dp * getResources().getDisplayMetrics().density);
}

/**
 * Corners: 0 = top left; 1 = top right; 2 = bottom left; 3 = bottom right;
 */
@Override
public StandOutLayoutParams getParams(int corner, Window window) {
prefs = PreferenceManager.getDefaultSharedPreferences(this);
// Check if this corner is enabled
if (prefs.getBoolean("corner" + corner, true)) {
int radius = pxFromDp(prefs.getInt("radius", 20));
// Thanks to Jan Metten for rewriting this based on gravity
switch (corner) {
case 0:
return new StandOutLayoutParams(corner, radius, radius, Gravity.TOP | Gravity.LEFT);
case 1:
return new StandOutLayoutParams(corner, radius, radius, Gravity.TOP | Gravity.RIGHT);
case 2:
return new StandOutLayoutParams(corner, radius, radius, Gravity.BOTTOM | Gravity.LEFT);
case 3:
return new StandOutLayoutParams(corner, radius, radius, Gravity.BOTTOM | Gravity.RIGHT);
}
}
// Outside of screen
return new StandOutLayoutParams(corner, 1, 1, -1, -1, 1, 1);

}

@Override
public int getFlags(int corner) {
return super.getFlags(corner) | StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE | StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE;
}

@Override
public String getPersistentNotificationMessage(int corner) {
return "Tap to configure";
}

@Override
public Intent getPersistentNotificationIntent(int corner) {
return new Intent(this, Corner.class).putExtra("id", corner).setAction(ACTION_SETTINGS);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
String action = intent.getAction();
int corner = intent.getIntExtra("id", DEFAULT_ID);
if (corner == ONGOING_NOTIFICATION_ID) {
throw new RuntimeException("ID cannot equals StandOutWindow.ONGOING_NOTIFICATION_ID");
}

if (ACTION_SHOW.equals(action) || ACTION_RESTORE.equals(action)) {
show(corner);
} else if (ACTION_SETTINGS.equals(action)) {
try {
Intent intentS = new Intent(this, SettingsActivity.class);
intentS.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentS);
} catch (Exception e) {
// Addressing this issue: http://i.imgur.com/Op9kfy8.png
}
} else if (ACTION_HIDE.equals(action)) {
hide(corner);
} else if (ACTION_CLOSE.equals(action)) {
close(corner);
} else if (ACTION_CLOSE_ALL.equals(action)) {
closeAll();
} else if (ACTION_SEND_DATA.equals(action)) {
if (isExistingId(corner) || corner == DISREGARD_ID) {
Bundle data = intent.getBundleExtra("wei.mark.standout.data");
int requestCode = intent.getIntExtra("requestCode", 0);
@SuppressWarnings("unchecked")
Class<? extends StandOutWindow> fromCls = (Class<? extends StandOutWindow>) intent.getSerializableExtra("wei.mark.standout.fromCls");
int fromId = intent.getIntExtra("fromId", DEFAULT_ID);
onReceiveData(corner, requestCode, data, fromCls, fromId);
}
}
}
return START_NOT_STICKY;
}

@Override
public boolean onClose(final int corner, final Window window) {
running = false;
return false;
}

@Override
public String getPersistentNotificationTitle(int corner) {
return "Rounded Corners";
}

@SuppressLint({ "InlinedApi", "NewApi" })
@SuppressWarnings("deprecation")
@Override
public Notification getPersistentNotification(int id) {
int icon = getAppIcon();
long when = System.currentTimeMillis();
Context c = getApplicationContext();
String contentTitle = getPersistentNotificationTitle(id);
String contentText = getPersistentNotificationMessage(id);

Intent notificationIntent = getPersistentNotificationIntent(id);

PendingIntent contentIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

// 4.1+ Low priority notification
final int apiLevel = Build.VERSION.SDK_INT;
if (apiLevel >= 16) {
Notification.Builder mBuilder = new Notification.Builder(this).setContent(new RemoteViews(getPackageName(), R.layout.notification)).setSmallIcon(getAppIcon()).setContentTitle(contentTitle).setContentText(contentText).setPriority(Notification.PRIORITY_MIN).setContentIntent(contentIntent);
return mBuilder.build();
}

String tickerText = String.format("%s: %s", contentTitle, contentText);

Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(c, contentTitle, contentText, contentIntent);

return notification;
}

@Override
public boolean onShow(final int corner, final Window window) {
running = true;
return false;
}

@Override
public void onReceiveData(int corner, int requestCode, Bundle data, Class<? extends StandOutWindow> fromCls, int fromId) {
Window window = getWindow(corner);
if (requestCode == UPDATE_CODE) {
// Update the corners when device is rotated
updateViewLayout(3, getParams(3, window));
updateViewLayout(2, getParams(2, window));
updateViewLayout(1, getParams(1, window));
updateViewLayout(0, getParams(0, window));
} else if (requestCode == NOTIFICATION_CODE) {
if (!prefs.getBoolean("notification", true)) {
// Hide Notification Icon (for <= Gingerbread devices only)
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = getPersistentNotification(corner);
notification.icon = wei.mark.standout.R.drawable.nothing;
mNotificationManager.notify(getClass().hashCode() + ONGOING_NOTIFICATION_ID, notification);
Log.d("Hello World", "");
} else {
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = getPersistentNotification(corner);
mNotificationManager.notify(getClass().hashCode() + ONGOING_NOTIFICATION_ID, notification);
}
}
}
}
SeekBarPreference:
Code:
 package mohammad.adib.roundr;

import wei.mark.standout.StandOutWindow;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.preference.Preference;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class SeekBarPreference extends Preference implements OnSeekBarChangeListener {

private final String TAG = getClass().getName();

private static final String ANDROIDNS = "http://schemas.android.com/apk/res/android";
private static final String ROUNDRNS = "roundrprefs";
private static final int DEFAULT_VALUE = 50;

private int mMaxValue = 100;
private int mMinValue = 0;
private int mInterval = 1;
private int mCurrentValue;
private String mUnitsLeft = "";
private String mUnitsRight = "";
private SeekBar mSeekBar;
private Context context;

private TextView mStatusText;

public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
initPreference(context, attrs);
}

public SeekBarPreference(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initPreference(context, attrs);
}

private void initPreference(Context context, AttributeSet attrs) {
setValuesFromXml(attrs);
mSeekBar = new SeekBar(context, attrs);
mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);
}

private void setValuesFromXml(AttributeSet attrs) {
mMaxValue = attrs.getAttributeIntValue(ANDROIDNS, "max", 100);
mMinValue = attrs.getAttributeIntValue(ROUNDRNS, "min", 0);

mUnitsLeft = getAttributeStringValue(attrs, ROUNDRNS, "unitsLeft", "");
String units = getAttributeStringValue(attrs, ROUNDRNS, "units", "");
mUnitsRight = getAttributeStringValue(attrs, ROUNDRNS, "unitsRight", units);

try {
String newInterval = attrs.getAttributeValue(ROUNDRNS, "interval");
if (newInterval != null)
mInterval = Integer.parseInt(newInterval);
} catch (Exception e) {
Log.e(TAG, "Invalid interval value", e);
}

}

private String getAttributeStringValue(AttributeSet attrs, String namespace, String name, String defaultValue) {
String value = attrs.getAttributeValue(namespace, name);
if (value == null)
value = defaultValue;

return value;
}

@Override
protected View onCreateView(ViewGroup parent) {

RelativeLayout layout = null;

try {
LayoutInflater mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

layout = (RelativeLayout) mInflater.inflate(R.layout.seek_bar_preference, parent, false);
} catch (Exception e) {
Log.e(TAG, "Error creating seek bar preference", e);
}

return layout;

}

@Override
public void onBindView(View view) {
super.onBindView(view);

try {
// move our seekbar to the new view we've been given
ViewParent oldContainer = mSeekBar.getParent();
ViewGroup newContainer = (ViewGroup) view.findViewById(R.id.seekBarPrefBarContainer);

if (oldContainer != newContainer) {
// remove the seekbar from the old view
if (oldContainer != null) {
((ViewGroup) oldContainer).removeView(mSeekBar);
}
// remove the existing seekbar (there may not be one) and add
// ours
newContainer.removeAllViews();
newContainer.addView(mSeekBar, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
} catch (Exception ex) {
Log.e(TAG, "Error binding view: " + ex.toString());
}

updateView(view);
}

/**
 * Update a SeekBarPreference view with our current state
 * 
 * @param view
 */
protected void updateView(View view) {

try {
RelativeLayout layout = (RelativeLayout) view;

mStatusText = (TextView) layout.findViewById(R.id.seekBarPrefValue);
mStatusText.setText(String.valueOf(pxFromDp(mCurrentValue)));
mStatusText.setMinimumWidth(30);

mSeekBar.setProgress(mCurrentValue - mMinValue);

} catch (Exception e) {
Log.e(TAG, "Error updating seek bar preference", e);
}

}

private int pxFromDp(double dp) {
return (int) (dp * context.getResources().getDisplayMetrics().density);
}

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int newValue = progress + mMinValue;

if (newValue > mMaxValue)
newValue = mMaxValue;
else if (newValue < mMinValue)
newValue = mMinValue;
else if (mInterval != 1 && newValue % mInterval != 0)
newValue = Math.round(((float) newValue) / mInterval) * mInterval;

// change rejected, revert to the previous value
if (!callChangeListener(newValue)) {
seekBar.setProgress(mCurrentValue - mMinValue);
return;
}

// change accepted, store it
mCurrentValue = newValue;
mStatusText.setText(String.valueOf(pxFromDp(newValue)));
persistInt(newValue);
// Refresh the corners to apply the new radius
StandOutWindow.sendData(context, Corner.class, Corner.wildcard, Corner.UPDATE_CODE, new Bundle(), Corner.class, StandOutWindow.DISREGARD_ID);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {
notifyChanged();
}

@Override
protected Object onGetDefaultValue(TypedArray ta, int index) {

int defaultValue = ta.getInt(index, DEFAULT_VALUE);
return defaultValue;

}

@Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {

if (restoreValue) {
mCurrentValue = getPersistedInt(mCurrentValue);
} else {
int temp = 0;
try {
temp = (Integer) defaultValue;
} catch (Exception ex) {
Log.e(TAG, "Invalid default value: " + defaultValue.toString());
}

persistInt(temp);
mCurrentValue = temp;
}

}

}
SettingsActivity.java:
Code:
 package mohammad.adib.roundr;

import wei.mark.standout.StandOutWindow;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.util.Log;
import android.view.WindowManager.LayoutParams;

public class SettingsActivity extends PreferenceActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
/**
 * Handle Preference Changes
 */
// Enable/Disable
((Preference) findPreference("enable")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean isChecked = (Boolean) newValue;
if (isChecked) {
StandOutWindow.show(SettingsActivity.this, Corner.class, 0);
StandOutWindow.show(SettingsActivity.this, Corner.class, 1);
StandOutWindow.show(SettingsActivity.this, Corner.class, 2);
StandOutWindow.show(SettingsActivity.this, Corner.class, 3);
} else {
StandOutWindow.closeAll(SettingsActivity.this, Corner.class);
}
return true;
}
});
// Notification
final int apiLevel = Build.VERSION.SDK_INT;
if (apiLevel >= 16) {
((Preference) findPreference("notification")).setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
new AlertDialog.Builder(SettingsActivity.this).setTitle("Notification").setMessage("The notification prevents Android from killing RoundR in low memory situations.\n\nOn Android 4.1+ devices, it can be disabled via the App Info.").setPositiveButton("Continue", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
showInstalledAppDetails("mohammad.adib.roundr");
}
}).show();
return true;
}
});
}else{
((Preference) findPreference("notification")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
StandOutWindow.sendData(SettingsActivity.this, Corner.class, Corner.wildcard, Corner.NOTIFICATION_CODE, new Bundle(), Corner.class, StandOutWindow.DISREGARD_ID);
return true;
}
});
}
// Enable specific corners
for (int i = 0; i < 4; i++) {
((Preference) findPreference("corner" + i)).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
refresh();
return true;
}
});
}
/**
 * Overlap Settings TODO: These are messy
 */
((Preference) findPreference("overlap1")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean isChecked = (Boolean) newValue;
if (isChecked) {
prefs.edit().putInt("type", LayoutParams.TYPE_SYSTEM_OVERLAY).commit();
if (prefs.getBoolean("overlap2", false))
prefs.edit().putInt("flags", LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_LAYOUT_IN_SCREEN).commit();
else
prefs.edit().putInt("flags", LayoutParams.FLAG_SHOW_WHEN_LOCKED).commit();
} else {
prefs.edit().putInt("type", LayoutParams.TYPE_SYSTEM_ALERT).commit();
if (prefs.getBoolean("overlap2", false))
prefs.edit().putInt("flags", LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_LAYOUT_IN_SCREEN).commit();
else
prefs.edit().putInt("flags", LayoutParams.FLAG_NOT_TOUCH_MODAL).commit();
}
new Thread(new Runnable() {

@Override
public void run() {
// Disable and Re-enable the corners
StandOutWindow.closeAll(SettingsActivity.this, Corner.class);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
StandOutWindow.show(SettingsActivity.this, Corner.class, 0);
StandOutWindow.show(SettingsActivity.this, Corner.class, 1);
StandOutWindow.show(SettingsActivity.this, Corner.class, 2);
StandOutWindow.show(SettingsActivity.this, Corner.class, 3);
}

}).start();
return true;
}
});
((Preference) findPreference("overlap2")).setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean isChecked = (Boolean) newValue;
if (isChecked) {
if (prefs.getBoolean("overlap", true))
prefs.edit().putInt("flags", LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_LAYOUT_IN_SCREEN).commit();
else
prefs.edit().putInt("flags", LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | LayoutParams.FLAG_LAYOUT_IN_SCREEN).commit();
} else {
if (prefs.getBoolean("overlap", true))
prefs.edit().putInt("flags", LayoutParams.FLAG_SHOW_WHEN_LOCKED).commit();
else
prefs.edit().putInt("flags", LayoutParams.FLAG_NOT_TOUCH_MODAL | LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH).commit();
}
new Thread(new Runnable() {

@Override
public void run() {
// Disable and Reenable the corners
StandOutWindow.closeAll(SettingsActivity.this, Corner.class);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
StandOutWindow.show(SettingsActivity.this, Corner.class, 0);
StandOutWindow.show(SettingsActivity.this, Corner.class, 1);
StandOutWindow.show(SettingsActivity.this, Corner.class, 2);
StandOutWindow.show(SettingsActivity.this, Corner.class, 3);
}

}).start();
return true;
}
});
/**
 * TODO: Figure out if Developer Options is enabled. If so, show a
 * GitHub Source Code Link preference:
 * "Seems like you are a developer? Check out the RoundR source code on GitHub!"
 */
}

/*
 * Sends a signal to all the corners to refresh their layout parameters,
 * which in turn refreshes their size.
 */
public void refresh() {
StandOutWindow.sendData(this, Corner.class, Corner.wildcard, Corner.UPDATE_CODE, new Bundle(), Corner.class, StandOutWindow.DISREGARD_ID);
}

@SuppressLint("InlinedApi")
public void showInstalledAppDetails(String packageName) {
Intent intent = new Intent();
intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", packageName, null);
intent.setData(uri);
startActivity(intent);
}
}
preferences.xml:
Code:
 <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:roundr="roundrprefs" >

    <PreferenceCategory android:title="General Settings" >
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="enable"
            android:summary="Enable rounded screen corners"
            android:title="Enable RoundR" />
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="start_on_boot"
            android:summary="Start RoundR automatically on boot"
            android:title="Start on boot" />
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="notification"
            android:summary="The notification is required to keep RoundR running in low memory situations"
            android:title="Visible Notification" />
    </PreferenceCategory>
    <PreferenceCategory android:title="RoundR Settings" >
        <PreferenceScreen
            android:dependency="enable"
            android:persistent="false"
            android:summary="Enable rounding on specific corners"
            android:title="Enabled Corners" >
            <CheckBoxPreference
                android:defaultValue="true"
                android:key="corner0"
                android:title="Top Left" />
            <CheckBoxPreference
                android:defaultValue="true"
                android:key="corner1"
                android:title="Top Right" />
            <CheckBoxPreference
                android:defaultValue="true"
                android:key="corner2"
                android:title="Bottom Left" />
            <CheckBoxPreference
                android:defaultValue="true"
                android:key="corner3"
                android:title="Bottom Right" />
        </PreferenceScreen>

        <mohammad.adib.roundr.SeekBarPreference
            android:defaultValue="10"
            android:key="radius"
            android:max="40"
            android:title="Corner Radius"
            roundr:min="2"
            roundr:unitsLeft=""
            roundr:unitsRight="" />

        <CheckBoxPreference
            android:defaultValue="true"
            android:key="overlap1"
            android:summary="This also constitutes overlaping of the corners on the notification pull-down"
            android:title="Enable on lockscreen" />
        <CheckBoxPreference
            android:defaultValue="false"
            android:key="overlap2"
            android:summary="Allows for the corners to overlap the status bar"
            android:title="Overlap Status Bar" />
    </PreferenceCategory>

</PreferenceScreen>

Can u help me? where is the specific code that i need, i was trying to find it for hours...

Enviado desde mi GT-S5570I usando Tapatalk 2
It's this particular code change: https://github.com/MohammadAdib/Roun...f48e95a1d369fa
The Following User Says Thank You to nikwen For This Useful Post: [ Click to Expand ]
 
DannyGM16
Old
#13  
DannyGM16's Avatar
Senior Member - OP
Thanks Meter 12
Posts: 131
Join Date: Jul 2013
Quote:
Originally Posted by nikwen View Post
IT WORK'S! IT WORK'S! THANK'S!
But the problem now i how to get clicks from it. Do you know how to do it?

Enviado desde mi GT-S5570I usando Tapatalk 2
 
nikwen
Old
#14  
nikwen's Avatar
Recognized Contributor
Thanks Meter 1231
Posts: 2,611
Join Date: Feb 2013
Quote:
Originally Posted by DannyGM16 View Post
IT WORK'S! IT WORK'S! THANK'S!
But the problem now i how to get clicks from it. Do you know how to do it?

Enviado desde mi GT-S5570I usando Tapatalk 2
Great.

What's about adding an onClick listener?
 
DannyGM16
Old
#15  
DannyGM16's Avatar
Senior Member - OP
Thanks Meter 12
Posts: 131
Join Date: Jul 2013
Quote:
Originally Posted by nikwen View Post
Great.

What's about adding an onClick listener?
I tryed it, but the onClick affects to all the screen...

Enviado desde mi GT-S5570I usando Tapatalk 2
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes