From 59b172adaacde867811a0b60de6177d7e33e5cd7 Mon Sep 17 00:00:00 2001 From: chanmol1999 Date: Sat, 11 May 2019 01:08:19 +0530 Subject: [PATCH 01/17] Update fragment settings --- app/src/main/AndroidManifest.xml | 3 +- .../java/com/dsciitp/shabd/MainActivity.java | 31 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 201589e..eef742c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,8 @@ android:roundIcon="@drawable/shabd" android:supportsRtl="true" android:theme="@style/AppTheme"> - + 1 && activeFragment.get(activeFragment.size() - 2) instanceof BasicFragment) { @@ -337,16 +342,16 @@ public void onBackPressed() { } private void hideTopBar() { - if (topbar == null) topbar = findViewById(R.id.bar); - if (topbar.getVisibility() == View.VISIBLE) { - topbar.setVisibility(View.GONE); + if (topBar == null) topBar = findViewById(R.id.bar); + if (topBar.getVisibility() == View.VISIBLE) { + topBar.setVisibility(View.GONE); } } private void showTopBar() { - if (topbar == null) topbar = findViewById(R.id.bar); - if (topbar.getVisibility() == View.GONE) { - topbar.setVisibility(View.VISIBLE); + if (topBar == null) topBar = findViewById(R.id.bar); + if (topBar.getVisibility() == View.GONE) { + topBar.setVisibility(View.VISIBLE); } } From 36112e40249a34c6b340847c0d805aa2d5cff7bc Mon Sep 17 00:00:00 2001 From: chanmol1999 Date: Sat, 11 May 2019 16:08:37 +0530 Subject: [PATCH 02/17] Add optio to save image to gallery as well as upload it to firebase storage --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 4 +- .../shabd/Dictionary/DictionaryActivity.java | 144 ++++++----- .../shabd/Learn/Drawing/DrawingActivity.java | 232 ++++++++++++++---- .../main/res/drawable/ic_save_black_24dp.xml | 9 + app/src/main/res/menu/drawingmenu.xml | 13 + 6 files changed, 293 insertions(+), 110 deletions(-) create mode 100644 app/src/main/res/drawable/ic_save_black_24dp.xml create mode 100644 app/src/main/res/menu/drawingmenu.xml diff --git a/app/build.gradle b/app/build.gradle index a41e22a..51324d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,6 +33,7 @@ dependencies { implementation 'com.android.support:design:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support:support-v4:28.0.0' + implementation 'com.google.firebase:firebase-storage:16.0.4' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index eef742c..b3d7108 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,9 @@ - + + + 0) { - word.setText(textString.substring(0, textString.length() - 1)); - word.setSelection(word.getText().length());//position cursor at the end of the line + word.setText( textString.substring( 0, textString.length() - 1 ) ); + word.setSelection( word.getText().length() );//position cursor at the end of the line } } - }); - del.setOnLongClickListener(new View.OnLongClickListener() { + } ); + del.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { String textString = word.getText().toString(); if (textString.length() > 0) { - word.setText(""); - word.setSelection(word.getText().length()); + word.setText( "" ); + word.setSelection( word.getText().length() ); } return false; } - }); - tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() { + } ); + tts = new TextToSpeech( this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status != TextToSpeech.ERROR) { - tts.setLanguage(Locale.US); + tts.setLanguage( Locale.US ); } } - }); + } ); - tts.setPitch(1f); - tts.setSpeechRate(0.9f); - play.setOnClickListener(new View.OnClickListener() { + tts.setPitch( 1f ); + tts.setSpeechRate( 0.9f ); + play.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { - tts.speak(word.getText(), TextToSpeech.QUEUE_FLUSH, null, TTS_SPEAK_ID); - search.animate().scaleX(2f).scaleY(2f).setDuration(1000).translationZBy(25f).withEndAction(new Runnable() { + tts.speak( word.getText(), TextToSpeech.QUEUE_FLUSH, null, TTS_SPEAK_ID ); + search.animate().scaleX( 2f ).scaleY( 2f ).setDuration( 1000 ).translationZBy( 25f ).withEndAction( new Runnable() { @Override public void run() { - search.animate().scaleX(1f).scaleY(1f).setDuration(1000).translationZBy(-25f).withEndAction(new Runnable() { + search.animate().scaleX( 1f ).scaleY( 1f ).setDuration( 1000 ).translationZBy( -25f ).withEndAction( new Runnable() { @Override public void run() { - tts.speak(press, TextToSpeech.QUEUE_FLUSH, null, TTS_SPEAK_ID); - search.animate().scaleX(2f).scaleY(2f).setDuration(1000).translationZBy(+25f).withEndAction(new Runnable() { + tts.speak( press, TextToSpeech.QUEUE_FLUSH, null, TTS_SPEAK_ID ); + search.animate().scaleX( 2f ).scaleY( 2f ).setDuration( 1000 ).translationZBy( +25f ).withEndAction( new Runnable() { @Override public void run() { - search.animate().scaleX(1f).scaleY(1f).translationZBy(25f).setDuration(1000); + search.animate().scaleX( 1f ).scaleY( 1f ).translationZBy( 25f ).setDuration( 1000 ); } - }); + } ); } - }); + } ); } - }); + } ); } - }); + } ); } private void setBaseFragment(Bundle savedInstanceState) { - if (findViewById(R.id.frame_dictionary) != null) { + if (findViewById( R.id.frame_dictionary ) != null) { if (savedInstanceState != null) { return; } DictionaryFragment firstFragment = new DictionaryFragment(); - firstFragment.setArguments(getIntent().getExtras()); + firstFragment.setArguments( getIntent().getExtras() ); getSupportFragmentManager().beginTransaction() - .add(R.id.frame_dictionary, firstFragment).commit(); + .add( R.id.frame_dictionary, firstFragment ).commit(); } } private void transactFragment(Fragment frag) { FragmentTransaction fragmentManager = getSupportFragmentManager().beginTransaction(); - fragmentManager.replace(R.id.frame_dictionary, frag, frag.getTag()) - .addToBackStack(frag.getTag()) + fragmentManager.replace( R.id.frame_dictionary, frag, frag.getTag() ) + .addToBackStack( frag.getTag() ) .commit(); } @Override public void onTopicSelected(String title) { - tts.speak(title, TextToSpeech.QUEUE_FLUSH, null, TTS_SPEAK_ID); - word.append(title); + tts.speak( title, TextToSpeech.QUEUE_FLUSH, null, TTS_SPEAK_ID ); + word.append( title ); } public void onDictionarySelected() { // NetworkUtils.dictionaryEntries(word.getText().toString()); - MeaningFragment fragment = MeaningFragment.newInstance(word.getText().toString()); - transactFragment(fragment); + MeaningFragment fragment = MeaningFragment.newInstance( word.getText().toString() ); + transactFragment( fragment ); final View view = this.getWindow().getDecorView(); - activefragment=fragment; + activefragment = fragment; // view.setBackgroundColor(getResources().getColor(R.color.colorPrimary)); - search.setBackgroundColor(getResources().getColor(R.color.searchBackground)); - search.setOnClickListener(new View.OnClickListener() { + search.setBackgroundColor( getResources().getColor( R.color.searchBackground ) ); + search.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { DictionaryActivity.super.onBackPressed(); onclicksearch(); } - }); + } ); } private void onclicksearch() { - search.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(final View v) { - search.setImageResource(R.color.searchBackground); - search.setBackgroundColor(getResources().getColor(R.color.searchBackground)); - v.animate().x(350f).y(250f).scaleX(40f).scaleY(40f).setDuration(500).translationZBy(25f).withEndAction(new Runnable() { - @Override - public void run() { - v.animate().translationX(0f).translationY(0f).scaleX(1f).scaleY(1f).setDuration(300).translationZBy(-25f).withEndAction(new Runnable() { - @Override - public void run() { - search.setImageResource(R.drawable.ic_search_black_24dp); - } - }); - onDictionarySelected(); - } - }); - } - }); + if (word.getText() == null) { + search.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick(View v) { + // TODO:Add proper message to display with translations + } + } ); + } else { + search.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick(final View v) { + search.setImageResource( R.color.searchBackground ); + search.setBackgroundColor( getResources().getColor( R.color.searchBackground ) ); + v.animate().x( 350f ).y( 250f ).scaleX( 40f ).scaleY( 40f ).setDuration( 500 ).translationZBy( 25f ).withEndAction( new Runnable() { + @Override + public void run() { + v.animate().translationX( 0f ).translationY( 0f ).scaleX( 1f ).scaleY( 1f ).setDuration( 300 ).translationZBy( -25f ).withEndAction( new Runnable() { + @Override + public void run() { + search.setImageResource( R.drawable.ic_search_black_24dp ); + } + } ); + onDictionarySelected(); + } + } ); + } + } ); + } } @Override @@ -174,8 +183,7 @@ protected void onDestroy() { @Override public void onBackPressed() { - if(activefragment instanceof MeaningFragment) - { + if (activefragment instanceof MeaningFragment) { onclicksearch(); } super.onBackPressed(); @@ -183,8 +191,8 @@ public void onBackPressed() { @Override public void onMeaningPass(String data) { - tts.setSpeechRate(0.8f); - tts.speak(data, TextToSpeech.QUEUE_FLUSH, null, TTS_SPEAK_ID); + tts.setSpeechRate( 0.8f ); + tts.speak( data, TextToSpeech.QUEUE_FLUSH, null, TTS_SPEAK_ID ); } } diff --git a/app/src/main/java/com/dsciitp/shabd/Learn/Drawing/DrawingActivity.java b/app/src/main/java/com/dsciitp/shabd/Learn/Drawing/DrawingActivity.java index c5161e4..024eea1 100644 --- a/app/src/main/java/com/dsciitp/shabd/Learn/Drawing/DrawingActivity.java +++ b/app/src/main/java/com/dsciitp/shabd/Learn/Drawing/DrawingActivity.java @@ -1,16 +1,34 @@ package com.dsciitp.shabd.Learn.Drawing; + +import android.content.SharedPreferences; +import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Point; +import android.net.Uri; import android.os.Bundle; +import android.os.Environment; +import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; +import android.util.Log; import android.view.Display; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.widget.Button; +import android.widget.Toast; import com.dsciitp.shabd.R; +import com.dsciitp.shabd.UserConstants; +import com.google.android.gms.tasks.OnFailureListener; +import com.google.android.gms.tasks.OnSuccessListener; +import com.google.firebase.storage.FirebaseStorage; +import com.google.firebase.storage.StorageReference; +import com.google.firebase.storage.UploadTask; import com.pes.androidmaterialcolorpickerdialog.ColorPicker; +import java.io.File; +import java.io.FileOutputStream; import java.util.Random; import me.panavtec.drawableview.DrawableView; @@ -24,51 +42,59 @@ public class DrawingActivity extends AppCompatActivity { private int selectedColorG; private int selectedColorB; private int selectedColorRGB; + private StorageReference mStorageRef; + private SharedPreferences counter; + @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_drawing2); - drawableView= findViewById(R.id.paintView); - Button strokeWidthMinusButton = findViewById(R.id.strokeWidthMinusButton); - Button strokeWidthPlusButton = findViewById(R.id.strokeWidthPlusButton); - Button changeColorButton = findViewById(R.id.changeColorButton); - Button undoButton = findViewById(R.id.undoButton); - Display display = getWindowManager(). getDefaultDisplay(); + super.onCreate( savedInstanceState ); + counter = getSharedPreferences( "i", 0 ); + mStorageRef = FirebaseStorage.getInstance().getReference(); + setContentView( R.layout.activity_drawing2 ); + drawableView = findViewById( R.id.paintView ); + Button strokeWidthMinusButton = findViewById( R.id.strokeWidthMinusButton ); + Button strokeWidthPlusButton = findViewById( R.id.strokeWidthPlusButton ); + Button changeColorButton = findViewById( R.id.changeColorButton ); + Button undoButton = findViewById( R.id.undoButton ); + Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); - display. getSize(size); - int width = size. x; - int height = size. y-200; - final ColorPicker cp = new ColorPicker(DrawingActivity.this, 25, 30, 40); - - config= new DrawableViewConfig(); - config.setStrokeColor(getResources().getColor(android.R.color.black)); - config.setShowCanvasBounds(true); // If the view is bigger than canvas, with this the user will see the bounds (Recommended) - config.setStrokeWidth(20.0f); - config.setMinZoom(1.0f); - config.setMaxZoom(1.0f); - config.setCanvasHeight(height); - config.setCanvasWidth(width); - drawableView.setConfig(config); - strokeWidthPlusButton.setOnClickListener(new View.OnClickListener() { - - @Override public void onClick(View v) { - config.setStrokeWidth(config.getStrokeWidth() + 10); + display.getSize( size ); + int width = size.x; + int height = size.y - 200; + final ColorPicker cp = new ColorPicker( DrawingActivity.this, 25, 30, 40 ); + + config = new DrawableViewConfig(); + config.setStrokeColor( getResources().getColor( android.R.color.black ) ); + config.setShowCanvasBounds( true ); // If the view is bigger than canvas, with this the user will see the bounds (Recommended) + config.setStrokeWidth( 20.0f ); + config.setMinZoom( 1.0f ); + config.setMaxZoom( 1.0f ); + config.setCanvasHeight( height ); + config.setCanvasWidth( width ); + drawableView.setConfig( config ); + strokeWidthPlusButton.setOnClickListener( new View.OnClickListener() { + + @Override + public void onClick(View v) { + config.setStrokeWidth( config.getStrokeWidth() + 10 ); } - }); - strokeWidthMinusButton.setOnClickListener(new View.OnClickListener() { + } ); + strokeWidthMinusButton.setOnClickListener( new View.OnClickListener() { - @Override public void onClick(View v) { - config.setStrokeWidth(config.getStrokeWidth() - 10); + @Override + public void onClick(View v) { + config.setStrokeWidth( config.getStrokeWidth() - 10 ); } - }); - changeColorButton.setOnClickListener(new View.OnClickListener() { + } ); + changeColorButton.setOnClickListener( new View.OnClickListener() { - @Override public void onClick(View v) { + @Override + public void onClick(View v) { Random random = new Random(); cp.show(); - Button okColor = cp.findViewById(R.id.okColorButton); + Button okColor = cp.findViewById( R.id.okColorButton ); - okColor.setOnClickListener(new View.OnClickListener() { + okColor.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { @@ -80,18 +106,142 @@ public void onClick(View v) { /* Or the android RGB Color (see the android Color class reference) */ selectedColorRGB = cp.getColor(); config.setStrokeColor( - Color.argb(255, selectedColorR, selectedColorG, selectedColorB)); + Color.argb( 255, selectedColorR, selectedColorG, selectedColorB ) ); cp.dismiss(); } - }); + } ); } - }); - undoButton.setOnClickListener(new View.OnClickListener() { + } ); + undoButton.setOnClickListener( new View.OnClickListener() { - @Override public void onClick(View v) { + @Override + public void onClick(View v) { drawableView.undo(); } - }); + } ); + //requestPermissionAndContinue(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate( R.menu.drawingmenu, menu ); + return true; + } +// private void requestPermissionAndContinue() { +// if (ContextCompat.checkSelfPermission( this, WRITE_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED +// && ContextCompat.checkSelfPermission( this, READ_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED) { +// +// if (ActivityCompat.shouldShowRequestPermissionRationale( this, WRITE_EXTERNAL_STORAGE ) +// && ActivityCompat.shouldShowRequestPermissionRationale( this, READ_EXTERNAL_STORAGE )) { +// AlertDialog.Builder alertBuilder = new AlertDialog.Builder( this ); +// alertBuilder.setCancelable( true ); +// alertBuilder.setTitle( "Permission necessary" ); +// alertBuilder.setMessage( "jaldi do" ); +// alertBuilder.setPositiveButton( android.R.string.yes, new DialogInterface.OnClickListener() { +// @TargetApi(Build.VERSION_CODES.JELLY_BEAN) +// public void onClick(DialogInterface dialog, int which) { +// ActivityCompat.requestPermissions( DrawingActivity.this, new String[]{WRITE_EXTERNAL_STORAGE +// , READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE ); +// } +// } ); +// AlertDialog alert = alertBuilder.create(); +// alert.show(); +// Log.e( "", "permission denied, show dialog" ); +// } else { +// ActivityCompat.requestPermissions( this, new String[]{WRITE_EXTERNAL_STORAGE, +// READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE ); +// } +// } else { +// openActivity(); +// } +// } +// @Override +// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { +// +// if (requestCode == PERMISSION_REQUEST_CODE) { +// if (permissions.length > 0 && grantResults.length > 0) { +// +// boolean flag = true; +// for (int i = 0; i < grantResults.length; i++) { +// if (grantResults[i] != PackageManager.PERMISSION_GRANTED) { +// flag = false; +// } +// } +// if (flag) { +// openActivity(); +// } else { +// finish(); +// } +// +// } else { +// finish(); +// } +// } else { +// super.onRequestPermissionsResult(requestCode, permissions, grantResults); +// } +// } + + private void openActivity() { + //add your further process after giving permission or to download images from remote server. + } + + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + if (id == R.id.save) { + + Toast.makeText( this, "success", Toast.LENGTH_SHORT ).show(); + drawableView.setDrawingCacheEnabled( true ); + drawableView.setDrawingCacheQuality( View.DRAWING_CACHE_QUALITY_HIGH ); + Bitmap bitmap = drawableView.getDrawingCache(); + File f = new File( Environment.getExternalStorageDirectory().getAbsolutePath(), "shabd" ); + if (!f.exists()) { + f.mkdirs(); + } + SharedPreferences.Editor editor = counter.edit(); + int c = counter.getInt( "i", 1 ); + editor.putInt( "i", ++c ); + editor.apply(); + String s = "image"; + if (UserConstants.displayName != null) + s = UserConstants.displayName; + StorageReference mDrawing = mStorageRef.child( "ShabdDrawing" ).child( s+c ); + File file = new File( f.getAbsolutePath() + "/drawingimage" + c + ".png" ); + + FileOutputStream ostream; + try { + file.createNewFile(); + ostream = new FileOutputStream( file ); + bitmap.compress( Bitmap.CompressFormat.PNG, 100, ostream ); + Uri uri = Uri.fromFile( new File( f.getAbsolutePath() + "/drawingimage" + c + ".png" ) ); + + mStorageRef.putFile( uri ); + UploadTask uploadTask = mDrawing.putFile( uri ); + uploadTask.addOnFailureListener( new OnFailureListener() { + @Override + public void onFailure(@NonNull Exception e) { + Log.d( "myStorage", "failure :(" ); + Toast.makeText( DrawingActivity.this, "Failure", Toast.LENGTH_SHORT ).show(); + } + } ).addOnSuccessListener( new OnSuccessListener() { + @Override + public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { + Log.d( "myStorage", "success!" ); + Toast.makeText( DrawingActivity.this, "Successsss", Toast.LENGTH_SHORT ).show(); + } + } ); + ostream.flush(); + ostream.close(); + Toast.makeText( this, "Image saved", Toast.LENGTH_SHORT ).show(); + } catch (Exception e) { + e.printStackTrace(); + Toast.makeText( this, "Not saved", Toast.LENGTH_SHORT ).show(); + } + + return super.onOptionsItemSelected( item ); + } + return true; } } diff --git a/app/src/main/res/drawable/ic_save_black_24dp.xml b/app/src/main/res/drawable/ic_save_black_24dp.xml new file mode 100644 index 0000000..a561d63 --- /dev/null +++ b/app/src/main/res/drawable/ic_save_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/menu/drawingmenu.xml b/app/src/main/res/menu/drawingmenu.xml new file mode 100644 index 0000000..43c3001 --- /dev/null +++ b/app/src/main/res/menu/drawingmenu.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file From 093c07cb2f9203db7088cd40bc9ba1d25c3ff8b9 Mon Sep 17 00:00:00 2001 From: aparshgupta Date: Sat, 11 May 2019 18:51:16 +0530 Subject: [PATCH 03/17] added rate popup --- app/build.gradle | 2 + .../shabd/Setting/SettingFragment.java | 59 +++++++++++++++++++ app/src/main/res/layout/fragment_setting.xml | 4 +- app/src/main/res/layout/rate_popup.xml | 39 ++++++++++++ app/src/main/res/values-hi-rIN/strings.xml | 2 +- app/src/main/res/values/strings.xml | 1 + build.gradle | 2 +- 7 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/layout/rate_popup.xml diff --git a/app/build.gradle b/app/build.gradle index 51324d6..ff75fb8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,5 +55,7 @@ dependencies { implementation 'com.wang.avi:library:2.1.3' implementation 'me.panavtec:drawableview:0.6.0' implementation 'com.pes.materialcolorpicker:library:1.2.0' + //smilie rating + implementation 'com.github.sujithkanna:smileyrating:1.6.8' } apply plugin: 'com.google.gms.google-services' diff --git a/app/src/main/java/com/dsciitp/shabd/Setting/SettingFragment.java b/app/src/main/java/com/dsciitp/shabd/Setting/SettingFragment.java index 1f52463..e5c5662 100644 --- a/app/src/main/java/com/dsciitp/shabd/Setting/SettingFragment.java +++ b/app/src/main/java/com/dsciitp/shabd/Setting/SettingFragment.java @@ -4,20 +4,27 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.PopupWindow; import android.widget.TextView; import com.bumptech.glide.Glide; import com.dsciitp.shabd.R; import com.dsciitp.shabd.UserConstants; import com.dsciitp.shabd.signin.SigninActivity; +import com.hsalf.smilerating.BaseRating; +import com.hsalf.smilerating.SmileRating; import java.util.Objects; +import static android.content.Context.LAYOUT_INFLATER_SERVICE; + /** * A simple {@link Fragment} subclass. */ @@ -25,6 +32,8 @@ public class SettingFragment extends Fragment { private final String INTENT_ACTION = "intent_action"; private LinearLayout language_setting; + + private int rating; public SettingFragment() { // Required empty public constructor } @@ -63,6 +72,56 @@ public void onClick(View v) { } }); + final LinearLayout settings_layout = view.findViewById(R.id.settings_fragmenr_layout); + LinearLayout rate = view.findViewById(R.id.rate_button); + rate.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + LayoutInflater inflater = (LayoutInflater) + getActivity().getSystemService(LAYOUT_INFLATER_SERVICE); + View popupView = inflater.inflate(R.layout.rate_popup, null); + + SmileRating smileRating = (SmileRating)popupView.findViewById(R.id.smile_rating); + + + smileRating.setOnSmileySelectionListener(new SmileRating.OnSmileySelectionListener() { + @Override + public void onSmileySelected(@BaseRating.Smiley int smiley, boolean reselected) { + + rating=smiley; + } + } + ); + + + + // create the popup window + int width = LinearLayout.LayoutParams.WRAP_CONTENT; + int height = LinearLayout.LayoutParams.WRAP_CONTENT; + boolean focusable = true; // lets taps outside the popup also dismiss it + final PopupWindow popupWindow = new PopupWindow(popupView, width, height, focusable); + + // show the popup window + // which view you pass in doesn't matter, it is only used for the window tolken + popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0); + + // dismiss the popup window when touched + + Button submit = popupView.findViewById(R.id.submit_button); + submit.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //int rating will be sent + // text also + popupWindow.dismiss(); + + } + }); + + + } + }); + ImageView profileImage = view.findViewById(R.id.profile_image); Glide.with(getContext()) .load(UserConstants.photoUri) diff --git a/app/src/main/res/layout/fragment_setting.xml b/app/src/main/res/layout/fragment_setting.xml index b83c7c1..38134ee 100644 --- a/app/src/main/res/layout/fragment_setting.xml +++ b/app/src/main/res/layout/fragment_setting.xml @@ -5,7 +5,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - tools:context=".Setting.SettingFragment"> + tools:context=".Setting.SettingFragment" + android:id="@+id/settings_fragmenr_layout"> + + + + + + +