Skip to content

Commit

Permalink
setting dialog add
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsouviki committed Sep 16, 2020
1 parent e1be0ab commit 2c8e5bc
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
36 changes: 34 additions & 2 deletions app/src/main/java/com/example/rws/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import static com.example.rws.R.layout.navigationcreditdialogview;
import static com.example.rws.R.layout.privacypolicies;
import static com.example.rws.R.layout.savefiledialogue;
import static com.example.rws.R.layout.settingdialog;

public class MainActivity extends AppCompatActivity {

Expand All @@ -48,11 +49,11 @@ public class MainActivity extends AppCompatActivity {
String actualfilepath,filename;
DrawerLayout drawerLayout;
ActionBarDrawerToggle actionBarDrawerToggle;
AlertDialog creditdialog,privacydialog,aboutappdialog,feedbackdialog;
AlertDialog creditdialog,privacydialog,aboutappdialog,feedbackdialog,settingsdialoge;
int[] sampleImages = {R.drawable.enjoy,R.drawable.viewimage1,R.drawable.viewimage2,R.drawable.viewimage3};
ImageListener imageListener;
String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE};
Button sendfeedback;
Button sendfeedback,cleardata;
EditText feedbackmessage;

@Override
Expand All @@ -62,6 +63,27 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setTitle("Read Write & Share");
requestPermissions(permissions,3);

//settingdialogview
AlertDialog.Builder settingbuilder = new AlertDialog.Builder(MainActivity.this);
final LayoutInflater infset = this.getLayoutInflater();
final View settingdialogView = infset.inflate(settingdialog,null);
settingbuilder.setView(settingdialogView);
settingbuilder.setCancelable(true);
settingsdialoge = settingbuilder.create();
cleardata=settingdialogView.findViewById(R.id.clearalldata);
cleardata.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try{
Runtime runtime = Runtime.getRuntime();
runtime.exec("pm clear YOUR_APP_PACKAGE_GOES HERE");
}
catch (Exception e){
e.printStackTrace();
}
}
});

//creditdialogview
AlertDialog.Builder creditbuilder = new AlertDialog.Builder(MainActivity.this);
final LayoutInflater inf = this.getLayoutInflater();
Expand Down Expand Up @@ -167,6 +189,16 @@ public void onClick(DialogInterface dialogInterface, int i) {
feedbackdialog.show();
feedbackdialog.setCancelable(false);
break;
case R.id.settings:
settingsdialoge.setButton(AlertDialog.BUTTON_NEUTRAL, "Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
settingsdialoge.dismiss();
}
});
settingsdialoge.show();
settingsdialoge.setCancelable(false);
break;
}

}
Expand Down
36 changes: 36 additions & 0 deletions app/src/main/res/layout/settingdialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/textView9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Settings"
android:textSize="26dp"
android:textStyle="bold"
android:layout_margin="10dp"
android:textColor="#4073C8"/>

<TextView
android:id="@+id/textView10"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="#000000"
android:layout_margin="10dp"/>

<Button
android:id="@+id/clearalldata"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="10dp"
android:text="Clear all Data"
android:textColor="#FF0000"
android:textAllCaps="false"
android:textAlignment="center"
android:textSize="15dp"
android:backgroundTint="@color/Transparent"/>

</LinearLayout>

0 comments on commit 2c8e5bc

Please sign in to comment.