Skip to content

Commit 413e1f9

Browse files
committed
feat: Add new color themes, improve profile photo retrieval, and refine custom theme and wallpaper handling.
1 parent 37d50d8 commit 413e1f9

9 files changed

Lines changed: 226 additions & 177 deletions

File tree

app/src/main/java/com/wmods/wppenhacer/activities/MessageListActivity.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,7 @@ private void deleteSelectedMessages() {
160160

161161
@Override
162162
public void onRestoreClick(DeletedMessage message) {
163-
com.google.android.material.bottomsheet.BottomSheetDialog bottomSheetDialog = new com.google.android.material.bottomsheet.BottomSheetDialog(
164-
this);
165-
View sheetView = getLayoutInflater().inflate(R.layout.layout_restore_coming_soon, null);
166-
bottomSheetDialog.setContentView(sheetView);
167-
168-
sheetView.findViewById(R.id.btn_follow_dev).setOnClickListener(v -> {
169-
android.content.Intent intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
170-
intent.setData(android.net.Uri.parse("https://github.com/mubashardev"));
171-
startActivity(intent);
172-
bottomSheetDialog.dismiss();
173-
});
174-
175-
bottomSheetDialog.show();
163+
Toast.makeText(this, "Restore coming soon!", Toast.LENGTH_SHORT).show();
176164
}
177165

178166
@Override

app/src/main/java/com/wmods/wppenhacer/ui/fragments/MediaFragment.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public void onResume() {
2424
setDisplayHomeAsUpEnabled(false);
2525
}
2626

27-
2827
@Override
2928
public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
3029
super.onCreatePreferences(savedInstanceState, rootKey);
@@ -42,17 +41,7 @@ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable S
4241

4342
var videoCallScreenRec = findPreference("video_call_screen_rec");
4443
if (videoCallScreenRec != null) {
45-
videoCallScreenRec.setEnabled(true);
46-
videoCallScreenRec.setOnPreferenceClickListener(preference -> {
47-
try {
48-
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW, android.net.Uri.parse("https://github.com/mubashardev"));
49-
startActivity(intent);
50-
} catch (Exception e) {
51-
e.printStackTrace();
52-
}
53-
return true;
54-
});
55-
videoCallScreenRec.setOnPreferenceChangeListener((preference, newValue) -> false); // Prevent toggling
44+
videoCallScreenRec.setEnabled(false);
5645
}
5746
}
5847
}

app/src/main/java/com/wmods/wppenhacer/ui/fragments/base/BasePreferenceFragment.java

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
import rikka.material.preference.MaterialSwitchPreference;
3030

31-
public abstract class BasePreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {
31+
public abstract class BasePreferenceFragment extends PreferenceFragmentCompat
32+
implements SharedPreferences.OnSharedPreferenceChangeListener {
3233
protected SharedPreferences mPrefs;
3334

3435
@Override
@@ -49,7 +50,8 @@ public void handleOnBackPressed() {
4950

5051
@NonNull
5152
@Override
52-
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
53+
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
54+
@Nullable Bundle savedInstanceState) {
5355
chanceStates(null);
5456
monitorPreference();
5557
return super.onCreateView(inflater, container, savedInstanceState);
@@ -93,7 +95,10 @@ private void monitorPreference() {
9395

9496
private boolean checkStoragePermission(Object newValue) {
9597
if (newValue instanceof Boolean && (Boolean) newValue) {
96-
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) || (Build.VERSION.SDK_INT < Build.VERSION_CODES.R && ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
98+
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager())
99+
|| (Build.VERSION.SDK_INT < Build.VERSION_CODES.R
100+
&& ContextCompat.checkSelfPermission(requireContext(),
101+
Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
97102
App.showRequestStoragePermission(requireActivity());
98103
return false;
99104
}
@@ -159,14 +164,12 @@ private void chanceStates(String key) {
159164
setPreferenceState("showonlinetext", !freezelastseen);
160165
setPreferenceState("dotonline", !freezelastseen);
161166

162-
163167
var separategroups = mPrefs.getBoolean("separategroups", false);
164168
setPreferenceState("filtergroups", !separategroups);
165169

166170
var filtergroups = mPrefs.getBoolean("filtergroups", false);
167171
setPreferenceState("separategroups", !filtergroups);
168172

169-
170173
var callBlockContacts = findPreference("call_block_contacts");
171174
var callWhiteContacts = findPreference("call_white_contacts");
172175
if (callBlockContacts != null && callWhiteContacts != null) {
@@ -190,58 +193,62 @@ private void chanceStates(String key) {
190193
}
191194

192195
public void setDisplayHomeAsUpEnabled(boolean enabled) {
193-
if (getActivity() == null) return;
196+
if (getActivity() == null)
197+
return;
194198
var actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
195199
if (actionBar != null) {
196200
actionBar.setDisplayHomeAsUpEnabled(enabled);
197201
}
198202
}
199-
203+
200204
/**
201205
* Scroll to a specific preference by key.
202206
* This is called when navigating from search results.
203207
*/
204208
public void scrollToPreference(String preferenceKey) {
205-
if (preferenceKey == null) return;
206-
209+
if (preferenceKey == null)
210+
return;
211+
207212
// Small delay to ensure preference screen is fully loaded
208213
getView().postDelayed(() -> {
209214
var preference = findPreference(preferenceKey);
210215
if (preference != null) {
211216
scrollToPreference(preference);
212-
217+
213218
// Highlight the preference for visibility
214219
highlightPreference(preference);
215220
}
216221
}, 100);
217222
}
218-
223+
219224
/**
220225
* Highlight a preference with a temporary background color.
221226
*/
222227
private void highlightPreference(androidx.preference.Preference preference) {
223228
// Wait longer to ensure RecyclerView has laid out the views after scrolling
224229
getView().postDelayed(() -> {
225230
androidx.recyclerview.widget.RecyclerView recyclerView = getListView();
226-
if (recyclerView == null || preference == null || preference.getKey() == null) return;
227-
231+
if (recyclerView == null || preference == null || preference.getKey() == null)
232+
return;
233+
228234
// Find the preference view by iterating through visible items
229235
String targetKey = preference.getKey();
230236
boolean found = false;
231-
237+
232238
for (int i = 0; i < recyclerView.getChildCount(); i++) {
233239
android.view.View child = recyclerView.getChildAt(i);
234240
androidx.recyclerview.widget.RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(child);
235-
241+
236242
if (holder instanceof androidx.preference.PreferenceViewHolder) {
237243
androidx.preference.PreferenceViewHolder prefHolder = (androidx.preference.PreferenceViewHolder) holder;
238-
244+
239245
// Try to match by adapter position
240246
int position = prefHolder.getBindingAdapterPosition();
241247
if (position != androidx.recyclerview.widget.RecyclerView.NO_POSITION) {
242248
try {
243249
// Get all preferences recursively
244-
androidx.preference.Preference pref = findPreferenceAtPosition(getPreferenceScreen(), position);
250+
androidx.preference.Preference pref = findPreferenceAtPosition(getPreferenceScreen(),
251+
position);
245252
if (pref != null && pref.getKey() != null && pref.getKey().equals(targetKey)) {
246253
animateHighlight(prefHolder.itemView);
247254
found = true;
@@ -253,21 +260,22 @@ private void highlightPreference(androidx.preference.Preference preference) {
253260
}
254261
}
255262
}
256-
263+
257264
// If not found, try a second time after a longer delay
258265
if (!found) {
259266
getView().postDelayed(() -> tryHighlightAgain(targetKey), 500);
260267
}
261268
}, 500);
262269
}
263-
270+
264271
private void tryHighlightAgain(String targetKey) {
265272
androidx.recyclerview.widget.RecyclerView recyclerView = getListView();
266-
if (recyclerView == null) return;
267-
273+
if (recyclerView == null)
274+
return;
275+
268276
for (int i = 0; i < recyclerView.getChildCount(); i++) {
269277
android.view.View child = recyclerView.getChildAt(i);
270-
278+
271279
// Simple approach: check all text views in the item for matching preference
272280
if (child instanceof android.view.ViewGroup) {
273281
android.view.ViewGroup group = (android.view.ViewGroup) child;
@@ -286,20 +294,23 @@ private void tryHighlightAgain(String targetKey) {
286294
}
287295
}
288296
}
289-
290-
private androidx.preference.Preference findPreferenceAtPosition(androidx.preference.PreferenceGroup group, int targetPosition) {
291-
if (group == null) return null;
292-
297+
298+
private androidx.preference.Preference findPreferenceAtPosition(androidx.preference.PreferenceGroup group,
299+
int targetPosition) {
300+
if (group == null)
301+
return null;
302+
293303
int currentPosition = 0;
294304
for (int i = 0; i < group.getPreferenceCount(); i++) {
295305
androidx.preference.Preference pref = group.getPreference(i);
296-
if (pref == null) continue;
297-
306+
if (pref == null)
307+
continue;
308+
298309
if (currentPosition == targetPosition) {
299310
return pref;
300311
}
301312
currentPosition++;
302-
313+
303314
// Recursively check groups
304315
if (pref instanceof androidx.preference.PreferenceGroup) {
305316
androidx.preference.PreferenceGroup subGroup = (androidx.preference.PreferenceGroup) pref;
@@ -312,7 +323,7 @@ private androidx.preference.Preference findPreferenceAtPosition(androidx.prefere
312323
}
313324
return null;
314325
}
315-
326+
316327
private int countPreferences(androidx.preference.PreferenceGroup group) {
317328
int count = 0;
318329
for (int i = 0; i < group.getPreferenceCount(); i++) {
@@ -325,32 +336,32 @@ private int countPreferences(androidx.preference.PreferenceGroup group) {
325336
}
326337
return count;
327338
}
328-
339+
329340
/**
330341
* Animate a highlight effect on the view.
331342
*/
332343
private void animateHighlight(android.view.View view) {
333-
if (view == null || getContext() == null) return;
334-
344+
if (view == null || getContext() == null)
345+
return;
346+
335347
// Get primary color using android attribute
336348
android.util.TypedValue typedValue = new android.util.TypedValue();
337349
view.getContext().getTheme().resolveAttribute(android.R.attr.colorPrimary, typedValue, true);
338350
int primaryColor = typedValue.data;
339-
351+
340352
// Make it 20% opacity (dim)
341353
int highlightColor = android.graphics.Color.argb(
342-
51, // ~20% of 255
343-
android.graphics.Color.red(primaryColor),
344-
android.graphics.Color.green(primaryColor),
345-
android.graphics.Color.blue(primaryColor)
346-
);
347-
354+
51, // ~20% of 255
355+
android.graphics.Color.red(primaryColor),
356+
android.graphics.Color.green(primaryColor),
357+
android.graphics.Color.blue(primaryColor));
358+
348359
// Save original background
349360
android.graphics.drawable.Drawable originalBackground = view.getBackground();
350-
361+
351362
// Set highlight background
352363
view.setBackgroundColor(highlightColor);
353-
364+
354365
// Fade out after 1.5 seconds
355366
view.postDelayed(() -> {
356367
if (originalBackground != null) {

app/src/main/java/com/wmods/wppenhacer/views/HorizontalListView.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class HorizontalListView extends AdapterView<ListAdapter> {
3535
private OnItemLongClickListener mOnItemLongClicked;
3636
private boolean mDataChanged = false;
3737

38-
3938
public HorizontalListView(Context context, AttributeSet attrs) {
4039
super(context, attrs);
4140
initView();
@@ -46,7 +45,6 @@ public HorizontalListView(Context context) {
4645
initView();
4746
}
4847

49-
5048
private synchronized void initView() {
5149
mLeftViewIndex = -1;
5250
mRightViewIndex = 0;
@@ -122,7 +120,7 @@ private synchronized void reset() {
122120

123121
@Override
124122
public void setSelection(int position) {
125-
//TODO: implement
123+
// TODO: implement
126124
}
127125

128126
private void addAndMeasureChild(final View child, int viewPos) {
@@ -145,13 +143,13 @@ public boolean onDown(@NonNull MotionEvent e) {
145143

146144
@Override
147145
public boolean onFling(MotionEvent e1, @NonNull MotionEvent e2, float velocityX,
148-
float velocityY) {
146+
float velocityY) {
149147
return HorizontalListView.this.onFling(e1, e2, velocityX, velocityY);
150148
}
151149

152150
@Override
153151
public boolean onScroll(MotionEvent e1, @NonNull MotionEvent e2,
154-
float distanceX, float distanceY) {
152+
float distanceX, float distanceY) {
155153

156154
getParent().requestDisallowInterceptTouchEvent(true);
157155

@@ -175,14 +173,17 @@ public boolean onSingleTapConfirmed(@NonNull MotionEvent e) {
175173
viewRect.set(left, top, right, bottom);
176174
if (viewRect.contains((int) e.getX(), (int) e.getY())) {
177175
if (mOnItemClicked != null) {
178-
mOnItemClicked.onItemClick(HorizontalListView.this, child, mLeftViewIndex + 1 + i, mAdapter.getItemId(mLeftViewIndex + 1 + i));
176+
mOnItemClicked.onItemClick(HorizontalListView.this, child, mLeftViewIndex + 1 + i,
177+
mAdapter.getItemId(mLeftViewIndex + 1 + i));
179178
}
180179
if (mOnItemSelected != null) {
181-
mOnItemSelected.onItemSelected(HorizontalListView.this, child, mLeftViewIndex + 1 + i, mAdapter.getItemId(mLeftViewIndex + 1 + i));
180+
mOnItemSelected.onItemSelected(HorizontalListView.this, child, mLeftViewIndex + 1 + i,
181+
mAdapter.getItemId(mLeftViewIndex + 1 + i));
182182
}
183183
int x = (int) e.getX() - left;
184184
int y = (int) e.getY() - top;
185-
MotionEvent motionEvent = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, x, y, 0);
185+
MotionEvent motionEvent = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
186+
MotionEvent.ACTION_DOWN, x, y, 0);
186187
child.dispatchTouchEvent(motionEvent);
187188
motionEvent.recycle();
188189
child.performClick();
@@ -206,7 +207,8 @@ public void onLongPress(@NonNull MotionEvent e) {
206207
viewRect.set(left, top, right, bottom);
207208
if (viewRect.contains((int) e.getX(), (int) e.getY())) {
208209
if (mOnItemLongClicked != null) {
209-
mOnItemLongClicked.onItemLongClick(HorizontalListView.this, child, mLeftViewIndex + 1 + i, mAdapter.getItemId(mLeftViewIndex + 1 + i));
210+
mOnItemLongClicked.onItemLongClick(HorizontalListView.this, child, mLeftViewIndex + 1 + i,
211+
mAdapter.getItemId(mLeftViewIndex + 1 + i));
210212
}
211213
break;
212214
}
@@ -231,7 +233,6 @@ private void fillList(final int dx) {
231233
}
232234
fillListLeft(edge, dx);
233235

234-
235236
}
236237

237238
private void fillListRight(int rightEdge, final int dx) {
@@ -320,7 +321,7 @@ private void requestParentIntercept(boolean allowIntercept) {
320321
}
321322

322323
protected boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
323-
float velocityY) {
324+
float velocityY) {
324325
synchronized (HorizontalListView.this) {
325326
mScroller.fling(mNextX, 0, (int) -velocityX, 0, 0, mMaxX, 0, 0);
326327
}

0 commit comments

Comments
 (0)