Android Open Source - PhoneAsTablet Notification Buttons Handler






From Project

Back to project page PhoneAsTablet.

License

The source code is released under:

GNU General Public License

If you think the Android project PhoneAsTablet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 */* ww  w.  j a va2 s .  c o  m*/
 */
package info.bits.phoneastablet.utils;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;

import java.io.IOException;

import info.bits.phoneastablet.Resolution;

/**
 * @author little
 */
public class NotificationButtonsHandler extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        String action = (String) getIntent().getExtras().get("DO");
        if (action.equals("custom") || action.equals("default")) {
            try {
                applyResolution(action);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else if (action.equals("app")) {
            Intent app = new Intent(this, Resolution.class);
            startActivity(app);
        }
        finish();
    }

    @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }

    private void applyResolution(String ResolutionApplied) throws IOException {
        int orientation = getResources().getConfiguration().orientation;
        DatabaseHandler dbHandler = new DatabaseHandler(this);
        if (ResolutionApplied.equals("custom")) {
            if (orientation == Configuration.ORIENTATION_PORTRAIT) {
                String width = dbHandler.getDimension(DatabaseHandler.KEY_PORTRAIT_WIDTH,
                        DatabaseHandler.TABLE_LATEST_RESOLUTIONS);
                String height = dbHandler.getDimension(DatabaseHandler.KEY_PORTRAIT_HEIGHT,
                        DatabaseHandler.TABLE_LATEST_RESOLUTIONS);
                SuCommands.changeResolution(width, height);
            } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
                String width = dbHandler.getDimension(DatabaseHandler.KEY_LANDSCAPE_WIDTH,
                        DatabaseHandler.TABLE_LATEST_RESOLUTIONS);
                String height = dbHandler.getDimension(DatabaseHandler.KEY_LANDSCAPE_HEIGHT,
                        DatabaseHandler.TABLE_LATEST_RESOLUTIONS);
                SuCommands.changeResolution(width, height);
            }
        } else {
            SuCommands.fallbackToDefaultResolution();
        }
    }
}




Java Source Code List

info.bits.phoneastablet.ApplicationTest.java
info.bits.phoneastablet.Resolution.java
info.bits.phoneastablet.listeners.MyOnCheckedListener.java
info.bits.phoneastablet.listeners.MyTextWatcher.java
info.bits.phoneastablet.listeners.package-info.java
info.bits.phoneastablet.receivers.BootCompletedReceiver.java
info.bits.phoneastablet.receivers.OrientationReceiver.java
info.bits.phoneastablet.receivers.package-info.java
info.bits.phoneastablet.services.OrientationService.java
info.bits.phoneastablet.services.package-info.java
info.bits.phoneastablet.utils.DatabaseHandler.java
info.bits.phoneastablet.utils.NotificationButtonsHandler.java
info.bits.phoneastablet.utils.NotificationHandler.java
info.bits.phoneastablet.utils.SuCommands.java
info.bits.phoneastablet.utils.package-info.java