Skip to content

Commit

Permalink
the floating window shows the password correctly now
Browse files Browse the repository at this point in the history
  • Loading branch information
shunix committed Jan 21, 2016
1 parent 3d46bac commit 714d84d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ private void startActivity(Class<? extends Activity> clazz) {
private void showFloatingWindow() {
Intent intent = new Intent(FloatingService.INTENT_ACTION);
intent.putExtra(FloatingService.KEY, FloatingService.SHOW_FLOATING_WINDOW);
DatabaseManager.PasswordEntity entity = mAdapter.getItem(mSelection);
if (entity != null) {
intent.putExtra(FloatingService.DATA, entity.password);
}
sendBroadcast(intent);
mActionMode.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.*;
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
Expand All @@ -19,14 +20,17 @@ public class FloatingService extends Service {
public final static short SHOW_FLOATING_WINDOW = 0;
public final static short HIDE_FLOATING_WINDOW = 1;
public final static String KEY = "action";
public final static String DATA = "data";
public final static String INTENT_ACTION = "com.shunix.encryptor.action";
private boolean mIsShow = false;
private String mData;
private View mFloatingView;
private WindowManager mWindowManager;
BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
short action = intent.getShortExtra(KEY, HIDE_FLOATING_WINDOW);
mData = intent.getStringExtra(DATA);
switch (action) {
case SHOW_FLOATING_WINDOW:
showFloatingWindow();
Expand Down Expand Up @@ -65,6 +69,9 @@ public void onDestroy() {

private void showFloatingWindow() {
if (mIsShow) {
if (!TextUtils.isEmpty(mData) && !mData.equals(((FloatingView) mFloatingView).getText())) {
((FloatingView) mFloatingView).setText(mData);
}
return;
}
buildFloatingView();
Expand Down Expand Up @@ -99,7 +106,9 @@ private void hideFloatingWindow() {
private void buildFloatingView() {
if (mFloatingView == null) {
mFloatingView = new FloatingView(getApplicationContext());
((FloatingView) mFloatingView).setText("TEST");
if (!TextUtils.isEmpty(mData) && !mData.equals(((FloatingView) mFloatingView).getText())) {
((FloatingView) mFloatingView).setText(mData);
}
}
}

Expand Down

0 comments on commit 714d84d

Please sign in to comment.