Skip to content

Commit

Permalink
v4.1.0 (#105)
Browse files Browse the repository at this point in the history
Co-authored-by: π—ͺπ—œπ—‘π—­π—’π—₯𝗧 <75412448+mikropsoft@users.noreply.github.com>
  • Loading branch information
DP-Hridayan and mikropsoft authored Jul 7, 2024
1 parent 04ea3fb commit 84f0a44
Show file tree
Hide file tree
Showing 15 changed files with 346 additions and 143 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "in.hridayan.ashell"
minSdk 26
targetSdk 34
versionCode 40
versionName "v4.0.3"
versionCode 41
versionName "v4.1.0"
}

lint {
Expand Down
21 changes: 5 additions & 16 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,14 @@
column="23"/>
</issue>

<issue
id="InlinedApi"
message="Field requires API level 31 (current min is 26): `android.R.color#system_accent3_500`"
errorLine1=" mCable.setColorFilter(Utils.getColor(android.R.color.system_accent3_500, requireActivity()));"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/in/hridayan/ashell/fragments/otgShellFragment.java"
line="429"
column="44"/>
</issue>

<issue
id="NonConstantResourceId"
message="Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements"
errorLine1=" case R.id.sort:"
errorLine2=" ~~~~~~~~~">
<location
file="src/main/java/in/hridayan/ashell/activities/ExamplesActivity.java"
line="114"
line="115"
column="18"/>
</issue>

Expand All @@ -74,7 +63,7 @@
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/java/in/hridayan/ashell/activities/ExamplesActivity.java"
line="118"
line="119"
column="18"/>
</issue>

Expand All @@ -85,7 +74,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/in/hridayan/ashell/activities/ExamplesActivity.java"
line="123"
line="124"
column="18"/>
</issue>

Expand All @@ -96,7 +85,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~">
<location
file="src/main/java/in/hridayan/ashell/activities/ExamplesActivity.java"
line="128"
line="129"
column="18"/>
</issue>

Expand All @@ -107,7 +96,7 @@
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/in/hridayan/ashell/activities/ExamplesActivity.java"
line="132"
line="133"
column="18"/>
</issue>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,16 @@ protected void onCreate(Bundle savedInstanceState) {
"id_weiguangtwk",
"weiguangtwk",
getString(R.string.weiguangtwk_about),
R.mipmap.dp_weiguangtwk));
R.mipmap.dp_weiguangtwk));

items.add(
new Category.ContributorsItem(
"id_winzort",
"WINZORT",
getString(R.string.winzort_about),
R.mipmap.dp_winzort));


