Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * This is the source code of VshGap for Android v. 1.4.x.
 * It is licensed under GNU GPL v. 2 or later.
 * You should have received a copy of the license in this archive (see LICENSE).
 *
 * Copyright Nikolai Kudashov, 2013-2014.
 */

import android.content.Context;

import android.graphics.Color;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;

public class Main {
    public static final String THEME_PREFS = "theme";

    public static Drawable paintGradient(Context c, int mainColor, String gColor, String g) {
        GradientDrawable gd = null;
        int[] a = { mainColor, getIntPref(c, gColor) };
        int gType = Integer.parseInt(c.getSharedPreferences(THEME_PREFS, 0).getString(g, "0"));
        if (gType == 2)
            gd = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, a);
        if (gType == 1)
            gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, a);
        return gd;
    }

    public static int getIntPref(Context context, String key) {
        int i = 0;
        if (key.contains("picker")) {
            int intColor = context.getSharedPreferences(THEME_PREFS, 0).getInt(key, Color.WHITE);
            i = intColor;
        }
        return i;
    }
}