Commit 5583e4fc authored by Varun Patil's avatar Varun Patil

Merge branch 'master' into generifyadapters

parents fa3b6d1b 76c88c8b
......@@ -8,11 +8,13 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import app.insti.activity.MainActivity;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.Body;
import app.insti.api.model.Event;
......@@ -26,6 +28,7 @@ public final class Utils {
private static String sessionId;
private static RetrofitInterface retrofitInterface;
public static Gson gson;
public static boolean darkTheme = false;
public static final void loadImageWithPlaceholder(final ImageView imageView, final String url) {
Picasso.get()
......@@ -119,4 +122,17 @@ public final class Utils {
public static void makeGson() {
Utils.gson = new Gson();
}
public static void changeTheme(FragmentActivity context) {
if (darkTheme) {
context.setTheme(R.style.AppTheme);
} else {
Toast.makeText(context, "You have unlocked super max pro mode", Toast.LENGTH_SHORT).show();
context.setTheme(R.style.AppThemeDark);
}
darkTheme = !darkTheme;
Intent intent = new Intent(context, MainActivity.class);
context.startActivity(intent);
context.finish();
}
}
package app.insti.activity;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.NotificationChannel;
......@@ -24,8 +25,10 @@ import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
......@@ -95,7 +98,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private RetrofitInterface retrofitInterface;
private List<Notification> notifications = null;
/** which menu item should be checked on activity start */
/**
* which menu item should be checked on activity start
*/
private int initMenuChecked = R.id.nav_feed;
public static void hideKeyboard(Activity activity) {
......@@ -109,8 +114,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
if (Utils.darkTheme) {
setTheme(R.style.AppThemeDark_NoActionBar);
}
super.onCreate(savedInstanceState);
ServiceGenerator serviceGenerator = new ServiceGenerator(getApplicationContext());
......@@ -152,10 +161,29 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
toolbar.setOnTouchListener(new View.OnTouchListener() {
private GestureDetector gestureDetector = new GestureDetector(MainActivity.this, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
Toast.makeText(MainActivity.this, "You have unlocked super max pro mode", Toast.LENGTH_SHORT).show();
Utils.changeTheme(MainActivity.this);
return super.onDoubleTap(e);
}
});
@Override
public boolean onTouch(View v, MotionEvent event) {
gestureDetector.onTouchEvent(event);
return true;
}
});
checkLatestVersion();
}
/** Get the notifications from memory cache or network */
/**
* Get the notifications from memory cache or network
*/
private void fetchNotifications() {
// Try memory cache
if (notifications != null) {
......@@ -176,7 +204,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
});
}
/** Show the right notification icon */
/**
* Show the right notification icon
*/
private void showNotifications() {
if (notifications != null && !notifications.isEmpty()) {
menu.findItem(R.id.action_notifications).setIcon(R.drawable.baseline_notifications_active_white_24);
......@@ -185,7 +215,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
/** Get version code we are currently on */
/**
* Get version code we are currently on
*/
private int getCurrentVersion() {
try {
PackageInfo pInfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
......@@ -195,10 +227,14 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
/** Check for updates in andro.json */
/**
* Check for updates in andro.json
*/
private void checkLatestVersion() {
final int versionCode = getCurrentVersion();
if (versionCode == 0) { return; }
if (versionCode == 0) {
return;
}
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getLatestVersion().enqueue(new EmptyCallback<JsonObject>() {
@Override
......@@ -260,7 +296,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
mNotificationManager.createNotificationChannel(mChannel);
}
/** Handle opening event/body/blog from FCM notification */
/**
* Handle opening event/body/blog from FCM notification
*/
private void handleFCMIntent(Bundle bundle) {
/* Mark the notification read */
final String notificationId = bundle.getString(FCM_BUNDLE_NOTIFICATION_ID);
......@@ -276,7 +314,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
);
}
/** Handle intents for links */
/**
* Handle intents for links
*/
private void handleIntent(Intent appLinkIntent) {
String appLinkAction = appLinkIntent.getAction();
String appLinkData = appLinkIntent.getDataString();
......@@ -285,9 +325,13 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
/** Open the proper fragment from given type and id */
/**
* Open the proper fragment from given type and id
*/
private void chooseIntent(String type, String id) {
if (type == null || id == null) { return; }
if (type == null || id == null) {
return;
}
switch (type) {
case DATA_TYPE_BODY:
openBodyFragment(id);
......@@ -306,7 +350,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
Log.e("NOTIFICATIONS", "Server sent invalid notification?");
}
/** Open the proper fragment from given type, id and extra */
/**
* Open the proper fragment from given type, id and extra
*/
private void chooseIntent(String type, String id, String extra) {
if (extra == null) {
chooseIntent(type, id);
......@@ -326,18 +372,24 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
/** Open user fragment from given id */
/**
* Open user fragment from given id
*/
private void openUserFragment(String id) {
UserFragment userFragment = UserFragment.newInstance(id);
updateFragment(userFragment);
}
/** Open the body fragment from given id */
/**
* Open the body fragment from given id
*/
private void openBodyFragment(String id) {
Utils.openBodyFragment(new Body(id), this);
}
/** Open the event fragment from the provided id */
/**
* Open the event fragment from the provided id
*/
private void openEventFragment(String id) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
final FragmentActivity self = this;
......@@ -548,7 +600,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
return true;
}
/** Open placement blog fragment */
/**
* Open placement blog fragment
*/
private void openPlacementBlog() {
if (session.isLoggedIn()) {
PlacementBlogFragment placementBlogFragment = new PlacementBlogFragment();
......@@ -567,7 +621,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
}
/** Change the active fragment to the supplied one */
/**
* Change the active fragment to the supplied one
*/
public void updateFragment(Fragment fragment) {
Log.d(TAG, "updateFragment: " + fragment.toString());
Bundle bundle = fragment.getArguments();
......@@ -579,7 +635,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
bundle.putString(Constants.USER_HOSTEL, session.isLoggedIn() && currentUser.getHostel() != null ? currentUser.getHostel() : "1");
if (fragment instanceof SettingsFragment && session.isLoggedIn())
bundle.putString(Constants.USER_ID, currentUser.getUserID());
if (fragment instanceof ComplaintsFragment && session.isLoggedIn()){
if (fragment instanceof ComplaintsFragment && session.isLoggedIn()) {
bundle.putString(Constants.USER_ID, currentUser.getUserID());
bundle.putString(Constants.CURRENT_USER_PROFILE_PICTURE, currentUser.getUserProfilePictureUrl());
}
......
......@@ -24,5 +24,5 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textColor="?attr/themeColorInverse"
android:textColorLink="@color/colorPrimary" />
android:textColorLink="?attr/urlColor" />
</LinearLayout>
\ No newline at end of file
......@@ -638,7 +638,7 @@
android:gravity="center"
android:linksClickable="true"
android:text="@string/django_api"
android:textColorLink="@color/colorPrimaryDark"
android:textColorLink="?attr/urlColor"
android:textStyle="bold" />
<TextView
......@@ -652,7 +652,7 @@
android:gravity="center"
android:linksClickable="true"
android:text="@string/android_app"
android:textColorLink="@color/colorPrimaryDark"
android:textColorLink="?attr/urlColor"
android:textStyle="bold" />
<TextView
......@@ -666,7 +666,7 @@
android:gravity="center"
android:linksClickable="true"
android:text="@string/angular_pwa"
android:textColorLink="@color/colorPrimaryDark"
android:textColorLink="?attr/urlColor"
android:textStyle="bold" />
......
......@@ -65,7 +65,7 @@
android:layout_height="wrap_content"
android:layout_weight="10"
android:text="Org Title"
android:textColor="#fff"
android:textColor="@color/colorWhite"
android:textSize="21sp"
android:textStyle="bold" />
......@@ -137,8 +137,8 @@
android:layout_marginEnd="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="12dp"
android:textColor="#333"
android:textColorLink="@color/colorPrimary"
android:textColor="?attr/themeColorInverse"
android:textColorLink="?attr/urlColor"
android:textSize="16sp" />
<TextView
......
......@@ -61,7 +61,7 @@
android:layout_height="wrap_content"
android:layout_weight="10"
android:text="Event Title"
android:textColor="?attr/themeColor"
android:textColor="@color/colorWhite"
android:textSize="21sp"
android:textStyle="bold" />
......@@ -73,7 +73,7 @@
android:layout_marginStart="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Event Website"
android:tint="?attr/themeColor"
android:tint="@color/colorWhite"
android:visibility="invisible"
app:srcCompat="@drawable/ic_language_black_24dp" />
......@@ -85,7 +85,7 @@
android:layout_marginStart="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Navigate"
android:tint="?attr/themeColor"
android:tint="@color/colorWhite"
app:srcCompat="@drawable/baseline_navigation_24" />
<ImageButton
......@@ -97,7 +97,7 @@
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="Share Event"
android:src="@drawable/ic_menu_share"
android:tint="?attr/themeColor" />
android:tint="@color/colorWhite" />
</LinearLayout>
<LinearLayout
......@@ -110,14 +110,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Date Specified"
android:textColor="?attr/themeColor"
android:textColor="@color/colorWhite"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textColor="?attr/themeColor"
android:textColor="@color/colorWhite"
android:textSize="20sp" />
<TextView
......@@ -125,14 +125,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Time Specified"
android:textColor="?attr/themeColor"
android:textColor="@color/colorWhite"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" | "
android:textColor="?attr/themeColor"
android:textColor="@color/colorWhite"
android:textSize="20sp" />
<TextView
......@@ -140,8 +140,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:text="No Venue Specified"
android:textColor="?attr/themeColor"
android:text="Venue"
android:textColor="@color/colorWhite"
android:textSize="16sp" />
</LinearLayout>
......@@ -190,6 +190,12 @@
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#aaa">
</View>
<TextView
android:id="@+id/event_page_description"
android:layout_width="match_parent"
......@@ -199,7 +205,7 @@
android:layout_marginStart="10dp"
android:layout_marginTop="12dp"
android:textColor="?attr/themeColorInverse"
android:textColorLink="@color/colorPrimary"
android:textColorLink="?attr/urlColor"
android:textSize="16sp" />
<android.support.v7.widget.RecyclerView
......
......@@ -29,7 +29,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Breakfast"
android:textColor="@color/colorPrimaryDark"
android:textColor="?attr/urlColor"
android:textSize="16sp" />
<TextView
......@@ -43,7 +43,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Lunch"
android:textColor="@color/colorPrimaryDark"
android:textColor="?attr/urlColor"
android:textSize="16sp" />
<TextView
......@@ -57,7 +57,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Tiffin"
android:textColor="@color/colorPrimaryDark"
android:textColor="?attr/urlColor"
android:textSize="16sp" />
<TextView
......@@ -71,7 +71,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Dinner"
android:textColor="@color/colorPrimaryDark"
android:textColor="?attr/urlColor"
android:textSize="16sp" />
<TextView
......
......@@ -4,14 +4,14 @@
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_margin="8dp"
android:background="#F2F2F2"
android:background="?attr/newsColor"
android:orientation="vertical">
<TextView
android:id="@+id/article_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textColor="?attr/themeColorInverse"
android:textSize="20sp"
android:textStyle="bold" />
......@@ -25,7 +25,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:textColor="#000000"
android:textColor="?attr/themeColorInverse"
android:textSize="17sp" />
<TextView
......@@ -48,6 +48,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textColor="#000000"
android:textColorLink="@color/colorPrimary" />
android:textColor="?attr/themeColorInverse"
android:textColorLink="?attr/urlColor" />
</LinearLayout>
......@@ -39,5 +39,7 @@ limitations under the License.
<attr name="themeColor" format="reference|color" />
<attr name="themeColorInverse" format="reference|color" />
<attr name="newsColor" format="reference|color" />
<attr name="urlColor" format="reference|color" />
</resources>
\ No newline at end of file
......@@ -8,6 +8,7 @@
<item name="colorAccent">@color/colorAccent</item>
<item name="themeColor">#FFFFFF</item>
<item name="themeColorInverse">#000000</item>
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
</style>
<style name="AppTheme.NoActionBar">
......@@ -21,6 +22,7 @@
<item name="colorAccent">@color/colorAccent</item>
<item name="themeColor">#000000</item>
<item name="themeColorInverse">#FFFFFF</item>
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
</style>
<style name="AppThemeDark.NoActionBar">
......@@ -68,4 +70,9 @@
<item name="android:textColor">#999</item>
<item name="android:textSize">12sp</item>
</style>
<style name="WindowAnimationTransition">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment