Search in sources :

Example 6 with AppSettings

use of com.klinker.android.twitter.settings.AppSettings in project Talon-for-Twitter by klinker24.

the class NotificationUtils method sendTestNotification.

public static void sendTestNotification(Context context) {
    if (!TEST_NOTIFICATION) {
        return;
    }
    AppSettings settings = AppSettings.getInstance(context);
    SharedPreferences sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    Intent markRead = new Intent(context, MarkReadService.class);
    PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0);
    String shortText = "Test Talon";
    String longText = "Here is a test for Talon's notifications";
    Intent resultIntent = new Intent(context, RedirectToMentions.class);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0);
    NotificationCompat.Builder mBuilder;
    Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class);
    mBuilder = new NotificationCompat.Builder(context).setContentTitle(shortText).setContentText(longText).setSmallIcon(R.drawable.ic_stat_icon).setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)).setContentIntent(resultPendingIntent).setAutoCancel(true).setTicker(shortText).setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0)).setPriority(NotificationCompat.PRIORITY_HIGH);
    // Pebble notification
    if (sharedPrefs.getBoolean("pebble_notification", false)) {
        sendAlertToPebble(context, shortText, shortText);
    }
    // Light Flow notification
    sendToLightFlow(context, shortText, shortText);
    if (settings.vibrate) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    }
    if (settings.sound) {
        try {
            mBuilder.setSound(Uri.parse(settings.ringtone));
        } catch (Exception e) {
            e.printStackTrace();
            mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
        }
    }
    if (settings.led)
        mBuilder.setLights(0xFFFFFF, 1000, 1000);
    // Get an instance of the NotificationManager service
    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
    Intent reply = new Intent(context, NotificationCompose.class);
    MentionsDataSource data = MentionsDataSource.getInstance(context);
    PendingIntent replyPending = PendingIntent.getActivity(context, 0, reply, 0);
    RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel("@" + "lukeklinker" + " ").build();
    // Create the notification action
    NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_action_reply_dark, context.getResources().getString(R.string.noti_reply), replyPending).addRemoteInput(remoteInput).build();
    NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder(R.drawable.ic_action_read_dark, context.getResources().getString(R.string.mark_read), readPending);
    mBuilder.addAction(replyAction);
    mBuilder.addAction(action.build());
    // Build the notification and issues it with notification manager.
    notificationManager.notify(1, mBuilder.build());
    // if we want to wake the screen on a new message
    if (settings.wakeScreen) {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
        wakeLock.acquire(5000);
    }
}
Also used : RemoteInput(android.support.v4.app.RemoteInput) AppSettings(com.klinker.android.twitter.settings.AppSettings) SharedPreferences(android.content.SharedPreferences) NotificationManagerCompat(android.support.v4.app.NotificationManagerCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PowerManager(android.os.PowerManager) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 7 with AppSettings

use of com.klinker.android.twitter.settings.AppSettings in project Talon-for-Twitter by klinker24.

the class NotificationUtils method favUsersNotification.

public static void favUsersNotification(int account, Context context) {
    ArrayList<String[]> tweets = new ArrayList<String[]>();
    HomeDataSource data = HomeDataSource.getInstance(context);
    Cursor cursor = data.getUnreadCursor(account);
    FavoriteUsersDataSource favs = FavoriteUsersDataSource.getInstance(context);
    if (cursor.moveToFirst()) {
        do {
            String screenname = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_SCREEN_NAME));
            if (favs.isFavUser(account, screenname)) {
                String name = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_NAME));
                String text = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_TEXT));
                String time = cursor.getLong(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_TIME)) + "";
                String picUrl = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_PIC_URL));
                String otherUrl = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_URL));
                String users = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_USERS));
                String hashtags = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_HASHTAGS));
                String id = cursor.getLong(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_TWEET_ID)) + "";
                String profilePic = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_PRO_PIC));
                String otherUrls = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_URL));
                String userss = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_USERS));
                String hashtagss = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_HASHTAGS));
                String retweeter;
                try {
                    retweeter = cursor.getString(cursor.getColumnIndex(HomeSQLiteHelper.COLUMN_RETWEETER));
                } catch (Exception e) {
                    retweeter = "";
                }
                String link = "";
                boolean displayPic = !picUrl.equals("") && !picUrl.contains("youtube");
                if (displayPic) {
                    link = picUrl;
                } else {
                    link = otherUrls.split("  ")[0];
                }
                tweets.add(new String[] { name, text, screenname, time, retweeter, link, displayPic ? "true" : "false", id, profilePic, userss, hashtagss, otherUrls });
            }
        } while (cursor.moveToNext());
    }
    cursor.close();
    if (tweets.size() > 0) {
        if (tweets.size() == 1) {
            makeFavsNotificationToActivity(tweets, context);
        } else {
            AppSettings settings = AppSettings.getInstance(context);
            makeFavsNotification(tweets, context, settings.liveStreaming || settings.pushNotifications);
        }
    }
}
Also used : AppSettings(com.klinker.android.twitter.settings.AppSettings) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 8 with AppSettings

use of com.klinker.android.twitter.settings.AppSettings in project Talon-for-Twitter by klinker24.

