Commit affee3de authored by Mrunzzz's avatar Mrunzzz Committed by GitHub

Merge pull request #1 from unstablebrainiac/master

Update from ORiginal
parents bdce0205 fc841ea4
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/IITB-App.iml" filepath="$PROJECT_DIR$/IITB-App.iml" />
<module fileurl="file://$PROJECT_DIR$/IITBApp.iml" filepath="$PROJECT_DIR$/IITBApp.iml" /> <module fileurl="file://$PROJECT_DIR$/IITBApp.iml" filepath="$PROJECT_DIR$/IITBApp.iml" />
<module fileurl="file://D:\IITB-App\IITBApp.iml" filepath="D:\IITB-App\IITBApp.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules> </modules>
</component> </component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -5,6 +5,7 @@ android { ...@@ -5,6 +5,7 @@ android {
buildToolsVersion "25.0.3" buildToolsVersion "25.0.3"
defaultConfig { defaultConfig {
applicationId "in.ac.iitb.gymkhana.iitbapp" applicationId "in.ac.iitb.gymkhana.iitbapp"
manifestPlaceholders 'appAuthRedirectScheme': 'https'
minSdkVersion 17 minSdkVersion 17
targetSdkVersion 25 targetSdkVersion 25
versionCode 1 versionCode 1
...@@ -25,7 +26,9 @@ dependencies { ...@@ -25,7 +26,9 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.android.support', module: 'support-annotations'
}) })
compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:appcompat-v7:25.3.1'
compile 'net.openid:appauth:0.2.0'
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1' compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'
} }
...@@ -13,6 +13,31 @@ ...@@ -13,6 +13,31 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="HANDLE_AUTHORIZATION_RESPONSE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="redirecturi"
android:scheme="https" />
</intent-filter>
</activity>
</application> </application>
</manifest> </manifest>
\ No newline at end of file
package in.ac.iitb.gymkhana.iitbapp;
import android.annotation.TargetApi;
import android.app.PendingIntent;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import net.openid.appauth.AuthState;
import net.openid.appauth.AuthorizationException;
import net.openid.appauth.AuthorizationRequest;
import net.openid.appauth.AuthorizationResponse;
import net.openid.appauth.AuthorizationService;
import net.openid.appauth.AuthorizationServiceConfiguration;
import net.openid.appauth.TokenResponse;
import static android.R.attr.action;
public class LoginActivity extends AppCompatActivity {
private static final String TAG = "LoginActivity";
private final String clientId = "pFcDDWtUUfzlAX2ibriV25lm1J2m92O5ynfT4SYk";
private final String clientSecret = "k56GXiN1qB4Dt7CnTVWjuwLJyWntNulitWOkL7Wddr6JHPiHqIZgSfgUplO6neTqumVr32zA14XgQmkuoC8y6y9jnaQT9tKDsq4jQklRb8MQNQglQ1H4YrmqOwPfaNyO";
private final Uri redirectUri = Uri.parse("https://redirecturi");
private final Uri mAuthEndpoint = Uri.parse("http://gymkhana.iitb.ac.in/sso/oauth/authorize/");
private final Uri mTokenEndpoint = Uri.parse("http://gymkhana.iitb.ac.in/sso/oauth/token/");
private AuthorizationService mAuthService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mAuthService = new AuthorizationService(this);
Button ldapLogin = (Button) findViewById(R.id.ldap_login);
ldapLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "Initiating auth");
AuthorizationServiceConfiguration config =
new AuthorizationServiceConfiguration(mAuthEndpoint, mTokenEndpoint);
makeAuthRequest(config);
}
});
Button guestLogin = (Button) findViewById(R.id.guest_login);
guestLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
}
});
}
@Override
protected void onNewIntent(Intent intent) {
checkIntent(intent);
}
private void checkIntent(@Nullable Intent intent) {
if (intent != null) {
Log.d(TAG,"Intent Received");
String action = intent.getAction();
switch (action) {
case "HANDLE_AUTHORIZATION_RESPONSE":
{
handleAuthorizationResponse(intent);
}
break;
default:Log.d(TAG,intent.getAction());
}
}
}
@Override
protected void onStart() {
super.onStart();
checkIntent(getIntent());
}
@Override
protected void onResume() {
super.onResume();
Log.d(TAG,"In Resume");
}
@Override
protected void onDestroy() {
super.onDestroy();
mAuthService.dispose();
}
private void handleAuthorizationResponse(@NonNull Intent intent) {
AuthorizationResponse response = AuthorizationResponse.fromIntent(intent);
AuthorizationException error = AuthorizationException.fromIntent(intent);
if (response != null) {
Log.d(TAG, "Received AuthorizationResponse: "+ "AuthCode: "+response.authorizationCode);
Toast.makeText(this,
"AuthCode: "+response.authorizationCode, Toast.LENGTH_SHORT)
.show();
} else {
Log.i(TAG, "Authorization failed: " + error.getMessage());
Toast.makeText(this,
"Authorization failed", Toast.LENGTH_LONG)
.show();
}
}
private void makeAuthRequest(
@NonNull AuthorizationServiceConfiguration serviceConfig) {
AuthorizationRequest authRequest = new AuthorizationRequest.Builder(
serviceConfig,
clientId,
"code",
redirectUri)
.setScope("profile")
.build();
Log.d(TAG, "Making auth request");
String action = "HANDLE_AUTHORIZATION_RESPONSE";
Intent postAuthorizationIntent = new Intent(action);
PendingIntent pendingIntent = PendingIntent.getActivity(this, authRequest.hashCode(), postAuthorizationIntent, 0);
mAuthService.performAuthorizationRequest(
authRequest,
pendingIntent,
mAuthService.createCustomTabsIntentBuilder()
.setToolbarColor(getCustomTabColor())
.build());
}
//Todo: Change the color of Chrome custom tabs based on app theme color
@TargetApi(Build.VERSION_CODES.M)
@SuppressWarnings("deprecation")
private int getCustomTabColor() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return getColor(R.color.colorPrimaryDark);
} else {
return getResources().getColor(R.color.colorPrimaryDark);
}
}
}
...@@ -2,9 +2,11 @@ package in.ac.iitb.gymkhana.iitbapp; ...@@ -2,9 +2,11 @@ package in.ac.iitb.gymkhana.iitbapp;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.ActionBarDrawerToggle;
...@@ -12,6 +14,9 @@ import android.support.v7.app.AppCompatActivity; ...@@ -12,6 +14,9 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
import in.ac.iitb.gymkhana.iitbapp.fragments.CalendarFragment;
public class MainActivity extends AppCompatActivity public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener { implements NavigationView.OnNavigationItemSelectedListener {
...@@ -80,17 +85,28 @@ public class MainActivity extends AppCompatActivity ...@@ -80,17 +85,28 @@ public class MainActivity extends AppCompatActivity
// Handle navigation view item clicks here. // Handle navigation view item clicks here.
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.nav_camera) { if (id == R.id.nav_feed) {
// Handle the camera action // Handle the camera action
} else if (id == R.id.nav_gallery) { } else if (id == R.id.nav_my_events) {
} else if (id == R.id.nav_pt_cell) {
} else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_mess_menu) {
} else if (id == R.id.nav_manage) { } else if (id == R.id.nav_gc_rankings) {
} else if (id == R.id.nav_share) { } else if (id == R.id.nav_calendar) {
CalendarFragment calendarFragment = new CalendarFragment();
updateFragment(calendarFragment);
} else if (id == R.id.nav_cms) {
} else if (id == R.id.nav_send) { } else if (id == R.id.nav_timetable) {
} else if (id == R.id.nav_map) {
} else if (id == R.id.nav_contacts) {
} else if (id == R.id.nav_about) {
} }
...@@ -98,4 +114,11 @@ public class MainActivity extends AppCompatActivity ...@@ -98,4 +114,11 @@ public class MainActivity extends AppCompatActivity
drawer.closeDrawer(GravityCompat.START); drawer.closeDrawer(GravityCompat.START);
return true; return true;
} }
private void updateFragment(Fragment fragment) {
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.constraintlayout_for_fragment, fragment, fragment.getTag());
transaction.commit();
}
} }
package in.ac.iitb.gymkhana.iitbapp.fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
* A simple {@link Fragment} subclass.
*/
public class CalendarFragment extends Fragment {
public CalendarFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_calendar, container, false);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/guest_login"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center"
android:text="Guest Login"
/>
<Button
android:id="@+id/ldap_login"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center"
android:text="LDAP login"
/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="in.ac.iitb.gymkhana.iitbapp.MainActivity" android:id="@+id/constraintlayout_for_fragment"
tools:showIn="@layout/app_bar_main"> app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="in.ac.iitb.gymkhana.iitbapp.MainActivity"
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" tools:showIn="@layout/app_bar_main" />
android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragments.CalendarFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>
...@@ -2,23 +2,35 @@ ...@@ -2,23 +2,35 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" tools:showIn="navigation_view"> xmlns:tools="http://schemas.android.com/tools" tools:showIn="navigation_view">
<!--TODO Update icons-->
<group android:checkableBehavior="single"> <group android:checkableBehavior="single">
<item android:id="@+id/nav_camera" android:icon="@drawable/ic_menu_camera" <item android:id="@+id/nav_feed" android:icon="@drawable/ic_feed"
android:title="Import" /> android:title="Feed" />
<item android:id="@+id/nav_gallery" android:icon="@drawable/ic_menu_gallery" <item android:id="@+id/nav_my_events" android:icon="@drawable/ic_event"
android:title="Gallery" /> android:title="My Events" />
<item android:id="@+id/nav_slideshow" android:icon="@drawable/ic_menu_slideshow" <item android:id="@+id/nav_pt_cell" android:icon="@drawable/ic_pt"
android:title="Slideshow" /> android:title="PT Cell" />
<item android:id="@+id/nav_manage" android:icon="@drawable/ic_menu_manage"
android:title="Tools" /> <item android:id="@+id/nav_mess_menu" android:icon="@drawable/ic_mess_menu"
android:title="Mess Menu" />
<item android:id="@+id/nav_gc_rankings" android:icon="@drawable/ic_poll"
android:title="GC Rankings" />
<item android:id="@+id/nav_calendar" android:icon="@drawable/ic_calendar"
android:title="Calendar" />
<item android:id="@+id/nav_timetable" android:icon="@drawable/ic_timetable"
android:title="Timetable" />
<item android:id="@+id/nav_cms" android:icon="@drawable/ic_contacts"
android:title="CMS" />
<item android:id="@+id/nav_map" android:icon="@drawable/ic_map"
android:title="Map" />
</group> </group>
<item android:title="Communicate"> <item android:title="Communicate">
<menu> <menu>
<item android:id="@+id/nav_share" android:icon="@drawable/ic_menu_share" <item android:id="@+id/nav_contacts" android:icon="@drawable/ic_phone"
android:title="Share" /> android:title="Contacts" />
<item android:id="@+id/nav_send" android:icon="@drawable/ic_menu_send" <item android:id="@+id/nav_about" android:icon="@drawable/ic_about"
android:title="Send" /> android:title="About" />
</menu> </menu>
</item> </item>
......
...@@ -5,4 +5,7 @@ ...@@ -5,4 +5,7 @@
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>
...@@ -7,7 +7,7 @@ buildscript { ...@@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1' classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
......
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