-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add message reply based on contacts #316
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
.../main/java/com/parishod/watomatic/activity/advancedsettings/AdvancedSettingsActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.parishod.watomatic.activity.advancedsettings; | ||
|
||
import android.os.Bundle; | ||
|
||
import com.parishod.watomatic.R; | ||
import com.parishod.watomatic.activity.BaseActivity; | ||
|
||
public class AdvancedSettingsActivity extends BaseActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_advanced_settings); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/parishod/watomatic/fragment/AdvancedSettingsFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.parishod.watomatic.fragment; | ||
|
||
import android.os.Build; | ||
import android.os.Bundle; | ||
|
||
import androidx.preference.Preference; | ||
import androidx.preference.PreferenceFragmentCompat; | ||
import androidx.preference.SwitchPreference; | ||
|
||
import com.parishod.watomatic.R; | ||
import com.parishod.watomatic.model.utils.ContactsHelper; | ||
|
||
public class AdvancedSettingsFragment extends PreferenceFragmentCompat { | ||
|
||
private Preference advancedPref; | ||
private SwitchPreference enable_contact_replies_preference; | ||
private ContactsHelper contactsHelper; | ||
|
||
@Override | ||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { | ||
setPreferencesFromResource(R.xml.fragment_advanced_settings, rootKey); | ||
|
||
contactsHelper = ContactsHelper.getInstance(getContext()); | ||
|
||
enable_contact_replies_preference = findPreference(getString(R.string.pref_reply_contacts)); | ||
enable_contact_replies_preference.setOnPreferenceChangeListener((preference, newValue) -> { | ||
if ((Boolean) newValue) { | ||
if (contactsHelper.hasContactPermission()) | ||
return true; | ||
else { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
contactsHelper.requestContactPermission(getActivity()); | ||
} | ||
return false; | ||
} | ||
} | ||
return true; | ||
}); | ||
|
||
advancedPref = findPreference(getString(R.string.key_pref_select_contacts)); | ||
advancedPref.setOnPreferenceClickListener(preference -> { | ||
if (contactsHelper.hasContactPermission()) | ||
contactsHelper.showContactPicker(); | ||
else { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
contactsHelper.requestContactPermission(getActivity()); | ||
} | ||
} | ||
return true; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/parishod/watomatic/model/adapters/ContactListAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.parishod.watomatic.model.adapters; | ||
|
||
import android.view.LayoutInflater; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.parishod.watomatic.databinding.ContactListRowBinding; | ||
import com.parishod.watomatic.model.data.ContactHolder; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class ContactListAdapter extends RecyclerView.Adapter<ContactListAdapter.ViewHolder> { | ||
private final ArrayList<ContactHolder> contactHolderArrayList; | ||
|
||
public ContactListAdapter(ArrayList<ContactHolder> contactHolderArrayList) { | ||
this.contactHolderArrayList = contactHolderArrayList; | ||
} | ||
|
||
@NonNull | ||
@NotNull | ||
@Override | ||
public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) { | ||
ContactListRowBinding binding = ContactListRowBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false); | ||
return new ViewHolder(binding); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull @NotNull ViewHolder holder, int position) { | ||
ContactListRowBinding binding = holder.getBinding(); | ||
binding.contactCheckbox.setChecked(contactHolderArrayList.get(position).isChecked()); | ||
binding.contactCheckbox.setText(contactHolderArrayList.get(position).getContactName()); | ||
binding.contactCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> | ||
contactHolderArrayList.get(position).setChecked(isChecked)); | ||
} | ||
|
||
@Override | ||
public void onViewRecycled(@NonNull @NotNull ViewHolder holder) { | ||
ContactListRowBinding binding = holder.getBinding(); | ||
binding.contactCheckbox.setOnCheckedChangeListener(null); | ||
super.onViewRecycled(holder); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return contactHolderArrayList.size(); | ||
} | ||
|
||
@Override | ||
public long getItemId(int position) { | ||
return position; | ||
} | ||
|
||
class ViewHolder extends RecyclerView.ViewHolder { | ||
private final ContactListRowBinding binding; | ||
public ViewHolder(@NonNull @NotNull ContactListRowBinding binding) { | ||
super(binding.getRoot()); | ||
this.binding = binding; | ||
} | ||
|
||
public ContactListRowBinding getBinding() { | ||
return binding; | ||
} | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/parishod/watomatic/model/data/ContactHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.parishod.watomatic.model.data; | ||
|
||
public class ContactHolder { | ||
private final String contactName; | ||
private boolean isChecked; | ||
|
||
public ContactHolder(String contactName, boolean isChecked) { | ||
this.contactName = contactName; | ||
this.isChecked = isChecked; | ||
} | ||
|
||
public String getContactName() { | ||
return contactName; | ||
} | ||
|
||
public void setChecked(boolean checked) { | ||
isChecked = checked; | ||
} | ||
|
||
public boolean isChecked() { | ||
return isChecked; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything is good except group detection. This should work ideally but there is an issue where images messages in WhatsApp group are not being tagged with
isGroupConversation
sometimes (#181).So there is an extra logic to detect that: src
May be we should move that logic to a separate method and reuse it.
Or I will merge this PR as is this evening and raise another one fixing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using that logic, but didn't manage to do it right, so went the easy way as a temporary fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read the issue you mentioned, if we are gonna add a new option to do extra checks in settings, i think this should be changed on the new PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No probs 😊
I'll merge this PR in the evening (CST) as is and make that fix before I forget. Great work!! 🙌
Also, as you are already good with Kotlin, feel free to use that in the future (anything is fine though). I am planning to move this project to Kotlin in the near future anyways as it is getting difficult to stick to Java in the Android world.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, Had to do a hotfix for a previous release. As soon as that is done, will make a PR to fix this group issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds nice
Yay!