Skip to content

Commit

Permalink
added Device section
Browse files Browse the repository at this point in the history
  • Loading branch information
Akilesh-T committed Feb 2, 2019
1 parent 944b2d1 commit 7aa473e
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions app/src/main/java/app/akilesh/nex/DeviceFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package app.akilesh.nex;

import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import static android.content.ContentValues.TAG;


public class DeviceFragment extends Fragment {
private OnFragmentInteractionListener listener;

static DeviceFragment newInstance() {
return new DeviceFragment();
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

}


@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.device_fragment, container, false);

String brand = Build.BRAND;
TextView deviceBrand = view.findViewById(R.id.brand);
deviceBrand.setText(String.format("%s", brand));

String model = Build.MODEL;
TextView deviceModel = view.findViewById(R.id.model);
deviceModel.setText(String.format("%s", model));

String code = Build.DEVICE;
TextView deviceCodeName = view.findViewById(R.id.codeName);
deviceCodeName.setText(String.format("%s", code));

String buildVer = null;
try {
Process process = Runtime.getRuntime().exec("su");
InputStream in = process.getInputStream();
OutputStream out = process.getOutputStream();
String cmd = "cat /data/misc/box/report/PREV_VER";
out.write(cmd.getBytes());
out.flush();
out.close();
byte[] buffer = new byte[1024];
int length = in.read(buffer);
buildVer = new String(buffer, 0, length);
process.waitFor();
} catch (IOException e) {
Log.e(TAG, "IOException, " + e.getMessage());
} catch (InterruptedException e) {
Log.e(TAG, "InterruptedException, " + e.getMessage());
}

TextView build = view.findViewById(R.id.buildVersion);
build.setText(String.format("%s", buildVer));

return view;
}

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

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


interface OnFragmentInteractionListener {
}

}
12 changes: 10 additions & 2 deletions app/src/main/java/app/akilesh/nex/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.akilesh.nex;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.fragment.app.Fragment;
Expand All @@ -13,6 +14,7 @@
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.Html;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
Expand All @@ -22,14 +24,15 @@


import java.util.List;
import java.util.Objects;

import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;



