Android Open Source - 24hAnalogWidget Analog Clock Application






From Project

Back to project page 24hAnalogWidget.

License

The source code is released under:

GNU General Public License

If you think the Android project 24hAnalogWidget 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

package info.staticfree.android.twentyfourhour;
//from  w w  w.  ja v a2s .  c  om
import android.app.Application;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;

public class AnalogClockApplication extends Application {

    private static final String TAG = AnalogClockApplication.class.getSimpleName();

    @Override
    public void onCreate() {
        super.onCreate();

        new DisableWidgetTask().execute();
    }

    /**
     * Disables the fixed-sized widgets for Android 3.0+, otherwise disables resizable one.
     */
    private void disableWidgetSizes() {

        final PackageManager pm = getPackageManager();

        // for versions 3.0+ we use the resizable widget instead of having multiple pre-defined
        // sizes.
        final boolean supportsResize = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;

        // resizable widget

        pm.setComponentEnabledSetting(new ComponentName(this,
                        TwentyFourHourClockWidgetResizable.class),
                supportsResize ? PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
                        : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);

        // fixed size widgets

        pm.setComponentEnabledSetting(new ComponentName(this, TwentyFourHourClockWidget.class),
                supportsResize ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
                PackageManager.DONT_KILL_APP);

        pm.setComponentEnabledSetting(new ComponentName(this, TwentyFourHourClockWidget3x.class),
                supportsResize ? PackageManager.COMPONENT_ENABLED_STATE_DISABLED
                        : PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
                PackageManager.DONT_KILL_APP);

        Log.d(TAG, "Resizable widgets are: " + (supportsResize ? "enabled" : "disabled"));
    }

    private class DisableWidgetTask extends AsyncTask<Void, Void, Boolean> {

        @Override
        protected Boolean doInBackground(Void... params) {
            disableWidgetSizes();
            return true;
        }
    }
}




Java Source Code List

info.staticfree.android.twentyfourhour.Analog24HClock.java
info.staticfree.android.twentyfourhour.AnalogClockApplication.java
info.staticfree.android.twentyfourhour.ClockUtil.java
info.staticfree.android.twentyfourhour.TwentyFourHourClockWidget3x.java
info.staticfree.android.twentyfourhour.TwentyFourHourClockWidgetResizable.java
info.staticfree.android.twentyfourhour.TwentyFourHourClockWidget.java
info.staticfree.android.twentyfourhour.WearFace.java
info.staticfree.android.twentyfourhour.WidgetDemo.java
info.staticfree.android.twentyfourhour.overlay.DateOverlay.java
info.staticfree.android.twentyfourhour.overlay.DebugOverlay.java
info.staticfree.android.twentyfourhour.overlay.DialOverlay.java
info.staticfree.android.twentyfourhour.overlay.HandsOverlay.java
info.staticfree.android.twentyfourhour.overlay.SunPositionOverlay.java
twentyfourhour.WearFaceDemoActivity.java