diff --git a/Feedback/FeedbackActivity.java b/Feedback/FeedbackActivity.java new file mode 100644 index 00000000..6af32489 --- /dev/null +++ b/Feedback/FeedbackActivity.java @@ -0,0 +1,91 @@ +package com.example.avjindersinghsekhon.minimaltodo.Feedback; + +import android.content.pm.PackageInfo; +import android.graphics.Color; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; +import android.support.annotation.NonNull; +import android.support.v4.app.Fragment; +import android.support.v4.app.NavUtils; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.MenuItem; +import android.widget.TextView; + +import com.example.avjindersinghsekhon.minimaltodo.About.AboutFragment; +import com.example.avjindersinghsekhon.minimaltodo.Analytics.AnalyticsApplication; +import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultActivity; +import com.example.avjindersinghsekhon.minimaltodo.Main.MainFragment; +import com.example.avjindersinghsekhon.minimaltodo.R; + +public class FeedbackActivity extends AppDefaultActivity { + + private TextView mVersionTextView; + private String appVersion = "0.1"; + private Toolbar toolbar; + private TextView contactMe; + String theme; + // private UUID mId; + private AnalyticsApplication app; + + @Override + protected void onCreate(Bundle savedInstanceState) { + + + theme = getSharedPreferences(MainFragment.THEME_PREFERENCES, MODE_PRIVATE).getString(MainFragment.THEME_SAVED, MainFragment.LIGHTTHEME); + if (theme.equals(MainFragment.DARKTHEME)) { + Log.d("OskarSchindler", "One"); + setTheme(R.style.CustomStyle_DarkTheme); + } else { + Log.d("OskarSchindler", "One"); + setTheme(R.style.CustomStyle_LightTheme); + } + + super.onCreate(savedInstanceState); +// mId = (UUID)i.getSerializableExtra(TodoNotificationService.TODOUUID); + + final Drawable backArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha); + if (backArrow != null) { + backArrow.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); + } + try { + PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0); + appVersion = info.versionName; + } catch (Exception e) { + e.printStackTrace(); + } + + toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeAsUpIndicator(backArrow); + } + } + + @Override + protected int contentViewLayoutRes() { + return R.layout.feedback_layout; + } + + @NonNull + protected Fragment createInitialFragment() { + return FeedbackFragment.newInstance(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + if (NavUtils.getParentActivityName(this) != null) { + NavUtils.navigateUpFromSameTask(this); + } + return true; + default: + return super.onOptionsItemSelected(item); + } + } +} diff --git a/Feedback/FeedbackFragment.java b/Feedback/FeedbackFragment.java new file mode 100644 index 00000000..9c9764e8 --- /dev/null +++ b/Feedback/FeedbackFragment.java @@ -0,0 +1,117 @@ +package com.example.avjindersinghsekhon.minimaltodo.Feedback; + +import android.content.Intent; +import android.database.Cursor; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.media.Image; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +import android.provider.MediaStore; +import android.support.annotation.LayoutRes; +import android.support.annotation.Nullable; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; + +import com.example.avjindersinghsekhon.minimaltodo.About.AboutFragment; +import com.example.avjindersinghsekhon.minimaltodo.Analytics.AnalyticsApplication; +import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultActivity; +import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultFragment; +import com.example.avjindersinghsekhon.minimaltodo.R; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import static android.app.Activity.RESULT_OK; + +/** + * Created by Awamry on 12/14/2018. + */ + +public class FeedbackFragment extends AppDefaultFragment { + private Button sendAttachment; + private AnalyticsApplication app; + ImageView imageView; + EditText feedbackText; + TextView noAttachments; + Button sendEmail; + Uri uri; + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + app = (AnalyticsApplication) getActivity().getApplication(); + app.send(this); + sendAttachment = (Button) view.findViewById(R.id.attach_photo); + sendEmail = (Button) view.findViewById(R.id.send_email); + imageView = (ImageView) view.findViewById(R.id.imageView1); + feedbackText = (EditText) view.findViewById(R.id.feedback_text); + noAttachments = (TextView)view.findViewById(R.id.no_attachment_view); + sendAttachment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Intent intent = new Intent(Intent.ACTION_PICK, + android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + startActivityForResult(intent, 0); + } + }); + + sendEmail.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String message = feedbackText.getText().toString(); + String[] recipients = new String[]{"avisekhon2@gmail.com"}; + Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); + emailIntent.setType("application/image"); + emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,recipients); + emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Feedback Report"); + emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,message); + emailIntent.putExtra(Intent.EXTRA_STREAM, uri); //this line is added to your code + startActivity(emailIntent); + } + }); + + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + if(requestCode==0&&resultCode==RESULT_OK&&data!=null&&data.getData()!=null){ + noAttachments.setVisibility(View.INVISIBLE); + uri = data.getData(); + try{ + Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContext().getContentResolver(),uri); + imageView.setImageBitmap(bitmap); + + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + @LayoutRes + protected int layoutRes() { + return R.layout.fragment_feedback; + } + + public static FeedbackFragment newInstance() { + return new FeedbackFragment(); + } +} diff --git a/MainActivity.java b/MainActivity.java new file mode 100644 index 00000000..7235551d --- /dev/null +++ b/MainActivity.java @@ -0,0 +1,86 @@ +package com.example.avjindersinghsekhon.minimaltodo.Main; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.Fragment; +import android.support.v7.app.ActionBar; +import android.view.Menu; +import android.view.MenuItem; + +import com.example.avjindersinghsekhon.minimaltodo.About.AboutActivity; +import com.example.avjindersinghsekhon.minimaltodo.AppDefault.AppDefaultActivity; +import com.example.avjindersinghsekhon.minimaltodo.Feedback.FeedbackActivity; +import com.example.avjindersinghsekhon.minimaltodo.R; +import com.example.avjindersinghsekhon.minimaltodo.Settings.SettingsActivity; + +public class MainActivity extends AppDefaultActivity { + + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(false); + } + } + + @Override + protected int contentViewLayoutRes() { + return R.layout.activity_main; + } + + @NonNull + @Override + protected Fragment createInitialFragment() { + return MainFragment.newInstance(); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.aboutMeMenuItem: + Intent i = new Intent(this, AboutActivity.class); + startActivity(i); + return true; +// case R.id.switch_themes: +// if(mTheme == R.style.CustomStyle_DarkTheme){ +// addThemeToSharedPreferences(LIGHTTHEME); +// } +// else{ +// addThemeToSharedPreferences(DARKTHEME); +// } +// +//// if(mTheme == R.style.CustomStyle_DarkTheme){ +//// mTheme = R.style.CustomStyle_LightTheme; +//// } +//// else{ +//// mTheme = R.style.CustomStyle_DarkTheme; +//// } +// this.recreate(); +// return true; + case R.id.preferences: + Intent intent = new Intent(this, SettingsActivity.class); + startActivity(intent); + return true; + + case R.id.feedback: + Intent i2 = new Intent(this, FeedbackActivity.class); + startActivity(i2); + return true; + + default: + return super.onOptionsItemSelected(item); + } + } + +} + + diff --git a/feedback_layout.xml b/feedback_layout.xml new file mode 100644 index 00000000..74203e4c --- /dev/null +++ b/feedback_layout.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/fragment_feedback.xml b/fragment_feedback.xml new file mode 100644 index 00000000..55fae1d7 --- /dev/null +++ b/fragment_feedback.xml @@ -0,0 +1,87 @@ + + + + + + + +