public class MainActivity extends AppCompatActivity implements HomeFragment.OnFragmentInteractionListener, AboutFragment.OnFragmentInteractionListener, HelpFragment.OnFragmentInteractionListener, ThemeFragment.OnFragmentInteractionListener {
public class MainActivity extends AppCompatActivity implements HomeFragment.OnFragmentInteractionListener, AboutFragment.OnFragmentInteractionListener, HelpFragment.OnFragmentInteractionListener, ThemeFragment.OnFragmentInteractionListener, DeviceFragment.OnFragmentInteractionListener {
int modeType;

@Override
Expand All @@ -42,6 +45,8 @@ protected void onCreate(Bundle savedInstanceState) {
int themeID = sharedPref.getInt("ThemePrefs",1);
AppCompatDelegate.setDefaultNightMode(themeID);

Objects.requireNonNull(getSupportActionBar()).setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.abs_layout);

View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
Expand All @@ -51,7 +56,6 @@ protected void onCreate(Bundle savedInstanceState) {

}

//
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
Expand All @@ -72,6 +76,10 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
fragment = ThemeFragment.newInstance();
break;

case R.id.device_info:
fragment = DeviceFragment.newInstance();
break;


}
if (fragment != null) {
Expand Down
Binary file added app/src/main/res/drawable/smartphone.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions app/src/main/res/layout/abs_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textColor="@color/colorAccent"
android:text="@string/app_name"/>

</LinearLayout>
195 changes: 195 additions & 0 deletions app/src/main/res/layout/device_fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="?actionBarSize"
android:background="@color/background"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">




<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
xmlns:tools="http://schemas.android.com/tools">



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="16dp"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="@color/background"
tools:layout_editor_absoluteX="4dp"
tools:layout_editor_absoluteY="50dp">

<com.google.android.material.card.MaterialCardView
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="15dp"
android:innerRadius="0dp"
android:layout_marginLeft="@dimen/mtrl_card_spacing"
android:layout_marginTop="@dimen/mtrl_card_spacing"
android:layout_marginRight="@dimen/mtrl_card_spacing"
android:minHeight="70dp"
app:cardBackgroundColor="@color/background"
tools:ignore="PrivateResource">

<TextView
style="?android:attr/listSeparatorTextViewStyle"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textAllCaps="false"
android:textColor="@color/colorAccent"
android:layout_marginTop="5dp"
android:background="@color/background"
android:textSize="19sp"
android:text="@string/brand"/>


<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="fill_horizontal"
android:layout_marginStart="10dp"
android:layout_marginTop="35dp"
android:textSize="18sp"
android:background="@color/background"
android:textColor="?android:attr/textColorPrimary"
android:id="@+id/brand"/>

</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="15dp"
android:innerRadius="0dp"
android:layout_marginLeft="@dimen/mtrl_card_spacing"
android:layout_marginTop="@dimen/mtrl_card_spacing"
android:layout_marginRight="@dimen/mtrl_card_spacing"
android:minHeight="70dp"
app:cardBackgroundColor="@color/background"
tools:ignore="PrivateResource">

<TextView
style="?android:attr/listSeparatorTextViewStyle"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textAllCaps="false"
android:textColor="@color/colorAccent"
android:layout_marginTop="5dp"
android:background="@color/background"
android:textSize="19sp"
android:text="@string/model"/>


<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="fill_horizontal"
android:layout_marginStart="10dp"
android:layout_marginTop="35dp"
android:textSize="18sp"
android:background="@color/background"
android:textColor="?android:attr/textColorPrimary"
android:id="@+id/model"/>

</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="15dp"
android:innerRadius="0dp"
android:layout_marginLeft="@dimen/mtrl_card_spacing"
android:layout_marginTop="@dimen/mtrl_card_spacing"
android:layout_marginRight="@dimen/mtrl_card_spacing"
android:minHeight="70dp"
app:cardBackgroundColor="@color/background"
tools:ignore="PrivateResource">

<TextView
style="?android:attr/listSeparatorTextViewStyle"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textAllCaps="false"
android:textColor="@color/colorAccent"
android:layout_marginTop="5dp"
android:background="@color/background"
android:textSize="19sp"
android:text="@string/code_name"/>


<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="fill_horizontal"
android:layout_marginStart="10dp"
android:layout_marginTop="35dp"
android:textSize="18sp"
android:background="@color/background"
android:textColor="?android:attr/textColorPrimary"
android:id="@+id/codeName"/>

</com.google.android.material.card.MaterialCardView>


<com.google.android.material.card.MaterialCardView
style="@style/Widget.MaterialComponents.CardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="15dp"
android:innerRadius="0dp"
android:layout_marginLeft="@dimen/mtrl_card_spacing"
android:layout_marginTop="@dimen/mtrl_card_spacing"
android:layout_marginRight="@dimen/mtrl_card_spacing"
android:minHeight="70dp"
app:cardBackgroundColor="@color/background"
tools:ignore="PrivateResource">

<TextView
style="?android:attr/listSeparatorTextViewStyle"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textAllCaps="false"
android:textColor="@color/colorAccent"
android:layout_marginTop="5dp"
android:background="@color/background"
android:textSize="19sp"
android:text="@string/build_version"/>


<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="fill_horizontal"
android:layout_marginStart="10dp"
android:layout_marginTop="35dp"
android:textSize="18sp"
android:background="@color/background"
android:textColor="?android:attr/textColorPrimary"
android:id="@+id/buildVersion"/>

</com.google.android.material.card.MaterialCardView>

<androidx.legacy.widget.Space
android:layout_width="match_parent"
android:layout_height="@dimen/mtrl_card_spacing"
tools:ignore="PrivateResource" />


</LinearLayout>

</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 comments on commit 7aa473e

Please sign in to comment.