commit c75135f2883993055565e68b50f0b29d8908ecf1 Author: erik Date: Sun May 20 22:34:31 2012 -0700 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f4ceb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/bin +/gen +/project.properties +/proguard-project.txt +/.classpath +/.project \ No newline at end of file diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..68accac --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/avion.png b/avion.png new file mode 100644 index 0000000..47ac887 Binary files /dev/null and b/avion.png differ diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..5005e81 Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ diff --git a/res/drawable-ldpi/ic_launcher.png b/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 0000000..159121e Binary files /dev/null and b/res/drawable-ldpi/ic_launcher.png differ diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..e562125 Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..9146a78 Binary files /dev/null and b/res/drawable-xhdpi/ic_launcher.png differ diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml new file mode 100644 index 0000000..d41e83e --- /dev/null +++ b/res/values-fr/strings.xml @@ -0,0 +1,9 @@ + + + Avion + Mode Avion + Mode Avion activée + Mode Avion désactivé + OK + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..47a990c --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,9 @@ + + + Plane + Airplane Mode + Airplane Mode activated + Airplane Mode deactivated + OK + + \ No newline at end of file diff --git a/src/net/thauvin/erik/android/avion/AvionActivity.java b/src/net/thauvin/erik/android/avion/AvionActivity.java new file mode 100644 index 0000000..93733a1 --- /dev/null +++ b/src/net/thauvin/erik/android/avion/AvionActivity.java @@ -0,0 +1,102 @@ +/* + * AvionActivity.java + * + * Copyright (c) 2012 Erik C. Thauvin (http://erik.thauvin.net/) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * Neither the name of the authors nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +package net.thauvin.erik.android.avion; + +/** + * The AvionActivity class implements an airplane mode toggler. + * + * @author Erik C. Thauvin + * @created May 20, 2012 + * @since 1.0 + */ +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.content.Intent; +import android.os.Bundle; +import android.provider.Settings; + +public class AvionActivity extends Activity +{ + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + // Get the airplane mode status + boolean isEnabled = (Settings.System.getInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1); + + // Toggle airplane mode + Settings.System.putInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1); + + // Send intent to refresh status + final Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); + intent.putExtra("state", !isEnabled); + sendBroadcast(intent); + + // Create Dialog + final AlertDialog alertDialog = new AlertDialog.Builder(this).create(); + + // Set Dialog Icon + alertDialog.setIcon(R.drawable.ic_launcher); + + // Set Dialog Title + alertDialog.setTitle(R.string.title); + + // Set Dialog Message + if (isEnabled) + { + alertDialog.setMessage(getString(R.string.deactivated)); + } + else + { + alertDialog.setMessage(getString(R.string.activated)); + } + + // Set OK button + alertDialog.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() + { + public void onClick(DialogInterface dialog, int which) + { + // Terminate activity + AvionActivity.this.finish(); + } + }); + + // Show Alert Message + alertDialog.show(); + } +} \ No newline at end of file