Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
immat0x1 committed Feb 26, 2023
1 parent 7238a6c commit 317a24e
Show file tree
Hide file tree
Showing 69 changed files with 289 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ public void onAnimationEnd(Animator animation) {
mSelected = selected;

if (actionState == ACTION_STATE_DRAG) {
if (!ExteraConfig.disableVibration) mSelected.itemView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
mSelected.itemView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
}
final ViewParent rvParent = mRecyclerView.getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7052,7 +7052,6 @@ public final VH createViewHolder(@NonNull ViewGroup parent, int viewType) {
try {
TraceCompat.beginSection(TRACE_CREATE_VIEW_TAG);
final VH holder = onCreateViewHolder(parent, viewType);
if (ExteraConfig.disableVibration) Vibrate.disableHapticFeedback(holder.itemView);
if (holder.itemView.getParent() != null) {
throw new IllegalStateException("ViewHolder views must not be attached when"
+ " created. Ensure that you are not passing 'true' to the attachToRoot"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.TLRPC;

import java.util.Arrays;
Expand All @@ -51,7 +50,7 @@ public class ExteraConfig {

public static int eventType;
public static boolean forceSnow;
public static boolean changeStatus, newGroup, newSecretChat, newChannel, contacts, calls, peopleNearby, archivedChats, savedMessages, scanQr, inviteFriends, telegramFeatures, downloads;
public static boolean changeStatus, newGroup, newSecretChat, newChannel, contacts, calls, peopleNearby, archivedChats, savedMessages, scanQr, inviteFriends, telegramFeatures;

// General
public static int cameraType;
Expand Down Expand Up @@ -199,7 +198,6 @@ public static void loadConfig() {
calls = preferences.getBoolean("calls", false);
peopleNearby = preferences.getBoolean("peopleNearby", false);
archivedChats = preferences.getBoolean("archivedChats", true);
downloads = preferences.getBoolean("downloads", true);
savedMessages = preferences.getBoolean("savedMessages", true);
scanQr = preferences.getBoolean("scanQr", true);
inviteFriends = preferences.getBoolean("inviteFriends", false);
Expand Down Expand Up @@ -306,9 +304,6 @@ public static void toggleDrawerElements(int id) {
case 12:
editor.putBoolean("changeStatus", changeStatus ^= true).apply();
break;
case 13:
editor.putBoolean("downloads", downloads ^= true).apply();
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
import android.os.SystemClock;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.OrientationEventListener;
Expand All @@ -27,6 +25,8 @@
import androidx.camera.core.ImageCapture;
import androidx.camera.view.PreviewView;

import com.exteragram.messenger.extras.Vibrate;

import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.Utilities;
Expand Down Expand Up @@ -490,12 +490,8 @@ public boolean isSameTakePictureOrientation() {
@SuppressLint("MissingPermission")
@Override
public void runHaptic() {
long[] vibrationWaveFormDurationPattern = {0, 1};
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
final Vibrator vibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
VibrationEffect vibrationEffect = VibrationEffect.createWaveform(vibrationWaveFormDurationPattern, -1);
vibrator.cancel();
vibrator.vibrate(vibrationEffect);
Vibrate.vibrate();
} else {
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
import android.view.MotionEvent;
import android.widget.LinearLayout;

import com.exteragram.messenger.ExteraConfig;

import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.TLRPC;
Expand All @@ -28,7 +24,6 @@
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Cells.ChatMessageCell;
import org.telegram.ui.Components.BackgroundGradientDrawable;
import org.telegram.ui.Components.BulletinFactory;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.MotionBackgroundDrawable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
import android.view.View;
import android.view.ViewGroup;

import com.exteragram.messenger.ExteraConfig;

import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.ui.ActionBar.BaseFragment;

public class Vibrate {
public final class Vibrate {

private final static long time = 200L;
private static long[] vibrationWaveFormDurationPattern = {0, 1};

public static void disableHapticFeedback(BaseFragment fragment) {
disableHapticFeedback(fragment.getFragmentView());
}
public static void disableHapticFeedback(View view) {
if (view == null) {
return;
Expand All @@ -42,32 +46,34 @@ public static void disableHapticFeedback(View view) {
}

public static void vibrate() {

if (ExteraConfig.disableVibration) {
return;
}

Vibrator vibrator;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
VibratorManager vibratorManager = (VibratorManager) ApplicationLoader.applicationContext.getSystemService(Context.VIBRATOR_MANAGER_SERVICE);
vibrator = vibratorManager.getDefaultVibrator();
} else {
vibrator = (Vibrator) ApplicationLoader.applicationContext.getSystemService(Context.VIBRATOR_SERVICE);
vibrator = AndroidUtilities.getVibrator();
}
if (vibrator != null && !vibrator.hasVibrator()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
try {
vibrator.vibrate(VibrationEffect.createOneShot(time, VibrationEffect.DEFAULT_AMPLITUDE));
} catch (Exception e) {
FileLog.e("Failed to vibrate");
}
} else {
try {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
VibrationEffect vibrationEffect = VibrationEffect.createWaveform(vibrationWaveFormDurationPattern, -1);
vibrator.cancel();
vibrator.vibrate(vibrationEffect);
setDefaultPattern();
} else {
vibrator.vibrate(time);
} catch (Exception e) {
FileLog.e("Failed to vibrate");
}
} catch (Exception e) {
FileLog.e("Failed to vibrate");
}
}
}

public static void setPattern(long[] pattern) {
vibrationWaveFormDurationPattern = pattern;
}

public static void setDefaultPattern() {
Vibrate.setPattern(new long[]{0, 1});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class IconSetsController {
public static final SparseIntArray solar = new SparseIntArray();

static {


solar.put(R.drawable.arrow_more, R.drawable.arrow_more_solar);
solar.put(R.drawable.attach_send, R.drawable.attach_send_solar);
solar.put(R.drawable.bot_file, R.drawable.msg_round_file_solar);
Expand Down Expand Up @@ -98,6 +100,12 @@ public class IconSetsController {
solar.put(R.drawable.list_pin, R.drawable.msg_pin_mini_solar);
solar.put(R.drawable.list_secret, R.drawable.list_secret_solar);
solar.put(R.drawable.menu_devices, R.drawable.msg_devices_solar);
solar.put(R.drawable.msg2_ask_question, R.drawable.msg_ask_question_solar);
solar.put(R.drawable.msg2_call_earpiece, R.drawable.msg_calls_solar);
solar.put(R.drawable.msg2_gif, R.drawable.msg_gif_solar);
solar.put(R.drawable.msg2_smile_status, R.drawable.input_smile_solar);
solar.put(R.drawable.msg2_sticker, R.drawable.msg_sticker_solar);
solar.put(R.drawable.msg2_videocall, R.drawable.msg_videocall_solar);
solar.put(R.drawable.msg_addbio, R.drawable.msg_addbio_solar);
solar.put(R.drawable.msg_addcontact, R.drawable.msg_contact_add_solar);
solar.put(R.drawable.msg_addfolder, R.drawable.msg_addfolder_solar);
Expand Down Expand Up @@ -358,7 +366,6 @@ public class IconSetsController {
solar.put(R.drawable.msg_theme, R.drawable.msg_theme_solar);
solar.put(R.drawable.msg_timeredit, R.drawable.msg_timeredit_solar);
solar.put(R.drawable.msg_to_beginning, R.drawable.msg_to_beginning_solar);

solar.put(R.drawable.msg_tone_add, R.drawable.msg_tone_add_solar);
solar.put(R.drawable.msg_tone_off, R.drawable.msg_tone_off_solar);
solar.put(R.drawable.msg_tone_on, R.drawable.msg_tone_on_solar);
Expand Down Expand Up @@ -405,7 +412,6 @@ public class IconSetsController {
solar.put(R.drawable.photo_undo, R.drawable.photo_undo_solar);
solar.put(R.drawable.picker, R.drawable.ic_colorpicker_solar);
solar.put(R.drawable.pin, R.drawable.bot_location_solar);
solar.put(R.drawable.player_new_order, R.drawable.player_new_order_solar);
solar.put(R.drawable.profile_discuss, R.drawable.profile_discuss_solar);
solar.put(R.drawable.profile_newmsg_filled, R.drawable.profile_newmsg_filled_solar);
solar.put(R.drawable.profile_phone, R.drawable.profile_phone_solar);
Expand All @@ -417,6 +423,7 @@ public class IconSetsController {
solar.put(R.drawable.reactionchatslist, R.drawable.msg_reactions_filled_solar);
solar.put(R.drawable.screencast_big, R.drawable.screencast_big_solar);
solar.put(R.drawable.search_files_filled, R.drawable.msg_round_file_solar);
solar.put(R.drawable.select_between, R.drawable.msg_select_between_solar);
solar.put(R.drawable.share, R.drawable.msg_filled_shareout_solar);
solar.put(R.drawable.share_arrow, R.drawable.share_arrow_solar);
solar.put(R.drawable.smallanimationpin, R.drawable.smallanimationpin_solar);
Expand All @@ -426,6 +433,7 @@ public class IconSetsController {
solar.put(R.drawable.smiles_tab_settings, R.drawable.smiles_tab_settings_solar);
solar.put(R.drawable.smiles_tab_smiles, R.drawable.input_smile_solar);
solar.put(R.drawable.smiles_tab_stickers, R.drawable.msg_sticker_solar);
solar.put(R.drawable.stickers_empty, R.drawable.stickers_empty_solar);
solar.put(R.drawable.stickers_favorites, R.drawable.stickers_favorites_solar);
solar.put(R.drawable.stickers_gifs_trending, R.drawable.stickers_gifs_trending_solar);
solar.put(R.drawable.stickers_recent, R.drawable.msg_emoji_recent_solar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public class AppearancePreferencesActivity extends BasePreferencesActivity {
private int callsRow;
private int peopleNearbyRow;
private int archivedChatsRow;
private int downloadsRow;
private int savedMessagesRow;
private int scanQrRow;
private int inviteFriendsRow;
Expand Down Expand Up @@ -157,7 +156,6 @@ protected void updateRowsId() {
callsRow = newRow();
peopleNearbyRow = ExteraUtils.hasGps() ? newRow() : -1;
savedMessagesRow = newRow();
downloadsRow = newRow();
scanQrRow = newRow();
inviteFriendsRow = newRow();
telegramFeaturesRow = newRow();
Expand Down Expand Up @@ -273,10 +271,6 @@ protected void onItemClick(View view, int position, float x, float y) {
ExteraConfig.toggleDrawerElements(11);
((TextCell) view).setChecked(ExteraConfig.telegramFeatures);
parentLayout.rebuildAllFragmentViews(false, false);
} else if (position == downloadsRow) {
ExteraConfig.toggleDrawerElements(13);
((TextCell) view).setChecked(ExteraConfig.downloads);
parentLayout.rebuildAllFragmentViews(false, false);
} else if (position == forceSnowRow) {
ExteraConfig.editor.putBoolean("forceSnow", ExteraConfig.forceSnow ^= true).apply();
((TextCheckCell) view).setChecked(ExteraConfig.forceSnow);
Expand All @@ -292,7 +286,7 @@ protected void onItemClick(View view, int position, float x, float y) {
ExteraConfig.editor.putInt("eventType", ExteraConfig.eventType = which).apply();
parentLayout.rebuildAllFragmentViews(false, false);
listAdapter.notifyItemChanged(eventChooserRow, payload);
listAdapter.notifyItemRangeChanged(statusRow, 13);
listAdapter.notifyItemRangeChanged(statusRow, 12);
});
} else if (position == hideActionBarStatusRow) {
ExteraConfig.editor.putBoolean("hideActionBarStatus", ExteraConfig.hideActionBarStatus ^= true).apply();
Expand Down Expand Up @@ -452,8 +446,6 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
textCell.setTextAndCheckAndIcon(LocaleController.getString("SavedMessages", R.string.SavedMessages), ExteraConfig.savedMessages, icons[5], true);
} else if (position == scanQrRow) {
textCell.setTextAndCheckAndIcon(LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient), ExteraConfig.scanQr, R.drawable.msg_qrcode, true);
} else if (position == downloadsRow) {
textCell.setTextAndCheckAndIcon(LocaleController.getString("DownloadsTabs", R.string.DownloadsTabs), ExteraConfig.downloads, R.drawable.msg_download, true);
} else if (position == inviteFriendsRow) {
textCell.setTextAndCheckAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), ExteraConfig.inviteFriends, icons[6], true);
} else if (position == telegramFeaturesRow) {
Expand Down Expand Up @@ -491,7 +483,7 @@ public int getItemViewType(int position) {
return 1;
} else if (position == statusRow || position == newGroupRow || position == newSecretChatRow || position == newChannelRow ||
position == contactsRow || position == callsRow || position == peopleNearbyRow || position == archivedChatsRow ||
position == savedMessagesRow || position == scanQrRow || position == inviteFriendsRow || position == telegramFeaturesRow || position == downloadsRow) {
position == savedMessagesRow || position == scanQrRow || position == inviteFriendsRow || position == telegramFeaturesRow) {
return 2;
} else if (position == appearanceHeaderRow || position == drawerHeaderRow || position == drawerOptionsHeaderRow || position == mainScreenHeaderRow || position == solarIconsHeaderRow) {
return 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.Theme;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected void updateRowsId() {
generalHeaderRow = newRow();
disableNumberRoundingRow = newRow();
formatTimeWithSecondsRow = newRow();
disableVibrationRow = newRow();
disableVibrationRow = -1; // need to be refactored
disableProximitySensorRow = newRow();
tabletModeRow = newRow();
generalDividerRow = newRow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3562,7 +3562,7 @@ public void startRecording(int currentAccount, long dialogId, MessageObject repl
requestAudioFocus(true);

try {
if (!ExteraConfig.disableVibration) feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception e) {
FileLog.e(e);
}
Expand Down Expand Up @@ -3798,7 +3798,7 @@ public void stopRecording(final int send, boolean notify, int scheduleDate) {
}

try {
if (!ExteraConfig.disableVibration) feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception e) {
FileLog.e(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.Surface;
Expand All @@ -51,6 +49,9 @@

import androidx.core.graphics.ColorUtils;

import com.exteragram.messenger.camera.BaseCameraView;
import com.exteragram.messenger.extras.Vibrate;

import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.DispatchQueue;
Expand Down Expand Up @@ -80,9 +81,6 @@
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;

import com.exteragram.messenger.ExteraConfig;
import com.exteragram.messenger.camera.BaseCameraView;

@SuppressLint("NewApi")
public class CameraView extends BaseCameraView implements TextureView.SurfaceTextureListener {

Expand Down Expand Up @@ -649,17 +647,10 @@ public void startTakePictureAnimation() {
}

public void runHaptic() {
long[] vibrationWaveFormDurationPattern = {0, 1};

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {

final Vibrator vibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
VibrationEffect vibrationEffect = VibrationEffect.createWaveform(vibrationWaveFormDurationPattern, -1);

vibrator.cancel();
vibrator.vibrate(vibrationEffect);
Vibrate.vibrate();
} else {
if (!ExteraConfig.disableVibration) performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
}

Expand Down
Loading

0 comments on commit 317a24e

Please sign in to comment.