added settings screen
also added camera connection
This commit is contained in:
parent
bd992f1beb
commit
e0a89d5149
5 changed files with 174 additions and 1 deletions
|
@ -12,6 +12,11 @@
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
|
<!--<uses-feature android:name="android.hardware.camera"/>-->
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
|
|
||||||
|
<!--<uses-feature android:name="android.hardware.camera"-->
|
||||||
|
<!--android:required="true" />-->
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
private boolean locationPermission;
|
private boolean locationPermission;
|
||||||
private GmapFragment gmapFragment;
|
private GmapFragment gmapFragment;
|
||||||
private PersonalFragment personalFragment;
|
private PersonalFragment personalFragment;
|
||||||
|
private SettingsFragment settingsFragment;
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
public static final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
|
public static final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
|
||||||
private ImageView menu_avatar;
|
private ImageView menu_avatar;
|
||||||
|
@ -64,6 +65,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
gmapFragment = new GmapFragment();
|
gmapFragment = new GmapFragment();
|
||||||
personalFragment = new PersonalFragment();
|
personalFragment = new PersonalFragment();
|
||||||
|
settingsFragment = new SettingsFragment();
|
||||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||||
StrictMode.setThreadPolicy(policy);
|
StrictMode.setThreadPolicy(policy);
|
||||||
|
|
||||||
|
@ -165,6 +167,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
} else if (id == R.id.nav_settings) {
|
} else if (id == R.id.nav_settings) {
|
||||||
toolbar.setTitle("Settings");
|
toolbar.setTitle("Settings");
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
ft.replace(R.id.fragment_container, settingsFragment);
|
||||||
|
ft.commit();
|
||||||
} else if (id == R.id.nav_logout) {
|
} else if (id == R.id.nav_logout) {
|
||||||
|
|
||||||
SharedPreferences sharedPref = this.getSharedPreferences(MainActivity.LOCAL_DATA_TSN, Context.MODE_PRIVATE);
|
SharedPreferences sharedPref = this.getSharedPreferences(MainActivity.LOCAL_DATA_TSN, Context.MODE_PRIVATE);
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
package com.android_app.matan.ara.sagi.thesocialnotework;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
public class SettingsFragment extends Fragment {
|
||||||
|
private static final String ARG_PARAM1 = "param1";
|
||||||
|
private static final String ARG_PARAM2 = "param2";
|
||||||
|
private static final String TAG = "Settings" ;
|
||||||
|
private static final int REQUEST_IMAGE_CAPTURE = 1;
|
||||||
|
private Button cameraBtn;
|
||||||
|
private ImageView avatarImage;
|
||||||
|
// private OnFragmentInteractionListener mListener;
|
||||||
|
|
||||||
|
|
||||||
|
public SettingsFragment() {
|
||||||
|
// Required empty public constructor
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this factory method to create a new instance of
|
||||||
|
* this fragment using the provided parameters.
|
||||||
|
*
|
||||||
|
* @param param1 Parameter 1.
|
||||||
|
* @param param2 Parameter 2.
|
||||||
|
* @return A new instance of fragment SettingsFragment.
|
||||||
|
*/
|
||||||
|
// TODO: Rename and change types and number of parameters
|
||||||
|
public static SettingsFragment newInstance(String param1, String param2) {
|
||||||
|
SettingsFragment fragment = new SettingsFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString(ARG_PARAM1, param1);
|
||||||
|
args.putString(ARG_PARAM2, param2);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.fragment_settings, container, false);
|
||||||
|
|
||||||
|
cameraBtn = (Button) view.findViewById(R.id.camera_button);
|
||||||
|
cameraBtn.setOnClickListener(cameraBtnListener);
|
||||||
|
avatarImage = (ImageView) view.findViewById(R.id.settings_userAvater_iamgeView);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
// // TODO: Rename method, update argument and hook method into UI event
|
||||||
|
// public void onButtonPressed(Uri uri) {
|
||||||
|
// if (mListener != null) {
|
||||||
|
// mListener.onFragmentInteraction(uri);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Context context) {
|
||||||
|
super.onAttach(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetach() {
|
||||||
|
super.onDetach();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * This interface must be implemented by activities that contain this
|
||||||
|
// * fragment to allow an interaction in this fragment to be communicated
|
||||||
|
// * to the activity and potentially other fragments contained in that
|
||||||
|
// * activity.
|
||||||
|
// * <p>
|
||||||
|
// * See the Android Training lesson <a href=
|
||||||
|
// * "http://developer.android.com/training/basics/fragments/communicating.html"
|
||||||
|
// * >Communicating with Other Fragments</a> for more information.
|
||||||
|
// */
|
||||||
|
// public interface OnFragmentInteractionListener {
|
||||||
|
// // TODO: Update argument type and name
|
||||||
|
// void onFragmentInteraction(Uri uri);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private View.OnClickListener cameraBtnListener = new View.OnClickListener()
|
||||||
|
{
|
||||||
|
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
|
||||||
|
Log.d(TAG, "in camera Button");
|
||||||
|
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
|
||||||
|
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
Log.d(TAG, "on activity result");
|
||||||
|
Log.d(TAG, "requestCode: "+requestCode);
|
||||||
|
Log.d(TAG, "resultCode: "+resultCode);
|
||||||
|
Log.d(TAG, "Activity.RESULT_OK: "+Activity.RESULT_OK);
|
||||||
|
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == Activity.RESULT_OK) {
|
||||||
|
Log.d(TAG, "inside if");
|
||||||
|
|
||||||
|
Bundle extras = data.getExtras();
|
||||||
|
Bitmap imageBitmap= (Bitmap) extras.get("data");
|
||||||
|
Log.d(TAG, "bitmap: "+imageBitmap.toString());
|
||||||
|
|
||||||
|
// Bitmap imageBitmap = (Bitmap) extras.get("data");
|
||||||
|
avatarImage.setImageBitmap(imageBitmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
20
app/src/main/res/layout/fragment_settings.xml
Normal file
20
app/src/main/res/layout/fragment_settings.xml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<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="com.android_app.matan.ara.sagi.thesocialnotework.SettingsFragment">
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Change"
|
||||||
|
android:id="@+id/camera_button"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/settings_userAvater_iamgeView"
|
||||||
|
android:layout_gravity="center_horizontal|bottom" />
|
||||||
|
</FrameLayout>
|
|
@ -38,6 +38,6 @@
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||||
<string name="login_err_message_invalid">Password should be at least 4 chars long</string>
|
<string name="login_err_message_invalid">Password should be at least 4 chars long</string>
|
||||||
<string name="title_activity_maps">Map</string>
|
<string name="title_activity_maps">Map</string>
|
||||||
<string name="avatar">Avatar</string>
|
<string name="avatar">Avatar</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue