Exit button in status bar

This commit is contained in:
Sylvain Berfini 2012-07-18 16:26:27 +02:00
parent cc656726e1
commit 606b19b15c
4 changed files with 27 additions and 11 deletions

View file

@ -20,11 +20,6 @@
android:layout_height="match_parent"
android:background="@android:color/black">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/menu_exit" />
</RelativeLayout>
<RelativeLayout
@ -70,6 +65,14 @@
android:src="@drawable/security_pending"
android:visibility="gone"
android:layout_alignParentRight="true" />
<TextView
android:id="@+id/exit"
android:text="EXIT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="10dp" />
</RelativeLayout>

View file

@ -593,12 +593,16 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
return chatStorage;
}
public void exit() {
finish();
stopService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_FIRST_USER && requestCode == SETTINGS_ACTIVITY) {
if (data.getExtras().getBoolean("Exit", false)) {
finish();
stopService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
exit();
} else {
FragmentsAvailable newFragment = (FragmentsAvailable) data.getExtras().getSerializable("FragmentToDisplay");
changeCurrentFragment(newFragment, null, true);

View file

@ -28,6 +28,7 @@ import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
@ -57,6 +58,12 @@ public class StatusFragment extends Fragment {
encryption = (ImageView) view.findViewById(R.id.encryption);
drawer = (SlidingDrawer) view.findViewById(R.id.statusBar);
view.findViewById(R.id.exit).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
LinphoneActivity.instance().exit();
}
});
return view;
}
@ -194,7 +201,9 @@ public class StatusFragment extends Fragment {
drawer.lock();
}
} else {
if (drawer != null && !getResources().getBoolean(R.bool.lock_statusbar)) {
if (drawer != null && getResources().getBoolean(R.bool.lock_statusbar)) {
drawer.lock();
} else if (drawer != null) {
drawer.unlock();
}
}

View file

@ -417,13 +417,13 @@ public class SlidingDrawer extends ViewGroup {
mVelocityTracker.addMovement(event);
}
return true;
return onTouchEvent(event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mLocked) {
return true;
return false;
}
if (mTracking) {
@ -534,7 +534,7 @@ public class SlidingDrawer extends ViewGroup {
}
}
return mTracking || mAnimating || super.onTouchEvent(event);
return false;
}
private void animateClose(int position) {