Home | History | Annotate | Download | only in mock
      1 package com.example.android.wearable.wear.wearnotifications.mock;
      2 
      3 import android.support.v4.app.NotificationCompat.MessagingStyle;
      4 
      5 import com.example.android.wearable.wear.wearnotifications.R;
      6 
      7 import java.util.ArrayList;
      8 
      9 /**
     10  * Mock data for each of the Notification Style Demos.
     11  */
     12 public final class MockDatabase {
     13 
     14     public static BigTextStyleReminderAppData getBigTextStyleData() {
     15         return BigTextStyleReminderAppData.getInstance();
     16     }
     17 
     18     public static BigPictureStyleSocialAppData getBigPictureStyleData() {
     19         return BigPictureStyleSocialAppData.getInstance();
     20     }
     21 
     22     public static InboxStyleEmailAppData getInboxStyleData() {
     23         return InboxStyleEmailAppData.getInstance();
     24     }
     25 
     26     public static MessagingStyleCommsAppData getMessagingStyleData() {
     27         return MessagingStyleCommsAppData.getInstance();
     28     }
     29 
     30     /**
     31      * Represents data needed for BigTextStyle Notification.
     32      */
     33     public static class BigTextStyleReminderAppData {
     34 
     35         private static BigTextStyleReminderAppData sInstance = null;
     36 
     37         // Standard notification values
     38         private String mContentTitle;
     39         private String mContentText;
     40 
     41         // Style notification values
     42         private String mBigContentTitle;
     43         private String mBigText;
     44         private String mSummaryText;
     45 
     46 
     47         public static BigTextStyleReminderAppData getInstance() {
     48             if (sInstance == null) {
     49                 sInstance = getSync();
     50             }
     51 
     52             return sInstance;
     53         }
     54 
     55         private static synchronized BigTextStyleReminderAppData getSync() {
     56             if (sInstance == null) {
     57                 sInstance = new BigTextStyleReminderAppData();
     58             }
     59 
     60             return sInstance;
     61         }
     62 
     63         private BigTextStyleReminderAppData() {
     64             // Standard Notification values
     65             // Title for API <16 (4.0 and below) devices
     66             mContentTitle = "Don't forget to...";
     67             // Content for API <24 (4.0 and below) devices
     68             mContentText = "Feed Dogs and check garage!";
     69 
     70             // BigText Style Notification values
     71             mBigContentTitle = "Don't forget to...";
     72             mBigText = "... feed the dogs before you leave for work, and check the garage to "
     73                             + "make sure the door is closed.";
     74             mSummaryText = "Dogs and Garage";
     75         }
     76         public String getContentTitle() {
     77             return mContentTitle;
     78         }
     79 
     80         public String getContentText() {
     81             return mContentText;
     82         }
     83 
     84         public String getBigContentTitle() {
     85             return mBigContentTitle;
     86         }
     87 
     88         public String getBigText() {
     89             return mBigText;
     90         }
     91 
     92         public String getSummaryText() {
     93             return mSummaryText;
     94         }
     95 
     96         @Override
     97         public String toString() {
     98             return getBigContentTitle() + getBigText();
     99         }
    100     }
    101 
    102     /**
    103      * Represents data needed for BigPictureStyle Notification.
    104      */
    105     public static class BigPictureStyleSocialAppData {
    106         private static BigPictureStyleSocialAppData sInstance = null;
    107 
    108         // Standard notification values
    109         private String mContentTitle;
    110         private String mContentText;
    111 
    112         // Style notification values
    113         private int mBigImage;
    114         private String mBigContentTitle;
    115         private String mSummaryText;
    116 
    117         private CharSequence[] mPossiblePostResponses;
    118 
    119         private ArrayList<String> mParticipants;
    120 
    121 
    122         public static BigPictureStyleSocialAppData getInstance() {
    123             if (sInstance == null) {
    124                 sInstance = getSync();
    125             }
    126             return sInstance;
    127         }
    128 
    129         private static synchronized BigPictureStyleSocialAppData getSync() {
    130             if (sInstance == null) {
    131                 sInstance = new BigPictureStyleSocialAppData();
    132             }
    133 
    134             return sInstance;
    135         }
    136 
    137         private BigPictureStyleSocialAppData() {
    138             // Standard Notification values
    139             // Title/Content for API <16 (4.0 and below) devices
    140             mContentTitle = "Bob's Post";
    141             mContentText = "[Picture] Like my shot of Earth?";
    142 
    143             // Style notification values
    144             mBigImage = R.drawable.earth;
    145             mBigContentTitle = "Bob's Post";
    146             mSummaryText = "Like my shot of Earth?";
    147 
    148             // This would be possible responses based on the contents of the post
    149             mPossiblePostResponses = new CharSequence[]{"Yes", "No", "Maybe?"};
    150 
    151             mParticipants = new ArrayList<>();
    152             mParticipants.add("Bob Smith");
    153         }
    154 
    155         public String getContentTitle() {
    156             return mContentTitle;
    157         }
    158 
    159         public String getContentText() {
    160             return mContentText;
    161         }
    162 
    163         public int getBigImage() {
    164             return mBigImage;
    165         }
    166 
    167         public String getBigContentTitle() {
    168             return mBigContentTitle;
    169         }
    170 
    171         public String getSummaryText() {
    172             return mSummaryText;
    173         }
    174 
    175         public CharSequence[] getPossiblePostResponses() {
    176             return mPossiblePostResponses;
    177         }
    178 
    179         public ArrayList<String> getParticipants() {
    180             return mParticipants;
    181         }
    182 
    183         @Override
    184         public String toString() {
    185             return getContentTitle() + " - " + getContentText();
    186         }
    187     }
    188 
    189     /**
    190      * Represents data needed for InboxStyle Notification.
    191      */
    192     public static class InboxStyleEmailAppData {
    193         private static InboxStyleEmailAppData sInstance = null;
    194 
    195         // Standard notification values
    196         private String mContentTitle;
    197         private String mContentText;
    198         private int mNumberOfNewEmails;
    199 
    200         // Style notification values
    201         private String mBigContentTitle;
    202         private String mSummaryText;
    203         private ArrayList<String> mIndividualEmailSummary;
    204 
    205         private ArrayList<String> mParticipants;
    206 
    207         public static InboxStyleEmailAppData getInstance() {
    208             if (sInstance == null) {
    209                 sInstance = getSync();
    210             }
    211             return sInstance;
    212         }
    213 
    214         private static synchronized InboxStyleEmailAppData getSync() {
    215             if (sInstance == null) {
    216                 sInstance = new InboxStyleEmailAppData();
    217             }
    218 
    219             return sInstance;
    220         }
    221 
    222         private InboxStyleEmailAppData() {
    223             // Standard Notification values
    224             // Title/Content for API <16 (4.0 and below) devices
    225             mContentTitle = "5 new emails";
    226             mContentText = "from Jane, Jay, Alex +2 more";
    227             mNumberOfNewEmails = 5;
    228 
    229             // Style notification values
    230             mBigContentTitle = "5 new emails from Jane, Jay, Alex +2";
    231             mSummaryText = "New emails";
    232 
    233             // Add each summary line of the new emails, you can add up to 5
    234             mIndividualEmailSummary = new ArrayList<>();
    235             mIndividualEmailSummary.add("Jane Faab  -   Launch Party is here...");
    236             mIndividualEmailSummary.add("Jay Walker -   There's a turtle on the server!");
    237             mIndividualEmailSummary.add("Alex Chang -   Check this out...");
    238             mIndividualEmailSummary.add("Jane Johns -   Check in code?");
    239             mIndividualEmailSummary.add("John Smith -   Movies later....");
    240 
    241             // If the phone is in "Do not disturb mode, the user will still be notified if
    242             // the user(s) is starred as a favorite.
    243             mParticipants = new ArrayList<>();
    244             mParticipants.add("Jane Faab");
    245             mParticipants.add("Jay Walker");
    246             mParticipants.add("Alex Chang");
    247             mParticipants.add("Jane Johns");
    248             mParticipants.add("John Smith");
    249         }
    250 
    251         public String getContentTitle() {
    252             return mContentTitle;
    253         }
    254 
    255         public String getContentText() {
    256             return mContentText;
    257         }
    258 
    259         public int getNumberOfNewEmails() {
    260             return mNumberOfNewEmails;
    261         }
    262 
    263         public String getBigContentTitle() {
    264             return mBigContentTitle;
    265         }
    266 
    267         public String getSummaryText() {
    268             return mSummaryText;
    269         }
    270 
    271         public ArrayList<String> getIndividualEmailSummary() {
    272             return mIndividualEmailSummary;
    273         }
    274 
    275         public ArrayList<String> getParticipants() {
    276             return mParticipants;
    277         }
    278 
    279         @Override
    280         public String toString() {
    281             return getContentTitle() + " " + getContentText();
    282         }
    283     }
    284 
    285     /**
    286      * Represents data needed for MessagingStyle Notification.
    287      */
    288     public static class MessagingStyleCommsAppData {
    289 
    290         private static MessagingStyleCommsAppData sInstance = null;
    291 
    292         // Standard notification values
    293         private String mContentTitle;
    294         private String mContentText;
    295 
    296         // Style notification values
    297         private ArrayList<MessagingStyle.Message> mMessages;
    298         // Basically, String of all mMessages
    299         private String mFullConversation;
    300         // Name preferred when replying to chat
    301         private String mReplayName;
    302         private int mNumberOfNewMessages;
    303         private ArrayList<String> mParticipants;
    304 
    305         public static MessagingStyleCommsAppData getInstance() {
    306             if (sInstance == null) {
    307                 sInstance = getSync();
    308             }
    309             return sInstance;
    310         }
    311 
    312         private static synchronized MessagingStyleCommsAppData getSync() {
    313             if (sInstance == null) {
    314                 sInstance = new MessagingStyleCommsAppData();
    315             }
    316 
    317             return sInstance;
    318         }
    319 
    320         private MessagingStyleCommsAppData() {
    321             // Standard notification values
    322             // Content for API <24 (M and below) devices
    323             mContentTitle = "2 Messages w/ Famous McFamously";
    324             mContentText = "Dude! ... You know I am a Pesce-pescetarian. :P";
    325 
    326             // Style notification values
    327 
    328             // For each message, you need the timestamp, in this case, we are using arbitrary ones.
    329             long currentTime = System.currentTimeMillis();
    330 
    331             mMessages = new ArrayList<>();
    332             mMessages.add(new MessagingStyle.Message(
    333                     "What are you doing tonight?", currentTime - 4000, "Famous"));
    334             mMessages.add(new MessagingStyle.Message(
    335                     "I don't know, dinner maybe?", currentTime - 3000, null));
    336             mMessages.add(new MessagingStyle.Message(
    337                     "Sounds good.", currentTime - 2000, "Famous"));
    338             mMessages.add(new MessagingStyle.Message(
    339                     "How about BBQ?", currentTime - 1000, null));
    340             // Last two are the newest message (2) from friend
    341             mMessages.add(new MessagingStyle.Message(
    342                     "Dude!", currentTime, "Famous"));
    343             mMessages.add(new MessagingStyle.Message(
    344                     "You know I am a Pesce-pescetarian. :P", currentTime, "Famous"));
    345 
    346 
    347             // String version of the mMessages above
    348             mFullConversation = "Famous: What are you doing tonight?\n\n"
    349                     + "Me: I don't know, dinner maybe?\n\n"
    350                     + "Famous: Sounds good.\n\n"
    351                     + "Me: How about BBQ?\n\n"
    352                     + "Famous: Dude!\n\n"
    353                     + "Famous: You know I am a Pesce-pescetarian. :P\n\n";
    354 
    355             mNumberOfNewMessages = 2;
    356 
    357             // Name preferred when replying to chat
    358             mReplayName = "Me";
    359 
    360             // If the phone is in "Do not disturb mode, the user will still be notified if
    361             // the user(s) is starred as a favorite.
    362             mParticipants = new ArrayList<>();
    363             mParticipants.add("Famous McFamously");
    364 
    365         }
    366 
    367         public String getContentTitle() {
    368             return mContentTitle;
    369         }
    370 
    371         public String getContentText() {
    372             return mContentText;
    373         }
    374 
    375         public ArrayList<MessagingStyle.Message> getMessages() {
    376             return mMessages;
    377         }
    378 
    379         public String getFullConversation() {
    380             return mFullConversation;
    381         }
    382 
    383         public String getReplayName() {
    384             return mReplayName;
    385         }
    386 
    387         public int getNumberOfNewMessages() {
    388             return mNumberOfNewMessages;
    389         }
    390 
    391         public ArrayList<String> getParticipants() {
    392             return mParticipants;
    393         }
    394 
    395         @Override
    396         public String toString() {
    397             return getFullConversation();
    398         }
    399     }
    400 }