items.add(new Category(getString(R.string.app)));
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ChangelogActivity extends AppCompatActivity {
private AppBarLayout appBarLayout;
private RecyclerView recyclerViewChangelogs;

private final String[] versionNumbers = {"4.0.3",
private final String[] versionNumbers = {"4.1.0","4.0.3",
"4.0.2", "4.0.1", "4.0.0", "3.9.1", "3.9.0", "3.8.2", "3.8.1", "3.8.0", "3.7.0", "3.6.0",
"3.5.1", "3.5.0", "3.4.0", "3.3.0", "3.2.0", "3.1.0", "3.0.0", "2.0.2", "2.0.1", "2.0.0",
"1.3.0", "1.2.0", "1.1.1", "1.1.0", "1.0.0", "0.9.1", "0.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModel;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements otgShellFragment.OnFragmentInteractionListener {
private boolean isKeyboardVisible;
public BottomNavigationView mNav;
private SettingsAdapter adapter;
Expand Down Expand Up @@ -285,4 +285,10 @@ private void switchFragments(int currentFragment) {
break;
}
}

@Override
public void onRequestReset() {
currentFragment = OTG_FRAGMENT;
replaceFragment(new otgShellFragment());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
idUrlMap.put("id_drDisagree", "https://github.com/Mahmud0808");
idUrlMap.put("id_marciozomb13", "https://github.com/marciozomb13");
idUrlMap.put("id_weiguangtwk", "https://github.com/WeiguangTWK");
idUrlMap.put("id_winzort", "https://github.com/mikropsoft");

String id = ContributorsItem.getId();
String url = idUrlMap.get(id);
Expand Down
117 changes: 69 additions & 48 deletions app/src/main/java/in/hridayan/ashell/fragments/otgShellFragment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package in.hridayan.ashell.fragments;

import android.app.Activity;
import static in.hridayan.ashell.utils.OtgUtils.MessageOtg.CONNECTING;
import static in.hridayan.ashell.utils.OtgUtils.MessageOtg.DEVICE_FOUND;
import static in.hridayan.ashell.utils.OtgUtils.MessageOtg.DEVICE_NOT_FOUND;
Expand Down Expand Up @@ -67,7 +66,6 @@
import in.hridayan.ashell.utils.OtgUtils;
import in.hridayan.ashell.utils.OtgUtils.Const;
import in.hridayan.ashell.utils.OtgUtils.MessageOtg;
import in.hridayan.ashell.utils.Preferences;
import in.hridayan.ashell.utils.SettingsItem;
import in.hridayan.ashell.utils.Utils;
import java.io.File;
Expand All @@ -88,7 +86,6 @@ public class otgShellFragment extends Fragment
private AdbConnection adbConnection;
private UsbManager mManager;
private BottomNavigationView mNav;

private CommandsAdapter mCommandsAdapter;
private LinearLayoutCompat terminalView;
private MaterialButton mSettingsButton, mBookMarks, mHistoryButton;
Expand All @@ -107,13 +104,31 @@ public class otgShellFragment extends Fragment
private View view;
private AdbStream stream;
private Context context;

@Override
public void onAttach(@NonNull Context mContext) {
super.onAttach(mContext);
context = mContext;

private OnFragmentInteractionListener mListener;

public interface OnFragmentInteractionListener {
void onRequestReset();
}

@Override
public void onDetach() {
super.onDetach();
mListener = null;
}

@Override
public void onAttach(@NonNull Context mContext) {
super.onAttach(mContext);
context = mContext;
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
throw new RuntimeException(
context.toString() + " must implement OnFragmentInteractionListener");
}

}

@Nullable
@Override
public View onCreateView(
Expand All @@ -138,7 +153,7 @@ public View onCreateView(
scrollView = view.findViewById(R.id.scrollView);
terminalView = view.findViewById(R.id.terminalView);
mUndoButton = view.findViewById(R.id.fab_undo);

mRecyclerViewCommands.addOnScrollListener(new FabExtendingOnScrollListener(mPasteButton));

mRecyclerViewCommands.setLayoutManager(new LinearLayoutManager(requireActivity()));
Expand All @@ -161,8 +176,6 @@ public void onKeyboardVisibilityChanged(boolean visible) {
}
}
});



if (isSendDrawable) {
mSendButton.setImageDrawable(Utils.getDrawable(R.drawable.ic_send, requireActivity()));
Expand Down Expand Up @@ -228,8 +241,8 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
isSendDrawable = mCommand.getText() != null;

isSendDrawable = mCommand.getText() != null;

mCommandInput.setError(null);

Expand Down Expand Up @@ -280,7 +293,8 @@ public void onClick(View v) {
}

mCommandsAdapter =
new CommandsAdapter(Commands.getPackageInfo(packageNamePrefix + ".",context));
new CommandsAdapter(
Commands.getPackageInfo(packageNamePrefix + ".", context));
if (isAdded()) {
mRecyclerViewCommands.setLayoutManager(
new LinearLayoutManager(requireActivity()));
Expand All @@ -300,7 +314,8 @@ public void onClick(View v) {
mRecyclerViewCommands.setVisibility(View.GONE);
});
} else {
mCommandsAdapter = new CommandsAdapter(Commands.getCommand(s.toString(),context));
mCommandsAdapter =
new CommandsAdapter(Commands.getCommand(s.toString(), context));
if (isAdded()) {
mRecyclerViewCommands.setLayoutManager(
new LinearLayoutManager(requireActivity()));
Expand All @@ -310,8 +325,9 @@ public void onClick(View v) {
mRecyclerViewCommands.setVisibility(View.VISIBLE);
mCommandsAdapter.setOnItemClickListener(
(command, v) -> {
mCommand.setText(command.contains(" <") ? command.split("<")[0] : command);

mCommand.setText(
command.contains(" <") ? command.split("<")[0] : command);

mCommand.setSelection(mCommand.getText().length());
});
}
Expand Down Expand Up @@ -360,6 +376,9 @@ public void onClick(View v) {
sendButtonClicked = true;
mPasteButton.hide();
mUndoButton.hide();
if (mRecyclerViewCommands.getVisibility() == View.VISIBLE) {
mRecyclerViewCommands.setVisibility(View.GONE);
}
if (adbConnection != null) {
putCommand();
} else {
Expand All @@ -386,7 +405,9 @@ public void onClick(View v) {
new MaterialAlertDialogBuilder(requireActivity())
.setTitle(requireActivity().getString(R.string.error))
.setMessage(requireActivity().getString(R.string.otg_not_connected))
.setPositiveButton(requireActivity().getString(R.string.ok), (dialogInterface, i) -> {})
.setPositiveButton(
requireActivity().getString(R.string.ok),
(dialogInterface, i) -> {})
.show();
}
}
Expand Down Expand Up @@ -425,11 +446,6 @@ public void onClick(View v) {
});

// Glow otg symbol when adb connection successfull
if (adbConnection != null) {
mCable.setColorFilter(Utils.getColor(android.R.color.system_accent3_500, requireActivity()));
} else {
mCable.clearColorFilter();
}

mSettingsButton.setTooltipText(getString(R.string.settings));
mSettingsButton.setOnClickListener(
Expand All @@ -444,22 +460,27 @@ public void onClick(View v) {
public void handleMessage(@NonNull android.os.Message msg) {
switch (msg.what) {
case DEVICE_FOUND:
closeWaiting();
terminalView.setVisibility(View.VISIBLE);
initCommand();
KeyboardUtils.showKeyboard(mCommand, context);
if (adbConnection != null) {
mCable.setColorFilter(Utils.getColor(R.color.green, requireActivity()));
}
if (mWaitingDialog != null) {
Toast.makeText(context, "device found", Toast.LENGTH_SHORT).show();
}
break;

case CONNECTING:
// Toast.makeText(context, "connecting", Toast.LENGTH_SHORT).show();
if (adbConnection == null) {
waitingDialog(context);
KeyboardUtils.closeKeyboard(requireActivity(), context);
terminalView.setVisibility(View.VISIBLE);
}

break;

case DEVICE_NOT_FOUND:
closeWaiting();
KeyboardUtils.closeKeyboard(requireActivity(), context);
terminalView.setVisibility(View.VISIBLE);

mCable.clearColorFilter();
// Toast.makeText(context, "device not found!", Toast.LENGTH_SHORT).show();
adbConnection = null; // Fix this issue
break;

Expand Down Expand Up @@ -538,29 +559,32 @@ public void handleMessage(@NonNull android.os.Message msg) {
return view;
}

private void closeWaiting() {
if(mWaitingDialog != null && mWaitingDialog.isShowing())
{
mWaitingDialog.dismiss();
}

}

private void waitingDialog(Context context) {
View dialogView =
LayoutInflater.from(context).inflate(R.layout.loading_dialog_layout, null);
View dialogView = LayoutInflater.from(context).inflate(R.layout.loading_dialog_layout, null);
ProgressBar progressBar = dialogView.findViewById(R.id.progressBar);

mWaitingDialog =
new MaterialAlertDialogBuilder(context)
.setCancelable(false)
.setView(dialogView)
.setTitle(context.getString(R.string.waiting_device))
.setPositiveButton(
getString(R.string.ok),
(dialogInterface, i) -> {
if (mListener != null) {
mListener.onRequestReset();
}
})
.show();

progressBar.setVisibility(View.VISIBLE);
}

private void closeWaiting() {
if (mWaitingDialog != null && mWaitingDialog.isShowing()) {
mWaitingDialog.dismiss();
}
}

public void asyncRefreshAdbConnection(final UsbDevice device) {
if (device != null) {
new Thread() {
Expand Down Expand Up @@ -597,6 +621,8 @@ public void onReceive(Context context, Intent intent) {
} else if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
asyncRefreshAdbConnection(device);
mListener.onRequestReset();

} else if (MessageOtg.USB_PERMISSION.equals(action)) {
System.out.println("From receiver!");
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
Expand Down Expand Up @@ -828,9 +854,4 @@ public void updateInputField(String sharedText) {
mCommand.setSelection(mCommand.getText().length());
}
}



}


Binary file added app/src/main/res/mipmap-hdpi/dp_winzort.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 84f0a44

Please sign in to comment.