Search in sources :

Example 26 with TypedArray

use of android.content.res.TypedArray in project Talon-for-Twitter by klinker24.

the class InteractionsCursorAdapter method setUpLayout.

public void setUpLayout() {
    talonLayout = settings.layout == AppSettings.LAYOUT_TALON;
    layout = R.layout.interaction;
    TypedArray b;
    if (talonLayout) {
        b = context.getTheme().obtainStyledAttributes(new int[] { R.attr.circleBorder });
    } else {
        b = context.getTheme().obtainStyledAttributes(new int[] { R.attr.squareBorder });
    }
    border = b.getResourceId(0, 0);
    b.recycle();
    mCache = App.getInstance(context).getBitmapCache();
    b = context.getTheme().obtainStyledAttributes(new int[] { R.attr.message_color });
    color = new ColorDrawable(context.getResources().getColor(b.getResourceId(0, 0)));
    b.recycle();
    transparent = new ColorDrawable(context.getResources().getColor(android.R.color.transparent));
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) TypedArray(android.content.res.TypedArray)

Example 27 with TypedArray

use of android.content.res.TypedArray in project Talon-for-Twitter by klinker24.

the class TimeLineCursorAdapter method getFavoriteCount.

public void getFavoriteCount(final ViewHolder holder, final long tweetId) {
    Thread getCount = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                Twitter twitter = getTwitter();
                final Status status;
                if (holder.retweeter.getVisibility() != View.GONE) {
                    status = twitter.showStatus(holder.tweetId).getRetweetedStatus();
                } else {
                    status = twitter.showStatus(tweetId);
                }
                if (status != null && holder.tweetId == tweetId) {
                    ((Activity) context).runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            holder.favCount.setText(" " + status.getFavoriteCount());
                            if (status.isFavorited()) {
                                TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();
                                if (!settings.addonTheme) {
                                    holder.favorite.setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    holder.favorite.setColorFilter(settings.accentInt);
                                }
                                holder.favorite.setImageDrawable(context.getResources().getDrawable(resource));
                                holder.isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();
                                holder.favorite.setImageDrawable(context.getResources().getDrawable(resource));
                                holder.isFavorited = false;
                                holder.favorite.clearColorFilter();
                            }
                        }
                    });
                }
            } catch (Exception e) {
            }
        }
    });
    getCount.setPriority(7);
    getCount.start();
}
Also used : Status(twitter4j.Status) TypedArray(android.content.res.TypedArray) Twitter(twitter4j.Twitter) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) TwitterException(twitter4j.TwitterException) IOException(java.io.IOException)

Example 28 with TypedArray

use of android.content.res.TypedArray in project Talon-for-Twitter by klinker24.

the class Compose method onBackPressed.

@Override
public void onBackPressed() {
    if (emojiKeyboard.isShowing()) {
        emojiKeyboard.setVisibility(false);
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.emoji_button_changing });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        emojiButton.setImageResource(resource);
        return;
    }
    super.onBackPressed();
}
Also used : TypedArray(android.content.res.TypedArray) Point(android.graphics.Point)

Example 29 with TypedArray

use of android.content.res.TypedArray in project Talon-for-Twitter by klinker24.

