Search in sources :

Example 6 with HoloTextView

use of com.klinker.android.twitter.views.HoloTextView in project Talon-for-Twitter by klinker24.

the class InteractionClickListener method onItemClick.

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    HoloTextView title = (HoloTextView) view.findViewById(R.id.title);
    String mTitle = title.getText().toString();
    HoloTextView text = (HoloTextView) view.findViewById(R.id.text);
    String mText = text.getText().toString();
    // get the datasource ready to read/write
    InteractionsDataSource data = InteractionsDataSource.getInstance(context);
    if (mTitle.contains(context.getResources().getString(R.string.mentioned_by))) {
        // this is a mention
        if (MainDrawerArrayAdapter.current < 3) {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    try {
                        drawer.closeDrawer(Gravity.END);
                    } catch (Exception e) {
                    // landscape mode
                    }
                }
            }, 300);
            viewPager.setCurrentItem((mentionsPage), true);
        } else {
            final int pos = i;
            try {
                drawer.closeDrawer(Gravity.END);
            } catch (Exception e) {
            // landscape mode
            }
            new Thread(new Runnable() {

                @Override
                public void run() {
                    Intent intent = new Intent(context, MainActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    intent.putExtra("page_to_open", mentionsPage);
                    intent.putExtra("from_drawer", true);
                    sharedPreferences.edit().putBoolean("should_refresh", false).commit();
                    try {
                        Thread.sleep(400);
                    } catch (Exception e) {
                    }
                    try {
                        context.startActivity(intent);
                        ((Activity) context).overridePendingTransition(0, 0);
                        ((Activity) context).finish();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();
        }
    } else if (mTitle.contains(context.getResources().getString(R.string.retweeted)) || mTitle.contains(context.getResources().getString(R.string.favorited)) || mTitle.contains(context.getResources().getString(R.string.quoted)) || mTitle.contains(context.getResources().getString(R.string.new_favorites)) || mTitle.contains(context.getResources().getString(R.string.new_retweets)) || mTitle.contains(context.getResources().getString(R.string.new_quotes))) {
        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
        // landscape mode
        }
        // open up the dialog with the users that retweeted it
        final String[] fItems = data.getUsers(sharedPreferences.getInt("current_account", 1), i, DrawerActivity.oldInteractions.getText().toString().equals(context.getResources().getString(R.string.old_interactions))).split(" ");
        LayoutInflater factory = LayoutInflater.from(context);
        View content = factory.inflate(R.layout.interaction_dialog, null);
        TextView textView = (TextView) content.findViewById(R.id.text);
        textView.setText(mText);
        ListView lv = (ListView) content.findViewById(R.id.list);
        lv.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_selectable_list_item, fItems));
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
                String touched = fItems[item];
                Intent user = new Intent(context, ProfilePager.class);
                user.putExtra("screenname", touched.replace("@", "").replace(" ", ""));
                user.putExtra("proPic", "");
                context.startActivity(user);
            }
        });
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setView(content);
        AlertDialog alert = builder.create();
        alert.show();
    } else if (mTitle.contains(context.getResources().getString(R.string.followed))) {
        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
        // landscape mode
        }
        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));
        Intent user = new Intent(context, ProfilePager.class);
        user.putExtra("screenname", username);
        user.putExtra("proPic", "");
        context.startActivity(user);
    } else if (mTitle.contains(context.getResources().getString(R.string.tweeted))) {
        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
        // landscape mode
        }
        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));
        Intent user = new Intent(context, ProfilePager.class);
        user.putExtra("screenname", username);
        user.putExtra("proPic", "");
        context.startActivity(user);
    }
    // mark it read in the sql database
    data.markRead(sharedPreferences.getInt("current_account", 1), i);
    // tell the system to refresh the notifications when the user opens the drawer again
    sharedPreferences.edit().putBoolean("new_notification", true).commit();
}
Also used : AlertDialog(android.app.AlertDialog) Handler(android.os.Handler) DrawerActivity(com.klinker.android.twitter.activities.drawer_activities.DrawerActivity) MainActivity(com.klinker.android.twitter.activities.MainActivity) Activity(android.app.Activity) Intent(android.content.Intent) HoloTextView(com.klinker.android.twitter.views.HoloTextView) HoloTextView(com.klinker.android.twitter.views.HoloTextView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) InteractionsDataSource(com.klinker.android.twitter.data.sq_lite.InteractionsDataSource) ListView(android.widget.ListView) LayoutInflater(android.view.LayoutInflater) ProfilePager(com.klinker.android.twitter.activities.profile_viewer.ProfilePager) HoloTextView(com.klinker.android.twitter.views.HoloTextView) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) MainDrawerArrayAdapter(com.klinker.android.twitter.adapters.MainDrawerArrayAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 7 with HoloTextView

use of com.klinker.android.twitter.views.HoloTextView 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 8 with HoloTextView

use of com.klinker.android.twitter.views.HoloTextView in project Talon-for-Twitter by klinker24.

the class ComposeSecAccActivity method setUpReplyText.

public void setUpReplyText() {
    useAccOne = false;
    useAccTwo = true;
    NetworkedCacheableImageView pic = (NetworkedCacheableImageView) findViewById(R.id.profile_pic);
    HoloTextView currentName = (HoloTextView) findViewById(R.id.current_name);
    if (settings.roundContactImages) {
        pic.loadImage(settings.secondProfilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE);
    } else {
        pic.loadImage(settings.secondProfilePicUrl, false, null);
    }
    currentName.setText("@" + settings.secondScreenName);
    // for failed notification
    if (!sharedPrefs.getString("draft", "").equals("")) {
        reply.setText(sharedPrefs.getString("draft", ""));
        reply.setSelection(reply.getText().length());
    }
    String to = getIntent().getStringExtra("user") + (isDM ? "" : " ");
    if ((!to.equals("null ") && !isDM) || (isDM && !to.equals("null"))) {
        if (!isDM) {
            Log.v("username_for_noti", "to place: " + to);
            reply.setText(to);
            reply.setSelection(reply.getText().toString().length());
        } else {
            contactEntry.setText(to);
            reply.requestFocus();
        }
        sharedPrefs.edit().putString("draft", "").commit();
    }
    notiId = getIntent().getLongExtra("id", 0);
    replyText = getIntent().getStringExtra("reply_to_text");
    // Get intent, action and MIME type
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if ("text/plain".equals(type)) {
            // Handle text being sent
            handleSendText(intent);
        } else if (type.startsWith("image/")) {
            // Handle single image being sent
            handleSendImage(intent);
        }
    }
}
Also used : NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) Intent(android.content.Intent) HoloTextView(com.klinker.android.twitter.views.HoloTextView)