the class Utils method getTwitter.

public static Twitter getTwitter(Context context) {
    AppSettings settings = AppSettings.getInstance(context);
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY).setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET).setOAuthAccessToken(settings.authenticationToken).setOAuthAccessTokenSecret(settings.authenticationTokenSecret);
    cb.setTweetModeExtended(true);
    TwitterFactory tf = new TwitterFactory(cb.build());
    return tf.getInstance();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) AppSettings(com.klinker.android.twitter.settings.AppSettings) TwitterFactory(twitter4j.TwitterFactory)

Example 9 with AppSettings

use of com.klinker.android.twitter.settings.AppSettings in project Talon-for-Twitter by klinker24.

the class Utils method getSecondTwitter.

public static Twitter getSecondTwitter(Context context) {
    AppSettings settings = AppSettings.getInstance(context);
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(AppSettings.TWITTER_CONSUMER_KEY).setOAuthConsumerSecret(AppSettings.TWITTER_CONSUMER_SECRET).setOAuthAccessToken(settings.secondAuthToken).setOAuthAccessTokenSecret(settings.secondAuthTokenSecret);
    TwitterFactory tf = new TwitterFactory(cb.build());
    return tf.getInstance();
}
Also used : ConfigurationBuilder(twitter4j.conf.ConfigurationBuilder) AppSettings(com.klinker.android.twitter.settings.AppSettings) TwitterFactory(twitter4j.TwitterFactory)

Example 10 with AppSettings

use of com.klinker.android.twitter.settings.AppSettings in project Talon-for-Twitter by klinker24.

the class PhotoViewerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    try {
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    } catch (Exception e) {
        Log.e(LOGGER_TAG, "", e);
    }
    if (Build.VERSION.SDK_INT > 18) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    url = getIntent().getStringExtra("url");
    if (url == null) {
        finish();
        return;
    }
    // get higher quality imgur pictures
    if (url.contains("imgur")) {
        url = url.replace("t.jpg", ".jpg");
    }
    if (url.contains("insta")) {
        url = url.substring(0, url.length() - 1) + "l";
    }
    boolean fromCache = getIntent().getBooleanExtra("from_cache", true);
    boolean doRestart = getIntent().getBooleanExtra("restart", true);
    final boolean fromLauncher = getIntent().getBooleanExtra("from_launcher", false);
    AppSettings settings = new AppSettings(context);
    if (Build.VERSION.SDK_INT > 18 && settings.uiExtras) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }
    setContentView(R.layout.photo_dialog_layout);
    if (!doRestart || getIntent().getBooleanExtra("config_changed", false)) {
        LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
        spinner.setVisibility(View.GONE);
    }
    picture = (NetworkedCacheableImageView) findViewById(R.id.picture);
    PhotoViewAttacher mAttacher = new PhotoViewAttacher(picture);
    picture.loadImage(url, false, new NetworkedCacheableImageView.OnImageLoadedListener() {

        @Override
        public void onImageLoaded(CacheableBitmapDrawable result) {
            LinearLayout spinner = (LinearLayout) findViewById(R.id.list_progress);
            spinner.setVisibility(View.GONE);
        }
    }, 0, // no transform
    fromCache);
    mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            ((Activity) context).finish();
        }
    });
    ActionBar ab = getActionBar();
    if (ab != null) {
        ColorDrawable transparent = new ColorDrawable(getResources().getColor(android.R.color.transparent));
        ab.setBackgroundDrawable(transparent);
        ab.setDisplayHomeAsUpEnabled(false);
        ab.setDisplayShowHomeEnabled(false);
        ab.setTitle("");
        ab.setIcon(transparent);
    }
}
Also used : AppSettings(com.klinker.android.twitter.settings.AppSettings) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) View(android.view.View) NetworkedCacheableImageView(com.klinker.android.twitter.views.NetworkedCacheableImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) CacheableBitmapDrawable(uk.co.senab.bitmapcache.CacheableBitmapDrawable) LinearLayout(android.widget.LinearLayout) ActionBar(android.app.ActionBar)

Aggregations

AppSettings (com.klinker.android.twitter.settings.AppSettings)33 Intent (android.content.Intent)18 PendingIntent (android.app.PendingIntent)10 Context (android.content.Context)10 NotificationCompat (android.support.v4.app.NotificationCompat)9 SharedPreferences (android.content.SharedPreferences)6 Cursor (android.database.Cursor)6 Bitmap (android.graphics.Bitmap)6 PowerManager (android.os.PowerManager)6 NotificationManagerCompat (android.support.v4.app.NotificationManagerCompat)6 Paging (twitter4j.Paging)6 ArrayList (java.util.ArrayList)5 Twitter (twitter4j.Twitter)5 HomeDataSource (com.klinker.android.twitter.data.sq_lite.HomeDataSource)4 MentionsDataSource (com.klinker.android.twitter.data.sq_lite.MentionsDataSource)4 Status (twitter4j.Status)4 AlarmManager (android.app.AlarmManager)3 Handler (android.os.Handler)3 RemoteInput (android.support.v4.app.RemoteInput)3 DMDataSource (com.klinker.android.twitter.data.sq_lite.DMDataSource)3