the class SettingsActivityOld method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit);
    AppSettings.invalidate();
    setUpTheme();
    setContentView(R.layout.settings_main);
    DrawerArrayAdapter.current = 0;
    linkItems = new String[] { getResources().getString(R.string.get_help_settings), getResources().getString(R.string.other_apps), getResources().getString(R.string.whats_new), getResources().getString(R.string.rate_it) };
    settingsItems = new String[] { getResources().getString(R.string.ui_settings), getResources().getString(R.string.timelines_settings), getResources().getString(R.string.sync_settings), getResources().getString(R.string.notification_settings), getResources().getString(R.string.browser_settings), getResources().getString(R.string.advanced_settings), getResources().getString(R.string.memory_manage) };
    sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    if (sharedPrefs.getBoolean("version_1.20_1", true)) {
        // necessary because i didnt start out by using sets
        boolean led = sharedPrefs.getBoolean("led", true);
        boolean sound = sharedPrefs.getBoolean("sound", true);
        boolean vibrate = sharedPrefs.getBoolean("vibrate", true);
        boolean wakeScreen = sharedPrefs.getBoolean("wake", true);
        boolean timelineNot = sharedPrefs.getBoolean("timeline_notifications", true);
        boolean mentionsNot = sharedPrefs.getBoolean("mentions_notifications", true);
        boolean dmsNot = sharedPrefs.getBoolean("direct_message_notifications", true);
        boolean favoritesNot = sharedPrefs.getBoolean("favorite_notifications", true);
        boolean retweetNot = sharedPrefs.getBoolean("retweet_notifications", true);
        boolean followersNot = sharedPrefs.getBoolean("follower_notifications", true);
        Set<String> alert = sharedPrefs.getStringSet("alert_types", new HashSet<String>());
        alert.clear();
        if (vibrate) {
            alert.add("1");
        }
        if (led) {
            alert.add("2");
        }
        if (wakeScreen) {
            alert.add("3");
        }
        if (sound) {
            alert.add("4");
        }
        sharedPrefs.edit().putStringSet("alert_types", alert).commit();
        Set<String> timeline = sharedPrefs.getStringSet("timeline_set", new HashSet<String>());
        timeline.clear();
        if (timelineNot) {
            timeline.add("1");
        }
        if (mentionsNot) {
            timeline.add("2");
        }
        if (dmsNot) {
            timeline.add("3");
        }
        sharedPrefs.edit().putStringSet("timeline_set", timeline).commit();
        Set<String> interactions = sharedPrefs.getStringSet("interactions_set", new HashSet<String>());
        interactions.clear();
        if (favoritesNot) {
            interactions.add("1");
        }
        if (retweetNot) {
            interactions.add("2");
        }
        if (followersNot) {
            interactions.add("3");
        }
        sharedPrefs.edit().putStringSet("interactions_set", interactions).commit();
        sharedPrefs.edit().putBoolean("version_1.20_1", false).commit();
        recreate();
    }
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager(), this, otherList);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
    otherList = (ListView) findViewById(R.id.other_list);
    settingsList = (ListView) findViewById(R.id.settings_list);
    mDrawer = (LinearLayout) findViewById(R.id.drawer);
    // Set the adapter for the list view
    otherList.setAdapter(new DrawerArrayAdapter(this, new ArrayList<String>(Arrays.asList(linkItems))));
    settingsList.setAdapter(new DrawerArrayAdapter(this, new ArrayList<String>(Arrays.asList(settingsItems))));
    // Set the list's click listener
    settingsList.setOnItemClickListener(new SettingsDrawerClickListener(this, mDrawerLayout, settingsList, mViewPager, mDrawer));
    otherList.setOnItemClickListener(new SettingsLinkDrawerClickListener(this, mDrawerLayout, otherList, mViewPager, mDrawer));
    findViewById(R.id.settingsLinks).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            switchToSettingsList(true);
            settingsLinksActive = true;
            findViewById(R.id.settingsSelector).setVisibility(View.VISIBLE);
            findViewById(R.id.otherSelector).setVisibility(View.INVISIBLE);
        }
    });
    findViewById(R.id.otherLinks).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            switchToSettingsList(false);
            settingsLinksActive = false;
            findViewById(R.id.settingsSelector).setVisibility(View.INVISIBLE);
            findViewById(R.id.otherSelector).setVisibility(View.VISIBLE);
        }
    });
    if (settingsLinksActive) {
        settingsList.setVisibility(View.VISIBLE);
        otherList.setVisibility(View.GONE);
        findViewById(R.id.settingsSelector).setVisibility(View.VISIBLE);
        findViewById(R.id.otherSelector).setVisibility(View.INVISIBLE);
    } else {
        settingsList.setVisibility(View.GONE);
        otherList.setVisibility(View.VISIBLE);
        findViewById(R.id.settingsSelector).setVisibility(View.INVISIBLE);
        findViewById(R.id.otherSelector).setVisibility(View.VISIBLE);
    }
    TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon });
    int resource = a.getResourceId(0, 0);
    a.recycle();
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    resource, /* nav drawer icon to replace 'Up' caret */
    R.string.app_name, /* "open drawer" description */
    R.string.app_name);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    userKnows = sharedPrefs.getBoolean("user_knows_navigation_drawer", false);
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        public void onPageScrollStateChanged(int state) {
        }

        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        public void onPageSelected(int position) {
            DrawerArrayAdapter.current = position;
            otherList.invalidateViews();
            settingsList.invalidateViews();
        }
    });
    if (!userKnows) {
        mDrawerLayout.openDrawer(mDrawer);
    }
    HoloTextView createdBy = (HoloTextView) findViewById(R.id.created_by);
    HoloTextView versionNumber = (HoloTextView) findViewById(R.id.version_number);
    try {
        String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
        String text = getResources().getString(R.string.created_by) + " Luke Klinker";
        String text2 = getResources().getString(R.string.version) + " " + versionName;
        createdBy.setText(text);
        versionNumber.setText(text2);
    } catch (Exception e) {
        String text = getResources().getString(R.string.created_by) + " Luke Klinker";
        String text2 = getResources().getString(R.string.version) + " 0.00";
        createdBy.setText(text);
        versionNumber.setText(text2);
    }
    LinearLayout description = (LinearLayout) findViewById(R.id.created_by_layout);
    description.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=Klinker+Apps")));
        }
    });
    mDrawerLayout.openDrawer(Gravity.START);
}
Also used : ArrayList(java.util.ArrayList) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) Intent(android.content.Intent) HoloTextView(com.klinker.android.twitter.views.HoloTextView) HoloTextView(com.klinker.android.twitter.views.HoloTextView) View(android.view.View) ListView(android.widget.ListView) ViewPager(android.support.v4.view.ViewPager) TypedArray(android.content.res.TypedArray) LinearLayout(android.widget.LinearLayout)