Example 9 with HoloTextView

use of com.klinker.android.twitter.views.HoloTextView in project Talon-for-Twitter by klinker24.

the class DrawerActivity method setUpDrawer.

public void setUpDrawer(int number, final String actName) {
    int currentAccount = sharedPrefs.getInt("current_account", 1);
    for (int i = 0; i < TimelinePagerAdapter.MAX_EXTRA_PAGES; i++) {
        String pageIdentifier = "account_" + currentAccount + "_page_" + (i + 1);
        int type = sharedPrefs.getInt(pageIdentifier, AppSettings.PAGE_TYPE_NONE);
        if (type != AppSettings.PAGE_TYPE_NONE) {
            number++;
        }
    }
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
    // Ignore
    }
    actionBar = getActionBar();
    adapter = new MainDrawerArrayAdapter(context);
    MainDrawerArrayAdapter.setCurrent(context, number);
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon });
    int resource = a.getResourceId(0, 0);
    a.recycle();
    a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.read_button });
    openMailResource = a.getResourceId(0, 0);
    a.recycle();
    a = context.getTheme().obtainStyledAttributes(new int[] { R.attr.unread_button });
    closedMailResource = a.getResourceId(0, 0);
    a.recycle();
    mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout);
    mDrawer = (LinearLayout) findViewById(R.id.left_drawer);
    HoloTextView name = (HoloTextView) mDrawer.findViewById(R.id.name);
    HoloTextView screenName = (HoloTextView) mDrawer.findViewById(R.id.screen_name);
    backgroundPic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.background_image);
    profilePic = (NetworkedCacheableImageView) mDrawer.findViewById(R.id.profile_pic_contact);
    final ImageButton showMoreDrawer = (ImageButton) mDrawer.findViewById(R.id.options);
    final LinearLayout logoutLayout = (LinearLayout) mDrawer.findViewById(R.id.logoutLayout);
    final Button logoutDrawer = (Button) mDrawer.findViewById(R.id.logoutButton);
    drawerList = (ListView) mDrawer.findViewById(R.id.drawer_list);
    notificationList = (EnhancedListView) findViewById(R.id.notificationList);
    try {
        mDrawerLayout = (NotificationDrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_rev, Gravity.END);
        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) {

            /* "close drawer" description */
            public void onDrawerClosed(View view) {
                actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
                if (logoutVisible) {
                    Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back);
                    ranim.setFillAfter(true);
                    showMoreDrawer.startAnimation(ranim);
                    logoutLayout.setVisibility(View.GONE);
                    drawerList.setVisibility(View.VISIBLE);
                    logoutVisible = false;
                }
                if (MainDrawerArrayAdapter.current > adapter.pageTypes.size()) {
                    actionBar.setTitle(actName);
                } else {
                    int position = mViewPager.getCurrentItem();
                    String title = "";
                    try {
                        title = "" + mSectionsPagerAdapter.getPageTitle(position);
                    } catch (NullPointerException e) {
                        title = "";
                    }
                    actionBar.setTitle(title);
                }
                try {
                    if (oldInteractions.getText().toString().equals(getResources().getString(R.string.new_interactions))) {
                        oldInteractions.setText(getResources().getString(R.string.old_interactions));
                        readButton.setImageResource(openMailResource);
                        notificationList.enableSwipeToDismiss();
                        notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount));
                        notificationList.setAdapter(notificationAdapter);
                    }
                } catch (Exception e) {
                // don't have talon pull on
                }
                invalidateOptionsMenu();
            }

            public void onDrawerOpened(View drawerView) {
                actionBar.setTitle(getResources().getString(R.string.app_name));
                actionBar.setIcon(R.mipmap.ic_launcher);
                try {
                    notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context).getUnreadCursor(settings.currentAccount));
                    notificationList.setAdapter(notificationAdapter);
                    notificationList.enableSwipeToDismiss();
                    oldInteractions.setText(getResources().getString(R.string.old_interactions));
                    readButton.setImageResource(openMailResource);
                    sharedPrefs.edit().putBoolean("new_notification", false).commit();
                } catch (Exception e) {
                // don't have talon pull on
                }
                invalidateOptionsMenu();
            }

            public void onDrawerSlide(View drawerView, float slideOffset) {
                super.onDrawerSlide(drawerView, slideOffset);
                if (!actionBar.isShowing()) {
                    actionBar.show();
                }
                if (translucent) {
                    statusBar.setVisibility(View.VISIBLE);
                }
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
    } catch (Exception e) {
    // landscape mode
    }
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    showMoreDrawer.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (logoutLayout.getVisibility() == View.GONE) {
                Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate);
                ranim.setFillAfter(true);
                showMoreDrawer.startAnimation(ranim);
                Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_out);
                anim.setAnimationListener(new Animation.AnimationListener() {

                    @Override
                    public void onAnimationStart(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        drawerList.setVisibility(View.GONE);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }
                });
                anim.setDuration(300);
                drawerList.startAnimation(anim);
                Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_in);
                anim2.setAnimationListener(new Animation.AnimationListener() {

                    @Override
                    public void onAnimationStart(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        logoutLayout.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }
                });
                anim2.setDuration(300);
                logoutLayout.startAnimation(anim2);
                logoutVisible = true;
            } else {
                Animation ranim = AnimationUtils.loadAnimation(context, R.anim.drawer_rotate_back);
                ranim.setFillAfter(true);
                showMoreDrawer.startAnimation(ranim);
                Animation anim = AnimationUtils.loadAnimation(context, R.anim.fade_in);
                anim.setAnimationListener(new Animation.AnimationListener() {

                    @Override
                    public void onAnimationStart(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        drawerList.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }
                });
                anim.setDuration(300);
                drawerList.startAnimation(anim);
                Animation anim2 = AnimationUtils.loadAnimation(context, R.anim.fade_out);
                anim2.setAnimationListener(new Animation.AnimationListener() {

                    @Override
                    public void onAnimationStart(Animation animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        logoutLayout.setVisibility(View.GONE);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {
                    }
                });
                anim2.setDuration(300);
                logoutLayout.startAnimation(anim2);
                logoutVisible = false;
            }
        }
    });
    logoutDrawer.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            logoutFromTwitter();
        }
    });
    final String sName = settings.myName;
    final String sScreenName = settings.myScreenName;
    final String backgroundUrl = settings.myBackgroundUrl;
    final String profilePicUrl = settings.myProfilePicUrl;
    final BitmapLruCache mCache = App.getInstance(context).getProfileCache();
    if (!backgroundUrl.equals("")) {
        backgroundPic.loadImage(backgroundUrl, false, null);
    //ImageUtils.loadImage(context, backgroundPic, backgroundUrl, mCache);
    } else {
        backgroundPic.setImageDrawable(getResources().getDrawable(R.drawable.default_header_background));
    }
    backgroundPic.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            try {
                mDrawerLayout.closeDrawer(Gravity.START);
            } catch (Exception e) {
            }
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    Intent viewProfile = new Intent(context, ProfilePager.class);
                    viewProfile.putExtra("name", sName);
                    viewProfile.putExtra("screenname", sScreenName);
                    viewProfile.putExtra("proPic", profilePicUrl);
                    viewProfile.putExtra("tweetid", 0);
                    viewProfile.putExtra("retweet", false);
                    viewProfile.putExtra("long_click", false);
                    context.startActivity(viewProfile);
                }
            }, 400);
        }
    });
    backgroundPic.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View view) {
            try {
                mDrawerLayout.closeDrawer(Gravity.START);
            } catch (Exception e) {
            }
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    Intent viewProfile = new Intent(context, ProfilePager.class);
                    viewProfile.putExtra("name", sName);
                    viewProfile.putExtra("screenname", sScreenName);
                    viewProfile.putExtra("proPic", profilePicUrl);
                    viewProfile.putExtra("tweetid", 0);
                    viewProfile.putExtra("retweet", false);
                    viewProfile.putExtra("long_click", true);
                    context.startActivity(viewProfile);
                }
            }, 400);
            return false;
        }
    });
    try {
        name.setText(sName);
        screenName.setText("@" + sScreenName);
        name.setTextSize(15);
        screenName.setTextSize(15);
    } catch (Exception e) {
    // 7 inch tablet in portrait
    }
    try {
        if (settings.roundContactImages) {
            //profilePic.loadImage(profilePicUrl, false, null, NetworkedCacheableImageView.CIRCLE);
            ImageUtils.loadCircleImage(context, profilePic, profilePicUrl, mCache);
        } else {
            profilePic.loadImage(profilePicUrl, false, null);
            ImageUtils.loadImage(context, profilePic, profilePicUrl, mCache);
        }
    } catch (Exception e) {
    // empty path again
    }
    drawerList.setAdapter(adapter);
    drawerList.setOnItemClickListener(new MainDrawerClickListener(context, mDrawerLayout, mViewPager));
    // set up for the second account
    // number of accounts logged in
    int count = 0;
    if (sharedPrefs.getBoolean("is_logged_in_1", false)) {
        count++;
    }
    if (sharedPrefs.getBoolean("is_logged_in_2", false)) {
        count++;
    }
    RelativeLayout secondAccount = (RelativeLayout) findViewById(R.id.second_profile);
    HoloTextView name2 = (HoloTextView) findViewById(R.id.name_2);
    HoloTextView screenname2 = (HoloTextView) findViewById(R.id.screen_name_2);
    NetworkedCacheableImageView proPic2 = (NetworkedCacheableImageView) findViewById(R.id.profile_pic_2);
    name2.setTextSize(15);
    screenname2.setTextSize(15);
    final int current = sharedPrefs.getInt("current_account", 1);
    // make a second account
    if (count == 1) {
        name2.setText(getResources().getString(R.string.new_account));
        screenname2.setText(getResources().getString(R.string.tap_to_setup));
        secondAccount.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (canSwitch) {
                    if (current == 1) {
                        sharedPrefs.edit().putInt("current_account", 2).commit();
                    } else {
                        sharedPrefs.edit().putInt("current_account", 1).commit();
                    }
                    context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE"));
                    context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION"));
                    Intent login = new Intent(context, LoginActivity.class);
                    AppSettings.invalidate();
                    finish();
                    startActivity(login);
                }
            }
        });
    } else {
        // switch accounts
        if (current == 1) {
            name2.setText(sharedPrefs.getString("twitter_users_name_2", ""));
            screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_2", ""));
            try {
                if (settings.roundContactImages) {
                    //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null, NetworkedCacheableImageView.CIRCLE);
                    ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache);
                } else {
                    //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_2", ""), true, null);
                    ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_2", ""), mCache);
                }
            } catch (Exception e) {
            }
            secondAccount.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (canSwitch) {
                        context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE"));
                        context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION").putExtra("current_account", current));
                        Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show();
                        // we want to wait a second so that the mark position broadcast will work
                        new Thread(new Runnable() {

                            @Override
                            public void run() {
                                try {
                                    Thread.sleep(1000);
                                } catch (Exception e) {
                                }
                                sharedPrefs.edit().putInt("current_account", 2).commit();
                                sharedPrefs.edit().remove("new_notifications").remove("new_retweets").remove("new_favorites").remove("new_follows").commit();
                                AppSettings.invalidate();
                                finish();
                                Intent next = new Intent(context, MainActivity.class);
                                startActivity(next);
                            }
                        }).start();
                    }
                }
            });
        } else {
            name2.setText(sharedPrefs.getString("twitter_users_name_1", ""));
            screenname2.setText("@" + sharedPrefs.getString("twitter_screen_name_1", ""));
            try {
                if (settings.roundContactImages) {
                    //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null, NetworkedCacheableImageView.CIRCLE);
                    ImageUtils.loadCircleImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache);
                } else {
                    //proPic2.loadImage(sharedPrefs.getString("profile_pic_url_1", ""), true, null);
                    ImageUtils.loadImage(context, proPic2, sharedPrefs.getString("profile_pic_url_1", ""), mCache);
                }
            } catch (Exception e) {
            }
            secondAccount.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (canSwitch) {
                        context.sendBroadcast(new Intent("com.klinker.android.twitter.STOP_PUSH_SERVICE"));
                        context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION").putExtra("current_account", current));
                        Toast.makeText(context, "Preparing to switch", Toast.LENGTH_SHORT).show();
                        new Thread(new Runnable() {

                            @Override
                            public void run() {
                                try {
                                    Thread.sleep(1000);
                                } catch (Exception e) {
                                }
                                sharedPrefs.edit().putInt("current_account", 1).commit();
                                sharedPrefs.edit().remove("new_notifications").remove("new_retweets").remove("new_favorites").remove("new_follows").commit();
                                AppSettings.invalidate();
                                finish();
                                Intent next = new Intent(context, MainActivity.class);
                                startActivity(next);
                            }
                        }).start();
                    }
                }
            });
        }
    }
    statusBar = findViewById(R.id.activity_status_bar);
    statusBarHeight = Utils.getStatusBarHeight(context);
    navBarHeight = Utils.getNavBarHeight(context);
    try {
        RelativeLayout.LayoutParams statusParams = (RelativeLayout.LayoutParams) statusBar.getLayoutParams();
        statusParams.height = statusBarHeight;
        statusBar.setLayoutParams(statusParams);
    } catch (Exception e) {
        try {
            LinearLayout.LayoutParams statusParams = (LinearLayout.LayoutParams) statusBar.getLayoutParams();
            statusParams.height = statusBarHeight;
            statusBar.setLayoutParams(statusParams);
        } catch (Exception x) {
        // in the trends
        }
    }
    View navBarSeperater = findViewById(R.id.nav_bar_seperator);
    if (translucent && Utils.hasNavBar(context)) {
        try {
            RelativeLayout.LayoutParams navParams = (RelativeLayout.LayoutParams) navBarSeperater.getLayoutParams();
            navParams.height = navBarHeight;
            navBarSeperater.setLayoutParams(navParams);
        } catch (Exception e) {
            try {
                LinearLayout.LayoutParams navParams = (LinearLayout.LayoutParams) navBarSeperater.getLayoutParams();
                navParams.height = navBarHeight;
                navBarSeperater.setLayoutParams(navParams);
            } catch (Exception x) {
            // in the trends
            }
        }
    }
    if (translucent) {
        if (Utils.hasNavBar(context)) {
            View footer = new View(context);
            footer.setOnClickListener(null);
            footer.setOnLongClickListener(null);
            ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context));
            footer.setLayoutParams(params);
            drawerList.addFooterView(footer);
            drawerList.setFooterDividersEnabled(false);
        }
        View drawerStatusBar = findViewById(R.id.drawer_status_bar);
        LinearLayout.LayoutParams status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams();
        status2Params.height = statusBarHeight;
        drawerStatusBar.setLayoutParams(status2Params);
        drawerStatusBar.setVisibility(View.VISIBLE);
        statusBar.setVisibility(View.VISIBLE);
        drawerStatusBar = findViewById(R.id.drawer_status_bar_2);
        status2Params = (LinearLayout.LayoutParams) drawerStatusBar.getLayoutParams();
        status2Params.height = statusBarHeight;
        drawerStatusBar.setLayoutParams(status2Params);
        drawerStatusBar.setVisibility(View.VISIBLE);
    }
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE || getResources().getBoolean(R.bool.isTablet)) {
        actionBar.setDisplayHomeAsUpEnabled(false);
    }
    if (!settings.pushNotifications || !settings.useInteractionDrawer) {
        try {
            mDrawerLayout.setDrawerLockMode(NotificationDrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END);
        } catch (Exception e) {
        // no drawer?
        }
    } else {
        mDrawerLayout.setDrawerRightEdgeSize(this, .1f);
        try {
            if (Build.VERSION.SDK_INT < 18 && DrawerActivity.settings.uiExtras) {
                View viewHeader2 = ((Activity) context).getLayoutInflater().inflate(R.layout.ab_header, null);
                notificationList.addHeaderView(viewHeader2, null, false);
                notificationList.setHeaderDividersEnabled(false);
            }
        } catch (Exception e) {
        // i don't know why it does this to be honest...
        }
        notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount));
        try {
            notificationList.setAdapter(notificationAdapter);
        } catch (Exception e) {
        }
        View viewHeader = ((Activity) context).getLayoutInflater().inflate(R.layout.interactions_footer_1, null);
        notificationList.addFooterView(viewHeader, null, false);
        oldInteractions = (HoloTextView) findViewById(R.id.old_interactions_text);
        readButton = (ImageView) findViewById(R.id.read_button);
        LinearLayout footer = (LinearLayout) viewHeader.findViewById(R.id.footer);
        footer.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                if (oldInteractions.getText().toString().equals(getResources().getString(R.string.old_interactions))) {
                    oldInteractions.setText(getResources().getString(R.string.new_interactions));
                    readButton.setImageResource(closedMailResource);
                    notificationList.disableSwipeToDismiss();
                    notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context).getCursor(DrawerActivity.settings.currentAccount));
                } else {
                    oldInteractions.setText(getResources().getString(R.string.old_interactions));
                    readButton.setImageResource(openMailResource);
                    notificationList.enableSwipeToDismiss();
                    notificationAdapter = new InteractionsCursorAdapter(context, InteractionsDataSource.getInstance(context).getUnreadCursor(DrawerActivity.settings.currentAccount));
                }
                notificationList.setAdapter(notificationAdapter);
            }
        });
        if (DrawerActivity.translucent) {
            if (Utils.hasNavBar(context)) {
                View nav = new View(context);
                nav.setOnClickListener(null);
                nav.setOnLongClickListener(null);
                ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, Utils.getNavBarHeight(context));
                nav.setLayoutParams(params);
                notificationList.addFooterView(nav);
                notificationList.setFooterDividersEnabled(false);
            }
        }
        notificationList.setDismissCallback(new EnhancedListView.OnDismissCallback() {

            @Override
            public EnhancedListView.Undoable onDismiss(EnhancedListView listView, int position) {
                Log.v("talon_interactions_delete", "position to delete: " + position);
                InteractionsDataSource data = InteractionsDataSource.getInstance(context);
                data.markRead(settings.currentAccount, position);
                notificationAdapter = new InteractionsCursorAdapter(context, data.getUnreadCursor(DrawerActivity.settings.currentAccount));
                notificationList.setAdapter(notificationAdapter);
                oldInteractions.setText(getResources().getString(R.string.old_interactions));
                readButton.setImageResource(openMailResource);
                if (notificationAdapter.getCount() == 0) {
                    setNotificationFilled(false);
                }
                return null;
            }
        });
        notificationList.enableSwipeToDismiss();
        notificationList.setSwipeDirection(EnhancedListView.SwipeDirection.START);
        notificationList.setOnItemClickListener(new InteractionClickListener(context, mDrawerLayout, mViewPager));
    }
}
Also used : ActionBarDrawerToggle(com.klinker.android.twitter.views.ActionBarDrawerToggle) MainActivity(com.klinker.android.twitter.activities.MainActivity) InteractionsCursorAdapter(com.klinker.android.twitter.adapters.InteractionsCursorAdapter) ViewConfiguration(android.view.ViewConfiguration) Field(java.lang.reflect.Field) AsyncListView(org.lucasr.smoothie.AsyncListView) EnhancedListView(de.timroes.android.listview.EnhancedListView) InteractionClickListener(com.klinker.android.twitter.listeners.InteractionClickListener) TypedArray(android.content.res.TypedArray) LoginActivity(com.klinker.android.twitter.activities.setup.LoginActivity) Handler(android.os.Handler) MainDrawerClickListener(com.klinker.android.twitter.listeners.MainDrawerClickListener) HoloTextView(com.klinker.android.twitter.views.HoloTextView) NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) AsyncListView(org.lucasr.smoothie.AsyncListView) View(android.view.View) HoloTextView(com.klinker.android.twitter.views.HoloTextView) EnhancedListView(de.timroes.android.listview.EnhancedListView) MainDrawerArrayAdapter(com.klinker.android.twitter.adapters.MainDrawerArrayAdapter) NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) BitmapLruCache(uk.co.senab.bitmapcache.BitmapLruCache) ColorDrawable(android.graphics.drawable.ColorDrawable) Animation(android.view.animation.Animation) EnhancedListView(de.timroes.android.listview.EnhancedListView)

