Skip to content
Snippets Groups Projects
Commit 7e8e859e authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

adjust spacing

parent ccd17053
No related branches found
No related tags found
No related merge requests found
......@@ -193,157 +193,157 @@ public class MainActivity extends Activity{
@Override
protected void onPreExecute() {
_compute = true;
_runStopMenuItem.setTitle(R.string.menu_stop);
super.onPreExecute();
_runStopMenuItem.setTitle(R.string.menu_stop);
super.onPreExecute();
}
@Override
protected Integer[] doInBackground(Void... params) {
_gmsh.onelabCB("compute");
return new Integer[] {1};
}
@Override
protected Integer[] doInBackground(Void... params) {
_gmsh.onelabCB("compute");
return new Integer[] {1};
}
@Override
protected void onPostExecute(Integer[] result) {
//(Vibrator) getSystemService(Context.VIBRATOR_SERVICE).vibrate(350);
_runStopMenuItem.setTitle(R.string.menu_run);
_runStopMenuItem.setEnabled(true);
if(_modelFragment != null) _modelFragment.hideProgress();
_compute = false;
if(_notify) notifyEndComputing();
super.onPostExecute(result);
}
@Override
protected void onPostExecute(Integer[] result) {
//(Vibrator) getSystemService(Context.VIBRATOR_SERVICE).vibrate(350);
_runStopMenuItem.setTitle(R.string.menu_run);
_runStopMenuItem.setEnabled(true);
if(_modelFragment != null) _modelFragment.hideProgress();
_compute = false;
if(_notify) notifyEndComputing();
super.onPostExecute(result);
}
}
private void showError(){
private void showError(){
if(_errors.size()>0){
if(_errorDialog != null && _errorDialog.isShowing()) _errorDialog.dismiss();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle("Gmsh/GetDP Error(s)")
.setMessage(_errors.get(_errors.size()-1))
.setNegativeButton("Hide", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
_errors.clear();
_errorDialog.dismiss();
}
});
if(_errors.size()>1)dialogBuilder.setPositiveButton("Show more", new DialogInterface.OnClickListener() {
if(_errorDialog != null && _errorDialog.isShowing()) _errorDialog.dismiss();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle("Gmsh/GetDP Error(s)")
.setMessage(_errors.get(_errors.size()-1))
.setNegativeButton("Hide", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
_errors.remove(_errors.size()-1);
_errorDialog.dismiss();
showError();
_errors.clear();
_errorDialog.dismiss();
}
});
_errorDialog = dialogBuilder.show();
});
if(_errors.size()>1)dialogBuilder.setPositiveButton("Show more", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
_errors.remove(_errors.size()-1);
_errorDialog.dismiss();
showError();
}
});
_errorDialog = dialogBuilder.show();
}
}
@Override
@Override
protected void onPause() {
if(_compute) notifyComputing();
super.onPause();
_notify = true;
}
if(_compute) notifyComputing();
super.onPause();
_notify = true;
}
@Override
@Override
protected void onResume() {
super.onResume();
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(1337);
_notify = false;
}
super.onResume();
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(1337);
_notify = false;
}
@Override
@Override
protected void onStop() {
super.onStop();
if(_compute) notifyComputing();
_notify = true;
}
super.onStop();
if(_compute) notifyComputing();
_notify = true;
}
@Override
@Override
public void onLowMemory() {
if(!_compute) return;
_gmsh.onelabCB("stop");
Toast.makeText(this, "Low memory! Computation is going to stop", Toast.LENGTH_LONG).show();
super.onLowMemory();
}
if(!_compute) return;
_gmsh.onelabCB("stop");
Toast.makeText(this, "Low memory! Computation is going to stop", Toast.LENGTH_LONG).show();
super.onLowMemory();
}
@Override
@Override
public void onTrimMemory(int level) {
if(!_compute) return;
if(level == Activity.TRIM_MEMORY_COMPLETE){
_gmsh.onelabCB("stop");
notifyEndComputing("The computation had to stop because your device ran out of memory");
_notify = false;
}
else if(level == Activity.TRIM_MEMORY_MODERATE) {
notifyComputing("Computation in progress - low memory", true);
}
super.onTrimMemory(level);
}
if(!_compute) return;
if(level == Activity.TRIM_MEMORY_COMPLETE){
_gmsh.onelabCB("stop");
notifyEndComputing("The computation had to stop because your device ran out of memory");
_notify = false;
}
else if(level == Activity.TRIM_MEMORY_MODERATE) {
notifyComputing("Computation in progress - low memory", true);
}
super.onTrimMemory(level);
}
private void notifyComputing(String msg, boolean alert) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Builder notifyBuilder = new Notification.Builder(this);
notifyBuilder.setContentTitle("ONELAB")
.setContentIntent(pendingIntent)
.setContentText(msg)
.setSmallIcon(R.drawable.ic_launcher)
.setProgress(0, 0, true);
if(alert) notifyBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1337, notifyBuilder.getNotification());
}
private void notifyComputing(String msg, boolean alert) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Builder notifyBuilder = new Notification.Builder(this);
notifyBuilder.setContentTitle("ONELAB")
.setContentIntent(pendingIntent)
.setContentText(msg)
.setSmallIcon(R.drawable.ic_launcher)
.setProgress(0, 0, true);
if(alert) notifyBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1337, notifyBuilder.getNotification());
}
private void notifyComputing() {
notifyComputing("Computation in progress", false);
}
private void notifyComputing() {
notifyComputing("Computation in progress", false);
}
private void notifyEndComputing() {
notifyEndComputing("Computation done!");
}
private void notifyEndComputing() {
notifyEndComputing("Computation done!");
}
private void notifyEndComputing(String msg) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Builder notifyBuilder = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pendingIntent)
.setContentTitle("ONELAB")
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setProgress(0, 0, false)
.setContentText(msg);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1337, notifyBuilder.getNotification());
}
private void notifyEndComputing(String msg) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
Notification.Builder notifyBuilder = new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentIntent(pendingIntent)
.setContentTitle("ONELAB")
.setDefaults(Notification.DEFAULT_ALL)
.setAutoCancel(true)
.setProgress(0, 0, false)
.setContentText(msg);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1337, notifyBuilder.getNotification());
}
private final Handler mainHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
private final Handler mainHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
switch (msg.what) {
case 0: // we get a message from gmsh library
String message =(String) msg.obj;
_errors.add(message);
showError();
break;
case 1: // request render from gmsh library
if(_modelFragment != null) _modelFragment.requestRender();
if(_optionsFragment != null) _optionsFragment.refresh();
break;
case 2: // we get a message for loading
if(_modelFragment != null) _modelFragment.showProgress((String) msg.obj);
break;
case 3: // we get a progress for loading
//loading.setProgress(msg.arg1);
break;
default:
break;
}
};
};
case 0: // we get a message from gmsh library
String message =(String) msg.obj;
_errors.add(message);
showError();
break;
case 1: // request render from gmsh library
if(_modelFragment != null) _modelFragment.requestRender();
if(_optionsFragment != null) _optionsFragment.refresh();
break;
case 2: // we get a message for loading
if(_modelFragment != null) _modelFragment.showProgress((String) msg.obj);
break;
case 3: // we get a progress for loading
//loading.setProgress(msg.arg1);
break;
default:
break;
}
};
};
public boolean isComputing() {return _compute;}
}
......@@ -248,7 +248,7 @@
<rect key="frame" x="14" y="114" width="292" height="434"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Intervals" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="elK-Av-NO2">
<rect key="frame" x="-8" y="202" width="91" height="21"/>
<rect key="frame" x="-8" y="172" width="91" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="91" id="g2R-zm-Dt4"/>
</constraints>
......@@ -257,7 +257,7 @@
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="rgB-dz-6XG">
<rect key="frame" x="91" y="202" width="71" height="30"/>
<rect key="frame" x="91" y="168" width="71" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="71" id="DMh-ns-x7e"/>
</constraints>
......@@ -265,32 +265,32 @@
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Raise (Z)" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bfu-t9-dAj">
<rect key="frame" x="-8" y="251" width="91" height="21"/>
<rect key="frame" x="-8" y="217" width="91" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="-5" maxValue="5" translatesAutoresizingMaskIntoConstraints="NO" id="BC5-E7-rEF">
<rect key="frame" x="89" y="247" width="185" height="31"/>
<rect key="frame" x="89" y="213" width="185" height="31"/>
</slider>
<stepper opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" maximumValue="100" translatesAutoresizingMaskIntoConstraints="NO" id="fq0-E8-V07">
<rect key="frame" x="178" y="202" width="94" height="29"/>
<rect key="frame" x="178" y="168" width="94" height="29"/>
<connections>
<action selector="stepperValueChanged:" destination="pfu-w8-zq5" eventType="valueChanged" id="d8w-ZF-KcK"/>
</connections>
</stepper>
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xW0-cN-kxL">
<rect key="frame" x="17" y="20" width="258" height="162"/>
<rect key="frame" x="17" y="0.0" width="258" height="162"/>
</pickerView>
</subviews>
<constraints>
<constraint firstItem="BC5-E7-rEF" firstAttribute="leading" secondItem="Bfu-t9-dAj" secondAttribute="trailing" constant="8" symbolic="YES" id="171-4w-6wl"/>
<constraint firstItem="Bfu-t9-dAj" firstAttribute="leading" secondItem="elK-Av-NO2" secondAttribute="leading" id="1t0-hf-2Hf"/>
<constraint firstItem="Bfu-t9-dAj" firstAttribute="top" secondItem="elK-Av-NO2" secondAttribute="bottom" constant="28" id="2cz-wD-n92"/>
<constraint firstItem="xW0-cN-kxL" firstAttribute="top" secondItem="h3e-8g-CWy" secondAttribute="top" constant="20" id="6Tb-lU-QwA"/>
<constraint firstItem="elK-Av-NO2" firstAttribute="top" secondItem="xW0-cN-kxL" secondAttribute="bottom" constant="20" id="6dl-PR-DcO"/>
<constraint firstItem="Bfu-t9-dAj" firstAttribute="top" secondItem="elK-Av-NO2" secondAttribute="bottom" constant="24" id="2cz-wD-n92"/>
<constraint firstItem="xW0-cN-kxL" firstAttribute="top" secondItem="h3e-8g-CWy" secondAttribute="top" id="6Tb-lU-QwA"/>
<constraint firstItem="elK-Av-NO2" firstAttribute="top" secondItem="xW0-cN-kxL" secondAttribute="bottom" constant="10" id="6dl-PR-DcO"/>
<constraint firstItem="xW0-cN-kxL" firstAttribute="leading" secondItem="h3e-8g-CWy" secondAttribute="leading" constant="17" id="DQh-yQ-mvn"/>
<constraint firstItem="elK-Av-NO2" firstAttribute="top" secondItem="rgB-dz-6XG" secondAttribute="top" id="HEg-td-wvJ"/>
<constraint firstItem="elK-Av-NO2" firstAttribute="top" secondItem="rgB-dz-6XG" secondAttribute="top" constant="4" id="HEg-td-wvJ"/>
<constraint firstItem="xW0-cN-kxL" firstAttribute="centerX" secondItem="h3e-8g-CWy" secondAttribute="centerX" id="HHR-C5-tPS"/>
<constraint firstAttribute="bottom" secondItem="BC5-E7-rEF" secondAttribute="bottom" constant="136" id="Lwf-Ue-JYj"/>
<constraint firstItem="elK-Av-NO2" firstAttribute="leading" secondItem="h3e-8g-CWy" secondAttribute="leading" constant="-8" id="NO1-74-SYu"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment