Skip to content

Commit

Permalink
mult_not_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcostar committed Feb 10, 2016
1 parent 0477f69 commit 3af103f
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 102 deletions.
4 changes: 0 additions & 4 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/Greet/pubnative-1.4.8/unspecified/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/Greet/unity-ads-1.5.6/unspecified/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.1/jars" />
Expand Down Expand Up @@ -112,7 +110,5 @@
<orderEntry type="library" exported="" name="applovin-6.1.5" level="project" />
<orderEntry type="module" module-name="unity-ads-1.5.6" exported="" />
<orderEntry type="module" module-name="pubnative-1.4.8" exported="" />
<orderEntry type="library" exported="" name="unity-ads-1.5.6-unspecified" level="project" />
<orderEntry type="library" exported="" name="pubnative-1.4.8-unspecified" level="project" />
</component>
</module>
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.sagycorp.greet"
minSdkVersion 14
targetSdkVersion 23
versionCode 12
versionName "2.1"
versionCode 14
versionName "2.3"
}
buildTypes {
release {
Expand Down
23 changes: 22 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sagycorp.greet">

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission-sdk-23 android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
Expand Down Expand Up @@ -73,8 +75,27 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.sagycorp.greet.MainActivity" />
</activity>


<service android:name=".Services.AlarmService"
android:enabled="true"
android:exported="false" />
<!-- Register the Alarm Receiver -->
<receiver android:name="com.sagycorp.greet.Helper.NotificationCreator"/>
<receiver android:name=".Helper.NotificationCreator">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
<action android:name="android.intent.action.TIME_SET" />
</intent-filter>
</receiver>

<receiver android:name=".Helper.ServiceStarter">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
<action android:name="android.intent.action.TIME_SET" />
</intent-filter>
</receiver>

<service android:name="com.parse.PushService" />

Expand Down
17 changes: 10 additions & 7 deletions app/src/main/java/com/sagycorp/greet/FullPlaceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FullPlaceInfo extends AppCompatActivity {
private ScrollView PlaceViewLayout;
private LinearLayout LoadingLayout, ErrorLayout;
private SwipeRefreshLayout RefreshLayout;
private Boolean visiblity = false;
private Boolean visibility = false;
SharedPreferences sharedPreferences;
SharedPreferences.Editor editor;
private Tracker mTracker;
Expand Down Expand Up @@ -82,7 +82,7 @@ protected void onCreate(Bundle savedInstanceState) {
RefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if(!visiblity){
if(!visibility){
ErrorLayout.setVisibility(View.GONE);
initiateRequest();
}
Expand All @@ -105,11 +105,11 @@ public void onResponse(JSONObject response) {
PlacesDescription.setText(response.getString("Description"));
StoryImage.setImageUrl(response.getString("ImageURL"),imageLoader);

//set visiblity
visiblity = true;
//set visibility
visibility = true;

} catch (JSONException e) {
visiblity = false;
visibility = false;
e.printStackTrace();
}
RefreshLayout.setRefreshing(false);
Expand Down Expand Up @@ -150,7 +150,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

if (id == R.id.Refresh)
{
if(!visiblity) {
if(!visibility) {
if (!RefreshLayout.isRefreshing()) {
ErrorLayout.setVisibility(View.GONE);
RefreshLayout.setRefreshing(true);
Expand All @@ -172,6 +172,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
.build());

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Visit Scenic\n"+ Destination + "\nvia Greet."+"\n"+"http://goo.gl/T1AS5u");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Expand All @@ -182,6 +183,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if(id == R.id.suggestions)
{
Intent Email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "suggestions@sagycorp.com", null));
Email.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Email.putExtra(Intent.EXTRA_SUBJECT,"Advice for making this better app");
Email.putExtra(Intent.EXTRA_TEXT, "**Your Demands/Suggestions here**");
startActivity(Intent.createChooser(Email, "Share Your Advice with :"));
Expand All @@ -190,7 +192,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (id == R.id.tellFriend)
{
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "I found very interesting app!!\nGreet! Your storyteller, trip consultant, an astrological advisor and much more."+"\nDownload Greet\n"+"\n"+"http://goo.gl/T1AS5u");
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
sendIntent.putExtra(Intent.EXTRA_TEXT, "I am using an interesting app!!\n" + "Greet! Your storyteller, trip consultant, an astrological advisor and much more. Now it has hundreds of offline astonishing facts and quotes that will inspire us."+"\nDownload Greet\n"+"\n"+"http://goo.gl/T1AS5u");
sendIntent.setType("text/plain");
startActivity(sendIntent);
return true;
Expand Down
17 changes: 10 additions & 7 deletions app/src/main/java/com/sagycorp/greet/FullStory.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FullStory extends AppCompatActivity {
private ScrollView StoryViewLayout;
private LinearLayout LoadingLayout, ErrorLayout;
private SwipeRefreshLayout RefreshLayout;
private Boolean visiblity = false;
private Boolean visibility = false;
SharedPreferences sharedPreferences;
SharedPreferences.Editor editor;
private Tracker mTracker;
Expand Down Expand Up @@ -86,7 +86,7 @@ protected void onCreate(Bundle savedInstanceState) {
RefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if(!visiblity){
if(!visibility){
ErrorLayout.setVisibility(View.GONE);
initiateRequest();
}
Expand All @@ -109,11 +109,11 @@ public void onResponse(JSONObject response) {
StoryDescription.setText(response.getString("Description"));
StoryImage.setImageUrl(response.getString("ImageURL"),imageLoader);

//set visiblity
visiblity = true;
//set visibility
visibility = true;

} catch (JSONException e) {
visiblity = false;
visibility = false;
e.printStackTrace();
}
RefreshLayout.setRefreshing(false);
Expand Down Expand Up @@ -154,7 +154,7 @@ public boolean onOptionsItemSelected(MenuItem item) {

if (id == R.id.Refresh)
{
if(!visiblity) {
if(!visibility) {
if (!RefreshLayout.isRefreshing()) {
ErrorLayout.setVisibility(View.GONE);
RefreshLayout.setRefreshing(true);
Expand All @@ -177,6 +177,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
.build());

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
sendIntent.putExtra(Intent.EXTRA_TEXT, "Read\n"+ InShort +"\nwith Greet."+"\n"+"http://goo.gl/T1AS5u");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Expand All @@ -187,6 +188,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if(id == R.id.suggestions)
{
Intent Email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "suggestions@sagycorp.com", null));
Email.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Email.putExtra(Intent.EXTRA_SUBJECT,"Advice for making this better app");
Email.putExtra(Intent.EXTRA_TEXT, "**Your Demands/Suggestions here**");
startActivity(Intent.createChooser(Email, "Share Your Advice with :"));
Expand All @@ -195,7 +197,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (id == R.id.tellFriend)
{
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "I found very interesting app!!\nGreet! Your storyteller, trip consultant, an astrological advisor and much more."+"\nDownload Greet\n"+ "http://goo.gl/T1AS5u");
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
sendIntent.putExtra(Intent.EXTRA_TEXT, "I am using an interesting app!!\n" + "Greet! Your storyteller, trip consultant, an astrological advisor and much more. Now it has hundreds of offline astonishing facts and quotes that will inspire us."+"\nDownload Greet\n"+ "http://goo.gl/T1AS5u");
sendIntent.setType("text/plain");
startActivity(sendIntent);
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,77 +1,38 @@
package com.sagycorp.greet.Helper;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.WakefulBroadcastReceiver;

import com.sagycorp.greet.MainActivity;
import com.sagycorp.greet.R;
import com.sagycorp.greet.Services.AlarmService;

import java.util.Random;
import java.util.Calendar;

/**
* Created by Dzeko on 1/26/2016.
*/
public class NotificationCreator extends BroadcastReceiver {

NotificationManager nm;
Uri uri;
private String notification[] = {"Read today's astonishing story.",
"Read surprising fact from Black Box.",
"Your horoscope is quite interesting today.",
"Get inspired today with a great thought.",
"Visit this scenic place inside."};
private Random random = new Random();
@Override
public void onReceive(Context context, Intent intent) {
Integer randomNumber = random.nextInt(5);
nm = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);

uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Intent notificationIntent = new Intent(context, MainActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
public class NotificationCreator extends WakefulBroadcastReceiver {


public static void setAlarm(Context context)
{
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR_OF_DAY, 9);

Intent intent = new Intent(context, NotificationCreator.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN)
{
Notification.Builder mBuilder = new Notification.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Greet")
.setContentText(notification[randomNumber])
.setContentIntent(pendingIntent)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
.setLights(Color.BLUE, 3000, 3000)
.setSound(uri)
.setAutoCancel(true);

nm.notify(24392, mBuilder.build());
}
else if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
{
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Greet")
.setContentText(notification[randomNumber])
.setContentIntent(pendingIntent)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000})
.setLights(Color.BLUE, 3000, 3000)
.setSound(uri)
.setAutoCancel(true);
}

nm.notify(24392, mBuilder.build());
}
@Override
public void onReceive(Context context, Intent intent) {

Intent startIntent = AlarmService.startNotificationServices(context);
startWakefulService(context,startIntent);
}
}
15 changes: 15 additions & 0 deletions app/src/main/java/com/sagycorp/greet/Helper/ServiceStarter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.sagycorp.greet.Helper;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
* Created by Dzeko on 2/4/2016.
*/
public class ServiceStarter extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
NotificationCreator.setAlarm(context);
}
}
27 changes: 9 additions & 18 deletions app/src/main/java/com/sagycorp/greet/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.sagycorp.greet;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
Expand Down Expand Up @@ -46,34 +44,25 @@ public class MainActivity extends AppCompatActivity
SharedPreferences.Editor editor;
private NavigationView navigationView;
private Fragment fragment;
private String sign, title;
private boolean IsNotificationSet = false, CheckNotification;
private String title;
private boolean CheckNotification;
private static final String appKey = "7efbcd7b61614667cb4d65ddcf9a026a4c044e085755707c";


private boolean viewIsAtHome;
public String[] Horoscopes;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sharedPreferences = getSharedPreferences(Startup.PreferenceSETTINGS, Context.MODE_PRIVATE);
editor = sharedPreferences.edit();
CheckNotification = sharedPreferences.getBoolean(Startup.IsNotificationSet,false);
CheckNotification = sharedPreferences.getBoolean(Startup.NotificationSets,false);

if (IsNotificationSet == CheckNotification)
if (!CheckNotification)
{
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 9);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);

Intent intent = new Intent(MainActivity.this, NotificationCreator.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0,intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) MainActivity.this.getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
editor.putBoolean(Startup.IsNotificationSet,true).apply();
NotificationCreator.setAlarm(getApplicationContext());
editor.putBoolean(Startup.NotificationSets,true).apply();
}
setContentView(R.layout.activity_main);

Expand Down Expand Up @@ -157,6 +146,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if(id == R.id.suggestions)
{
Intent Email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "suggestions@sagycorp.com", null));
Email.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
Email.putExtra(Intent.EXTRA_SUBJECT,"Advice for making this better app");
Email.putExtra(Intent.EXTRA_TEXT, "**Your Demands/Suggestions here**");
startActivity(Intent.createChooser(Email, "Share Your Advice with :"));
Expand All @@ -165,7 +155,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (id == R.id.tellFriend)
{
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "I found very interesting app!!\nGreet! Your storyteller, trip consultant, an astrological advisor and much more."+"\nDownload Greet\n"+ "http://goo.gl/T1AS5u");
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
sendIntent.putExtra(Intent.EXTRA_TEXT, "I am using an interesting app!!\nGreet! Your storyteller, trip consultant, an astrological advisor and much more. Now it has hundreds of offline astonishing facts and quotes that will inspire us."+"\nDownload Greet\n"+ "http://goo.gl/T1AS5u");
sendIntent.setType("text/plain");
startActivity(sendIntent);
return true;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/sagycorp/greet/PushStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public void onCreate()
{
super.onCreate();
Parse.initialize(this, "bLwuq7MBXbyuBSrzmuw7Kkl2vUGb6rpszbEsanIO", "LAGZVb7E473d56HjqkczculReTkBZyUcwkcU3JTs");
ParsePush.subscribeInBackground("v2");
ParsePush.unsubscribeInBackground("v2");
ParsePush.subscribeInBackground("v3");
ParseInstallation.getCurrentInstallation().saveInBackground();
}
}
Loading

0 comments on commit 3af103f

Please sign in to comment.