Example 10 with HoloTextView

use of com.klinker.android.twitter.views.HoloTextView in project Talon-for-Twitter by klinker24.

the class Compose method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    countHandler = new Handler();
    settings = AppSettings.getInstance(this);
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
    // Ignore
    }
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }
    currentAccount = sharedPrefs.getInt("current_account", 1);
    buildGoogleApiClient();
    Utils.setUpPopupTheme(context, settings);
    setUpWindow();
    setUpLayout();
    setUpActionBar();
    setUpReplyText();
    if (reply.getText().toString().contains(" RT @") || reply.getText().toString().contains("/status/")) {
        reply.setSelection(0);
    }
    if (getIntent().getBooleanExtra("start_attach", false)) {
        attachButton.performClick();
    //overflow.performClick();
    }
    if (notiId != 0) {
        HoloTextView replyTo = (HoloTextView) findViewById(R.id.reply_to);
        replyTo.setText(replyText);
        TextUtils.linkifyText(context, replyTo, null, true, "", true);
        replyTo.setVisibility(View.VISIBLE);
    }
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            String text = reply.getText().toString();
            try {
                if (!android.text.TextUtils.isEmpty(text) && !(text.startsWith(" RT @") || text.contains("/status/"))) {
                    //text = text.replaceAll("  ", " ");
                    reply.setText(text);
                    reply.setSelection(text.length());
                    if (!text.endsWith(" ")) {
                        reply.append(" ");
                    }
                }
            } catch (Exception e) {
            }
        }
    }, 250);
}
Also used : ViewConfiguration(android.view.ViewConfiguration) Field(java.lang.reflect.Field) Handler(android.os.Handler) HoloTextView(com.klinker.android.twitter.views.HoloTextView) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Point(android.graphics.Point)

Aggregations

HoloTextView (com.klinker.android.twitter.views.HoloTextView)13 View (android.view.View)8 Intent (android.content.Intent)6 Handler (android.os.Handler)6 NetworkedCacheableImageView (com.klinker.android.twitter.views.NetworkedCacheableImageView)6 TypedArray (android.content.res.TypedArray)4 Point (android.graphics.Point)4 Editable (android.text.Editable)4 TextWatcher (android.text.TextWatcher)4 LayoutInflater (android.view.LayoutInflater)3 ViewConfiguration (android.view.ViewConfiguration)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 IOException (java.io.IOException)3 Field (java.lang.reflect.Field)3 AsyncListView (org.lucasr.smoothie.AsyncListView)3 BitmapLruCache (uk.co.senab.bitmapcache.BitmapLruCache)3 AlertDialog (android.app.AlertDialog)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2