Example 30 with TypedArray

use of android.content.res.TypedArray in project Talon-for-Twitter by klinker24.

the class PrefActivity method setIcon.

public void setIcon(ActionBar ab, int position) {
    if (position == 0) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.themeSettings });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 1) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.timelineItem });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 2) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.syncSettings });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 3) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.notificationSettings });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 5) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.advancedSettings });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 8) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.getHelp });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 9) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.otherApps });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 7) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.memManagement });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 4) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.links });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    } else if (position == 6) {
        TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.settings_pages });
        int resource = a.getResourceId(0, 0);
        a.recycle();
        ab.setIcon(resource);
    }
}
Also used : TypedArray(android.content.res.TypedArray)

Aggregations

TypedArray (android.content.res.TypedArray)2031 Paint (android.graphics.Paint)193 TypedValue (android.util.TypedValue)190 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)162 Drawable (android.graphics.drawable.Drawable)119 Resources (android.content.res.Resources)118 View (android.view.View)117 Context (android.content.Context)80 XmlResourceParser (android.content.res.XmlResourceParser)80 ColorStateList (android.content.res.ColorStateList)78 AttributeSet (android.util.AttributeSet)78 IOException (java.io.IOException)77 SuppressLint (android.annotation.SuppressLint)66 TextPaint (android.text.TextPaint)63 TextView (android.widget.TextView)63 ViewGroup (android.view.ViewGroup)59 Bundle (android.os.Bundle)48 Point (android.graphics.Point)43 LayoutInflater (android.view.LayoutInflater)42 ImageView (android.widget.ImageView)40