Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to replace user image icon #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<string name="news">News</string>
<string name="issues">Issues</string>
<string name="gists">Gists</string>
<string name="sign_out">Sign Out</string>
<string name="commits">Commits</string>
<string name="global_search">GitHub search</string>
<string name="find_repositories">Find Repositories</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
Expand All @@ -24,6 +30,7 @@
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.github.mobile.R;
import com.github.mobile.util.AvatarLoader;
Expand All @@ -49,6 +56,7 @@ public class NavigationDrawerFragment extends Fragment implements AdapterView.On
private ImageView userImage;
private TextView userRealName;
private TextView userName;
private static final int IMAGE_PICKER_SELECT = 999;

public NavigationDrawerFragment() {
}
Expand All @@ -63,6 +71,8 @@ public void onCreate(Bundle savedInstanceState) {
mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
mFromSavedInstanceState = true;
}


}

@Override
Expand Down Expand Up @@ -116,6 +126,16 @@ public void setUp(int fragmentId, DrawerLayout drawerLayout, NavigationDrawerAda
avatar.bind(userImage, user);
userName.setText(user.getLogin());

userImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(i, IMAGE_PICKER_SELECT);
}

});

String name = user.getName();
if (name != null) {
userRealName.setText(user.getName());
Expand Down Expand Up @@ -249,4 +269,25 @@ public int materializedWidth() {
return screenSize.x - actionBarHeight;

}
}

public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == IMAGE_PICKER_SELECT && resultCode == Activity.RESULT_OK) {
MainActivity activity = (MainActivity)getActivity();
Bitmap bitmap = getBitmapFromCameraData(data, activity);
userImage.setImageBitmap(bitmap);
}
}
public static Bitmap getBitmapFromCameraData(Intent data, Context context){
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = context.getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
return BitmapFactory.decodeFile(picturePath);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,12 @@ public boolean onCreateOptionsMenu(final Menu optionsMenu) {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.m_wrap:
if (editor.getWrap())

//enable textWrapping
if (editor.getWrap()){
item.setTitle(R.string.enable_wrapping);
else
codeView.getSettings().setBuiltInZoomControls(true);
} else
item.setTitle(R.string.disable_wrapping);
editor.toggleWrap();
PreferenceUtils.save(PreferenceUtils.getCodePreferences(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ProgressBar;

import com.github.kevinsawicki.wishlist.ViewUtils;
import com.github.mobile.R;
import com.github.mobile.ui.MainActivity;
Expand Down