-
-
Notifications
You must be signed in to change notification settings - Fork 188
This pull request enables new group widgets #669
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
Draft
Altonss
wants to merge
52
commits into
CatimaLoyalty:main
Choose a base branch
from
Altonss:group-widget-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
7fca6db
Add code 93
e727a27
Merge remote-tracking branch 'origin/master'
8c86fa8
Fix long press to add card to group
a15cc31
Merge remote-tracking branch 'origin/master'
4304a51
Merge remote-tracking branch 'origin/master'
7cf8d89
First step to implement group widget
2504a24
Try to fix (try with a standard list view)
4a5f517
Try to fix with group cursors
1bfff05
Blank list, fix with GroupCursorAdapter
a8f9baf
implement GroupCursorAdapter
a6aa6f6
implement click action
10da2a7
try fixes with renaming groupListListItemViewHolder
5a074db
try fixes with onResume group view
8078f0c
try fixes with updateLoyaltyCardList()
d57f26e
try fixes with groupTabs selectTab
d3c2412
fix, just set selectedTab
30f1381
Revert some changes to see if the app starts again correctly :/
36cdbd1
Select group for widget
7563bee
fix select button class
004df4a
Merge branch 'master' of https://github.com/TheLastProject/Catima int…
b61ed93
Add onResume group widget logic
22dbd1d
Add elements to onResume group widget logic
ff2d23e
Fixes to onResume
a1e9bfb
Fixes to MainActivity.java
dc8fd57
Respect order and orderDirection when opening a widget
9b13be0
Edit and delete group shortcuts implemented
2548759
Fix edit group shortcut
0d8acbf
Group not found implemented
b5ab5d7
Revert some wrong shortcut related commits
ec95b0b
Simplify MainActivity.java
a0c0332
Merge branch 'master' into group-widget-2
Altonss ed84142
Update MainActivity.java
Altonss b7d20f3
Several fixes:
5681326
Fix missing group error message: make groupWidget string not final
5092731
Fix MainActivity
d6b82bb
Merge remote-tracking branch 'origin/master'
ec06134
Fix icon and shortcutId
90dfa93
Set GroupShortcut to use Catima Icon
e36657e
Add fix in ShortcutBuilder with intent flags
5e2cbd9
Fix LoyaltyCardEditActivity according to Android studio
7bc52a7
Merge remote-tracking branch 'origin/master'
8284293
Merge branch 'master' into group-widget-2
2fd7292
Merge new db changes
0b4e4be
Small fix (make spotbugs happy :))
b5dae66
Merge remote-tracking branch 'origin/master' into group-widget-2
bc9fc4f
Merge current master branch into this branch, to keep it up to date w…
f58bb48
Merge remote-tracking branch 'origin/master' into group-widget-2
608dd76
Small improvement
fecad9c
Merge branch 'master' into group-widget-2
Altonss 1301e61
Small improvements and fix extract intent
02f2ab1
Fix bugs
aa53837
Merge remote-tracking branch 'origin/master' into group-widget-2
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 hidden or 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
74 changes: 74 additions & 0 deletions
74
app/src/main/java/protect/card_locker/GroupSelectCursorAdapter.java
This file contains hidden or 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,74 @@ | ||
package protect.card_locker; | ||
|
||
import android.content.Context; | ||
import android.database.Cursor; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.widget.AppCompatButton; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import protect.card_locker.preferences.Settings; | ||
|
||
public class GroupSelectCursorAdapter extends BaseCursorAdapter<GroupSelectCursorAdapter.GroupListItemViewHolder> { | ||
Settings mSettings; | ||
private final Context mContext; | ||
private final GroupAdapterListener mListener; | ||
SQLiteDatabase mDatabase; | ||
|
||
public GroupSelectCursorAdapter(Context inputContext, Cursor inputCursor, GroupAdapterListener inputListener) { | ||
super(inputCursor, DBHelper.LoyaltyCardDbGroups.ORDER); | ||
setHasStableIds(true); | ||
mSettings = new Settings(inputContext); | ||
mContext = inputContext.getApplicationContext(); | ||
mListener = inputListener; | ||
mDatabase = new DBHelper(inputContext).getReadableDatabase(); | ||
|
||
swapCursor(inputCursor); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public GroupSelectCursorAdapter.GroupListItemViewHolder onCreateViewHolder(ViewGroup inputParent, int inputViewType) { | ||
View itemView = LayoutInflater.from(inputParent.getContext()).inflate(R.layout.group_select_layout, inputParent, false); | ||
return new GroupListItemViewHolder(itemView); | ||
} | ||
|
||
public void onBindViewHolder(GroupListItemViewHolder inputHolder, Cursor inputCursor) { | ||
Group group = Group.toGroup(inputCursor); | ||
|
||
inputHolder.mName.setText(group._id); | ||
|
||
int groupCardCount = DBHelper.getGroupCardCount(mDatabase, group._id); | ||
inputHolder.mCardCount.setText(mContext.getResources().getQuantityString(R.plurals.groupCardCount, groupCardCount, groupCardCount)); | ||
|
||
inputHolder.mName.setTextSize(mSettings.getFontSizeMax(mSettings.getMediumFont())); | ||
inputHolder.mCardCount.setTextSize(mSettings.getFontSizeMax(mSettings.getSmallFont())); | ||
|
||
applyClickEvents(inputHolder); | ||
} | ||
|
||
private void applyClickEvents(GroupListItemViewHolder inputHolder) { | ||
inputHolder.mSelect.setOnClickListener(view -> mListener.onSelectButtonClicked(inputHolder.itemView)); | ||
} | ||
|
||
public interface GroupAdapterListener { | ||
void onSelectButtonClicked(View view); | ||
} | ||
|
||
public static class GroupListItemViewHolder extends RecyclerView.ViewHolder { | ||
public TextView mName, mCardCount; | ||
public AppCompatButton mSelect; | ||
|
||
public GroupListItemViewHolder(View inputView) { | ||
super(inputView); | ||
mName = inputView.findViewById(R.id.name); | ||
mCardCount = inputView.findViewById(R.id.cardCount); | ||
mSelect = inputView.findViewById(R.id.select); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
app/src/main/java/protect/card_locker/GroupShortcutConfigure.java
This file contains hidden or 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,81 @@ | ||
package protect.card_locker; | ||
|
||
import android.database.Cursor; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import androidx.appcompat.widget.Toolbar; | ||
import androidx.core.content.pm.ShortcutInfoCompat; | ||
import androidx.core.content.pm.ShortcutManagerCompat; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
/** | ||
* The configuration screen for creating a shortcut. | ||
*/ | ||
public class GroupShortcutConfigure extends CatimaAppCompatActivity implements GroupSelectCursorAdapter.GroupAdapterListener { | ||
static final String TAG = "Catima"; | ||
private SQLiteDatabase mDatabase; | ||
|
||
@Override | ||
public void onCreate(Bundle bundle) { | ||
super.onCreate(bundle); | ||
|
||
mDatabase = new DBHelper(this).getReadableDatabase(); | ||
|
||
|
||
// Set the result to CANCELED. This will cause nothing to happen if the | ||
// aback button is pressed. | ||
setResult(RESULT_CANCELED); | ||
|
||
setContentView(R.layout.simple_toolbar_list_activity); | ||
Toolbar toolbar = findViewById(R.id.toolbar); | ||
toolbar.setTitle(R.string.shortcutSelectGroup); | ||
|
||
// If there are no groups, bail | ||
if (DBHelper.getGroupCount(mDatabase) == 0) { | ||
Toast.makeText(this, R.string.noGroups, Toast.LENGTH_LONG).show(); | ||
finish(); | ||
} | ||
|
||
final RecyclerView groupList = findViewById(R.id.list); | ||
|
||
Cursor groupCursor = DBHelper.getGroupCursor(mDatabase); | ||
final GroupSelectCursorAdapter adapter = new GroupSelectCursorAdapter(this, groupCursor,this); | ||
groupList.setAdapter(adapter); | ||
} | ||
|
||
private String getGroupName(View view) { | ||
TextView groupNameTextView = view.findViewById(R.id.name); | ||
return (String) groupNameTextView.getText(); | ||
} | ||
|
||
private void onClickAction(View view) { | ||
String groupId = getGroupName(view); | ||
if (groupId == null) { | ||
throw (new IllegalArgumentException("The widget expects a group")); | ||
} | ||
Log.d("groupId", "groupId: " + groupId); | ||
Group group = DBHelper.getGroup(mDatabase, groupId); | ||
if (group == null) { | ||
throw (new IllegalArgumentException("cannot load group " + groupId + " from database")); | ||
} | ||
|
||
Log.d(TAG, "Creating shortcut for group " + group._id + "," + group._id); | ||
|
||
ShortcutInfoCompat shortcut = ShortcutHelper.createGroupShortcutBuilder(GroupShortcutConfigure.this, group).build(); | ||
|
||
setResult(RESULT_OK, ShortcutManagerCompat.createShortcutResultIntent(GroupShortcutConfigure.this, shortcut)); | ||
|
||
finish(); | ||
} | ||
|
||
@Override | ||
public void onSelectButtonClicked(View view) { | ||
onClickAction(view); | ||
} | ||
|
||
} |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -714,7 +714,6 @@ public void onBackPressed() { | |
setFullscreen(false); | ||
return; | ||
} | ||
|
||
super.onBackPressed(); | ||
} | ||
|
||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -25,4 +25,5 @@ | |
android:clipToPadding="false" | ||
android:scrollbars="vertical" | ||
android:visibility="gone" /> | ||
|
||
</RelativeLayout> |
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.
Uh oh!
There was an error while loading. Please reload this page.